Documentation ¶
Index ¶
- Constants
- Variables
- func CalcCrc32(crc uint32, buffer []byte) uint32
- func H264NaluType(h264 []byte) uint8
- func H265NaluType(h265 []byte) uint8
- func SplitFrame(frames []byte, onFrame func(nalu []byte) bool)
- type BitStream
- func (bs *BitStream) Bits() []byte
- func (bs *BitStream) ByteOffset() int
- func (bs *BitStream) DistanceFromMarkDot() int
- func (bs *BitStream) EOS() bool
- func (bs *BitStream) GetBit() uint8
- func (bs *BitStream) GetBits(n int) uint64
- func (bs *BitStream) GetBytes(n int) []byte
- func (bs *BitStream) Markdot()
- func (bs *BitStream) NextBits(n int) uint64
- func (bs *BitStream) ReadSE() int64
- func (bs *BitStream) ReadUE() uint64
- func (bs *BitStream) RemainBits() int
- func (bs *BitStream) RemainBytes() int
- func (bs *BitStream) RemainData() []byte
- func (bs *BitStream) SkipBits(n int)
- func (bs *BitStream) Uint16(n int) uint16
- func (bs *BitStream) Uint32(n int) uint32
- func (bs *BitStream) Uint8(n int) uint8
- func (bs *BitStream) UnRead(n int)
- type BitStreamWriter
- func (bsw *BitStreamWriter) BitOffset() int
- func (bsw *BitStreamWriter) Bits() []byte
- func (bsw *BitStreamWriter) ByteOffset() int
- func (bsw *BitStreamWriter) DistanceFromMarkDot() int
- func (bsw *BitStreamWriter) FillRemainData(v byte)
- func (bsw *BitStreamWriter) Markdot()
- func (bsw *BitStreamWriter) PutByte(v byte)
- func (bsw *BitStreamWriter) PutBytes(v []byte)
- func (bsw *BitStreamWriter) PutRepetValue(v byte, n int)
- func (bsw *BitStreamWriter) PutUint16(v uint16, n int)
- func (bsw *BitStreamWriter) PutUint32(v uint32, n int)
- func (bsw *BitStreamWriter) PutUint64(v uint64, n int)
- func (bsw *BitStreamWriter) PutUint8(v uint8, n int)
- func (bsw *BitStreamWriter) Reset()
- func (bsw *BitStreamWriter) SetByte(v byte, where int)
- func (bsw *BitStreamWriter) SetUint16(v uint16, where int)
- type CommonPesPacket
- type Display
- type ElementaryStream
- type ElementaryStreamElem
- type Error
- type PesPacket
- type PesStreamId
- type ProgramStreamDirectory
- type ProgramStreamMap
- type PsDemuxer
- type PsMuxer
- type PsPackHeader
- type PsPacket
- type PsStreamType
- type StartCodeType
- type SystemHeader
- type TsStreamType
Constants ¶
View Source
const ( CodecUnknown = iota CodecH264 CodecH265 CodecH266 CodecMpeg4 )
Variables ¶
View Source
var BitMask [8]byte = [8]byte{0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}
View Source
var H264AudNalu []byte = []byte{0x00, 0x00, 0x00, 0x01, 0x09, 0xF0} //ffmpeg mpegtsenc.c mpegts_write_packet_internal
View Source
var H265AudNalu []byte = []byte{0x00, 0x00, 0x00, 0x01, 0x46, 0x01, 0x50}
Functions ¶
func H264NaluType ¶
func H265NaluType ¶
func SplitFrame ¶
Types ¶
type BitStream ¶
type BitStream struct {
// contains filtered or unexported fields
}
func NewBitStream ¶
func (*BitStream) ByteOffset ¶
func (*BitStream) DistanceFromMarkDot ¶
func (*BitStream) RemainBits ¶
func (*BitStream) RemainBytes ¶
func (*BitStream) RemainData ¶
type BitStreamWriter ¶
type BitStreamWriter struct {
// contains filtered or unexported fields
}
func NewBitStreamWriter ¶
func NewBitStreamWriter(n int) *BitStreamWriter
func (*BitStreamWriter) BitOffset ¶
func (bsw *BitStreamWriter) BitOffset() int
func (*BitStreamWriter) Bits ¶
func (bsw *BitStreamWriter) Bits() []byte
func (*BitStreamWriter) ByteOffset ¶
func (bsw *BitStreamWriter) ByteOffset() int
func (*BitStreamWriter) DistanceFromMarkDot ¶
func (bsw *BitStreamWriter) DistanceFromMarkDot() int
func (*BitStreamWriter) FillRemainData ¶
func (bsw *BitStreamWriter) FillRemainData(v byte)
用v 填充剩余字节
func (*BitStreamWriter) Markdot ¶
func (bsw *BitStreamWriter) Markdot()
func (*BitStreamWriter) PutByte ¶
func (bsw *BitStreamWriter) PutByte(v byte)
func (*BitStreamWriter) PutBytes ¶
func (bsw *BitStreamWriter) PutBytes(v []byte)
func (*BitStreamWriter) PutRepetValue ¶
func (bsw *BitStreamWriter) PutRepetValue(v byte, n int)
func (*BitStreamWriter) PutUint16 ¶
func (bsw *BitStreamWriter) PutUint16(v uint16, n int)
func (*BitStreamWriter) PutUint32 ¶
func (bsw *BitStreamWriter) PutUint32(v uint32, n int)
func (*BitStreamWriter) PutUint64 ¶
func (bsw *BitStreamWriter) PutUint64(v uint64, n int)
func (*BitStreamWriter) PutUint8 ¶
func (bsw *BitStreamWriter) PutUint8(v uint8, n int)
func (*BitStreamWriter) Reset ¶
func (bsw *BitStreamWriter) Reset()
func (*BitStreamWriter) SetByte ¶
func (bsw *BitStreamWriter) SetByte(v byte, where int)
func (*BitStreamWriter) SetUint16 ¶
func (bsw *BitStreamWriter) SetUint16(v uint16, where int)
type CommonPesPacket ¶
func (*CommonPesPacket) Decode ¶
func (compes *CommonPesPacket) Decode(bs *BitStream) error
type ElementaryStream ¶ added in v0.3.3
type ElementaryStream struct { StreamId uint8 PStdBufferBoundScale uint8 PStdBufferSizeBound uint16 }
func NewElementaryStream ¶ added in v0.3.3
func NewElementaryStream(sid uint8) *ElementaryStream
type ElementaryStreamElem ¶ added in v0.3.3
type ElementaryStreamElem struct { StreamType uint8 ElementaryStreamId uint8 ElementaryStreamInfoLength uint16 }
func NewElementaryStreamElem ¶ added in v0.3.3
func NewElementaryStreamElem(stype uint8, esid uint8) *ElementaryStreamElem
type PesPacket ¶
type PesPacket struct { StreamId uint8 PesPacketLength uint16 PesScramblingControl uint8 PesPriority uint8 DataAlignmentIndicator uint8 Copyright uint8 OriginalOrCopy uint8 PtsDtsFlags uint8 EscrFlag uint8 EsRateFlag uint8 DsmTrickModeFlag uint8 AdditionalCopyInfoFlag uint8 PesCrcFlag uint8 PesExtensionFlag uint8 PesHeaderDataLength uint8 Pts uint64 Dts uint64 EscrBase uint64 EscrExtension uint16 EsRate uint32 TrickModeControl uint8 TrickValue uint8 AdditionalCopyInfo uint8 PreviousPesPacketCrc uint16 PesPayload []byte }
func NewPesPacket ¶
func NewPesPacket() *PesPacket
func (*PesPacket) DecodeMpeg1 ¶
func (*PesPacket) Encode ¶
func (pkg *PesPacket) Encode(bsw *BitStreamWriter)
func (*PesPacket) PrettyPrint ¶
type PesStreamId ¶ added in v0.3.3
type PesStreamId int
const ( PesStreamEnd PesStreamId = 0xB9 PesStreamStart PesStreamId = 0xBA PesStreamSystemHead PesStreamId = 0xBB PesStreamMap PesStreamId = 0xBC PesStreamPrivate PesStreamId = 0xBD PesStreamAudio PesStreamId = 0xC0 PesStreamVideo PesStreamId = 0xE0 )
type ProgramStreamDirectory ¶ added in v0.3.3
type ProgramStreamDirectory struct {
PesPacketLength uint16
}
func (*ProgramStreamDirectory) Decode ¶ added in v0.3.3
func (psd *ProgramStreamDirectory) Decode(bs *BitStream) error
type ProgramStreamMap ¶ added in v0.3.3
type ProgramStreamMap struct { MapStreamId uint8 ProgramStreamMapLength uint16 CurrentNextIndicator uint8 ProgramStreamMapVersion uint8 ProgramStreamInfoLength uint16 ElementaryStreamMapLength uint16 StreamMap []*ElementaryStreamElem }
func (*ProgramStreamMap) Decode ¶ added in v0.3.3
func (psm *ProgramStreamMap) Decode(bs *BitStream) error
func (*ProgramStreamMap) Encode ¶ added in v0.3.3
func (psm *ProgramStreamMap) Encode(bsw *BitStreamWriter)
func (*ProgramStreamMap) PrettyPrint ¶ added in v0.3.3
func (psm *ProgramStreamMap) PrettyPrint(file *os.File)
type PsDemuxer ¶ added in v0.3.3
type PsDemuxer struct { OnFrame func(frame []byte, cid PsStreamType, pts uint64, dts uint64) //解ps包过程中,解码回调psm,system header,pes包等 //decodeResult 解码ps包时的产生的错误 //这个回调主要用于debug,查看是否ps包存在问题 OnPacket func(pkg Display, decodeResult error) // contains filtered or unexported fields }
func NewPsDemuxer ¶ added in v0.3.3
func NewPsDemuxer() *PsDemuxer
type PsMuxer ¶ added in v0.3.3
type PsMuxer struct { OnPacket func(pkg []byte, pts uint64) // contains filtered or unexported fields }
func NewPsMuxer ¶
func NewPsMuxer() *PsMuxer
func (*PsMuxer) AddStream ¶ added in v0.3.3
func (muxer *PsMuxer) AddStream(cid PsStreamType) uint8
type PsPackHeader ¶ added in v0.3.3
type PsPackHeader struct { IsMpeg1 bool SystemClockReferenceBase uint64 //33 bits SystemClockReferenceExtension uint16 //9 bits ProgramMuxRate uint32 //22 bits PackStuffingLength uint8 //3 bitss }
func (*PsPackHeader) Decode ¶ added in v0.3.3
func (psPackHeader *PsPackHeader) Decode(bs *BitStream) error
func (*PsPackHeader) Encode ¶ added in v0.3.3
func (psPackHeader *PsPackHeader) Encode(bsw *BitStreamWriter)
func (*PsPackHeader) PrettyPrint ¶ added in v0.3.3
func (psPackHeader *PsPackHeader) PrettyPrint(file *os.File)
type PsPacket ¶ added in v0.3.3
type PsPacket struct { Header *PsPackHeader System *SystemHeader Psm *ProgramStreamMap Psd *ProgramStreamDirectory CommPes *CommonPesPacket Pes *PesPacket }
type PsStreamType ¶ added in v0.3.3
type PsStreamType int
const ( PsStreamUnknow PsStreamType = 0xFF PsStreamAac PsStreamType = 0x0F PsStreamH264 PsStreamType = 0x1B PsStreamH265 PsStreamType = 0x24 PsStreamG711A PsStreamType = 0x90 PsStreamG711U PsStreamType = 0x91 )
type StartCodeType ¶ added in v0.3.3
type StartCodeType int
const ( StartCode3 StartCodeType = 3 STartCode4 StartCodeType = 4 )
func FindStartCode ¶
func FindStartCode(nalu []byte, offset int) (int, StartCodeType)
type SystemHeader ¶ added in v0.3.3
type SystemHeader struct { HeaderLength uint16 RateBound uint32 AudioBound uint8 FixedFlag uint8 CspsFlag uint8 SystemAudioLockFlag uint8 SystemVideoLockFlag uint8 VideoBound uint8 PacketRateRestrictionFlag uint8 Streams []*ElementaryStream }
func (*SystemHeader) Decode ¶ added in v0.3.3
func (sh *SystemHeader) Decode(bs *BitStream) error
func (*SystemHeader) Encode ¶ added in v0.3.3
func (sh *SystemHeader) Encode(bsw *BitStreamWriter)
func (*SystemHeader) PrettyPrint ¶ added in v0.3.3
func (sh *SystemHeader) PrettyPrint(file *os.File)
type TsStreamType ¶ added in v0.3.3
type TsStreamType int
const ( TsStreamAudioMpeg1 TsStreamType = 0x03 TsStreamAudioMpeg2 TsStreamType = 0x04 TsStreamAac TsStreamType = 0x0F TsStreamH264 TsStreamType = 0x1B TsStreamH265 TsStreamType = 0x24 )
Click to show internal directories.
Click to hide internal directories.