add comments

This commit is contained in:
nareix 2016-07-30 15:03:43 +08:00
parent 0b0eeeefbf
commit 7fc65516ab

View File

@ -76,7 +76,7 @@ func (self SampleFormat) IsPlanar() bool {
} }
} }
// Audio channel layout // Audio channel layout.
type ChannelLayout uint16 type ChannelLayout uint16
func (self ChannelLayout) String() string { func (self ChannelLayout) String() string {
@ -153,13 +153,13 @@ func (self CodecType) IsVideo() bool {
return self&codecTypeAudioBit == 0 return self&codecTypeAudioBit == 0
} }
// Make a new audio codec type // Make a new audio codec type.
func MakeAudioCodecType(base uint32) (c CodecType) { func MakeAudioCodecType(base uint32) (c CodecType) {
c = CodecType(base)<<codecTypeOtherBits | CodecType(codecTypeAudioBit) c = CodecType(base)<<codecTypeOtherBits | CodecType(codecTypeAudioBit)
return return
} }
// Make a new video codec type // Make a new video codec type.
func MakeVideoCodecType(base uint32) (c CodecType) { func MakeVideoCodecType(base uint32) (c CodecType) {
c = CodecType(base) << codecTypeOtherBits c = CodecType(base) << codecTypeOtherBits
return return
@ -172,7 +172,7 @@ const avCodecTypeMagic = 233333
// //
// codecdata.(AudioCodecData) or codecdata.(VideoCodecData) // codecdata.(AudioCodecData) or codecdata.(VideoCodecData)
// //
// for H264, CodecData is AVCDecoderConfigure bytes, includes SPS/PPS // for H264, CodecData is AVCDecoderConfigure bytes, includes SPS/PPS.
type CodecData interface { type CodecData interface {
Type() CodecType // Video/Audio codec type Type() CodecType // Video/Audio codec type
} }
@ -205,7 +205,7 @@ type PacketReader interface {
type Muxer interface { type Muxer interface {
WriteHeader([]CodecData) error // write the file header WriteHeader([]CodecData) error // write the file header
PacketWriter // write compressed audio/video packets PacketWriter // write compressed audio/video packets
WriteTrailer() error // end writing, complete file. can be called only once WriteTrailer() error // finish writing file, this func can be called only once
} }
// Muxer with Close() method // Muxer with Close() method
@ -226,7 +226,7 @@ type DemuxCloser interface {
Close() error Close() error
} }
// Packet stores compressed audio/video data // Packet stores compressed audio/video data.
type Packet struct { type Packet struct {
IsKeyFrame bool // video packet is key frame IsKeyFrame bool // video packet is key frame
Idx int8 // stream index in container format Idx int8 // stream index in container format
@ -235,7 +235,7 @@ type Packet struct {
Data []byte // packet data Data []byte // packet data
} }
// Raw audio frame // Raw audio frame.
type AudioFrame struct { type AudioFrame struct {
SampleFormat SampleFormat // audio sample format, e.g: S16,FLTP,... SampleFormat SampleFormat // audio sample format, e.g: S16,FLTP,...
ChannelLayout ChannelLayout // audio channel layout, e.g: CH_MONO,CH_STEREO,... ChannelLayout ChannelLayout // audio channel layout, e.g: CH_MONO,CH_STEREO,...
@ -248,7 +248,7 @@ func (self AudioFrame) Duration() time.Duration {
return time.Second * time.Duration(self.SampleCount) / time.Duration(self.SampleRate) return time.Second * time.Duration(self.SampleCount) / time.Duration(self.SampleRate)
} }
// Check this audio frame has same format as other audio frame // Check this audio frame has same format as other audio frame.
func (self AudioFrame) HasSameFormat(other AudioFrame) bool { func (self AudioFrame) HasSameFormat(other AudioFrame) bool {
if self.SampleRate != other.SampleRate { if self.SampleRate != other.SampleRate {
return false return false
@ -262,7 +262,7 @@ func (self AudioFrame) HasSameFormat(other AudioFrame) bool {
return true return true
} }
// Split sample audio sample from this frame // Split sample audio sample from this frame.
func (self AudioFrame) Slice(start int, end int) (out AudioFrame) { func (self AudioFrame) Slice(start int, end int) (out AudioFrame) {
out = self out = self
out.Data = append([][]byte(nil), out.Data...) out.Data = append([][]byte(nil), out.Data...)
@ -274,7 +274,7 @@ func (self AudioFrame) Slice(start int, end int) (out AudioFrame) {
return return
} }
// Concat two audio frames // Concat two audio frames.
func (self AudioFrame) Concat(in AudioFrame) (out AudioFrame) { func (self AudioFrame) Concat(in AudioFrame) (out AudioFrame) {
out = self out = self
out.Data = append([][]byte(nil), out.Data...) out.Data = append([][]byte(nil), out.Data...)
@ -306,7 +306,7 @@ type AudioDecoder interface {
Close() // close decode, free cgo contexts Close() // close decode, free cgo contexts
} }
// AudioResampler can convert raw audio frames in different sample rate/format/channel layout // AudioResampler can convert raw audio frames in different sample rate/format/channel layout.
type AudioResampler interface { type AudioResampler interface {
Resample(AudioFrame) (AudioFrame, error) // convert raw audio frames Resample(AudioFrame) (AudioFrame, error) // convert raw audio frames
} }