Documentation ¶
Index ¶
- Constants
- Variables
- func MakeAscWithAdtsHeader(adtsHeader []byte) (asc []byte, err error)
- func MakeAudioDataSeqHeaderWithAdtsHeader(adtsHeader []byte) (out []byte, err error)
- func MakeAudioDataSeqHeaderWithAsc(asc []byte) (out []byte, err error)
- type AdtsHeaderContext
- type AscContext
- func (ascCtx *AscContext) GetSamplingFrequency() (int, error)
- func (ascCtx *AscContext) Pack() (asc []byte)
- func (ascCtx *AscContext) PackAdtsHeader(frameLength int) (out []byte)
- func (ascCtx *AscContext) PackToAdtsHeader(out []byte, frameLength int) error
- func (ascCtx *AscContext) Unpack(asc []byte) error
- type SequenceHeaderContext
Constants ¶
const ( AdtsHeaderLength = 7 AscSamplingFrequencyIndex48000 = 3 AscSamplingFrequencyIndex44100 = 4 )
Variables ¶
var ErrAac = errors.New("lal.aac: fxxk")
Functions ¶
func MakeAscWithAdtsHeader ¶ added in v0.24.1
@param adtsHeader: 函数调用结束后,内部不持有该内存块
@return asc: 内存块为独立新申请;函数调用结束后,内部不持有该内存块
func MakeAudioDataSeqHeaderWithAdtsHeader ¶ added in v0.24.1
@param adtsHeader: 函数调用结束后,内部不持有该内存块
@return out: 内存块为独立新申请;函数调用结束后,内部不持有该内存块
func MakeAudioDataSeqHeaderWithAsc ¶ added in v0.24.1
@param asc: 函数调用结束后,内部不持有该内存块
@return out: 内存块为独立新申请;函数调用结束后,内部不持有该内存块
Types ¶
type AdtsHeaderContext ¶ added in v0.24.1
type AdtsHeaderContext struct { AscCtx AscContext AdtsLength uint16 // 字段中的值,包含了adts header + adts frame }
func NewAdtsHeaderContext ¶ added in v0.24.1
func NewAdtsHeaderContext(adtsHeader []byte) (*AdtsHeaderContext, error)
func (*AdtsHeaderContext) Unpack ¶ added in v0.24.1
func (ctx *AdtsHeaderContext) Unpack(adtsHeader []byte) error
@param adtsHeader: 函数调用结束后,内部不持有该内存块
type AscContext ¶ added in v0.24.1
type AscContext struct { AudioObjectType uint8 // [5b] SamplingFrequencyIndex uint8 // [4b] ChannelConfiguration uint8 // [4b] }
<ISO_IEC_14496-3.pdf> <1.6.2.1 AudioSpecificConfig>, <page 33/110> <1.5.1.1 Audio Object type definition>, <page 23/110> <1.6.3.3 samplingFrequencyIndex>, <page 35/110> <1.6.3.4 channelConfiguration> -------------------------------------------------------- audio object type [5b] 1=AAC MAIN 2=AAC LC samplingFrequencyIndex [4b] 3=48000 4=44100 6=24000 5=32000 11=11025 channelConfiguration [4b] 1=center front speaker 2=left, right front speakers
func NewAscContext ¶ added in v0.24.1
func NewAscContext(asc []byte) (*AscContext, error)
func (*AscContext) GetSamplingFrequency ¶ added in v0.24.1
func (ascCtx *AscContext) GetSamplingFrequency() (int, error)
func (*AscContext) Pack ¶ added in v0.24.1
func (ascCtx *AscContext) Pack() (asc []byte)
@return asc: 内存块为独立新申请;函数调用结束后,内部不持有该内存块
func (*AscContext) PackAdtsHeader ¶ added in v0.24.1
func (ascCtx *AscContext) PackAdtsHeader(frameLength int) (out []byte)
获取ADTS头,由于ADTS头中的字段依赖包的长度,而每个包的长度可能不同,所以每个包的ADTS头都需要独立生成
@param frameLength: raw aac frame的大小
注意,如果是rtmp/flv的message/tag,应去除Seq Header头部的2个字节
@return h: 内存块为独立新申请;函数调用结束后,内部不持有该内存块
func (*AscContext) PackToAdtsHeader ¶ added in v0.24.1
func (ascCtx *AscContext) PackToAdtsHeader(out []byte, frameLength int) error
@param out: 函数调用结束后,内部不持有该内存块
func (*AscContext) Unpack ¶ added in v0.24.1
func (ascCtx *AscContext) Unpack(asc []byte) error
@param asc: 2字节的AAC Audio Specifc Config
注意,如果是rtmp/flv的message/tag,应去除Seq Header头部的2个字节 函数调用结束后,内部不持有该内存块
type SequenceHeaderContext ¶ added in v0.24.1
type SequenceHeaderContext struct { SoundFormat uint8 // [4b] SoundRate uint8 // [2b] SoundSize uint8 // [1b] SoundType uint8 // [1b] AacPacketType uint8 // [8b] }
<spec-video_file_format_spec_v10.pdf>, <Audio tags, AUDIODATA>, <page 10/48> ---------------------------------------------------------------------------- soundFormat [4b] 10=AAC soundRate [2b] 3=44kHz. AAC always 3 soundSize [1b] 0=snd8Bit, 1=snd16Bit soundType [1b] 0=sndMono, 1=sndStereo. AAC always 1 aacPackageType [8b] 0=seq header, 1=AAC raw
func (*SequenceHeaderContext) Unpack ¶ added in v0.24.1
func (shCtx *SequenceHeaderContext) Unpack(b []byte)
@param b: rtmp/flv的message/tag的payload的前2个字节
函数调用结束后,内部不持有该内存块