dvrengine/CommonRecordingEngine/inc/CCRXpsSink.h
branchRCL_3
changeset 47 826cea16efd9
parent 45 798ee5f1972c
child 48 13a33d82ad98
equal deleted inserted replaced
45:798ee5f1972c 47:826cea16efd9
     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 XPS gets the streaming.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 #ifndef CCRXPSSINK_H
       
    20 #define CCRXPSSINK_H
       
    21 
       
    22 // INCLUDES
       
    23 #include "CCRPacketSinkBase.h"
       
    24 #include "MCRTimerObserver.h"
       
    25 #include "VideoServiceUtilsConf.hrh"
       
    26 #include <CXPSPktSinkObserver.h>
       
    27 #include <RtpDef.h>
       
    28 #include "videoserviceutilsLogger.h"
       
    29 #ifdef VIA_FEA_IPTV_USE_IPDC
       
    30 #include <H264Mpeg4GenrToFileFormat.h>
       
    31 #endif // VIA_FEA_IPTV_USE_IPDC
       
    32 
       
    33 // CONSTANTS
       
    34 // None
       
    35 
       
    36 // MACROS
       
    37 // None
       
    38 
       
    39 // DATA TYPES
       
    40 // None
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CCRPacketBuffer;
       
    44 class CXPSPacketSink;
       
    45 class CCRStreamingSession;
       
    46 class CRtpTsConverter;
       
    47 class CRtpPacket;
       
    48 class CCRTimer;
       
    49 
       
    50 // CLASS DECLARATION
       
    51 
       
    52 /**
       
    53 *  Packet sink that does not forward packets. Good for testing. 
       
    54 *
       
    55 *  @lib CommonRecordingEngine.lib
       
    56 *  @since Series 60 3.0
       
    57 */
       
    58 class CCRXpsSink : public CCRPacketSinkBase,
       
    59                    public MCRTimerObserver,
       
    60                    public MXPSPktSinkObserver
       
    61     {
       
    62 
       
    63 public: // Constructors and destructors   
       
    64     
       
    65     /**
       
    66     * Two-phased constructor.
       
    67     * @return CCRXpsSink pointer. 
       
    68     */
       
    69     static CCRXpsSink* NewL( CCRStreamingSession::TCRSinkId aSinkId,
       
    70                              CCRStreamingSession& aOwningSession );
       
    71     
       
    72     /**
       
    73     * Destructor 
       
    74     */
       
    75     virtual ~CCRXpsSink();
       
    76     
       
    77 protected: // Constructors and destructors
       
    78 
       
    79     /**
       
    80     * By default default constructor is private
       
    81     * @param aConnection is the IAP representative that we need to use
       
    82     * @param aSockServer is the socketserver to use when opening socks
       
    83     * @param aSinkId that this class needs to use when reporting progress back to owner
       
    84     * @param aOwningSession is the streaming session that owns this instance
       
    85     */
       
    86     CCRXpsSink( CCRStreamingSession::TCRSinkId aSinkId,
       
    87                 CCRStreamingSession& aOwningSession );
       
    88 
       
    89     /**
       
    90     * Second phase of 2-phased construction
       
    91     */
       
    92     void ConstructL(); 
       
    93 
       
    94 private: // Methods from base classes
       
    95     
       
    96     /**
       
    97     * From CCRPacketSinkBase.
       
    98     * Method for setting the sdp in use.
       
    99     * @since Series 60 3.0
       
   100     * @param aSdp is the new sdp.
       
   101     * @return none.
       
   102     */
       
   103     void SetSdpL( const TDesC8& aSdp );
       
   104     
       
   105     /**
       
   106     * From CCRPacketSinkBase.
       
   107     * Adds packet to the sink.
       
   108     * @since Series 60 3.0
       
   109     * @return none.
       
   110     */
       
   111     void NewPacketAvailable();
       
   112     
       
   113     /**
       
   114     * From CCRPacketSinkBase.
       
   115     * Buffer reset info for the sink.
       
   116     * @since Series 60 3.0
       
   117     * @return none.
       
   118     */
       
   119     void BufferResetDone();
       
   120     
       
   121     /**
       
   122     * From MCRTimerObserver.
       
   123     * The function to be called when a timeout occurs.
       
   124     * @since Series 60 3.0
       
   125     * @param aTimer a pointer to timer.
       
   126     * @return none.
       
   127     */
       
   128     void TimerExpired( CCRTimer* aTimer );
       
   129 
       
   130     /**
       
   131     * From MXPSPktSinkObserver.
       
   132     * API to inform for resumption of packet supply.
       
   133     * @since Series 60 3.0
       
   134     * @param uStreamId a stream id.
       
   135     * @return none.
       
   136     */
       
   137     void RestorePacketSupply( TUint uStreamId );
       
   138 
       
   139 private: // New methods
       
   140 
       
   141     /**
       
   142     * Restores sink for new packets.
       
   143     * @since Series 60 3.0
       
   144     * @param none.
       
   145     * @return none.
       
   146     */
       
   147     void RestoreSink();
       
   148 
       
   149     /**
       
   150     * Sends one RTP packet to a player.
       
   151     * @since Series 60 3.0
       
   152     * @param none.
       
   153     * @return ETrue if packet was sent, EFalse if not.
       
   154     */
       
   155     TBool SendPacket();
       
   156 
       
   157     /**
       
   158     * Adjust time stamp and enque audio packet to player.
       
   159     * @since Series 60 3.0
       
   160     * @param aPacket a packet payload to send.
       
   161     * @return a system wide error code of sending.
       
   162     */
       
   163     TInt SendAudioPacket( const TDesC8& aPacket );
       
   164 
       
   165     /**
       
   166     * Adjust time stamp and enque video packet to player.
       
   167     * @since Series 60 3.0
       
   168     * @param aPacket a packet payload to send.
       
   169     * @return a system wide error code of sending.
       
   170     */
       
   171     TInt SendVideoPacket( const TDesC8& aPacket );
       
   172 
       
   173     /**
       
   174     * Adjust time stamp and enque sub title packet to player.
       
   175     * @since Series 60 3.0
       
   176     * @param aPacket a packet payload to send.
       
   177     * @return a system wide error code of sending.
       
   178     */
       
   179     TInt SendTitlePacket( const TDesC8& aPacket );
       
   180 
       
   181     /**
       
   182     * Sends packet to the player.
       
   183     * @since Series 60 3.0
       
   184     * @param aStreamId a stream id of packet.
       
   185     * @return a system wide error code of sending.
       
   186     */
       
   187     TInt EnqueuePacket( const TUint aStreamId );
       
   188     
       
   189     /**
       
   190      * Serach if buffer contains control stream packets.
       
   191      * If not, in non continous stream ask more packets to buffer.  
       
   192      * 
       
   193      * @since S60 v3.0
       
   194      * @return none.
       
   195      */
       
   196     void SearchForControlStreamPackets();
       
   197 
       
   198     /**
       
   199      * Checks if the buffer contains control stream packets. This is needed
       
   200      * if we receive packets for stream that has not yet received any control
       
   201      * stream packets, so that we do not have to discard the packets. If any
       
   202      * control stream packets are found for a stream that has not been 
       
   203      * initiated, then that control stream packet is used to initiate that
       
   204      * stream.
       
   205      * 
       
   206      * @since S60 v3.0
       
   207      * @return ETrue if a control stream packet was found, EFalse othervise.
       
   208      */
       
   209     TBool CheckBufferForControlStreamPackets();
       
   210 
       
   211     /**
       
   212     * Starts flow timer.
       
   213     * @since Series 60 3.0
       
   214     * @param aInterval a timer interval.
       
   215     * @return none.
       
   216     */
       
   217     void StartTimer( const TInt& aInterval );
       
   218     
       
   219     /**
       
   220     * Starts flow timer.
       
   221     * @since Series 60 3.0
       
   222     * @param none.
       
   223     * @return none.
       
   224     */
       
   225     void StopTimer();
       
   226     
       
   227 #ifdef VIA_FEA_IPTV_USE_IPDC
       
   228     /**
       
   229     * Serach for fmtp string.
       
   230     * @since Series 60 3.0
       
   231     * @param aSdpData a SDP data.
       
   232     * @return smtp string from SDP.
       
   233     */
       
   234     HBufC8* FindFmtpLC( const TDesC8& aSdpData );
       
   235 
       
   236 #endif // VIA_FEA_IPTV_USE_IPDC
       
   237 
       
   238 private: // Data
       
   239 
       
   240     /**
       
   241     * XPS packet sink.
       
   242     */
       
   243     CXPSPacketSink* iPacketSink;
       
   244     
       
   245     /**
       
   246     * Status of XPS buffer.
       
   247     */
       
   248     TInt iWaitPlayer;
       
   249     
       
   250     /**
       
   251     * Requested packet after overflow.
       
   252     */
       
   253     TInt iRequested;
       
   254 
       
   255     /**
       
   256     * Status for XPS reset.
       
   257     */
       
   258     TBool iXpsResetOk;
       
   259     
       
   260     /**
       
   261     * Status of range.
       
   262     */
       
   263     TBool iRangeKnown;
       
   264 
       
   265     /**
       
   266     * Flow control timer.
       
   267     */
       
   268     CCRTimer* iFlowTimer;
       
   269     
       
   270     /**
       
   271     * Audio stream id for XPS.
       
   272     */
       
   273     TInt iAudioStreamId;
       
   274     
       
   275     /**
       
   276     * Audio stream id for XPS.
       
   277     */
       
   278     TInt iVideoStreamId;
       
   279     
       
   280     /**
       
   281     * Sub title stream id for XPS.
       
   282     */
       
   283     TInt iTitleStreamId;
       
   284     
       
   285     /**
       
   286     * TS converter for audio.
       
   287     */
       
   288     CRtpTsConverter* iAudioConv;
       
   289 
       
   290     /**
       
   291     * TS converter for video.
       
   292     */
       
   293     CRtpTsConverter* iVideoConv;
       
   294     
       
   295     /**
       
   296     * TS converter for video.
       
   297     */
       
   298     CRtpTsConverter* iTitleConv;
       
   299     
       
   300     /**
       
   301     * RTP packet to enqueue.
       
   302     */
       
   303     CRtpPacket* iRtpPacket;
       
   304     
       
   305 #ifdef VIA_FEA_IPTV_USE_IPDC
       
   306     /**
       
   307     * Depacketizer for video stream (ISMACryp).
       
   308     */
       
   309     CH264Mpeg4GenrToFileformat * iVideoDepacketizer;
       
   310 
       
   311 #endif // VIA_FEA_IPTV_USE_IPDC
       
   312 
       
   313 #if defined( LIVE_TV_RDEBUG_TRACE ) || defined( LIVE_TV_FILE_TRACE )
       
   314     /**
       
   315     * Debug purposes.
       
   316     */
       
   317     TInt iLogXps;
       
   318 
       
   319 #endif // LIVE_TV_RDEBUG_TRACE || LIVE_TV_FILE_TRACE
       
   320 
       
   321     };
       
   322 
       
   323 #endif // CCRXPSSINK_H
       
   324 
       
   325 //  End of File