Home | History | Annotate | Download | only in src
      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 #ifndef PV_PLAYER_ENGINE_H_INCLUDED
     19 #define PV_PLAYER_ENGINE_H_INCLUDED
     20 
     21 #ifndef OSCL_BASE_H_INCLUDED
     22 #include "oscl_base.h"
     23 #endif
     24 
     25 #ifndef OSCL_MEM_H_INCLUDED
     26 #include "oscl_mem.h"
     27 #endif
     28 
     29 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
     30 #include "oscl_scheduler_ao.h"
     31 #endif
     32 
     33 #ifndef OSCL_VECTOR_H_INCLUDED
     34 #include "oscl_vector.h"
     35 #endif
     36 
     37 #ifndef OSCL_PRIQUEUE_H_INCLUDED
     38 #include "oscl_priqueue.h"
     39 #endif
     40 
     41 #ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
     42 #include "pvmf_media_clock.h"
     43 #endif
     44 
     45 #ifndef PV_ENGINE_TYPES_H_INCLUDED
     46 #include "pv_engine_types.h"
     47 #endif
     48 
     49 #ifndef PV_PLAYER_DATASOURCE_H_INCLUDED
     50 #include "pv_player_datasource.h"
     51 #endif
     52 
     53 #ifndef PV_PLAYER_DATASINK_H_INCLUDED
     54 #include "pv_player_datasink.h"
     55 #endif
     56 
     57 #ifndef PV_PLAYER_INTERFACE_H_INCLUDED
     58 #include "pv_player_interface.h"
     59 #endif
     60 
     61 #ifndef PV_ENGINE_OBSERVER_H_INCLUDED
     62 #include "pv_engine_observer.h"
     63 #endif
     64 
     65 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
     66 #include "pvmf_node_interface.h"
     67 #endif
     68 
     69 #ifndef PV_PLAYER_DATAPATH_H_INCLUDED
     70 #include "pv_player_datapath.h"
     71 #endif
     72 
     73 #ifndef PV_PLAYER_NODE_REGISTRY_H_INCLUDED
     74 #include "pv_player_node_registry.h"
     75 #endif
     76 
     77 #ifndef PVMF_META_DATA_TYPES_H_INCLUDED
     78 #include "pvmf_meta_data_types.h"
     79 #endif
     80 
     81 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
     82 #include "pvmf_meta_data_extension.h"
     83 #endif
     84 
     85 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
     86 #include "pvmf_data_source_init_extension.h"
     87 #endif
     88 
     89 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
     90 #include "pvmf_media_presentation_info.h"
     91 #endif
     92 
     93 #ifndef OSCL_TIMER_H_INCLUDED
     94 #include "oscl_timer.h"
     95 #endif
     96 
     97 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
     98 #include "oscl_mem_mempool.h"
     99 #endif
    100 
    101 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
    102 #include "pvmi_config_and_capability.h"
    103 #endif
    104 
    105 #ifndef PV_PLAYER_LICENSE_ACQUISITION_INTERFACE_H_INCLUDED
    106 #include "pv_player_license_acquisition_interface.h"
    107 #endif
    108 
    109 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
    110 #include "pvmf_data_source_playback_control.h"
    111 #endif
    112 
    113 #ifndef PV_PLAYER_TRACK_SELECTION_INTERFACE_H_INCLUDED
    114 #include "pv_player_track_selection_interface.h"
    115 #endif
    116 
    117 #ifndef PV_PLAYER_REGISTRY_INTERFACE_H_INCLUDED
    118 #include "pv_player_registry_interface.h"
    119 #endif
    120 
    121 #include "threadsafe_queue.h"
    122 
    123 /**
    124  * PVPlayerEngineState enum
    125  *
    126  *  Enumeration of internal pvPlayer engine state.
    127  *
    128  **/
    129 typedef enum
    130 {
    131     PVP_ENGINE_STATE_IDLE = 1,
    132     PVP_ENGINE_STATE_INITIALIZING,
    133     PVP_ENGINE_STATE_INITIALIZED,
    134     PVP_ENGINE_STATE_PREPARING,
    135     PVP_ENGINE_STATE_TRACK_SELECTION_1_DONE,
    136     PVP_ENGINE_STATE_TRACK_SELECTION_2_DONE,
    137     PVP_ENGINE_STATE_TRACK_SELECTION_3_DONE,
    138     PVP_ENGINE_STATE_PREPARED,
    139     PVP_ENGINE_STATE_STARTING,
    140     PVP_ENGINE_STATE_STARTED,
    141     PVP_ENGINE_STATE_AUTO_PAUSING,
    142     PVP_ENGINE_STATE_AUTO_PAUSED,
    143     PVP_ENGINE_STATE_AUTO_RESUMING,
    144     PVP_ENGINE_STATE_PAUSING,
    145     PVP_ENGINE_STATE_PAUSED,
    146     PVP_ENGINE_STATE_RESUMING,
    147     PVP_ENGINE_STATE_STOPPING,
    148     PVP_ENGINE_STATE_RESETTING,
    149     PVP_ENGINE_STATE_ERROR
    150 } PVPlayerEngineState;
    151 
    152 
    153 typedef union PVPlayerEngineCommandParamUnion
    154 {
    155     bool  bool_value;
    156     float float_value;
    157     double double_value;
    158     uint8 uint8_value;
    159     int32 int32_value;
    160     uint32 uint32_value;
    161     PVPPlaybackPosition playbackpos_value;
    162     oscl_wchar* pWChar_value;
    163     char* pChar_value;
    164     uint8* pUint8_value;
    165     int32* pInt32_value;
    166     uint32* pUint32_value;
    167     int64* pInt64_value;
    168     uint64*  pUint64_value;
    169     PVPPlaybackPosition* pPlaybackpos_value;
    170     OsclAny* pOsclAny_value;
    171 } _PVPlayerEngineCommandParamUnion;
    172 
    173 /**
    174  * PVPlayerEngineCommand Class
    175  *
    176  * PVPlayerEngineCommand class is a data class to hold issued commands inside the player engine
    177  **/
    178 class PVPlayerEngineCommand
    179 {
    180     public:
    181         /**
    182          * The constructor for PVPlayerEngineCommand which allows the data values to be set.
    183          *
    184          * @param aCmdType The command type value for this command. The value is an engine-specific 32-bit value.
    185          * @param aCmdId The command ID assigned by the engine for this command.
    186          * @param aContextData The pointer to the passed-in context data for this command.
    187          *
    188          * @returns None
    189          **/
    190         PVPlayerEngineCommand(int32 aCmdType, PVCommandId aCmdId, OsclAny* aContextData = NULL,
    191                               Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector = NULL, bool aAPICommand = true) :
    192                 iCmdType(aCmdType), iCmdId(aCmdId), iContextData(aContextData), iAPICommand(aAPICommand)
    193         {
    194             iParamVector.clear();
    195             if (aParamVector)
    196             {
    197                 iParamVector = *aParamVector;
    198             }
    199         }
    200 
    201         /**
    202          * The copy constructor for PVPlayerEngineCommand. Used mainly for Oscl_Vector.
    203          *
    204          * @param aCmd The reference to the source PVPlayerEngineCommand to copy the data values from.
    205          *
    206          * @returns None
    207          **/
    208         PVPlayerEngineCommand(const PVPlayerEngineCommand& aCmd)
    209         {
    210             iCmdType = aCmd.iCmdType;
    211             iCmdId = aCmd.iCmdId;
    212             iContextData = aCmd.iContextData;
    213             iAPICommand = aCmd.iAPICommand;
    214             iParamVector = aCmd.iParamVector;
    215             iMimeType = aCmd.iMimeType;
    216             iUuid = aCmd.iUuid;
    217         }
    218 
    219         /**
    220          * This function returns the stored command type value.
    221          *
    222          * @returns The signed 32-bit command type value for this command.
    223          **/
    224         int32 GetCmdType()const
    225         {
    226             return iCmdType;
    227         }
    228 
    229         /**
    230          * This function returns the stored command ID value.
    231          *
    232          * @returns The PVCommandId value for this command.
    233          **/
    234         PVCommandId GetCmdId()const
    235         {
    236             return iCmdId;
    237         }
    238 
    239         /**
    240          * This function returns the stored context data pointer.
    241          *
    242          * @returns The pointer to the context data for this command
    243          **/
    244         OsclAny* GetContext()const
    245         {
    246             return iContextData;
    247         }
    248 
    249         /**
    250          * This function tells whether the command is an API command or not
    251          *
    252          * @returns true if API command, false if not.
    253          **/
    254         bool IsAPICommand()const
    255         {
    256             return iAPICommand;
    257         }
    258 
    259         /**
    260          * This function returns the command parameter from the specified index.
    261          * If the specified index is not available, empty parameter will be returned
    262          *
    263          * @param aIndex The index of the parameter to return
    264          *
    265          * @returns The stored parameter for this command
    266          **/
    267         PVPlayerEngineCommandParamUnion GetParam(uint32 aIndex)const
    268         {
    269             if (aIndex >= iParamVector.size())
    270             {
    271                 PVPlayerEngineCommandParamUnion param;
    272                 oscl_memset(&param, 0, sizeof(PVPlayerEngineCommandParamUnion));
    273                 return param;
    274             }
    275             else
    276             {
    277                 return iParamVector[aIndex];
    278             }
    279         }
    280 
    281         /**
    282          * This function returns Mime type parameter for this command
    283          *
    284          * @returns The Mime type parameter for this command
    285          */
    286         const PvmfMimeString& GetMimeType()const
    287         {
    288             return iMimeType;
    289         }
    290 
    291         /**
    292          * This function returns Uuid parameter for this command
    293          *
    294          * @returns The Uuid parameter for this command
    295          */
    296         PVUuid GetUuid()const
    297         {
    298             return iUuid;
    299         }
    300 
    301         /**
    302          * This function stores Mime type parameter of this command
    303          */
    304         void SetMimeType(const PvmfMimeString& aMimeType)
    305         {
    306             iMimeType = aMimeType;
    307         }
    308 
    309         /**
    310          * This function stores the Uuid parameter of this command
    311          */
    312         void SetUuid(const PVUuid& aUuid)
    313         {
    314             iUuid = aUuid;
    315         }
    316 
    317         /**
    318          * Equality operator, for use by OsclPriorityQueue.
    319          */
    320         bool operator==(const PVPlayerEngineCommand& aCmd) const
    321         {
    322             return iCmdId == aCmd.iCmdId;
    323         }
    324 
    325         int32 iCmdType;
    326         PVCommandId iCmdId;
    327         OsclAny* iContextData;
    328         bool iAPICommand;
    329         Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator> iParamVector;
    330         OSCL_HeapString<OsclMemAllocator> iMimeType;
    331         PVUuid iUuid;
    332 };
    333 
    334 /**
    335  * PVPlayerEngineCommandType enum
    336  *
    337  *  Enumeration of types of commands that can be issued to the pvPlayer.
    338  *
    339  **/
    340 typedef enum
    341 {
    342     // Engine API commands
    343     PVP_ENGINE_COMMAND_GET_SDK_INFO = 1,
    344     PVP_ENGINE_COMMAND_GET_SDK_MODULE_INFO,
    345     PVP_ENGINE_COMMAND_SET_LOG_APPENDER,
    346     PVP_ENGINE_COMMAND_REMOVE_LOG_APPENDER,
    347     PVP_ENGINE_COMMAND_SET_LOG_LEVEL,
    348     PVP_ENGINE_COMMAND_GET_LOG_LEVEL,
    349     PVP_ENGINE_COMMAND_QUERY_UUID,
    350     PVP_ENGINE_COMMAND_QUERY_INTERFACE,
    351     PVP_ENGINE_COMMAND_CANCEL_COMMAND,
    352     PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS,
    353     PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE,
    354     PVP_ENGINE_COMMAND_ADD_DATA_SOURCE,
    355     PVP_ENGINE_COMMAND_INIT,
    356     PVP_ENGINE_COMMAND_GET_METADATA_KEY,
    357     PVP_ENGINE_COMMAND_GET_METADATA_VALUE,
    358     PVP_ENGINE_COMMAND_RELEASE_METADATA_VALUE,
    359     PVP_ENGINE_COMMAND_ADD_DATA_SINK,
    360     PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE,
    361     PVP_ENGINE_COMMAND_GET_PLAYBACK_RANGE,
    362     PVP_ENGINE_COMMAND_GET_CURRENT_POSITION,
    363     PVP_ENGINE_COMMAND_SET_PLAYBACK_RATE,
    364     PVP_ENGINE_COMMAND_GET_PLAYBACK_RATE,
    365     PVP_ENGINE_COMMAND_GET_PLAYBACK_MINMAX_RATE,
    366     PVP_ENGINE_COMMAND_PREPARE,
    367     PVP_ENGINE_COMMAND_START,
    368     PVP_ENGINE_COMMAND_PAUSE,
    369     PVP_ENGINE_COMMAND_RESUME,
    370     PVP_ENGINE_COMMAND_STOP,
    371     PVP_ENGINE_COMMAND_REMOVE_DATA_SINK,
    372     PVP_ENGINE_COMMAND_RESET,
    373     PVP_ENGINE_COMMAND_REMOVE_DATA_SOURCE,
    374     PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS,
    375     PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR,
    376     PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR,
    377     PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE,
    378     PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE_OOTSYNC,
    379     PVP_ENGINE_COMMAND_GET_CURRENT_POSITION_OOTSYNC,
    380     PVP_ENGINE_COMMAND_CAPCONFIG_SET_OBSERVER_OOTSYNC,
    381     PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS_OOTSYNC,
    382     PVP_ENGINE_COMMAND_GET_LICENSE_STATUS_OOTSYNC,
    383     PVP_ENGINE_COMMAND_CAPCONFIG_GET_PARAMETERS_OOTSYNC,
    384     PVP_ENGINE_COMMAND_CAPCONFIG_RELEASE_PARAMETERS_OOTSYNC,
    385     PVP_ENGINE_COMMAND_CAPCONFIG_VERIFY_PARAMETERS_OOTSYNC,
    386     // Internal engine commands
    387     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED,
    388     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP,
    389     PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW,
    390     PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY,
    391     // Internal Error Handling Commands
    392     PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE,
    393     PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT,
    394     PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE,
    395     PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE,
    396     PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME,
    397     PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE,
    398     PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE,
    399     PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP,
    400     PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS,
    401     PVP_ENGINE_COMMAND_ERROR_HANDLING_GENERAL
    402 } PVPlayerEngineCommandType;
    403 
    404 
    405 /**
    406  * PVPlayerEngineCommandCompareLess Class
    407  *
    408  * PVPlayerEngineCommandCompareLess class is a utility class to allow the OSCL priority queue perform command priority comparison.
    409  * The class is meant to be used inside the player engine and not exposed to the interface layer or above.
    410  **/
    411 class PVPlayerEngineCommandCompareLess
    412 {
    413     public:
    414         /**
    415         * The algorithm used in OsclPriorityQueue needs a compare function
    416         * that returns true when A's priority is less than B's
    417         * @return true if A's priority is less than B's, else false
    418         */
    419         int compare(PVPlayerEngineCommand& a, PVPlayerEngineCommand& b) const
    420         {
    421             int a_pri = PVPlayerEngineCommandCompareLess::GetPriority(a);
    422             int b_pri = PVPlayerEngineCommandCompareLess::GetPriority(b);
    423             if (a_pri < b_pri)
    424             {
    425                 // Higher priority
    426                 return false;
    427             }
    428             else if (a_pri == b_pri)
    429             {
    430                 // Same priority so look at the command ID to maintain FIFO
    431                 return (a.GetCmdId() > b.GetCmdId());
    432             }
    433             else
    434             {
    435                 // Lower priority
    436                 return true;
    437             }
    438         }
    439 
    440         /**
    441         * Returns the priority of each command
    442         * @return A 0-based priority number. A lower number indicates higher priority.
    443         */
    444         static int GetPriority(PVPlayerEngineCommand& aCmd)
    445         {
    446             switch (aCmd.GetCmdType())
    447             {
    448                 case PVP_ENGINE_COMMAND_GET_SDK_INFO:
    449                     return 5;
    450                 case PVP_ENGINE_COMMAND_GET_SDK_MODULE_INFO:
    451                     return 5;
    452                 case PVP_ENGINE_COMMAND_SET_LOG_APPENDER:
    453                     return 5;
    454                 case PVP_ENGINE_COMMAND_REMOVE_LOG_APPENDER:
    455                     return 5;
    456                 case PVP_ENGINE_COMMAND_SET_LOG_LEVEL:
    457                     return 5;
    458                 case PVP_ENGINE_COMMAND_GET_LOG_LEVEL:
    459                     return 5;
    460                 case PVP_ENGINE_COMMAND_QUERY_UUID:
    461                     return 5;
    462                 case PVP_ENGINE_COMMAND_QUERY_INTERFACE:
    463                     return 5;
    464                 case PVP_ENGINE_COMMAND_CANCEL_COMMAND:
    465                 case PVP_ENGINE_COMMAND_CANCEL_ALL_COMMANDS:
    466                     return 3;
    467                 case PVP_ENGINE_COMMAND_GET_PVPLAYER_STATE:
    468                     return 5;
    469                 case PVP_ENGINE_COMMAND_ADD_DATA_SOURCE:
    470                     return 5;
    471                 case PVP_ENGINE_COMMAND_INIT:
    472                     return 5;
    473                 case PVP_ENGINE_COMMAND_GET_METADATA_KEY:
    474                     return 5;
    475                 case PVP_ENGINE_COMMAND_GET_METADATA_VALUE:
    476                     return 5;
    477                 case PVP_ENGINE_COMMAND_ADD_DATA_SINK:
    478                     return 5;
    479                 case PVP_ENGINE_COMMAND_SET_PLAYBACK_RANGE:
    480                     return 5;
    481                 case PVP_ENGINE_COMMAND_GET_PLAYBACK_RANGE:
    482                     return 5;
    483                 case PVP_ENGINE_COMMAND_GET_CURRENT_POSITION:
    484                     return 5;
    485                 case PVP_ENGINE_COMMAND_SET_PLAYBACK_RATE:
    486                     return 5;
    487                 case PVP_ENGINE_COMMAND_GET_PLAYBACK_RATE:
    488                     return 5;
    489                 case PVP_ENGINE_COMMAND_GET_PLAYBACK_MINMAX_RATE:
    490                     return 5;
    491                 case PVP_ENGINE_COMMAND_PREPARE:
    492                     return 5;
    493                 case PVP_ENGINE_COMMAND_START:
    494                     return 5;
    495                 case PVP_ENGINE_COMMAND_PAUSE:
    496                     return 5;
    497                 case PVP_ENGINE_COMMAND_RESUME:
    498                     return 5;
    499                 case PVP_ENGINE_COMMAND_STOP:
    500                     return 5;
    501                 case PVP_ENGINE_COMMAND_REMOVE_DATA_SINK:
    502                     return 5;
    503                 case PVP_ENGINE_COMMAND_RESET:
    504                     return 5;
    505                 case PVP_ENGINE_COMMAND_REMOVE_DATA_SOURCE:
    506                     return 5;
    507                 case PVP_ENGINE_COMMAND_CAPCONFIG_SET_PARAMETERS:
    508                     return 5;
    509                 case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_WCHAR:
    510                     return 5;
    511                 case PVP_ENGINE_COMMAND_ACQUIRE_LICENSE_CHAR:
    512                     return 5;
    513                 case PVP_ENGINE_COMMAND_CANCEL_ACQUIRE_LICENSE:
    514                     return 3;
    515 
    516                 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDTIME_REACHED:
    517                     return 4;
    518                 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_ENDOFCLIP:
    519                     return 4;
    520                 case PVP_ENGINE_COMMAND_PAUSE_DUE_TO_BUFFER_UNDERFLOW:
    521                     return 5;
    522                 case PVP_ENGINE_COMMAND_RESUME_DUE_TO_BUFFER_DATAREADY:
    523                     return 5;
    524 
    525                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_ADD_DATA_SOURCE:
    526                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_INIT:
    527                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_PREPARE:
    528                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_PAUSE:
    529                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_RESUME:
    530                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RANGE:
    531                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_SET_PLAYBACK_RATE:
    532                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_STOP:
    533                 case PVP_ENGINE_COMMAND_ERROR_HANDLING_CANCEL_ALL_COMMANDS:
    534                     return 1;
    535                 default:
    536                     return 0;
    537             }
    538         }
    539 };
    540 
    541 
    542 // Structure to hold the key string info for
    543 // player engine's capability-and-config
    544 struct PVPlayerKeyStringData
    545 {
    546     char iString[64];
    547     PvmiKvpType iType;
    548     PvmiKvpValueType iValueType;
    549 };
    550 
    551 // The number of characters to allocate for the key string
    552 #define PVPLAYERCONFIG_KEYSTRING_SIZE 128
    553 
    554 
    555 
    556 // Key string info at the base level ("x-pvmf/player/")
    557 #define PVPLAYERCONFIG_BASE_NUMKEYS 13
    558 const PVPlayerKeyStringData PVPlayerConfigBaseKeys[PVPLAYERCONFIG_BASE_NUMKEYS] =
    559 {
    560     {"pbpos_units", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
    561     {"pbpos_interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
    562     {"endtimecheck_interval", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
    563     {"seektosyncpoint", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
    564     {"skiptorequestedpos", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL},
    565     {"syncpointseekwindow", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
    566     {"syncmargin_video", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32},
    567     {"syncmargin_audio", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32},
    568     {"syncmargin_text", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_RANGE_INT32},
    569     {"nodecmd_timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
    570     {"nodedataqueuing_timeout", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_UINT32},
    571     {"productinfo", PVMI_KVPTYPE_AGGREGATE, PVMI_KVPVALTYPE_KSV},
    572     {"pbpos_enable", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_BOOL}
    573 };
    574 
    575 enum PlayerConfigBaseKeys_IndexMap
    576 {
    577     PBPOS_UNITS = 0,
    578     PBPOS_INTERVAL,
    579     ENDTIMECHECK_INTERVAL,
    580     SEEKTOSYNCPOINT,
    581     SKIPTOREQUESTEDPOSITION,
    582     SYNCPOINTSEEKWINDOW,
    583     SYNCMARGIN_VIDEO,
    584     SYNCMARGIN_AUDIO,
    585     SYNCMARGIN_TEXT,
    586     NODECMD_TIMEOUT,
    587     NODEDATAQUEIUING_TIMEOUT,
    588     PRODUCTINFO,
    589     PBPOS_ENABLE
    590 };
    591 
    592 // Key string info at the productinfo level ("x-pvmf/player/productinfo/")
    593 #define PVPLAYERCONFIG_PRODINFO_NUMKEYS 5
    594 const PVPlayerKeyStringData PVPlayerConfigProdInfoKeys[PVPLAYERCONFIG_PRODINFO_NUMKEYS] =
    595 {
    596     {"productname", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
    597     {"partnumber", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
    598     {"hardwareplatform", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
    599     {"softwareplatform", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR},
    600     {"device", PVMI_KVPTYPE_VALUE, PVMI_KVPVALTYPE_CHARPTR}
    601 };
    602 
    603 enum ProductInfoKeys_IndexMap
    604 {
    605     PRODUCTNAME = 0,
    606     PARTNUMBER,
    607     HARDWAREPLATFORM,
    608     SOFTWAREPLATFORM,
    609     DEVICE
    610 };
    611 
    612 // Player engine's timebase with rate change capability
    613 class PVPlayerTimebase : public PVMFTimebase_Tickcount
    614 {
    615     public:
    616         PVPlayerTimebase()
    617         {
    618             iRate = 100000;
    619             iRateChangeTCTime = 0;
    620             iRateChangeTC = 0;
    621         }
    622 
    623         ~PVPlayerTimebase()
    624         {
    625         }
    626         void GetCurrentTick32(uint32& aTimebaseTickCount, bool& aOverflow)
    627         {
    628             // Retrieve the tickcount time
    629             uint32 tickcount = 0;
    630 
    631             PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, aOverflow);
    632 
    633             if (aOverflow)
    634             {
    635                 aTimebaseTickCount = 0;
    636                 return;
    637             }
    638 
    639             // Calculate the tickcount since last rate change
    640             uint32 ticksSinceChange = 0;
    641             PVTimeComparisonUtils::IsEarlier(iRateChangeTC, tickcount, ticksSinceChange);
    642 
    643             if (iRate != 100000)
    644             {
    645                 // Adjust according to rate
    646                 // Rate change resolution is 0.1
    647                 uint32 convnum = (iRate / 10000);
    648                 uint32 convden = 10;
    649                 aTimebaseTickCount = ((ticksSinceChange * convnum) / convden);
    650             }
    651             else
    652             {
    653                 aTimebaseTickCount = ticksSinceChange;
    654             }
    655 
    656             // Add the timebase since last rate change
    657             aTimebaseTickCount = aTimebaseTickCount + iRateChangeTCTime;
    658         }
    659 
    660         void SetRate(int32 aRate)
    661         {
    662             bool overflow = 0;
    663             // Save the tickcount time when the rate changed
    664             uint32 temp = 0;
    665             GetCurrentTick32(temp, overflow);
    666             iRateChangeTCTime = temp;
    667 
    668             uint32 tickcount = 0;
    669             PVMFTimebase_Tickcount::GetCurrentTick32(tickcount, overflow);
    670             iRateChangeTC = tickcount;
    671             // Change the rate
    672             iRate = aRate;
    673         }
    674 
    675         int32 GetRate()
    676         {
    677             return iRate;
    678         }
    679 
    680     private:
    681         int32 iRate; // In millipercent of "real-time"
    682         uint32 iRateChangeTCTime;  // The tickcount's time when rate last changed
    683         uint32 iRateChangeTC;
    684 };
    685 
    686 
    687 class PVMFNodeInterface;
    688 class PVMFDataSourceInitializationExtensionInterface;
    689 class PVMFTrackSelectionExtensionInterface;
    690 class PvmfDataSourcePlaybackControlInterface;
    691 class PvmfDataSourceDirectionControlInterface;
    692 class PVMFTrackLevelInfoExtensionInterface;
    693 class PvmfNodesSyncControlInterface;
    694 class PvmfFileOutputNodeConfigInterface;
    695 class PVMFErrorInfoMessageInterface;
    696 class PVLogger;
    697 class PVMFCPMPluginLicenseInterface;
    698 class PVMFBasicErrorInfoMessage;
    699 class PVPlayerWatchdogTimer;
    700 
    701 typedef enum
    702 {
    703     PVP_NODETYPE_SOURCE,
    704     PVP_NODETYPE_SINK,
    705     PVP_NODETYPE_DECODER,
    706     PVP_NODETYPE_UNKNOWN
    707 } PVPlayerNodeType;
    708 
    709 class PVPlayerEngineDatapath
    710 {
    711     public:
    712         PVPlayerEngineDatapath()
    713         {
    714             iTrackInfo = NULL;
    715             iSrcFormat = PVMF_MIME_FORMAT_UNKNOWN;
    716             iDataSink = NULL;
    717             iDatapath = NULL;
    718             iDecNode = NULL;
    719             iDecNodeSessionId = 0;
    720             iDecNodeCapConfigIF = NULL;
    721             iDecNodeMetadataExtIF = NULL;
    722             iDecNodePVInterfaceMetadataExt = NULL;
    723             iSinkNode = NULL;
    724             iSinkNodeSessionId = 0;
    725             iSinkNodeFOConfigIF = NULL;
    726             iSinkNodeSyncCtrlIF = NULL;
    727             iSinkNodeCapConfigIF = NULL;
    728             iSinkNodeMetadataExtIF = NULL;
    729             iSinkFormat = PVMF_MIME_FORMAT_UNKNOWN;
    730             iSinkNodePVInterfaceSyncCtrl = NULL;
    731             iSinkNodePVInterfaceCapConfig = NULL;
    732             iSinkNodePVInterfaceMetadataExt = NULL;
    733             iNumPendingCmd = 0;
    734             iEndOfDataReceived = false;
    735         };
    736 
    737         PVPlayerEngineDatapath(const PVPlayerEngineDatapath& aSrc)
    738         {
    739             iTrackInfo = aSrc.iTrackInfo;
    740             iSrcFormat = aSrc.iSrcFormat;
    741             iDataSink = aSrc.iDataSink;
    742             iDatapath = aSrc.iDatapath;
    743             iDecNode = aSrc.iDecNode;
    744             iDecNodeSessionId = aSrc.iDecNodeSessionId;
    745             iDecNodeCapConfigIF = aSrc.iDecNodeCapConfigIF;
    746             iDecNodeMetadataExtIF = aSrc.iDecNodeMetadataExtIF;
    747             iDecNodePVInterfaceMetadataExt = aSrc.iDecNodePVInterfaceMetadataExt;
    748             iSinkNode = aSrc.iSinkNode;
    749             iSinkNodeSessionId = aSrc.iSinkNodeSessionId;
    750             iSinkNodeFOConfigIF = aSrc.iSinkNodeFOConfigIF;
    751             iSinkNodeSyncCtrlIF = aSrc.iSinkNodeSyncCtrlIF;
    752             iSinkNodeCapConfigIF = aSrc.iSinkNodeCapConfigIF;
    753             iSinkNodeMetadataExtIF = aSrc.iSinkNodeMetadataExtIF;
    754             iSinkFormat = aSrc.iSinkFormat;
    755             iSinkNodePVInterfaceSyncCtrl = aSrc.iSinkNodePVInterfaceSyncCtrl;
    756             iSinkNodePVInterfaceCapConfig = aSrc.iSinkNodePVInterfaceCapConfig;
    757             iSinkNodePVInterfaceMetadataExt = aSrc.iSinkNodePVInterfaceMetadataExt;
    758             iNumPendingCmd = aSrc.iNumPendingCmd;
    759             iEndOfDataReceived = aSrc.iEndOfDataReceived;
    760         };
    761 
    762         ~PVPlayerEngineDatapath()
    763         {
    764         };
    765 
    766         PVMFTrackInfo* iTrackInfo;
    767         PVMFFormatType iSrcFormat;
    768 
    769         PVPlayerDataSink* iDataSink;
    770         PVPlayerDatapath* iDatapath;
    771 
    772         PVMFNodeInterface* iDecNode;
    773         PVMFSessionId iDecNodeSessionId;
    774         PvmiCapabilityAndConfig* iDecNodeCapConfigIF;
    775         PVMFMetadataExtensionInterface* iDecNodeMetadataExtIF;
    776         PVInterface* iDecNodePVInterfaceMetadataExt;
    777 
    778         PVMFNodeInterface* iSinkNode;
    779         PVMFSessionId iSinkNodeSessionId;
    780         PvmfFileOutputNodeConfigInterface* iSinkNodeFOConfigIF;
    781         PvmfNodesSyncControlInterface* iSinkNodeSyncCtrlIF;
    782         PvmiCapabilityAndConfig* iSinkNodeCapConfigIF;
    783         PVMFMetadataExtensionInterface* iSinkNodeMetadataExtIF;
    784         PVMFFormatType iSinkFormat;
    785         PVInterface* iSinkNodePVInterfaceSyncCtrl;
    786         PVInterface* iSinkNodePVInterfaceCapConfig;
    787         PVInterface* iSinkNodePVInterfaceMetadataExt;
    788 
    789         uint32 iNumPendingCmd;
    790         bool iEndOfDataReceived;
    791 };
    792 
    793 struct PVPlayerEngineContext
    794 {
    795     PVPlayerEngineDatapath* iEngineDatapath;
    796     PVMFNodeInterface* iNode;
    797     PVPlayerDatapath* iDatapath;
    798     PVCommandId iCmdId;
    799     OsclAny* iCmdContext;
    800     int32 iCmdType;
    801 };
    802 
    803 class PVPlayerEngineTrackSelection
    804 {
    805     public:
    806         PVPlayerEngineTrackSelection()
    807         {
    808             iTsSinkNode = NULL;
    809             iTsSinkNodeSessionId = 0;
    810             iTsSinkNodeCapConfigIF = NULL;
    811             iTsDecNode = NULL;
    812             iTsDecNodeSessionId = 0;
    813             iTsDecNodeCapConfigIF = NULL;
    814             iTsDecNodePVInterfaceCapConfig = NULL;
    815             iTsTrackID = -1;
    816             iTsTrackValidForPlayableList = false;
    817         };
    818 
    819         PVPlayerEngineTrackSelection(const PVPlayerEngineTrackSelection& aTrackSelection)
    820         {
    821             iTsSinkNode = aTrackSelection.iTsSinkNode;
    822             iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId;
    823             iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF;
    824             iTsDecNode = aTrackSelection.iTsDecNode;
    825             iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId;
    826             iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF;
    827             iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig;
    828             iTsTrackID = aTrackSelection.iTsTrackID;
    829             iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList;
    830         };
    831 
    832         PVPlayerEngineTrackSelection& operator=(const PVPlayerEngineTrackSelection& aTrackSelection)
    833         {
    834             iTsSinkNode = aTrackSelection.iTsSinkNode;
    835             iTsSinkNodeSessionId = aTrackSelection.iTsSinkNodeSessionId;
    836             iTsSinkNodeCapConfigIF = aTrackSelection.iTsSinkNodeCapConfigIF;
    837             iTsDecNode = aTrackSelection.iTsDecNode;
    838             iTsDecNodeSessionId = aTrackSelection.iTsDecNodeSessionId;
    839             iTsDecNodeCapConfigIF = aTrackSelection.iTsDecNodeCapConfigIF;
    840             iTsDecNodePVInterfaceCapConfig = aTrackSelection.iTsDecNodePVInterfaceCapConfig;
    841             iTsTrackID = aTrackSelection.iTsTrackID;
    842             iTsTrackValidForPlayableList = aTrackSelection.iTsTrackValidForPlayableList;
    843             return *this;
    844         };
    845 
    846         ~PVPlayerEngineTrackSelection()
    847         {
    848         };
    849 
    850         PVMFNodeInterface* iTsSinkNode;
    851         PVMFSessionId iTsSinkNodeSessionId;
    852         PvmiCapabilityAndConfig* iTsSinkNodeCapConfigIF;
    853 
    854         PVMFNodeInterface* iTsDecNode;
    855         PVMFSessionId iTsDecNodeSessionId;
    856         PvmiCapabilityAndConfig* iTsDecNodeCapConfigIF;
    857         PVInterface* iTsDecNodePVInterfaceCapConfig;
    858 
    859         int32 iTsTrackID;
    860         bool iTsTrackValidForPlayableList;
    861 };
    862 
    863 
    864 /**
    865  * Observer class for the inactivity timer AO
    866  */
    867 class PVPlayerWatchdogTimerObserver
    868 {
    869     public:
    870         virtual ~PVPlayerWatchdogTimerObserver() {}
    871         /**
    872          * A timer event, indicating that the inactivity timer has expired.
    873          */
    874         virtual void PVPlayerWatchdogTimerEvent() = 0;
    875 };
    876 
    877 
    878 class PVPlayerEngine : public OsclTimerObject,
    879         public PVPlayerInterface,
    880         public PvmiCapabilityAndConfig,
    881         public PVMFNodeCmdStatusObserver,
    882         public PVMFNodeInfoEventObserver,
    883         public PVMFNodeErrorEventObserver,
    884         public PVPlayerDatapathObserver,
    885         public OsclTimerObserver,
    886         public PVPlayerLicenseAcquisitionInterface,
    887         public PVPlayerRecognizerRegistryObserver,
    888         public PVPlayerWatchdogTimerObserver,
    889         public PVPlayerTrackSelectionInterface,
    890         public PVMFMediaClockNotificationsObs,
    891         public ThreadSafeQueueObserver
    892 {
    893     public:
    894         static PVPlayerEngine* New(PVCommandStatusObserver *aCmdObserver,
    895                                    PVErrorEventObserver *aErrorObserver,
    896                                    PVInformationalEventObserver *aInfoObserver,
    897                                    bool aHwAccelerated);
    898         ~PVPlayerEngine();
    899 
    900         // From PVPlayerInterface
    901         PVCommandId GetSDKInfo(PVSDKInfo &aSDKInfo, const OsclAny* aContextData = NULL);
    902         PVCommandId GetSDKModuleInfo(PVSDKModuleInfo &aSDKModuleInfo, const OsclAny* aContextData = NULL);
    903         PVCommandId SetLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, const OsclAny* aContextData = NULL);
    904         PVCommandId RemoveLogAppender(const char* aTag, OsclSharedPtr<PVLoggerAppender>& aAppender, const OsclAny* aContextData = NULL);
    905         PVCommandId SetLogLevel(const char* aTag, int32 aLevel, bool aSetSubtree = false, const OsclAny* aContextData = NULL);
    906         PVCommandId GetLogLevel(const char* aTag, PVLogLevelInfo& aLogInfo, const OsclAny* aContextData = NULL);
    907         PVCommandId QueryUUID(const PvmfMimeString& aMimeType, Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids, bool aExactUuidsOnly = false, const OsclAny* aContextData = NULL);
    908         PVCommandId QueryInterface(const PVUuid& aUuid, PVInterface*& aInterfacePtr, const OsclAny* aContextData = NULL);
    909         PVCommandId CancelCommand(PVCommandId aCancelCmdId, const OsclAny* aContextData = NULL);
    910         PVCommandId CancelAllCommands(const OsclAny* aContextData = NULL);
    911         PVCommandId GetPVPlayerState(PVPlayerState& aState, const OsclAny* aContextData = NULL);
    912         PVMFStatus GetPVPlayerStateSync(PVPlayerState& aState);
    913         PVCommandId AddDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL);
    914         PVCommandId Init(const OsclAny* aContextData = NULL);
    915         PVCommandId GetMetadataKeys(PVPMetadataList& aKeyList, int32 aStartingIndex = 0, int32 aMaxEntries = -1, char* aQueryKey = NULL, const OsclAny* aContextData = NULL);
    916         PVCommandId GetMetadataValues(PVPMetadataList& aKeyList, int32 aStartingValueIndex, int32 aMaxValueEntries, int32& aNumAvailableValueEntries, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL, bool aMetadataValuesCopiedInCallBack = true);
    917         PVCommandId ReleaseMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, const OsclAny* aContextData = NULL);
    918         PVCommandId AddDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL);
    919         PVCommandId SetPlaybackRange(PVPPlaybackPosition aBeginPos, PVPPlaybackPosition aEndPos, bool aQueueRange, const OsclAny* aContextData = NULL);
    920         PVCommandId GetPlaybackRange(PVPPlaybackPosition &aBeginPos, PVPPlaybackPosition &aEndPos, bool aQueued, const OsclAny* aContextData = NULL);
    921         PVCommandId GetCurrentPosition(PVPPlaybackPosition &aPos, const OsclAny* aContextData = NULL);
    922         PVMFStatus GetCurrentPositionSync(PVPPlaybackPosition &aPos);
    923         PVCommandId SetPlaybackRate(int32 aRate, PVMFTimebase* aTimebase = NULL, const OsclAny* aContextData = NULL);
    924         PVCommandId GetPlaybackRate(int32& aRate, PVMFTimebase*& aTimebase, const OsclAny* aContextData = NULL);
    925         PVCommandId GetPlaybackMinMaxRate(int32& aMinRate, int32& aMaxRate, const OsclAny* aContextData = NULL);
    926         PVCommandId Prepare(const OsclAny* aContextData = NULL);
    927         PVCommandId Start(const OsclAny* aContextData = NULL);
    928         PVCommandId Pause(const OsclAny* aContextData = NULL);
    929         PVCommandId Resume(const OsclAny* aContextData = NULL);
    930         PVCommandId Stop(const OsclAny* aContextData = NULL);
    931         PVCommandId RemoveDataSink(PVPlayerDataSink& aDataSink, const OsclAny* aContextData = NULL);
    932         PVCommandId Reset(const OsclAny* aContextData = NULL);
    933         PVCommandId RemoveDataSource(PVPlayerDataSource& aDataSource, const OsclAny* aContextData = NULL);
    934 
    935         // From PvmiCapabilityAndConfig
    936         void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver);
    937         PVMFStatus getParametersSync(PvmiMIOSession aSession, PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
    938         PVMFStatus releaseParameters(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
    939         void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
    940         void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext, PvmiKvp* aParameters, int aNumParamElements);
    941         void DeleteContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
    942         void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp* &aRetKVP);
    943         PVMFCommandId setParametersAsync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements, PvmiKvp*& aRetKVP, OsclAny* aContext = NULL);
    944         uint32 getCapabilityMetric(PvmiMIOSession aSession);
    945         PVMFStatus verifyParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters, int aNumElements);
    946 
    947         // From PVPlayerLicenseAcquisitionInterface
    948         PVCommandId AcquireLicense(OsclAny* aLicenseData, uint32 aDataSize, oscl_wchar* aContentName, int32 aTimeoutMsec, const OsclAny* aContextData = NULL);
    949         PVCommandId AcquireLicense(OsclAny* aLicenseData, uint32 aDataSize, char* aContentName, int32 aTimeoutMsec, const OsclAny* aContextData = NULL);
    950         PVCommandId CancelAcquireLicense(PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
    951         PVMFStatus GetLicenseStatus(PVMFCPMLicenseStatus& aStatus);
    952 
    953         //From PVPlayerTrackSelectionInterface
    954         PVMFStatus GetCompleteList(PVMFMediaPresentationInfo& aList);
    955         PVMFStatus ReleaseCompleteList(PVMFMediaPresentationInfo& aList);
    956         PVMFStatus GetPlayableList(PVMFMediaPresentationInfo& aList);
    957         PVMFStatus ReleasePlayableList(PVMFMediaPresentationInfo& aList);
    958         PVMFStatus GetSelectedList(PVMFMediaPresentationInfo& aList);
    959         PVMFStatus ReleaseSelectedList(PVMFMediaPresentationInfo& aList);
    960         PVMFStatus RegisterHelperObject(PVMFTrackSelectionHelper* aObject);
    961 
    962         // From PVInterface
    963         void addRef();
    964         void removeRef();
    965         bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
    966 
    967         // From PVPlayerWatchdogTimerObserver
    968         void PVPlayerWatchdogTimerEvent();
    969 
    970     private:
    971         PVPlayerEngine(bool aHwAccelerated);
    972         void Construct(PVCommandStatusObserver *aCmdObserver,
    973                        PVErrorEventObserver *aErrorObserver,
    974                        PVInformationalEventObserver *aInfoObserver);
    975 
    976         // From OsclTimerObject
    977         void Run();
    978 
    979         // Utility function to determine the type of node in the player datapath and of the datapath which it belongs to
    980         bool FindNodeTypeByNode(PVMFNodeInterface* aUnknownNode, PVPlayerNodeType& aNodeType, int32& aDatapathListIndex);
    981 
    982         // Utility function to find the track for given datapath based on mime string
    983         bool FindTrackForDatapathUsingMimeString(bool& aVideoTrack, bool& aAudioTrack, bool& aTextTrack, PVPlayerEngineDatapath* aDatapath);
    984 
    985         // Utility function to find the datapath list index based on mime string
    986         bool FindDatapathForTrackUsingMimeString(bool aVideoTrack, bool aAudioTrack, bool aTextTrack, int32& aDatapathListIndex);
    987 
    988         // From PVMFNodeCmdStatusObserver
    989         void NodeCommandCompleted(const PVMFCmdResp& aResponse);
    990 
    991         // From PVMFNodeInfoEventObserver
    992         void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent);
    993 
    994         // From PVMFNodeErrorEventObserver
    995         void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
    996 
    997         // From PVPlayerDatapathObserver
    998         void HandlePlayerDatapathEvent(int32 aDatapathEvent, PVMFStatus aEventStatus, OsclAny* aContext = NULL, PVMFCmdResp* aCmdResp = NULL);
    999 
   1000         // From OsclTimerObserver
   1001         void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
   1002 
   1003         //From PVMFMediaClockNotificationsObs
   1004         void ProcessCallBack(uint32 aCallBackID, PVTimeComparisonUtils::MediaTimeStatus aTimerAccuracy, uint32 delta,
   1005                              const OsclAny* acontextData, PVMFStatus aStatus);
   1006         void NotificationsInterfaceDestroyed();
   1007 
   1008         //For sending PVMFInfoPositionStatus
   1009         void SendPositionStatusUpdate(void);
   1010 
   1011         // For checking of any pending error handling cmd in the queue
   1012         bool CheckForPendingErrorHandlingCmd();
   1013 
   1014         // From PVPlayerRecognizerRegistryObserver
   1015         void RecognizeCompleted(PVMFFormatType aSourceFormatType, OsclAny* aContext);
   1016 
   1017         // Command and event queueing related functions
   1018         PVCommandId AddCommandToQueue(int32 aCmdType, OsclAny* aContextData = NULL,
   1019                                       Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector = NULL,
   1020                                       const PVUuid* aUuid = NULL, bool aAPICommand = true, PVCommandId* aId = NULL);
   1021 
   1022         // Thread-safety mechanisms
   1023         ThreadSafeQueue iThreadSafeQueue;
   1024         void ThreadSafeQueueDataAvailable(ThreadSafeQueue*);
   1025         OsclSemaphore iOOTSyncCommandSem;
   1026         OsclMutex iCommandIdMut;
   1027         PVMFStatus DoOOTSyncCommand(int32 aCmdType,
   1028                                     Oscl_Vector<PVPlayerEngineCommandParamUnion, OsclMemAllocator>* aParamVector,
   1029                                     const PVUuid* aUuid = NULL);
   1030         void OOTSyncCommandComplete(PVPlayerEngineCommand& aCmd, PVMFStatus aStatus);
   1031 
   1032         // start the playback clock once skip is completed by one of the tracks
   1033         void StartPlaybackClock();
   1034 
   1035         // Functions for engine state handling
   1036         void SetEngineState(PVPlayerEngineState aState);
   1037         PVPlayerState GetPVPlayerState(void);
   1038 
   1039         // Keeps track of next available command ID
   1040         PVCommandId iCommandId;
   1041 
   1042         // Current engine state
   1043         PVPlayerEngineState iState;
   1044 
   1045         // Reference to observers
   1046         PVCommandStatusObserver *iCmdStatusObserver;
   1047         PVErrorEventObserver *iErrorEventObserver;
   1048         PVInformationalEventObserver *iInfoEventObserver;
   1049 
   1050         PvmiConfigAndCapabilityCmdObserver *iCfgCapCmdObserver;
   1051 
   1052         // Retrieve current playback clock position
   1053         void GetPlaybackClockPosition(PVPPlaybackPosition& aClockPos);
   1054 
   1055         // Utility functions to convert to/from milliseconds to other playback position units
   1056         PVMFStatus ConvertToMillisec(PVPPlaybackPosition& aPBPos, uint32& aTimeMS);
   1057         PVMFStatus ConvertFromMillisec(uint32 aTimeMS, PVPPlaybackPosition& aPBPos);
   1058 
   1059         // OsclTimer for polling checks
   1060         OsclTimer<OsclMemAllocator>* iPollingCheckTimer;
   1061 
   1062         // Command and event callback functions
   1063         void EngineCommandCompleted(PVCommandId aId, OsclAny* aContext, PVMFStatus aStatus, PVInterface* aExtInterface = NULL,
   1064                                     OsclAny* aEventData = NULL, int32 aEventDataSize = 0);
   1065         void SendInformationalEvent(PVMFEventType aEventType, PVInterface* aExtInterface = NULL,
   1066                                     OsclAny* aEventData = NULL, uint8* aLocalBuffer = NULL, uint32 aLocalBufferSize = 0);
   1067         void SendErrorEvent(PVMFEventType aEventType, PVInterface* aExtInterface = NULL,
   1068                             OsclAny* aEventData = NULL, uint8* aLocalBuffer = NULL, uint32 aLocalBufferSize = 0);
   1069 
   1070         // Queue for engine commands
   1071         Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCurrentCmd; // Vector of size 1 to hold the command being currently processed
   1072         Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCmdToCancel; // Vector of size 1 to hold the command being currently cancelled
   1073         Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> iCmdToDlaCancel; // Vector of size 1 to hold the command being currently cancelled
   1074         OsclPriorityQueue<PVPlayerEngineCommand, OsclMemAllocator, Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator>, PVPlayerEngineCommandCompareLess> iPendingCmds; // Vector to hold the command that has been requested
   1075 
   1076         // Variables for completing engine commands after error handling
   1077         PVMFStatus iCommandCompleteStatusInErrorHandling;
   1078         PVMFBasicErrorInfoMessage* iCommandCompleteErrMsgInErrorHandling;
   1079 
   1080         // Command handling functions
   1081         void DoCancelCommand(PVPlayerEngineCommand& aCmd);
   1082         void DoCancelAllCommands(PVPlayerEngineCommand& aCmd);
   1083         void DoCancelCommandBeingProcessed(void);
   1084         void DoCancelAcquireLicense(PVPlayerEngineCommand& aCmd);
   1085         PVMFStatus DoCancelPendingNodeDatapathCommand(void);
   1086         PVMFStatus DoErrorHandling(void);
   1087         PVMFStatus DoGetSDKInfo(PVPlayerEngineCommand& aCmd);
   1088         PVMFStatus DoSetLogAppender(PVPlayerEngineCommand& aCmd);
   1089         PVMFStatus DoRemoveLogAppender(PVPlayerEngineCommand& aCmd);
   1090         PVMFStatus DoSetLogLevel(PVPlayerEngineCommand& aCmd);
   1091         PVMFStatus DoGetLogLevel(PVPlayerEngineCommand& aCmd);
   1092         PVMFStatus DoQueryUUID(PVPlayerEngineCommand& aCmd);
   1093         PVMFStatus DoQueryInterface(PVPlayerEngineCommand& aCmd);
   1094         PVMFStatus DoGetPVPlayerState(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false);
   1095         PVMFStatus DoAddDataSource(PVPlayerEngineCommand& aCmd);
   1096         PVMFStatus DoQuerySourceFormatType(PVCommandId aCmdId, OsclAny* aCmdContext);
   1097         PVMFStatus DoSetupSourceNode(PVCommandId aCmdId, OsclAny* aCmdContext);
   1098         PVMFStatus SetupDataSourceForUnknownURLAccess();
   1099         PVMFStatus DoSourceNodeQueryTrackSelIF(PVCommandId aCmdId, OsclAny* aCmdContext);
   1100         PVMFStatus DoSourceNodeQueryInterfaceOptional(PVCommandId aCmdId, OsclAny* aCmdContext);
   1101         PVMFStatus DoGetMetadataKey(PVPlayerEngineCommand& aCmd);
   1102         PVMFStatus DoGetMetadataValue(PVPlayerEngineCommand& aCmd);
   1103         PVMFStatus DoReleaseMetadataValues(PVPlayerEngineCommand& aCmd);
   1104         PVMFStatus AddToMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId, PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode);
   1105         PVMFStatus RemoveFromMetadataInterfaceList(PVMFMetadataExtensionInterface* aMetadataIF, PVMFSessionId aSessionId);
   1106         PVMFStatus DoInit(PVPlayerEngineCommand& aCmd);
   1107         PVMFStatus DoSourceNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
   1108         PVMFStatus DoSourceNodeGetDurationValue(PVCommandId aCmdId, OsclAny* aCmdContext);
   1109         PVMFStatus DoAcquireLicense(PVPlayerEngineCommand& aCmd);
   1110         PVMFStatus DoSourceNodeGetLicense(PVCommandId aCmdId, OsclAny* aCmdContext);
   1111         PVMFStatus DoAddDataSink(PVPlayerEngineCommand& aCmd);
   1112         PVMFStatus DoSetPlaybackRange(PVPlayerEngineCommand& aCmd);
   1113         PVMFStatus UpdateCurrentEndPosition(PVPPlaybackPosition& aEndPos);
   1114         PVMFStatus UpdateCurrentBeginPosition(PVPPlaybackPosition& aBeginPos, PVPlayerEngineCommand& aCmd);
   1115         PVMFStatus DoChangePlaybackPosition(PVCommandId aCmdId, OsclAny* aCmdContext);
   1116         PVMFStatus DoSourceNodeSetDataSourcePositionDuringPlayback(PVCommandId aCmdId, OsclAny* aCmdContext);
   1117         PVMFStatus DoSinkNodeSkipMediaDataDuringPlayback(PVCommandId aCmdId,
   1118                 OsclAny* aCmdContext,
   1119                 bool aSFR = false);
   1120         PVMFStatus DoGetPlaybackRange(PVPlayerEngineCommand& aCmd);
   1121         PVMFStatus DoGetCurrentPosition(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false);
   1122         PVMFStatus DoSetPlaybackRate(PVPlayerEngineCommand& aCmd);
   1123         PVMFStatus DoGetPlaybackRate(PVPlayerEngineCommand& aCmd);
   1124         PVMFStatus DoGetPlaybackMinMaxRate(PVPlayerEngineCommand& aCmd);
   1125         PVMFStatus DoPrepare(PVPlayerEngineCommand& aCmd);
   1126         PVMFStatus DoSinkNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext);
   1127         PVMFStatus DoSinkNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
   1128         PVMFStatus DoSinkNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext);
   1129         PVMFStatus DoDecNodeQueryCapConfigIF(PVCommandId aCmdId, OsclAny* aCmdContext);
   1130         PVMFStatus DoDecNodeInit(PVCommandId aCmdId, OsclAny* aCmdContext);
   1131         PVMFStatus DoSourceNodeTrackSelection(PVCommandId aCmdId, OsclAny* aCmdContext);
   1132         PVMFStatus DoTrackSelection(bool oPopulatePlayableListOnly, bool oUsePreferenceList);
   1133         PVMFStatus DoVerifyTrackInfo(PVPlayerEngineTrackSelection &aTrackSelection, PVMFTrackInfo* aTrack, PVMFStatus& aCheckcodec);
   1134         PVMFStatus DoSinkNodeDecNodeReset(PVCommandId aCmdId, OsclAny* aCmdContext);
   1135         PVMFStatus DoSinkDecCleanupSourcePrepare(PVCommandId aCmdId, OsclAny* aCmdContext);
   1136         PVMFStatus DoSourceNodePrepare(PVCommandId aCmdId, OsclAny* aCmdContext);
   1137         PVMFStatus DoSinkNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1138         PVMFStatus DoDecNodeQueryInterfaceOptional(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1139         PVMFStatus DoDatapathPrepare(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1140         PVMFStatus DoSourceNodeQueryDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext);
   1141         PVMFStatus DoSourceNodeSetDataSourcePosition(PVCommandId aCmdId, OsclAny* aCmdContext);
   1142         PVMFStatus DoSourceNodeSetDataSourceDirection(PVCommandId aCmdId, OsclAny* aCmdContext);
   1143         PVMFStatus DoSourceNodeStart(PVCommandId aCmdId, OsclAny* aCmdContext);
   1144         PVMFStatus DoDatapathStart(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1145         PVMFStatus DoSinkNodeSkipMediaData(PVCommandId aCmdId, OsclAny* aCmdContext);
   1146         PVMFStatus DoStart(PVPlayerEngineCommand& aCmd);
   1147         PVMFStatus DoPause(PVPlayerEngineCommand& aCmd);
   1148         PVMFStatus DoDatapathPause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext, bool aSinkPaused);
   1149         PVMFStatus DoSourceNodePause(PVCommandId aCmdId, OsclAny* aCmdContext);
   1150         PVMFStatus DoResume(PVPlayerEngineCommand& aCmd);
   1151         PVMFStatus DoStop(PVPlayerEngineCommand& aCmd);
   1152         PVMFStatus DoDatapathStop(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1153         PVMFStatus DoSourceNodeStop(PVCommandId aCmdId, OsclAny* aCmdContext);
   1154         PVMFStatus DoDatapathTeardown(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1155         PVMFStatus DoDatapathReset(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1156         PVMFStatus DoRemoveDataSink(PVPlayerEngineCommand& aCmd);
   1157         PVMFStatus DoReset(PVPlayerEngineCommand& aCmd);
   1158         PVMFStatus DoRemoveDataSource(PVPlayerEngineCommand& aCmd);
   1159         PVMFStatus RemoveDataSourceSync(PVPlayerDataSource &aSrc);
   1160         PVMFStatus DoSourceUnderflowAutoPause(PVPlayerEngineCommand& aCmd);
   1161         PVMFStatus DoSourceDataReadyAutoResume(PVPlayerEngineCommand& aCmd);
   1162         PVMFStatus DoSinkNodePause(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1163         PVMFStatus DoSinkNodeResume(PVPlayerEngineDatapath &aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext);
   1164         void DoRemoveAllSinks(void);
   1165         void DoEngineDatapathTeardown(PVPlayerEngineDatapath& aDatapath);
   1166         void DoEngineDatapathCleanup(PVPlayerEngineDatapath& aDatapath);
   1167         void DoSourceNodeCleanup(void);
   1168 
   1169         PVMFStatus DoSetObserverSync(PVPlayerEngineCommand& aCmd);
   1170         PVMFStatus DoGetLicenseStatusSync(PVPlayerEngineCommand& aCmd);
   1171         PVMFStatus DoGetParametersSync(PVPlayerEngineCommand& aCmd);
   1172         PVMFStatus DoReleaseParametersSync(PVPlayerEngineCommand& aCmd);
   1173         PVMFStatus DoVerifyParametersSync(PVPlayerEngineCommand& aCmd);
   1174         PVMFStatus DoCapConfigGetParametersSync(PvmiKeyType aIdentifier, PvmiKvp*& aParameters, int& aNumParamElements, PvmiCapabilityContext aContext);
   1175         PVMFStatus DoCapConfigReleaseParameters(PvmiKvp* aParameters, int aNumElements);
   1176         PVMFStatus DoCapConfigSetParameters(PVPlayerEngineCommand& aCmd, bool aSyncCmd = false);
   1177         PVMFStatus DoCapConfigVerifyParameters(PvmiKvp* aParameters, int aNumElements);
   1178         PVMFStatus DoGetPlayerParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
   1179         PVMFStatus DoGetPlayerProductInfoParameter(PvmiKvp*& aParameters, int& aNumParamElements, int32 aIndex, PvmiKvpAttr reqattr);
   1180         PVMFStatus DoVerifyAndSetPlayerParameter(PvmiKvp& aParameter, bool aSetParam);
   1181         PVMFStatus DoVerifyAndSetPlayerProductInfoParameter(PvmiKvp& aParameter, bool aSetParam);
   1182         PVMFStatus DoSetConfigSyncMargin(int32 aEarlyMargin, int32 aLateMargin, int32 aMediaType);
   1183         bool iHwAccelerated;
   1184         int32 iCapConfigContext;
   1185 
   1186         // Engine datapath and related variables
   1187         Oscl_Vector<PVPlayerEngineDatapath, OsclMemAllocator> iDatapathList;
   1188         uint32 iNumPendingNodeCmd;
   1189         int32 iNumPendingSkipCompleteEvent;
   1190         PVPlayerWatchdogTimer* iWatchDogTimer;
   1191         uint32 iNumPendingDatapathCmd;
   1192         int32 iNumPVMFInfoStartOfDataPending;
   1193 
   1194         // Data source, data sink, and nodes
   1195         PVPlayerDataSource* iDataSource;
   1196 
   1197         PVMFFormatType iSourceFormatType;
   1198         PVMFNodeInterface* iSourceNode;
   1199         PVMFSessionId iSourceNodeSessionId;
   1200         PVMFDataSourceInitializationExtensionInterface* iSourceNodeInitIF;
   1201         PVMFTrackSelectionExtensionInterface* iSourceNodeTrackSelIF;
   1202         PvmfDataSourcePlaybackControlInterface* iSourceNodePBCtrlIF;
   1203         PvmfDataSourceDirectionControlInterface* iSourceNodeDirCtrlIF;
   1204         PVMFTrackLevelInfoExtensionInterface* iSourceNodeTrackLevelInfoIF;
   1205         PVMFMetadataExtensionInterface* iSourceNodeMetadataExtIF;
   1206         PvmiCapabilityAndConfig* iSourceNodeCapConfigIF;
   1207         PVMFDataSourceNodeRegistryInitInterface* iSourceNodeRegInitIF;
   1208         PVMFCPMPluginLicenseInterface* iSourceNodeCPMLicenseIF;
   1209         PVInterface* iSourceNodePVInterfaceInit;
   1210         PVInterface* iSourceNodePVInterfaceTrackSel;
   1211         PVInterface* iSourceNodePVInterfacePBCtrl;
   1212         PVInterface* iSourceNodePVInterfaceDirCtrl;
   1213         PVInterface* iSourceNodePVInterfaceTrackLevelInfo;
   1214         PVInterface* iSourceNodePVInterfaceMetadataExt;
   1215         PVInterface* iSourceNodePVInterfaceCapConfig;
   1216         PVInterface* iSourceNodePVInterfaceRegInit;
   1217         PVInterface* iSourceNodePVInterfaceCPMLicense;
   1218 
   1219         // For CPM license acquisition
   1220         struct PVPlayerEngineCPMAcquireLicenseParam
   1221         {
   1222             OsclAny* iLicenseData;
   1223             uint32 iLicenseDataSize;
   1224             char* iContentNameChar;
   1225             oscl_wchar* iContentNameWChar;
   1226             int32 iTimeoutMsec;
   1227         };
   1228         PVPlayerEngineCPMAcquireLicenseParam iCPMAcquireLicenseParam;
   1229         OSCL_HeapString<OsclMemAllocator> iCPMContentNameStr;
   1230         OSCL_wHeapString<OsclMemAllocator> iCPMContentNameWStr;
   1231         PVMFCommandId iCPMGetLicenseCmdId;
   1232 
   1233         // For metadata handling
   1234         // Vector to hold a list of metadata interface available from the node
   1235         struct PVPlayerEngineMetadataIFInfo
   1236         {
   1237             PVMFMetadataExtensionInterface* iInterface;
   1238             PVMFSessionId iSessionId;
   1239             PVPlayerEngineDatapath* iEngineDatapath;
   1240             PVMFNodeInterface* iNode;
   1241         };
   1242         Oscl_Vector<PVPlayerEngineMetadataIFInfo, OsclMemAllocator> iMetadataIFList;
   1243 
   1244         // Structure to hold the parameters for GetMetadataKeys()
   1245         struct PVPlayerEngineGetMetadataKeysParam
   1246         {
   1247             int32 iStartingKeyIndex;
   1248             int32 iMaxKeyEntries;
   1249             char* iQueryKey;
   1250             PVPMetadataList* iKeyList;
   1251 
   1252             uint32 iCurrentInterfaceIndex;
   1253             int32 iNumKeyEntriesToFill;
   1254             int32 iNumKeyEntriesInList;
   1255         };
   1256         PVPlayerEngineGetMetadataKeysParam iGetMetadataKeysParam;
   1257 
   1258         // Structure to hold the parameters for GetMetadataValues()
   1259         struct PVPlayerEngineGetMetadataValuesParam
   1260         {
   1261             int32 iStartingValueIndex;
   1262             int32 iMaxValueEntries;
   1263             int32* iNumAvailableValues;
   1264             PVPMetadataList* iKeyList;
   1265             Oscl_Vector<PvmiKvp, OsclMemAllocator>* iValueList;
   1266 
   1267             uint32 iCurrentInterfaceIndex;
   1268             int32 iNumValueEntriesToFill;
   1269             int32 iNumValueEntriesInList;
   1270         };
   1271         PVPlayerEngineGetMetadataValuesParam iGetMetadataValuesParam;
   1272 
   1273         // Boolean to let engine know if metadata values have been copied by the app
   1274         bool iMetadataValuesCopiedInCallBack;
   1275 
   1276         // Boolean to check if Metadata values have been released
   1277         bool iReleaseMetadataValuesPending;
   1278 
   1279         // Vector hold a list of metadata interfaces with key/value to release memory
   1280         struct PVPlayerEngineMetadataReleaseEntry
   1281         {
   1282             uint32 iMetadataIFListIndex;
   1283             int32 iStartIndex;
   1284             int32 iEndIndex;
   1285         };
   1286         Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataKeyReleaseList;
   1287         Oscl_Vector<PVPlayerEngineMetadataReleaseEntry, OsclMemAllocator> iMetadataValueReleaseList;
   1288 
   1289         // Engine context related objects and utility functions
   1290         OsclMemPoolFixedChunkAllocator iCurrentContextListMemPool;
   1291         Oscl_Vector<PVPlayerEngineContext*, OsclMemAllocator> iCurrentContextList;
   1292         PVPlayerEngineContext* AllocateEngineContext(PVPlayerEngineDatapath* aEngineDatapath, PVMFNodeInterface* aNode, PVPlayerDatapath* aDatapath, PVCommandId aCmdId, OsclAny* aCmdContext, int32 aCmdType);
   1293         void FreeEngineContext(PVPlayerEngineContext* aContext);
   1294         void RemoveDatapathContextFromList();
   1295 
   1296         // Cancel and error handling related variables
   1297         uint32 iNumberCancelCmdPending;
   1298 
   1299         enum
   1300         {
   1301             // Node commands
   1302             PVP_CMD_SourceNodeQueryInitIF,
   1303             PVP_CMD_SourceNodeQueryTrackSelIF,
   1304             PVP_CMD_SourceNodeQueryTrackLevelInfoIF,
   1305             PVP_CMD_SourceNodeQueryPBCtrlIF,
   1306             PVP_CMD_SourceNodeQueryDirCtrlIF,
   1307             PVP_CMD_SourceNodeQueryMetadataIF,
   1308             PVP_CMD_SourceNodeQueryCapConfigIF,
   1309             PVP_CMD_SourceNodeQueryCPMLicenseIF,
   1310             PVP_CMD_SourceNodeQuerySrcNodeRegInitIF,
   1311             PVP_CMD_SourceNodeInit,
   1312             PVP_CMD_SourceNodeGetDurationValue,
   1313             PVP_CMD_SourceNodeSetDataSourceRate,
   1314             PVP_CMD_SourceNodePrepare,
   1315             PVP_CMD_SourceNodeGetLicense,
   1316             PVP_CMD_SourceNodeCancelGetLicense,
   1317             PVP_CMD_SinkNodeQuerySyncCtrlIF,
   1318             PVP_CMD_SinkNodeQueryMetadataIF,
   1319             PVP_CMD_SinkNodeQueryCapConfigIF,
   1320             PVP_CMD_DecNodeQueryMetadataIF,
   1321             PVP_CMD_DecNodeQueryCapConfigIF,
   1322             PVP_CMD_SinkNodeInit,
   1323             PVP_CMD_DecNodeInit,
   1324             PVP_CMD_SourceNodeQueryDataSourcePosition,
   1325             PVP_CMD_SourceNodeSetDataSourcePosition,
   1326             PVP_CMD_SourceNodeSetDataSourceDirection,
   1327             PVP_CMD_SourceNodeStart,
   1328             PVP_CMD_SourceNodeQueryDataSourcePositionDuringPlayback,
   1329             PVP_CMD_SourceNodeSetDataSourcePositionDuringPlayback,
   1330             PVP_CMD_SinkNodeSkipMediaDataDuringPlayback,
   1331             PVP_CMD_SinkNodeSkipMediaData,
   1332             PVP_CMD_SinkNodeDecNodeReset,
   1333             PVP_CMD_SinkNodeReset,
   1334             PVP_CMD_DecNodeReset,
   1335             PVP_CMD_GetNodeMetadataValue,
   1336             PVP_CMD_GetNodeMetadataKey,
   1337             PVP_CMD_SinkNodeAutoPause,
   1338             PVP_CMD_SinkNodeAutoResume,
   1339             PVP_CMD_SourceNodeStop,
   1340             PVP_CMD_SourceNodeReset,
   1341             // Datapath commands
   1342             PVP_CMD_DPPrepare,
   1343             PVP_CMD_DPStart,
   1344             PVP_CMD_DPStop,
   1345             PVP_CMD_DPTeardown,
   1346             PVP_CMD_DPReset,
   1347             // Recognizer command
   1348             PVP_CMD_QUERYSOURCEFORMATTYPE,
   1349             // source roll over
   1350             PVP_CMD_SourceNodeRollOver
   1351         };
   1352 
   1353         // Node command handling functions
   1354         void HandleSourceNodeQueryInitIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1355         void HandleSourceNodeQueryTrackSelIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1356         void HandleSourceNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1357         void HandleSourceNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1358         void HandleSourceNodeGetDurationValue(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1359         void HandleSourceNodeGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1360         void HandleSourceNodeCancelGetLicense(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1361 
   1362         void HandleSourceNodeSetDataSourceRate(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1363         PVMFStatus DoSinkNodeChangeClockRate();
   1364         PVMFStatus DoSinkPlaybackDirectionChange();
   1365         PVMFStatus UpdateCurrentDirection(PVMFCommandId, OsclAny*);
   1366         void UpdateTimebaseAndRate();
   1367         void UpdateDirection(PVMFTimestamp, PVMFTimestamp, PVPPlaybackPosition&);
   1368         void HandleSourceNodePrepare(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1369         void HandleSinkNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1370         void HandleDecNodeQueryInterfaceOptional(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1371         void HandleSourceNodeQueryDataSourcePosition(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1372         void HandleSourceNodeSetDataSourcePosition(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1373         void HandleSourceNodeSetDataSourceDirection(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1374         void HandleSourceNodeStart(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1375         void HandleSinkNodeSkipMediaData(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1376 
   1377         void HandleSourceNodeQueryDataSourcePositionDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1378         void HandleSourceNodeSetDataSourcePositionDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1379         void HandleSinkNodeSkipMediaDataDuringPlayback(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1380 
   1381         void HandleSourceNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1382         void HandleSourceNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1383         void HandleSourceNodeStop(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1384         void HandleSourceNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1385 
   1386         void HandleSinkNodePause(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1387         void HandleSinkNodeResume(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1388         void HandleSinkNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1389         void HandleDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1390 
   1391         void HandleSinkNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1392         void HandleSinkNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1393         void HandleDecNodeQueryCapConfigIF(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1394         void HandleDecNodeInit(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1395 
   1396         void HandleSinkNodeDecNodeReset(PVPlayerEngineContext& aNodeContext, const PVMFCmdResp& aNodeResp);
   1397 
   1398         // Datapath command handling functions
   1399         void HandleDatapathPrepare(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1400         void HandleDatapathStart(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1401         void HandleDatapathPause(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1402         void HandleDatapathResume(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1403         void HandleDatapathStop(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1404         void HandleDatapathTeardown(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1405         void HandleDatapathReset(PVPlayerEngineContext& aDatapathContext, PVMFStatus aDatapathStatus, PVMFCmdResp* aCmdResp);
   1406 
   1407         // Node error event handling functions
   1408         void HandleSourceNodeErrorEvent(const PVMFAsyncEvent& aEvent);
   1409         void HandleDecNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
   1410         void HandleSinkNodeErrorEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
   1411 
   1412         // Node informational event handling functions
   1413         void HandleSourceNodeInfoEvent(const PVMFAsyncEvent& aEvent);
   1414         void HandleDecNodeInfoEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
   1415         void HandleSinkNodeInfoEvent(const PVMFAsyncEvent& aEvent, int32 aDatapathIndex);
   1416         bool AllDatapathReceivedEndOfData();
   1417 
   1418         // Utility functions to send specific async events
   1419         void SendEndOfClipInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
   1420         void SendEndTimeReachedInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
   1421         void SendSourceUnderflowInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
   1422         void SendSourceDataReadyInfoEvent(PVMFStatus aStatus, PVInterface* aExtInterface = NULL);
   1423 
   1424         // Utility to retrieve the PVMFErrorInfoMessageInterface from a PVInterface
   1425         PVMFErrorInfoMessageInterface* GetErrorInfoMessageInterface(PVInterface& aInterface);
   1426 
   1427         // Utility functions to start/stop playback status timer
   1428         void StartPlaybackStatusTimer(void);
   1429         void StopPlaybackStatusTimer(void);
   1430 
   1431         // Utility Fucntion to calculate the nearest sync frame
   1432         void CalculateActualPlaybackPosition();
   1433 
   1434         // to save config values in case of protocol rollover
   1435         PVMFStatus VerifyAndSaveKVPValues(PvmiKvp *aKvpValue);
   1436         void SetRollOverKVPValues();
   1437         void DeleteKVPValues();
   1438 
   1439         // to reset reposition related variables.
   1440         void ResetReposVariables(bool aResetAll);
   1441 
   1442         PVMFStatus IssueNodeCancelCommand(PVPlayerEngineContext* aCurrentListContext, PVMFSessionId aSessionId, OsclAny* aNumberCancelCmdPending);
   1443         PVMFStatus IssueDatapathCancelCommand(PVPlayerEngineContext* aCurrentListContext, OsclAny* aNumberCancelCmdPending);
   1444         PVMFStatus IssueRecognizerRegistryCancel(OsclAny* aNumberCancelCmdPending);
   1445         PVMFStatus IssueSinkNodeInit(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
   1446         PVMFStatus IssueSinkNodeReset(PVPlayerEngineDatapath* aDatapath, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
   1447         PVMFStatus IssueSinkSkipMediaData(PVPlayerEngineDatapath* aDatapath, bool aSFR, OsclAny* aCmdContext);
   1448         PVMFStatus IssueSourceSetDataSourcePosition(bool aIsPosUnitPlayList, OsclAny* aCmdContext);
   1449         PVMFStatus IssueDecNodeInit(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
   1450         PVMFStatus IssueDecNodeReset(PVMFNodeInterface* aNode, PVMFSessionId aDecNodeSessionId, OsclAny* aCmdContext, PVMFCommandId &aCmdId);
   1451         PVMFStatus IssueQueryInterface(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, const PVUuid aUuid, PVInterface*& aInterfacePtr, OsclAny* aCmdContext, PVMFCommandId& aCmdId);
   1452 
   1453         // Handle to the logger node
   1454         PVLogger* iLogger;
   1455         PVLogger* iReposLogger;
   1456         PVLogger* iPerfLogger;
   1457 
   1458         // The node registry for the player engine
   1459         PVPlayerNodeRegistry iPlayerNodeRegistry;
   1460 
   1461         // The recognizer registry for the player engine
   1462         PVPlayerRecognizerRegistry iPlayerRecognizerRegistry;
   1463 
   1464         // Objects for playback clock and playback rate control
   1465         PVPlayerTimebase iPlaybackTimebase;
   1466         PVMFMediaClock iPlaybackClock;
   1467         PVMFMediaClockNotificationsInterface* iClockNotificationsInf;
   1468         uint32 iPlayStatusCallbackTimerID;
   1469         uint32 iPlayStatusCallbackTimerMarginWindow;
   1470 
   1471 
   1472         uint32 iCurrCallbackTimerLatency;
   1473         int32 iPlaybackClockRate;//always >=0
   1474         PVMFTimebase* iOutsideTimebase;
   1475         int32 iPlaybackClockRate_New;
   1476         PVMFTimebase* iOutsideTimebase_New;
   1477 
   1478         PVMFDataSourcePositionParams iDataSourcePosParams;
   1479 
   1480         // Objects for direction control.
   1481         int32 iPlaybackDirection;//1=forward, (-1)=backward.
   1482         int32 iPlaybackDirection_New;
   1483         bool iChangePlaybackDirectionWhenResuming;
   1484         PVPPlaybackPosition iChangeDirectionNPT;
   1485 
   1486         // Variables to store data for SetPlaybackRange()
   1487         PVPPlaybackPosition iCurrentBeginPosition;
   1488         PVPPlaybackPosition iCurrentEndPosition;
   1489         bool iEndTimeCheckEnabled;
   1490         bool iQueuedRangePresent;
   1491         PVPPlaybackPosition iQueuedBeginPosition;
   1492         PVPPlaybackPosition iQueuedEndPosition;
   1493         bool iChangePlaybackPositionWhenResuming;
   1494 
   1495         PVMFTimestamp iActualNPT;
   1496         PVMFTimestamp iTargetNPT;
   1497         PVMFTimestamp iActualMediaDataTS;
   1498         PVMFTimestamp iSkipMediaDataTS;
   1499         PVMFTimestamp iStartNPT;
   1500         PVMFTimestamp iStartMediaDataTS;
   1501         uint32 iWatchDogTimerInterval;
   1502         PVMFTimestamp iSeekPointBeforeTargetNPT;
   1503         PVMFTimestamp iSeekPointAfterTargetNPT;
   1504         // forward and reverse flags, a single flag can also serve, but kept for MP4 parser alignment.
   1505         bool iForwardReposFlag;
   1506         bool iBackwardReposFlag;
   1507 
   1508         // Flag to keep track of whether play status event is enabled or not
   1509         bool iPlayStatusTimerEnabled;
   1510 
   1511         // Flags to keep track of source auto-pause/resume
   1512         bool iDataReadySent;
   1513         bool removeCmdFromQ(OsclPriorityQueue<PVPlayerEngineCommand, OsclMemAllocator, Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator>, PVPlayerEngineCommandCompareLess> &aVec, const PVPlayerEngineCommandType aCmdType, bool aRemove);
   1514         bool removeCmdFromQ(Oscl_Vector<PVPlayerEngineCommand, OsclMemAllocator> &aVec, const PVPlayerEngineCommandType aCmdType, bool aRemove);
   1515 
   1516         // Flag to keep track of whether playback has ended with end of clip
   1517         bool iPlaybackPausedDueToEndOfClip;
   1518 
   1519         // Variables to store the source data duration
   1520         bool iSourceDurationAvailable;
   1521         uint32 iSourceDurationInMS;
   1522         PVMFMetadataList iSourceDurationKeyList;
   1523         Oscl_Vector<PvmiKvp, OsclMemAllocator> iSourceDurationValueList;
   1524 
   1525         // Variables to store the source data duration
   1526         PVMFMetadataList iDlaDataKeyList;
   1527         Oscl_Vector<PvmiKvp, OsclMemAllocator> iDlaDataValueList;
   1528 
   1529         // Player engine configuration
   1530         bool iPBPosEnable;
   1531         PVPPlaybackPositionUnit iPBPosStatusUnit;
   1532         uint32 iPBPosStatusInterval;
   1533         uint32 iEndTimeCheckInterval;
   1534         bool iSeekToSyncPoint;
   1535         bool iSkipToRequestedPosition;
   1536         bool iBackwardRepos; /* To avoid backward looping :: Flag to remember if this is a case of backward repositioning */
   1537         uint32 iSyncPointSeekWindow;
   1538         range_int32 iSyncMarginVideo;
   1539         range_int32 iSyncMarginAudio;
   1540         range_int32 iSyncMarginText;
   1541         uint32 iNodeCmdTimeout;
   1542         uint32 iNodeDataQueuingTimeout;
   1543         OSCL_HeapString<OsclMemAllocator> iProdInfoProdName;
   1544         OSCL_HeapString<OsclMemAllocator> iProdInfoPartNum;
   1545         OSCL_HeapString<OsclMemAllocator> iProdInfoHWPlatform;
   1546         OSCL_HeapString<OsclMemAllocator> iProdInfoSWPlatform;
   1547         OSCL_HeapString<OsclMemAllocator> iProdInfoDevice;
   1548         // stream ID for media streams
   1549         uint32 iStreamID;
   1550 
   1551         //source roll over related
   1552         PVMFStatus DoSourceNodeRollOver(PVCommandId aCmdId, OsclAny* aCmdContext);
   1553         uint32 iAlternateSrcFormatIndex;
   1554         bool CheckForSourceRollOver();
   1555         enum RollOverState
   1556         {
   1557             RollOverStateIdle,
   1558             RollOverStateStart,
   1559             RollOverStateInProgress
   1560         };
   1561         RollOverState iRollOverState;
   1562 
   1563         //To save CapnCapability in case of Protocol Rollover
   1564         Oscl_Vector<PvmiKvp *, OsclMemAllocator> iPvmiKvpCapNConfig;
   1565 
   1566         struct PVPlayerEngineUuidNodeMapping
   1567         {
   1568             PVUuid          iUuid;
   1569             PVMFNodeInterface*  iNode;
   1570             PVPlayerEngineUuidNodeMapping(PVUuid aUuid, PVMFNodeInterface* aNode):
   1571                     iUuid(aUuid), iNode(aNode) {}
   1572         };
   1573         //Vector to store the Uuids for the nodes created throughout the playback
   1574         Oscl_Vector<PVPlayerEngineUuidNodeMapping, OsclMemAllocator> iNodeUuids;
   1575 
   1576         // For Track Selection during Prepare
   1577         Oscl_Vector<PVPlayerEngineTrackSelection, OsclMemAllocator> iTrackSelectionList;
   1578         PVMFMediaPresentationInfo iSourcePresInfoList;
   1579         PVMFMediaPresentationInfo iPlayableList;
   1580         PVMFMediaPresentationInfo iPreferenceList;
   1581         PVMFTrackSelectionHelper* iTrackSelectionHelper;
   1582 
   1583         PVPPlaybackPositionMode iPlaybackPositionMode;
   1584         bool iOverflowFlag;
   1585 };
   1586 
   1587 /**
   1588  * Inactivity timer object to Jitter Buffer node. This object generates event
   1589  * on remote inactivity (no UDP traffic from server for a certain time)
   1590  */
   1591 #define DEFAULT_WATCHDOG_TIMERDURATION 10
   1592 #define PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL 1000
   1593 
   1594 class PVPlayerWatchdogTimer : public OsclTimerObject
   1595 {
   1596     public:
   1597         PVPlayerWatchdogTimer(PVPlayerWatchdogTimerObserver* aTimerObserver):
   1598                 OsclTimerObject(OsclActiveObject::EPriorityNominal, "PVPlayerWatchDogTimer"),
   1599                 iTimerDuration(DEFAULT_WATCHDOG_TIMERDURATION),
   1600                 iObserver(aTimerObserver),
   1601                 iStarted(false)
   1602         {
   1603             AddToScheduler();
   1604         }
   1605 
   1606         virtual ~PVPlayerWatchdogTimer()
   1607         {
   1608             Stop();
   1609         }
   1610 
   1611         /** Start Timer */
   1612         PVMFStatus Start()
   1613         {
   1614             if (iTimerDuration != 0)
   1615             {
   1616                 RunIfNotReady(iTimerDuration * 1000);
   1617                 iStarted = true;
   1618                 return PVMFSuccess;
   1619             }
   1620             else
   1621             {
   1622                 return PVMFFailure;
   1623             }
   1624         }
   1625 
   1626         void setTimerDuration(uint32 aTimerDuration)
   1627         {
   1628             Cancel();
   1629             iTimerDuration = (PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL < aTimerDuration) ? aTimerDuration : PVPLAYERENGINE_DEFAULT_WATCHDOGTIMER_INTERVAL;
   1630         }
   1631 
   1632         uint32 getTimerDurationInMS()
   1633         {
   1634             return iTimerDuration;
   1635         }
   1636 
   1637         /** Stop Timer events */
   1638         PVMFStatus Stop()
   1639         {
   1640             Cancel();
   1641             iStarted = false;
   1642             return PVMFSuccess;
   1643         }
   1644 
   1645         bool IsTimerStarted()
   1646         {
   1647             return iStarted;
   1648         }
   1649 
   1650     private:
   1651         void Run()
   1652         {
   1653             if (!iStarted)
   1654                 return;
   1655 
   1656             if (!iObserver)
   1657             {
   1658                 // Error, No observer set
   1659                 return;
   1660             }
   1661 
   1662             iObserver->PVPlayerWatchdogTimerEvent();
   1663             /*
   1664              * Do not reschudule the AO here. Observer would reschedule this AO
   1665              * once it is done processing the timer event.
   1666              */
   1667         }
   1668 
   1669 
   1670         uint32 iTimerDuration;
   1671         PVPlayerWatchdogTimerObserver* iObserver;
   1672         PVLogger* iLogger;
   1673         bool iStarted;
   1674 };
   1675 
   1676 #endif
   1677