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 Publisher
- type RingItem_Audio
- type RingItem_Hook
- type RingItem_Video
- type Ring_Audio
- 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()
- 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) 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()
- 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 (r *Stream) AddAudioTrack(codec string, at *AudioTrack) *AudioTrack
- func (r *Stream) AddVideoTrack(codec string, vt *VideoTrack) *VideoTrack
- func (r *Stream) Close()
- func (r *Stream) SetOriginAT(at *AudioTrack)
- func (r *Stream) SetOriginVT(vt *VideoTrack)
- func (r *Stream) Subscribe(s *Subscriber)
- func (r *Stream) UnSubscribe(s *Subscriber)
- type Subscriber
- func (s *Subscriber) Close()
- func (s *Subscriber) GetAudioTrack(codecs ...string) (at *AudioTrack)
- func (s *Subscriber) GetVideoTrack(codec string) *VideoTrack
- func (s *Subscriber) IsClosed() bool
- func (s *Subscriber) Play(at *AudioTrack, vt *VideoTrack)
- func (s *Subscriber) PlayAudio(at *AudioTrack)
- func (s *Subscriber) PlayVideo(vt *VideoTrack)
- func (s *Subscriber) Subscribe(streamPath string) error
- func (s *Subscriber) WaitAudioTrack(codecs ...string) *AudioTrack
- func (s *Subscriber) WaitVideoTrack(codec string) *VideoTrack
- type TSSlice
- type Track
- type TrackWaiter
- type Track_Audio
- type Track_Video
- 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()
View Source
var Streams sync.Map
Streams 所有的流集合
Functions ¶
func AddHookWithContext ¶
func TriggerHook ¶
func TriggerHook(hook Hook)
Types ¶
type AudioTrack ¶
type AudioTrack struct {
Track_Audio
SoundFormat byte //4bit
SoundRate int //2bit
SoundSize byte //1bit
Channels byte //1bit
RtmpTag []byte //rtmp协议需要先发这个帧
}
func NewAudioTrack ¶
func NewAudioTrack() *AudioTrack
func (*AudioTrack) Push ¶
func (at *AudioTrack) Push(timestamp uint32, payload []byte)
Push 来自发布者推送的音频
func (*AudioTrack) PushRTP ¶
func (at *AudioTrack) PushRTP(pack rtp.Packet)
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 Publisher ¶
type Publisher struct {
context.Context
AutoUnPublish bool // 当无人订阅时自动停止发布
*Stream `json:"-"`
Type string //类型,用来区分不同的发布者
// contains filtered or unexported fields
}
Publisher 发布者实体定义
type RingItem_Audio ¶
type RingItem_Hook ¶
type RingItem_Video ¶
type Ring_Audio ¶
type Ring_Audio struct {
Current *RingItem_Audio
Index byte
// contains filtered or unexported fields
}
Ring 环形缓冲,使用数组实现
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
// contains filtered or unexported fields
}
Ring 环形缓冲,使用数组实现
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
StreamPath string
StartTime time.Time //流的创建时间
*Publisher
Subscribers []*Subscriber // 订阅者
VideoTracks sync.Map
AudioTracks sync.Map
OriginVideoTrack *VideoTrack //原始视频轨
OriginAudioTrack *AudioTrack //原始音频轨
// contains filtered or unexported fields
}
Stream 流定义
func (*Stream) AddAudioTrack ¶
func (r *Stream) AddAudioTrack(codec string, at *AudioTrack) *AudioTrack
func (*Stream) AddVideoTrack ¶
func (r *Stream) AddVideoTrack(codec string, vt *VideoTrack) *VideoTrack
func (*Stream) SetOriginAT ¶
func (r *Stream) SetOriginAT(at *AudioTrack)
func (*Stream) SetOriginVT ¶
func (r *Stream) SetOriginVT(vt *VideoTrack)
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
Sign string
OffsetTime uint32
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) GetAudioTrack ¶
func (s *Subscriber) GetAudioTrack(codecs ...string) (at *AudioTrack)
func (*Subscriber) GetVideoTrack ¶
func (s *Subscriber) GetVideoTrack(codec string) *VideoTrack
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关联
func (*Subscriber) WaitAudioTrack ¶
func (s *Subscriber) WaitAudioTrack(codecs ...string) *AudioTrack
func (*Subscriber) WaitVideoTrack ¶
func (s *Subscriber) WaitVideoTrack(codec string) *VideoTrack
type TrackWaiter ¶
func (*TrackWaiter) Ok ¶
func (tw *TrackWaiter) Ok(t Track)
type Track_Audio ¶
type Track_Audio struct {
Buffer *Ring_Audio `json:"-"`
PacketCount int
CodecID byte
BPS int
// contains filtered or unexported fields
}
func (*Track_Audio) GetBPS ¶
func (t *Track_Audio) GetBPS(payloadLen int)
type Track_Video ¶
type Track_Video struct {
Buffer *Ring_Video `json:"-"`
PacketCount int
CodecID byte
BPS int
// contains filtered or unexported fields
}
func (*Track_Video) GetBPS ¶
func (t *Track_Video) GetBPS(payloadLen int)
type TransCodeReq ¶
type TransCodeReq struct {
*Subscriber
RequestCodec string
}
type VideoPack ¶
type VideoTrack ¶
type VideoTrack struct {
IDRIndex byte //最近的关键帧位置,首屏渲染
Track_Video
SPS []byte `json:"-"`
PPS []byte `json:"-"`
SPSInfo codec.SPSInfo
GOP byte //关键帧间隔
RtmpTag []byte `json:"-"` //rtmp需要先发送一个序列帧,包含SPS和PPS
WaitIDR context.Context `json:"-"`
// contains filtered or unexported fields
}
func NewVideoTrack ¶
func NewVideoTrack() *VideoTrack
func (*VideoTrack) PushRTP ¶
func (vt *VideoTrack) PushRTP(pack rtp.Packet)
func (*VideoTrack) SetRtmpTag ¶
func (vt *VideoTrack) SetRtmpTag()
Source Files
¶
Click to show internal directories.
Click to hide internal directories.