Documentation
¶
Index ¶
- Constants
- Variables
- func AddHook(name string, callback func(interface{}))
- func AddHookWithContext(ctx context.Context, name string, callback func(interface{}))
- func InstallPlugin(opt *PluginConfig)
- func Run(configFile string) (err error)
- func TriggerHook(hook Hook)
- type AudioPack
- type AudioTrack
- type Hook
- type PluginConfig
- type RTPAudio
- type RTPPublisher
- type RTPVideo
- type RingItem_Audio
- type RingItem_Hook
- type RingItem_Video
- type Ring_Audio
- func (r *Ring_Audio) Dispose()
- func (r *Ring_Audio) GetAt(index byte) *RingItem_Audio
- func (r *Ring_Audio) GetBuffer() *bytes.Buffer
- func (r *Ring_Audio) GetLast() *RingItem_Audio
- func (r *Ring_Audio) GetNext() *RingItem_Audio
- func (r *Ring_Audio) GoBack()
- func (r *Ring_Audio) GoNext()
- func (r *Ring_Audio) GoTo(index byte)
- func (r *Ring_Audio) NextR() bool
- func (r *Ring_Audio) NextW()
- func (r *Ring_Audio) SubRing(index byte) *Ring_Audio
- func (r *Ring_Audio) Timeout(t time.Duration) bool
- type Ring_Hook
- func (r *Ring_Hook) GetAt(index byte) *RingItem_Hook
- func (r *Ring_Hook) GetBuffer() *bytes.Buffer
- func (r *Ring_Hook) GetLast() *RingItem_Hook
- func (r *Ring_Hook) GetNext() *RingItem_Hook
- func (r *Ring_Hook) GoBack()
- func (r *Ring_Hook) GoNext()
- func (r *Ring_Hook) GoTo(index byte)
- func (r *Ring_Hook) NextR()
- func (r *Ring_Hook) NextW()
- func (r *Ring_Hook) SubRing(index byte) *Ring_Hook
- func (r *Ring_Hook) Timeout(t time.Duration) bool
- type Ring_Video
- func (r *Ring_Video) Dispose()
- func (r *Ring_Video) GetAt(index byte) *RingItem_Video
- func (r *Ring_Video) GetBuffer() *bytes.Buffer
- func (r *Ring_Video) GetLast() *RingItem_Video
- func (r *Ring_Video) GetNext() *RingItem_Video
- func (r *Ring_Video) GoBack()
- func (r *Ring_Video) GoNext()
- func (r *Ring_Video) GoTo(index byte)
- func (r *Ring_Video) NextR() bool
- func (r *Ring_Video) NextW()
- func (r *Ring_Video) SubRing(index byte) *Ring_Video
- func (r *Ring_Video) Timeout(t time.Duration) bool
- 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 TrackWaiter
- type Track_Audio
- type Track_Video
- type Tracks
- func (ts *Tracks) AddTrack(codec string, t Track)
- func (ts *Tracks) Codecs() (result []string)
- func (ts *Tracks) Dispose()
- func (ts *Tracks) GetTrack(codec string) (tw *TrackWaiter, ok bool)
- func (ts *Tracks) Init()
- func (ts *Tracks) MarshalJSON() ([]byte, error)
- func (ts *Tracks) WaitTrack(codecs ...string) Track
- 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.0.1"
Variables ¶
View Source
var ( // ConfigRaw 配置信息的原始数据 ConfigRaw []byte StartTime time.Time //启动时间 Plugins = make(map[string]*PluginConfig) // Plugins 所有的插件配置 HasTranscoder bool )
View Source
var Hooks = NewRing_Hook()
Functions ¶
func AddHookWithContext ¶
func TriggerHook ¶
func TriggerHook(hook Hook)
Types ¶
type AudioTrack ¶
type AudioTrack struct {
Track_Audio
SoundRate int //2bit
SoundSize byte //1bit
Channels byte //1bit
ExtraData []byte `json:"-"` //rtmp协议需要先发这个帧
PushByteStream func(pack AudioPack) `json:"-"`
PushRaw func(pack AudioPack) `json:"-"`
WriteByteStream func(writer io.Writer, pack AudioPack) `json:"-"` //使用函数写入,避免申请内存
}
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 RingItem_Audio ¶
type RingItem_Hook ¶
type RingItem_Video ¶
type Ring_Audio ¶
type Ring_Audio struct {
Current *RingItem_Audio
Index byte
Flag int32 // 0:不在写入,1:正在写入,2:已销毁
// contains filtered or unexported fields
}
Ring 环形缓冲,使用数组实现
func (*Ring_Audio) Dispose ¶
func (r *Ring_Audio) Dispose()
func (*Ring_Audio) GetBuffer ¶
func (r *Ring_Audio) GetBuffer() *bytes.Buffer
func (*Ring_Audio) SubRing ¶
func (r *Ring_Audio) SubRing(index byte) *Ring_Audio
type Ring_Hook ¶
type Ring_Hook struct {
Current *RingItem_Hook
Index byte
// contains filtered or unexported fields
}
Ring 环形缓冲,使用数组实现
type Ring_Video ¶
type Ring_Video struct {
Current *RingItem_Video
Index byte
Flag int32 // 0:不在写入,1:正在写入,2:已销毁
// contains filtered or unexported fields
}
Ring 环形缓冲,使用数组实现
func (*Ring_Video) Dispose ¶
func (r *Ring_Video) Dispose()
func (*Ring_Video) GetBuffer ¶
func (r *Ring_Video) GetBuffer() *bytes.Buffer
func (*Ring_Video) SubRing ¶
func (r *Ring_Video) SubRing(index byte) *Ring_Video
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:"-"`
// 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:"-"`
ByteStreamFormat bool
// 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 TrackWaiter ¶
func (*TrackWaiter) Dispose ¶
func (tw *TrackWaiter) Dispose()
func (*TrackWaiter) Ok ¶
func (tw *TrackWaiter) Ok(t Track)
func (*TrackWaiter) Wait ¶
func (tw *TrackWaiter) Wait(c chan<- Track)
type Track_Audio ¶
type Track_Audio struct {
Buffer *Ring_Audio `json:"-"`
Stream *Stream `json:"-"`
PacketCount int
CodecID byte
BPS int
// contains filtered or unexported fields
}
func (*Track_Audio) Dispose ¶
func (t *Track_Audio) Dispose()
func (*Track_Audio) GetBPS ¶
func (t *Track_Audio) GetBPS(payloadLen int)
type Track_Video ¶
type Track_Video struct {
Buffer *Ring_Video `json:"-"`
Stream *Stream `json:"-"`
PacketCount int
CodecID byte
BPS int
// contains filtered or unexported fields
}
func (*Track_Video) Dispose ¶
func (t *Track_Video) Dispose()
func (*Track_Video) GetBPS ¶
func (t *Track_Video) GetBPS(payloadLen int)
type Tracks ¶
type Tracks struct {
sync.RWMutex
context.Context `json:"-"`
// contains filtered or unexported fields
}
func (*Tracks) MarshalJSON ¶
type TransCodeReq ¶
type TransCodeReq struct {
*Subscriber
RequestCodec string
}
type VideoPack ¶
type VideoTrack ¶
type VideoTrack struct {
IDRIndex byte //最近的关键帧位置,首屏渲染
Track_Video
SPSInfo codec.SPSInfo
GOP byte //关键帧间隔
ExtraData *VideoPack `json:"-"` //H264(SPS、PPS) H265(VPS、SPS、PPS)
WaitIDR context.Context `json:"-"`
PushByteStream func(pack VideoPack) `json:"-"`
PushNalu func(pack VideoPack) `json:"-"`
WriteByteStream func(writer io.Writer, pack VideoPack) `json:"-"` //使用函数写入,避免申请内存
UsingDonlField bool
// contains filtered or unexported fields
}
func (*VideoTrack) PushAnnexB ¶
func (vt *VideoTrack) PushAnnexB(pack VideoPack)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.