Documentation
¶
Index ¶
- Constants
- Variables
- func AddHook(name string, channel chan interface{})
- func AddHookWithContext(name string, channel chan interface{}, ctx context.Context)
- 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() (at *AudioTrack)
- func (r *Stream) AddVideoTrack() (vt *VideoTrack)
- func (r *Stream) Close()
- func (r *Stream) PushAudio(ts uint32, payload []byte)
- func (r *Stream) PushVideo(ts uint32, payload []byte)
- func (r *Stream) Subscribe(s *Subscriber)
- func (r *Stream) UnSubscribe(s *Subscriber)
- type Subscriber
- type SubscriberInfo
- type Track
- type TrackCP
- type Track_Audio
- type Track_Video
- type VideoPack
- type VideoTrack
Constants ¶
View Source
const Version = "3.0.1"
Variables ¶
View Source
var ( // ConfigRaw 配置信息的原始数据 ConfigRaw []byte StartTime time.Time //启动时间 Plugins = make(map[string]*PluginConfig) // Plugins 所有的插件配置 )
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
SoundType byte //1bit
RtmpTag []byte //rtmp协议需要先发这个帧
ASC []byte //audio special configure
}
func (*AudioTrack) Play ¶ added in v3.1.3
func (at *AudioTrack) Play(ctx context.Context, callback func(AudioPack))
func (*AudioTrack) Push ¶
func (at *AudioTrack) Push(timestamp uint32, payload []byte)
Push 来自发布者推送的音频
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 []*VideoTrack
AudioTracks []*AudioTrack
WaitPub chan struct{} `json:"-"` //用于订阅和等待发布者
HasAudio bool
HasVideo bool
EnableVideo *bool
EnableAudio *bool
// contains filtered or unexported fields
}
Stream 流定义
func (*Stream) AddAudioTrack ¶
func (r *Stream) AddAudioTrack() (at *AudioTrack)
func (*Stream) AddVideoTrack ¶
func (r *Stream) AddVideoTrack() (vt *VideoTrack)
type Subscriber ¶
type Subscriber struct {
context.Context
*Stream `json:"-"`
SubscriberInfo
Sign string
OffsetTime uint32
// contains filtered or unexported fields
}
Subscriber 订阅者实体定义
func DeleteSliceItem_Subscriber ¶
func DeleteSliceItem_Subscriber(slice []*Subscriber, item *Subscriber) []*Subscriber
func (*Subscriber) MarshalJSON ¶
func (s *Subscriber) MarshalJSON() ([]byte, error)
func (*Subscriber) Subscribe ¶
func (s *Subscriber) Subscribe(streamPath string) error
Subscribe 开始订阅
type SubscriberInfo ¶
type SubscriberInfo struct {
ID string
TotalDrop int //总丢帧
TotalPacket int
Type string
BufferLength int
Delay uint32
SubscribeTime time.Time
}
SubscriberInfo 订阅者可序列化信息,用于控制台输出
type TrackCP ¶
type TrackCP struct {
Audio *AudioTrack
Video *VideoTrack
}
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 VideoTrack ¶
type VideoTrack struct {
FirstScreen byte //最近的关键帧位置,首屏渲染
Track_Video
SPS []byte
PPS []byte
SPSInfo codec.SPSInfo
GOP byte //关键帧间隔
RtmpTag []byte //rtmp需要先发送一个序列帧,包含SPS和PPS
}
func (*VideoTrack) Play ¶ added in v3.1.3
func (vt *VideoTrack) Play(ctx context.Context, callback func(VideoPack))
func (*VideoTrack) Push ¶
func (vt *VideoTrack) Push(timestamp uint32, payload []byte)
Push 来自发布者推送的视频
Source Files
¶
Click to show internal directories.
Click to hide internal directories.