dvrengine/CommonRecordingEngine/inc/CCRStreamingSession.h
branchRCL_3
changeset 48 13a33d82ad98
parent 0 822a42b6c3f1
equal deleted inserted replaced
47:826cea16efd9 48:13a33d82ad98
       
     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:    Streaming session, eg one url, one channel...*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 #ifndef _CCRSTREAMINGSESSION_
       
    21 #define _CCRSTREAMINGSESSION_
       
    22 
       
    23 // INCLUDES
       
    24 #include <ipvideo/CRTypeDefs.h>
       
    25 #include "MCRStreamObserver.h"
       
    26 #include <e32base.h>
       
    27 #include <es_sock.h>
       
    28 
       
    29 // CONSTANTS
       
    30 // None
       
    31 
       
    32 // MACROS
       
    33 // None
       
    34 
       
    35 // DATA TYPES
       
    36 // None
       
    37 
       
    38 // FORWARD DECLARATIONS
       
    39 class CCRPacketBuffer;
       
    40 class CAsyncCallBack;
       
    41 class CCRConnection;
       
    42 class CCRPacketSourceBase;
       
    43 class CCRPacketSinkBase;
       
    44 class CRtpClipHandler;
       
    45 class CCREngine;
       
    46 class MCRPacketSource;
       
    47 
       
    48 // CLASS DECLARATION
       
    49 
       
    50 /**
       
    51 *  Streaming session.
       
    52 *
       
    53 *  @lib CommonRecordingEngine.lib
       
    54 *  @since Series 60 3.0
       
    55 */
       
    56 
       
    57 class CCRStreamingSession : public CBase,
       
    58                             public MCRStreamObserver
       
    59     {
       
    60 
       
    61 public: // Datatype definitions
       
    62     
       
    63     enum TCRSinkId
       
    64         {
       
    65         ECRRtspSinkId = 7000,
       
    66         ECRXpsSinkId,
       
    67         ECR3gpRecSinkId,
       
    68         ECRRtpRecSinkId,
       
    69         ECRNullSinkId
       
    70         };
       
    71 
       
    72     enum TCRSourceId
       
    73         {
       
    74         ECRRtspSourceId = 7100,
       
    75         ECRDvbhSourceId,
       
    76         ECRRtpSourceId,
       
    77         ECRNullSourceId
       
    78         };
       
    79 
       
    80 public: // Constructors and destructors
       
    81 
       
    82     /**
       
    83     * Two-phased constructor.
       
    84     * @return CCRStreamingSession pointer. 
       
    85     */
       
    86     static CCRStreamingSession* NewL( RSocketServ& aSockServer,
       
    87                                       CCRConnection* aConnection,
       
    88                                       CCREngine& aEngine );
       
    89 
       
    90     /**
       
    91     * Destructor 
       
    92     */
       
    93     virtual ~CCRStreamingSession();
       
    94 
       
    95 public: // New methods
       
    96 
       
    97     /**
       
    98     * Method used to start a new RTSP session with parameters.
       
    99     * @since Series 60 3.0
       
   100     * @param aParams specifies the connection addr.
       
   101     * @param aClipHandler a reference pointer to RTP clip handler.
       
   102     * @param aSessionDefinition a session definition string.
       
   103     * @return none.
       
   104     */
       
   105     void OpenSourceL( const SCRRtspParams& aParams,
       
   106                       const TDesC& aSessionDefinition );
       
   107 
       
   108     /**
       
   109     * Method used to start a new RTP session with parameters.
       
   110     * @since Series 60 3.0
       
   111     * @param aParams specifies the RTP clip parameters.
       
   112     * @param aClipHandler a reference pointer to RTP clip handler.
       
   113     * @param aSessionDefinition a session definition string.
       
   114     * @return none.
       
   115     */
       
   116     void OpenSourceL( const SCRRtpPlayParams& aParams,
       
   117                       CRtpClipHandler*& aClipHandler,
       
   118                       const TDesC& aSessionDefinition );
       
   119 
       
   120     /**
       
   121     * Method used to start a new RTP session with parameters.
       
   122     * @since Series 60 3.0
       
   123     * @param aRtpHandle a open file handle for RTP file.
       
   124     * @param aParams specifies the RTP clip parameters.
       
   125     * @param aSessionDefinition a session definition string.
       
   126     * @return none.
       
   127     */
       
   128     void OpenSourceL( const RFile& aRtpHandle,
       
   129                       CRtpClipHandler*& aClipHandler,
       
   130                       const TDesC& aSessionDefinition );
       
   131 
       
   132     /**
       
   133     * Method used to start a new DVB-H session with parameters.
       
   134     * @since Series 60 3.0
       
   135     * @param aLiveParams specifies DVB-H live parameters.
       
   136     * @param aSessionDefinition a session definition string.
       
   137     * @return none.
       
   138     */
       
   139     void OpenSourceL( const SCRLiveParams& aLiveParams,
       
   140                       const TDesC& aSessionDefinition );
       
   141 
       
   142     /**
       
   143     * Method used to start a new Null source session.
       
   144     * @since Series 60 3.0
       
   145     * @param aSessionDefinition a session definition string.
       
   146     * @return none.
       
   147     */
       
   148     void OpenSourceL( const TDesC& aSessionDefinition );
       
   149 
       
   150     /**
       
   151     * Calculates source definition checksum: URL, file name etc.
       
   152     * @since Series 60 3.0
       
   153     * @param aName a pointer to defination name.
       
   154     * @return none.
       
   155     */
       
   156     TUint SourceDefinition( const TDesC& aName );
       
   157 
       
   158     /**
       
   159     * Getter for source definition checksum.
       
   160     * @since Series 60 3.0
       
   161     * @param none.
       
   162     * @return a value of source definition checksum.
       
   163     */
       
   164     TUint SourceChecksum();
       
   165 
       
   166     /**
       
   167     * Method that creates a set of buffers depending on
       
   168     * number of rtp streams to handle.
       
   169     * @since Series 60 3.0
       
   170     * @param none.
       
   171     * @return none.
       
   172     */
       
   173     void CreateAndSetBufferL();
       
   174 
       
   175     /**
       
   176     * Method that creates a packet sink that forwards 
       
   177     * packets to rop plugin for rendering.
       
   178     * @since Series 60 3.0
       
   179     * @param aLoopbackPort a RTSP port for loopback socket.
       
   180     * @return none.
       
   181     */
       
   182     void CreateRtspSinkL( const TInt& aLoopbackPort );
       
   183 
       
   184     /**
       
   185     * Creates XPS sink for passing packets to Helix player.
       
   186     * @since Series 60 3.0
       
   187     * @param none.
       
   188     * @return none.
       
   189     */
       
   190     void CreateXpsSinkL();
       
   191 
       
   192     /**
       
   193     * Creates RTP clip sink for saving packets to a clip.
       
   194     * @since Series 60 3.0
       
   195     * @param aRecordParams a recording parameters.
       
   196     * @return none.
       
   197     */
       
   198     void Create3gpRecordSinkL( const SCRRecordParams& aRecordParams );
       
   199 
       
   200     /**
       
   201     * Creates RTP clip sink for saving packets to a clip.
       
   202     * @since Series 60 3.0
       
   203     * @param aRecordParams a recording parameters.
       
   204     * @param aClipHandler a reference pointer to RTP clip handler.
       
   205     * @return none.
       
   206     */
       
   207     void CreateRtpRecordSinkL( const SCRRecordParams& aRecordParams,
       
   208                                CRtpClipHandler*& aClipHandler );
       
   209 
       
   210     /**
       
   211     * Post action after source initialized.
       
   212     * @since Series 60 3.0
       
   213     * @param none.
       
   214     * @return none.
       
   215     */
       
   216     void PostActionL();
       
   217 
       
   218     /**
       
   219     * Play command for current source.
       
   220     * @since Series 60 3.0
       
   221     * @param aStartPos is start position in seconds.
       
   222     * @param aEndPos is end position in seconds.
       
   223     * @return a system wide error code.
       
   224     */
       
   225     TInt PlayCommand( const TReal& aStartPos,
       
   226                       const TReal& aEndPos );
       
   227 
       
   228     /**
       
   229     * Pause command for current source.
       
   230     * @since Series 60 3.0
       
   231     * @param none.
       
   232     * @return a system wide error code.
       
   233     */
       
   234     TInt PauseCommand();
       
   235 
       
   236     /**
       
   237     * Stop command for current source.
       
   238     * @since Series 60 3.0
       
   239     * @param none.
       
   240     * @return a system wide error code.
       
   241     */
       
   242     TInt StopCommand();
       
   243 
       
   244     /**
       
   245     * Setter for source position.
       
   246     * @since Series 60 3.0
       
   247     * @param aPosition a current play position of the clip.
       
   248     * @return a system wide error code.
       
   249     */
       
   250     TInt SetPosition( const TInt64 aPosition );
       
   251 
       
   252     /**
       
   253     * Getter for source position.
       
   254     * @since Series 60 3.0
       
   255     * @param aPosition a current play position of the clip.
       
   256     * @param aDuration a duration of the clip.
       
   257     * @return a system wide error code.
       
   258     */
       
   259     TInt GetPosition( TInt64& aPosition,
       
   260                       TInt64& aDuration );
       
   261 
       
   262     /**
       
   263     * Pause command for wanted sink.
       
   264     * @since Series 60 3.0
       
   265     * @param aSinkId identifies the sink.
       
   266     * @return a system wide error code.
       
   267     */
       
   268     TInt PauseCommand( const TCRSinkId& aSinkId );
       
   269 
       
   270     /**
       
   271     * Restore command for wanted sink.
       
   272     * @since Series 60 3.0
       
   273     * @param aSinkId identifies the sink.
       
   274     * @return a system wide error code.
       
   275     */
       
   276     TInt RestoreCommand( const TCRSinkId& aSinkId );
       
   277 
       
   278     /**
       
   279     * Stop command for wanted sink.
       
   280     * @since Series 60 3.0
       
   281     * @param aSinkId identifies the sink.
       
   282     * @return a system wide error code.
       
   283     */
       
   284     TInt StopCommand( const TCRSinkId& aSinkId );
       
   285 
       
   286     /**
       
   287     * Method to transfer ownership of existing sink.
       
   288     * @since Series 60 3.0
       
   289     * @param aSinkId identifies the sink.
       
   290     * @param aTargetSession identifies the sink.
       
   291     * @return a system wide error code.
       
   292     */
       
   293     TInt TransferSink( const TCRSinkId& aSinkId,
       
   294                        CCRStreamingSession& aTargetSession );
       
   295 
       
   296     /**
       
   297     * Method to add new sink to session.
       
   298     * @since Series 60 3.0
       
   299     * @param aSink a pointer to the sink to add.
       
   300     * @return a system wide error code.
       
   301     */
       
   302     TInt AddNewSink( CCRPacketSinkBase* aSink );
       
   303 
       
   304     /**
       
   305     * Veryfies if source or any sink on session uses RTP clip handler.
       
   306     * @since Series 60 3.0
       
   307     * @param none.
       
   308     * @return true if clip handler user, otherwise false.
       
   309     */
       
   310     TBool ClipHandlerUsed();
       
   311 
       
   312     /**
       
   313     * Method that creates a packet sink that forwards.
       
   314     * packets to bit bucket.
       
   315     * @since Series 60 3.0
       
   316     * @param none.
       
   317     * @return none.
       
   318     */
       
   319     void CreateNullSinkL();
       
   320 
       
   321     /**
       
   322     * Sets SDP and buffer for sinks. 
       
   323     * @since Series 60 3.0
       
   324     * @param none.
       
   325     * @return none.
       
   326     */
       
   327     void InitializeSinks();
       
   328 
       
   329     /**
       
   330     * Set timestamp and sequence numbers from source to sinks.
       
   331     * If Range is available, sets it too.
       
   332     * @since Series 60 3.0
       
   333     * @param none.
       
   334     * @return none.
       
   335     */
       
   336     void SetSeqAndTs();
       
   337 
       
   338     /**
       
   339     * Method that sink calls to communicate that it wants to quit its business.
       
   340     * It is now our responsibility to delete the sink after buffers have been
       
   341     * notified about the situation.
       
   342     * @since Series 60 3.0
       
   343     * @param aSinkId identifies the sink.
       
   344     * @return none.
       
   345     */
       
   346     void SinkStops( const TCRSinkId& aSinkId );
       
   347 
       
   348     /**
       
   349     * Method that source uses to communicate that it wants more packets.
       
   350     * @since Series 60 3.0
       
   351     * @param none.
       
   352     * @return none.
       
   353     */
       
   354     void SourceRestore();
       
   355 
       
   356     /**
       
   357     * Method that source uses to communicate that it wants to be deleted.
       
   358     * @since Series 60 3.0
       
   359     * @param none.
       
   360     * @return none.
       
   361     */
       
   362     void SourceStop();
       
   363 
       
   364 private: // Constructors and destructors
       
   365 
       
   366     /**
       
   367     * by default default constructor is private
       
   368     * @param aSockServer is the socketserver to use when opening socks.
       
   369     * @param aConnection 
       
   370     * @param aEngine 
       
   371     */
       
   372     CCRStreamingSession( RSocketServ& aSockServer,
       
   373                          CCRConnection* aConnection,
       
   374                          CCREngine& aEngine );
       
   375 
       
   376     /**
       
   377     * second phase of 2-phased construction
       
   378     */
       
   379     void ConstructL();
       
   380 
       
   381 private: // Functions from base classes
       
   382 
       
   383     /**
       
   384     * From MCRStreamObserver.
       
   385     * Source status indication.
       
   386     * @since Series 60 3.0
       
   387     * @param aStatus 
       
   388     * @return none.
       
   389     */
       
   390     void StatusChanged( MCRPacketSource::TCRPacketSourceState aStatus );
       
   391 
       
   392 private: // New methods
       
   393 
       
   394     /**
       
   395     * Static callback called via CAsyncCallBack to initiate cleaning of a sink
       
   396     * @since Series 60 3.0
       
   397     * @param aThis a pointer to owner of call back.
       
   398     * @return none.
       
   399     */
       
   400     static TInt SinkStopCallBack( TAny* aThis );
       
   401 
       
   402     /**
       
   403     * Method for cleaning a sink. Called from SinkStopCallBack
       
   404     * @since Series 60 3.0
       
   405     * @param none.
       
   406     * @return none.
       
   407     */
       
   408     void DoSinkStop( void );
       
   409 
       
   410     /**
       
   411     * Method that deletes a packet sink.
       
   412     * @since Series 60 3.0
       
   413     * @param aSinkId identifies the sink.
       
   414     * @return none.
       
   415     */
       
   416     void DeleteSink( const TCRSinkId& aSinkId );
       
   417 
       
   418 public: // Data
       
   419 
       
   420     /**
       
   421     * Socket server.
       
   422     */
       
   423     RSocketServ& iSockServer;
       
   424 
       
   425     /**
       
   426     * Connections.
       
   427     */
       
   428     CCRConnection* iConnection;
       
   429 
       
   430     /**
       
   431     * Reference to engine object owning this instance.
       
   432     */
       
   433     CCREngine& iEngine;
       
   434 
       
   435     /**
       
   436     * Callback for cutting the call stack in cleanup.
       
   437     */
       
   438     CAsyncCallBack *iCleanUp;
       
   439 
       
   440     /**
       
   441     * Packet sources.
       
   442     */
       
   443     CCRPacketSourceBase* iSource;
       
   444 
       
   445     /**
       
   446     * Source definition checksum.
       
   447     */
       
   448     TUint iSourceChecksum;
       
   449 
       
   450     /**
       
   451     * Packet buffer.
       
   452     */
       
   453     CCRPacketBuffer* iBuffer;
       
   454 
       
   455     /**
       
   456     * Packet sinks.
       
   457     */
       
   458     RPointerArray<CCRPacketSinkBase> iSinks;
       
   459 
       
   460     /**
       
   461     * Array of sinks that have declared that they want to be deleted.
       
   462     */
       
   463     RArray<TCRSinkId> iSinksToDelete;
       
   464 
       
   465 };
       
   466 
       
   467 #endif // _CCRSTREAMINGSESSION_
       
   468 
       
   469 //  End of File