dvrengine/CommonRecordingEngine/src/CCRRTSPCommon.cpp
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:    RTSP command/response common part*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CRRtspCommon.h"
       
    22 #include "videoserviceutilsLogger.h"
       
    23 
       
    24 // CONSTANTS
       
    25 const TReal KRealZero( 0.0 ); 
       
    26 const TReal KRealMinusOne( -1.0 ); 
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CCRRtspCommon::CCRRtspCommon
       
    32 // C++ default constructor can NOT contain any code, that might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CCRRtspCommon::CCRRtspCommon ()
       
    36   : iContentLen( KErrNotFound ),
       
    37     iContent( NULL, 0 ),
       
    38     iCSeq( KErrNotFound ),
       
    39     iSessionId( NULL, 0 ),
       
    40     iClientPort( KErrNotFound ),
       
    41     iLowerRange( KRealZero ),
       
    42     iUpperRange( KRealMinusOne ),
       
    43     iIsLiveStream( EFalse )
       
    44     {  
       
    45     // None
       
    46     }
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CCRRtspCommon::~CCRRtspCommon
       
    50 // Destructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CCRRtspCommon::~CCRRtspCommon()
       
    54     {
       
    55     LOG( "CCRRtspCommon::~CCRRtspCommon()" );
       
    56 
       
    57     delete iRtspText; 
       
    58     delete iRealm;
       
    59     delete iOpaque;
       
    60     delete iNonce;
       
    61     delete iUserName;
       
    62     delete iUri; 
       
    63     delete iPassword;
       
    64     delete iAuthType;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CCRRtspCommon::CSeq
       
    69 // 
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 TInt CCRRtspCommon::CSeq( void ) 
       
    73     {
       
    74     return iCSeq;   
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CCRRtspCommon::SetCSeq
       
    79 // 
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 void CCRRtspCommon::SetCSeq( TInt aCSeq ) 
       
    83     {
       
    84     iCSeq = aCSeq;  
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // CCRRtspCommon::FindCSeqL
       
    89 // 
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CCRRtspCommon::FindCSeqL( void ) 
       
    93     {
       
    94     TInt offSet( iRtspText->FindC( KCRCSeq() ) ); 
       
    95     if ( offSet == KErrNotFound ) 
       
    96         {
       
    97         LOG( "CCRRtspCommon::FindCSeqL FAILED, 'CSeq' not found [1]" );
       
    98         User::Leave ( KErrNotSupported ); 
       
    99         }
       
   100     
       
   101     offSet += KCRCSeq().Length();       
       
   102     TInt eolOffSet = iRtspText->Right ( iRtspText->Length() - 
       
   103                                         offSet ).Find ( KCRNewLine() ); 
       
   104     if ( eolOffSet == KErrNotFound ) 
       
   105         {
       
   106         LOG1( "CCRRtspCommon::FindCSeqL FAILED, 'CSeq' not found [2], offset=%d", offSet );
       
   107         User::Leave ( KErrNotSupported ); 
       
   108         }
       
   109     TPtrC8 CSeqString ( iRtspText->Mid ( offSet, eolOffSet ) );     
       
   110     TLex8 CSeqNumberLex( CSeqString ); 
       
   111     User::LeaveIfError ( CSeqNumberLex.Val( iCSeq ) ) ;
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CCRRtspCommon::FindSessionIdL
       
   116 //
       
   117 // method that finds session id from RTSP response
       
   118 // -----------------------------------------------------------------------------
       
   119 //  
       
   120 void CCRRtspCommon::FindSessionIdL( void ) 
       
   121     {
       
   122     iSessionId.Set( NULL, 0 );
       
   123     TInt sessionStringOffset( iRtspText->FindC( KCRNlAndSession() ) );
       
   124     if ( sessionStringOffset > 0 )
       
   125         {
       
   126         TPtrC8 beginningFromSession( iRtspText->Right( iRtspText->Length() - 
       
   127                                    ( sessionStringOffset + 11 ) ) );
       
   128         TInt lfStringOffset( beginningFromSession.Find( KCRNewLine ) );
       
   129         if ( lfStringOffset != KErrNotFound )
       
   130             {
       
   131             iSessionId.Set( beginningFromSession.Mid( 0, lfStringOffset ) );
       
   132             // with some servers there is;Timeout=xxx after the session id; 
       
   133             // lets strip that out:
       
   134             TInt semicolonOffset( iSessionId.Locate( ';' ) ); 
       
   135             if ( semicolonOffset > 0 )
       
   136                 {
       
   137                 iSessionId.Set( iSessionId.Mid( 0, semicolonOffset ) ); 
       
   138                 }
       
   139             }
       
   140         }
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CCRRtspCommon::SessionId
       
   145 //
       
   146 // method that returns session id string
       
   147 // -----------------------------------------------------------------------------
       
   148 //  
       
   149 TInt CCRRtspCommon::SessionId( TPtrC8& aId ) 
       
   150     {
       
   151     if ( iSessionId.Ptr() != NULL )     
       
   152         {
       
   153         aId.Set( iSessionId ); 
       
   154         return KErrNone;
       
   155         }
       
   156     else
       
   157         {
       
   158         return KErrNotFound; 
       
   159         }       
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CCRRtspCommon::SetSessionId
       
   164 //
       
   165 // 
       
   166 // -----------------------------------------------------------------------------
       
   167 //  
       
   168 void CCRRtspCommon::SetSessionId( TPtrC8& aId ) 
       
   169     {
       
   170     iSessionId.Set( aId ); 
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // CCRRtspCommon::FindContentL
       
   175 //
       
   176 // 
       
   177 // -----------------------------------------------------------------------------
       
   178 //  
       
   179 void CCRRtspCommon::FindContentL( void ) 
       
   180     {
       
   181 #ifdef _DEBUG       
       
   182     _LIT(KPanicStr, "RTSPCommon"); 
       
   183     __ASSERT_DEBUG( iRtspText, 
       
   184                     User::Panic( KPanicStr, KErrBadHandle ) );
       
   185 #endif                    
       
   186     // find possible content:
       
   187     //
       
   188     TInt replyEndOffSet( iRtspText->Find( KCR2NewLines ) );
       
   189     if ( replyEndOffSet > KErrNotFound )
       
   190         {
       
   191         replyEndOffSet += KCR2NewLines().Length();
       
   192         }
       
   193     
       
   194     // next thing to check if there is content-length-header, 
       
   195     // it seems like it may follow about any response..
       
   196     //
       
   197     TInt contentLenOffset( KErrNotFound ); 
       
   198     iContentLen = KErrNotFound; // this will hold (usually SDP) length
       
   199     if ( ( contentLenOffset = iRtspText->Des().FindC( 
       
   200                               KCRRTSPContentLength() ) ) != KErrNotFound )
       
   201         {
       
   202         TLex8 contentLenLex( iRtspText->Des().Mid( contentLenOffset + 16, 5 ) );
       
   203         User::LeaveIfError( contentLenLex.Val( iContentLen ) ); 
       
   204         }
       
   205     
       
   206     LOG1( "CCRRtspCommon::FindContentL(), iContentLen: %d", iContentLen );                       
       
   207 
       
   208     // then set content in place    
       
   209     if ( replyEndOffSet > iRtspText->Length() )
       
   210         {
       
   211         LOG( "CCRRtspCommon::FindContentL() out because too litle data !" );
       
   212         User::Leave( KErrUnderflow ); 
       
   213         }
       
   214     if ( iContentLen > KErrNotFound )
       
   215         {   
       
   216         iContent.Set( iRtspText->Des().Mid( replyEndOffSet, iContentLen ) );
       
   217         }
       
   218     else
       
   219         {
       
   220         iContent.Set( NULL, 0 );
       
   221         }
       
   222     }
       
   223     
       
   224 // -----------------------------------------------------------------------------
       
   225 // CCRRtspCommon::ContentLen
       
   226 // 
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 TInt CCRRtspCommon::ContentLen( void ) 
       
   230     {
       
   231     return iContentLen; 
       
   232     }
       
   233         
       
   234 // -----------------------------------------------------------------------------
       
   235 // CCRRtspCommon::Content
       
   236 // 
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 TPtrC8& CCRRtspCommon::Content( void ) 
       
   240     {
       
   241     return iContent ; 
       
   242     }
       
   243 
       
   244 // -----------------------------------------------------------------------------
       
   245 // CCRRtspCommon::FindClientPorts
       
   246 //
       
   247 // method that finds client port numeric value
       
   248 // -----------------------------------------------------------------------------
       
   249 //  
       
   250 void CCRRtspCommon::FindClientPorts( void )
       
   251     {
       
   252     iClientPort = KErrNotFound;
       
   253 
       
   254     // Bend concept of client port to mean also the interleaved channel for TCP streaming
       
   255     const TDesC8& portdes( ( iTransport == ERTPOverTCP )? KCRInterleaved():
       
   256                            ( iTransport == ERTPOverMulticast )? KCRPort():
       
   257                             KCRClient_Port() );
       
   258 
       
   259     TInt portNumberOffset( iRtspText->FindC( portdes ) ); 
       
   260     if ( portNumberOffset != KErrNotFound )
       
   261         {
       
   262         TPtrC8 portNumberStr( iRtspText->Mid( portNumberOffset + portdes.Length() ) );
       
   263         TInt endoffset = portNumberStr.FindC( KCRDash() );
       
   264         if ( endoffset >= 0 )
       
   265             {
       
   266             portNumberStr.Set( portNumberStr.Left( endoffset ) );
       
   267             }
       
   268         else
       
   269             {
       
   270             endoffset = portNumberStr.FindC( KCRSemiColon() );
       
   271             if ( endoffset >= 0 )
       
   272                 {
       
   273                 portNumberStr.Set( portNumberStr.Left( endoffset ) );
       
   274                 }
       
   275             }
       
   276         TLex8 portNumberLex( portNumberStr );
       
   277         if ( portNumberLex.Val( iClientPort ) != KErrNone )
       
   278             { // something wrong? 
       
   279             LOG( "CCRRtspCommon::FindClientPorts val != KErrNone" );
       
   280             }
       
   281         }
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // CCRRtspCommon::ClientPort
       
   286 //
       
   287 // method that returns client port numeric value
       
   288 // -----------------------------------------------------------------------------
       
   289 //  
       
   290 TInt CCRRtspCommon::ClientPort( void )
       
   291     {
       
   292     return iClientPort; 
       
   293     }
       
   294     
       
   295 // -----------------------------------------------------------------------------
       
   296 // CCRRtspCommon::SetClientPort
       
   297 //
       
   298 // method that sets client port numeric value
       
   299 // -----------------------------------------------------------------------------
       
   300 //  
       
   301 void CCRRtspCommon::SetClientPort( TInt aPort )
       
   302     {
       
   303     iClientPort = aPort; 
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CCRRtspCommon::FindTransport
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void CCRRtspCommon::FindTransport()
       
   311     {
       
   312     // User TCP streaming if 'RTP/AVP/TCP' found
       
   313     if ( iRtspText->FindC( KCRSDPRTPAVPTCP ) != KErrNotFound )
       
   314         {
       
   315         iTransport = ERTPOverTCP;
       
   316         }
       
   317     // multicast UDP if 'multicast' present
       
   318     else if ( iRtspText->FindC( KCRSDPMulticast ) != KErrNotFound ||
       
   319               iRtspText->FindC( KCRSDPRTPAVPUDP ) != KErrNotFound &&
       
   320               iRtspText->FindC( KCRDestination )  != KErrNotFound )
       
   321         {
       
   322         iTransport = ERTPOverMulticast;
       
   323         }
       
   324     // otherwise, plain unicast UDP
       
   325     else
       
   326         {
       
   327         iTransport = ERTPOverUDP;
       
   328         }
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CCRRtspCommon::Transport
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 TCRRTPTransport CCRRtspCommon::Transport()
       
   336     {
       
   337     return iTransport;
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CCRRtspCommon::SetTransport
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CCRRtspCommon::SetTransport( TCRRTPTransport aTransport )
       
   345     {
       
   346     iTransport = aTransport; 
       
   347     }
       
   348 
       
   349 // -----------------------------------------------------------------------------
       
   350 // CCRRtspCommon::FindDestination
       
   351 // -----------------------------------------------------------------------------
       
   352 //
       
   353 void CCRRtspCommon::FindDestination()
       
   354     {
       
   355     // resets destination to KAFUnspec
       
   356     iDestination = TInetAddr();
       
   357 
       
   358     // search for destination
       
   359     TInt startoffset = iRtspText->FindC( KCRDestination() );
       
   360     if ( startoffset >= 0 )
       
   361         {
       
   362         startoffset += KCRDestination().Length();
       
   363         TPtrC8 destdes = iRtspText->Mid( startoffset );
       
   364         TInt endoffset = destdes.FindC( KCRSemiColon() );
       
   365         if ( endoffset >= 0 )
       
   366             {
       
   367             destdes.Set( destdes.Left(endoffset) );
       
   368             }
       
   369 
       
   370         TBuf<128> destbuf;
       
   371         destbuf.Copy( destdes.Left(128) );
       
   372         TInt err = iDestination.Input( destbuf );
       
   373         if ( err != KErrNone )
       
   374             {
       
   375             LOG1( "CCRRtspCommon::FindDestination(), INVALID destination address '%S'", &destbuf );
       
   376             }
       
   377         else
       
   378             {
       
   379             LOG1( "CCRRtspCommon::FindDestination(), multicast address '%S'", &destbuf );
       
   380             iDestination.ConvertToV4Mapped();
       
   381             }
       
   382         }
       
   383     }
       
   384 
       
   385 // -----------------------------------------------------------------------------
       
   386 // CCRRtspCommon::Destination
       
   387 // -----------------------------------------------------------------------------
       
   388 //
       
   389 const TInetAddr& CCRRtspCommon::Destination()
       
   390     {
       
   391     return iDestination;
       
   392     }
       
   393 
       
   394 // -----------------------------------------------------------------------------
       
   395 // CCRRtspCommon::SetRange
       
   396 //
       
   397 // method that sets Range: header values
       
   398 // -----------------------------------------------------------------------------
       
   399 //  
       
   400 void CCRRtspCommon::SetRange( TReal aLower , TReal aUpper ) 
       
   401     {
       
   402     iLowerRange = aLower; 
       
   403     iUpperRange = aUpper; 
       
   404     }
       
   405 
       
   406 // -----------------------------------------------------------------------------
       
   407 // CCRRtspCommon::GetRange
       
   408 //
       
   409 // method that gets Range: header values
       
   410 // -----------------------------------------------------------------------------
       
   411 //  
       
   412 void CCRRtspCommon::GetRange( TReal& aLower , TReal& aUpper ) 
       
   413     {
       
   414     aLower = iLowerRange; 
       
   415     aUpper = iUpperRange; 
       
   416     }
       
   417 
       
   418 // -----------------------------------------------------------------------------
       
   419 // CCRRtspCommon::ParseRange
       
   420 //
       
   421 // method that tries to parse contents of possible Range: header 
       
   422 // -----------------------------------------------------------------------------
       
   423 //  
       
   424 void CCRRtspCommon::ParseRange( void ) 
       
   425     {
       
   426     if ( iRtspText )
       
   427         {
       
   428         TInt rangeHeaderOffset( iRtspText->Des().FindC( KCRRangeHeader ) );
       
   429         if ( rangeHeaderOffset > 0 )
       
   430             {
       
   431             // check for live-stream specific range "Range: npt=now-"
       
   432             if ( iRtspText->Des().FindC( KCRRangeHeaderLiveStream ) > KErrNotFound )
       
   433                 { // yes, this is a live stream
       
   434                 iLowerRange = KRealZero; 
       
   435                 iUpperRange = KRealMinusOne; 
       
   436                 iIsLiveStream = ETrue; 
       
   437                 LOG( "CCRRtspCommon::ParseRange(), Found livestream range" );
       
   438                 }
       
   439             else
       
   440                 {
       
   441                 TPtrC8 rangeHeader = iRtspText->Des().Mid(
       
   442                                      rangeHeaderOffset + KCRRangeHeader().Length() ); 
       
   443                 TInt minusSignOffset( rangeHeader.Locate( '-' ) ); 
       
   444                 if ( minusSignOffset > 0 ) 
       
   445                     {
       
   446                     TPtrC8 startPosStr = rangeHeader.Left( minusSignOffset ); 
       
   447                     TLex8 startPosLex ( startPosStr ); 
       
   448                     startPosLex.Val ( iLowerRange ) ; // if .Val fails, value will just remain zero
       
   449                     LOG1( "CCRRtspCommon::ParseRange(), start: %f", iLowerRange );
       
   450                     }
       
   451 
       
   452                 TInt lineFeedOffset( rangeHeader.Locate( '\n' ) );
       
   453                 if ( lineFeedOffset > ( minusSignOffset + 2 ) )
       
   454                     {
       
   455                     TPtrC8 endPosStr = rangeHeader.Mid( minusSignOffset + 1,
       
   456                                        lineFeedOffset - ( minusSignOffset + 1 ) ); 
       
   457                     TLex8 endPosLex ( endPosStr ); 
       
   458                     endPosLex.Val ( iUpperRange ) ; // if .Val fails, value will just remain -1.0
       
   459                     LOG1( "CCRRtspCommon::ParseRange(), end: %f", iUpperRange );
       
   460                     }
       
   461                 else
       
   462                     {
       
   463                     iUpperRange = KRealMinusOne; 
       
   464                     LOG( "CCRRtspCommon::ParseRange(), Setting end range to -1.0" );
       
   465                     }
       
   466                 }
       
   467             }
       
   468         }   
       
   469     }
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // CCRRTSPResponse::AuthenticationTypeL
       
   473 //
       
   474 // method that returns authentication type
       
   475 // -----------------------------------------------------------------------------
       
   476 //  
       
   477 
       
   478 TDesC8& CCRRtspCommon::AuthenticationTypeL( void )
       
   479     {
       
   480     if ( !iAuthType )
       
   481         {
       
   482         iAuthType = HBufC8::NewL( 0 );
       
   483         }
       
   484     
       
   485     return *iAuthType;
       
   486     }
       
   487 
       
   488 // -----------------------------------------------------------------------------
       
   489 // CCRRTSPResponse::NonceL
       
   490 //
       
   491 // method that returns session nonce
       
   492 // -----------------------------------------------------------------------------
       
   493 //  
       
   494 TDesC8& CCRRtspCommon::NonceL( void )
       
   495     {   
       
   496     if ( !iNonce )
       
   497         {           
       
   498         iNonce = HBufC8::NewL( 0 );
       
   499         }   
       
   500     
       
   501     return *iNonce;
       
   502     }
       
   503     
       
   504 // -----------------------------------------------------------------------------
       
   505 // CCRRTSPResponse::RealmL
       
   506 //
       
   507 // method that returns session realm
       
   508 // -----------------------------------------------------------------------------
       
   509 //  
       
   510 TDesC8& CCRRtspCommon::RealmL( void )
       
   511     {   
       
   512     if ( !iRealm )
       
   513         {           
       
   514         iRealm = HBufC8::NewL( 0 );
       
   515         }
       
   516     
       
   517     return *iRealm;
       
   518     }
       
   519     
       
   520 // -----------------------------------------------------------------------------
       
   521 // CCRRTSPResponse::OpaqueL
       
   522 //
       
   523 // method that returns session opaque value
       
   524 // -----------------------------------------------------------------------------
       
   525 //  
       
   526 TDesC8& CCRRtspCommon::OpaqueL( void )
       
   527     {
       
   528     if ( !iOpaque )
       
   529         {           
       
   530         iOpaque = HBufC8::NewL( 0 );
       
   531         }
       
   532     
       
   533     return *iOpaque;
       
   534     }
       
   535 
       
   536 // -----------------------------------------------------------------------------
       
   537 // CCRRTSPResponse::SetNonce
       
   538 //
       
   539 // method that sets session nonce
       
   540 // -----------------------------------------------------------------------------
       
   541 //  
       
   542 void CCRRtspCommon::SetNonceL( const TDesC& aNonce )
       
   543     {
       
   544     delete iNonce; iNonce = NULL;
       
   545     iNonce = HBufC8::NewL( aNonce.Length() ); 
       
   546     iNonce->Des().Copy( aNonce );   
       
   547     }
       
   548     
       
   549 // -----------------------------------------------------------------------------
       
   550 // CCRRTSPResponse::SetNonce
       
   551 //
       
   552 // method that sets session nonce
       
   553 // -----------------------------------------------------------------------------
       
   554 //  
       
   555 void CCRRtspCommon::SetNonceL( const TDesC8& aNonce )
       
   556     {
       
   557     delete iNonce; iNonce = NULL;
       
   558     iNonce = aNonce.AllocL();
       
   559     }
       
   560 
       
   561 // -----------------------------------------------------------------------------
       
   562 // CCRRTSPResponse::SetAuthenticationTypeL
       
   563 //
       
   564 // method that sets authentication type
       
   565 // -----------------------------------------------------------------------------
       
   566 //
       
   567 void CCRRtspCommon::SetAuthenticationTypeL( const TDesC8& aAuthType )
       
   568     {
       
   569     delete iAuthType;
       
   570     iAuthType = NULL;
       
   571     iAuthType = aAuthType.AllocL();
       
   572     }
       
   573 
       
   574 // -----------------------------------------------------------------------------
       
   575 // CCRRTSPResponse::SetRealmL
       
   576 //
       
   577 // method that sets session realm
       
   578 // -----------------------------------------------------------------------------
       
   579 //  
       
   580 void CCRRtspCommon::SetRealmL( const TDesC& aRealm )
       
   581     {
       
   582     delete iRealm; iRealm = NULL;
       
   583     iRealm = HBufC8::NewL( aRealm.Length()); 
       
   584     iRealm->Des().Copy( aRealm );   
       
   585     }
       
   586 
       
   587 // -----------------------------------------------------------------------------
       
   588 // CCRRTSPResponse::SetRealmL
       
   589 //
       
   590 // method that sets session realm
       
   591 // -----------------------------------------------------------------------------
       
   592 //  
       
   593 void CCRRtspCommon::SetRealmL( const TDesC8& aRealm )
       
   594     {
       
   595     delete iRealm; iRealm = NULL;
       
   596     iRealm = aRealm.AllocL();   
       
   597     }
       
   598 
       
   599 // -----------------------------------------------------------------------------
       
   600 // CCRRTSPResponse::SetOpaqueL
       
   601 //
       
   602 // method that sets session opaque
       
   603 // -----------------------------------------------------------------------------
       
   604 //  
       
   605 void CCRRtspCommon::SetOpaqueL( const TDesC& aOpaque )
       
   606     {
       
   607     delete iOpaque; iOpaque = NULL;
       
   608     iOpaque = HBufC8::NewL( aOpaque.Length()); 
       
   609     iOpaque->Des().Copy( aOpaque ); 
       
   610     }
       
   611     
       
   612 // -----------------------------------------------------------------------------
       
   613 // CCRRTSPResponse::SetOpaqueL
       
   614 //
       
   615 // method that sets session opaque
       
   616 // -----------------------------------------------------------------------------
       
   617 //  
       
   618 void CCRRtspCommon::SetOpaqueL( const TDesC8& aOpaque )
       
   619     {
       
   620     delete iOpaque; iOpaque = NULL;
       
   621     iOpaque = aOpaque.AllocL(); 
       
   622     }
       
   623     
       
   624 // -----------------------------------------------------------------------------
       
   625 // CCRRTSPResponse::SetUserNameL
       
   626 //
       
   627 // method that sets session user name
       
   628 // -----------------------------------------------------------------------------
       
   629 //  
       
   630 void CCRRtspCommon::SetUserNameL( const TDesC& aUserName )
       
   631     {
       
   632     delete iUserName; iUserName = NULL;
       
   633     iUserName = HBufC8::NewL( aUserName.Length() ); 
       
   634     iUserName->Des().Copy( aUserName );
       
   635     }
       
   636     
       
   637 // -----------------------------------------------------------------------------
       
   638 // CCRRtspCommon::SetPassWdL
       
   639 //
       
   640 // method that sets session password
       
   641 // -----------------------------------------------------------------------------
       
   642 //  
       
   643 void CCRRtspCommon::SetPassWdL( const TDesC& aPassWd )
       
   644     {
       
   645     delete iPassword; iPassword = NULL;
       
   646     iPassword = HBufC8::NewL( aPassWd.Length() ); 
       
   647     iPassword->Des().Copy( aPassWd );
       
   648     }
       
   649     
       
   650 // -----------------------------------------------------------------------------
       
   651 // CCRRtspCommon::SetRtspUriL
       
   652 //
       
   653 // method that sets session uri
       
   654 // -----------------------------------------------------------------------------
       
   655 //  
       
   656 void CCRRtspCommon::SetRtspUriL( const TDesC& aUri )
       
   657     {
       
   658     delete iUri; iUri = NULL;
       
   659     iUri = HBufC8::NewL( aUri.Length() ); 
       
   660     iUri->Des().Copy( aUri );
       
   661     }
       
   662 
       
   663 // -----------------------------------------------------------------------------
       
   664 // CCRRtspCommon::IsLiveStream
       
   665 //
       
   666 // getter method for livelihood of a stream
       
   667 // -----------------------------------------------------------------------------
       
   668 //  
       
   669 TBool CCRRtspCommon::IsLiveStream( void )
       
   670     {
       
   671     return iIsLiveStream; 
       
   672     }
       
   673  
       
   674 // -----------------------------------------------------------------------------
       
   675 // CCRRtspCommon::FindContentBase
       
   676 //
       
   677 // -----------------------------------------------------------------------------
       
   678 //  
       
   679 void CCRRtspCommon::FindContentBase( void )
       
   680     {
       
   681     iContentBase.Set( NULL, 0 );
       
   682     TInt cbStringOffset( iRtspText->FindC( KCRContentBaseHeader() ) );
       
   683     if ( cbStringOffset > 0 )
       
   684         {
       
   685         TPtrC8 beginningFromCb( iRtspText->Right( iRtspText->Length() - 
       
   686                               ( cbStringOffset + KCRContentBaseHeader().Length() ) ) );
       
   687         TInt lfStringOffset( beginningFromCb.Find( KCRNewLine ) );
       
   688         if ( lfStringOffset != KErrNotFound )
       
   689             {
       
   690             LOG1( "### setting content-base, len = %d", lfStringOffset - 1 );
       
   691             iContentBase.Set( beginningFromCb.Mid( 0, lfStringOffset - 1 ) ); // -1 to cut trailing /
       
   692             }
       
   693         }
       
   694     }
       
   695 // -----------------------------------------------------------------------------
       
   696 // CCRRtspCommon::ContentBase
       
   697 //
       
   698 // -----------------------------------------------------------------------------
       
   699 //  
       
   700 TPtrC8 CCRRtspCommon::ContentBase( void )
       
   701     {
       
   702     return iContentBase;
       
   703     }
       
   704 
       
   705 //  End of File
       
   706