16 * |
16 * |
17 */ |
17 */ |
18 |
18 |
19 #include <stdio.h> |
19 #include <stdio.h> |
20 #include <string.h> |
20 #include <string.h> |
|
21 #include <strings.h> |
|
22 #include <gst/gst.h> |
|
23 #include <gobject_global.h> |
|
24 |
21 #include "xagstcapabilitiesmgr.h" |
25 #include "xagstcapabilitiesmgr.h" |
22 #include "xaframeworkmgr.h" |
26 #include "xaframeworkmgr.h" |
23 |
27 |
24 static XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
28 static XAresult XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities( |
25 XACapabilities **ppNode); |
29 XACapabilities **ppNode); |
26 static XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
30 static XAresult XAGSTCapabilitiesMgr_GetAudioAMREncoderCapabilities( |
27 XACapabilities **ppNode); |
31 XACapabilities **ppNode); |
28 static XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
32 static XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities( |
29 XACapabilities **ppNode); |
33 XACapabilities **ppNode); |
|
34 static XAresult XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement( |
|
35 XAAudioCodecDescriptor **entries, XAuint32 type); |
30 |
36 |
31 /* XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList |
37 /* XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList |
32 * Description: Update the capabilities list supported by GStreamer framework. |
38 * Description: Update the capabilities list supported by GStreamer framework. |
33 */ |
39 */ |
|
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 } |
34 XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList( |
253 XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList( |
35 FrameworkMap *frameworkMap, XACapabilities **ppListHead) |
254 FrameworkMap *frameworkMap, XACapabilities **ppListHead) |
36 |
255 |
37 { |
256 { |
38 XAresult res = XA_RESULT_SUCCESS; |
257 XAresult res = XA_RESULT_SUCCESS; |
177 return res; |
410 return res; |
178 } |
411 } |
179 |
412 |
180 newNode->pEntry = (void*) entries; |
413 newNode->pEntry = (void*) entries; |
181 |
414 |
182 entries->maxChannels = 2; |
415 res = XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
183 entries->minBitsPerSample = 16; |
416 newNode->xaid); |
184 entries->maxBitsPerSample = 16; |
|
185 entries->minSampleRate = 8000000; /*milliHz*/ |
|
186 entries->maxSampleRate = 48000000; |
|
187 entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
|
188 entries->numSampleRatesSupported = 7; |
|
189 entries->pSampleRatesSupported = (XAmilliHertz*) calloc( |
|
190 entries->numSampleRatesSupported, sizeof(XAmilliHertz)); |
|
191 if (!entries->pSampleRatesSupported) |
|
192 { |
|
193 res = XA_RESULT_MEMORY_FAILURE; |
|
194 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
195 return res; |
|
196 } |
|
197 /* entries in milliHz */ |
|
198 entries->pSampleRatesSupported[0] = 8000000; |
|
199 entries->pSampleRatesSupported[1] = 11025000; |
|
200 entries->pSampleRatesSupported[2] = 16000000; |
|
201 entries->pSampleRatesSupported[3] = 22050000; |
|
202 entries->pSampleRatesSupported[4] = 32000000; |
|
203 entries->pSampleRatesSupported[5] = 44100000; |
|
204 entries->pSampleRatesSupported[6] = 48000000; |
|
205 |
|
206 entries->minBitRate = 32000; |
|
207 entries->maxBitRate = 256000; |
|
208 entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
209 entries->numBitratesSupported = 8; |
|
210 entries->pBitratesSupported = (XAuint32*) calloc( |
|
211 entries->numBitratesSupported, sizeof(XAuint32)); |
|
212 if (!entries->pBitratesSupported) |
|
213 { |
|
214 res = XA_RESULT_MEMORY_FAILURE; |
|
215 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
216 return res; |
|
217 } |
|
218 (entries->pBitratesSupported)[0] = 32000; |
|
219 (entries->pBitratesSupported)[1] = 64000; |
|
220 (entries->pBitratesSupported)[2] = 96000; |
|
221 (entries->pBitratesSupported)[3] = 128000; |
|
222 (entries->pBitratesSupported)[4] = 160000; |
|
223 (entries->pBitratesSupported)[5] = 192000; |
|
224 (entries->pBitratesSupported)[6] = 224000; |
|
225 (entries->pBitratesSupported)[7] = 256000; |
|
226 |
|
227 entries->profileSetting = XA_AUDIOPROFILE_AAC_AAC; |
|
228 entries->modeSetting = XA_AUDIOMODE_AAC_LC; |
|
229 |
417 |
230 newNode->pEntry = (void*) entries; |
418 newNode->pEntry = (void*) entries; |
231 |
419 |
232 *ppNode = newNode; |
420 *ppNode = newNode; |
233 return res; |
421 return res; |
261 return res; |
449 return res; |
262 } |
450 } |
263 |
451 |
264 newNode->pEntry = (void*) entries; |
452 newNode->pEntry = (void*) entries; |
265 |
453 |
266 entries->maxChannels = 1; |
454 XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
267 entries->minBitsPerSample = 8; |
455 newNode->xaid); |
268 entries->maxBitsPerSample = 8; |
|
269 entries->minSampleRate = 8000000; /*milliHz*/ |
|
270 entries->maxSampleRate = 8000000; |
|
271 entries->isFreqRangeContinuous = XA_BOOLEAN_TRUE; |
|
272 entries->numSampleRatesSupported = 1; |
|
273 entries->minBitRate = 4750; |
|
274 entries->maxBitRate = 12200; |
|
275 entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
276 entries->numBitratesSupported = 8; |
|
277 entries->pBitratesSupported = (XAuint32*) calloc( |
|
278 entries->numBitratesSupported, sizeof(XAuint32)); |
|
279 if (!entries->pBitratesSupported) |
|
280 { |
|
281 res = XA_RESULT_MEMORY_FAILURE; |
|
282 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
283 return res; |
|
284 } |
|
285 (entries->pBitratesSupported)[0] = 4750; |
|
286 (entries->pBitratesSupported)[1] = 5150; |
|
287 (entries->pBitratesSupported)[2] = 5900; |
|
288 (entries->pBitratesSupported)[3] = 6700; |
|
289 (entries->pBitratesSupported)[4] = 7400; |
|
290 (entries->pBitratesSupported)[5] = 7950; |
|
291 (entries->pBitratesSupported)[6] = 10200; |
|
292 (entries->pBitratesSupported)[7] = 12200; |
|
293 |
|
294 entries->profileSetting = XA_AUDIOPROFILE_AMR; |
|
295 entries->modeSetting = 0; |
|
296 |
456 |
297 newNode->pEntry = (void*) entries; |
457 newNode->pEntry = (void*) entries; |
298 |
458 |
299 *ppNode = newNode; |
459 *ppNode = newNode; |
300 return res; |
460 return res; |
328 return res; |
488 return res; |
329 } |
489 } |
330 |
490 |
331 newNode->pEntry = (void*) entries; |
491 newNode->pEntry = (void*) entries; |
332 |
492 |
333 entries->maxChannels = 2; |
493 XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries, |
334 entries->minBitsPerSample = 16; |
494 newNode->xaid); |
335 entries->maxBitsPerSample = 16; |
|
336 entries->minSampleRate = 8000000; /*milliHz*/ |
|
337 entries->maxSampleRate = 96000000; |
|
338 entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE; |
|
339 entries->numSampleRatesSupported = 10; |
|
340 entries->pSampleRatesSupported = (XAmilliHertz*) calloc( |
|
341 entries->numSampleRatesSupported, sizeof(XAmilliHertz)); |
|
342 if (!entries->pSampleRatesSupported) |
|
343 { |
|
344 res = XA_RESULT_MEMORY_FAILURE; |
|
345 XACapabilitiesMgr_DeleteCapabilitieList(&newNode); |
|
346 return res; |
|
347 } |
|
348 /* entries in milliHz */ |
|
349 entries->pSampleRatesSupported[0] = 12000000; |
|
350 entries->pSampleRatesSupported[1] = 16000000; |
|
351 entries->pSampleRatesSupported[2] = 22050000; |
|
352 entries->pSampleRatesSupported[3] = 24000000; |
|
353 entries->pSampleRatesSupported[4] = 32000000; |
|
354 entries->pSampleRatesSupported[5] = 44100000; |
|
355 entries->pSampleRatesSupported[6] = 48000000; |
|
356 entries->pSampleRatesSupported[7] = 64000000; |
|
357 entries->pSampleRatesSupported[8] = 88200000; |
|
358 entries->pSampleRatesSupported[9] = 96000000; |
|
359 |
|
360 entries->minBitRate = 0; |
|
361 entries->maxBitRate = 0; |
|
362 entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE; |
|
363 entries->pBitratesSupported = NULL; |
|
364 entries->numBitratesSupported = 0; |
|
365 entries->profileSetting = XA_AUDIOPROFILE_PCM; |
|
366 entries->modeSetting = 0; |
|
367 |
495 |
368 newNode->pEntry = (void*) entries; |
496 newNode->pEntry = (void*) entries; |
369 |
497 |
370 *ppNode = newNode; |
498 *ppNode = newNode; |
371 return res; |
499 return res; |