javauis/mmapi_qt/baseline/inc/cmmavideourlplayer.h
changeset 23 98ccebc37403
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
       
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  This class is used for playing URL videos
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMMAVIDEOURLPLAYER_H
       
    20 #define CMMAVIDEOURLPLAYER_H
       
    21 
       
    22 
       
    23 //  INCLUDES
       
    24 #include "cmmavideoplayer.h"
       
    25 #include "mmmaguiplayer.h"
       
    26 #include <es_sock.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class MMAFunctionServer;
       
    30 
       
    31 //  CLASS DECLARATION
       
    32 /**
       
    33 *   This class is used for playing video.
       
    34 *
       
    35 *
       
    36 */
       
    37 
       
    38 class CMMAVideoUrlPlayer: public CMMAVideoPlayer
       
    39 {
       
    40 protected:
       
    41     /**
       
    42      * Protected abstract base class for url player delegates.
       
    43      */
       
    44     class CMMAVideoUrlPlayerDelegate : public CBase
       
    45     {
       
    46     public:
       
    47         virtual ~CMMAVideoUrlPlayerDelegate();
       
    48 
       
    49     protected:
       
    50         /**
       
    51          * C++ constructor
       
    52          */
       
    53         CMMAVideoUrlPlayerDelegate(CMMAVideoUrlPlayer& aPlayer);
       
    54 
       
    55     public:
       
    56         /**
       
    57          * Handles StartL call for url player.
       
    58          */
       
    59         virtual void StartL() = 0;
       
    60 
       
    61         /**
       
    62          * Handles StopL call for url player.
       
    63          *
       
    64          * @param aPostEvent post event to Java side
       
    65          */
       
    66         virtual void StopL(TBool aPostEvent) = 0;
       
    67 
       
    68         /**
       
    69          * Gets media time for url player.
       
    70          *
       
    71          * @param aMediaTime When method returns parameter contains the media
       
    72          * time.
       
    73          */
       
    74         virtual void GetMediaTime(TInt64* aMediaTime) = 0;
       
    75 
       
    76         /**
       
    77          * Handles events for url player.
       
    78          *
       
    79          * @param aEvent event type
       
    80          */
       
    81         virtual void HandleEvent(const TMMFEvent& aEvent) = 0;
       
    82 
       
    83     protected: // data
       
    84         CMMAVideoUrlPlayer& iPlayer;
       
    85     };
       
    86 
       
    87     /**
       
    88      * Delegate class for non-live video streams
       
    89      */
       
    90     class CMMAVideoUrlPlayerClipStreamDelegate :
       
    91             public CMMAVideoUrlPlayerDelegate
       
    92     {
       
    93     public:
       
    94         CMMAVideoUrlPlayerClipStreamDelegate(CMMAVideoUrlPlayer& aPlayer);
       
    95         virtual ~CMMAVideoUrlPlayerClipStreamDelegate();
       
    96 
       
    97     public: // from CMMAVideoUrlPlayerDelegate
       
    98         void StartL();
       
    99         void StopL(TBool aPostEvent);
       
   100         void GetMediaTime(TInt64* aMediaTime);
       
   101         void HandleEvent(const TMMFEvent& aEvent);
       
   102     };
       
   103 
       
   104     /**
       
   105      * Delegate class for live video streams
       
   106      */
       
   107     class CMMAVideoUrlPlayerLiveStreamDelegate :
       
   108             public CMMAVideoUrlPlayerDelegate
       
   109     {
       
   110     public:
       
   111         static CMMAVideoUrlPlayerLiveStreamDelegate*
       
   112         NewL(CMMAVideoUrlPlayer& aPlayer);
       
   113 
       
   114         virtual ~CMMAVideoUrlPlayerLiveStreamDelegate();
       
   115 
       
   116     protected:
       
   117         CMMAVideoUrlPlayerLiveStreamDelegate(CMMAVideoUrlPlayer& aPlayer);
       
   118         void ConstructL();
       
   119 
       
   120     public: // from CMMAVideoUrlPlayerDelegate
       
   121         void StartL();
       
   122         void StopL(TBool aPostEvent);
       
   123         void GetMediaTime(TInt64* aMediaTime);
       
   124         void HandleEvent(const TMMFEvent& aEvent);
       
   125 
       
   126     private: // data
       
   127         CActiveSchedulerWait* iActiveSchedulerWait;
       
   128 
       
   129         /**
       
   130          * RTSP live stream returns current media time
       
   131          * from the server, but local media time must
       
   132          * start from zero. Thus start media time is
       
   133          * cached here.
       
   134          */
       
   135         TInt64 iMediaStartTime;
       
   136 
       
   137         /**
       
   138          * Hold player stop time value. It is otherwise
       
   139          * forgotten when player is stopped.
       
   140          */
       
   141         TInt64 iStoppedAtTime;
       
   142     };
       
   143 
       
   144 public: // Construction
       
   145     static CMMAVideoUrlPlayer* NewLC(
       
   146         CMMAMMFResolver* aResolver,
       
   147         const TDesC& aUrl);
       
   148 
       
   149     //   Destructor
       
   150     IMPORT_C ~CMMAVideoUrlPlayer();
       
   151 
       
   152 protected:
       
   153     //   C++ constructor
       
   154     IMPORT_C CMMAVideoUrlPlayer(CMMAMMFResolver* aResolver);
       
   155     IMPORT_C void ConstructL(const TDesC& aUrl);
       
   156 
       
   157 public: // from CMMAPlayer
       
   158     IMPORT_C void RealizeL();
       
   159     IMPORT_C void PrefetchL();
       
   160     IMPORT_C void StartL();
       
   161     IMPORT_C void StopL(TBool aPostEvent);
       
   162     IMPORT_C void GetMediaTime(TInt64* aMediaTime);
       
   163     IMPORT_C void DeallocateL();
       
   164     IMPORT_C void CloseL();
       
   165 
       
   166 protected: // New Methods
       
   167     void FindActiveIap(const TUint aConnectionCount, TUint& aActiveIap);
       
   168     virtual TBool IsLiveStreamL();
       
   169 
       
   170     /**
       
   171      * Handles events from delegate classes to
       
   172      * superclass HandleEvent.
       
   173      *
       
   174      * @param aEvent event data
       
   175      */
       
   176     void HandleEventToParent(const TMMFEvent& aEvent);
       
   177 
       
   178 protected: // From CMMAVideoPlayer
       
   179     IMPORT_C void HandleEvent(const TMMFEvent& aEvent);
       
   180 
       
   181 protected: // Data
       
   182     HBufC* iUrl; // Owned url
       
   183     RConnection iConnection;
       
   184     RSocketServ iSocketServ;
       
   185     TThreadPriority iOrigPriority;
       
   186     CMMAVideoUrlPlayerDelegate* iPlayerDelegate;
       
   187 };
       
   188 
       
   189 #endif // CMMAVIDEOURLPLAYER_H