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