dvrengine/CommonRecordingEngine/src/CCRRtpTcpStream.cpp
branchRCL_3
changeset 23 13a33d82ad98
parent 0 822a42b6c3f1
equal deleted inserted replaced
22:826cea16efd9 23: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:    Single media stream for RTP/TCP streamer*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CCRRtpTcpStream.h"
       
    22 #include "CCRRtpTcpObserver.h"
       
    23 #include <es_sock.h>
       
    24 #include <e32math.h>
       
    25 #include "videoserviceutilsLogger.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KReceiverReportLength( 12 );
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CCRRtpTcpStream::CCRRtpTcpStream
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CCRRtpTcpStream::CCRRtpTcpStream( MCRRtpTcpObserver& aObserver )
       
    37   : iObserver(aObserver)
       
    38     {
       
    39     iSSRC = Math::Random();
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CCRRtpTcpStream::NewL
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CCRRtpTcpStream* CCRRtpTcpStream::NewL( MCRRtpTcpObserver& aObserver )
       
    47     {
       
    48     CCRRtpTcpStream* self = new( ELeave ) CCRRtpTcpStream( aObserver );
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     CleanupStack::Pop( self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CCRRtpTcpStream::ConstructL
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CCRRtpTcpStream::ConstructL()
       
    60     {
       
    61     // None
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CCRRtpTcpStream::~CCRRtpTcpStream
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CCRRtpTcpStream::~CCRRtpTcpStream()
       
    69     {
       
    70     // None
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CCRRtpTcpStream::ForwardPacketAvailable
       
    75 // -----------------------------------------------------------------------------
       
    76 //
       
    77 void CCRRtpTcpStream::PacketAvailable( TInt aChannel )
       
    78     {
       
    79     // Nothing to to do for RTP, just ignore
       
    80     if ( !( aChannel % 2 ) )
       
    81         {
       
    82         return;
       
    83         }
       
    84 
       
    85     // Very simple Receiver Report generation:
       
    86     // - RC=0, no SSRC report blocks -> no statistics keeping
       
    87     // - one RR for every SR received -> no timing, back-off, etc
       
    88     TBuf8<KReceiverReportLength> chunk( KNullDesC8 );
       
    89     chunk.SetLength( KReceiverReportLength );
       
    90 
       
    91     // RTSP header
       
    92     chunk[0] = ( TUint8 )( 0x24 );     // magic '$' for embedded binary in RTSP     
       
    93     chunk[1] = ( TUint8 )( aChannel ); // enbedded RTSP channel
       
    94     // Embedded packet length, fixed
       
    95     BigEndian::Put16( ( TUint8* )chunk.Ptr() + 2, 8 ); 
       
    96 
       
    97     // RR
       
    98     chunk[4] = 0x80; // v=2, p=0, rc=0
       
    99     chunk[5] = 201;  // PT= RR= 201
       
   100     // Length=1 ( in 32bits, -1 )
       
   101     BigEndian::Put16( ( TUint8* )chunk.Ptr() + 6, 1 );     
       
   102     BigEndian::Put32( ( TUint8* )chunk.Ptr() + 8, iSSRC );
       
   103 
       
   104     iObserver.ForwardRtpTcpChunck( chunk );
       
   105     }
       
   106 
       
   107 //  End of File