Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 #ifndef PVMF_SM_FSP_BASE_IMPL_H
     19 #define PVMF_SM_FSP_BASE_IMPL_H
     20 
     21 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
     22 #include "pvmf_node_interface.h"
     23 #endif
     24 
     25 #ifndef PVMF_NODE_UTILS_H_INCLUDED
     26 #include "pvmf_node_utils.h"
     27 #endif
     28 
     29 #ifndef PVMF_DATA_SOURCE_INIT_EXTENSION_H_INCLUDED
     30 #include "pvmf_data_source_init_extension.h"
     31 #endif
     32 
     33 #ifndef PVMF_TRACK_SELECTION_EXTENSION_H_INCLUDED
     34 #include "pvmf_track_selection_extension.h"
     35 #endif
     36 
     37 #ifndef PVMF_DATA_SOURCE_PLAYBACK_CONTROL_H_INCLUDED
     38 #include "pvmf_data_source_playback_control.h"
     39 #endif
     40 
     41 #ifndef PVMF_META_DATA_EXTENSION_H_INCLUDED
     42 #include "pvmf_meta_data_extension.h"
     43 #endif
     44 
     45 #ifndef PVMI_CONFIG_AND_CAPABILITY_H_INCLUDED
     46 #include "pvmi_config_and_capability.h"
     47 #endif
     48 
     49 #ifndef PVMF_CPMPLUGIN_LICENSE_INTERFACE_H_INCLUDED
     50 #include "pvmf_cpmplugin_license_interface.h"
     51 #endif
     52 
     53 #ifndef CPM_H_INCLUDED
     54 #include "cpm.h"
     55 #endif
     56 
     57 #ifndef PVMF_STREAMING_DATA_SOURCE_H_INCLUDED
     58 #include "pvmf_streaming_data_source.h"
     59 #endif
     60 
     61 #ifndef PVMF_SOURCE_CONTEXT_DATA_H_INCLUDED
     62 #include "pvmf_source_context_data.h"
     63 #endif
     64 
     65 #ifndef PVMF_SM_FSP_BASE_CMDS_H_INCLUDED
     66 #include "pvmf_sm_fsp_base_cmds.h"
     67 #endif
     68 
     69 #ifndef PVMF_SM_FSP_BASE_TYPES_H_INCLUDED
     70 #include "pvmf_sm_fsp_base_types.h"
     71 #endif
     72 
     73 class JitterBufferFactory;
     74 
     75 
     76 #ifndef PVLOGGER_H_INCLUDED
     77 #include "pvlogger.h"
     78 #endif
     79 
     80 #ifndef PVMF_SM_FSP_BASE_METADATA_H_INCLUDED
     81 #include "pvmf_sm_fsp_base_metadata.h"
     82 #endif
     83 
     84 #define PVMF_SM_FSP_BASE_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_STACK_TRACE,m);
     85 #define PVMF_SM_FSP_BASE_LOGDEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_DEBUG,m);
     86 #define PVMF_SM_FSP_BASE_LOGERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iSMBaseLogger,PVLOGMSG_ERR,m);
     87 #define PVMF_SM_FSP_BASE_LOGCMDSEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iCommandSeqLogger,PVLOGMSG_STACK_TRACE,m);
     88 
     89 #define PVMF_SM_ERRHANDLER_LOGSTACKTRACE(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
     90 #define PVMF_SM_ERRHANDLER_LOGDEBUG(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_DEBUG,m);
     91 #define PVMF_SM_ERRHANDLER_LOGERR(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_ERR,m);
     92 #define PVMF_SM_ERRHANDLER_LOGCMDSEQ(m) PVLOGGER_LOGMSG(PVLOGMSG_INST_LLDBG,iLogger,PVLOGMSG_STACK_TRACE,m);
     93 
     94 class PVMFSMSessionMetaDataInfo;
     95 class PVMFSMFSPChildNodeErrorHandler;
     96 #define PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE 40
     97 
     98 class PVMFSMFSPBaseNode : public PVMFNodeInterface,
     99         public OsclActiveObject,
    100         public PvmiCapabilityAndConfig,
    101         public PVMFDataSourceInitializationExtensionInterface,
    102         public PVMFTrackSelectionExtensionInterface,
    103         public PvmfDataSourcePlaybackControlInterface,
    104         public PVMFMetadataExtensionInterface,
    105         public PVMFCPMPluginLicenseInterface,
    106         public PVMFNodeErrorEventObserver,
    107         public PVMFNodeInfoEventObserver,
    108         public PVMFNodeCmdStatusObserver,
    109         public PVMFCPMStatusObserver
    110 {
    111         friend class PVMFSMFSPChildNodeErrorHandler;
    112     public:
    113         OSCL_IMPORT_REF virtual ~PVMFSMFSPBaseNode();
    114 
    115         /* From PVMFNodeInterface */
    116         OSCL_IMPORT_REF PVMFStatus ThreadLogon();
    117         OSCL_IMPORT_REF PVMFStatus ThreadLogoff();
    118 
    119         //Added overload of Connect
    120         //Connects PVMFSMFSPBaseNode to the StreamingManagerNode
    121         OSCL_IMPORT_REF PVMFSessionId Connect(const PVMFNodeSession &iUpstreamSession);
    122 
    123 
    124         OSCL_IMPORT_REF PVMFStatus GetCapability(PVMFNodeCapability& aNodeCapability);
    125         OSCL_IMPORT_REF PVMFPortIter* GetPorts(const PVMFPortFilter* aFilter = NULL);
    126 
    127         //Deprecated.Will cause assertion failure
    128         OSCL_IMPORT_REF PVMFCommandId QueryUUID(PVMFSessionId,
    129                                                 const PvmfMimeString& aMimeType,
    130                                                 Oscl_Vector< PVUuid, OsclMemAllocator >& aUuids,
    131                                                 bool aExactUuidsOnly = false,
    132                                                 const OsclAny* aContext = NULL);
    133 
    134         //Synchronous add-ons only for quering PVMFDataSourceInitializationExtensionInterface
    135         virtual bool queryInterface(const PVUuid& uuid, PVInterface*& iface);
    136         OSCL_IMPORT_REF PVMFCommandId QueryInterface(PVMFSessionId, const PVUuid& aUuid,
    137                 PVInterface*& aInterfacePtr,
    138                 const OsclAny* aContext = NULL);
    139 
    140         OSCL_IMPORT_REF PVMFCommandId RequestPort(PVMFSessionId,
    141                 int32 aPortTag,
    142                 const PvmfMimeString* aPortConfig = NULL,
    143                 const OsclAny* aContext = NULL);
    144         OSCL_IMPORT_REF PVMFCommandId ReleasePort(PVMFSessionId,
    145                 PVMFPortInterface& aPort,
    146                 const OsclAny* aContext = NULL);
    147 
    148         OSCL_IMPORT_REF PVMFCommandId Init(PVMFSessionId,
    149                                            const OsclAny* aContext = NULL);
    150         OSCL_IMPORT_REF PVMFCommandId Prepare(PVMFSessionId,
    151                                               const OsclAny* aContext = NULL);
    152         OSCL_IMPORT_REF PVMFCommandId Start(PVMFSessionId,
    153                                             const OsclAny* aContext = NULL);
    154         OSCL_IMPORT_REF PVMFCommandId Stop(PVMFSessionId,
    155                                            const OsclAny* aContext = NULL);
    156         OSCL_IMPORT_REF PVMFCommandId Flush(PVMFSessionId,
    157                                             const OsclAny* aContext = NULL);
    158         OSCL_IMPORT_REF PVMFCommandId Pause(PVMFSessionId,
    159                                             const OsclAny* aContext = NULL);
    160         OSCL_IMPORT_REF PVMFCommandId Reset(PVMFSessionId,
    161                                             const OsclAny* aContext = NULL);
    162         OSCL_IMPORT_REF PVMFCommandId CancelAllCommands(PVMFSessionId,
    163                 const OsclAny* aContextData = NULL);
    164         OSCL_IMPORT_REF PVMFCommandId CancelCommand(PVMFSessionId,
    165                 PVMFCommandId aCmdId,
    166                 const OsclAny* aContextData = NULL);
    167 
    168         /* From PVMFPortActivityHandler */
    169         void HandlePortActivity(const PVMFPortActivity& aActivity);
    170 
    171         /* From PvmiCapabilityAndConfig */
    172         virtual PVMFCommandId setParametersAsync(PvmiMIOSession aSession,
    173                 PvmiKvp* aParameters,
    174                 int num_elements,
    175                 PvmiKvp*& aRet_kvp,
    176                 OsclAny* context = NULL);
    177 
    178         //Pure virtual(s) from following classes should be implemented in feature specific derived classes
    179         //(i)    PVMFDataSourceInitializationExtensionInterface
    180         //(ii)   PVMFTrackSelectionExtensionInterface
    181 
    182         /* From PvmfDataSourcePlaybackControlInterface */
    183         virtual PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
    184                 PVMFTimestamp aTargetNPT,
    185                 PVMFTimestamp& aActualNPT,
    186                 PVMFTimestamp& aActualMediaDataTS,
    187                 bool aSeekToSyncPoint = true,
    188                 uint32 aStreamID = 0,
    189                 OsclAny* aContext = NULL);
    190 
    191         virtual PVMFCommandId SetDataSourcePosition(PVMFSessionId aSessionId,
    192                 PVMFDataSourcePositionParams& aPVMFDataSourcePositionParams,
    193                 OsclAny* aContext = NULL);
    194 
    195         virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
    196                 PVMFTimestamp aTargetNPT,
    197                 PVMFTimestamp& aActualNPT,
    198                 bool aSeekToSyncPoint = true,
    199                 OsclAny* aContext = NULL);
    200         virtual PVMFCommandId QueryDataSourcePosition(PVMFSessionId aSessionId,
    201                 PVMFTimestamp aTargetNPT,
    202                 PVMFTimestamp& aSyncBeforeTargetNPT,
    203                 PVMFTimestamp& aSyncAfterTargetNPT,
    204                 OsclAny* aContext = NULL,
    205                 bool aSeekToSyncPoint = true);
    206         virtual PVMFCommandId SetDataSourceRate(PVMFSessionId aSessionId,
    207                                                 int32 aRate,
    208                                                 PVMFTimebase* aTimebase = NULL,
    209                                                 OsclAny* aContext = NULL);
    210         //PvmfDataSourcePlaybackControlInterface::ComputeSkipTimeStamp is not supported
    211         //in all streaming formats. So not overriding
    212         //the base implementataion of returning PVMFErrNotSupported. FSP plugins can override
    213         //if they so choose.
    214 
    215         /* From PVMFMetadataExtensionInterface */
    216         virtual uint32 GetNumMetadataKeysBase(char* aQueryKeyString = NULL);
    217         virtual uint32 GetNumMetadataValuesBase(PVMFMetadataList& aKeyList);
    218         virtual PVMFCommandId GetNodeMetadataKeys(PVMFSessionId aSessionId,
    219                 PVMFMetadataList& aKeyList,
    220                 uint32 aStartingKeyIndex,
    221                 int32 aMaxKeyEntries = -1,
    222                 char* aQueryKeyString = NULL,
    223                 const OsclAny* aContextData = NULL);
    224         virtual PVMFCommandId GetNodeMetadataValues(PVMFSessionId aSessionId,
    225                 PVMFMetadataList& aKeyList,
    226                 Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
    227                 uint32 aStartingValueIndex,
    228                 int32 aMaxValueEntries = -1,
    229                 const OsclAny* aContextData = NULL);
    230         PVMFStatus ReleaseNodeMetadataKeysBase(PVMFMetadataList& aKeyList,
    231                                                uint32 aStartingKeyIndex,
    232                                                uint32 aEndKeyIndex);
    233         PVMFStatus ReleaseNodeMetadataValuesBase(Oscl_Vector<PvmiKvp, OsclMemAllocator>& aValueList,
    234                 uint32 aStartingValueIndex,
    235                 uint32 aEndValueIndex);
    236 
    237         /* From PVMFCPMPluginLicenseInterface */
    238         virtual PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
    239                                          OSCL_wString& aContentName,
    240                                          OSCL_wString& aLicenseURL);
    241         virtual PVMFStatus GetLicenseURL(PVMFSessionId aSessionId,
    242                                          OSCL_String&  aContentName,
    243                                          OSCL_String&  aLicenseURL);
    244         virtual PVMFCommandId GetLicense(PVMFSessionId aSessionId
    245                                          , OSCL_wString& aContentName
    246                                          , OsclAny* aLicenseData = NULL
    247                                                                    , uint32 aDataSize = 0
    248                                                                                         , int32 aTimeoutMsec = (-1)
    249                                                                                                                , OsclAny* aContext = NULL);
    250         virtual PVMFCommandId GetLicense(PVMFSessionId aSessionId
    251                                          , OSCL_String&  aContentName
    252                                          , OsclAny* aLicenseData = NULL
    253                                                                    , uint32 aDataSize = 0
    254                                                                                         , int32 aTimeoutMsec = (-1)
    255                                                                                                                , OsclAny* aContext = NULL);
    256         virtual PVMFCommandId CancelGetLicense(PVMFSessionId aSessionId
    257                                                , PVMFCommandId aCmdId
    258                                                , OsclAny* aContext = NULL);
    259         virtual PVMFStatus GetLicenseStatus(PVMFCPMLicenseStatus& aStatus);
    260 
    261         /* From PVMFNodeErrorEventObserver */
    262         virtual void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
    263 
    264         //Pure virtual(s) from following classes should be implemented in feature specific derived classes
    265         //(i)    PVMFNodeInfoEventObserver
    266         //(ii)   PVMFNodeCmdStatusObserver
    267 
    268         //For streaming of protected content PVMFCPM plugin is required.
    269         //Response of async commands executed on PVMFCPM will be notified by callback to func CPMCommandCompleted
    270         virtual void CPMCommandCompleted(const PVMFCmdResp& aResponse);
    271     protected:
    272         PVMFSMFSPBaseNode(int32 aPriority);
    273         //Second Phase ctor for allocating mem on heap
    274         void Construct();
    275 
    276         //Pure virtuals to be implemented in the derived classes
    277         virtual bool ProcessCommand(PVMFSMFSPBaseNodeCommand&) = 0; //FSP concrete implementation need to implement it.
    278         virtual bool IsFSPInternalCmd(PVMFCommandId aId) = 0;
    279         virtual void PopulateDRMInfo() = 0;
    280         virtual bool RequestUsageComplete() = 0;
    281 
    282         //For processing command Queues
    283         void MoveCmdToCurrentQueue(PVMFSMFSPBaseNodeCommand& aCmd);
    284         void MoveCmdToCancelQueue(PVMFSMFSPBaseNodeCommand& aCmd);
    285         void MoveErrHandlingCmdToCurErrHandlingQ(PVMFSMFSPBaseNodeCommand& aCmd);
    286 
    287         virtual PVMFCommandId QueueCommandL(PVMFSMFSPBaseNodeCommand& aCmd);
    288         PVMFCommandId QueueErrHandlingCommandL(PVMFSMFSPBaseNodeCommand& aCmd);
    289 
    290         //Functions for reporting error event, info event and command completion
    291         virtual void CommandComplete(PVMFFSPNodeCmdQ&,
    292                                      PVMFSMFSPBaseNodeCommand&,
    293                                      PVMFStatus,
    294                                      OsclAny* aData = NULL,
    295                                      PVUuid* aEventUUID = NULL,
    296                                      int32* aEventCode = NULL,
    297                                      PVInterface* aExtMsg = NULL,
    298                                      uint32 aEventDataLen = 0);
    299 
    300         void ReportErrorEvent(PVMFEventType aEventType,
    301                               OsclAny* aEventData = NULL,
    302                               PVUuid* aEventUUID = NULL,
    303                               int32* aEventCode = NULL);
    304         void ReportInfoEvent(PVMFEventType aEventType,
    305                              OsclAny* aEventData = NULL,
    306                              PVUuid* aEventUUID = NULL,
    307                              int32* aEventCode = NULL);
    308 
    309         //Utiliy funcions for internal commands handling
    310         PVMFSMFSPCommandContext* RequestNewInternalCmd();
    311         virtual void InternalCommandComplete(PVMFFSPNodeCmdQ&,
    312                                              PVMFSMFSPBaseNodeCommand&,
    313                                              PVMFStatus,
    314                                              OsclAny* aData = NULL,
    315                                              PVUuid* aEventUUID = NULL,
    316                                              int32* aEventCode = NULL,
    317                                              PVInterface* aExtMsg = NULL);
    318         void ResetNodeContainerCmdState();
    319 
    320         //Utility funct that can be called by derived class to populate available keys based on iMetaDataInfo
    321         void PopulateAvailableMetadataKeys();
    322 
    323         //PVMFNodeInterface
    324         //To process Cancel command & CancelAll command
    325         /**
    326         * Assumption: When this function is called, cancel all command is present in the input Q.
    327         *             Cancellion of the API's will be attempted till the point CancelAllCommand is issued.
    328         *             No attempt will be made to cancel any of the async command that are queued after
    329         *             making call to CancelAllCommand.
    330         * Command completion status values:
    331         *             PVMFErrNoMemory, PVMFSuccess, PVMFFailure
    332         */
    333         virtual void DoCancelAllCommands(PVMFSMFSPBaseNodeCommand&);
    334         void DoCancelAllPendingCommands(PVMFSMFSPBaseNodeCommand& aCmd);
    335         void DoResetDueToErr(PVMFSMFSPBaseNodeCommand& aCmd);
    336 
    337         /**
    338         * Assumption: When this function is called, cancel all command is present in the input Q.
    339         *             Cancellion of the API's will be attempted till the point CancelAllCommand is issued.
    340         *             No attempt will be made to cancel any of the async command that are queued after
    341         *             making call to CancelAllCommand.
    342         * Command completion status values:
    343         *             PVMFErrNoMemory, PVMFSuccess, PVMFFailure
    344         */
    345         virtual void DoCancelCommand(PVMFSMFSPBaseNodeCommand&);
    346 
    347         //Functions used to check if cancelcommand/cancelallcommand is complete
    348         virtual void CompleteChildNodesCmdCancellation();
    349         virtual bool CheckChildrenNodesCancelAll();
    350 
    351         //To process Reset command
    352         virtual void DoReset(PVMFSMFSPBaseNodeCommand&);
    353         virtual void CompleteReset();
    354         virtual bool CheckChildrenNodesReset();
    355         void CompleteResetDueToErr();
    356 
    357         //To process Flush command
    358         virtual void DoFlush(PVMFSMFSPBaseNodeCommand&);
    359         virtual void CompleteFlush();
    360         virtual bool CheckChildrenNodesFlush();
    361         virtual bool FlushPending();
    362 
    363         //PVMFMetadataExtensionInterface
    364         PVMFStatus DoGetMetadataKeysBase(PVMFSMFSPBaseNodeCommand& aCmd);
    365         PVMFStatus CompleteGetMetadataKeys(PVMFSMFSPBaseNodeCommand& aCmd);
    366         PVMFStatus DoGetMetadataValuesBase(PVMFSMFSPBaseNodeCommand& aCmd);
    367 
    368 
    369         PVMFStatus DoGetLicense(PVMFSMFSPBaseNodeCommand& aCmd,
    370                                 bool aWideCharVersion = false);
    371         void DoCancelGetLicense(PVMFSMFSPBaseNodeCommand& aCmd);
    372 
    373         void CompleteGetLicense();
    374 
    375         //CPM related functions
    376         void InitCPM();
    377         void OpenCPMSession();
    378         void CPMRegisterContent();
    379         bool GetCPMContentAccessFactory();
    380         bool GetCPMMetaDataExtensionInterface();
    381         void GetCPMLicenseInterface();
    382         void GetCPMCapConfigInterface();
    383         bool SetCPMKvps();
    384         void RequestUsage();
    385         void SendUsageComplete();
    386         void CloseCPMSession();
    387         void ResetCPM();
    388         void GetCPMMetaDataKeys();
    389         void GetCPMMetaDataValues();
    390         void CompleteGetMetaDataValues();
    391         void CompleteDRMInit();
    392 
    393         PVMFStatus CheckCPMCommandCompleteStatus(PVMFCommandId aID, PVMFStatus aStatus);
    394 
    395         void GetActualMediaTSAfterSeek();
    396         virtual bool IsFatalErrorEvent(const PVMFEventType& event);
    397         PVMFSMFSPChildNodeContainer* getChildNodeContainer(int32 tag);
    398         virtual void ResetNodeParams(bool aReleaseMemmory = true);
    399 
    400         uint32  iNoOfValuesIteratedForValueVect;
    401         uint32  iNoOfValuesPushedInValueVect;
    402 
    403         PVMFNodeCapability iCapability;
    404 
    405         bool iRepositioning;
    406         PVMFTimestamp iRepositionRequestedStartNPTInMS;
    407         PVMFTimestamp iActualRepositionStartNPTInMS;
    408         PVMFTimestamp* iActualRepositionStartNPTInMSPtr;
    409         PVMFTimestamp iActualMediaDataTS;
    410         PVMFTimestamp* iActualMediaDataTSPtr;
    411         bool iJumpToIFrame;
    412 
    413 
    414         /* Session start & stop times */
    415         uint32 iSessionStartTime;
    416         uint32 iSessionStopTime;
    417         bool   iSessionStopTimeAvailable;
    418         bool   iSessionSeekAvailable;
    419 
    420         bool iPlaylistPlayInProgress;
    421 
    422         PVMFDataSourcePositionParams* iPVMFDataSourcePositionParamsPtr;
    423         uint32 iStreamID;
    424         bool iPlayListRepositioning;
    425         bool iPlayListRepositioningSupported;
    426         bool iGraphConstructComplete;
    427         bool iGraphConnectComplete;
    428         uint32 iNumRequestPortsPending;
    429         uint32 iTotalNumRequestPortsComplete;
    430         //Filled on completion of init
    431         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iAvailableMetadataKeys;
    432         Oscl_Vector<OSCL_HeapString<OsclMemAllocator>, OsclMemAllocator> iCPMMetadataKeys;
    433         PVMFSMSessionMetaDataInfo* iMetaDataInfo;
    434 
    435         PVMFStatus GetIndexParamValues(char* aString, uint32& aStartIndex, uint32& aEndIndex);
    436         PVMFStatus GetMaxSizeValue(char* aString, uint32& aMaxSize);
    437         PVMFStatus GetTruncateFlagValue(char* aString, uint32& aTruncateFlag);
    438 
    439         JitterBufferFactory* iJBFactory;
    440 
    441         //CPM related
    442         bool iPreviewMode;
    443         bool iUseCPMPluginRegistry;
    444         bool iDRMResetPending;
    445         bool iCPMInitPending;
    446         uint32 maxPacketSize;
    447         uint32 iPVMFStreamingManagerNodeMetadataValueCount;
    448         PVMFStreamingDataSource iCPMSourceData;
    449         PVMFSourceContextData iSourceContextData;
    450         bool iSourceContextDataValid;
    451         PVMFCPM* iCPM;
    452         PVMFSessionId iCPMSessionID;
    453         PVMFCPMContentType iCPMContentType;
    454         PVMFCPMPluginAccessInterfaceFactory* iCPMContentAccessFactory;
    455         PVMFCPMPluginAccessUnitDecryptionInterface* iDecryptionInterface;
    456         PVMFCPMPluginLicenseInterface* iCPMLicenseInterface;
    457         PVInterface* iCPMLicenseInterfacePVI;
    458         PvmiCapabilityAndConfig* iCPMCapConfigInterface;
    459         PVInterface* iCPMCapConfigInterfacePVI;
    460         PVMFSMNodeKVPStore iCPMKvpStore;
    461         PvmiKvp iRequestedUsage;
    462         PvmiKvp iApprovedUsage;
    463         PvmiKvp iAuthorizationDataKvp;
    464         PVMFCPMUsageID iUsageID;
    465         PVMFCommandId iCPMInitCmdId;
    466         PVMFCommandId iCPMOpenSessionCmdId;
    467         PVMFCommandId iCPMRegisterContentCmdId;
    468         PVMFCommandId iCPMRequestUsageId;
    469         PVMFCommandId iCPMUsageCompleteCmdId;
    470         PVMFCommandId iCPMCloseSessionCmdId;
    471         PVMFCommandId iCPMResetCmdId;
    472         PVMFCommandId iCPMGetMetaDataKeysCmdId;
    473         PVMFCommandId iCPMGetMetaDataValuesCmdId;
    474         PVMFCommandId iCPMGetLicenseInterfaceCmdId;
    475         PVMFCommandId iCPMGetLicenseCmdId;
    476         PVMFCommandId iCPMGetCapConfigCmdId;
    477         PVMFCommandId iCPMCancelGetLicenseCmdId;
    478         PVMFStatus iCPMRequestUsageCommandStatus;
    479 
    480         PVMFFSPNodeCmdQ iInputCommands;
    481         PVMFFSPNodeCmdQ iCurrentCommand;
    482         PVMFFSPNodeCmdQ iCancelCommand;
    483         PVMFFSPNodeCmdQ iErrHandlingCommandQ;
    484         PVMFFSPNodeCmdQ iCurrErrHandlingCommand;
    485 
    486         PVMFSMFSPCommandContext iInternalCmdPool[PVMF_STREAMING_MANAGER_INTERNAL_CMDQ_SIZE];
    487 
    488         PVMFSMFSPChildNodeContainerVector  iFSPChildNodeContainerVec;
    489         PVMFSMFSPSessionSourceInfo* iSessionSourceInfo;
    490 
    491         PVLogger *iCommandSeqLogger;
    492         PVLogger *iLogger;
    493         PVLogger * iSMBaseLogger;
    494 
    495         //For Error handling
    496         void HandleError(const PVMFCmdResp& aResponse);
    497         void ErrHandlingComplete(const PVMFSMFSPBaseNodeCommand* aErroneousCmd = NULL);
    498 
    499         //For pushing data to vect
    500         PVMFStatus PushKeyToMetadataList(PVMFMetadataList* aMetaDataListPtr, const OSCL_HeapString<OsclMemAllocator> & aKey)const;
    501         PVMFStatus PushKVPToMetadataValueList(Oscl_Vector<PvmiKvp, OsclMemAllocator>* aValueList, const PvmiKvp& aKVP)const;
    502         PVMFStatus SetCPMKvp(PvmiKvp& aKVP);
    503         void CleanUp();
    504         uint8* GetMemoryChunk(OsclMemAllocDestructDealloc<uint8>& aAllocator, const uint32 aChunkSize)
    505         {
    506             int32 leaveCode = 0;
    507             uint8* memChunk = NULL;
    508             OSCL_TRY(leaveCode,
    509                      memChunk = OSCL_STATIC_CAST(uint8*, aAllocator.ALLOCATE(aChunkSize)));
    510             if (leaveCode != OsclErrNone)
    511             {
    512                 PVMF_SM_FSP_BASE_LOGERR((0, "PVMFSMFSPBaseNode::GetMemoryChunk - Error Memory Allocation failed"));
    513             }
    514             return memChunk;
    515         }
    516 
    517         bool SupressInfoEvent();
    518 
    519 
    520     private:
    521         PVMFSMFSPChildNodeErrorHandler* iChildNodeErrHandler;
    522         OSCL_IMPORT_REF PVMFSessionId Connect(const PVMFNodeSessionInfo &aSessionInfo);
    523         /* From OsclActiveObject */
    524         void Run();
    525         void DoCancel();
    526 
    527         void CleanupCPMdata();
    528         void CreateCommandQueues();
    529         virtual bool IsInternalCmd(PVMFCommandId aId);
    530 
    531         void ResetCPMParams(bool aReleaseMem = true);
    532         bool ErrorHandlingRequired(PVMFStatus aStatus);
    533 
    534         //CPM related
    535         PVMFMetadataExtensionInterface* iCPMMetaDataExtensionInterface;
    536 };
    537 
    538 //This class does error handling only for the errors issued by child nodes of SM node.
    539 //For handling errors generated by CPM plugin we rely on engine to do err handling.
    540 class PVMFSMFSPChildNodeErrorHandler
    541 {
    542     public:
    543         PVMFSMFSPChildNodeErrorHandler(PVMFSMFSPBaseNode * aFSPBaseNode): iCmdResponse(NULL)
    544                 , iAsyncEvent(NULL)
    545                 , iErroneousCmdResponse(NULL)
    546                 , iErrCmd(NULL)
    547                 , iErrSource(SMFSP_ERR_SOURCE_INDETERMINATE)
    548                 , iState(SMFSP_ERRHANDLER_IDLE)
    549                 , iSMFSPNode(aFSPBaseNode)
    550                 , iLogger(NULL)
    551         {
    552 
    553         }
    554 
    555         void Construct()
    556         {
    557             iLogger = PVLogger::GetLoggerObject("PVMFSMFSPChildNodeErrorHandler");
    558         }
    559         static PVMFSMFSPChildNodeErrorHandler* CreateErrHandler(PVMFSMFSPBaseNode* aFSPBaseNode);
    560         static void DeleteErrHandler(PVMFSMFSPChildNodeErrorHandler*& aErrHandler);
    561         void InitiateErrorHandling(const PVMFCmdResp& aCmdResponse);
    562         void InitiateErrorHandling(const PVMFAsyncEvent& aAsyncEvent);
    563         void CompleteErrorHandling(const PVMFCmdResp& aResponse);
    564         bool IsErrorHandlingComplete() const
    565         {
    566             return (SMFSP_ERRHANDLER_IDLE == iState);
    567         }
    568         void Reset();
    569         const PVMFCmdResp* GetErroneousCmdResponse();
    570         const PVMFAsyncEvent* GetAsyncErrEvent();
    571         void ErrHandlingCommandComplete(PVMFFSPNodeCmdQ&,
    572                                         PVMFSMFSPBaseNodeCommand&,
    573                                         PVMFStatus,
    574                                         OsclAny* aData = NULL,
    575                                         PVUuid* aEventUUID = NULL,
    576                                         int32* aEventCode = NULL,
    577                                         PVInterface* aExtMsg = NULL);
    578     private:
    579         void SaveErrorInfo(const PVMFCmdResp& aCmdResponse);
    580         void SaveErrorInfo(const PVMFAsyncEvent& aAsyncEvent);
    581         void PerformErrorHandling();
    582         void ContinueChildNodesCmdCancellation();
    583         void CompleteChildNodesCmdCancellationDueToErr();
    584         void CompleteChildNodesResetDueToError();
    585 
    586         enum SMFSPErrorSource
    587         {
    588             SMFSP_ERR_SOURCE_INDETERMINATE,
    589             SMFSP_ERR_SOURCE_EVENT,
    590             SMFSP_ERR_SOURCE_NODE_CMD_COMPLETION
    591         };
    592 
    593         enum SMFSPChildNodeErrorHandlerState
    594         {
    595             SMFSP_ERRHANDLER_IDLE,
    596             SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_COMPLETION, //when er occurs for cancel command we do not queue cancel due to err
    597             SMFSP_ERRHANDLER_WAITING_FOR_CANCEL_DUE_TO_ERR_COMPLETION,
    598             SMFSP_ERRHANDLER_WAITING_FOR_RESET_DUE_TO_ERR_COMPLETION
    599         };
    600 
    601         PVMFCmdResp *iCmdResponse;
    602         PVMFAsyncEvent *iAsyncEvent;
    603         PVMFCmdResp *iErroneousCmdResponse;
    604         PVMFSMFSPBaseNodeCommand* iErrCmd;
    605         SMFSPErrorSource iErrSource;
    606         SMFSPChildNodeErrorHandlerState iState;
    607         PVMFSMFSPBaseNode * iSMFSPNode;
    608         PVLogger *iLogger;
    609 };
    610 #endif
    611