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