Documentation ¶
Index ¶
- Constants
- Variables
- func PackHttpflvTag(t uint8, timestamp uint32, in []byte) []byte
- type FlvFilePump
- type FlvFilePumpOption
- type FlvFileReader
- type FlvFileWriter
- func (ffw *FlvFileWriter) Dispose() error
- func (ffw *FlvFileWriter) Name() string
- func (ffw *FlvFileWriter) Open(filename string) (err error)
- func (ffw *FlvFileWriter) WriteFlvHeader() (err error)
- func (ffw *FlvFileWriter) WriteRaw(b []byte) (err error)
- func (ffw *FlvFileWriter) WriteTag(tag Tag) (err error)
- type ModFlvFilePumpOption
- type ModPullSessionOption
- type OnPumpFlvTag
- type OnReadFlvTag
- type PullSession
- func (session *PullSession) AppName() string
- func (session *PullSession) Dispose() error
- func (session *PullSession) GetStat() base.StatSession
- func (session *PullSession) IsAlive() (readAlive, writeAlive bool)
- func (session *PullSession) Pull(rawUrl string, onReadFlvTag OnReadFlvTag) error
- func (session *PullSession) RawQuery() string
- func (session *PullSession) StreamName() string
- func (session *PullSession) UniqueKey() string
- func (session *PullSession) UpdateStat(intervalSec uint32)
- func (session *PullSession) Url() string
- func (session *PullSession) WaitChan() <-chan error
- type PullSessionOption
- type SubSession
- func (session *SubSession) AppName() string
- func (session *SubSession) Dispose() error
- func (session *SubSession) GetStat() base.StatSession
- func (session *SubSession) IsAlive() (readAlive, writeAlive bool)
- func (session *SubSession) RawQuery() string
- func (session *SubSession) RunLoop() error
- func (session *SubSession) StreamName() string
- func (session *SubSession) UniqueKey() string
- func (session *SubSession) UpdateStat(intervalSec uint32)
- func (session *SubSession) Url() string
- func (session *SubSession) Write(b []byte)
- func (session *SubSession) WriteFlvHeader()
- func (session *SubSession) WriteHttpResponseHeader()
- func (session *SubSession) WriteTag(tag *Tag)
- type Tag
- func (tag *Tag) IsAacSeqHeader() bool
- func (tag *Tag) IsAvc() bool
- func (tag *Tag) IsAvcKeyNalu() bool
- func (tag *Tag) IsAvcKeySeqHeader() bool
- func (tag *Tag) IsHevc() bool
- func (tag *Tag) IsHevcKeyNalu() bool
- func (tag *Tag) IsHevcKeySeqHeader() bool
- func (tag *Tag) IsMetadata() bool
- func (tag *Tag) IsVideoKeyNalu() bool
- func (tag *Tag) IsVideoKeySeqHeader() bool
- func (tag *Tag) ModTagTimestamp(timestamp uint32)
- func (tag *Tag) Payload() []byte
- type TagHeader
Constants ¶
const ( TagHeaderSize int = 11 PrevTagSizeFieldSize int = 4 )
const ( TagTypeMetadata uint8 = 18 TagTypeVideo uint8 = 9 TagTypeAudio uint8 = 8 )
const ( AvcKeyFrame = frameTypeKey<<4 | codecIdAvc AvcInterFrame = frameTypeInter<<4 | codecIdAvc HevcKeyFrame = frameTypeKey<<4 | codecIdHevc HevcInterFrame = frameTypeInter<<4 | codecIdHevc )
const ( AvcPacketTypeSeqHeader uint8 = 0 AvcPacketTypeNalu uint8 = 1 HevcPacketTypeSeqHeader uint8 = 0 HevcPacketTypeNalu uint8 = 1 AacPacketTypeSeqHeader uint8 = 0 AacPacketTypeRaw uint8 = 1 )
const (
SoundFormatAac uint8 = 10
)
Variables ¶
var ( SubSessionWriteChanSize = 1024 // SubSession发送数据时channel的大小 SubSessionWriteTimeoutMs = 10000 FlvHeader = []byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x00} Log = nazalog.GetGlobalLogger() )
var Clock = mock.NewStdClock()
Functions ¶
Types ¶
type FlvFilePump ¶
type FlvFilePump struct {
// contains filtered or unexported fields
}
func NewFlvFilePump ¶
func NewFlvFilePump(modOptions ...ModFlvFilePumpOption) *FlvFilePump
func (*FlvFilePump) Pump ¶
func (f *FlvFilePump) Pump(filename string, onFlvTag OnPumpFlvTag) error
Pump
@param onFlvTag 如果回调中返回false,则停止Pump
func (*FlvFilePump) PumpWithTags ¶
func (f *FlvFilePump) PumpWithTags(tags []Tag, onFlvTag OnPumpFlvTag) error
PumpWithTags @return error 暂时只做预留,目前只会返回nil
type FlvFilePumpOption ¶
type FlvFilePumpOption struct {
IsRecursive bool // 如果为true,则循环返回文件内容(类似于ffmpeg的-stream_loop -1)
}
FlvFilePumpOption
读取flv文件,将tag按时间戳间隔缓慢(类似于ffmpeg的-re)返回
type FlvFileReader ¶
type FlvFileReader struct {
// contains filtered or unexported fields
}
func (*FlvFileReader) Dispose ¶
func (ffr *FlvFileReader) Dispose()
func (*FlvFileReader) Open ¶
func (ffr *FlvFileReader) Open(filename string) (err error)
func (*FlvFileReader) ReadFlvHeader ¶
func (ffr *FlvFileReader) ReadFlvHeader() ([]byte, error)
func (*FlvFileReader) ReadTag ¶
func (ffr *FlvFileReader) ReadTag() (Tag, error)
type FlvFileWriter ¶
type FlvFileWriter struct {
// contains filtered or unexported fields
}
func (*FlvFileWriter) Dispose ¶
func (ffw *FlvFileWriter) Dispose() error
func (*FlvFileWriter) Name ¶
func (ffw *FlvFileWriter) Name() string
func (*FlvFileWriter) Open ¶
func (ffw *FlvFileWriter) Open(filename string) (err error)
func (*FlvFileWriter) WriteFlvHeader ¶
func (ffw *FlvFileWriter) WriteFlvHeader() (err error)
func (*FlvFileWriter) WriteRaw ¶
func (ffw *FlvFileWriter) WriteRaw(b []byte) (err error)
func (*FlvFileWriter) WriteTag ¶
func (ffw *FlvFileWriter) WriteTag(tag Tag) (err error)
type ModFlvFilePumpOption ¶
type ModFlvFilePumpOption func(option *FlvFilePumpOption)
type ModPullSessionOption ¶
type ModPullSessionOption func(option *PullSessionOption)
type OnPumpFlvTag ¶
type OnReadFlvTag ¶
type OnReadFlvTag func(tag Tag)
OnReadFlvTag @param tag: 底层保证回调上来的Raw数据长度是完整的(但是不会分析Raw内部的编码数据)
type PullSession ¶
type PullSession struct {
// contains filtered or unexported fields
}
func NewPullSession ¶
func NewPullSession(modOptions ...ModPullSessionOption) *PullSession
func (*PullSession) AppName ¶
func (session *PullSession) AppName() string
AppName 文档请参考: interface ISessionUrlContext
func (*PullSession) Dispose ¶
func (session *PullSession) Dispose() error
Dispose 文档请参考: IClientSessionLifecycle interface
func (*PullSession) GetStat ¶
func (session *PullSession) GetStat() base.StatSession
GetStat 文档请参考: interface ISessionStat
func (*PullSession) IsAlive ¶
func (session *PullSession) IsAlive() (readAlive, writeAlive bool)
IsAlive 文档请参考: interface ISessionStat
func (*PullSession) Pull ¶
func (session *PullSession) Pull(rawUrl string, onReadFlvTag OnReadFlvTag) error
Pull 阻塞直到和对端完成拉流前,握手部分的工作,或者发生错误
注意,握手指的是发送完HTTP Request,不包含接收任何数据,因为有的httpflv服务端,如果流不存在不会发送任何内容,此时我们也应该认为是握手完成了
@param rawUrl 支持如下两种格式。(当然,关键点是对端支持)
http://{domain}/{app_name}/{stream_name}.flv http://{ip}/{domain}/{app_name}/{stream_name}.flv
@param onReadFlvTag 读取到 flv tag 数据时回调。回调结束后,PullSession 不会再使用这块 <tag> 数据。
func (*PullSession) RawQuery ¶
func (session *PullSession) RawQuery() string
RawQuery 文档请参考: interface ISessionUrlContext
func (*PullSession) StreamName ¶
func (session *PullSession) StreamName() string
StreamName 文档请参考: interface ISessionUrlContext
func (*PullSession) UniqueKey ¶
func (session *PullSession) UniqueKey() string
UniqueKey 文档请参考: interface IObject
func (*PullSession) UpdateStat ¶
func (session *PullSession) UpdateStat(intervalSec uint32)
UpdateStat 文档请参考: interface ISessionStat
func (*PullSession) Url ¶
func (session *PullSession) Url() string
Url 文档请参考: interface ISessionUrlContext
func (*PullSession) WaitChan ¶
func (session *PullSession) WaitChan() <-chan error
WaitChan 文档请参考: IClientSessionLifecycle interface
type PullSessionOption ¶
type SubSession ¶
type SubSession struct { IsFresh bool ShouldWaitVideoKeyFrame bool // contains filtered or unexported fields }
func NewSubSession ¶
func NewSubSession(conn net.Conn, urlCtx base.UrlContext, isWebSocket bool, websocketKey string) *SubSession
func (*SubSession) AppName ¶
func (session *SubSession) AppName() string
func (*SubSession) Dispose ¶
func (session *SubSession) Dispose() error
func (*SubSession) GetStat ¶
func (session *SubSession) GetStat() base.StatSession
func (*SubSession) IsAlive ¶
func (session *SubSession) IsAlive() (readAlive, writeAlive bool)
func (*SubSession) RawQuery ¶
func (session *SubSession) RawQuery() string
func (*SubSession) RunLoop ¶
func (session *SubSession) RunLoop() error
func (*SubSession) StreamName ¶
func (session *SubSession) StreamName() string
func (*SubSession) UniqueKey ¶
func (session *SubSession) UniqueKey() string
func (*SubSession) UpdateStat ¶
func (session *SubSession) UpdateStat(intervalSec uint32)
func (*SubSession) Url ¶
func (session *SubSession) Url() string
func (*SubSession) Write ¶
func (session *SubSession) Write(b []byte)
func (*SubSession) WriteFlvHeader ¶
func (session *SubSession) WriteFlvHeader()
func (*SubSession) WriteHttpResponseHeader ¶
func (session *SubSession) WriteHttpResponseHeader()
func (*SubSession) WriteTag ¶
func (session *SubSession) WriteTag(tag *Tag)
type Tag ¶
type Tag struct { Header TagHeader Raw []byte // 结构为 (11字节的 tag header) + (body) + (4字节的 prev tag size) }
func ReadAllTagsFromFlvFile ¶
func (*Tag) IsAacSeqHeader ¶
func (*Tag) IsAvcKeyNalu ¶
func (*Tag) IsAvcKeySeqHeader ¶
func (*Tag) IsHevcKeyNalu ¶
func (*Tag) IsHevcKeySeqHeader ¶
func (*Tag) IsMetadata ¶
func (*Tag) IsVideoKeySeqHeader ¶
IsVideoKeySeqHeader AVC或HEVC的seq header