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 Elementary_Stream
- type Elementary_stream_elem
- type Error
- type PES_STREMA_ID
- type PSDemuxer
- type PSMuxer
- type PSPackHeader
- type PSPacket
- type PS_STREAM_TYPE
- type PesPacket
- type Program_stream_directory
- type Program_stream_map
- type START_CODE_TYPE
- type System_header
- type TS_STREAM_TYPE
Constants ¶
View Source
const ( PsPackStartCodePackHeader = 0x01ba PsPackStartCodeSystemHeader = 0x01bb PsPackStartCodeProgramStreamMap = 0x01bc PsPackStartCodeAudioStream = 0x01c0 PsPackStartCodeVideoStream = 0x01e0 PsPackStartCodeHikStream = 0x01bd PsPackStartCodePesPsd = 0x01ff // program_stream_directory PsPackStartCodePesPadding = 0x01be // padding_stream PsPackStartCodePesPrivate2 = 0x01bf // padding_stream_2 PsPackStartCodePesEcm = 0x01f0 // ECM_stream PsPackStartCodePesEmm = 0x01f1 // EMM_stream PsPackStartCodePackEnd = 0x01b9 )
View Source
const ( StreamTypeH264 uint8 = 0x1b StreamTypeH265 = 0x24 StreamTypeAAC = 0x0f StreamTypeG711A = 0x90 //PCMA StreamTypeG7221 = 0x92 StreamTypeG7231 = 0x93 StreamTypeG729 = 0x99 StreamTypeUnknown = 0 )
View Source
const ( PsHeaderlen int = 14 SysHeaderlen int = 18 SysMapHeaderLen int = 24 PesHeaderLen int = 19 )
View Source
const ( MaxPesLen = 0xFFFF // 64k pes data MaxPesPayloadLen = MaxPesLen - PesHeaderLen + 5 // 64k pes data )
View Source
const ( StreamIdVideo = 0xe0 StreamIdAudio = 0xc0 )
Variables ¶
View Source
var BitMask [8]byte = [8]byte{0x01, 0x03, 0x07, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF}
View Source
var ErrGb28181 = errors.New("tops.gb28181: fxxk")
View Source
var H264_AUD_NALU []byte = []byte{0x00, 0x00, 0x00, 0x01, 0x09, 0xF0} //ffmpeg mpegtsenc.c mpegts_write_packet_internal
View Source
var H265_AUD_NALU []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 Elementary_Stream ¶
type Elementary_Stream struct { Stream_id uint8 P_STD_buffer_bound_scale uint8 P_STD_buffer_size_bound uint16 }
func NewElementary_Stream ¶
func NewElementary_Stream(sid uint8) *Elementary_Stream
type Elementary_stream_elem ¶
type Elementary_stream_elem struct { Stream_type uint8 Elementary_stream_id uint8 Elementary_stream_info_length uint16 }
func NewElementary_stream_elem ¶
func NewElementary_stream_elem(stype uint8, esid uint8) *Elementary_stream_elem
type PES_STREMA_ID ¶
type PES_STREMA_ID int
const ( PES_STREAM_END PES_STREMA_ID = 0xB9 PES_STREAM_START PES_STREMA_ID = 0xBA PES_STREAM_SYSTEM_HEAD PES_STREMA_ID = 0xBB PES_STREAM_MAP PES_STREMA_ID = 0xBC PES_STREAM_PRIVATE PES_STREMA_ID = 0xBD PES_STREAM_AUDIO PES_STREMA_ID = 0xC0 PES_STREAM_VIDEO PES_STREMA_ID = 0xE0 )
type PSDemuxer ¶
type PSDemuxer struct { OnFrame func(frame []byte, cid PS_STREAM_TYPE, 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 ¶
func NewPSDemuxer() *PSDemuxer
type PSMuxer ¶
type PSMuxer struct { OnPacket func(pkg []byte, pts uint64) // contains filtered or unexported fields }
func NewPsMuxer ¶
func NewPsMuxer() *PSMuxer
func (*PSMuxer) AddStream ¶
func (muxer *PSMuxer) AddStream(cid PS_STREAM_TYPE) uint8
type PSPackHeader ¶
type PSPackHeader struct { IsMpeg1 bool System_clock_reference_base uint64 //33 bits System_clock_reference_extension uint16 //9 bits Program_mux_rate uint32 //22 bits Pack_stuffing_length uint8 //3 bitss }
func (*PSPackHeader) Decode ¶
func (ps_pkg_hdr *PSPackHeader) Decode(bs *BitStream) error
func (*PSPackHeader) Encode ¶
func (ps_pkg_hdr *PSPackHeader) Encode(bsw *BitStreamWriter)
func (*PSPackHeader) PrettyPrint ¶
func (ps_pkg_hdr *PSPackHeader) PrettyPrint(file *os.File)
type PSPacket ¶
type PSPacket struct { Header *PSPackHeader System *System_header Psm *Program_stream_map Psd *Program_stream_directory CommPes *CommonPesPacket Pes *PesPacket }
type PS_STREAM_TYPE ¶
type PS_STREAM_TYPE int
const ( PS_STREAM_UNKNOW PS_STREAM_TYPE = 0xFF PS_STREAM_AAC PS_STREAM_TYPE = 0x0F PS_STREAM_H264 PS_STREAM_TYPE = 0x1B PS_STREAM_H265 PS_STREAM_TYPE = 0x24 PS_STREAM_G711A PS_STREAM_TYPE = 0x90 PS_STREAM_G711U PS_STREAM_TYPE = 0x91 )
type PesPacket ¶
type PesPacket struct { Stream_id uint8 PES_packet_length uint16 PES_scrambling_control uint8 PES_priority uint8 Data_alignment_indicator uint8 Copyright uint8 Original_or_copy uint8 PTS_DTS_flags uint8 ESCR_flag uint8 ES_rate_flag uint8 DSM_trick_mode_flag uint8 Additional_copy_info_flag uint8 PES_CRC_flag uint8 PES_extension_flag uint8 PES_header_data_length uint8 Pts uint64 Dts uint64 ESCR_base uint64 ESCR_extension uint16 ES_rate uint32 Trick_mode_control uint8 Trick_value uint8 Additional_copy_info uint8 Previous_PES_packet_CRC uint16 Pes_payload []byte }
func NewPesPacket ¶
func NewPesPacket() *PesPacket
func (*PesPacket) DecodeMpeg1 ¶
func (*PesPacket) Encode ¶
func (pkg *PesPacket) Encode(bsw *BitStreamWriter)
func (*PesPacket) PrettyPrint ¶
type Program_stream_directory ¶
type Program_stream_directory struct {
PES_packet_length uint16
}
func (*Program_stream_directory) Decode ¶
func (psd *Program_stream_directory) Decode(bs *BitStream) error
type Program_stream_map ¶
type Program_stream_map struct { Map_stream_id uint8 Program_stream_map_length uint16 Current_next_indicator uint8 Program_stream_map_version uint8 Program_stream_info_length uint16 Elementary_stream_map_length uint16 Stream_map []*Elementary_stream_elem }
func (*Program_stream_map) Decode ¶
func (psm *Program_stream_map) Decode(bs *BitStream) error
func (*Program_stream_map) Encode ¶
func (psm *Program_stream_map) Encode(bsw *BitStreamWriter)
func (*Program_stream_map) PrettyPrint ¶
func (psm *Program_stream_map) PrettyPrint(file *os.File)
type START_CODE_TYPE ¶
type START_CODE_TYPE int
const ( START_CODE_3 START_CODE_TYPE = 3 START_CODE_4 START_CODE_TYPE = 4 )
func FindStartCode ¶
func FindStartCode(nalu []byte, offset int) (int, START_CODE_TYPE)
type System_header ¶
type System_header struct { Header_length uint16 Rate_bound uint32 Audio_bound uint8 Fixed_flag uint8 CSPS_flag uint8 System_audio_lock_flag uint8 System_video_lock_flag uint8 Video_bound uint8 Packet_rate_restriction_flag uint8 Streams []*Elementary_Stream }
func (*System_header) Decode ¶
func (sh *System_header) Decode(bs *BitStream) error
func (*System_header) Encode ¶
func (sh *System_header) Encode(bsw *BitStreamWriter)
func (*System_header) PrettyPrint ¶
func (sh *System_header) PrettyPrint(file *os.File)
type TS_STREAM_TYPE ¶
type TS_STREAM_TYPE int
const ( TS_STREAM_AUDIO_MPEG1 TS_STREAM_TYPE = 0x03 TS_STREAM_AUDIO_MPEG2 TS_STREAM_TYPE = 0x04 TS_STREAM_AAC TS_STREAM_TYPE = 0x0F TS_STREAM_H264 TS_STREAM_TYPE = 0x1B TS_STREAM_H265 TS_STREAM_TYPE = 0x24 )
Click to show internal directories.
Click to hide internal directories.