From 58acf9ee66009d50e95827df7402eff78b61c824 Mon Sep 17 00:00:00 2001 From: nareix Date: Wed, 8 Jun 2016 14:41:32 +0800 Subject: [PATCH] add codec.go --- codec.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 codec.go diff --git a/codec.go b/codec.go new file mode 100644 index 0000000..d4eb2db --- /dev/null +++ b/codec.go @@ -0,0 +1,46 @@ +package codec + +import ( + "github.com/nareix/av" +) + +type AudioCodecData struct { + CodecType int + CodecSampleRate int + CodecChannelLayout av.ChannelLayout + CodecSampleFormat av.SampleFormat +} + +func (self AudioCodecData) Type() int { + return self.CodecType +} + +func (self AudioCodecData) IsAudio() bool { + return true +} + +func (self AudioCodecData) IsVideo() bool { + return false +} + +func (self AudioCodecData) SampleRate() int { + return self.CodecSampleRate +} + +func (self AudioCodecData) ChannelLayout() av.ChannelLayout { + return self.CodecChannelLayout +} + +func (self AudioCodecData) SampleFormat() av.SampleFormat { + return self.CodecSampleFormat +} + +func NewPCMMulawCodecData() av.AudioCodecData { + return AudioCodecData{ + CodecType: av.PCM_MULAW, + CodecSampleFormat: av.S16, + CodecChannelLayout: av.CH_MONO, + CodecSampleRate: 8000, + } +} +