19
|
1 |
/*
|
25
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: MMF capabilities mgr
|
|
15 |
*
|
|
16 |
*/
|
19
|
17 |
#include <stdio.h>
|
|
18 |
#include <string.h>
|
25
|
19 |
#include "xammfcapabilitiesmgr.h"
|
19
|
20 |
|
25
|
21 |
static XAresult XAMMFCapabilitiesMgr_GetAudioAACEncoderCapabilities(
|
|
22 |
XACapabilities **ppNode);
|
|
23 |
static XAresult XAMMFCapabilitiesMgr_GetAudioAMREncoderCapabilities(
|
|
24 |
XACapabilities **ppNode);
|
|
25 |
static XAresult XAMMFCapabilitiesMgr_GetAudioPCMEncoderCapabilities(
|
|
26 |
XACapabilities **ppNode);
|
19
|
27 |
|
|
28 |
/* XAresult XAMMFCapabilitiesMgr_UpdateCapabilitieList
|
|
29 |
* Description: Update the capabilities list supported by GStreamer framework.
|
|
30 |
*/
|
|
31 |
XAresult XAMMFCapabilitiesMgr_UpdateCapabilitieList(
|
25
|
32 |
FrameworkMap *frameworkMap, XACapabilities **ppListHead)
|
19
|
33 |
|
25
|
34 |
{
|
19
|
35 |
XAresult res = XA_RESULT_SUCCESS;
|
|
36 |
XACapabilities *lastNode;
|
|
37 |
XACapabilities *firstNode;
|
|
38 |
XACapabilities *newNode = NULL;
|
|
39 |
FWMgrFwType fwtype = FWMgrFWUknown;
|
|
40 |
char *uri = NULL;
|
|
41 |
DEBUG_API("->XAGSTCapabilitiesMgr_UpdateCapabilitieList");
|
|
42 |
|
25
|
43 |
if (!frameworkMap || !ppListHead)
|
|
44 |
{
|
19
|
45 |
res = XA_RESULT_PARAMETER_INVALID;
|
|
46 |
return res;
|
25
|
47 |
}
|
19
|
48 |
|
|
49 |
lastNode = firstNode = *ppListHead;
|
25
|
50 |
|
19
|
51 |
/* traverse and point to the last node in the list */
|
25
|
52 |
while (lastNode && lastNode->next)
|
|
53 |
{
|
19
|
54 |
lastNode = lastNode->next;
|
25
|
55 |
}
|
19
|
56 |
|
|
57 |
uri = "file:///c:/test.mp4";
|
25
|
58 |
fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder);
|
|
59 |
|
|
60 |
if (fwtype == FWMgrFWMMF)
|
|
61 |
{
|
19
|
62 |
/* Add codec capabilities */
|
|
63 |
newNode = NULL;
|
|
64 |
res = XAMMFCapabilitiesMgr_GetAudioAACEncoderCapabilities(&newNode);
|
|
65 |
if (res != XA_RESULT_SUCCESS)
|
|
66 |
{
|
|
67 |
return res;
|
|
68 |
}
|
|
69 |
if (lastNode)
|
25
|
70 |
{
|
19
|
71 |
lastNode->next = newNode;
|
25
|
72 |
}
|
19
|
73 |
if (newNode)
|
25
|
74 |
{ /* if a new node is created move lastNode to the new item */
|
19
|
75 |
if (!firstNode)
|
25
|
76 |
{
|
19
|
77 |
firstNode = newNode;
|
25
|
78 |
}
|
19
|
79 |
lastNode = newNode;
|
25
|
80 |
}
|
19
|
81 |
}
|
|
82 |
|
|
83 |
uri = "file:///c:/test.amr";
|
25
|
84 |
fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder);
|
|
85 |
|
|
86 |
if (fwtype == FWMgrFWMMF)
|
|
87 |
{
|
19
|
88 |
newNode = NULL;
|
|
89 |
res = XAMMFCapabilitiesMgr_GetAudioAMREncoderCapabilities(&newNode);
|
|
90 |
if (res != XA_RESULT_SUCCESS)
|
|
91 |
{
|
|
92 |
return res;
|
|
93 |
}
|
|
94 |
if (lastNode)
|
25
|
95 |
{
|
19
|
96 |
lastNode->next = newNode;
|
25
|
97 |
}
|
19
|
98 |
if (newNode)
|
25
|
99 |
{ /* if a new node is created move lastNode to the new item */
|
19
|
100 |
if (!firstNode)
|
25
|
101 |
{
|
19
|
102 |
firstNode = newNode;
|
25
|
103 |
}
|
19
|
104 |
lastNode = newNode;
|
25
|
105 |
}
|
19
|
106 |
}
|
|
107 |
|
|
108 |
uri = "file:///c:/test.wav";
|
25
|
109 |
fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder);
|
|
110 |
|
|
111 |
if (fwtype == FWMgrFWMMF)
|
|
112 |
{
|
19
|
113 |
newNode = NULL;
|
|
114 |
res = XAMMFCapabilitiesMgr_GetAudioPCMEncoderCapabilities(&newNode);
|
|
115 |
if (res != XA_RESULT_SUCCESS)
|
|
116 |
{
|
|
117 |
return res;
|
|
118 |
}
|
|
119 |
if (lastNode)
|
25
|
120 |
{
|
19
|
121 |
lastNode->next = newNode;
|
25
|
122 |
}
|
19
|
123 |
if (newNode)
|
25
|
124 |
{ /* if a new node is created move lastNode to the new item */
|
19
|
125 |
if (!firstNode)
|
25
|
126 |
{
|
19
|
127 |
firstNode = newNode;
|
25
|
128 |
}
|
19
|
129 |
lastNode = newNode;
|
25
|
130 |
}
|
19
|
131 |
}
|
|
132 |
/* if empty list, then append first node as the head */
|
|
133 |
if (!(*ppListHead))
|
|
134 |
{
|
|
135 |
*ppListHead = firstNode;
|
25
|
136 |
}DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList");
|
19
|
137 |
return res;
|
25
|
138 |
}
|
19
|
139 |
|
25
|
140 |
XAresult XAMMFCapabilitiesMgr_GetAudioAACEncoderCapabilities(
|
|
141 |
XACapabilities **ppNode)
|
|
142 |
{
|
19
|
143 |
XAresult res = XA_RESULT_SUCCESS;
|
|
144 |
XACapabilities *newNode = NULL;
|
|
145 |
XAAudioCodecDescriptor *entries = NULL;
|
|
146 |
|
25
|
147 |
newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
|
19
|
148 |
if (!newNode)
|
25
|
149 |
{
|
19
|
150 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
151 |
return res;
|
25
|
152 |
}
|
19
|
153 |
|
|
154 |
newNode->capsType = AUD_E;
|
|
155 |
newNode->xaid = XA_AUDIOCODEC_AAC;
|
|
156 |
newNode->noOfEntries = 1;
|
|
157 |
|
|
158 |
/* Allocate array */
|
25
|
159 |
entries = (XAAudioCodecDescriptor*) calloc(1,
|
|
160 |
sizeof(XAAudioCodecDescriptor));
|
19
|
161 |
if (!entries)
|
25
|
162 |
{
|
19
|
163 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
164 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
165 |
return res;
|
25
|
166 |
}
|
19
|
167 |
|
25
|
168 |
newNode->pEntry = (void*) entries;
|
|
169 |
|
19
|
170 |
entries->maxChannels = 2;
|
|
171 |
entries->minBitsPerSample = 16;
|
|
172 |
entries->maxBitsPerSample = 16;
|
25
|
173 |
entries->minSampleRate = 8000000; /*milliHz*/
|
19
|
174 |
entries->maxSampleRate = 48000000;
|
25
|
175 |
entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
|
19
|
176 |
entries->numSampleRatesSupported = 7;
|
25
|
177 |
entries->pSampleRatesSupported = (XAmilliHertz*) calloc(
|
|
178 |
entries->numSampleRatesSupported, sizeof(XAmilliHertz));
|
19
|
179 |
if (!entries->pSampleRatesSupported)
|
25
|
180 |
{
|
19
|
181 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
182 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
183 |
return res;
|
25
|
184 |
}
|
19
|
185 |
/* entries in milliHz */
|
|
186 |
entries->pSampleRatesSupported[0] = 8000000;
|
|
187 |
entries->pSampleRatesSupported[1] = 11025000;
|
|
188 |
entries->pSampleRatesSupported[2] = 16000000;
|
|
189 |
entries->pSampleRatesSupported[3] = 22050000;
|
|
190 |
entries->pSampleRatesSupported[4] = 32000000;
|
|
191 |
entries->pSampleRatesSupported[5] = 44100000;
|
|
192 |
entries->pSampleRatesSupported[6] = 48000000;
|
|
193 |
|
|
194 |
entries->minBitRate = 32000;
|
|
195 |
entries->maxBitRate = 256000;
|
|
196 |
entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
|
|
197 |
entries->numBitratesSupported = 8;
|
25
|
198 |
entries->pBitratesSupported = (XAuint32*) calloc(
|
|
199 |
entries->numBitratesSupported, sizeof(XAuint32));
|
19
|
200 |
if (!entries->pBitratesSupported)
|
25
|
201 |
{
|
19
|
202 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
203 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
204 |
return res;
|
25
|
205 |
}
|
19
|
206 |
(entries->pBitratesSupported)[0] = 32000;
|
|
207 |
(entries->pBitratesSupported)[1] = 64000;
|
|
208 |
(entries->pBitratesSupported)[2] = 96000;
|
|
209 |
(entries->pBitratesSupported)[3] = 128000;
|
|
210 |
(entries->pBitratesSupported)[4] = 160000;
|
|
211 |
(entries->pBitratesSupported)[5] = 192000;
|
|
212 |
(entries->pBitratesSupported)[6] = 224000;
|
|
213 |
(entries->pBitratesSupported)[7] = 256000;
|
|
214 |
|
|
215 |
entries->profileSetting = XA_AUDIOPROFILE_AAC_AAC;
|
|
216 |
entries->modeSetting = XA_AUDIOMODE_AAC_LC;
|
|
217 |
|
|
218 |
*ppNode = newNode;
|
|
219 |
return res;
|
25
|
220 |
}
|
19
|
221 |
|
25
|
222 |
XAresult XAMMFCapabilitiesMgr_GetAudioAMREncoderCapabilities(
|
|
223 |
XACapabilities **ppNode)
|
|
224 |
{
|
19
|
225 |
XAresult res = XA_RESULT_SUCCESS;
|
|
226 |
XACapabilities *newNode = NULL;
|
|
227 |
XAAudioCodecDescriptor *entries = NULL;
|
25
|
228 |
|
|
229 |
newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
|
19
|
230 |
if (!newNode)
|
25
|
231 |
{
|
19
|
232 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
233 |
return res;
|
25
|
234 |
}
|
19
|
235 |
|
|
236 |
newNode->capsType = AUD_E;
|
|
237 |
newNode->xaid = XA_AUDIOCODEC_AMR;
|
|
238 |
newNode->noOfEntries = 1;
|
|
239 |
|
|
240 |
/* Allocate array */
|
25
|
241 |
entries = (XAAudioCodecDescriptor*) calloc(1,
|
|
242 |
sizeof(XAAudioCodecDescriptor));
|
19
|
243 |
if (!entries)
|
25
|
244 |
{
|
19
|
245 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
246 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
247 |
return res;
|
25
|
248 |
}
|
19
|
249 |
|
25
|
250 |
newNode->pEntry = (void*) entries;
|
|
251 |
|
19
|
252 |
entries->maxChannels = 1;
|
|
253 |
entries->minBitsPerSample = 8;
|
|
254 |
entries->maxBitsPerSample = 8;
|
25
|
255 |
entries->minSampleRate = 8000000; /*milliHz*/
|
19
|
256 |
entries->maxSampleRate = 8000000;
|
25
|
257 |
entries->isFreqRangeContinuous = XA_BOOLEAN_TRUE;
|
19
|
258 |
entries->numSampleRatesSupported = 1;
|
25
|
259 |
entries->minBitRate = 4750;
|
|
260 |
entries->maxBitRate = 12200;
|
|
261 |
entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
|
19
|
262 |
entries->numBitratesSupported = 8;
|
25
|
263 |
entries->pBitratesSupported = (XAuint32*) calloc(
|
|
264 |
entries->numBitratesSupported, sizeof(XAuint32));
|
19
|
265 |
if (!entries->pBitratesSupported)
|
25
|
266 |
{
|
19
|
267 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
268 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
269 |
return res;
|
25
|
270 |
}
|
19
|
271 |
(entries->pBitratesSupported)[0] = 4750;
|
|
272 |
(entries->pBitratesSupported)[1] = 5150;
|
|
273 |
(entries->pBitratesSupported)[2] = 5900;
|
|
274 |
(entries->pBitratesSupported)[3] = 6700;
|
|
275 |
(entries->pBitratesSupported)[4] = 7400;
|
|
276 |
(entries->pBitratesSupported)[5] = 7950;
|
|
277 |
(entries->pBitratesSupported)[6] = 10200;
|
|
278 |
(entries->pBitratesSupported)[7] = 12200;
|
|
279 |
|
|
280 |
entries->profileSetting = XA_AUDIOPROFILE_AMR;
|
|
281 |
entries->modeSetting = 0;
|
|
282 |
|
|
283 |
*ppNode = newNode;
|
|
284 |
return res;
|
25
|
285 |
}
|
19
|
286 |
|
25
|
287 |
XAresult XAMMFCapabilitiesMgr_GetAudioPCMEncoderCapabilities(
|
|
288 |
XACapabilities **ppNode)
|
|
289 |
{
|
19
|
290 |
XAresult res = XA_RESULT_SUCCESS;
|
|
291 |
XACapabilities *newNode = NULL;
|
|
292 |
XAAudioCodecDescriptor *entries = NULL;
|
|
293 |
|
25
|
294 |
newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities));
|
19
|
295 |
if (!newNode)
|
25
|
296 |
{
|
19
|
297 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
298 |
return res;
|
25
|
299 |
}
|
19
|
300 |
|
|
301 |
newNode->capsType = AUD_E;
|
|
302 |
newNode->xaid = XA_AUDIOCODEC_PCM;
|
|
303 |
newNode->noOfEntries = 1;
|
|
304 |
|
|
305 |
/* Allocate array */
|
25
|
306 |
entries = (XAAudioCodecDescriptor*) calloc(1,
|
|
307 |
sizeof(XAAudioCodecDescriptor));
|
19
|
308 |
if (!entries)
|
25
|
309 |
{
|
19
|
310 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
311 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
312 |
return res;
|
25
|
313 |
}
|
19
|
314 |
|
25
|
315 |
newNode->pEntry = (void*) entries;
|
19
|
316 |
|
|
317 |
entries->maxChannels = 2;
|
|
318 |
entries->minBitsPerSample = 16;
|
|
319 |
entries->maxBitsPerSample = 16;
|
25
|
320 |
entries->minSampleRate = 8000000; /*milliHz*/
|
19
|
321 |
entries->maxSampleRate = 96000000;
|
25
|
322 |
entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
|
19
|
323 |
entries->numSampleRatesSupported = 10;
|
25
|
324 |
entries->pSampleRatesSupported = (XAmilliHertz*) calloc(
|
|
325 |
entries->numSampleRatesSupported, sizeof(XAmilliHertz));
|
19
|
326 |
if (!entries->pSampleRatesSupported)
|
25
|
327 |
{
|
19
|
328 |
res = XA_RESULT_MEMORY_FAILURE;
|
|
329 |
XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
|
|
330 |
return res;
|
25
|
331 |
}
|
19
|
332 |
/* entries in milliHz */
|
|
333 |
entries->pSampleRatesSupported[0] = 12000000;
|
|
334 |
entries->pSampleRatesSupported[1] = 16000000;
|
|
335 |
entries->pSampleRatesSupported[2] = 22050000;
|
|
336 |
entries->pSampleRatesSupported[3] = 24000000;
|
|
337 |
entries->pSampleRatesSupported[4] = 32000000;
|
|
338 |
entries->pSampleRatesSupported[5] = 44100000;
|
|
339 |
entries->pSampleRatesSupported[6] = 48000000;
|
|
340 |
entries->pSampleRatesSupported[7] = 64000000;
|
|
341 |
entries->pSampleRatesSupported[8] = 88200000;
|
|
342 |
entries->pSampleRatesSupported[9] = 96000000;
|
|
343 |
|
|
344 |
entries->minBitRate = 0;
|
|
345 |
entries->maxBitRate = 0;
|
|
346 |
entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
|
|
347 |
entries->pBitratesSupported = NULL;
|
|
348 |
entries->numBitratesSupported = 0;
|
|
349 |
entries->profileSetting = XA_AUDIOPROFILE_PCM;
|
|
350 |
entries->modeSetting = 0;
|
|
351 |
|
|
352 |
*ppNode = newNode;
|
|
353 |
return res;
|
25
|
354 |
}
|