Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 // -*- c++ -*-
     19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
     20 
     21 //               P V M I _ C A P A B I L I T Y _ A N D _ C O N F I G
     22 
     23 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
     24 
     25 /*! \addtogroup pvmicapability PvmiCapability
     26 *
     27 * @{
     28 */
     29 
     30 
     31 /*! \file pvmi_config_and_capability_utils.h
     32 \brief This file contains a simple implementation
     33 of config and capability for setting port data format
     34 only.
     35 */
     36 
     37 #ifndef PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
     38 #define PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
     39 
     40 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
     41 #include "pvmi_config_and_capability.h"
     42 #endif
     43 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
     44 #include "oscl_string_containers.h"
     45 #endif
     46 
     47 //A static routine to set a port format using setParametersSync.
     48 //The call may leave.
     49 class PVMFPortInterface;
     50 OSCL_IMPORT_REF void pvmiSetPortFormatSync(PvmiCapabilityAndConfig *aPort, const char* aFormatValType, PVMFFormatType aFormat);
     51 
     52 // A routing to allocate a Kvp
     53 OSCL_IMPORT_REF PVMFStatus AllocateKvp(OsclMemAllocator& aAlloc, PvmiKvp*& aKvp, PvmiKeyType aKey, int32 aNumParams);
     54 
     55 /** This class will set port data format using
     56 ** the synchronous methods only.  The derived class
     57 ** must set the format type string and format val type string
     58 ** by calling Construct,
     59 ** and must implement the IsFormatSupported and FormatUpdated
     60 ** routines.
     61 */
     62 class OSCL_IMPORT_REF PvmiCapabilityAndConfigPortFormatImpl
     63         : public PvmiCapabilityAndConfig
     64 {
     65     public:
     66         PvmiCapabilityAndConfigPortFormatImpl()
     67                 : iFormat(PVMF_MIME_FORMAT_UNKNOWN)
     68         {}
     69 
     70         virtual ~PvmiCapabilityAndConfigPortFormatImpl() {};
     71 
     72         //Derived class must call this to set the format type strings
     73         //before the other methods can be used.
     74         void Construct(const char*aFormatType, const char* aFormatValType)
     75         {
     76             iFormatTypeString = aFormatType;
     77             iFormatValTypeString = aFormatValType;
     78         }
     79 
     80         //Derived class must implement this to verify the requested
     81         //format.
     82         virtual bool IsFormatSupported(PVMFFormatType aFormat) = 0;
     83 
     84         //Derived class must implement this to be notified when
     85         //the format has been updated through the setParametersSync
     86         //call.  If this function leaves, the leave will
     87         //propagate to the caller of setParametersSync
     88         virtual void FormatUpdated() = 0;
     89 
     90         // Implement pure virtuals from PvmiCapabilityAndConfig interface
     91         OSCL_IMPORT_REF virtual PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier,
     92                 PvmiKvp*& aParameters, int& num_parameter_elements, PvmiCapabilityContext aContext);
     93         OSCL_IMPORT_REF virtual PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
     94         OSCL_IMPORT_REF virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
     95                 int num_elements, PvmiKvp * & aRet_kvp);
     96         OSCL_IMPORT_REF virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int num_elements);
     97 
     98         // Unsupported PvmiCapabilityAndConfig methods
     99         void virtual setObserver(PvmiConfigAndCapabilityCmdObserver*) {};
    100         void virtual createContext(PvmiMIOSession , PvmiCapabilityContext&) {};
    101         void virtual setContextParameters(PvmiMIOSession , PvmiCapabilityContext& , PvmiKvp* , int) {};
    102         void virtual DeleteContext(PvmiMIOSession , PvmiCapabilityContext&) {};
    103         PVMFCommandId virtual setParametersAsync(PvmiMIOSession , PvmiKvp* , int , PvmiKvp*& , OsclAny* context = NULL)
    104         {
    105             OSCL_UNUSED_ARG(context);
    106             return -1;
    107         }
    108         uint32 virtual getCapabilityMetric(PvmiMIOSession)
    109         {
    110             return 0;
    111         }
    112 
    113 
    114         PVMFFormatType iFormat;
    115 
    116     protected:
    117         //Format type and FormatValType strings.
    118         OSCL_HeapString<OsclMemAllocator> iFormatTypeString;
    119         OSCL_HeapString<OsclMemAllocator> iFormatValTypeString;
    120 };
    121 
    122 #endif //PVMI_CONFIG_AND_CAPABILITY_UTILS_H_INCLUDED
    123