• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 /**
19  * @file pvaenodefactoryutility.h
20  * PVAuthorEngine Node Factory Utility for single core builds
21  */
22 
23 #ifndef PVAE_NODE_FACTORY_UTILITY_H_INCLUDED
24 #define PVAE_NODE_FACTORY_UTILITY_H_INCLUDED
25 
26 #ifndef OSCL_BASE_H_INCLUDED
27 #include "oscl_base.h"
28 #endif
29 #ifndef OSCL_STRING_H_INCLUDED
30 #include "oscl_string.h"
31 #endif
32 #ifndef PVAUTHORENGINE_H_INCLUDED
33 #include "pvauthorengine.h"
34 #endif
35 #ifndef PVMP4FFCN_FACTORY_H_INCLUDED
36 #include "pvmp4ffcn_factory.h"
37 #endif
38 #ifndef PVMF_FILEOUTPUT_FACTORY_H_INCLUDED
39 #include "pvmf_fileoutput_factory.h"
40 #endif
41 #ifndef PVMP4FFCN_CLIPCONFIG_H_INCLUDED
42 #include "pvmp4ffcn_clipconfig.h"
43 #endif
44 #ifndef PVMP4FFCN_TRACKCONFIG_H_INCLUDED
45 #include "pvmp4ffcn_trackconfig.h"
46 #endif
47 #ifndef PVMF_FILEOUTPUT_CONFIG_H_INCLUDED
48 #include "pvmf_fileoutput_config.h"
49 #endif
50 #ifndef PV_MP4_H263_ENC_EXTENSION_H_INCLUDED
51 #include "pvmp4h263encextension.h"
52 #endif
53 #ifndef PVMF_AUDIO_ENCNODE_EXTENSION_H_INCLUDED
54 #include "pvmf_audio_encnode_extension.h"
55 #endif
56 
57 #if USE_OMX_ENC_NODE
58 
59 #ifndef PVMF_OMX_ENC_FACTORY_H_INCLUDED
60 #include "pvmf_omx_enc_factory.h"
61 #endif
62 
63 #else
64 
65 #ifndef PVMFAVCENCNODE_FACTORY_H_INCLUDED
66 #include "pvmf_avcenc_node_factory.h"
67 #endif
68 #ifndef PVMF_VIDEOENC_NODE_FACTORY_H_INCLUDED
69 #include "pvmf_videoenc_node_factory.h"
70 #endif
71 #ifndef PVMF_AMRENC_NODE_FACTORY_H_INCLUDED
72 #include "pvmf_amrenc_node_factory.h"
73 #endif
74 #endif
75 
76 class PVAuthorEngineNodeFactoryUtility
77 {
78     public:
CreateEncoder(const PVUuid & aUuid)79         static PVMFNodeInterface* CreateEncoder(const PVUuid& aUuid)
80         {
81             PVMFNodeInterface* node = NULL;
82 #if USE_OMX_ENC_NODE
83             if (aUuid == KPVMFOMXVideoEncNodeUuid)
84             {
85                 node = PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode();
86             }
87             else if (aUuid == KPVMFOMXAudioEncNodeUuid)
88             {
89                 node = PVMFOMXEncNodeFactory::CreatePVMFOMXEncNode();
90             }
91 #else
92 
93             if (aUuid == PVMFVideoEncNodeUuid)
94             {
95                 node = PVMFVideoEncNodeFactory::CreateVideoEncNode();
96             }
97             else if (aUuid == PvmfAmrEncNodeUuid)
98             {
99                 node = PvmfAmrEncNodeFactory::Create();
100             }
101             else if (aUuid == PVMFAvcEncNodeUuid)
102             {
103                 node = PVMFAvcEncNodeFactory::CreateAvcEncNode();
104             }
105 #endif
106             return node;
107         }
108 
CreateComposer(const PVUuid & aUuid)109         static PVMFNodeInterface* CreateComposer(const PVUuid& aUuid)
110         {
111             PVMFNodeInterface* node = NULL;
112             if (aUuid == KPVMp4FFComposerNodeUuid)
113             {
114                 node = PVMp4FFComposerNodeFactory::CreateMp4FFComposer();
115             }
116             else if (aUuid == KPVFileOutputNodeUuid)
117             {
118                 node = PVFileOutputNodeFactory::CreateFileOutput();
119             }
120 
121             return node;
122         }
123 
Delete(const PVUuid & aUuid,PVMFNodeInterface * aNode)124         static bool Delete(const PVUuid& aUuid, PVMFNodeInterface* aNode)
125         {
126             if (!aNode)
127                 return false;
128 
129 #if USE_OMX_ENC_NODE
130             else if (aUuid == KPVMFOMXVideoEncNodeUuid)
131             {
132                 return PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(aNode);
133             }
134             else if (aUuid == KPVMFOMXAudioEncNodeUuid)
135             {
136                 return PVMFOMXEncNodeFactory::DeletePVMFOMXEncNode(aNode);
137             }
138 #else
139             if (aUuid == PVMFVideoEncNodeUuid)
140             {
141                 return PVMFVideoEncNodeFactory::DeleteVideoEncNode(aNode);
142             }
143             else if (aUuid == PVMFAvcEncNodeUuid)
144             {
145                 return PVMFAvcEncNodeFactory::DeleteAvcEncNode(aNode);
146             }
147             else if (aUuid == PvmfAmrEncNodeUuid)
148             {
149                 return PvmfAmrEncNodeFactory::Delete(aNode);
150             }
151 #endif
152             else if (aUuid == KPVMp4FFComposerNodeUuid)
153             {
154                 return PVMp4FFComposerNodeFactory::DeleteMp4FFComposer(aNode);
155             }
156             else if (aUuid == KPVFileOutputNodeUuid)
157             {
158                 return PVFileOutputNodeFactory::DeleteFileOutput(aNode);
159             }
160             return false;
161         }
162 
QueryRegistry(const PvmfMimeString & aMimeType,PVUuid & aUuid)163         static bool QueryRegistry(const PvmfMimeString& aMimeType, PVUuid& aUuid)
164         {
165             if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(K3gpComposerMimeType)) ||
166                     CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KMP4ComposerMimeType)))
167             {
168                 aUuid = KPVMp4FFComposerNodeUuid;
169             }
170             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KMp4EncMimeType)) ||
171                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KH263EncMimeType)))
172             {
173 #if USE_OMX_ENC_NODE
174                 // replace mp4/h263 encoder node with omx encoder node
175                 aUuid = KPVMFOMXVideoEncNodeUuid;
176 #else
177                 aUuid = PVMFVideoEncNodeUuid;
178 #endif
179             }
180             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KH264EncMimeType)))
181             {
182 #if USE_OMX_ENC_NODE
183                 // replace avc encoder node with omx encoder node
184                 aUuid = KPVMFOMXVideoEncNodeUuid;
185 #else
186                 aUuid = PVMFAvcEncNodeUuid;
187 #endif
188 
189             }
190             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAmrNbEncMimeType)))
191             {
192 #if USE_OMX_ENC_NODE
193                 // replace amr encoder node with omx encoder node
194                 aUuid = KPVMFOMXAudioEncNodeUuid;
195 #else
196                 aUuid = PvmfAmrEncNodeUuid;
197 #endif
198             }
199 #if USE_OMX_ENC_NODE
200             // aac encoding is supported only under OMX node
201             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACADIFEncMimeType)) ||
202                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACADTSEncMimeType)) ||
203                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACMP4EncMimeType))  ||
204                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAMRWbEncMimeType)))
205             {
206                 aUuid = KPVMFOMXAudioEncNodeUuid;
207             }
208 #endif
209             else if (CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAMRNbComposerMimeType)) ||
210                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAMRWbComposerMimeType)) ||
211                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACADIFComposerMimeType)) ||
212                      CompareMimeTypes(aMimeType, OSCL_HeapString<OsclMemAllocator>(KAACADTSComposerMimeType)))
213             {
214                 aUuid = KPVFileOutputNodeUuid;
215             }
216             else
217             {
218                 return false;
219             }
220 
221             return true;
222         }
223 
QueryNodeConfigUuid(const PVUuid & aNodeUuid,PVUuid & aConfigUuid)224         static bool QueryNodeConfigUuid(const PVUuid& aNodeUuid, PVUuid& aConfigUuid)
225         {
226             bool status = false;
227 
228             if (aNodeUuid == KPVMp4FFComposerNodeUuid)
229             {
230                 aConfigUuid = KPVMp4FFCNClipConfigUuid;
231                 status = true;
232             }
233             else if (aNodeUuid == KPVFileOutputNodeUuid)
234             {
235                 aConfigUuid = PvmfFileOutputNodeConfigUuid;
236                 status = true;
237             }
238 #if USE_OMX_ENC_NODE
239             else if (aNodeUuid == KPVMFOMXVideoEncNodeUuid)
240             {
241                 aConfigUuid = PVMp4H263EncExtensionUUID;
242                 status = true;
243             }
244             else if (aNodeUuid == KPVMFOMXAudioEncNodeUuid)
245             {
246                 aConfigUuid = PVAudioEncExtensionUUID;
247                 status = true;
248             }
249 #else
250             else if ((aNodeUuid == PVMFVideoEncNodeUuid) ||
251                      (aNodeUuid == PVMFAvcEncNodeUuid))
252             {
253                 aConfigUuid = PVMp4H263EncExtensionUUID;
254                 status = true;
255             }
256             else if (aNodeUuid == PvmfAmrEncNodeUuid)
257             {
258                 aConfigUuid = PVAudioEncExtensionUUID;
259                 status = true;
260             }
261 #endif
262             ////////////////////////////////////////////////////////////////////////////
263             // When implementing support for a new file format composer or encoder node,
264             // add code to return config uuid of the new node here if necessary
265             ////////////////////////////////////////////////////////////////////////////
266 
267             return status;
268         }
269 
CompareMimeTypes(const PvmfMimeString & a,const PvmfMimeString & b)270         static bool CompareMimeTypes(const PvmfMimeString& a, const PvmfMimeString& b)
271         {
272             return (oscl_strncmp(a.get_cstr(), b.get_cstr(), oscl_strlen(a.get_cstr())) == 0);
273         }
274 
275 };
276 
277 #endif // PVAE_NODE_FACTORY_UTILITY_H_INCLUDED
278