17 */ |
17 */ |
18 |
18 |
19 #include <stdio.h> |
19 #include <stdio.h> |
20 #include <string.h> |
20 #include <string.h> |
21 #include <strings.h> |
21 #include <strings.h> |
22 #include <gst/gst.h> |
|
23 #include <gobject_global.h> |
|
24 |
22 |
25 #include "xagstcapabilitiesmgr.h" |
23 #include "xagstcapabilitiesmgr.h" |
26 #include "xaframeworkmgr.h" |
24 #include "xaframeworkmgr.h" |
27 |
25 |
28 static XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
26 static XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
29 XACapabilities **ppNode); |
27 XACapabilities **ppNode); |
30 static XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
28 static XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
31 XACapabilities **ppNode); |
29 XACapabilities **ppNode); |
32 static XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
30 static XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
33 XACapabilities **ppNode); |
31 XACapabilities **ppNode); |
34 static XAresult XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement( |
32 |
35 XAAudioCodecDescriptor **entries, XAuint32 type); |
33 /* XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList( |
36 |
34 * FrameworkMap *frameworkMap, XACapabilities **ppListHead) |
37 /* XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList |
35 * Description: Append capabilities supported by Gstreamer framework. |
38 * Description: Update the capabilities list supported by GStreamer framework. |
|
39 */ |
36 */ |
40 static gboolean populate_field(GQuark field, const GValue * value, |
|
41 gpointer pfx) |
|
42 { |
|
43 gchar *field_name; |
|
44 gpointer *pfxd = (gpointer*) pfx; |
|
45 XAAudioCodecDescriptor *ctxx = (XAAudioCodecDescriptor *) pfxd; |
|
46 |
|
47 field_name = (gchar*) g_quark_to_string(field); |
|
48 |
|
49 if ((strcasecmp((const char*) field_name, "channels") == 0)) |
|
50 { |
|
51 if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE) |
|
52 { |
|
53 (ctxx)->maxChannels = gst_value_get_int_range_max(value); |
|
54 } |
|
55 else |
|
56 (ctxx)->maxChannels = g_value_get_int(value); |
|
57 } |
|
58 if ((strcasecmp((const char*) field_name, "depth") == 0)) |
|
59 { |
|
60 if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE) |
|
61 { |
|
62 (ctxx)->minBitsPerSample = gst_value_get_int_range_min(value); |
|
63 } |
|
64 else |
|
65 (ctxx)->minBitsPerSample = g_value_get_int(value); |
|
66 } |
|
67 if ((strcasecmp((const char*) field_name, "bitrate") == 0)) |
|
68 { |
|
69 if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE) |
|
70 { |
|
71 (ctxx)->minBitRate = gst_value_get_int_range_min(value); |
|
72 (ctxx)->maxBitRate = gst_value_get_int_range_max(value); |
|
73 } |
|
74 else |
|
75 { |
|
76 (ctxx)->minBitRate = g_value_get_int(value); |
|
77 (ctxx)->maxBitRate = g_value_get_int(value); |
|
78 } |
|
79 } |
|
80 if ((strcasecmp((const char*) field_name, "width") == 0)) |
|
81 { |
|
82 if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE) |
|
83 { |
|
84 (ctxx)->maxBitsPerSample = gst_value_get_int_range_max(value); |
|
85 } |
|
86 else |
|
87 (ctxx)->maxBitsPerSample = g_value_get_int(value); |
|
88 } |
|
89 if ((strcasecmp((const char*) field_name, "rate") == 0)) |
|
90 { |
|
91 if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE) |
|
92 { |
|
93 (ctxx)->minSampleRate = gst_value_get_int_range_min(value) * 1000; |
|
94 (ctxx)->maxSampleRate = gst_value_get_int_range_max(value) * 1000; |
|
95 } |
|
96 else |
|
97 { |
|
98 (ctxx)->minSampleRate = g_value_get_int(value) * 1000; |
|
99 (ctxx)->maxSampleRate = g_value_get_int(value) * 1000; |
|
100 } |
|
101 } |
|
102 |
|
103 return TRUE; |
|
104 } |
|
105 |
|
106 XAresult XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement( |
|
107 XAAudioCodecDescriptor **entries, XAuint32 type) |
|
108 { |
|
109 int i = 0; |
|
110 GstElement *element = NULL; |
|
111 GstPad *elementpad = NULL; |
|
112 GstCaps *elementcaps = NULL; |
|
113 GstStructure *s = NULL; |
|
114 GParamSpec *elementproperty; |
|
115 GParamSpecInt *pint; |
|
116 GParamSpecEnum *penum; |
|
117 gchar *findamr = "\0"; |
|
118 gpointer *myentries; |
|
119 |
|
120 |
|
121 if (type == XA_AUDIOCODEC_AAC) |
|
122 { |
|
123 element = gst_element_factory_make("nokiaaacenc", "encoderelement"); |
|
124 if (element) |
|
125 { |
|
126 elementpad = gst_element_get_static_pad(element, "sink"); |
|
127 if (!elementpad) |
|
128 { |
|
129 DEBUG_ERR("no pad found for AAC Encoder"); |
|
130 return XA_RESULT_INTERNAL_ERROR; |
|
131 } |
|
132 elementcaps = gst_pad_get_caps(elementpad); |
|
133 s = gst_caps_get_structure(elementcaps, 0); |
|
134 |
|
135 myentries = (gpointer*) *entries; |
|
136 gst_structure_foreach(s, populate_field, (gpointer) myentries); |
|
137 |
|
138 elementproperty = g_object_class_find_property( |
|
139 G_OBJECT_GET_CLASS (element), "bitrate"); |
|
140 if (elementproperty) |
|
141 { |
|
142 pint = G_PARAM_SPEC_INT (elementproperty); |
|
143 (*entries)->minBitRate = pint->minimum; |
|
144 (*entries)->maxBitRate = pint->maximum; |
|
145 } |
|
146 elementproperty = g_object_class_find_property( |
|
147 G_OBJECT_GET_CLASS (element), "profile"); |
|
148 if (elementproperty) |
|
149 { |
|
150 penum = G_PARAM_SPEC_ENUM(elementproperty); |
|
151 (*entries)->modeSetting = penum->default_value; |
|
152 } |
|
153 |
|
154 (*entries)->profileSetting = XA_AUDIOPROFILE_AAC_AAC; |
|
155 (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE; |
|
156 (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE; |
|
157 } |
|
158 else |
|
159 { |
|
160 DEBUG_ERR("failed to get the AACencoder element"); |
|
161 } |
|
162 } |
|
163 else if (type == XA_AUDIOCODEC_AMR) |
|
164 { |
|
165 element = gst_element_factory_make("devsoundsrc", "encoderelement"); |
|
166 if (element) |
|
167 { |
|
168 elementpad = gst_element_get_pad(element, "src"); |
|
169 if (!elementpad) |
|
170 { |
|
171 DEBUG_ERR("no source pad for Devsound(amr) element"); |
|
172 return XA_RESULT_INTERNAL_ERROR; |
|
173 } |
|
174 |
|
175 elementcaps = gst_pad_get_caps(elementpad); |
|
176 while (!(strcasecmp(findamr, "audio/amr") == 0) && i |
|
177 < elementcaps->structs->len) |
|
178 { |
|
179 s = gst_caps_get_structure(elementcaps, i); |
|
180 findamr = (char*) gst_structure_get_name(s); |
|
181 i++; |
|
182 } |
|
183 |
|
184 //populating the Other Values |
|
185 myentries = (gpointer*) *entries; |
|
186 gst_structure_foreach(s, populate_field, (gpointer) myentries); |
|
187 |
|
188 elementproperty = g_object_class_find_property( |
|
189 G_OBJECT_GET_CLASS (element), "speechbitrate"); |
|
190 if (elementproperty) |
|
191 { |
|
192 pint = G_PARAM_SPEC_INT (elementproperty); |
|
193 (*entries)->minBitRate = pint->minimum; |
|
194 (*entries)->maxBitRate = pint->maximum; |
|
195 } |
|
196 |
|
197 (*entries)->profileSetting = XA_AUDIOPROFILE_AMR; |
|
198 (*entries)->modeSetting = 0; |
|
199 (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE; |
|
200 (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE; |
|
201 |
|
202 } |
|
203 else |
|
204 { |
|
205 DEBUG_ERR("failed to get the Devsoundsrc(amr encoder) element"); |
|
206 } |
|
207 } |
|
208 |
|
209 else if (type == XA_AUDIOCODEC_PCM) |
|
210 { |
|
211 element = gst_element_factory_make("wavenc", "encoderelement"); |
|
212 if (element) |
|
213 { |
|
214 elementpad = gst_element_get_pad(element, "sink"); |
|
215 if (!elementpad) |
|
216 { |
|
217 DEBUG_ERR("failed to get Sink pad on Wave encoder element"); |
|
218 return XA_RESULT_INTERNAL_ERROR; |
|
219 } |
|
220 elementcaps = gst_pad_get_caps(elementpad); |
|
221 s = gst_caps_get_structure(elementcaps, 2); |
|
222 myentries = (gpointer*) *entries; |
|
223 gst_structure_foreach(s, populate_field, (gpointer) myentries); |
|
224 elementproperty = g_object_class_find_property( |
|
225 G_OBJECT_GET_CLASS (element), "bitrate"); |
|
226 if (elementproperty) |
|
227 { |
|
228 pint = G_PARAM_SPEC_INT (elementproperty); |
|
229 (*entries)->minBitRate = pint->minimum; |
|
230 (*entries)->maxBitRate = pint->maximum; |
|
231 } |
|
232 |
|
233 (*entries)->profileSetting = XA_AUDIOPROFILE_PCM; |
|
234 (*entries)->modeSetting = 0; |
|
235 (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE; |
|
236 (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE; |
|
237 } |
|
238 else |
|
239 { |
|
240 DEBUG_ERR("failed to get the wavencoder element"); |
|
241 } |
|
242 } |
|
243 |
|
244 if (elementcaps != NULL) |
|
245 gst_caps_unref(elementcaps); |
|
246 if (elementpad != NULL) |
|
247 gst_object_unref(elementpad); |
|
248 if (element != NULL) |
|
249 gst_object_unref(element); |
|
250 |
|
251 return XA_RESULT_SUCCESS; |
|
252 } |
|
253 XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList( |
37 XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList( |
254 FrameworkMap *frameworkMap, XACapabilities **ppListHead) |
38 FrameworkMap *frameworkMap, XACapabilities **ppListHead) |
255 |
39 |
256 { |
40 { |
257 XAresult res = XA_RESULT_SUCCESS; |
41 XAresult res = XA_RESULT_SUCCESS; |
258 XACapabilities *newNode = NULL; |
42 XACapabilities *newNode = NULL; |
259 FWMgrFwType fwtype = FWMgrFWUknown; |
43 FWMgrFwType fwtype = FWMgrFWUknown; |
260 char *uri = NULL; |
44 char *uri = NULL; |
261 XACapabilities *lastNode; |
45 XACapabilities *lastNode = NULL; |
262 XACapabilities *firstNode; |
46 XACapabilities *firstNode = NULL; |
263 |
47 |
264 DEBUG_API("->XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
48 DEBUG_API("->XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
265 |
49 |
266 if (!frameworkMap || !ppListHead) |
50 if (!frameworkMap || !ppListHead) |
267 { |
51 { |
268 res = XA_RESULT_PARAMETER_INVALID; |
52 DEBUG_ERR("XA_RESULT_PARAMETER_INVALID"); |
269 return res; |
53 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
270 } |
54 return XA_RESULT_PARAMETER_INVALID; |
271 |
|
272 lastNode = firstNode = *ppListHead; |
|
273 |
|
274 /* traverse and point to the last node in the list */ |
|
275 while (lastNode && lastNode->next) |
|
276 { |
|
277 lastNode = lastNode->next; |
|
278 } |
55 } |
279 |
56 |
280 uri = "file:///c:/test.mp4"; |
57 uri = "file:///c:/test.mp4"; |
281 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
58 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
282 |
|
283 if (fwtype == FWMgrFWGST) |
59 if (fwtype == FWMgrFWGST) |
284 { |
60 { |
285 GError* gerror = 0; |
|
286 //initialize gstreamer |
|
287 //AL_PROFILING_BEGIN; |
|
288 if (!gst_init_check(NULL, NULL, &gerror)) |
|
289 { |
|
290 DEBUG_ERR("Gst Initalization failure."); |
|
291 return XA_RESULT_INTERNAL_ERROR; |
|
292 } |
|
293 //AL_PROFILING_END_PRINT("gst_init_check"); |
|
294 |
|
295 } |
|
296 |
|
297 if (fwtype == FWMgrFWGST) |
|
298 { |
|
299 /* Add codec capabilities */ |
|
300 newNode = NULL; |
|
301 res = XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities(&newNode); |
61 res = XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities(&newNode); |
302 if (res != XA_RESULT_SUCCESS) |
62 if (res != XA_RESULT_SUCCESS) |
303 { |
63 { |
|
64 XACapabilitiesMgr_DeleteCapabilitieList(&firstNode); |
|
65 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
304 return res; |
66 return res; |
305 } |
67 } |
306 if (lastNode) |
68 if (!firstNode) |
307 { |
69 { |
308 lastNode->next = newNode; |
70 firstNode = newNode; |
309 } |
|
310 if (newNode) |
|
311 { /* if a new node is created move lastNode to the new item */ |
|
312 if (!firstNode) |
|
313 firstNode = newNode; |
|
314 lastNode = newNode; |
71 lastNode = newNode; |
315 } |
72 } |
316 } |
73 } |
317 |
74 |
318 uri = "file:///c:/test.amr"; |
75 uri = "file:///c:/test.amr"; |
319 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
76 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
320 |
|
321 if (fwtype == FWMgrFWGST) |
77 if (fwtype == FWMgrFWGST) |
322 { |
78 { |
323 newNode = NULL; |
|
324 res = XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities(&newNode); |
79 res = XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities(&newNode); |
325 if (res != XA_RESULT_SUCCESS) |
80 if (res != XA_RESULT_SUCCESS) |
326 { |
81 { |
|
82 XACapabilitiesMgr_DeleteCapabilitieList(&firstNode); |
|
83 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
327 return res; |
84 return res; |
328 } |
85 } |
329 if (lastNode) |
86 if (!firstNode) |
|
87 { |
|
88 firstNode = newNode; |
|
89 lastNode = newNode; |
|
90 } |
|
91 else |
330 { |
92 { |
331 lastNode->next = newNode; |
93 lastNode->next = newNode; |
332 } |
|
333 if (newNode) |
|
334 { /* if a new node is created move lastNode to the new item */ |
|
335 if (!firstNode) |
|
336 firstNode = newNode; |
|
337 lastNode = newNode; |
94 lastNode = newNode; |
338 } |
95 } |
339 } |
96 } |
340 |
97 |
341 uri = "file:///c:/test.wav"; |
98 uri = "file:///c:/test.wav"; |
342 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
99 fwtype = XAFrameworkMgr_GetFramework(frameworkMap, uri, FWMgrMORecorder); |
343 |
|
344 if (fwtype == FWMgrFWGST) |
100 if (fwtype == FWMgrFWGST) |
345 { |
101 { |
346 newNode = NULL; |
|
347 res = XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities(&newNode); |
102 res = XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities(&newNode); |
348 if (res != XA_RESULT_SUCCESS) |
103 if (res != XA_RESULT_SUCCESS) |
349 { |
104 { |
|
105 XACapabilitiesMgr_DeleteCapabilitieList(&firstNode); |
|
106 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
350 return res; |
107 return res; |
351 } |
108 } |
352 if (lastNode) |
109 if (!firstNode) |
|
110 { |
|
111 firstNode = newNode; |
|
112 lastNode = newNode; |
|
113 } |
|
114 else |
353 { |
115 { |
354 lastNode->next = newNode; |
116 lastNode->next = newNode; |
355 } |
|
356 if (newNode) |
|
357 { /* if a new node is created move lastNode to the new item */ |
|
358 if (!firstNode) |
|
359 firstNode = newNode; |
|
360 lastNode = newNode; |
117 lastNode = newNode; |
361 } |
118 } |
362 } |
119 } |
363 /* if empty list, then append first node as the head */ |
120 |
364 if (!(*ppListHead)) |
121 /* if we have some capabilities supported by Gstreamer framework */ |
365 { |
122 if (firstNode) |
366 *ppListHead = firstNode; |
123 { |
|
124 /* if empty list, then append first node as the head */ |
|
125 if (!(*ppListHead)) |
|
126 { |
|
127 *ppListHead = firstNode; |
|
128 } |
|
129 else /* traverse to the last item in the list and link firstNode to it */ |
|
130 { |
|
131 lastNode = *ppListHead; |
|
132 while(lastNode->next) |
|
133 { |
|
134 lastNode = lastNode->next; |
|
135 } |
|
136 lastNode->next = firstNode; |
|
137 } |
367 } |
138 } |
368 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
139 DEBUG_API("<-XAGSTCapabilitiesMgr_UpdateCapabilitieList"); |
369 return res; |
140 return res; |
370 } |
141 } |
371 |
142 |
|
143 /* XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
|
144 XACapabilities **ppNode) |
|
145 * Description: If return value is XA_RESULT_SUCCESS, Creats a new XACapabilities |
|
146 * node and update ppNode to contain pointer to it. |
|
147 * Otherwise return error code for failure. |
|
148 */ |
372 XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
149 XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
373 XACapabilities **ppNode) |
150 XACapabilities **ppNode) |
374 { |
151 { |
375 XAresult res = XA_RESULT_SUCCESS; |
152 XAresult res = XA_RESULT_SUCCESS; |
376 XACapabilities *newNode = NULL; |
153 XACapabilities *newNode = NULL; |
377 XAAudioCodecDescriptor *entries = NULL; |
|
378 XAchar aacencelement[] = "nokiaaacenc"; |
154 XAchar aacencelement[] = "nokiaaacenc"; |
379 int strLen = 0; |
155 int strLen = 0; |
380 |
156 XAAudioCodecDescriptor *codecDesc = NULL; |
|
157 |
|
158 DEBUG_API("->XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
381 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
159 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
382 if (!newNode) |
160 if (!newNode) |
383 { |
161 { |
384 res = XA_RESULT_MEMORY_FAILURE; |
162 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
385 return res; |
163 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
164 return XA_RESULT_MEMORY_FAILURE; |
386 } |
165 } |
387 |
166 |
388 newNode->capsType = AUD_E; |
167 newNode->capsType = AUD_E; |
389 newNode->xaid = XA_AUDIOCODEC_AAC; |
168 newNode->xaid = XA_AUDIOCODEC_AAC; |
390 newNode->noOfEntries = 1; |
|
391 |
169 |
392 strLen = strlen((char*) aacencelement); |
170 strLen = strlen((char*) aacencelement); |
393 newNode->adaptId = (XAchar *) calloc(strLen + 1, sizeof(XAchar)); |
171 newNode->adaptId = (XAchar *) calloc(strLen + 1, sizeof(XAchar)); |
394 if (!newNode->adaptId) |
172 if (!newNode->adaptId) |
395 { |
173 { |
396 res = XA_RESULT_MEMORY_FAILURE; |
174 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
397 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
175 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
398 return res; |
176 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
177 return XA_RESULT_MEMORY_FAILURE; |
399 } |
178 } |
400 |
179 |
401 strncpy((char*) newNode->adaptId, (char*) aacencelement, strLen); |
180 strncpy((char*) newNode->adaptId, (char*) aacencelement, strLen); |
402 newNode->adaptId[strLen] = '\0'; /*Null terminate it*/ |
181 newNode->adaptId[strLen] = '\0'; /*Null terminate it*/ |
403 |
182 |
404 /* Allocate array */ |
183 /* create XAAudioCodecDescriptor for AAC and initialize values */ |
405 entries = (XAAudioCodecDescriptor*) calloc(1, |
184 codecDesc = (XAAudioCodecDescriptor*) calloc(2, sizeof(XAAudioCodecDescriptor)); |
406 sizeof(XAAudioCodecDescriptor)); |
185 if (!codecDesc) |
407 if (!entries) |
186 { |
408 { |
187 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
409 res = XA_RESULT_MEMORY_FAILURE; |
188 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
410 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
189 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
411 return res; |
190 return XA_RESULT_MEMORY_FAILURE; |
412 } |
191 } |
413 |
192 newNode->noOfEntries = 2; |
414 newNode->pEntry = (void*) entries; |
193 newNode->pEntry = (void *)codecDesc; |
415 |
194 |
416 res = XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
195 codecDesc->maxChannels = 2; |
417 newNode->xaid); |
196 (codecDesc+1)->maxChannels = 2; |
418 |
197 codecDesc->minBitsPerSample = 16; |
419 newNode->pEntry = (void*) entries; |
198 (codecDesc+1)->minBitsPerSample = 16; |
|
199 codecDesc->maxBitsPerSample = 16; |
|
200 (codecDesc+1)->maxBitsPerSample = 16; |
|
201 codecDesc->minSampleRate = 8000000; |
|
202 (codecDesc+1)->minSampleRate = 8000000; |
|
203 codecDesc->maxSampleRate = 48000000; |
|
204 (codecDesc+1)->maxSampleRate = 48000000; |
|
205 codecDesc->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
|
206 (codecDesc+1)->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
|
207 codecDesc->pSampleRatesSupported = (XAmilliHertz*)calloc(5, sizeof(XAmilliHertz)); |
|
208 if (!(codecDesc->pSampleRatesSupported)) |
|
209 { |
|
210 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
211 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
212 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
213 return XA_RESULT_MEMORY_FAILURE; |
|
214 } |
|
215 (codecDesc+1)->pSampleRatesSupported = (XAmilliHertz*)calloc(5, sizeof(XAmilliHertz)); |
|
216 if (!((codecDesc+1)->pSampleRatesSupported)) |
|
217 { |
|
218 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
219 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
220 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
221 return XA_RESULT_MEMORY_FAILURE; |
|
222 } |
|
223 codecDesc->pSampleRatesSupported[0] = 8000000; |
|
224 (codecDesc+1)->pSampleRatesSupported[0] = 8000000; |
|
225 codecDesc->pSampleRatesSupported[1] = 16000000; |
|
226 (codecDesc+1)->pSampleRatesSupported[1] = 16000000; |
|
227 codecDesc->pSampleRatesSupported[2] = 24000000; |
|
228 (codecDesc+1)->pSampleRatesSupported[2] = 24000000; |
|
229 codecDesc->pSampleRatesSupported[3] = 32000000; |
|
230 (codecDesc+1)->pSampleRatesSupported[3] = 32000000; |
|
231 codecDesc->pSampleRatesSupported[4] = 48000000; |
|
232 (codecDesc+1)->pSampleRatesSupported[4] = 48000000; |
|
233 codecDesc->numSampleRatesSupported = 5; |
|
234 (codecDesc+1)->numSampleRatesSupported = 5; |
|
235 codecDesc->minBitRate = 32000; |
|
236 (codecDesc+1)->minBitRate = 32000; |
|
237 codecDesc->maxBitRate = 256000; |
|
238 (codecDesc+1)->maxBitRate = 256000; |
|
239 codecDesc->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
240 (codecDesc+1)->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
241 codecDesc->pBitratesSupported = (XAuint32 *)calloc(8, sizeof(XAuint32));; |
|
242 if (!(codecDesc->pBitratesSupported)) |
|
243 { |
|
244 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
245 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
246 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
247 return XA_RESULT_MEMORY_FAILURE; |
|
248 } |
|
249 (codecDesc+1)->pBitratesSupported = (XAuint32 *)calloc(8, sizeof(XAuint32));; |
|
250 if (!((codecDesc+1)->pBitratesSupported)) |
|
251 { |
|
252 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
253 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
254 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
|
255 return XA_RESULT_MEMORY_FAILURE; |
|
256 } |
|
257 codecDesc->pBitratesSupported[0] = 32000; |
|
258 (codecDesc+1)->pBitratesSupported[0] = 32000; |
|
259 codecDesc->pBitratesSupported[1] = 64000; |
|
260 (codecDesc+1)->pBitratesSupported[1] = 64000; |
|
261 codecDesc->pBitratesSupported[2] = 96000; |
|
262 (codecDesc+1)->pBitratesSupported[2] = 96000; |
|
263 codecDesc->pBitratesSupported[3] = 128000; |
|
264 (codecDesc+1)->pBitratesSupported[3] = 128000; |
|
265 codecDesc->pBitratesSupported[4] = 160000; |
|
266 (codecDesc+1)->pBitratesSupported[4] = 160000; |
|
267 codecDesc->pBitratesSupported[5] = 192000; |
|
268 (codecDesc+1)->pBitratesSupported[5] = 192000; |
|
269 codecDesc->pBitratesSupported[6] = 224000; |
|
270 (codecDesc+1)->pBitratesSupported[6] = 224000; |
|
271 codecDesc->pBitratesSupported[7] = 256000; |
|
272 (codecDesc+1)->pBitratesSupported[7] = 256000; |
|
273 codecDesc->numBitratesSupported = 8; |
|
274 (codecDesc+1)->numBitratesSupported = 8; |
|
275 codecDesc->profileSetting = XA_AUDIOPROFILE_AAC_AAC; |
|
276 (codecDesc+1)->profileSetting = XA_AUDIOPROFILE_AAC_AAC; |
|
277 codecDesc->modeSetting = XA_AUDIOMODE_AAC_HE; |
|
278 (codecDesc+1)->modeSetting = XA_AUDIOMODE_AAC_LC; |
420 |
279 |
421 *ppNode = newNode; |
280 *ppNode = newNode; |
|
281 |
|
282 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities"); |
422 return res; |
283 return res; |
423 } |
284 } |
424 |
285 |
425 XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
286 XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
426 XACapabilities **ppNode) |
287 XACapabilities **ppNode) |
427 { |
288 { |
428 XAresult res = XA_RESULT_SUCCESS; |
289 XAresult res = XA_RESULT_SUCCESS; |
429 XACapabilities *newNode = NULL; |
290 XACapabilities *newNode = NULL; |
430 XAAudioCodecDescriptor *entries = NULL; |
291 XAchar amrencelement[] = "devsoundsrc"; |
431 |
292 int strLen = 0; |
|
293 XAAudioCodecDescriptor *codecDesc = NULL; |
|
294 |
|
295 DEBUG_API("->XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
432 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
296 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
433 if (!newNode) |
297 if (!newNode) |
434 { |
298 { |
435 res = XA_RESULT_MEMORY_FAILURE; |
299 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
436 return res; |
300 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
|
301 return XA_RESULT_MEMORY_FAILURE; |
437 } |
302 } |
438 |
303 |
439 newNode->capsType = AUD_E; |
304 newNode->capsType = AUD_E; |
440 newNode->xaid = XA_AUDIOCODEC_AMR; |
305 newNode->xaid = XA_AUDIOCODEC_AMR; |
|
306 |
|
307 strLen = strlen((char*) amrencelement); |
|
308 newNode->adaptId = (XAchar *) calloc(strLen + 1, sizeof(XAchar)); |
|
309 if (!newNode->adaptId) |
|
310 { |
|
311 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
312 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
313 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
|
314 return XA_RESULT_MEMORY_FAILURE; |
|
315 } |
|
316 |
|
317 strncpy((char*) newNode->adaptId, (char*) amrencelement, strLen); |
|
318 newNode->adaptId[strLen] = '\0'; /*Null terminate it*/ |
|
319 |
|
320 /* create XAAudioCodecDescriptor for AMR and initialize values */ |
|
321 codecDesc = (XAAudioCodecDescriptor*) calloc(1, sizeof(XAAudioCodecDescriptor)); |
|
322 if (!codecDesc) |
|
323 { |
|
324 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
325 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
326 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
|
327 return XA_RESULT_MEMORY_FAILURE; |
|
328 } |
441 newNode->noOfEntries = 1; |
329 newNode->noOfEntries = 1; |
442 |
330 newNode->pEntry = (void *)codecDesc; |
443 /* Allocate array */ |
331 |
444 entries = (XAAudioCodecDescriptor*) calloc(1, |
332 codecDesc->maxChannels = 1; |
445 sizeof(XAAudioCodecDescriptor)); |
333 codecDesc->minBitsPerSample = 8; |
446 if (!entries) |
334 codecDesc->maxBitsPerSample = 8; |
447 { |
335 codecDesc->minSampleRate = 8000000; |
448 res = XA_RESULT_MEMORY_FAILURE; |
336 codecDesc->maxSampleRate = 8000000; |
449 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
337 codecDesc->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
450 return res; |
338 codecDesc->pSampleRatesSupported = (XAmilliHertz*)calloc(1, sizeof(XAmilliHertz)); |
451 } |
339 if (!(codecDesc->pSampleRatesSupported)) |
452 |
340 { |
453 newNode->pEntry = (void*) entries; |
341 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
454 |
342 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
455 XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
343 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
456 newNode->xaid); |
344 return XA_RESULT_MEMORY_FAILURE; |
457 |
345 } |
458 newNode->pEntry = (void*) entries; |
346 codecDesc->pSampleRatesSupported[0] = 8000000; |
459 |
347 codecDesc->numSampleRatesSupported = 1; |
|
348 codecDesc->minBitRate = 4750; |
|
349 codecDesc->maxBitRate = 12200; |
|
350 codecDesc->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
351 codecDesc->pBitratesSupported = (XAuint32 *)calloc(8, sizeof(XAuint32));; |
|
352 if (!(codecDesc->pBitratesSupported)) |
|
353 { |
|
354 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
355 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
356 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
|
357 return XA_RESULT_MEMORY_FAILURE; |
|
358 } |
|
359 codecDesc->pBitratesSupported[0] = 4750; |
|
360 codecDesc->pBitratesSupported[1] = 5150; |
|
361 codecDesc->pBitratesSupported[2] = 5900; |
|
362 codecDesc->pBitratesSupported[3] = 6700; |
|
363 codecDesc->pBitratesSupported[4] = 7400; |
|
364 codecDesc->pBitratesSupported[5] = 7950; |
|
365 codecDesc->pBitratesSupported[6] = 10200; |
|
366 codecDesc->pBitratesSupported[7] = 12200; |
|
367 codecDesc->numBitratesSupported = 8; |
|
368 codecDesc->profileSetting = XA_AUDIOPROFILE_AMR; |
|
369 codecDesc->modeSetting = 0; |
|
370 |
460 *ppNode = newNode; |
371 *ppNode = newNode; |
|
372 |
|
373 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities"); |
461 return res; |
374 return res; |
462 } |
375 } |
463 |
376 |
464 XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
377 XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
465 XACapabilities **ppNode) |
378 XACapabilities **ppNode) |
466 { |
379 { |
467 XAresult res = XA_RESULT_SUCCESS; |
380 XAresult res = XA_RESULT_SUCCESS; |
468 XACapabilities *newNode = NULL; |
381 XACapabilities *newNode = NULL; |
469 XAAudioCodecDescriptor *entries = NULL; |
382 XAchar wavencelement[] = "wavenc"; |
470 |
383 int strLen = 0; |
|
384 XAAudioCodecDescriptor *codecDesc = NULL; |
|
385 |
|
386 DEBUG_API("->XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
471 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
387 newNode = (XACapabilities *) calloc(1, sizeof(XACapabilities)); |
472 if (!newNode) |
388 if (!newNode) |
473 { |
389 { |
474 res = XA_RESULT_MEMORY_FAILURE; |
390 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
475 return res; |
391 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
|
392 return XA_RESULT_MEMORY_FAILURE; |
476 } |
393 } |
477 |
394 |
478 newNode->capsType = AUD_E; |
395 newNode->capsType = AUD_E; |
479 newNode->xaid = XA_AUDIOCODEC_PCM; |
396 newNode->xaid = XA_AUDIOCODEC_PCM; |
|
397 |
|
398 strLen = strlen((char*) wavencelement); |
|
399 newNode->adaptId = (XAchar *) calloc(strLen + 1, sizeof(XAchar)); |
|
400 if (!newNode->adaptId) |
|
401 { |
|
402 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
403 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
404 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
|
405 return XA_RESULT_MEMORY_FAILURE; |
|
406 } |
|
407 |
|
408 strncpy((char*) newNode->adaptId, (char*) wavencelement, strLen); |
|
409 newNode->adaptId[strLen] = '\0'; /*Null terminate it*/ |
|
410 |
|
411 /* create XAAudioCodecDescriptor for PCM and initialize values */ |
|
412 codecDesc = (XAAudioCodecDescriptor*) calloc(1, sizeof(XAAudioCodecDescriptor)); |
|
413 if (!codecDesc) |
|
414 { |
|
415 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
416 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
|
417 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
|
418 return XA_RESULT_MEMORY_FAILURE; |
|
419 } |
480 newNode->noOfEntries = 1; |
420 newNode->noOfEntries = 1; |
481 |
421 newNode->pEntry = (void *)codecDesc; |
482 /* Allocate array */ |
422 |
483 entries = (XAAudioCodecDescriptor*) calloc(1, |
423 codecDesc->maxChannels = 2; |
484 sizeof(XAAudioCodecDescriptor)); |
424 codecDesc->minBitsPerSample = 16; |
485 if (!entries) |
425 codecDesc->maxBitsPerSample = 16; |
486 { |
426 codecDesc->minSampleRate = 8000000; |
487 res = XA_RESULT_MEMORY_FAILURE; |
427 codecDesc->maxSampleRate = 48000000; |
488 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
428 codecDesc->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
489 return res; |
429 codecDesc->pSampleRatesSupported = (XAmilliHertz*)calloc(12, sizeof(XAmilliHertz)); |
490 } |
430 if (!(codecDesc->pSampleRatesSupported)) |
491 |
431 { |
492 newNode->pEntry = (void*) entries; |
432 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
493 |
433 DEBUG_ERR("XA_RESULT_MEMORY_FAILURE"); |
494 XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
434 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
495 newNode->xaid); |
435 return XA_RESULT_MEMORY_FAILURE; |
496 |
436 } |
497 newNode->pEntry = (void*) entries; |
437 codecDesc->pSampleRatesSupported[0] = 8000000; |
498 |
438 codecDesc->pSampleRatesSupported[1] = 16000000; |
|
439 codecDesc->pSampleRatesSupported[2] = 24000000; |
|
440 codecDesc->pSampleRatesSupported[3] = 32000000; |
|
441 codecDesc->pSampleRatesSupported[4] = 48000000; |
|
442 codecDesc->numSampleRatesSupported = 5; |
|
443 codecDesc->minBitRate = 0; |
|
444 codecDesc->maxBitRate = 0; |
|
445 codecDesc->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
446 codecDesc->pBitratesSupported = NULL; |
|
447 codecDesc->numBitratesSupported = 0; |
|
448 codecDesc->profileSetting = XA_AUDIOPROFILE_PCM; |
|
449 codecDesc->modeSetting = 0; |
|
450 |
499 *ppNode = newNode; |
451 *ppNode = newNode; |
|
452 |
|
453 DEBUG_API("<-XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities"); |
500 return res; |
454 return res; |
501 } |
455 } |