dvrengine/CommonRecordingEngine/inc/CCRRtpRecordSink.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:    Packet sink where no-one gets the streaming*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 #ifndef CCRRTPRECORDSINK_H
       
    20 #define CCRRTPRECORDSINK_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "CCRPacketSinkBase.h"
       
    24 #include <ipvideo/MRtpFileWriteObserver.h>
       
    25 #include "MCRTimerObserver.h"
       
    26 #include <CXPSPktSinkObserver.h>
       
    27 
       
    28 // CONSTANTS
       
    29 // None
       
    30 
       
    31 // MACROS
       
    32 // None
       
    33 
       
    34 // DATA TYPES
       
    35 // None
       
    36 
       
    37 // FORWARD DECLARATIONS
       
    38 class CCRPacketBuffer;
       
    39 class CCRStreamingSession;
       
    40 class MCRConnectionObserver;
       
    41 class CRtpClipHandler;
       
    42 class CRtpTsConverter;
       
    43 
       
    44 // CLASS DECLARATION
       
    45 
       
    46 /**
       
    47 *  Packet sink that does not forward packets. Good for testing. 
       
    48 *
       
    49 *  @lib CommonRecordingEngine.lib
       
    50 *  @since Series 60 3.0
       
    51 */
       
    52 class CCRRtpRecordSink : public CCRPacketSinkBase,
       
    53                          public MRtpFileWriteObserver
       
    54     {
       
    55 
       
    56 public: // Constructors and destructors   
       
    57     
       
    58     /**
       
    59     * Two-phased constructor.
       
    60     * @param aRecordParams a recording parameters.
       
    61     * @param aSinkId that this class needs to use when reporting progress back to owner.
       
    62     * @param aOwningSession is the streaming session that owns this instance.
       
    63     * @param aObserver a pointer to connection observer.
       
    64     * @param aClipHandler a reference pointer to .rtp clip handler.
       
    65     * @return CCRRtpRecordSink pointer. 
       
    66     */
       
    67     static CCRRtpRecordSink* NewL( const SCRRecordParams& aRecordParams,
       
    68                                    CCRStreamingSession::TCRSinkId aSinkId,
       
    69                                    CCRStreamingSession& aOwningSession,
       
    70                                    MCRConnectionObserver* aObserver,
       
    71                                    CRtpClipHandler*& aClipHandler );
       
    72     
       
    73     /**
       
    74     * Destructor 
       
    75     */
       
    76     virtual ~CCRRtpRecordSink();
       
    77     
       
    78 protected: // Constructors and destructors
       
    79 
       
    80     /**
       
    81     * By default default constructor is private
       
    82     * @param aSinkId that this class needs to use when reporting progress back to owner.
       
    83     * @param aObserver a pointer to connection observer.
       
    84     * @param aClipHandler a reference pointer to .rtp clip handler.
       
    85     * @param aOwningSession is the streaming session that owns this instance.
       
    86     */
       
    87     CCRRtpRecordSink( CCRStreamingSession::TCRSinkId aSinkId,
       
    88                       CCRStreamingSession& aOwningSession,
       
    89                       MCRConnectionObserver* aObserver,
       
    90                       CRtpClipHandler*& aClipHandler );
       
    91 
       
    92     /**
       
    93     * Second phase of 2-phased construction
       
    94     * @param aRecordParams a recording parameters.
       
    95     */
       
    96     void ConstructL( const SCRRecordParams& aRecordParams ); 
       
    97 
       
    98 private: // Methods from base classes
       
    99     
       
   100     /**
       
   101     * From CCRPacketSinkBase.
       
   102     * Method for setting the sdp in use.
       
   103     * @since Series 60 3.0
       
   104     * @param aSdp is the new sdp.
       
   105     * @return none.
       
   106     */
       
   107     void SetSdpL( const TDesC8& aSdp );
       
   108     
       
   109     /**
       
   110     * From CCRPacketSinkBase.
       
   111     * Adds packet to the sink.
       
   112     * @since Series 60 3.0
       
   113     * @return none.
       
   114     */
       
   115     void NewPacketAvailable();
       
   116     
       
   117     /**
       
   118     * From CCRPacketSinkBase.
       
   119     * Buffer reset info for the sink.
       
   120     * @since Series 60 3.0
       
   121     * @return none.
       
   122     */
       
   123     void BufferResetDone();
       
   124     
       
   125     /**
       
   126     * From CCRPacketSinkBase.
       
   127     * Method for pause action for sink.
       
   128     * @since Series 60 3.0
       
   129     * @param none.
       
   130     * @return a system wide error code.
       
   131     */
       
   132     TInt Pause();
       
   133 
       
   134     /**
       
   135     * From CCRPacketSinkBase.
       
   136     * Method for restore action for sink.
       
   137     * @since Series 60 3.0
       
   138     * @param none.
       
   139     * @return a system wide error code.
       
   140     */
       
   141     TInt Restore();
       
   142 
       
   143     /**
       
   144     * From CCRPacketSinkBase.
       
   145     * Method for stopping action for sink.
       
   146     * @since Series 60 3.0
       
   147     * @param none.
       
   148     * @return none.
       
   149     */
       
   150     void Stop();
       
   151 
       
   152     /**
       
   153     * From MRtpFileWriteObserver.
       
   154     * Group saved indication.
       
   155     * @since Series 60 3.0
       
   156     * @return none.
       
   157     */
       
   158     void GroupSaved();
       
   159 
       
   160     /**
       
   161     * From MRtpFileWriteObserver.
       
   162     * Clip handler status of recording.
       
   163     * @since Series 60 3.0
       
   164     * @param aStatus a status of file writing.
       
   165     * @return none.
       
   166     */
       
   167     void WriteStatus( const TInt aStatus );
       
   168 
       
   169 private: // New methods
       
   170 
       
   171     /**
       
   172     * Adds RTP packet(s) to a group.
       
   173     * @since Series 60 3.0
       
   174     * @param none.
       
   175     * @return none.
       
   176     */
       
   177     void AddToGroup();
       
   178 
       
   179     /**
       
   180     * Adds one RTP packet to a group.
       
   181     * @since Series 60 3.0
       
   182     * @param aPacket a packet data.
       
   183     * @param aType a packet type.
       
   184     * @return none.
       
   185     */
       
   186     void AddPacketToGroupL( const TDesC8& aPacket,
       
   187                             const MRtpFileWriteObserver::TRtpType& aType );
       
   188 
       
   189     /**
       
   190     * Saves one RTP packet group to a clip.
       
   191     * @since Series 60 3.0
       
   192     * @param aAction a saving action.
       
   193     * @return none.
       
   194     */
       
   195     void SaveGroup( MRtpFileWriteObserver::TRtpSaveAction aAction );
       
   196 
       
   197     /**
       
   198     * Saves one RTP packet group to a clip.
       
   199     * @since Series 60 3.0
       
   200     * @param aAction a saving action.
       
   201     * @return none.
       
   202     */
       
   203     void SaveGroupL( MRtpFileWriteObserver::TRtpSaveAction aAction );
       
   204 
       
   205     /**
       
   206     * Converts stream id to old RTP propriatary format packet type.
       
   207     * @since Series 60 3.0
       
   208     * @param aType a packet type from a clip.
       
   209     * @param aStream a stream id to update.
       
   210     * @return true if packet valid, otherwise false.
       
   211     */
       
   212     TBool StreamToType( const MCRPacketSource::TCRPacketStreamId& aStream,
       
   213                         MRtpFileWriteObserver::TRtpType& aType );
       
   214 
       
   215     /**
       
   216     * Handles TS delta calculation from audio packets.
       
   217     * @since Series 60 3.0
       
   218     * @param aPacket a packet data.
       
   219     * @return a TS of packet.
       
   220     */
       
   221     TUint TsFromPacketL( const TDesC8& aPacket );
       
   222 
       
   223     /**
       
   224     * Wrapper for AddPausePacketL().
       
   225     * @since Series 60 3.0
       
   226     * @param none.
       
   227     * @return none.
       
   228     */
       
   229     void AddPausePacket();
       
   230 
       
   231     /**
       
   232     * Adds pause packet to group buffer.
       
   233     * @since Series 60 3.0
       
   234     * @param none.
       
   235     * @return none.
       
   236     */
       
   237     void AddPausePacketL();
       
   238 
       
   239     /**
       
   240     * Resets packets group variables.
       
   241     * @since Series 60 3.0
       
   242     * @param aStatus a reason for recording end.
       
   243     * @return none.
       
   244     */
       
   245     void ForceStopRecording( const TInt& aStatus );
       
   246 
       
   247     /**
       
   248     * Resets packets group variables.
       
   249     * @since Series 60 3.0
       
   250     * @param none.
       
   251     * @return none.
       
   252     */
       
   253     void ResetGroupVariables();
       
   254 
       
   255 private: // Data
       
   256 
       
   257     /**
       
   258     * Packets group buffer.
       
   259     */
       
   260     HBufC8* iGroupBuffer;
       
   261     
       
   262     /**
       
   263     * Connection status observer.
       
   264     */
       
   265     MCRConnectionObserver* iObserver;
       
   266     
       
   267     /**
       
   268     * Clip handler for RTP clip.
       
   269     */
       
   270     CRtpClipHandler*& iClipHandler;
       
   271 
       
   272     /**
       
   273     * Packets group pointer.
       
   274     */
       
   275     TPtr8 iGroupPointer;
       
   276     
       
   277     /**
       
   278     * Current group size in bytes.
       
   279     */
       
   280     TInt iGroupSize;
       
   281     
       
   282     /**
       
   283     * Current group packets count.
       
   284     */
       
   285     TInt iPacketsCount;
       
   286     
       
   287     /**
       
   288     * Wanted group size.
       
   289     */
       
   290     TInt iWantedGroup;
       
   291     
       
   292     /**
       
   293     * TS converter for audio.
       
   294     */
       
   295     CRtpTsConverter* iAudioConv;
       
   296 
       
   297     /**
       
   298     * Time stamp of oldest audio packet.
       
   299     */
       
   300     TUint iOldestTs;
       
   301     
       
   302     /**
       
   303     * Latest audio packet.
       
   304     */
       
   305     TPtrC8 iLatestAudio;
       
   306     
       
   307     /**
       
   308     * Record mode, can be either normal of time shift.
       
   309     */
       
   310     MRtpFileWriteObserver:: TRtpSaveAction iSaveMode;
       
   311     
       
   312     /**
       
   313     * Next packet(s) mode, can be: normal, pause, end.
       
   314     */
       
   315     MRtpFileWriteObserver:: TRtpSaveAction iGroupMode;
       
   316     
       
   317     /**
       
   318     * Recording parameters.
       
   319     */
       
   320     MRtpFileWriteObserver::SRtpRecParams iRecParams;
       
   321     
       
   322     };
       
   323 
       
   324 #endif // CCRRTPRECORDSINK_H
       
   325 
       
   326 //  End of File