aac

package
v0.37.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AdtsHeaderLength = 7

	AscSamplingFrequencyIndex96000 = 0
	AscSamplingFrequencyIndex88200 = 1
	AscSamplingFrequencyIndex64000 = 2
	AscSamplingFrequencyIndex48000 = 3
	AscSamplingFrequencyIndex44100 = 4
	AscSamplingFrequencyIndex32000 = 5
	AscSamplingFrequencyIndex24000 = 6
	AscSamplingFrequencyIndex22050 = 7
	AscSamplingFrequencyIndex16000 = 8
	AscSamplingFrequencyIndex12000 = 9
	AscSamplingFrequencyIndex11025 = 10
	AscSamplingFrequencyIndex8000  = 11
	AscSamplingFrequencyIndex7350  = 12
)

Variables

Functions

func MakeAscWithAdtsHeader

func MakeAscWithAdtsHeader(adtsHeader []byte) (asc []byte, err error)

MakeAscWithAdtsHeader

@param adtsHeader: 函数调用结束后,内部不持有该内存块

@return asc: 内存块为独立新申请;函数调用结束后,内部不持有该内存块

func MakeAudioDataSeqHeaderWithAdtsHeader

func MakeAudioDataSeqHeaderWithAdtsHeader(adtsHeader []byte) (out []byte, err error)

MakeAudioDataSeqHeaderWithAdtsHeader

@param adtsHeader: 函数调用结束后,内部不持有该内存块

@return out: 内存块为独立新申请;函数调用结束后,内部不持有该内存块

func MakeAudioDataSeqHeaderWithAsc

func MakeAudioDataSeqHeaderWithAsc(asc []byte) (out []byte, err error)

MakeAudioDataSeqHeaderWithAsc

@param asc: 函数调用结束后,内部不持有该内存块

@return out: 内存块为独立新申请;函数调用结束后,内部不持有该内存块

Types

type AdtsHeaderContext

type AdtsHeaderContext struct {
	AscCtx AscContext

	AdtsLength uint16 // 字段中的值,包含了adts header + adts frame
}

func NewAdtsHeaderContext

func NewAdtsHeaderContext(adtsHeader []byte) (*AdtsHeaderContext, error)

func (*AdtsHeaderContext) Unpack

func (ctx *AdtsHeaderContext) Unpack(adtsHeader []byte) error

Unpack

@param adtsHeader: 函数调用结束后,内部不持有该内存块

type AscContext

type AscContext struct {
	AudioObjectType        uint8 // [5b]
	SamplingFrequencyIndex uint8 // [4b]
	ChannelConfiguration   uint8 // [4b]
}

AscContext

<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] 0=96000, 1=88200, 2=64000, 3=48000, 4=44100, 5=32000, 6=24000, 7=22050, 8=16000, 9=12000, 10=11025, 11=11025, 12=7350 channelConfiguration [4b] 1=center front speaker 2=left, right front speakers

func NewAscContext

func NewAscContext(asc []byte) (*AscContext, error)

func (*AscContext) GetSamplingFrequency

func (ascCtx *AscContext) GetSamplingFrequency() (int, error)

func (*AscContext) Pack

func (ascCtx *AscContext) Pack() (asc []byte)

Pack

@return asc: 内存块为独立新申请;函数调用结束后,内部不持有该内存块

func (*AscContext) PackAdtsHeader

func (ascCtx *AscContext) PackAdtsHeader(frameLength int) (out []byte)

PackAdtsHeader

获取ADTS头,由于ADTS头中的字段依赖包的长度,而每个包的长度可能不同,所以每个包的ADTS头都需要独立生成。

@param frameLength: raw aac frame的大小。

注意,如果是rtmp/flv的message/tag,应去除Seq Header头部的2个字节。

@return h: 内存块为独立新申请;函数调用结束后,内部不持有该内存块

func (*AscContext) PackToAdtsHeader

func (ascCtx *AscContext) PackToAdtsHeader(out []byte, frameLength int) error

PackToAdtsHeader

@param out: 函数调用结束后,内部不持有该内存块

func (*AscContext) Unpack

func (ascCtx *AscContext) Unpack(asc []byte) error

Unpack

@param asc: 2字节的AAC Audio Specifc Config。

注意,如果是rtmp/flv的message/tag,应去除Seq Header头部的2个字节。
函数调用结束后,内部不持有该内存块。

type SequenceHeaderContext

type SequenceHeaderContext struct {
	SoundFormat   uint8 // [4b]
	SoundRate     uint8 // [2b]
	SoundSize     uint8 // [1b]
	SoundType     uint8 // [1b]
	AacPacketType uint8 // [8b]
}

SequenceHeaderContext

<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

func (shCtx *SequenceHeaderContext) Unpack(b []byte)

Unpack

@param b: rtmp/flv的message/tag的payload的前2个字节。

函数调用结束后,内部不持有该内存块

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL