khronosfws/openmax_al/src/common/xadynamicsourceitf.c
changeset 12 5a06f39ad45b
child 16 43d09473c595
equal deleted inserted replaced
0:71ca22bcf22a 12:5a06f39ad45b
       
     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 
       
    18 #include <stdio.h>
       
    19 #include <stdlib.h>
       
    20 #include <assert.h>
       
    21 #include "xadynamicsourceitf.h"
       
    22 #ifdef _GSTREAMER_BACKEND_   
       
    23 #include "XAAdaptationContextBase.h"
       
    24 #include "XADynamicSourceItfAdaptation.h"
       
    25 #endif
       
    26 
       
    27 /*****************************************************************************
       
    28  * Base interface XADynamicSourceItf implementation
       
    29  *****************************************************************************/
       
    30 
       
    31 /* XAResult XADynamicSourceItfImpl_SetSource
       
    32  * Description: Sets the data source for the object.
       
    33  */
       
    34 XAresult XADynamicSourceItfImpl_SetSource(XADynamicSourceItf self,
       
    35                                           XADataSource *pDataSource)
       
    36 {
       
    37     XAresult res = XA_RESULT_SUCCESS;
       
    38     XADynamicSourceItfImpl* impl = (XADynamicSourceItfImpl*)(*self);
       
    39     DEBUG_API("->XADynamicSourceItfImpl_SetSource");
       
    40     /* check casting */
       
    41     if( !impl ||  impl != impl->self || !pDataSource )
       
    42     {
       
    43         DEBUG_ERR("XA_RESULT_PARAMETER_INVALID");
       
    44         DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    45         return XA_RESULT_PARAMETER_INVALID;
       
    46     }
       
    47 #ifdef _GSTREAMER_BACKEND_   
       
    48     if( !impl->adaptCtx )
       
    49     {
       
    50         DEBUG_ERR("Adaptation not ready!!");
       
    51         DEBUG_ERR("XA_RESULT_INTERNAL_ERROR");
       
    52         DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    53         res = XA_RESULT_INTERNAL_ERROR;
       
    54     }
       
    55     else
       
    56     {
       
    57         res = XACommon_CheckDataSource(pDataSource,NULL);
       
    58         if(res==XA_RESULT_SUCCESS)
       
    59         {
       
    60             res = XADynamicSourceItfAdapt_SetSource(impl->adaptCtx, pDataSource );
       
    61         }
       
    62     }
       
    63 #endif
       
    64     DEBUG_API("<-XADynamicSourceItfImpl_SetSource");
       
    65     return res;
       
    66 }
       
    67 
       
    68 /*****************************************************************************
       
    69  * XADynamicSourceItfImpl -specific methods
       
    70  *****************************************************************************/
       
    71 #ifdef _GSTREAMER_BACKEND_   
       
    72 
       
    73 /* XADynamicSourceItfImpl* XADynamicSourceItfImpl_Create()
       
    74  * Description: Allocate and initialize DynamicSourceItfImpl
       
    75  */
       
    76 XADynamicSourceItfImpl* XADynamicSourceItfImpl_Create( XAAdaptationBaseCtx *adaptCtx )
       
    77 {
       
    78     XADynamicSourceItfImpl* self = (XADynamicSourceItfImpl*)
       
    79         calloc(1,sizeof(XADynamicSourceItfImpl));
       
    80     DEBUG_API("->XADynamicSourceItfImpl_Create");
       
    81     if( self )
       
    82     {
       
    83         /* init itf default implementation */
       
    84         self->itf.SetSource = XADynamicSourceItfImpl_SetSource;
       
    85         /* init variables */
       
    86         self->adaptCtx = adaptCtx;
       
    87         self->self = self;
       
    88     }
       
    89     DEBUG_API("<-XADynamicSourceItfImpl_Create");
       
    90     return self;
       
    91 }
       
    92 #endif
       
    93 /* void XADynamicSourceItfImpl_Free(XADynamicSourceItfImpl* self)
       
    94  * Description: Free all resources reserved at XADynamicSourceItfImpl_Create
       
    95  */
       
    96 void XADynamicSourceItfImpl_Free(XADynamicSourceItfImpl* self)
       
    97 {
       
    98     DEBUG_API("->XADynamicSourceItfImpl_Free");
       
    99     assert( self==self->self );
       
   100     free( self );
       
   101     DEBUG_API("<-XADynamicSourceItfImpl_Free");
       
   102 }
       
   103 
       
   104