--- a/khronosfws/openmax_al/src/gst_adaptation/xagstcapabilitiesmgr.c Wed Jun 23 18:47:10 2010 +0300
+++ b/khronosfws/openmax_al/src/gst_adaptation/xagstcapabilitiesmgr.c Tue Jul 06 14:50:35 2010 +0300
@@ -18,6 +18,10 @@
#include <stdio.h>
#include <string.h>
+#include <strings.h>
+#include <gst/gst.h>
+#include <gobject_global.h>
+
#include "xagstcapabilitiesmgr.h"
#include "xaframeworkmgr.h"
@@ -27,10 +31,225 @@
XACapabilities **ppNode);
static XAresult XAGSTCapabilitiesMgr_GetAudioPCMEncoderCapabilities(
XACapabilities **ppNode);
+static XAresult XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(
+ XAAudioCodecDescriptor **entries, XAuint32 type);
/* XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList
* Description: Update the capabilities list supported by GStreamer framework.
*/
+static gboolean populate_field(GQuark field, const GValue * value,
+ gpointer pfx)
+ {
+ gchar *field_name;
+ gpointer *pfxd = (gpointer*) pfx;
+ XAAudioCodecDescriptor *ctxx = (XAAudioCodecDescriptor *) pfxd;
+
+ field_name = (gchar*) g_quark_to_string(field);
+
+ if ((strcasecmp((const char*) field_name, "channels") == 0))
+ {
+ if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE)
+ {
+ (ctxx)->maxChannels = gst_value_get_int_range_max(value);
+ }
+ else
+ (ctxx)->maxChannels = g_value_get_int(value);
+ }
+ if ((strcasecmp((const char*) field_name, "depth") == 0))
+ {
+ if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE)
+ {
+ (ctxx)->minBitsPerSample = gst_value_get_int_range_min(value);
+ }
+ else
+ (ctxx)->minBitsPerSample = g_value_get_int(value);
+ }
+ if ((strcasecmp((const char*) field_name, "bitrate") == 0))
+ {
+ if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE)
+ {
+ (ctxx)->minBitRate = gst_value_get_int_range_min(value);
+ (ctxx)->maxBitRate = gst_value_get_int_range_max(value);
+ }
+ else
+ {
+ (ctxx)->minBitRate = g_value_get_int(value);
+ (ctxx)->maxBitRate = g_value_get_int(value);
+ }
+ }
+ if ((strcasecmp((const char*) field_name, "width") == 0))
+ {
+ if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE)
+ {
+ (ctxx)->maxBitsPerSample = gst_value_get_int_range_max(value);
+ }
+ else
+ (ctxx)->maxBitsPerSample = g_value_get_int(value);
+ }
+ if ((strcasecmp((const char*) field_name, "rate") == 0))
+ {
+ if (GST_VALUE_HOLDS_INT_RANGE(value) == TRUE)
+ {
+ (ctxx)->minSampleRate = gst_value_get_int_range_min(value) * 1000;
+ (ctxx)->maxSampleRate = gst_value_get_int_range_max(value) * 1000;
+ }
+ else
+ {
+ (ctxx)->minSampleRate = g_value_get_int(value) * 1000;
+ (ctxx)->maxSampleRate = g_value_get_int(value) * 1000;
+ }
+ }
+
+ return TRUE;
+ }
+
+XAresult XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(
+ XAAudioCodecDescriptor **entries, XAuint32 type)
+ {
+ int i = 0;
+ GstElement *element = NULL;
+ GstPad *elementpad = NULL;
+ GstCaps *elementcaps = NULL;
+ GstStructure *s = NULL;
+ GParamSpec *elementproperty;
+ GParamSpecInt *pint;
+ GParamSpecEnum *penum;
+ gchar *findamr = "\0";
+ gpointer *myentries;
+
+
+ if (type == XA_AUDIOCODEC_AAC)
+ {
+ element = gst_element_factory_make("nokiaaacenc", "encoderelement");
+ if (element)
+ {
+ elementpad = gst_element_get_static_pad(element, "sink");
+ if (!elementpad)
+ {
+ DEBUG_ERR("no pad found for AAC Encoder");
+ return XA_RESULT_INTERNAL_ERROR;
+ }
+ elementcaps = gst_pad_get_caps(elementpad);
+ s = gst_caps_get_structure(elementcaps, 0);
+
+ myentries = (gpointer*) *entries;
+ gst_structure_foreach(s, populate_field, (gpointer) myentries);
+
+ elementproperty = g_object_class_find_property(
+ G_OBJECT_GET_CLASS (element), "bitrate");
+ if (elementproperty)
+ {
+ pint = G_PARAM_SPEC_INT (elementproperty);
+ (*entries)->minBitRate = pint->minimum;
+ (*entries)->maxBitRate = pint->maximum;
+ }
+ elementproperty = g_object_class_find_property(
+ G_OBJECT_GET_CLASS (element), "profile");
+ if (elementproperty)
+ {
+ penum = G_PARAM_SPEC_ENUM(elementproperty);
+ (*entries)->modeSetting = penum->default_value;
+ }
+
+ (*entries)->profileSetting = XA_AUDIOPROFILE_AAC_AAC;
+ (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE;
+ (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE;
+ }
+ else
+ {
+ DEBUG_ERR("failed to get the AACencoder element");
+ }
+ }
+ else if (type == XA_AUDIOCODEC_AMR)
+ {
+ element = gst_element_factory_make("devsoundsrc", "encoderelement");
+ if (element)
+ {
+ elementpad = gst_element_get_pad(element, "src");
+ if (!elementpad)
+ {
+ DEBUG_ERR("no source pad for Devsound(amr) element");
+ return XA_RESULT_INTERNAL_ERROR;
+ }
+
+ elementcaps = gst_pad_get_caps(elementpad);
+ while (!(strcasecmp(findamr, "audio/amr") == 0) && i
+ < elementcaps->structs->len)
+ {
+ s = gst_caps_get_structure(elementcaps, i);
+ findamr = (char*) gst_structure_get_name(s);
+ i++;
+ }
+
+ //populating the Other Values
+ myentries = (gpointer*) *entries;
+ gst_structure_foreach(s, populate_field, (gpointer) myentries);
+
+ elementproperty = g_object_class_find_property(
+ G_OBJECT_GET_CLASS (element), "speechbitrate");
+ if (elementproperty)
+ {
+ pint = G_PARAM_SPEC_INT (elementproperty);
+ (*entries)->minBitRate = pint->minimum;
+ (*entries)->maxBitRate = pint->maximum;
+ }
+
+ (*entries)->profileSetting = XA_AUDIOPROFILE_AMR;
+ (*entries)->modeSetting = 0;
+ (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE;
+ (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE;
+
+ }
+ else
+ {
+ DEBUG_ERR("failed to get the Devsoundsrc(amr encoder) element");
+ }
+ }
+
+ else if (type == XA_AUDIOCODEC_PCM)
+ {
+ element = gst_element_factory_make("wavenc", "encoderelement");
+ if (element)
+ {
+ elementpad = gst_element_get_pad(element, "sink");
+ if (!elementpad)
+ {
+ DEBUG_ERR("failed to get Sink pad on Wave encoder element");
+ return XA_RESULT_INTERNAL_ERROR;
+ }
+ elementcaps = gst_pad_get_caps(elementpad);
+ s = gst_caps_get_structure(elementcaps, 2);
+ myentries = (gpointer*) *entries;
+ gst_structure_foreach(s, populate_field, (gpointer) myentries);
+ elementproperty = g_object_class_find_property(
+ G_OBJECT_GET_CLASS (element), "bitrate");
+ if (elementproperty)
+ {
+ pint = G_PARAM_SPEC_INT (elementproperty);
+ (*entries)->minBitRate = pint->minimum;
+ (*entries)->maxBitRate = pint->maximum;
+ }
+
+ (*entries)->profileSetting = XA_AUDIOPROFILE_PCM;
+ (*entries)->modeSetting = 0;
+ (*entries)->isFreqRangeContinuous = XA_BOOLEAN_TRUE;
+ (*entries)->isBitrateRangeContinuous = XA_BOOLEAN_TRUE;
+ }
+ else
+ {
+ DEBUG_ERR("failed to get the wavencoder element");
+ }
+ }
+
+ if (elementcaps != NULL)
+ gst_caps_unref(elementcaps);
+ if (elementpad != NULL)
+ gst_object_unref(elementpad);
+ if (element != NULL)
+ gst_object_unref(element);
+
+ return XA_RESULT_SUCCESS;
+ }
XAresult XAGSTCapabilitiesMgr_UpdateCapabilitieList(
FrameworkMap *frameworkMap, XACapabilities **ppListHead)
@@ -63,6 +282,20 @@
if (fwtype == FWMgrFWGST)
{
+ GError* gerror = 0;
+ //initialize gstreamer
+ //AL_PROFILING_BEGIN;
+ if (!gst_init_check(NULL, NULL, &gerror))
+ {
+ DEBUG_ERR("Gst Initalization failure.");
+ return XA_RESULT_INTERNAL_ERROR;
+ }
+ //AL_PROFILING_END_PRINT("gst_init_check");
+
+ }
+
+ if (fwtype == FWMgrFWGST)
+ {
/* Add codec capabilities */
newNode = NULL;
res = XAGSTCapabilitiesMgr_GetAudioAACEncoderCapabilities(&newNode);
@@ -179,53 +412,8 @@
newNode->pEntry = (void*) entries;
- entries->maxChannels = 2;
- entries->minBitsPerSample = 16;
- entries->maxBitsPerSample = 16;
- entries->minSampleRate = 8000000; /*milliHz*/
- entries->maxSampleRate = 48000000;
- entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
- entries->numSampleRatesSupported = 7;
- entries->pSampleRatesSupported = (XAmilliHertz*) calloc(
- entries->numSampleRatesSupported, sizeof(XAmilliHertz));
- if (!entries->pSampleRatesSupported)
- {
- res = XA_RESULT_MEMORY_FAILURE;
- XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
- return res;
- }
- /* entries in milliHz */
- entries->pSampleRatesSupported[0] = 8000000;
- entries->pSampleRatesSupported[1] = 11025000;
- entries->pSampleRatesSupported[2] = 16000000;
- entries->pSampleRatesSupported[3] = 22050000;
- entries->pSampleRatesSupported[4] = 32000000;
- entries->pSampleRatesSupported[5] = 44100000;
- entries->pSampleRatesSupported[6] = 48000000;
-
- entries->minBitRate = 32000;
- entries->maxBitRate = 256000;
- entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
- entries->numBitratesSupported = 8;
- entries->pBitratesSupported = (XAuint32*) calloc(
- entries->numBitratesSupported, sizeof(XAuint32));
- if (!entries->pBitratesSupported)
- {
- res = XA_RESULT_MEMORY_FAILURE;
- XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
- return res;
- }
- (entries->pBitratesSupported)[0] = 32000;
- (entries->pBitratesSupported)[1] = 64000;
- (entries->pBitratesSupported)[2] = 96000;
- (entries->pBitratesSupported)[3] = 128000;
- (entries->pBitratesSupported)[4] = 160000;
- (entries->pBitratesSupported)[5] = 192000;
- (entries->pBitratesSupported)[6] = 224000;
- (entries->pBitratesSupported)[7] = 256000;
-
- entries->profileSetting = XA_AUDIOPROFILE_AAC_AAC;
- entries->modeSetting = XA_AUDIOMODE_AAC_LC;
+ res = XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries,
+ newNode->xaid);
newNode->pEntry = (void*) entries;
@@ -263,36 +451,8 @@
newNode->pEntry = (void*) entries;
- entries->maxChannels = 1;
- entries->minBitsPerSample = 8;
- entries->maxBitsPerSample = 8;
- entries->minSampleRate = 8000000; /*milliHz*/
- entries->maxSampleRate = 8000000;
- entries->isFreqRangeContinuous = XA_BOOLEAN_TRUE;
- entries->numSampleRatesSupported = 1;
- entries->minBitRate = 4750;
- entries->maxBitRate = 12200;
- entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
- entries->numBitratesSupported = 8;
- entries->pBitratesSupported = (XAuint32*) calloc(
- entries->numBitratesSupported, sizeof(XAuint32));
- if (!entries->pBitratesSupported)
- {
- res = XA_RESULT_MEMORY_FAILURE;
- XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
- return res;
- }
- (entries->pBitratesSupported)[0] = 4750;
- (entries->pBitratesSupported)[1] = 5150;
- (entries->pBitratesSupported)[2] = 5900;
- (entries->pBitratesSupported)[3] = 6700;
- (entries->pBitratesSupported)[4] = 7400;
- (entries->pBitratesSupported)[5] = 7950;
- (entries->pBitratesSupported)[6] = 10200;
- (entries->pBitratesSupported)[7] = 12200;
-
- entries->profileSetting = XA_AUDIOPROFILE_AMR;
- entries->modeSetting = 0;
+ XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries,
+ newNode->xaid);
newNode->pEntry = (void*) entries;
@@ -330,40 +490,8 @@
newNode->pEntry = (void*) entries;
- entries->maxChannels = 2;
- entries->minBitsPerSample = 16;
- entries->maxBitsPerSample = 16;
- entries->minSampleRate = 8000000; /*milliHz*/
- entries->maxSampleRate = 96000000;
- entries->isFreqRangeContinuous = XA_BOOLEAN_FALSE;
- entries->numSampleRatesSupported = 10;
- entries->pSampleRatesSupported = (XAmilliHertz*) calloc(
- entries->numSampleRatesSupported, sizeof(XAmilliHertz));
- if (!entries->pSampleRatesSupported)
- {
- res = XA_RESULT_MEMORY_FAILURE;
- XACapabilitiesMgr_DeleteCapabilitieList(&newNode);
- return res;
- }
- /* entries in milliHz */
- entries->pSampleRatesSupported[0] = 12000000;
- entries->pSampleRatesSupported[1] = 16000000;
- entries->pSampleRatesSupported[2] = 22050000;
- entries->pSampleRatesSupported[3] = 24000000;
- entries->pSampleRatesSupported[4] = 32000000;
- entries->pSampleRatesSupported[5] = 44100000;
- entries->pSampleRatesSupported[6] = 48000000;
- entries->pSampleRatesSupported[7] = 64000000;
- entries->pSampleRatesSupported[8] = 88200000;
- entries->pSampleRatesSupported[9] = 96000000;
-
- entries->minBitRate = 0;
- entries->maxBitRate = 0;
- entries->isBitrateRangeContinuous = XA_BOOLEAN_FALSE;
- entries->pBitratesSupported = NULL;
- entries->numBitratesSupported = 0;
- entries->profileSetting = XA_AUDIOPROFILE_PCM;
- entries->modeSetting = 0;
+ XAGSTCapabilitiesMgr_GetCapabilities_FromGstElement(&entries,
+ newNode->xaid);
newNode->pEntry = (void*) entries;