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_DATAPATH_H_INCLUDED
     19 #define PV_PLAYER_DATAPATH_H_INCLUDED
     20 
     21 #ifndef OSCL_BASE_H_INCLUDED
     22 #include "oscl_base.h"
     23 #endif
     24 
     25 #ifndef OSCL_SCHEDULER_AO_H_INCLUDED
     26 #include "oscl_scheduler_ao.h"
     27 #endif
     28 
     29 #ifndef PVMF_NODE_INTERFACE_H_INCLUDED
     30 #include "pvmf_node_interface.h"
     31 #endif
     32 
     33 #ifndef OSCL_STRING_CONTAINERS_H_INCLUDED
     34 #include "oscl_string_containers.h"
     35 #endif
     36 
     37 #ifndef PVMF_FORMAT_TYPE_H_INCLUDED
     38 #include "pvmf_format_type.h"
     39 #endif
     40 
     41 #ifndef PVMF_MEDIA_PRESENTATION_INFO_H_INCLUDED
     42 #include "pvmf_media_presentation_info.h"
     43 #endif
     44 
     45 class PVPlayerDatapathObserver
     46 {
     47     public:
     48         virtual void HandlePlayerDatapathEvent(int32 aDatapathEvent, PVMFStatus aEventStatus, OsclAny* aContext = NULL, PVMFCmdResp* aCmdResp = NULL) = 0;
     49         virtual ~PVPlayerDatapathObserver() {}
     50 };
     51 
     52 enum PVPDPState
     53 {
     54     PVPDP_IDLE,
     55     PVPDP_ERROR,
     56     PREPARE_INIT,
     57     PREPARE_REQPORT,
     58     PREPARE_PREPARE,
     59     PREPARE_CONNECT,
     60     PREPARED,
     61     START_START,
     62     STARTED,
     63     PAUSE_PAUSE,
     64     PAUSED,
     65     STOP_STOP,
     66     STOPPED,
     67     TEARDOWN_RELEASEPORT1,
     68     TEARDOWN_RELEASEPORT2,
     69     TEARDOWNED,
     70     RESET_RESET,
     71     RESETTED,
     72     PVPDP_CANCEL,
     73     PVPDP_CANCELLED
     74 };
     75 
     76 class PVLogger;
     77 
     78 class PVPlayerDatapath : public OsclTimerObject,
     79         public PVMFNodeCmdStatusObserver,
     80         public PVMFNodeInfoEventObserver,
     81         public PVMFNodeErrorEventObserver
     82 {
     83     public:
     84         PVPlayerDatapath();
     85 
     86         ~PVPlayerDatapath();
     87 
     88         void SetObserver(PVPlayerDatapathObserver& aDPObserver,
     89                          PVMFNodeErrorEventObserver& aErrorObserver,
     90                          PVMFNodeInfoEventObserver& aInfoObserver)
     91         {
     92             iObserver = &aDPObserver;
     93             iErrorObserver = &aErrorObserver;
     94             iInfoObserver = &aInfoObserver;
     95         }
     96 
     97         void SetSourceNode(PVMFNodeInterface* aSourceNode)
     98         {
     99             iSourceNode = aSourceNode;
    100         }
    101 
    102         PVMFNodeInterface* GetSourceNode()
    103         {
    104             return iSourceNode;
    105         }
    106 
    107         void SetDecNode(PVMFNodeInterface* aDecNode)
    108         {
    109             iDecNode = aDecNode;
    110         }
    111 
    112         PVMFNodeInterface* GetDecNode()
    113         {
    114             return iDecNode;
    115         }
    116 
    117         void SetSinkNode(PVMFNodeInterface* aSinkNode)
    118         {
    119             iSinkNode = aSinkNode;
    120         }
    121 
    122         PVMFNodeInterface* GetSinkNode()
    123         {
    124             return iSinkNode;
    125         }
    126 
    127         void SetSourceDecTrackInfo(PVMFTrackInfo& aTrackInfo)
    128         {
    129             iSourceTrackInfo = &aTrackInfo;
    130             iSourceDecFormatType = aTrackInfo.getTrackMimeType().get_str();
    131         }
    132 
    133         void SetDecSinkFormatType(PVMFFormatType& aFormatType)
    134         {
    135             iDecSinkFormatType = aFormatType;
    136             iDecSinkFormatString = aFormatType.getMIMEStrPtr();
    137         }
    138 
    139         void SetSourceSinkTrackInfo(PVMFTrackInfo& aTrackInfo)
    140         {
    141             iSourceTrackInfo = &aTrackInfo;
    142             iSourceSinkFormatType = aTrackInfo.getTrackMimeType().get_str();
    143         }
    144 
    145         PVMFStatus Prepare(OsclAny* aContext);
    146 
    147         PVMFStatus Start(OsclAny* aContext);
    148 
    149         PVMFStatus Pause(OsclAny* aContext, bool aSinkPaused = false);
    150 
    151         PVMFStatus Stop(OsclAny* aContext, bool aErrorCondition = false);
    152 
    153         PVMFStatus Teardown(OsclAny* aContext, bool aErrorCondition = false);
    154 
    155         PVMFStatus Reset(OsclAny* aContext, bool aErrorCondition = false);
    156 
    157         PVMFStatus CancelCommand(OsclAny* aContext);
    158 
    159         void DisconnectNodeSession(void);
    160 
    161         PVPDPState iState;
    162 
    163     private:
    164         // From OsclTimerObject
    165         void Run();
    166 
    167         // From PVMFNodeCmdStatusObserver
    168         void NodeCommandCompleted(const PVMFCmdResp& aResponse);
    169 
    170         // From PVMFNodeInfoEventObserver
    171         void HandleNodeInformationalEvent(const PVMFAsyncEvent& aEvent);
    172 
    173         // From PVMFNodeErrorEventObserver
    174         void HandleNodeErrorEvent(const PVMFAsyncEvent& aEvent);
    175 
    176         PVMFStatus IssueDatapathInit(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    177         PVMFStatus IssueDatapathRequestPort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, int32 aPortTag,
    178                                             PvmfMimeString* aPortConfig, OsclAny* aContext, PVMFCommandId &aCmdId);
    179         PVMFStatus IssueDatapathPrepare(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    180         PVMFStatus IssueDatapathStart(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    181         PVMFStatus IssueDatapathPause(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    182         PVMFStatus IssueDatapathStop(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    183         PVMFStatus IssueDatapathReleasePort(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFPortInterface* aPort, PVMFCommandId& aCmdId);
    184         PVMFStatus IssueDatapathReset(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    185         PVMFStatus IssueDatapathCancel(PVMFNodeInterface* aNode, PVMFSessionId aSessionId, PVMFCommandId& aCmdId);
    186 
    187         PVMFNodeInterface* iSourceNode;
    188         PVMFSessionId iSourceSessionId;
    189         PVMFNodeInterface* iDecNode;
    190         PVMFSessionId iDecSessionId;
    191         PVMFNodeInterface* iSinkNode;
    192         PVMFSessionId iSinkSessionId;
    193 
    194         PVMFPortInterface* iSourceOutPort;
    195         PVMFPortInterface* iDecInPort;
    196         PVMFPortInterface* iDecOutPort;
    197         PVMFPortInterface* iSinkInPort;
    198 
    199         PVPlayerDatapathObserver* iObserver;
    200         PVMFNodeErrorEventObserver* iErrorObserver;
    201         PVMFNodeInfoEventObserver* iInfoObserver;
    202         OsclAny* iContext;
    203 
    204         PVMFFormatType iSourceDecFormatType;
    205         PVMFFormatType iDecSinkFormatType;
    206         OSCL_HeapString<OsclMemAllocator> iDecSinkFormatString;
    207         PVMFFormatType iSourceSinkFormatType;
    208         PVMFTrackInfo* iSourceTrackInfo;
    209 
    210         // Enum for the datapath configuration
    211         enum PVPDPConfig
    212         {
    213             CONFIG_NONE,
    214             CONFIG_DEC
    215         };
    216 
    217         PVPDPConfig iDatapathConfig;
    218 
    219         int32 iPendingCmds;
    220 
    221         PVLogger* iLogger;
    222 
    223         bool iSinkPaused;
    224 
    225         bool iErrorCondition;
    226         bool iErrorOccurredDuringErrorCondition;
    227 };
    228 
    229 #endif // PV_PLAYER_DATAPATH_H_INCLUDED
    230 
    231 
    232