Tizen 2.0 Release
[framework/osp/media.git] / src / FMedia_CodecFactory.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_CodecFactory.h
20  *  @brief  This is the header file for the _CodecFactory.
21  *
22  *  This header file contains the declarations of the _CodecFactory.
23  */
24
25 #ifndef _FMEDIA_INTERNAL_CODECFACTORY_H_
26 #define _FMEDIA_INTERNAL_CODECFACTORY_H_
27
28 #include <unique_ptr.h>
29
30 namespace Tizen { namespace Media
31 {
32
33 class _IVideoDecoder;
34 class _IVideoEncoder;
35 class _IAudioDecoder;
36 class _IAudioEncoder;
37
38 typedef _IVideoDecoder* (*_VideoDecoderCreateFunc)(void);
39 typedef _IVideoEncoder* (*_VideoEncoderCreateFunc)(void);
40 typedef _IAudioDecoder* (*_AudioDecoderCreateFunc)(void);
41 typedef _IAudioEncoder* (*_AudioEncoderCreateFunc)(void);
42
43 /**
44  * @class  __CodecFactory
45  * @brief  This class is used to create audio or video codec instance.
46  *
47  * This class contains list of __CodecCreator and create codec instance with Codec's request.
48  *
49  */
50 class _CodecFactory
51         : public Tizen::Base::Object
52 {
53 public:
54         /**
55          * Get the global instance of this class.
56          *
57          * @return Global instance of this class.
58          */
59         static _CodecFactory* GetInstance(void);
60
61         /**
62          * Create an instance of Codec with given type.
63          *
64          * @return E_SUCCESS on success, an error code on failure
65          *
66          * @param[in]   codecType               The codec type that want to create
67          * @param[Out]  pVideoDecoder   Reference to the _IVideoDecoder instance
68          *
69          * @exception   E_SUCCESS               This method was successful.
70          * @exception   E_INVALID_ARG   One of input parameter is invalid
71          * @exception   E_SYSTEM                A system error occurred.
72          */
73         result CreateCodecInstance(CodecType codecType, _IVideoDecoder*& pVideoDecoder);
74
75         /**
76          * Create an instance of Codec with given type.
77          *
78          * @return E_SUCCESS on success, an error code on failure
79          *
80          * @param[in]   codecType               The codec type that want to create
81          * @param[Out]  pVideoEncoder   Reference to the _IVideoEncoder instance
82          *
83          * @exception   E_SUCCESS               This method was successful.
84          * @exception   E_INVALID_ARG   One of input parameter is invalid
85          * @exception   E_SYSTEM                A system error occurred.
86          */
87         result CreateCodecInstance(CodecType codecType, _IVideoEncoder*& pVideoEncoder);
88
89         /**
90          * Create an instance of Codec with given type.
91          *
92          * @return E_SUCCESS on success, an error code on failure
93          *
94          * @param[in]   codecType               The codec type that want to create
95          * @param[Out]  pAudioDecoder   Reference to the _IAudioDecoder instance
96          *
97          * @exception   E_SUCCESS               This method was successful.
98          * @exception   E_INVALID_ARG   One of input parameter is invalid
99          * @exception   E_SYSTEM                A system error occurred.
100          */
101         result CreateCodecInstance(CodecType codecType, _IAudioDecoder*& pAudioDecoder);
102
103         /**
104          * Create an instance of Codec with given type.
105          *
106          * @return E_SUCCESS on success, an error code on failure
107          *
108          * @param[in]   codecType               The codec type that want to create
109          * @param[Out]  pAudioEncoder   Reference to the _IAudioEncoder instance
110          *
111          * @exception   E_SUCCESS               This method was successful.
112          * @exception   E_INVALID_ARG   One of input parameter is invalid
113          * @exception   E_SYSTEM                A system error occurred.
114          */
115         result CreateCodecInstance(CodecType codecType, _IAudioEncoder*& pAudioEncoder);
116
117
118         /**
119          * Registers the _IVideoDecoder CreateInstance function.
120          *
121          * @return E_SUCCESS on success, an error code on failure
122          *
123          * @param[in]   codecType               The codec type that want to create
124          * @param[in]   createFunc              The reference to the video encoder  create instance is returned
125          *
126          * @exception   E_SUCCESS               This method was successful.
127          * @exception   E_INVALID_ARG   One of input parameter is invalid
128          * @exception   E_SYSTEM                A system error occurred.
129          */
130         result RegisterCodecCreateFunc(CodecType codecType, _VideoDecoderCreateFunc createFunc);
131
132
133         /**
134          * Retrieves the _IVideoEncoder CreateInstance function.
135          *
136          * @return E_SUCCESS on success, an error code on failure
137          *
138          * @param[in]  codecType                The codec type that want to create
139          * @param[in]  createFunc               The reference to the video encoder  create instance is returned
140          *
141          * @exception  E_SUCCESS                This method was successful.
142          * @exception  E_INVALID_ARG    One of input parameter is invalid
143          * @exception  E_SYSTEM         A system error occurred.
144          */
145         result RegisterCodecCreateFunc(CodecType codecType, _VideoEncoderCreateFunc createFunc);
146
147         /**
148          * Retrieves the _IAudioDecoder CreateInstance function.
149          *
150          * @return E_SUCCESS on success, an error code on failure
151          *
152          * @param[in]   codecType               The codec type that want to create
153          * @param[in]   createFunc              The reference to the audio decoder create instance is returned
154          *
155          * @exception   E_SUCCESS               This method was successful.
156          * @exception   E_INVALID_ARG   One of input parameter is invalid
157          * @exception   E_SYSTEM                A system error occurred.
158          */
159         result RegisterCodecCreateFunc(CodecType codecType, _AudioDecoderCreateFunc createFunc);
160
161         /**
162          * Retrieves the _IAudioEncoder CreateInstance function.
163          *
164          * @return E_SUCCESS on success, an error code on failure
165          *
166          * @param[in]   codecType               The codec type that want to create
167          * @param[in]   createFunc              The reference to the audio encoder create instance is returned
168          *
169          * @exception   E_SUCCESS               This method was successful.
170          * @exception   E_INVALID_ARG   One of input parameter is invalid
171          * @exception   E_SYSTEM                A system error occurred.
172          */
173         result RegisterCodecCreateFunc(CodecType codecType, _AudioEncoderCreateFunc createFunc);
174
175         /**
176          * Registers all availiable codec
177          */
178         result RegisterAllCodec(void);
179
180         /**
181          * Gets supported audio decoder list
182          */
183         Tizen::Base::Collection::IListT<CodecType>* GetSupportedAudioDecoderListN(void);
184
185         /**
186          * Gets supported audio encoder list
187          */
188         Tizen::Base::Collection::IListT<CodecType>* GetSupportedAudioEncoderListN(void);
189
190         /**
191          * Gets supported video decoder list
192          */
193         Tizen::Base::Collection::IListT<CodecType>* GetSupportedVideoDecoderListN(void);
194
195         /**
196          * Gets supported video encoder list
197          */
198         Tizen::Base::Collection::IListT<CodecType>* GetSupportedVideoEncoderListN(void);
199
200 protected:
201         // This constructs the hash maps.
202         result Construct(void);
203
204 private:
205         _CodecFactory(void);
206         virtual ~_CodecFactory(void);
207
208         static void InitSingleton(void);
209         static void DestroySingleton(void);
210
211         static _CodecFactory* __pTheInstance;
212         friend struct std::default_delete<_CodecFactory>;
213         Tizen::Base::Collection::HashMapT<CodecType, _VideoDecoderCreateFunc> __videoDecoderRegister;
214         Tizen::Base::Collection::HashMapT<CodecType, _VideoEncoderCreateFunc> __videoEncoderRegister;
215         Tizen::Base::Collection::HashMapT<CodecType, _AudioDecoderCreateFunc> __audioDecoderRegister;
216         Tizen::Base::Collection::HashMapT<CodecType, _AudioEncoderCreateFunc> __audioEncoderRegister;
217 };
218
219 }} // Tizen::Media
220
221 #endif // _FMEDIA_INTERNAL_CODECFACTORY_H_