khronosfws/openmax_al/src/mmf_adaptation/xastreaminformationitfadaptationmmf.c
changeset 25 6f7ceef7b1d1
parent 19 4a629bc82c5e
child 33 5e8b14bae8c3
equal deleted inserted replaced
21:2ed61feeead6 25:6f7ceef7b1d1
     1 /**
     1 /*
     2  * src\adaptation\XAStreamInformationItfAdaptation.c
     2  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3  * Part of OpenMAX AL Implementation
     3  * All rights reserved.
     4  * Copyright (c) 2009 Nokia Inc.
     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".
     5  *
     8  *
     6  * This file contains implementation of XAStreamInformationItfAdaptation
     9  * Initial Contributors:
     7  **/
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description: StreamInfo Itf Adaptation MMF
       
    15  *
       
    16  */
     8 
    17 
     9 #include "xadebug.h"
    18 #include "xadebug.h"
    10 #include "xathreadsafety.h"
    19 #include "xathreadsafety.h"
    11 #include "xamediaplayeradaptctxmmf.h"
    20 #include "xamediaplayeradaptctxmmf.h"
    12 #include "xastreaminformationitfadaptationmmf.h"
    21 #include "xastreaminformationitfadaptationmmf.h"
    16  * XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation(
    25  * XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation(
    17  *   XAAdaptationBaseCtx *adaptCtx,
    26  *   XAAdaptationBaseCtx *adaptCtx,
    18  *   XAMediaContainerInformation *info);
    27  *   XAMediaContainerInformation *info);
    19  * Description: Obtains media container information
    28  * Description: Obtains media container information
    20  */
    29  */
    21 XAresult  XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation(
    30 XAresult XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation(
    22     XAAdaptationBaseCtx *adaptCtx,
    31         XAAdaptationBaseCtx *adaptCtx, XAuint32 *containerType,
    23     XAuint32 *containerType,
    32         XAmillisecond *mediaDuration, XAuint32 *numStreams)
    24     XAmillisecond *mediaDuration,
    33     {
    25     XAuint32 *numStreams)
       
    26 {
       
    27     XAresult ret = XA_RESULT_SUCCESS;
    34     XAresult ret = XA_RESULT_SUCCESS;
    28     XADataSource *xaDataSource = NULL;
    35     XADataSource *xaDataSource = NULL;
    29 
    36 
    30     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
    37     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
    31     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
    38     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
    32     if( !adaptCtx ||
    39     if (!adaptCtx || (adaptCtx->ctxId != XAMediaPlayerAdaptation))
    33         (adaptCtx->ctxId != XAMediaPlayerAdaptation) )
    40         {
    34 /*        !((adaptCtx->ctxId == XAMediaPlayerAdaptation) ||
    41         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
    35          (adaptCtx->ctxId == XAMDAdaptation) ) )
    42         return XA_RESULT_PARAMETER_INVALID;
    36 */
    43         }
    37     {
       
    38         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    39         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
       
    40         return XA_RESULT_PARAMETER_INVALID;
       
    41     }
       
    42 
    44 
    43     /* Initialize to unspecified */
    45     /* Initialize to unspecified */
    44     *containerType = XA_CONTAINERTYPE_UNSPECIFIED;
    46     *containerType = XA_CONTAINERTYPE_UNSPECIFIED;
    45     xaDataSource = ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->xaSource;
    47     xaDataSource = ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->xaSource;
    46 /*    DEBUG_INFO("Obtained handle to xaDataSource");*/
    48     /*    DEBUG_INFO("Obtained handle to xaDataSource");*/
    47     if ( xaDataSource &&
    49     if (xaDataSource && xaDataSource->pFormat
    48          xaDataSource->pFormat &&
    50             && ((*(XAuint32*) xaDataSource->pFormat) == XA_DATAFORMAT_MIME))
    49          ( (*(XAuint32*)xaDataSource->pFormat ) == XA_DATAFORMAT_MIME) )
    51         {
    50     {
    52         *containerType
    51         *containerType = ((XADataFormat_MIME*)(xaDataSource->pFormat))->containerType;
    53                 = ((XADataFormat_MIME*) (xaDataSource->pFormat))->containerType;
    52         DEBUG_INFO_A1("Container type obtained from xaDataSource->pFormat is [%u]", (unsigned int)(*containerType));
    54         DEBUG_INFO_A1("Container type obtained from xaDataSource->pFormat is [%u]", (unsigned int)(*containerType));
    53     }
    55         }
    54     else
    56     else
    55     {
    57         {
    56         DEBUG_INFO("Container type unspecified");
    58         DEBUG_INFO("Container type unspecified");
    57     }
    59         }
    58 
    60 
    59     /* Get media duration */
    61     /* Get media duration */
    60     ret = XAPlayItfAdaptMMF_GetDuration(adaptCtx, mediaDuration);
    62     ret = XAPlayItfAdaptMMF_GetDuration(adaptCtx, mediaDuration);
    61     if ( ret != XA_RESULT_SUCCESS )
    63     if (ret != XA_RESULT_SUCCESS)
    62         return ret;
    64         {
    63 
    65         return ret;
    64     ret = mmf_streaminformationitf_get_numstreams(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
    66         }
    65                                                     numStreams);
    67 
       
    68     ret = mmf_streaminformationitf_get_numstreams(
       
    69             ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
       
    70             numStreams);
    66 
    71 
    67     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
    72     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryMediaContainerInformation");
    68     return ret;
    73     return ret;
    69 }
    74     }
    70 
    75 
    71 /*
    76 /*
    72  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamType(
    77  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamType(
    73  *               XAAdaptationBaseCtx *adaptCtx,
    78  *               XAAdaptationBaseCtx *adaptCtx,
    74  *               XAuint32 streamIndex,
    79  *               XAuint32 streamIndex,
    75  *               XAuint32 *domain)
    80  *               XAuint32 *domain)
    76  * Description: Obtains stream type information
    81  * Description: Obtains stream type information
    77  */
    82  */
    78 XAresult XAStreamInformationItfAdaptMMF_QueryStreamType(
    83 XAresult XAStreamInformationItfAdaptMMF_QueryStreamType(
    79                 XAAdaptationBaseCtx *adaptCtx,
    84         XAAdaptationBaseCtx *adaptCtx, XAuint32 streamIndex, XAuint32 *domain)
    80                 XAuint32 streamIndex,
    85     {
    81                 XAuint32 *domain)
       
    82 {
       
    83     XAresult ret;
    86     XAresult ret;
    84     XAuint32 numStreams;
    87     XAuint32 numStreams;
    85     XADataSource *xaDataSource = NULL;
    88     XADataSource *xaDataSource = NULL;
    86 
    89 
       
    90     if (!adaptCtx || !domain)
       
    91         {
       
    92         ret = XA_RESULT_PARAMETER_INVALID;
       
    93         return ret;
       
    94         }
    87 
    95 
    88     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamType");
    96     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamType");
    89 
    97 
    90     ret = mmf_streaminformationitf_get_numstreams(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
    98     ret = mmf_streaminformationitf_get_numstreams(
    91                                                     &numStreams);
    99             ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
    92     if (ret != XA_RESULT_SUCCESS)
   100             &numStreams);
    93     {
   101     if (ret != XA_RESULT_SUCCESS)
    94         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   102         {
    95         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
   103         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
    96         return ret;
   104         return ret;
    97     }
   105         }
    98 
   106 
    99     /* validate stream index */
   107     /* validate stream index */
   100     if ( streamIndex > numStreams )
   108     if (streamIndex > numStreams)
   101     {
   109         {
   102         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   110         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
   103         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
   111         return XA_RESULT_PARAMETER_INVALID;
   104         return XA_RESULT_PARAMETER_INVALID;
   112         }
   105     }
       
   106 
   113 
   107     /* if format type is raw image */
   114     /* if format type is raw image */
   108     xaDataSource = ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->xaSource;
   115     xaDataSource = ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->xaSource;
   109     if( xaDataSource->pFormat &&
   116     if (xaDataSource && xaDataSource->pFormat
   110       ( (*(XAuint32*)xaDataSource->pFormat ) == XA_DATAFORMAT_RAWIMAGE) )
   117             && ((*(XAuint32*) xaDataSource->pFormat)
   111     {
   118                     == XA_DATAFORMAT_RAWIMAGE))
       
   119         {
   112         *domain = XA_DOMAINTYPE_IMAGE;
   120         *domain = XA_DOMAINTYPE_IMAGE;
   113         return XA_RESULT_SUCCESS;
   121         return XA_RESULT_SUCCESS;
   114     }
   122         }
   115     else
   123     else
   116     {
   124         {
   117     ret = mmf_streaminformationitf_get_streaminfo(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
   125         ret = mmf_streaminformationitf_get_streaminfo(
   118                                                     streamIndex,domain);
   126                 ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
   119     }
   127                 streamIndex, domain);
       
   128         }
   120 
   129 
   121     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
   130     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamType");
   122     return ret;
   131     return ret;
   123 }
   132     }
   124 
   133 
   125 /*
   134 /*
   126  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamInformation(
   135  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamInformation(
   127  *               XAAdaptationBaseCtx *adaptCtx,
   136  *               XAAdaptationBaseCtx *adaptCtx,
   128  *               XAuint32 streamIndex,
   137  *               XAuint32 streamIndex,
   129  *               void * info)
   138  *               void * info)
   130  * Description: Obtains stream information
   139  * Description: Obtains stream information
   131  */
   140  */
   132 XAresult XAStreamInformationItfAdaptMMF_QueryStreamInformation(
   141 XAresult XAStreamInformationItfAdaptMMF_QueryStreamInformation(
   133                 XAAdaptationBaseCtx *adaptCtx,
   142         XAAdaptationBaseCtx *adaptCtx, XAuint32 streamIndex, void * info)
   134                 XAuint32 streamIndex,
   143     {
   135                 void * info)
       
   136 {
       
   137     XAresult ret = XA_RESULT_SUCCESS;
   144     XAresult ret = XA_RESULT_SUCCESS;
   138     XAuint32 domain;
   145     XAuint32 domain;
   139     XAuint32 codecId;
   146     XAuint32 codecId;
   140     XAuint32 channels;
   147     XAuint32 channels;
   141     XAmilliHertz sampleRate;
   148     XAmilliHertz sampleRate;
   143     XAmillisecond duration;
   150     XAmillisecond duration;
   144     XAuint32 width;
   151     XAuint32 width;
   145     XAuint32 height;
   152     XAuint32 height;
   146     XAuint32 frameRate;
   153     XAuint32 frameRate;
   147     void* mmfctx;
   154     void* mmfctx;
   148     
   155 
   149     mmfctx = ((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext;
   156     if (!adaptCtx || !info)
   150 /*    GstElement *codecbin = NULL;*/
   157         {
       
   158         ret = XA_RESULT_PARAMETER_INVALID;
       
   159         return ret;
       
   160         }
       
   161 
       
   162     mmfctx = ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext;
   151 
   163 
   152     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   164     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   153 
   165 
   154     /* stream index is validated in XAStreamInformationItfAdaptMMF_QueryStreamType */
   166     /* stream index is validated in XAStreamInformationItfAdaptMMF_QueryStreamType */
   155     ret = XAStreamInformationItfAdaptMMF_QueryStreamType(
   167     ret = XAStreamInformationItfAdaptMMF_QueryStreamType(adaptCtx,
   156             adaptCtx, streamIndex, &domain);
   168             streamIndex, &domain);
   157 
   169 
   158     if (ret != XA_RESULT_SUCCESS)
   170     if (ret != XA_RESULT_SUCCESS)
   159     {
   171         {
   160         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   172         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   161         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   173         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   162         return ret;
   174         return ret;
   163     }
   175         }
   164     if ( domain == XA_DOMAINTYPE_UNKNOWN )
   176 
   165     {
   177     switch (domain)
   166         DEBUG_ERR("XA_RESULT_CONTENT_UNSUPPORTED");
   178         {
   167         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
       
   168         return XA_RESULT_CONTENT_UNSUPPORTED;
       
   169     }
       
   170 
       
   171     switch(domain)
       
   172     {
       
   173         case XA_DOMAINTYPE_AUDIO:
   179         case XA_DOMAINTYPE_AUDIO:
   174             DEBUG_INFO("Getting Audio Stream Info from Backend Engine");
   180             DEBUG_INFO("Getting Audio Stream Info from Backend Engine");
   175             ret = mmf_get_channels(mmfctx, &channels);
   181             ret = mmf_get_channels(mmfctx, &channels);
   176             ret = mmf_get_samplerate(mmfctx, &sampleRate);
   182             ret = mmf_get_samplerate(mmfctx, &sampleRate);
   177             ret = mmf_get_bitrate(mmfctx, &bitRate);
   183             ret = mmf_get_bitrate(mmfctx, &bitRate);
   178             ret = mmf_get_codec_id(mmfctx, &codecId);
   184             ret = mmf_get_codec_id(mmfctx, &codecId);
   179             break;
   185             break;
   180         case XA_DOMAINTYPE_VIDEO:
   186         case XA_DOMAINTYPE_VIDEO:
   181             DEBUG_INFO("Getting Video Stream Info from Backend Engine");
   187             DEBUG_INFO("Getting Video Stream Info from Backend Engine");
   182             ret = mmf_get_bitrate(mmfctx, &bitRate);
   188             ret = mmf_get_bitrate(mmfctx, &bitRate);
   183             ret = mmf_get_codec_id(mmfctx, &codecId);   
   189             ret = mmf_get_codec_id(mmfctx, &codecId);
   184             ret = mmf_streaminformationitf_get_videoframesize(mmfctx, &height, &width, &frameRate);
   190             ret = mmf_streaminformationitf_get_videoframesize(mmfctx,
       
   191                     &height, &width, &frameRate);
   185             break;
   192             break;
   186         case XA_DOMAINTYPE_IMAGE:
   193         case XA_DOMAINTYPE_IMAGE:
   187             DEBUG_INFO("Getting Image Stream Info from SrcPad");
   194             DEBUG_INFO("Getting Image Stream Info from SrcPad");
   188             break;
   195             break;
   189         default:
   196         default:
       
   197             DEBUG_ERR("XA_RESULT_CONTENT_UNSUPPORTED");
       
   198             DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
       
   199             ret = XA_RESULT_CONTENT_UNSUPPORTED;
   190             break;
   200             break;
   191     };
   201         };
   192 
   202 
   193 
   203     if (ret == XA_RESULT_SUCCESS)
   194     if ( ret == XA_RESULT_SUCCESS)
   204         {
   195     {
       
   196         DEBUG_INFO("Getting media duration");
   205         DEBUG_INFO("Getting media duration");
   197         ret = XAPlayItfAdaptMMF_GetDuration(adaptCtx, &duration);
   206         ret = XAPlayItfAdaptMMF_GetDuration(adaptCtx, &duration);
   198     }
   207         }
   199 
   208 
   200     /* Now assign properties to data structure */
   209     /* Now assign properties to data structure */
   201     if ( ret == XA_RESULT_SUCCESS)
   210     if (ret == XA_RESULT_SUCCESS)
   202     {
   211         {
   203         switch(domain)
   212         switch (domain)
   204         {
   213             {
   205             case XA_DOMAINTYPE_AUDIO:
   214             case XA_DOMAINTYPE_AUDIO:
   206             {
   215                 {
   207                 XAAudioStreamInformation* streamInfo = (XAAudioStreamInformation*)info;
   216                 XAAudioStreamInformation* streamInfo =
       
   217                         (XAAudioStreamInformation*) info;
   208                 DEBUG_INFO("Assigning values for XAAudioStreamInformation");
   218                 DEBUG_INFO("Assigning values for XAAudioStreamInformation");
   209                 streamInfo->codecId = codecId;
   219                 streamInfo->codecId = codecId;
   210                 streamInfo->channels = channels;
   220                 streamInfo->channels = channels;
   211                 streamInfo->sampleRate = sampleRate;
   221                 streamInfo->sampleRate = sampleRate;
   212                 streamInfo->bitRate = bitRate;
   222                 streamInfo->bitRate = bitRate;
   213                 streamInfo->langCountry[0] = '\0';
   223                 streamInfo->langCountry[0] = '\0';
   214                 streamInfo->duration = duration;
   224                 streamInfo->duration = duration;
   215             }
   225                 }
   216                 break;
   226                 break;
   217             case XA_DOMAINTYPE_MIDI:
   227             case XA_DOMAINTYPE_MIDI:
   218             {
   228                 {
   219                 XAMIDIStreamInformation* streamInfo = (XAMIDIStreamInformation*)info;
   229                 XAMIDIStreamInformation* streamInfo =
       
   230                         (XAMIDIStreamInformation*) info;
   220                 DEBUG_INFO("Assigning values for XAMIDIStreamInformation");
   231                 DEBUG_INFO("Assigning values for XAMIDIStreamInformation");
   221                 /*currently there is no way to get these information from gstreamer*/
   232                 /*currently there is no way to get these information from gstreamer*/
   222                 streamInfo->channels = XA_MIDI_UNKNOWN;
   233                 streamInfo->channels = XA_MIDI_UNKNOWN;
   223                 streamInfo->tracks = XA_MIDI_UNKNOWN;
   234                 streamInfo->tracks = XA_MIDI_UNKNOWN;
   224                 streamInfo->bankType = XA_MIDIBANK_DEVICE;
   235                 streamInfo->bankType = XA_MIDIBANK_DEVICE;
   225                 /*streamInfo->bitRate = 0;*/
   236                 /*streamInfo->bitRate = 0;*/
   226                 streamInfo->langCountry[0] = '\0';
   237                 streamInfo->langCountry[0] = '\0';
   227                 streamInfo->duration = duration;
   238                 streamInfo->duration = duration;
   228             }
   239                 }
   229                 break;
   240                 break;
   230             case XA_DOMAINTYPE_VIDEO:
   241             case XA_DOMAINTYPE_VIDEO:
   231             {
   242                 {
   232                 XAVideoStreamInformation* streamInfo = (XAVideoStreamInformation*)info;
   243                 XAVideoStreamInformation* streamInfo =
       
   244                         (XAVideoStreamInformation*) info;
   233                 DEBUG_INFO("Assigning values for XAVideoStreamInformation");
   245                 DEBUG_INFO("Assigning values for XAVideoStreamInformation");
   234                 streamInfo->codecId = codecId;
   246                 streamInfo->codecId = codecId;
   235                 streamInfo->width = width;
   247                 streamInfo->width = width;
   236                 streamInfo->height = height;
   248                 streamInfo->height = height;
   237                 streamInfo->bitRate = bitRate;
   249                 streamInfo->bitRate = bitRate;
   238                 streamInfo->duration = duration;
   250                 streamInfo->duration = duration;
   239                 streamInfo->frameRate = frameRate;
   251                 streamInfo->frameRate = frameRate;
   240             }
   252                 }
   241                 break;
   253                 break;
   242             case XA_DOMAINTYPE_IMAGE:
   254             case XA_DOMAINTYPE_IMAGE:
   243             {
   255                 {
   244                 XAImageStreamInformation* streamInfo = (XAImageStreamInformation*)info;
   256                 XAImageStreamInformation* streamInfo =
       
   257                         (XAImageStreamInformation*) info;
   245                 DEBUG_INFO("Assigning values for XAImageStreamInformation");
   258                 DEBUG_INFO("Assigning values for XAImageStreamInformation");
   246                 streamInfo->codecId = codecId;
   259                 streamInfo->codecId = codecId;
   247                 streamInfo->width = width;
   260                 streamInfo->width = width;
   248                 streamInfo->height = height;
   261                 streamInfo->height = height;
   249                 streamInfo->presentationDuration = duration;
   262                 streamInfo->presentationDuration = duration;
   250             }
   263                 }
   251                 break;
   264                 break;
   252             default:
   265             default:
   253                 break;
   266                 break;
   254         };
   267             };
   255     } /*if ( ret == XA_RESULT_SUCCESS)*/
   268         } /*if ( ret == XA_RESULT_SUCCESS)*/
   256 
   269 
   257     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   270     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamInformation");
   258     return ret;
   271     return ret;
   259 }
   272     }
   260 
   273 
   261 /*
   274 /*
   262  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamName(
   275  * XAresult XAStreamInformationItfAdaptMMF_QueryStreamName(
   263  *               XAAdaptationBaseCtx *adaptCtx,
   276  *               XAAdaptationBaseCtx *adaptCtx,
   264  *               XAuint32 streamIndex,
   277  *               XAuint32 streamIndex,
   265  *               XAuint16 * pNameSize,
   278  *               XAuint16 * pNameSize,
   266  *               XAchar * pName)
   279  *               XAchar * pName)
   267  * Description: Obtains stream name
   280  * Description: Obtains stream name
   268  */
   281  */
   269 XAresult XAStreamInformationItfAdaptMMF_QueryStreamName(
   282 XAresult XAStreamInformationItfAdaptMMF_QueryStreamName(
   270                 XAAdaptationBaseCtx *adaptCtx,
   283         XAAdaptationBaseCtx *adaptCtx, XAuint32 streamIndex,
   271                 XAuint32 streamIndex,
   284         XAuint16 * pNameSize, XAchar * pName)
   272                 XAuint16 * pNameSize,
   285     {
   273                 XAchar * pName)
       
   274 {
       
   275     XAresult ret = XA_RESULT_SUCCESS;
   286     XAresult ret = XA_RESULT_SUCCESS;
   276     XAuint32 numStreams;
   287     XAuint32 numStreams;
   277 
   288 
   278     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamName");
   289     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryStreamName");
   279     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   290     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   280     if( !adaptCtx ||
   291     if (!adaptCtx || !pNameSize || (adaptCtx->ctxId
   281         (adaptCtx->ctxId != XAMediaPlayerAdaptation) )
   292             != XAMediaPlayerAdaptation))
   282     {
   293         {
   283         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   294         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   284         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   295         return XA_RESULT_PARAMETER_INVALID;
   285         return XA_RESULT_PARAMETER_INVALID;
   296         }
   286     }
       
   287 
   297 
   288     /* validate stream index */
   298     /* validate stream index */
   289     ret = mmf_streaminformationitf_get_numstreams(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
   299     ret = mmf_streaminformationitf_get_numstreams(
   290                                                     &numStreams);
   300             ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
   291     if (ret != XA_RESULT_SUCCESS)
   301             &numStreams);
   292     {
   302     if (ret != XA_RESULT_SUCCESS)
   293         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   303         {
   294         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   304         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   295         return ret;
   305         return ret;
   296     }
   306         }
   297 
   307 
   298     /* validate stream index */
   308     /* validate stream index */
   299     if ( streamIndex > numStreams )
   309     if (streamIndex > numStreams)
   300     {
   310         {
   301         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   311         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   302         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   312         return XA_RESULT_PARAMETER_INVALID;
   303         return XA_RESULT_PARAMETER_INVALID;
   313         }
   304     }
       
   305 
   314 
   306     /* TODO there is no straight way to retreive stream name from mmf*/
   315     /* TODO there is no straight way to retreive stream name from mmf*/
   307     /*XAuint16 inputNameSize = *pNameSize;*/
   316     /*XAuint16 inputNameSize = *pNameSize;*/
   308     *pNameSize = 0; /* Replace this with actual size*/
   317     *pNameSize = 0; /* Replace this with actual size*/
   309     if ( pName )
   318     if (pName)
   310     {
   319         {
   311     /* TODO copy stream name into pName taking into account inputNameSize */
   320         /* TODO copy stream name into pName taking into account inputNameSize */
   312     }
   321         }
   313 
   322 
   314     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   323     DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryStreamName");
   315     return ret;
   324     return ret;
   316 }
   325     }
   317 
   326 
   318 /*
   327 /*
   319  * XAresult XAStreamInformationItfAdaptMMF_QueryActiveStreams(
   328  * XAresult XAStreamInformationItfAdaptMMF_QueryActiveStreams(
   320  *               XAAdaptationBaseCtx *adaptCtx,
   329  *               XAAdaptationBaseCtx *adaptCtx,
   321  *               XAuint32 *numStreams,
   330  *               XAuint32 *numStreams,
   322  *               XAboolean *activeStreams);
   331  *               XAboolean *activeStreams);
   323  * Description: Obtains active stream information
   332  * Description: Obtains active stream information
   324  */
   333  */
   325  XAresult XAStreamInformationItfAdaptMMF_QueryActiveStreams(
   334 XAresult XAStreamInformationItfAdaptMMF_QueryActiveStreams(
   326                 XAAdaptationBaseCtx *adaptCtx,
   335         XAAdaptationBaseCtx *adaptCtx, XAuint32 *numStreams,
   327                 XAuint32 *numStreams,
   336         XAboolean *activeStreams)
   328                 XAboolean *activeStreams)
   337     {
   329 {
       
   330     XAresult ret = XA_RESULT_SUCCESS;
   338     XAresult ret = XA_RESULT_SUCCESS;
   331     XAuint32 inputNumStreams;
   339     XAuint32 inputNumStreams;
   332 
   340 
   333     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   341     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   334 
   342 
   335     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   343     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   336     if( !adaptCtx ||
   344     if (!adaptCtx  || !numStreams || (adaptCtx->ctxId
   337         (adaptCtx->ctxId != XAMediaPlayerAdaptation) )
   345             != XAMediaPlayerAdaptation))
   338     {
   346         {
   339         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   347         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   340         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   348         return XA_RESULT_PARAMETER_INVALID;
   341         return XA_RESULT_PARAMETER_INVALID;
   349         }
   342     }
   350 
   343 
   351     if (adaptCtx->ctxId == XAMDAdaptation)
   344     if( adaptCtx->ctxId ==  XAMDAdaptation)
   352         {
   345     {
   353         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   346         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
       
   347         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
       
   348         return XA_RESULT_PRECONDITIONS_VIOLATED;
   354         return XA_RESULT_PRECONDITIONS_VIOLATED;
   349     }
   355         }
   350 
   356 
   351     /* Determine number of streams */
   357     /* Determine number of streams */
   352     ret = mmf_streaminformationitf_get_numstreams(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
   358     ret = mmf_streaminformationitf_get_numstreams(
   353                                                     &inputNumStreams);
   359             ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
   354     if (ret != XA_RESULT_SUCCESS)
   360             &inputNumStreams);
   355     {
   361     if (ret != XA_RESULT_SUCCESS)
   356         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   362         {
   357         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   363         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   358         return ret;
   364         return ret;
   359     }
   365         }
   360 
   366 
   361     if ( activeStreams )
   367     if (activeStreams)
   362     {
   368         {
   363         XAuint32 loopIndex;
   369         XAuint32 loopIndex;
   364         if (*numStreams < inputNumStreams)
   370         if (*numStreams < inputNumStreams)
   365         {
   371             {
   366             DEBUG_INFO("numStreams param value is smaller than number of streams");
   372             DEBUG_INFO("numStreams param value is smaller than number of streams");DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   367             DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
   368             DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
       
   369             return XA_RESULT_PARAMETER_INVALID;
   373             return XA_RESULT_PARAMETER_INVALID;
   370         }
   374             }
   371         for (loopIndex = 0; loopIndex < inputNumStreams; loopIndex++)
   375         for (loopIndex = 0; loopIndex < inputNumStreams; loopIndex++)
   372         {
   376             {
   373             /* TODO currently gstreamer doesn't allow multiple dynamic streams
   377             /* TODO currently gstreamer doesn't allow multiple dynamic streams
   374              * all streams are active streams */
   378              * all streams are active streams */
   375             activeStreams[loopIndex] = XA_BOOLEAN_TRUE;
   379             activeStreams[loopIndex] = XA_BOOLEAN_TRUE;
   376         }
   380             }
   377     }
   381         }
   378     else
   382     else
   379         {
   383         {
   380         *numStreams = inputNumStreams;
   384         *numStreams = inputNumStreams;
   381         }
   385         }
   382 
   386 
   383     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   387     DEBUG_API("->XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   384     return XA_RESULT_SUCCESS;
   388     return XA_RESULT_SUCCESS;
   385 }
   389     }
   386 
   390 
   387 XAresult XAStreamInformationItfAdaptMMF_SetActiveStream(
   391 XAresult XAStreamInformationItfAdaptMMF_SetActiveStream(
   388                 XAAdaptationBaseCtx *adaptCtx,
   392         XAAdaptationBaseCtx *adaptCtx, XAuint32 streamNum, XAboolean active,
   389                 XAuint32 streamNum,
   393         XAboolean commitNow)
   390                 XAboolean active,
   394     {
   391                 XAboolean commitNow)
       
   392 {
       
   393     XAresult ret = XA_RESULT_SUCCESS;
   395     XAresult ret = XA_RESULT_SUCCESS;
   394     XAuint32 numStreams;
   396     XAuint32 numStreams;
   395 
   397 
   396     DEBUG_API("->XAStreamInformationItfAdaptMMF_SetActiveStream");
   398     DEBUG_API("->XAStreamInformationItfAdaptMMF_SetActiveStream");
   397 
   399 
   398     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   400     /* Both Media Player and Metadata Extractor objec uses the same ctxId */
   399     if( !adaptCtx ||
   401     if (!adaptCtx || (adaptCtx->ctxId != XAMediaPlayerAdaptation))
   400         (adaptCtx->ctxId != XAMediaPlayerAdaptation) )
   402         {
   401     {
   403         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
   402         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   404         return XA_RESULT_PARAMETER_INVALID;
   403         DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
   405         }
   404         return XA_RESULT_PARAMETER_INVALID;
   406 
   405     }
   407     if (adaptCtx->ctxId == XAMDAdaptation)
   406 
   408         {
   407     if( adaptCtx->ctxId ==  XAMDAdaptation)
   409         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
   408     {
       
   409         DEBUG_ERR("XA_RESULT_PRECONDITIONS_VIOLATED");
       
   410         DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
       
   411         return XA_RESULT_PRECONDITIONS_VIOLATED;
   410         return XA_RESULT_PRECONDITIONS_VIOLATED;
   412     }
   411         }
   413 
   412 
   414     /* Determine number of streams */
   413     /* Determine number of streams */
   415     ret = mmf_streaminformationitf_get_numstreams(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
   414     ret = mmf_streaminformationitf_get_numstreams(
   416                                                     &numStreams);
   415             ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
   417     if (ret != XA_RESULT_SUCCESS)
   416             &numStreams);
   418     {
   417     if (ret != XA_RESULT_SUCCESS)
   419         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);
   418         {
   420         DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   419         DEBUG_ERR_A1("XA_RESULT_[0x%x]", (unsigned int)ret);DEBUG_API("-<XAStreamInformationItfAdaptMMF_QueryActiveStreams");
   421         return ret;
   420         return ret;
   422     }
   421         }
   423 
   422 
   424     /* validate stream index */
   423     /* validate stream index */
   425     if ( streamNum > numStreams )
   424     if (streamNum > numStreams)
   426     {
   425         {
   427         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
   426         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
   428         DEBUG_API("-<XAStreamInformationItfAdaptMMF_SetActiveStream");
   427         return XA_RESULT_PARAMETER_INVALID;
   429         return XA_RESULT_PARAMETER_INVALID;
   428         }
   430     }
   429 
   431 
   430     if (commitNow)
   432     if(commitNow)
   431         {
   433         {
   432         ret = mmf_streaminformationitf_set_activestream(
   434         ret = mmf_streaminformationitf_set_activestream(((XAMediaPlayerAdaptationMMFCtx*)adaptCtx)->mmfContext,
   433                 ((XAMediaPlayerAdaptationMMFCtx*) adaptCtx)->mmfContext,
   435                                                             streamNum, active);
   434                 streamNum, active);
   436         }
   435         }
   437 
   436 
   438     DEBUG_API("->XAStreamInformationItfAdaptMMF_SetActiveStream");
   437     DEBUG_API("->XAStreamInformationItfAdaptMMF_SetActiveStream");
   439     return ret;
   438     return ret;
   440 }
   439     }
   441 
   440 
   442