dvrengine/CommonRecordingEngine/inc/CCREngine.h
changeset 41 d88d70d98bbc
parent 34 814ba97beeb9
child 46 3bc36dbd63c2
equal deleted inserted replaced
34:814ba97beeb9 41:d88d70d98bbc
     1 /*
       
     2 * Copyright (c) 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 the License "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:    Engine part of the engine. Engineered to keep count*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CCRENGINE_H
       
    21 #define CCRENGINE_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include "CCRConnection.h"
       
    25 #include <ipvideo/CRTypeDefs.h>
       
    26 #include <e32base.h>
       
    27 
       
    28 // CONSTANTS
       
    29 // None
       
    30 
       
    31 // MACROS
       
    32 // None
       
    33 
       
    34 // DATA TYPES
       
    35 // None
       
    36     
       
    37 // FORWARD DECLARATIONS
       
    38 class CAsyncCallBack;
       
    39 class CCRSession;
       
    40 class CCRStreamingSession;
       
    41 class CCRClientInformer;
       
    42 class CRtpClipHandler;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 *  Server's bookkeeping part: knows what clients there are and thru which
       
    48 *  client sessions, what streaming sessions there are and passes commands
       
    49 *  to those sessions and sinks. 
       
    50 *
       
    51 *  @lib CommonRecordingEngine.lib
       
    52 *  @since Series 60 3.0
       
    53 */
       
    54 class CCREngine : public CObject,
       
    55                   public MCRConnectionObserver
       
    56     {
       
    57 
       
    58 public: // Constructors and destructor
       
    59 
       
    60     /**
       
    61     * Two-phased constructor.
       
    62     * @return CCREngine pointer to CCREngine class
       
    63     */
       
    64     static CCREngine* NewL( void );
       
    65 
       
    66     /**
       
    67     * Destructor.
       
    68     */
       
    69     virtual ~CCREngine();
       
    70 
       
    71 public: // New functions
       
    72 
       
    73     /**
       
    74     * Does the general message handling.
       
    75     * @since Series 60 3.0
       
    76     * @param aMessage contains data from the client.
       
    77     * @return none.
       
    78     */
       
    79     void GeneralServiceL( const RMessage2& aMessage );
       
    80 
       
    81     /**
       
    82     * Method that streams call to ask for resignation. 
       
    83     * @since Series 60 3.0
       
    84     * @param aSession is pointer to streamingsession that wants to quit.
       
    85     * @return none.
       
    86     */
       
    87     void SessionStop( CCRStreamingSession* aSession ); 
       
    88     
       
    89 private: // Constructors and destructor
       
    90 
       
    91     /**
       
    92     * C++ default constructor.
       
    93     */
       
    94     CCREngine( void );
       
    95 
       
    96     /**
       
    97     * By default Symbian 2nd phase constructor is private.
       
    98     */
       
    99     void ConstructL();
       
   100             
       
   101 public: // Methods from base classes
       
   102 
       
   103     /**
       
   104     * From MCRConnectionObserver.
       
   105     * receives notifications of connection status changes,
       
   106     * used to clear heuristics on streaming capabilities.
       
   107     * @since Series 60 3.0
       
   108     * @param aSessionId a session id.
       
   109     * @param aStatus is the new status of the connection.
       
   110     * @param aErr contains error code if new status is failure status.
       
   111     * @return none.
       
   112     */
       
   113     void ConnectionStatusChange( TInt aSessionId,
       
   114                                  TCRConnectionStatus aStatus,
       
   115                                  TInt aErr );
       
   116     
       
   117 private: // New methods
       
   118 
       
   119     /**
       
   120     * Verifies needed cababilities of DVR client user.
       
   121     * @since Series 60 3.0
       
   122     * @param aMessage contains data from the client.
       
   123     * @return None.
       
   124     */
       
   125     void VerifyCapabilitiesL( const RMessage2& aMessage );
       
   126 
       
   127     /**
       
   128     * Sets connection.
       
   129     * @since Series 60 3.0
       
   130     * @param aIap ?.
       
   131     * @return KErrNone if succesful, otherwise system wide error code.
       
   132     */
       
   133     TInt SetConnectionId( const SCRRtspIapParams& aIap );
       
   134     
       
   135     /**
       
   136     * Cancel connetion set.
       
   137     * @since Series 60 3.0
       
   138     * @return KErrNone if succesful, otherwise system wide error code.
       
   139     */
       
   140     TInt CancelSetConnectionId();
       
   141     
       
   142     /**
       
   143     * Starts RTSP URL streaming.
       
   144     * @since Series 60 3.0
       
   145     * @param aRtspParams a RTPS params.
       
   146     * @return a session definition checksum.
       
   147     */
       
   148     TUint PlayRtspUrlL( const SCRRtspParams& aRtspParams );
       
   149 
       
   150     /**
       
   151     * Starts DVB-H live streaming.
       
   152     * @since Series 60 3.0
       
   153     * @param aLiveParams is set of parameters required for DVB-H.
       
   154     * @return a session definition checksum.
       
   155     */
       
   156     TUint PlayDvbhLiveL( const SCRLiveParams& aLiveParams );
       
   157 
       
   158     /**
       
   159     * Change service (channel) of DVB-H live stream.
       
   160     * @since Series 60 3.0
       
   161     * @param aCurrentSessionChk a current service session checksum.
       
   162     * @param aLiveParams is set of parameters required for DVB-H.
       
   163     * @return a session definition checksum.
       
   164     */
       
   165     TUint ChangeDvbhServiceL( const TUint aSessionChk,
       
   166                               const SCRLiveParams& aLiveParams );
       
   167 
       
   168     /**
       
   169     * Starts RTP file format playing.
       
   170     * @since Series 60 3.0
       
   171     * @param aRtpParams a RTP clip play params.
       
   172     * @return a session definition checksum.
       
   173     */
       
   174     TUint PlayRtpFileL( const SCRRtpPlayParams& aRtpParams );
       
   175 
       
   176     /**
       
   177     * Starts RTP file format playing.
       
   178     * @since Series 60 3.0
       
   179     * @param aFileHandle a open file handle for RTP file.
       
   180     * @return a session definition checksum.
       
   181     */
       
   182     TUint PlayRtpFileL( const RFile& aFileHandle );
       
   183 
       
   184     /**
       
   185     * Starts recording of current stream.
       
   186     * @since Series 60 3.0
       
   187     * @param aSessionChk a session defination checksum.
       
   188     * @param aRecordParams a recording parameters.
       
   189     * @return none.
       
   190     */
       
   191     void RecordCurrentStreamL( const TUint aSessionChk,
       
   192                                const SCRRecordParams& aRecordParams );
       
   193     
       
   194     /**
       
   195     * Starts recording of RTSP stream.
       
   196     * @since Series 60 3.0
       
   197     * @param aRtspUrl is set of parameters required for rtsp.
       
   198     * @param aRecordParams a recording parameters.
       
   199     * @return a session definition checksum.
       
   200     */
       
   201     TUint RecordRtspStreamL( const SCRRtspParams& aRtspUrl,
       
   202                              const SCRRecordParams& aRecordParams );
       
   203     
       
   204     /**
       
   205     * Starts recording of DVB-H stream.
       
   206     * @since Series 60 3.0
       
   207     * @param aLiveParams is set of parameters required for DVB-H.
       
   208     * @param aRecordParams a recording parameters.
       
   209     * @return a session definition checksum.
       
   210     */
       
   211     TUint RecordDvbhStreamL( const SCRLiveParams& aLiveParams,
       
   212                              const SCRRecordParams& aRecordParams );
       
   213     
       
   214     /**
       
   215     * Pauses/Resumes current recording.
       
   216     * @since Series 60 3.0
       
   217     * @param aSessionChk a session defination checksum.
       
   218     * @param aStart a start or end pausing.
       
   219     * @return KErrNone if succesful, otherwise system wide error code.
       
   220     */
       
   221     TInt PauseRecordStream( const TUint aSessionChk,
       
   222                             const TBool& aStart );
       
   223 
       
   224     /**
       
   225     * Stops current recording.
       
   226     * @since Series 60 3.0
       
   227     * @param aSessionChk a session defination checksum.
       
   228     * @return KErrNone if succesful, otherwise system wide error code.
       
   229     */
       
   230     TInt StopRecordStream( const TUint aSessionChk );
       
   231 
       
   232     /**
       
   233     * Starts time shifting.
       
   234     * @since Series 60 3.0
       
   235     * @param aSessionChk a session defination checksum.
       
   236     * @return KErrNone if succesful, otherwise system wide error code.
       
   237     */
       
   238     TInt StartTimeShiftL( const TUint aSessionChk );
       
   239 
       
   240     /**
       
   241     * Stops time shifting.
       
   242     * @since Series 60 3.0
       
   243     * @param aTimeShiftChk a session definition checksum.
       
   244     * @param aCurrentChk a session definition of existing session.
       
   245     * @return KErrNone if succesful, otherwise system wide error code.
       
   246     */
       
   247     TInt StopTimeShift( const TUint aTimeShiftChk,
       
   248                         const TUint aCurrentChk );
       
   249 
       
   250     /**
       
   251     * Play command for wanted source.
       
   252     * @since Series 60 3.0
       
   253     * @param aSessionChk a session definition checksum.
       
   254     * @param aStartPos is start position in seconds.
       
   255     * @param aEndPos is end position in seconds.
       
   256     * @return KErrNone if succesful, otherwise system wide error code.
       
   257     */
       
   258     TInt PlayCommand( const TUint aSessionChk,
       
   259                       const TReal aStartPos,
       
   260                       const TReal aEndPos );
       
   261 
       
   262     /**
       
   263     * Pause command for wanted source.
       
   264     * @since Series 60 3.0
       
   265     * @param aSessionChk a session definition checksum.
       
   266     * @return KErrNone if succesful, otherwise system wide error code.
       
   267     */
       
   268     TInt PauseCommand( const TUint aSessionChk );
       
   269 
       
   270     /**
       
   271     * Stop command for wanted source.
       
   272     * @since Series 60 3.0
       
   273     * @param aSessionChk a session definition checksum.
       
   274     * @return KErrNone if succesful, otherwise system wide error code.
       
   275     */
       
   276     TInt StopCommand( const TUint aSessionChk );
       
   277 
       
   278     /**
       
   279     * Setter for source position.
       
   280     * @since Series 60 3.0
       
   281     * @param aSessionChk a session defination checksum.
       
   282     * @param aPosition a current play position of the clip.
       
   283     * @return KErrNone if succesful, otherwise system wide error code.
       
   284     */
       
   285     TInt SetPosition( const TUint aSessionChk,
       
   286                       const TInt64 aPosition );
       
   287 
       
   288     /**
       
   289     * Getter for source position.
       
   290     * @since Series 60 3.0
       
   291     * @param aSessionChk a session defination checksum.
       
   292     * @param aPosition a current play position of the clip.
       
   293     * @param aDuration a duration of the clip.
       
   294     * @return KErrNone if succesful, otherwise system wide error code.
       
   295     */
       
   296     TInt GetPosition( const TUint aSessionChk,
       
   297                       TInt64& aPosition,
       
   298                       TInt64& aDuration );
       
   299 
       
   300     /**
       
   301     * Closes wanted source and all sinks.
       
   302     * @since Series 60 3.0
       
   303     * @param aSessionChk a session definition checksum.
       
   304     * @return KErrNone if succesful, otherwise system wide error code.
       
   305     */
       
   306     TInt CloseSession( const TUint aSessionChk );
       
   307 
       
   308     /**
       
   309     * Emulates live source from a .rtp clip.
       
   310     * @since Series 60 3.0
       
   311     * @param none.
       
   312     * @return a session definition checksum.
       
   313     */
       
   314     TUint PlayNullSourceL();
       
   315     
       
   316     /**
       
   317     * Sends RTSP stream packets to null sink.
       
   318     * @since Series 60 3.0
       
   319     * @param aRtspParams a RTPS params.
       
   320     * @return a session definition checksum.
       
   321     */
       
   322     TUint PlayRtspUrlToNullSinkL( const SCRRtspParams& aRtspParams );
       
   323     
       
   324     /**
       
   325     * Creates connection.
       
   326     * @since Series 60 3.0
       
   327     * @param none.
       
   328     * @return none.
       
   329     */
       
   330     void CreateConnectionL( void ); 
       
   331     
       
   332     /**
       
   333     * Creates RTP clip handler.
       
   334     * @since Series 60 3.0
       
   335     * @param none.
       
   336     * @return none.
       
   337     */
       
   338     void CreateClipHandlerL( void ); 
       
   339     
       
   340     /**
       
   341     * Verifies if RTSP session with params is already available.
       
   342     * @since Series 60 3.0
       
   343     * @param aRtspParams a RTPS params.
       
   344     * @return an index to sessions array if session found,
       
   345               otherwise KErrNotFound.
       
   346     */
       
   347     TInt VerifyRtspSessionL( const SCRRtspParams& aRtspParams );
       
   348 
       
   349     /**
       
   350     * Verifies if DVB-H session with params is already available.
       
   351     * @since Series 60 3.0
       
   352     * @param aLiveParams is set of parameters required for DVB-H.
       
   353     * @return an index to sessions array if session found,
       
   354               otherwise KErrNotFound.
       
   355     */
       
   356     TInt VerifyDvbhSessionL( const SCRLiveParams& aLiveParams );
       
   357 
       
   358     /**
       
   359     * Verifies if DVB-H session with params is already available.
       
   360     * @since Series 60 3.0
       
   361     * @param aRtpParams a RTP clip play params.
       
   362     * @return an index to sessions array if session found,
       
   363               otherwise KErrNotFound.
       
   364     */
       
   365     TInt VerifyRtpFileSessionL( const SCRRtpPlayParams& aRtpParams );
       
   366 
       
   367     /**
       
   368     * Verifies if session with defination name is available.
       
   369     * @since Series 60 3.0
       
   370     * @param aFileHandle a open file handle for RTP file.
       
   371     * @return an index to sessions array if names match,
       
   372               otherwise KErrNotFound.
       
   373     */
       
   374     TInt VerifyRtpFileSessionL( const RFile& aFileHandle );
       
   375 
       
   376     /**
       
   377     * Verifies if session with defination name is available.
       
   378     * @since Series 60 3.0
       
   379     * @param aName a definition name of the session.
       
   380     * @return an index to sessions array if names match,
       
   381               otherwise KErrNotFound.
       
   382     */
       
   383     TInt VerifySession( const TDesC& aName );
       
   384 
       
   385     /**
       
   386     * Verifies if session with definition checksum is available.
       
   387     * @since Series 60 3.0
       
   388     * @param aSessionChk a session checksum to verify for.
       
   389     * @return an index to sessions array if names match,
       
   390               otherwise KErrNotFound.
       
   391     */
       
   392     TInt VerifySession( const TUint aSessionChk );
       
   393 
       
   394     /**
       
   395     * Creates recording sin base on file format.
       
   396     * @since Series 60 3.0
       
   397     * @param aSessionIndex a session index.
       
   398     * @param aRecordParams a recording parameters.
       
   399     * @return none.
       
   400     */
       
   401     void CreateRecordingSinkL( const TInt aSessionIndex,
       
   402                                const SCRRecordParams& aRecordParams ); 
       
   403     
       
   404     /**
       
   405     * Static callback called via CAsyncCallBack to initiate cleaning of a sessions.
       
   406     * @since Series 60 3.0
       
   407     * @param aThis ?.
       
   408     * @return KErrNone if succesful, otherwise system wide error code.
       
   409     */
       
   410     static TInt SessionStopCallBack( TAny* aThis ); 
       
   411     
       
   412     /**
       
   413     * Method for cleaning a sessions. Called from StreamStopCallBack.
       
   414     * @since Series 60 3.0
       
   415     * @param none.
       
   416     * @return none.
       
   417     */
       
   418     void DoSessionStop( void ); 
       
   419     
       
   420     /**
       
   421     * Method for deleting RTP clip handler if it is not used in any session.
       
   422     * @since Series 60 3.0
       
   423     * @param aCurrentSessionIndex a index of active session.
       
   424     * @return none.
       
   425     */
       
   426     void DeleteClipHandler( const TInt aCurrentSessionIndex ); 
       
   427     
       
   428     /**
       
   429     * Reads non unicode descriptor buffer to client address space.
       
   430     * @since Series 60 3.0
       
   431     * @param aMessage an object which encapsulates a client request.
       
   432     * @param aParam a index value identifying the argument.
       
   433     * @param aDes a buffer to be read.
       
   434     * @return None.
       
   435     */
       
   436     void Read( const RMessage2& aMessage, 
       
   437                const TInt& aParam,
       
   438                TDes8& aDes );
       
   439 
       
   440     /**
       
   441     * Reads unicode descriptor buffer to client address space.
       
   442     * @since Series 60 3.0
       
   443     * @param aMessage an object which encapsulates a client request.
       
   444     * @param aParam a index value identifying the argument.
       
   445     * @param aDes a buffer to be read.
       
   446     * @return None.
       
   447     */
       
   448     void Read( const RMessage2& aMessage, 
       
   449                const TInt& aParam,
       
   450                TDes16& aDes );
       
   451 
       
   452     /**
       
   453     * Writes non unicode descriptor buffer to client address space.
       
   454     * @since Series 60 3.0
       
   455     * @param aMessage an object which encapsulates a client request.
       
   456     * @param aParam a index value identifying the argument.
       
   457     * @param aDes a data to be written.
       
   458     * @return None.
       
   459     */
       
   460     void Write( const RMessage2& aMessage, 
       
   461                 const TInt& aParam,
       
   462                 const TDesC8& aDes );
       
   463 
       
   464     /**
       
   465     * Writes unicode descriptor buffer to client address space.
       
   466     * @since Series 60 3.0
       
   467     * @param aMessage an object which encapsulates a client request.
       
   468     * @param aPtr a pointer to client address space.
       
   469     * @param aDes a data to be written.
       
   470     * @return None.
       
   471     */
       
   472     void Write( const RMessage2& aMessage, 
       
   473                 const TInt& aParam,
       
   474                 const TDesC16& aDes );
       
   475 
       
   476     /**
       
   477     * Method for panicing a client.
       
   478     * @since Series 60 3.0
       
   479     * @param aPanic is the panic reason, essentially a symbian error code.
       
   480     * @aMessage is the message causing the panic.
       
   481     * @return none.
       
   482     */
       
   483     void PanicClient( TInt aPanic, 
       
   484                       const RMessage2& aMessage );
       
   485 
       
   486 private: // Data    
       
   487     
       
   488     /**
       
   489     * Name of the queue.
       
   490     */
       
   491     HBufC* iQueueName;
       
   492     
       
   493     /**
       
   494     * Callstack-cutter for cleanup purpose.
       
   495     */
       
   496     CAsyncCallBack* iCleanUp;
       
   497     
       
   498     /**
       
   499     * Connection manager.
       
   500     */
       
   501     CCRConnection* iConnection;
       
   502     
       
   503     /**
       
   504     * Clip handler for RTP clip.
       
   505     */
       
   506     CRtpClipHandler* iClipHandler;
       
   507 
       
   508     /**
       
   509     * Sends messages to client's message queue
       
   510     */
       
   511     CCRClientInformer* iInformer;
       
   512 
       
   513     /**
       
   514     * Socket server.
       
   515     */
       
   516     RSocketServ iSockServer;
       
   517     
       
   518     /**
       
   519     * Streamong sessions.
       
   520     */
       
   521     RPointerArray<CCRStreamingSession> iSessions;
       
   522     
       
   523     /**
       
   524     * Array of sessions that have declared that they want to be deleted
       
   525     */
       
   526     RPointerArray<CCRStreamingSession> iSessionsToDelete; 
       
   527     
       
   528     /**
       
   529     * Loopback port.
       
   530     */
       
   531     TInt iLoopbackPort;
       
   532     
       
   533     };
       
   534 
       
   535 #endif // CCRENGINE_H
       
   536 
       
   537 // End of file
       
   538