Tizen 2.0 Release
[framework/osp/media.git] / src / FMedia_AlawDecoder.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file   FMedia_AlawDecoder.h
20  * @brief  This is the header file for the Tizen::Media::_AlawDecoder.
21  *
22  * This header file contains the declarations of the Tizen::Media::_AlawDecoder.
23  */
24 #ifndef _FMEDIA_INTERNAL_ALAWDECODER_H_
25 #define _FMEDIA_INTERNAL_ALAWDECODER_H_
26
27
28 namespace Tizen { namespace Media
29 {
30
31 // Generally fiel header + format sub chunk is  36  byte + data chunk header 8 bytes;
32 static const int _MIN_WAVE_HEADER_SIZE = 44;
33 static const unsigned int _RIFF_CHUNK_ID = 0x46464952; // 'RIFF'
34 static const unsigned int _RIFF_FORMAT_WAVE = 0x45564157; // 'WAVE'
35 static const unsigned int _WAVE_FORMAT_CHUNK_ID = 0x20746d66; // 'fmt '
36 static const unsigned int _WAVE_DATA_CHUNK_ID = 0x61746164; // 'data'
37
38 struct _WavFormatInfo
39 {
40         unsigned short formatTag;
41         unsigned short channels;
42         unsigned int samplesPerSec;
43         unsigned int avgBytesPerSec;
44         unsigned short blockAlign;
45         unsigned short bitsPerSample;
46 };
47
48 struct _RiffFileHeader
49 {
50         unsigned int chunkId;
51         unsigned int size;
52         unsigned int format;
53 };
54
55 struct _RiffChunkHeader
56 {
57         unsigned int chunkId;
58         unsigned int size;
59 };
60
61 class _AlawDecoder
62         : public _IAudioDecoder
63 {
64 public:
65         _AlawDecoder(void);
66
67         virtual ~_AlawDecoder(void);
68
69 public:
70         virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
71
72         virtual result Probe(const byte* srcBuf, const int length,
73                                                  AudioSampleType& sampleType, AudioChannelType& channelType, int& sampleRate);
74
75         virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
76                                                   byte* dstBuf, int dstBufSize, int &dstBufUsed);
77
78         virtual result Reset(void);
79
80         virtual result GetValue(MediaPropertyType type, int& value) const;
81
82         virtual result GetValue(MediaPropertyType type, float& value) const;
83
84         virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
85
86         virtual bool IsPropertySupported(MediaPropertyType type) const;
87
88 private:
89         static const int MIN_OUT_BUFFER_SIZE = AVCODEC_MAX_AUDIO_FRAME_SIZE;
90         static const int INPUT_BUFFER_PADDING_SIZE = 8;
91         static const int MONO_CHANNEL = 1;
92         static const int STEREO_CHANNEL = 2;
93
94         _AlawDecoder(const _AlawDecoder&);
95
96         _AlawDecoder& operator =(const _AlawDecoder&);
97
98 private:
99         AVCodecContext* __pCodecCtx;
100         AVCodec* __pCodec;
101         bool __decodeCalled;
102         byte* __pOutBuf;
103         bool __decoderConfigured;
104 };
105
106 } } // Tizen::Media
107
108 #endif // _FMEDIA_INTERNAL_AlawDecoder_H_