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 PVMF_MP4FFPARSER_NODE_H_INCLUDED
     19 #define PVMF_MP4FFPARSER_NODE_H_INCLUDED
     20 
     21 
     22 #ifndef OSCL_BASE_H_INCLUDED
     23 #include "oscl_base.h"
     24 #endif
     25 
     26 #ifndef PVMF_MEDIA_CLOCK_H_INCLUDED
     27 #include "pvmf_media_clock.h"
     28 #endif
     29 
     30 #ifndef OSCL_TIMER_H_INCLUDED
     31 #include "oscl_timer.h"
     32 #endif
     33 
     34 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
     35 #include "oscl_scheduler_ao.h"
     36 #endif
     37 
     38 #ifndef OSCL_FILE_IO_H_INCLUDED
     39 #include "oscl_file_io.h"
     40 #endif
     41 
     42 #ifndef OSCL_STRING_H_INCLUDED
     43 #include "oscl_string.h"
     44 #endif
     45 
     46 #ifndef PVLOGGER_H_INCLUDED
     47 #include "pvlogger.h"
     48 #endif
     49 
     50 #ifndef PVLOGGER_FILE_APPENDER_H_INCLUDED
     51 #include "pvlogger_file_appender.h"
     52 #endif
     53 
     54 #ifndef OSCL_BIN_STREAM_H_INCLUDED
     55 #include "oscl_bin_stream.h"
     56 #endif
     57 
     58 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
     59 #include "pvmf_format_type.h"
     60 #endif
     61 
     62 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
     63 #include "pvmf_node_interface.h"
     64 #endif
     65 
     66 #ifndef PVMF_NODE_UTILS_H_INCLUDED
     67 #include "pvmf_node_utils.h"
     68 #endif
     69 
     70 #ifndef OSCL_PRIQUEUE_H_INCLUDED
     71 #include "oscl_priqueue.h"
     72 #endif
     73 
     74 #ifndef PVMF_MEDIA_DATA_H_INCLUDED
     75 #include "pvmf_media_data.h"
     76 #endif
     77 
     78 #ifndef OSCL_MEM_MEMPOOL_H_INCLUDED
     79 #include "oscl_mem_mempool.h"
     80 #endif
     81 
     82 #ifndef PVMF_SIMPLE_MEDIA_BUFFER_H_INCLUDED
     83 #include "pvmf_simple_media_buffer.h"
     84 #endif
     85 
     86 #ifndef PVMF_MEDIA_FRAG_GROUP_H_INCLUDED
     87 #include "pvmf_media_frag_group.h"
     88 #endif
     89 
     90 #ifndef PVMF_MP4FFPARSER_DEFS_H_INCLUDED
     91 #include "pvmf_mp4ffparser_defs.h"
     92 #endif
     93 
     94 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
     95 #include "pvmf_data_source_playback_control.h"
     96 #endif
     97 
     98 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
     99 #include "pvmf_meta_data_extension.h"
    100 #endif
    101 
    102 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
    103 #include "pvmf_data_source_init_extension.h"
    104 #endif
    105 
    106 #ifndef PVMF_TRACK_SELECTION_EXTENSION_H_INCLUDED
    107 #include "pvmf_track_selection_extension.h"
    108 #endif
    109 
    110 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
    111 #include "pvmf_media_presentation_info.h"
    112 #endif
    113 
    114 #ifndef PVMF_TRACK_LEVEL_INFO_EXTENSION_H_INCLUDED
    115 #include "pvmf_track_level_info_extension.h"
    116 #endif
    117 
    118 #ifndef PVMF_MP4_PROGDOWNLOAD_SUPPORT_EXTENSION_H_INCLUDED
    119 #include "pvmf_mp4_progdownload_support_extension.h"
    120 #endif
    121 
    122 #ifndef CPM_H_INCLUDED
    123 #include "cpm.h"
    124 #endif
    125 
    126 #ifndef PVMF_CPMPLUGIN_ACCESS_INTERFACE_H_INCLUDED
    127 #include "pvmf_cpmplugin_access_interface.h"
    128 #endif
    129 
    130 #ifndef PVMF_LOCAL_DATA_SOURCE_H_INCLUDED
    131 #include "pvmf_local_data_source.h"
    132 #endif
    133 
    134 #ifndef PVMF_MEMPOOL_H_INCLUDED
    135 #include "pvmf_mempool.h"
    136 #endif
    137 
    138 #ifndef PVMF_TIMEDTEXT_H_INCLUDED
    139 #include "pvmf_timedtext.h"
    140 #endif
    141 
    142 #ifndef PV_GAU_H_
    143 #include "pv_gau.h"
    144 #endif
    145 
    146 #ifndef PVMF_FORMAT_PROGDOWNLOAD_SUPPORT_EXTENSION_H_INCLUDED
    147 #include "pvmf_format_progdownload_support_extension.h"
    148 #endif
    149 
    150 #ifndef PVMF_DOWNLOAD_PROGRESS_EXTENSION_H
    151 #include "pvmf_download_progress_interface.h"
    152 #endif
    153 
    154 #ifndef PVMI_DATASTREAMUSER_INTERFACE_H_INCLUDED
    155 #include "pvmi_datastreamuser_interface.h"
    156 #endif
    157 
    158 #ifndef PVMF_MP4FFPARSER_OUTPORT_H_INCLUDED
    159 #include "pvmf_mp4ffparser_outport.h"
    160 #endif
    161 
    162 #ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
    163 #include "pvmf_source_context_data.h"
    164 #endif
    165 
    166 #ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
    167 #include "pvmf_cpmplugin_license_interface.h"
    168 #endif
    169 
    170 #ifndef PVMI_KVP_UTIL_H_INCLUDED
    171 #include "pvmi_kvp_util.h"
    172 #endif
    173 
    174 #ifndef PVMF_BASIC_ERRORINFOMESSAGE_H_INCLUDED
    175 #include "pvmf_basic_errorinfomessage.h"
    176 #endif
    177 
    178 #ifndef PVMF_DATA_SOURCE_DIRECTION_CONTROL_H_INCLUDED
    179 #include "pvmf_data_source_direction_control.h"
    180 #endif
    181 
    182 /**
    183 * Node command handling
    184 */
    185 
    186 class PVMFMP4ParserNodeLoggerDestructDealloc : public OsclDestructDealloc
    187 {
    188     public:
    189         void destruct_and_dealloc(OsclAny* ptr)
    190         {
    191             PVLoggerAppender* p = OSCL_REINTERPRET_CAST(PVLoggerAppender*, ptr);
    192             BinaryFileAppender* binPtr = OSCL_REINTERPRET_CAST(BinaryFileAppender*, p);
    193             if (!binPtr)
    194                 return;
    195             OSCL_DELETE(binPtr);
    196         }
    197 };
    198 
    199 #define PVMF_MP4FFPARSERNODE_UNDERFLOW_STATUS_TIMER_ID 1
    200 
    201 #define PVMF_MP4FFPARSERNODE_MAX_CPM_METADATA_KEYS 256
    202 
    203 #define NORMAL_PLAYRATE 100000
    204 
    205 typedef PVMFGenericNodeCommand<OsclMemAllocator> PVMFMP4FFParserNodeCommandBase;
    206 
    207 enum PVMFMP4FFParserNodeCommandType
    208 {
    209     PVMP4FF_NODE_CMD_SETDATASOURCEPOSITION = PVMF_GENERIC_NODE_COMMAND_LAST
    210     , PVMP4FF_NODE_CMD_QUERYDATASOURCEPOSITION
    211     , PVMP4FF_NODE_CMD_SETDATASOURCERATE
    212     , PVMP4FF_NODE_CMD_GETNODEMETADATAKEYS
    213     , PVMP4FF_NODE_CMD_GETNODEMETADATAVALUES
    214     , PVMP4FF_NODE_CMD_GET_LICENSE_W
    215     , PVMP4FF_NODE_CMD_GET_LICENSE
    216     , PVMP4FF_NODE_CMD_CANCEL_GET_LICENSE
    217     , PVMF_MP4_PARSER_NODE_CAPCONFIG_SETPARAMS
    218     , PVMP4FF_NODE_CMD_SETDATASOURCEDIRECTION
    219 };
    220 
    221 class PVMFMP4FFParserNodeCommand : public PVMFMP4FFParserNodeCommandBase
    222 {
    223     public:
    224 
    225         // Constructor and parser for GetNodeMetadataKeys
    226         void Construct(PVMFSessionId s, int32 cmd
    227                        , PVMFMetadataList& aKeyList
    228                        , uint32 aStartingIndex
    229                        , int32 aMaxEntries
    230                        , char* aQueryKey
    231                        , const OsclAny* aContext)
    232         {
    233             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    234             iParam1 = (OsclAny*) & aKeyList;
    235             iParam2 = (OsclAny*)aStartingIndex;
    236             iParam3 = (OsclAny*)aMaxEntries;
    237             if (aQueryKey)
    238             {
    239                 //allocate a copy of the query key string.
    240                 Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
    241                 iParam4 = str.ALLOC_AND_CONSTRUCT(aQueryKey);
    242             }
    243         }
    244         void Parse(PVMFMetadataList*& MetaDataListPtr, uint32 &aStartingIndex, int32 &aMaxEntries, char*& aQueryKey)
    245         {
    246             MetaDataListPtr = (PVMFMetadataList*)iParam1;
    247             aStartingIndex = (uint32)iParam2;
    248             aMaxEntries = (int32)iParam3;
    249             aQueryKey = NULL;
    250             if (iParam4)
    251             {
    252                 OSCL_HeapString<OsclMemAllocator>* keystring = (OSCL_HeapString<OsclMemAllocator>*)iParam4;
    253                 aQueryKey = keystring->get_str();
    254             }
    255         }
    256 
    257         // Constructor and parser for GetNodeMetadataValue
    258         void Construct(PVMFSessionId s, int32 cmd, PVMFMetadataList& aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 aStartIndex, int32 aMaxEntries, const OsclAny* aContext)
    259         {
    260             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    261             iParam1 = (OsclAny*) & aKeyList;
    262             iParam2 = (OsclAny*) & aValueList;
    263             iParam3 = (OsclAny*)aStartIndex;
    264             iParam4 = (OsclAny*)aMaxEntries;
    265 
    266         }
    267         void Parse(PVMFMetadataList* &aKeyList, Oscl_Vector<PvmiKvp, OsclMemAllocator>* &aValueList, uint32 &aStartingIndex, int32 &aMaxEntries)
    268         {
    269             aKeyList = (PVMFMetadataList*)iParam1;
    270             aValueList = (Oscl_Vector<PvmiKvp, OsclMemAllocator>*)iParam2;
    271             aStartingIndex = (uint32)iParam3;
    272             aMaxEntries = (int32)iParam4;
    273         }
    274 
    275         /* Constructor and parser for setParametersAsync */
    276         void Construct(PVMFSessionId s, int32 cmd, PvmiMIOSession aSession,
    277                        PvmiKvp* aParameters, int num_elements,
    278                        PvmiKvp*& aRet_kvp, OsclAny* aContext)
    279         {
    280             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    281             iParam1 = (OsclAny*)aSession;
    282             iParam2 = (OsclAny*)aParameters;
    283             iParam3 = (OsclAny*)num_elements;
    284             iParam4 = (OsclAny*) & aRet_kvp;
    285         }
    286         void Parse(PvmiMIOSession& aSession, PvmiKvp*& aParameters,
    287                    int &num_elements, PvmiKvp** &ppRet_kvp)
    288         {
    289             aSession = (PvmiMIOSession)iParam1;
    290             aParameters = (PvmiKvp*)iParam2;
    291             num_elements = (int)iParam3;
    292             ppRet_kvp = (PvmiKvp**)iParam4;
    293         }
    294 
    295         // Constructor and parser for SetDataSourcePosition
    296         void Construct(PVMFSessionId s, int32 cmd, PVMFTimestamp aTargetNPT, PVMFTimestamp& aActualNPT, PVMFTimestamp& aActualMediaDataTS,
    297                        bool aSeekToSyncPoint, uint32 aStreamID, const OsclAny*aContext)
    298         {
    299             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    300             iParam1 = (OsclAny*)aTargetNPT;
    301             iParam2 = (OsclAny*) & aActualNPT;
    302             iParam3 = (OsclAny*) & aActualMediaDataTS;
    303             iParam4 = (OsclAny*)aSeekToSyncPoint;
    304             iParam5 = (OsclAny*)aStreamID;
    305         }
    306         void Parse(PVMFTimestamp& aTargetNPT, PVMFTimestamp*& aActualNPT, PVMFTimestamp*& aActualMediaDataTS, bool& aSeekToSyncPoint, uint32& aStreamID)
    307         {
    308             aTargetNPT = (PVMFTimestamp)iParam1;
    309             aActualNPT = (PVMFTimestamp*)iParam2;
    310             aActualMediaDataTS = (PVMFTimestamp*)iParam3;
    311             aSeekToSyncPoint = (iParam4) ? true : false;
    312             aStreamID = (uint32)iParam5;
    313         }
    314 
    315         // Constructor and parser for QueryDataSourcePosition
    316         void Construct(PVMFSessionId s, int32 cmd, PVMFTimestamp aTargetNPT, PVMFTimestamp &aActualNPT,
    317                        bool aSeekToSyncPoint, const OsclAny*aContext)
    318         {
    319             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    320             iParam1 = (OsclAny*)aTargetNPT;
    321             iParam2 = (OsclAny*) & aActualNPT;
    322             iParam3 = (OsclAny*)aSeekToSyncPoint;
    323             iParam4 = NULL;
    324             iParam5 = NULL;
    325         }
    326 
    327         // Constructor and parser for QueryDataSourcePosition with aSeekPointBeforeTargetNPT and aSeekPointAfterTargetNPT
    328         void Construct(PVMFSessionId s, int32 cmd, PVMFTimestamp aTargetNPT,
    329                        PVMFTimestamp& aSeekPointBeforeTargetNPT, PVMFTimestamp& aSeekPointAfterTargetNPT,
    330                        const OsclAny*aContext, bool aSeekToSyncPoint)
    331         {
    332             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    333             iParam1 = (OsclAny*)aTargetNPT;
    334             iParam3 = (OsclAny*)aSeekToSyncPoint;
    335             iParam4 = (OsclAny*) & aSeekPointBeforeTargetNPT;
    336             iParam5 = (OsclAny*) & aSeekPointAfterTargetNPT;
    337         }
    338 
    339 
    340         void Parse(PVMFTimestamp& aTargetNPT, PVMFTimestamp*& aActualNPT, bool& aSeekToSyncPoint)
    341         {
    342             aTargetNPT = (PVMFTimestamp)iParam1;
    343             aActualNPT = (PVMFTimestamp*)iParam2;
    344             aSeekToSyncPoint = (iParam3) ? true : false;
    345         }
    346 
    347         void Parse(PVMFTimestamp& aTargetNPT, PVMFTimestamp*& aSeekPointBeforeTargetNPT,
    348                    bool& aSeekToSyncPoint, PVMFTimestamp*& aSeekPointAfterTargetNPT)
    349         {
    350             aTargetNPT = (PVMFTimestamp)iParam1;
    351             aSeekPointBeforeTargetNPT = (PVMFTimestamp*)iParam4;
    352             aSeekPointAfterTargetNPT = (PVMFTimestamp*)iParam5;
    353             aSeekToSyncPoint = (iParam3) ? true : false;
    354         }
    355         /* Constructor and parser for SetDataSourceDirection */
    356         void Construct(PVMFSessionId s, int32 cmd, int32 aDirection,
    357                        PVMFTimestamp& aActualNPT, PVMFTimestamp& aActualMediaDataTS,
    358                        PVMFTimebase* aTimebase, OsclAny* aContext)
    359         {
    360             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    361             iParam1 = (OsclAny*)aDirection;
    362             iParam2 = (OsclAny*) & aActualNPT;
    363             iParam3 = (OsclAny*) & aActualMediaDataTS;
    364             iParam4 = (OsclAny*)aTimebase;
    365             iParam5 = NULL;
    366         }
    367         void Parse(int32& aDirection,
    368                    PVMFTimestamp*& aActualNPT,
    369                    PVMFTimestamp*& aActualMediaDataTS,
    370                    PVMFTimebase*& aTimebase)
    371         {
    372             aDirection = (int32)iParam1;
    373             aActualNPT = (PVMFTimestamp*)iParam2;
    374             aActualMediaDataTS = (PVMFTimestamp*)iParam3;
    375             aTimebase = (PVMFTimebase*)iParam4;
    376         }
    377 
    378         // Constructor and parser for SetDataSourceRate
    379         void Construct(PVMFSessionId s, int32 cmd, int32 aRate, PVMFTimebase* aTimebase, const OsclAny*aContext)
    380         {
    381             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    382             iParam1 = (OsclAny*)aRate;
    383             iParam2 = (OsclAny*)aTimebase;
    384             iParam3 = NULL;
    385             iParam4 = NULL;
    386             iParam5 = NULL;
    387         }
    388         void Parse(int32& aRate, PVMFTimebase*& aTimebase)
    389         {
    390             aRate = (int32)iParam1;
    391             aTimebase = (PVMFTimebase*)iParam2;
    392         }
    393 
    394         /* Constructor and parser for GetLicenseW */
    395         void Construct(PVMFSessionId s,
    396                        int32 cmd,
    397                        OSCL_wString& aContentName,
    398                        OsclAny* aLicenseData,
    399                        uint32 aDataSize,
    400                        int32 aTimeoutMsec,
    401                        OsclAny* aContext)
    402         {
    403             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    404             iParam1 = (OsclAny*) & aContentName;
    405             iParam2 = (OsclAny*)aLicenseData;
    406             iParam3 = (OsclAny*)aDataSize;
    407             iParam4 = (OsclAny*)aTimeoutMsec;
    408             iParam5 = NULL;
    409         }
    410         void Parse(OSCL_wString*& aContentName,
    411                    OsclAny*& aLicenseData,
    412                    uint32& aDataSize,
    413                    int32& aTimeoutMsec)
    414         {
    415             aContentName = (OSCL_wString*)iParam1;
    416             aLicenseData = (PVMFTimestamp*)iParam2;
    417             aDataSize = (uint32)iParam3;
    418             aTimeoutMsec = (int32)iParam4;
    419         }
    420 
    421         /* Constructor and parser for GetLicense */
    422         void Construct(PVMFSessionId s,
    423                        int32 cmd,
    424                        OSCL_String& aContentName,
    425                        OsclAny* aLicenseData,
    426                        uint32 aDataSize,
    427                        int32 aTimeoutMsec,
    428                        OsclAny* aContext)
    429         {
    430             PVMFMP4FFParserNodeCommandBase::Construct(s, cmd, aContext);
    431             iParam1 = (OsclAny*) & aContentName;
    432             iParam2 = (OsclAny*)aLicenseData;
    433             iParam3 = (OsclAny*)aDataSize;
    434             iParam4 = (OsclAny*)aTimeoutMsec;
    435             iParam5 = NULL;
    436         }
    437         void Parse(OSCL_String*& aContentName,
    438                    OsclAny*& aLicenseData,
    439                    uint32& aDataSize,
    440                    int32& aTimeoutMsec)
    441         {
    442             aContentName = (OSCL_String*)iParam1;
    443             aLicenseData = (PVMFTimestamp*)iParam2;
    444             aDataSize = (uint32)iParam3;
    445             aTimeoutMsec = (int32)iParam4;
    446         }
    447 
    448 
    449         // Need to overlaod the base Destroy routine to cleanup metadata key.
    450         void Destroy()
    451         {
    452             PVMFGenericNodeCommand<OsclMemAllocator>::Destroy();
    453             switch (iCmd)
    454             {
    455                 case PVMP4FF_NODE_CMD_GETNODEMETADATAKEYS:
    456                     if (iParam4)
    457                     {
    458                         //cleanup the allocated string
    459                         Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
    460                         str.destruct_and_dealloc(iParam4);
    461                     }
    462                     break;
    463                 default:
    464                     break;
    465             }
    466         }
    467 
    468         // Need to overlaod the base Copy routine to copy metadata key.
    469         void Copy(const PVMFGenericNodeCommand<OsclMemAllocator>& aCmd)
    470         {
    471             PVMFGenericNodeCommand<OsclMemAllocator>::Copy(aCmd);
    472             switch (aCmd.iCmd)
    473             {
    474                 case PVMP4FF_NODE_CMD_GETNODEMETADATAKEYS:
    475                     if (aCmd.iParam4)
    476                     {
    477                         //copy the allocated string
    478                         OSCL_HeapString<OsclMemAllocator>* aStr = (OSCL_HeapString<OsclMemAllocator>*)aCmd.iParam4;
    479                         Oscl_TAlloc<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> str;
    480                         iParam4 = str.ALLOC_AND_CONSTRUCT(*aStr);
    481                     }
    482                     break;
    483                 default:
    484                     break;
    485             }
    486         }
    487 
    488 };
    489 typedef PVMFNodeCommandQueue<PVMFMP4FFParserNodeCommand, OsclMemAllocator> PVMFMP4FFParserNodeCmdQueue;
    490 
    491 //Command queue type
    492 typedef PVMFNodeCommandQueue<PVMFMP4FFParserNodeCommand, OsclMemAllocator> PVMFMP4FFParserNodeCmdQueue;
    493 
    494 
    495 /**
    496 * The Node class
    497 */
    498 class IMpeg4File;
    499 class PVMFMP4FFParserOutPort;
    500 class PVMFMP4FFPortIter;
    501 class PVLogger;
    502 class PVMFMediaClock;
    503 
    504 enum BaseKeys_SelectionType
    505 {
    506     INVALID = 0,
    507     NET,
    508     FILE_IO
    509 };
    510 
    511 #define PVMFFFPARSERNODE_MAX_NUM_TRACKS 6
    512 
    513 class PVMFMP4FFParserNode : public OsclTimerObject,
    514         public PVMFNodeInterface,
    515         public PVMFDataSourceInitializationExtensionInterface,
    516         public PVMFTrackSelectionExtensionInterface,
    517         public PvmfDataSourcePlaybackControlInterface,
    518         public PVMFMetadataExtensionInterface,
    519         public PVMFTrackLevelInfoExtensionInterface,
    520         public PVMFCPMStatusObserver,
    521         public PvmiDataStreamObserver,
    522         public PVMIDatastreamuserInterface,
    523         public PVMFFormatProgDownloadSupportInterface,
    524         public OsclTimerObserver,
    525         public PVMFCPMPluginLicenseInterface,
    526         public PvmiCapabilityAndConfig,
    527         public PVMFMediaClockStateObserver, // For observing the playback clock states
    528         public PvmfDataSourceDirectionControlInterface
    529 {
    530     public:
    531         PVMFMP4FFParserNode(int32 aPriority = OsclActiveObject::EPriorityNominal);
    532         virtual ~PVMFMP4FFParserNode();
    533 
    534         // From PVMFNodeInterface
    535         PVMFStatus ThreadLogon();
    536         PVMFStatus ThreadLogoff();
    537         PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
    538         PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
    539 
    540         PVMFCommandId QueryUUID(PVMFSessionId aSessionId,
    541                                 const PvmfMimeString& aMimeType,
    542                                 Oscl_Vector<PVUuid, OsclMemAllocator>& aUuids,
    543                                 bool aExactUuidsOnly = false,
    544                                 const OsclAny* aContext = NULL);
    545         PVMFCommandId QueryInterface(PVMFSessionId aSessionId,
    546                                      const PVUuid& aUuid,
    547                                      PVInterface*& aInterfacePtr,
    548                                      const OsclAny* aContext = NULL);
    549 
    550         PVMFCommandId RequestPort(PVMFSessionId aSessionId, int32 aPortTag,
    551                                   const PvmfMimeString* aPortConfig = NULL,
    552                                   const OsclAny* aContext = NULL);
    553         PVMFStatus ReleasePort(PVMFSessionId aSessionId, PVMFPortInterface& aPort,
    554                                const OsclAny* aContext = NULL);
    555 
    556         PVMFCommandId Init(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    557         PVMFCommandId Prepare(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    558         PVMFCommandId Start(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    559         PVMFCommandId Stop(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    560         PVMFCommandId Flush(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    561         PVMFCommandId Pause(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    562         PVMFCommandId Reset(PVMFSessionId aSessionId, const OsclAny* aContext = NULL);
    563 
    564         PVMFCommandId CancelAllCommands(PVMFSessionId aSessionId, const OsclAny* aContextData = NULL);
    565         PVMFCommandId CancelCommand(PVMFSessionId aSessionId, PVMFCommandId aCmdId, const OsclAny* aContextData = NULL);
    566         PVMFStatus QueryInterfaceSync(PVMFSessionId aSession,
    567                                       const PVUuid& aUuid,
    568                                       PVInterface*& aInterfacePtr);
    569 
    570         /* cap config interface */
    571         virtual void setObserver(PvmiConfigAndCapabilityCmdObserver* aObserver)
    572         {
    573             ciObserver = aObserver;
    574         }
    575 
    576         virtual PVMFStatus getParametersSync(PvmiMIOSession aSession,
    577                                              PvmiKeyType aIdentifier,
    578                                              PvmiKvp*& aParameters,
    579                                              int& aNumParamElements,
    580                                              PvmiCapabilityContext aContext);
    581         virtual PVMFStatus releaseParameters(PvmiMIOSession aSession,
    582                                              PvmiKvp* aParameters,
    583                                              int num_elements);
    584         virtual void createContext(PvmiMIOSession aSession, PvmiCapabilityContext& aContext);
    585         virtual void setContextParameters(PvmiMIOSession aSession, PvmiCapabilityContext& aContext,
    586                                           PvmiKvp* aParameters, int num_parameter_elements);
    587         virtual void DeleteContext(PvmiMIOSession aSession,
    588                                    PvmiCapabilityContext& aContext);
    589         virtual void setParametersSync(PvmiMIOSession aSession, PvmiKvp* aParameters,
    590                                        int num_elements, PvmiKvp * & aRet_kvp);
    591         virtual PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
    592                 PvmiKvp* aParameters,
    593                 int num_elements,
    594                 PvmiKvp*& aRet_kvp,
    595                 OsclAny* context = NULL);
    596         virtual uint32 getCapabilityMetric(PvmiMIOSession aSession);
    597         virtual PVMFStatus verifyParametersSync(PvmiMIOSession aSession,
    598                                                 PvmiKvp* aParameters,
    599                                                 int num_elements);
    600 
    601         PVMFStatus GetConfigParameter(PvmiKvp*& aParameters, int& aNumParamElements,
    602                                       int32 aIndex, PvmiKvpAttr reqattr);
    603         PVMFStatus VerifyAndSetConfigParameter(int index, PvmiKvp& aParameter, bool set);
    604 
    605 
    606         // From PVInterface
    607         void addRef();
    608         void removeRef();
    609         bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
    610 
    611         // From PVMFDataSourceInitializationExtensionInterface
    612         PVMFStatus SetSourceInitializationData(OSCL_wString& aSourceURL, PVMFFormatType& aSourceFormat, OsclAny* aSourceData);
    613         PVMFStatus SetClientPlayBackClock(PVMFMediaClock* aClientClock);
    614         PVMFStatus SetEstimatedServerClock(PVMFMediaClock* aClientClock);
    615 
    616         // From PVMFTrackSelectionExtensionInterface
    617         PVMFStatus GetMediaPresentationInfo(PVMFMediaPresentationInfo& aInfo);
    618         PVMFStatus SelectTracks(PVMFMediaPresentationInfo& aInfo);
    619 
    620         // From PVMFMetadataExtensionInterface
    621         uint32 GetNumMetadataKeys(char* aQueryKeyString = NULL);
    622         uint32 GetNumMetadataValues(PVMFMetadataList& aKeyList);
    623         uint32 GetNumImotionMetadataValues(PVMFMetadataList& aKeyList);
    624         PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList, uint32 aStartingKeyIndex, int32 aMaxKeyEntries,
    625                                           char* aQueryKeyString = NULL, const OsclAny* aContextData = NULL);
    626         PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId, PVMFMetadataList& aKeyList,
    627                                             Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 aStartingValueIndex, int32 aMaxValueEntries, const OsclAny* aContextData = NULL);
    628         PVMFStatus ReleaseNodeMetadataKeys(PVMFMetadataList& aKeyList, uint32 aStartingKeyIndex, uint32 aEndKeyIndex);
    629         PVMFStatus ReleaseNodeMetadataValues(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, uint32 aStartingValueIndex, uint32 aEndValueIndex);
    630 
    631         // From PvmfDataSourcePlaybackControlInterface
    632         PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId, PVMFTimestamp aTargetNPT, PVMFTimestamp& aActualNPT,
    633                                             PVMFTimestamp& aActualMediaDataTS, bool aSeekToSyncPoint = true, uint32 aStreamID = 0, OsclAny* aContext = NULL);
    634         PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId, PVMFTimestamp aTargetNPT, PVMFTimestamp& aActualNPT,
    635                                               bool aSeekToSyncPoint = true, OsclAny* aContext = NULL);
    636         PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId, PVMFTimestamp aTargetNPT,
    637                                               PVMFTimestamp& aSeekPointBeforeTargetNPT, PVMFTimestamp& aSeekPointAfterTargetNPT,  OsclAny* aContext = NULL, bool aSeekToSyncPoint = true);
    638 
    639         PVMFCommandId SetDataSourceRate(PVMFSessionId aSession, int32 aRate, PVMFTimebase* aTimebase = NULL, OsclAny* aContext = NULL);
    640         PVMFCommandId SetDataSourceDirection(PVMFSessionId aSessionId, int32 aDirection, PVMFTimestamp& aActualNPT,
    641                                              PVMFTimestamp& aActualMediaDataTS, PVMFTimebase* aTimebase, OsclAny* aContext);
    642 
    643         // From PVMFTrackLevelInfoExtensionInterface
    644         PVMFStatus GetAvailableTracks(Oscl_Vector<PVMFTrackInfo, OsclMemAllocator>& aTracks);
    645         PVMFStatus GetTimestampForSampleNumber(PVMFTrackInfo& aTrackInfo, uint32 aSampleNum, PVMFTimestamp& aTimestamp);
    646         PVMFStatus GetSampleNumberForTimestamp(PVMFTrackInfo& aTrackInfo, PVMFTimestamp aTimestamp, uint32& aSampleNum);
    647         PVMFStatus GetNumberOfSyncSamples(PVMFTrackInfo& aTrackInfo, int32& aNumSyncSamples);
    648         PVMFStatus GetSyncSampleInfo(PVMFTrackInfo& aTrackInfo, PVMFSampleNumTSList& aList, uint32 aStartIndex = 0, int32 aMaxEntries = -1);
    649         PVMFStatus GetSyncSampleInfo(PVMFSampleNumTSList& aList, PVMFTrackInfo& aTrackInfo, int32 aTargetTimeInMS, uint32 aHowManySamples = 1);
    650         PVMFStatus GetTimestampForDataPosition(PVMFTrackInfo& aTrackInfo, uint32 aDataPosition, PVMFTimestamp& aTimestamp);
    651         PVMFStatus GetDataPositionForTimestamp(PVMFTrackInfo& aTrackInfo, PVMFTimestamp aTimestamp, uint32& aDataPosition);
    652 
    653 
    654         // From PVMFPortActivityHandler
    655         void HandlePortActivity(const PVMFPortActivity& aActivity);
    656 
    657         // From PVMFCPMStatusObserver
    658         void CPMCommandCompleted(const PVMFCmdResp& aResponse);
    659 
    660         /* From PVMIDatastreamuserInterface */
    661         void PassDatastreamFactory(PVMFDataStreamFactory& aFactory,
    662                                    int32 aFactoryTag,
    663                                    const PvmfMimeString* aFactoryConfig = NULL);
    664         void PassDatastreamReadCapacityObserver(PVMFDataStreamReadCapacityObserver* aObserver);
    665 
    666 
    667         /* From PVMFFormatProgDownloadSupportInterface */
    668         int32 convertSizeToTime(uint32 fileSize, uint32& aNPTInMS);
    669         void setFileSize(const uint32 aFileSize);
    670         void setDownloadProgressInterface(PVMFDownloadProgressInterface*);
    671         void playResumeNotification(bool aDownloadComplete);
    672         void notifyDownloadComplete();
    673 
    674         // From OsclTimer
    675         void TimeoutOccurred(int32 timerID, int32 timeoutInfo);
    676 
    677         /* From PVMFCPMPluginLicenseInterface */
    678         PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
    679                                  OSCL_wString& aContentName,
    680                                  OSCL_wString& aLicenseURL)
    681         {
    682             OSCL_UNUSED_ARG(aSessionId);
    683             OSCL_UNUSED_ARG(aContentName);
    684             OSCL_UNUSED_ARG(aLicenseURL);
    685             //must use Async method.
    686             return PVMFErrNotSupported;
    687         }
    688         PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
    689                                  OSCL_String&  aContentName,
    690                                  OSCL_String&  aLicenseURL)
    691         {
    692             OSCL_UNUSED_ARG(aSessionId);
    693             OSCL_UNUSED_ARG(aContentName);
    694             OSCL_UNUSED_ARG(aLicenseURL);
    695             //must use Async method.
    696             return PVMFErrNotSupported;
    697         }
    698 
    699         PVMFCommandId GetLicense(PVMFSessionId aSessionId,
    700                                  OSCL_wString& aContentName,
    701                                  OsclAny* aData,
    702                                  uint32 aDataSize,
    703                                  int32 aTimeoutMsec,
    704                                  OsclAny* aContextData) ;
    705 
    706         PVMFCommandId GetLicense(PVMFSessionId aSessionId,
    707                                  OSCL_String&  aContentName,
    708                                  OsclAny* aData,
    709                                  uint32 aDataSize,
    710                                  int32 aTimeoutMsec,
    711                                  OsclAny* aContextData);
    712 
    713         PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId
    714                                        , PVMFCommandId aCmdId
    715                                        , OsclAny* aContextData);
    716 
    717         PVMFStatus GetLicenseStatus(
    718             PVMFCPMLicenseStatus& aStatus) ;
    719 
    720         //from PVMFMediaClockStateObserver
    721         void ClockStateUpdated();
    722         void NotificationsInterfaceDestroyed();
    723 
    724     private:
    725         // from OsclTimerObject
    726         void Run();
    727 
    728         //Command processing
    729         PVMFCommandId QueueCommandL(PVMFMP4FFParserNodeCommand& aCmd);
    730         void MoveCmdToCurrentQueue(PVMFMP4FFParserNodeCommand& aCmd);
    731         void MoveCmdToCancelQueue(PVMFMP4FFParserNodeCommand& aCmd);
    732         void ProcessCommand();
    733         void CommandComplete(PVMFMP4FFParserNodeCmdQueue& aCmdQueue, PVMFMP4FFParserNodeCommand& aCmd, PVMFStatus aStatus, OsclAny* aData = NULL, PVUuid* aEventUUID = NULL, int32* aEventCode = NULL);
    734         bool FlushPending();
    735         PVMFMP4FFParserNodeCmdQueue iInputCommands;
    736         PVMFMP4FFParserNodeCmdQueue iCurrentCommand;
    737         PVMFMP4FFParserNodeCmdQueue iCancelCommand;
    738 
    739         // Event reporting
    740         void ReportMP4FFParserErrorEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, PVUuid* aEventUUID = NULL, int32* aEventCode = NULL);
    741         void ReportMP4FFParserInfoEvent(PVMFEventType aEventType, OsclAny* aEventData = NULL, PVUuid* aEventUUID = NULL, int32* aEventCode = NULL);
    742         void ChangeNodeState(TPVMFNodeInterfaceState aNewState);
    743 
    744         // Node command handlers
    745         PVMFStatus DoQueryUuid(PVMFMP4FFParserNodeCommand& aCmd);
    746         PVMFStatus DoQueryInterface(PVMFMP4FFParserNodeCommand& aCmd);
    747         PVMFStatus DoRequestPort(PVMFMP4FFParserNodeCommand& aCmd, PVMFPortInterface*&);
    748         void GetTrackMaxParameters(PVMFFormatType aFormatType, uint32& aMaxDataSize, uint32& aMaxQueueDepth);
    749         PVMFStatus DoReleasePort(PVMFMP4FFParserNodeCommand& aCmd);
    750 
    751         PVMFStatus DoInit(PVMFMP4FFParserNodeCommand& aCmd);
    752         bool ParseMP4File(PVMFMP4FFParserNodeCmdQueue& aCmdQ,
    753                           PVMFMP4FFParserNodeCommand& aCmd);
    754         void PushToAvailableMetadataKeysList(const char* aKeystr, char* aOptionalParam = NULL);
    755         PVMFStatus InitMetaData();
    756         PVMFStatus InitImotionMetaData();
    757         uint32 CountImotionMetaDataKeys();
    758         int32 CountMetaDataKeys();
    759         void CompleteInit(PVMFMP4FFParserNodeCmdQueue& aCmdQ,
    760                           PVMFMP4FFParserNodeCommand& aCmd);
    761         void CompleteCancelAfterInit();
    762 
    763 
    764         PVMFStatus DoPrepare(PVMFMP4FFParserNodeCommand& aCmd);
    765         void CompletePrepare(PVMFStatus aStatus);
    766         PVMFStatus DoStart(PVMFMP4FFParserNodeCommand& aCmd);
    767         PVMFStatus DoStop(PVMFMP4FFParserNodeCommand& aCmd);
    768         PVMFStatus DoFlush(PVMFMP4FFParserNodeCommand& aCmd);
    769         PVMFStatus DoPause(PVMFMP4FFParserNodeCommand& aCmd);
    770 
    771         PVMFStatus DoReset(PVMFMP4FFParserNodeCommand& aCmd);
    772         void CompleteReset(PVMFMP4FFParserNodeCmdQueue& aCmdQ, PVMFMP4FFParserNodeCommand& aCmd);
    773 
    774         PVMFStatus DoCancelAllCommands(PVMFMP4FFParserNodeCommand& aCmd);
    775         PVMFStatus DoCancelCommand(PVMFMP4FFParserNodeCommand& aCmd);
    776         PVMFStatus DoCancelCurrentCommand(PVMFMP4FFParserNodeCommand& aCmd);
    777 
    778         // For metadata extention interface
    779         PVMFStatus DoGetMetadataKeys(PVMFMP4FFParserNodeCommand& aCmd);
    780         PVMFStatus CompleteGetMetadataKeys(PVMFMP4FFParserNodeCommand& aCmd);
    781         PVMFStatus DoGetImotionMetadataValues(PVMFMP4FFParserNodeCommand& aCmd, int32 &numentriesadded);
    782         PVMFStatus DoGetMetadataValues(PVMFMP4FFParserNodeCommand& aCmd);
    783         void CompleteGetMetaDataValues();
    784         int32 AddToValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList, PvmiKvp& aNewValue);
    785         PVMFStatus GetIndexParamValues(const char* aString, uint32& aStartIndex, uint32& aEndIndex);
    786         void DeleteAPICStruct(PvmfApicStruct*& aAPICStruct);
    787         PVMFStatus GetVideoFrameWidth(uint32 aId, int32& aWidth, int32& aDisplayWidth);
    788         PVMFStatus GetVideoFrameHeight(uint32 aId, int32& aHeight, int32& aDisplayHeight);
    789         int32 FindVideoWidth(uint32 aId);
    790         int32 FindVideoHeight(uint32 aId);
    791         int32 FindVideoDisplayWidth(uint32 aId);
    792         int32 FindVideoDisplayHeight(uint32 aId);
    793         PVMFStatus PopulateVideoDimensions(uint32 aId);
    794         uint32 GetNumAudioChannels(uint32 aId);
    795         uint32 GetAudioSampleRate(uint32 aId);
    796         uint32 GetAudioBitsPerSample(uint32 aId);
    797         PVMFStatus FindBestThumbnailKeyFrame(uint32 aId, uint32& aKeyFrameNum);
    798 
    799         // For data source position extension interface
    800         PVMFStatus DoSetDataSourcePosition(PVMFMP4FFParserNodeCommand& aCmd, PVMFStatus &aEventCode, PVUuid &aEventUuid);
    801         PVMFStatus DoQueryDataSourcePosition(PVMFMP4FFParserNodeCommand& aCmd);
    802         PVMFStatus DoSetDataSourceRate(PVMFMP4FFParserNodeCommand& aCmd);
    803 
    804         PVMFStatus DoSetDataSourceDirection(PVMFMP4FFParserNodeCommand& aCmd);
    805 
    806         void HandleTrackState();
    807         bool RetrieveTrackConfigInfo(uint32 aTrackId,
    808                                      PVMFFormatType aFormatType,
    809                                      OsclRefCounterMemFrag &aConfig);
    810         bool RetrieveTrackConfigInfoAndFirstSample(uint32 aTrackId,
    811                 PVMFFormatType aFormatType,
    812                 OsclRefCounterMemFrag &aConfig);
    813         bool RetrieveTrackData(PVMP4FFNodeTrackPortInfo& aTrackPortInfo);
    814         bool SendTrackData(PVMP4FFNodeTrackPortInfo& aTrackPortInfo);
    815         bool GenerateAVCNALGroup(PVMP4FFNodeTrackPortInfo& aTrackPortInfo, OsclSharedPtr<PVMFMediaDataImpl>& aMediaFragGroup);
    816         bool GenerateAACFrameFrags(PVMP4FFNodeTrackPortInfo& aTrackPortInfo, OsclSharedPtr<PVMFMediaDataImpl>& aMediaFragGroup);
    817         bool GetAVCNALLength(OsclBinIStreamBigEndian& stream, uint32& lengthSize, int32& len);
    818         bool UpdateTextSampleEntry(PVMP4FFNodeTrackPortInfo& aTrackPortInfo, uint32 aEntryIndex, PVMFTimedTextMediaData& aTextMediaData);
    819         bool SendEndOfTrackCommand(PVMP4FFNodeTrackPortInfo& aTrackPortInfo);
    820         bool SendBeginOfMediaStreamCommand(PVMP4FFNodeTrackPortInfo& aTrackPortInfo);
    821 
    822         // Port processing
    823         void ProcessPortActivity();
    824         void QueuePortActivity(const PVMFPortActivity& aActivity);
    825         PVMFStatus ProcessIncomingMsg(PVMFPortInterface* aPort);
    826         PVMFStatus ProcessOutgoingMsg(PVMFPortInterface* aPort);
    827         Oscl_Vector<PVMFPortActivity, OsclMemAllocator> iPortActivityQueue;
    828 
    829         friend class PVMFMP4FFParserOutPort;
    830 
    831         PVMFFormatType GetFormatTypeFromMIMEType(PvmfMimeString* aMIMEString);
    832 
    833         void ResetAllTracks();
    834         bool ReleaseAllPorts();
    835         void RemoveAllCommands();
    836         void CleanupFileSource();
    837 
    838         // For comparison with download progress clock
    839         bool checkTrackPosition(PVMP4FFNodeTrackPortInfo& aTrackPortInfo, uint32 numsamples);
    840 
    841         bool GetTrackPortInfoForTrackID(PVMP4FFNodeTrackPortInfo*& aInfo,
    842                                         uint32 aTrackID);
    843 
    844         bool GetTrackPortInfoForPort(PVMP4FFNodeTrackPortInfo*& aInfo,
    845                                      PVMFPortInterface* aPort);
    846 
    847         OSCL_wHeapString<OsclMemAllocator> iFilename;
    848         PVMFFormatType iSourceFormat;
    849         PVMFMediaClock* iClientPlayBackClock;
    850         PVMFMediaClockNotificationsInterface *iClockNotificationsInf;
    851         bool iUseCPMPluginRegistry;
    852         PVMFLocalDataSource iCPMSourceData;
    853         PVMFSourceContextData iSourceContextData;
    854         OsclFileHandle* iFileHandle;
    855         Oscl_FileServer iFileServer;
    856         uint32 iParsingMode;
    857         bool iProtectedFile;
    858         IMpeg4File* iMP4FileHandle;
    859         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
    860         uint32 iMP4ParserNodeMetadataValueCount;
    861         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iCPMMetadataKeys;
    862         Oscl_Vector<PVMP4FFNodeTrackPortInfo, OsclMemAllocator> iNodeTrackPortList;
    863         Oscl_Vector<PVMFTrackInfo, OsclMemAllocator> iSelectedTrackInfoList;
    864         Oscl_Vector<VideoTrackDimensionInfo, OsclMemAllocator> iVideoDimensionInfoVec;
    865 
    866         PVMFMP4FFPortIter* iPortIter;
    867 
    868         // stream id
    869         uint32 iStreamID;
    870 
    871         PVMFNodeCapability iCapability;
    872         PVLogger* iLogger;
    873         PVLogger* iDataPathLogger;
    874         PVLogger* iAVCDataPathLogger;
    875         PVLogger* iClockLogger;
    876         PVLogger* iDiagnosticsLogger;
    877         // Reference counter for extension
    878         uint32 iExtensionRefCount;
    879 
    880         // variables to support download autopause
    881         OsclSharedPtr<PVMFMediaClock> download_progress_clock;
    882         PVMFDownloadProgressInterface* download_progress_interface;
    883         uint32 iDownloadFileSize;
    884         bool autopaused;
    885 
    886         void DataStreamCommandCompleted(const PVMFCmdResp& aResponse);
    887         void DataStreamInformationalEvent(const PVMFAsyncEvent& aEvent);
    888         void DataStreamErrorEvent(const PVMFAsyncEvent& aEvent);
    889 
    890         bool MapMP4ErrorCodeToEventCode(int32 aMP4ErrCode, PVUuid& aEventUUID, int32& aEventCode);
    891 
    892         GAU iGau;
    893 
    894         bool iThumbNailMode;
    895 
    896         // Content Policy Manager related
    897         bool iSourceContextDataValid;
    898         bool iPreviewMode;
    899         PVMFCPM* iCPM;
    900         PVMFSessionId iCPMSessionID;
    901         PVMFCPMContentType iCPMContentType;
    902         PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
    903         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
    904         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
    905         PVInterface* iCPMLicenseInterfacePVI;
    906         PVMFCPMPluginAccessUnitDecryptionInterface* iDecryptionInterface;
    907         PvmiKvp iRequestedUsage;
    908         PvmiKvp iApprovedUsage;
    909         PvmiKvp iAuthorizationDataKvp;
    910         PVMFCPMUsageID iUsageID;
    911         bool oWaitingOnLicense;
    912         bool iPoorlyInterleavedContentEventSent;
    913 
    914         PVMFCommandId iCPMInitCmdId;
    915         PVMFCommandId iCPMOpenSessionCmdId;
    916         PVMFCommandId iCPMRegisterContentCmdId;
    917         PVMFCommandId iCPMRequestUsageId;
    918         PVMFCommandId iCPMUsageCompleteCmdId;
    919         PVMFCommandId iCPMCloseSessionCmdId;
    920         PVMFCommandId iCPMResetCmdId;
    921         PVMFCommandId iCPMGetMetaDataKeysCmdId;
    922         PVMFCommandId iCPMGetMetaDataValuesCmdId;
    923         PVMFCommandId iCPMGetLicenseInterfaceCmdId;
    924         PVMFCommandId iCPMGetLicenseCmdId;
    925         PVMFCommandId iCPMCancelGetLicenseCmdId;
    926         void InitCPM();
    927         void OpenCPMSession();
    928         void CPMRegisterContent();
    929         bool GetCPMContentAccessFactory();
    930         void GetCPMContentType();
    931         bool GetCPMMetaDataExtensionInterface();
    932         void GetCPMLicenseInterface();
    933         void RequestUsage(PVMP4FFNodeTrackOMA2DRMInfo* aInfo);
    934         void SendUsageComplete();
    935         void CloseCPMSession();
    936         void ResetCPM();
    937         void GetCPMMetaDataKeys();
    938         PVMFStatus CheckCPMCommandCompleteStatus(PVMFCommandId, PVMFStatus);
    939         PVMFStatus iCPMRequestUsageCommandStatus;
    940 
    941         PVMFStatus DoGetLicense(PVMFMP4FFParserNodeCommand& aCmd,
    942                                 bool aWideCharVersion = false);
    943         PVMFStatus DoCancelGetLicense(PVMFMP4FFParserNodeCommand& aCmd);
    944         void CompleteGetLicense();
    945 
    946         void PopulateOMA1DRMInfo();
    947         /*
    948          * OMA2 DRM Related Methods
    949          */
    950         Oscl_Vector<PVMP4FFNodeTrackOMA2DRMInfo, OsclMemAllocator> iOMA2DRMInfoVec;
    951         PVMP4FFNodeTrackOMA2DRMInfo* LookUpOMA2TrackInfoForTrack(uint32 aTrackID);
    952         PVMFStatus InitOMA2DRMInfo();
    953         void PopulateOMA2DRMInfo(PVMP4FFNodeTrackOMA2DRMInfo* aInfo);
    954         PVMFStatus CheckForOMA2AuthorizationComplete(PVMP4FFNodeTrackOMA2DRMInfo*& aInfo);
    955         void OMA2TrackAuthorizationComplete();
    956         bool CheckForOMA2UsageApproval();
    957         void ResetOMA2Flags();
    958         uint8* iOMA2DecryptionBuffer;
    959 
    960         PVMFStatus GetFileOffsetForAutoResume(uint32& aOffset, bool aPortsAvailable = true);
    961         PVMFStatus GetFileOffsetForAutoResume(uint32& aOffset, PVMP4FFNodeTrackPortInfo* aInfo);
    962 
    963         PVMFStatus CheckForUnderFlow(PVMP4FFNodeTrackPortInfo* aInfo);
    964 
    965         void getLanguageCode(uint16 langcode, int8 *LangCode);
    966         void getBrand(uint32 langcode, char *LangCode);
    967 
    968         PVMFStatus CheckForMP4HeaderAvailability();
    969         int32 CreateErrorInfoMsg(PVMFBasicErrorInfoMessage** aErrorMsg, PVUuid aEventUUID, int32 aEventCode);
    970         void CreateDurationInfoMsg(uint32 adurationms);
    971         PVMFStatus PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aVecPtr, PvmiKvp& aKvpVal);
    972         PVMFStatus CreateNewArray(uint32** aTrackidList, uint32 aNumTracks);
    973         PVMFStatus PushValueToList(Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> &aRefMetadataKeys,
    974                                    PVMFMetadataList *&aKeyListPtr,
    975                                    uint32 aLcv);
    976         PVMIDataStreamSyncInterface* iDataStreamInterface;
    977         PVMFDataStreamFactory* iDataStreamFactory;
    978         PVMFDataStreamReadCapacityObserver* iDataStreamReadCapacityObserver;
    979         PvmiDataStreamSession iDataStreamSessionID;
    980         PvmiDataStreamCommandId iRequestReadCapacityNotificationID;
    981         uint32 iMP4HeaderSize;
    982         bool iDownloadComplete;
    983         bool iProgressivelyDownlodable;
    984         uint32 iLastNPTCalcInConvertSizeToTime;
    985         uint32 iFileSizeLastConvertedToTime;
    986         bool iFastTrackSession;
    987 
    988         /* External PseudoStreaming related */
    989         bool iExternalDownload;
    990 
    991         bool iUnderFlowEventReported;
    992         PVMFStatus ReportUnderFlow();
    993         OsclTimer<OsclMemAllocator> *iUnderFlowCheckTimer;
    994 
    995         /* bitstream logging */
    996         void LogMediaData(PVMFSharedMediaDataPtr data,
    997                           PVMFPortInterface* aPort);
    998         bool iPortDataLog;
    999         char iLogFileIndex;
   1000         OSCL_HeapString<OsclMemAllocator> portLogPath;
   1001 
   1002         uint32 minTime;
   1003         uint32 avgTime;
   1004         uint32 maxTime;
   1005         uint32 sumTime;
   1006         bool iDiagnosticsLogged;
   1007         void LogDiagnostics();
   1008         uint32 iTimeTakenInReadMP4File;
   1009         bool iBackwardReposFlag; /* To avoid backwardlooping :: A flag to remember backward repositioning */
   1010         bool iForwardReposFlag;
   1011         uint32 iCurPos;
   1012         bool iEOTForTextSentToMIO;
   1013 
   1014         bool iSetTextSampleDurationZero;
   1015 
   1016         /* To take into account if we get negative TS for text track after repositionings*/
   1017         bool iTextInvalidTSAfterReposition;
   1018 
   1019         uint32 iDelayAddToNextTextSample;
   1020 
   1021         uint32 iCacheSize;
   1022         uint32 iAsyncReadBuffSize;
   1023         bool iPVLoggerEnableFlag;
   1024         bool iPVLoggerStateEnableFlag;
   1025         uint32 iNativeAccessMode;
   1026 
   1027         BaseKeys_SelectionType iBaseKey;
   1028         uint32 iJitterBufferDurationInMs;
   1029         bool iDataStreamRequestPending;
   1030         bool iCPMSequenceInProgress;
   1031         bool oIsAACFramesFragmented;
   1032 
   1033         int32 iPlayBackDirection;
   1034         int32 iStartForNextTSSearch;
   1035         int32 iPrevSampleTS;
   1036         bool iParseAudioDuringFF;
   1037         bool iParseAudioDuringREW;
   1038         bool iParseVideoOnly;
   1039         int32 iDataRate;
   1040 
   1041         int32 minFileOffsetTrackID;
   1042 };
   1043 
   1044 
   1045 class PVMFMP4FFPortIter : public PVMFPortIter
   1046 {
   1047     public:
   1048         PVMFMP4FFPortIter(Oscl_Vector<PVMP4FFNodeTrackPortInfo, OsclMemAllocator>& aTrackList)
   1049         {
   1050             iIndex = 0;
   1051             iTrackList = &aTrackList;
   1052         };
   1053 
   1054         virtual ~PVMFMP4FFPortIter() {};
   1055 
   1056         uint16 NumPorts()
   1057         {
   1058             if (iTrackList->size() < 0xFFFF)
   1059             {
   1060                 return (uint16)(iTrackList->size());
   1061             }
   1062             else
   1063             {
   1064                 return 0xFFFF;
   1065             }
   1066         };
   1067 
   1068         PVMFPortInterface* GetNext()
   1069         {
   1070             if (iIndex < iTrackList->size())
   1071             {
   1072                 PVMFPortInterface* portiface = (*iTrackList)[iIndex].iPortInterface;
   1073                 ++iIndex;
   1074                 return portiface;
   1075             }
   1076             else
   1077             {
   1078                 return NULL;
   1079             }
   1080         };
   1081 
   1082         void Reset()
   1083         {
   1084             iIndex = 0;
   1085         };
   1086 
   1087     private:
   1088         Oscl_Vector<PVMP4FFNodeTrackPortInfo, OsclMemAllocator>* iTrackList;
   1089         uint32 iIndex;
   1090 };
   1091 
   1092 #endif // PVMF_MP4FFPARSER_NODE_H_INCLUDED
   1093 
   1094