Documentation
¶
Index ¶
- Constants
- Variables
- func AddHook(name string, callback interface{})
- func AddHookWithContext(ctx context.Context, name string, callback interface{})
- func AddHooks(hooks map[string]interface{})
- func InstallPlugin(opt *PluginConfig)
- func Run(configFile string) (err error)
- func TriggerHook(name string, payload ...interface{})
- type AVPack
- type AudioPack
- type AudioTrack
- type BasePack
- type PluginConfig
- type RTPAudio
- type RTPPublisher
- type RTPVideo
- type RingBuffer
- func (rb RingBuffer) Clone() *RingBuffer
- func (r *RingBuffer) Current() *RingItem
- func (r *RingBuffer) CurrentValue() interface{}
- func (r *RingBuffer) GetNext() *RingItem
- func (r *RingBuffer) Init(n int)
- func (r *RingBuffer) MoveNext()
- func (r *RingBuffer) NextValue() interface{}
- func (r *RingBuffer) Read() interface{}
- func (r *RingBuffer) SubRing(rr *ring.Ring) *RingBuffer
- func (r *RingBuffer) Write(value interface{})
- type RingDisposable
- type RingItem
- type Stream
- func (s *Stream) NewAudioTrack(codec byte) (at *AudioTrack)
- func (s *Stream) NewRTPAudio(codec byte) (r *RTPAudio)
- func (s *Stream) NewRTPVideo(codec byte) (r *RTPVideo)
- func (s *Stream) NewVideoTrack(codec byte) (vt *VideoTrack)
- func (r *Stream) Publish() bool
- func (r *Stream) Subscribe(s *Subscriber)
- func (r *Stream) UnSubscribe(s *Subscriber)
- func (r *Stream) Update()
- func (r *Stream) WaitAudioTrack(codecs ...string) *AudioTrack
- func (r *Stream) WaitVideoTrack(codecs ...string) *VideoTrack
- type StreamCollection
- type Subscriber
- type TSSlice
- type Track
- type Track_Base
- type Tracks
- type TransCodeReq
- type VideoPack
- type VideoTrack
Constants ¶
View Source
const ( HOOK_SUBSCRIBE = "Subscribe" HOOK_UNSUBSCRIBE = "UnSubscibe" HOOK_STREAMCLOSE = "StreamClose" HOOK_PUBLISH = "Publish" HOOK_REQUEST_TRANSAUDIO = "RequestTransAudio" )
View Source
const Version = "3.1.6"
Variables ¶
View Source
var ( // ConfigRaw 配置信息的原始数据 ConfigRaw []byte StartTime time.Time //启动时间 Plugins = make(map[string]*PluginConfig) // Plugins 所有的插件配置 HasTranscoder bool )
View Source
var Hooks = make(map[string]*RingBuffer)
Functions ¶
func AddHookWithContext ¶
func TriggerHook ¶
func TriggerHook(name string, payload ...interface{})
Types ¶
type AudioTrack ¶
type AudioTrack struct {
Track_Base
SoundRate int //2bit
SoundSize byte //1bit
Channels byte //1bit
ExtraData []byte `json:"-"` //rtmp协议需要先发这个帧
PushByteStream func(ts uint32, payload []byte) `json:"-"`
PushRaw func(ts uint32, payload []byte) `json:"-"`
// contains filtered or unexported fields
}
func (*AudioTrack) Play ¶ added in v3.1.3
func (at *AudioTrack) Play(ctx context.Context, onAudio func(AudioPack))
func (*AudioTrack) SetASC ¶
func (at *AudioTrack) SetASC(asc []byte)
type PluginConfig ¶
type PluginConfig struct {
Name string //插件名称
Config interface{} //插件配置
Version string //插件版本
Dir string //插件代码路径
Run func() //插件启动函数
HotConfig map[string]func(interface{}) //热修改配置
}
PluginConfig 插件配置定义
type RTPAudio ¶
type RTPAudio struct {
RTPPublisher
*AudioTrack
}
type RTPPublisher ¶
type RTPVideo ¶
type RTPVideo struct {
RTPPublisher
*VideoTrack
}
type RingBuffer ¶ added in v3.1.0
func NewRingBuffer ¶ added in v3.1.0
func NewRingBuffer(n int) (r *RingBuffer)
func (RingBuffer) Clone ¶ added in v3.1.0
func (rb RingBuffer) Clone() *RingBuffer
func (*RingBuffer) Current ¶ added in v3.1.0
func (r *RingBuffer) Current() *RingItem
func (*RingBuffer) CurrentValue ¶ added in v3.1.0
func (r *RingBuffer) CurrentValue() interface{}
func (*RingBuffer) GetNext ¶ added in v3.1.0
func (r *RingBuffer) GetNext() *RingItem
func (*RingBuffer) Init ¶ added in v3.1.0
func (r *RingBuffer) Init(n int)
func (*RingBuffer) MoveNext ¶ added in v3.1.0
func (r *RingBuffer) MoveNext()
func (*RingBuffer) NextValue ¶ added in v3.1.0
func (r *RingBuffer) NextValue() interface{}
func (*RingBuffer) Read ¶ added in v3.1.0
func (r *RingBuffer) Read() interface{}
func (*RingBuffer) SubRing ¶ added in v3.1.0
func (r *RingBuffer) SubRing(rr *ring.Ring) *RingBuffer
func (*RingBuffer) Write ¶ added in v3.1.0
func (r *RingBuffer) Write(value interface{})
type RingDisposable ¶ added in v3.1.0
type RingDisposable struct {
RingBuffer
Flag int32 // 0:不在写入,1:正在写入,2:已销毁
}
可释放的Ring,用于音视频
func (*RingDisposable) Dispose ¶ added in v3.1.0
func (r *RingDisposable) Dispose()
func (*RingDisposable) Step ¶ added in v3.1.0
func (r *RingDisposable) Step()
func (*RingDisposable) Write ¶ added in v3.1.0
func (r *RingDisposable) Write(value interface{})
type Stream ¶
type Stream struct {
context.Context `json:"-"`
StreamPath string
Type string //流类型,来自发布者
StartTime time.Time //流的创建时间
Subscribers []*Subscriber // 订阅者
VideoTracks Tracks
AudioTracks Tracks
AutoUnPublish bool // 当无人订阅时自动停止发布
Transcoding map[string]string //转码配置,key:目标编码,value:发布者提供的编码
Close func() `json:"-"`
ExtraProp interface{} //额外的属性,用于实现子类化,减少map的使用
// contains filtered or unexported fields
}
Stream 流定义
func (*Stream) NewAudioTrack ¶
func (s *Stream) NewAudioTrack(codec byte) (at *AudioTrack)
func (*Stream) NewRTPAudio ¶
func (*Stream) NewRTPVideo ¶
func (*Stream) NewVideoTrack ¶
func (s *Stream) NewVideoTrack(codec byte) (vt *VideoTrack)
func (*Stream) WaitAudioTrack ¶
func (r *Stream) WaitAudioTrack(codecs ...string) *AudioTrack
TODO: 触发转码逻辑
func (*Stream) WaitVideoTrack ¶
func (r *Stream) WaitVideoTrack(codecs ...string) *VideoTrack
type StreamCollection ¶
var Streams StreamCollection
Streams 所有的流集合
func (*StreamCollection) Delete ¶
func (sc *StreamCollection) Delete(streamPath string)
func (*StreamCollection) GetStream ¶
func (sc *StreamCollection) GetStream(streamPath string) *Stream
func (*StreamCollection) ToList ¶
func (sc *StreamCollection) ToList() (r []*Stream)
type Subscriber ¶
type Subscriber struct {
context.Context `json:"-"`
Ctx2 context.Context `json:"-"`
*Stream `json:"-"`
ID string
TotalDrop int //总丢帧
TotalPacket int
Type string
BufferLength int
Delay uint32
SubscribeTime time.Time
SubscribeArgs url.Values
OnAudio func(pack AudioPack) `json:"-"`
OnVideo func(pack VideoPack) `json:"-"`
// contains filtered or unexported fields
}
Subscriber 订阅者实体定义
func DeleteSliceItem_Subscriber ¶
func DeleteSliceItem_Subscriber(slice []*Subscriber, item *Subscriber) ([]*Subscriber, bool)
func (*Subscriber) PlayAudio ¶
func (s *Subscriber) PlayAudio(at *AudioTrack)
func (*Subscriber) PlayVideo ¶
func (s *Subscriber) PlayVideo(vt *VideoTrack)
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe(streamPath string) error
Subscribe 开始订阅 将Subscriber与Stream关联
type Track_Base ¶ added in v3.1.0
type Track_Base struct {
RingDisposable `json:"-"`
Stream *Stream `json:"-"`
PacketCount int
CodecID byte
BPS int
// contains filtered or unexported fields
}
func (*Track_Base) GetBPS ¶ added in v3.1.0
func (t *Track_Base) GetBPS()
type Tracks ¶
type Tracks struct {
RingDisposable
context.Context
sync.RWMutex
// contains filtered or unexported fields
}
func (*Tracks) MarshalJSON ¶
type TransCodeReq ¶
type TransCodeReq struct {
*Subscriber
RequestCodec string
}
type VideoTrack ¶
type VideoTrack struct {
IDRing *ring.Ring //最近的关键帧位置,首屏渲染
Track_Base
SPSInfo codec.SPSInfo
GOP int //关键帧间隔
ExtraData *VideoPack `json:"-"` //H264(SPS、PPS) H265(VPS、SPS、PPS)
WaitIDR context.Context `json:"-"`
PushByteStream func(ts uint32, payload []byte) `json:"-"`
PushNalu func(ts uint32, cts uint32, nalus ...[]byte) `json:"-"`
UsingDonlField bool
// contains filtered or unexported fields
}
func (*VideoTrack) Play ¶ added in v3.1.3
func (vt *VideoTrack) Play(ctx context.Context, onVideo func(VideoPack))
func (*VideoTrack) PushAnnexB ¶
func (vt *VideoTrack) PushAnnexB(ts uint32, cts uint32, payload []byte)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.