Merge "seek expection handling bug" into tizen_2.2
[platform/framework/native/media.git] / src / FMedia_VorbisDecoder.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_VorbisDecoder.h
20  *  @brief  This is the header file for the _VorbisDecoder.
21  *
22  *  This header file contains the declarations of the Tizen::Media::_VorbisDecoder.
23  */
24 #ifndef _FMEDIA_INTERNAL_VORBISDECODER_H_
25 #define _FMEDIA_INTERNAL_VORBISDECODER_H_
26
27 #include "FMedia_IAudioDecoder.h"
28
29 namespace Tizen { namespace Media
30 {
31
32 class _OggStream;
33
34 class _VorbisDecoder
35         : public Tizen::Media::_IAudioDecoder
36 {
37 public:
38         _VorbisDecoder(void);
39
40         virtual ~_VorbisDecoder(void);
41
42 public:
43         virtual result Construct(const Tizen::Base::Collection::HashMap* pOption = null);
44
45         virtual result Probe(const byte* srcBuf, const int length, Tizen::Media::AudioSampleType& sampleType, Tizen::Media::AudioChannelType& channelType, int& sampleRate);
46
47         virtual result Decode(const byte* srcBuf, int srcBufSize, int &srcBufUsed,
48                                                   byte* dstBuf, int dstBufSize, int& dstBufUsed);
49
50         virtual result Reset(void);
51
52         virtual result GetValue(MediaPropertyType type, int& value) const;
53
54         virtual result GetValue(MediaPropertyType type, float& value) const;
55
56         virtual Tizen::Base::Collection::IListT<MediaPropertyType>* GetSupportedPropertyListN(void) const;
57
58         virtual bool IsPropertySupported(MediaPropertyType type) const;
59
60 private:
61         result ParseOggStream(void);
62
63         result SetStreamHeader(void);
64
65         _VorbisDecoder(const _VorbisDecoder&);
66
67         _VorbisDecoder& operator =(const _VorbisDecoder&);
68
69 private:
70         static const int PAGE_SIZE = 4096;
71         static const int DEFAULT_BUFFER_SIZE = 8192 * 2;
72         static const int HEADER_COUNT = 3;
73
74         vorbis_dsp_state __vorbisState;
75         vorbis_info __vorbisInfo;
76         vorbis_comment __vorbisComment;
77         vorbis_block __vorbisBlock;
78         bool __isConstructed;
79         bool __isHeaderDecoded;
80         ogg_sync_state __state;
81         Tizen::Base::Collection::HashMapT<int, _OggStream*> __streamMap;
82         _OggStream* __pStream;
83         byte* __pBuf;
84         int __offset;
85         int __maxOffsetLength;
86         int __serial;
87 };
88
89 } } // Tizen::Media
90
91 #endif // _FMEDIA_INTERNAL_VORBISDECODER_H_