mmsharing/mmshengine/src/musenglivesession.cpp
changeset 15 ccd8e69b5392
parent 2 b31261fd4e04
child 20 e8be2c2e049d
child 22 496ad160a278
equal deleted inserted replaced
2:b31261fd4e04 15:ccd8e69b5392
     1 /*
       
     2 * Copyright (c) 2005 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 "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: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // USER
       
    20 #include "musenglivesession.h"
       
    21 #include "musengsessionobserver.h"
       
    22 #include "musenglivesessionobserver.h"
       
    23 #include "musunittesting.h"
       
    24 #include "musengmceutils.h"
       
    25 #include "musenglogger.h"
       
    26 #include "mussettings.h"
       
    27 
       
    28 // SYSTEM
       
    29 #include <mcemanager.h>
       
    30 #include <mcecamerasource.h>
       
    31 #include <mcevideostream.h>
       
    32 #include <mcertpsink.h>
       
    33 #include <mcedisplaysink.h>
       
    34 #include <mcefilesink.h>
       
    35 #include <mcesession.h>
       
    36 #include <mcevideocodec.h>
       
    37 #include <mceh263codec.h>
       
    38 #include <mceavccodec.h>
       
    39 
       
    40 const TInt KMaxBrightness = 100;
       
    41 const TInt KMinBrightness = -100;
       
    42 const TInt KBrightnessStepSize = 10;
       
    43 
       
    44 // Names of AVC levels in string for config keys stored in CenRep 
       
    45 _LIT8( KMusAvcBitrateLevel1, "AvcBrL1=" );
       
    46 _LIT8( KMusAvcBitrateLevel1b, "AvcBrL1b=" );
       
    47 _LIT8( KMusAvcBitrateLevel1_1, "AvcBrL1_1=" );
       
    48 _LIT8( KMusAvcBitrateLevel1_2, "AvcBrL1_2=" );
       
    49 _LIT8( KMusAvcBitrateLevel1_3, "AvcBrL1_3=" );
       
    50 _LIT8( KMusAvcBitrateLevel2, "AvcBrL2=" );
       
    51 
       
    52 _LIT8( KMusEncoderInfoTokenizer, ";" );
       
    53 
       
    54 //Number of big and small zoom steps on Zoom scale
       
    55 const TInt KZoomBigStepCount = 15;
       
    56 const TInt KZoomSmallStepCount = KZoomBigStepCount*2;
       
    57 const TInt KZoomStepMinSize = 1;
       
    58 
       
    59 const TInt64 KZoomFasterTime = 333333; // 1/3 second
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C CMusEngLiveSession* CMusEngLiveSession::NewL(
       
    66                         const TDesC& aFileName,
       
    67                         const TRect& aRect,
       
    68                         MMusEngSessionObserver& aSessionObserver,
       
    69                         MMusEngOutSessionObserver& aOutSessionObserver,
       
    70                         MMusEngLiveSessionObserver& aLiveSessionObserver,
       
    71                         TUint aSipProfileId )
       
    72     {
       
    73     CMusEngLiveSession* self = new( ELeave ) CMusEngLiveSession( 
       
    74                                                     aSessionObserver,
       
    75                                                     aOutSessionObserver,
       
    76                                                     aLiveSessionObserver, 
       
    77                                                     aRect,
       
    78                                                     aFileName );
       
    79     CleanupStack::PushL( self );
       
    80     self->ConstructL( aSipProfileId );
       
    81     CleanupStack::Pop( self );
       
    82     return self;
       
    83     }
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 EXPORT_C CMusEngLiveSession* CMusEngLiveSession::NewL(
       
    91                         const TRect& aRect,
       
    92                         MMusEngSessionObserver& aSessionObserver,
       
    93                         MMusEngOutSessionObserver& aOutSessionObserver,
       
    94                         MMusEngLiveSessionObserver& aLiveSessionObserver,
       
    95                         TUint aSipProfileId )
       
    96     {
       
    97     CMusEngLiveSession* self = new( ELeave ) CMusEngLiveSession( 
       
    98                                                     aSessionObserver,
       
    99                                                     aOutSessionObserver,
       
   100                                                     aLiveSessionObserver, 
       
   101                                                     aRect );
       
   102     CleanupStack::PushL( self );
       
   103     self->ConstructL( aSipProfileId );
       
   104     CleanupStack::Pop( self );
       
   105     return self;
       
   106     }
       
   107 
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 CMusEngLiveSession::~CMusEngLiveSession()
       
   114     {
       
   115     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::~CMusEngLiveSession()" )
       
   116     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::~CMusEngLiveSession()" )
       
   117     }
       
   118 
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 EXPORT_C TInt CMusEngLiveSession::CurrentZoomL() const
       
   125     {
       
   126     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::CurrentZoomL()" )
       
   127     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   128 
       
   129     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   130 
       
   131     TInt currentZoom = camera->ZoomFactorL() + camera->DigitalZoomFactorL();
       
   132 
       
   133     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::CurrentZoomL( %d )",
       
   134               currentZoom )
       
   135 
       
   136     return currentZoom;
       
   137     }
       
   138 
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C void CMusEngLiveSession::SetZoomL( TInt aNewZoomFactor )
       
   145     {
       
   146     MUS_LOG1( "mus: [ENGINE]  -> CMusEngLiveSession::SetZoomL( %d )", 
       
   147               aNewZoomFactor )
       
   148               
       
   149     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   150     __ASSERT_ALWAYS( aNewZoomFactor <= MaxZoomL() &&
       
   151                      aNewZoomFactor >= MinZoomL(), 
       
   152                      User::Leave( KErrArgument ) );
       
   153     
       
   154     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   155 
       
   156     if ( aNewZoomFactor <= iCameraInfo.iMaxZoom )
       
   157         {
       
   158         MUS_LOG( "mus: [ENGINE]     Optical zoom factor increased" )
       
   159         camera->SetZoomFactorL( aNewZoomFactor ); 
       
   160         }
       
   161     
       
   162     if ( aNewZoomFactor - iCameraInfo.iMaxZoom > 0 )
       
   163         {
       
   164         camera->SetDigitalZoomFactorL( aNewZoomFactor - iCameraInfo.iMaxZoom );
       
   165         MUS_LOG1( "mus: [ENGINE]     Digital zoom factor increased to %d",
       
   166                   aNewZoomFactor - iCameraInfo.iMaxZoom )
       
   167         }
       
   168     
       
   169     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::SetZoomL()" )
       
   170     }
       
   171 
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C TInt CMusEngLiveSession::MinZoomL() const
       
   178     {
       
   179     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::MinZoomL()" )
       
   180     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   181 
       
   182     // Although we do not need camera for return value, we have to have it in
       
   183     // order to have proper iCameraInfo
       
   184     MusEngMceUtils::GetCameraL( *iSession );
       
   185 
       
   186     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::MinZoomL( %d )",
       
   187               iCameraInfo.iMinZoom )
       
   188 
       
   189     return iCameraInfo.iMinZoom;
       
   190     }
       
   191     
       
   192         
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 EXPORT_C TInt CMusEngLiveSession::MaxZoomL() const
       
   198     {
       
   199     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::MaxZoomL()" )
       
   200     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   201 
       
   202     // Although we do not need camera for return value, we have to have it in
       
   203     // order to have proper iCameraInfo
       
   204     MusEngMceUtils::GetCameraL( *iSession );
       
   205 
       
   206     TInt maxZoom = iCameraInfo.iMaxZoom + iCameraInfo.iMaxDigitalZoom;
       
   207 
       
   208     MUS_LOG1( "mus: [ENGINE]     Max optical zoom( %d )",
       
   209               iCameraInfo.iMaxZoom )
       
   210     MUS_LOG1( "mus: [ENGINE]     Max digital zoom( %d )",
       
   211               iCameraInfo.iMaxDigitalZoom )
       
   212     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::MaxZoomL( %d )",
       
   213               maxZoom )
       
   214 
       
   215     return maxZoom;
       
   216     }
       
   217 
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 //
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void CMusEngLiveSession::ZoomInL()
       
   224     {
       
   225     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::ZoomInL()" )
       
   226     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   227 
       
   228     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   229 
       
   230     // First try to increase optical zoom factor. If in maximum value, try to
       
   231     // increase digital zoom factor.
       
   232     TInt stepSize = ZoomStepSize( iZoomInTime );
       
   233     TInt zoomFactor = camera->ZoomFactorL();
       
   234     TInt zoomDigitalFactor = camera->DigitalZoomFactorL();
       
   235  
       
   236     //increate optical zoom factor
       
   237     if ( zoomFactor + stepSize <= iCameraInfo.iMaxZoom )
       
   238         {
       
   239         //optical zoom factor is enough
       
   240         camera->SetZoomFactorL( zoomFactor + stepSize );
       
   241         stepSize = 0;
       
   242         }
       
   243     else if (zoomFactor <  iCameraInfo.iMaxZoom)
       
   244        {
       
   245             stepSize -=  iCameraInfo.iMaxZoom - zoomFactor;
       
   246             camera->SetZoomFactorL( iCameraInfo.iMaxZoom );
       
   247        }
       
   248 
       
   249     //increate digital zoom factor
       
   250     if (stepSize > 0)
       
   251         {
       
   252         if ( zoomDigitalFactor + stepSize <= iCameraInfo.iMaxDigitalZoom )
       
   253             {
       
   254             camera->SetDigitalZoomFactorL( zoomDigitalFactor + stepSize );
       
   255             }
       
   256         else 
       
   257             {
       
   258             camera->SetDigitalZoomFactorL( iCameraInfo.iMaxDigitalZoom );
       
   259             MUS_LOG( "mus: [ENGINE]     CMusEngLiveSession::ZoomInL(): Optical \
       
   260                              and digital zoom factors are in maximum value" )
       
   261             }
       
   262         }
       
   263     
       
   264     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::ZoomInL()" )
       
   265 
       
   266     }
       
   267 
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 //
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 EXPORT_C void CMusEngLiveSession::ZoomOutL()
       
   274     {
       
   275     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::ZoomOutL()" )
       
   276     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   277 
       
   278     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   279 
       
   280     // First try to decrease digital zoom factor. If already zero, try to
       
   281     // decrease optical zoom factor.
       
   282     TInt stepSize = ZoomStepSize( iZoomOutTime );
       
   283     TInt zoomFactor = camera->ZoomFactorL();
       
   284     TInt zoomDigitalFactor = camera->DigitalZoomFactorL();
       
   285     
       
   286     //decreate digital zoom factor firstly
       
   287     if ( zoomDigitalFactor - stepSize >= 0  )
       
   288         {
       
   289         //digital zoom factor is enough
       
   290         camera->SetDigitalZoomFactorL( zoomDigitalFactor - stepSize );
       
   291         stepSize = 0;
       
   292         }
       
   293     else if ( zoomDigitalFactor > 0 )
       
   294         {
       
   295         stepSize -= zoomDigitalFactor;
       
   296         camera->SetDigitalZoomFactorL( 0 );
       
   297         MUS_LOG("mus: [ENGINE] Digigal Factor to zero")
       
   298         }
       
   299    
       
   300     //decreate optical zoom factor firstly
       
   301     if ( stepSize > 0 )
       
   302         {
       
   303         if ( zoomFactor - stepSize > iCameraInfo.iMinZoom )
       
   304             {
       
   305             camera->SetZoomFactorL( zoomFactor - stepSize );
       
   306             }
       
   307         else 
       
   308             {
       
   309             MUS_LOG( "mus: [ENGINE]    CMusEngLiveSession::ZoomOutL(): Optical and \
       
   310                         digital zoom factors are in minimum value" )
       
   311             camera->SetZoomFactorL( iCameraInfo.iMinZoom );
       
   312             }
       
   313         }
       
   314 
       
   315     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::ZoomOutL()" )
       
   316     }
       
   317 
       
   318 
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 // -----------------------------------------------------------------------------
       
   322 //
       
   323 EXPORT_C void CMusEngLiveSession::ZoomDefaultL()
       
   324     {
       
   325     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::ZoomDefaultL()" )
       
   326 
       
   327     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   328 
       
   329     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   330 
       
   331     camera->SetZoomFactorL( iDefaultZoomFactor );
       
   332     camera->SetDigitalZoomFactorL( 0 );
       
   333 
       
   334     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::ZoomDefaultL()" )
       
   335     }
       
   336 
       
   337 
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 // -----------------------------------------------------------------------------
       
   341 //
       
   342 EXPORT_C void CMusEngLiveSession::SetBrightnessL( TInt aBrightness ) const
       
   343     {
       
   344     MUS_LOG1( "mus: [ENGINE]  -> CMusEngLiveSession::SetBrightnessL( %d )",
       
   345               aBrightness )
       
   346 
       
   347     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   348 
       
   349     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   350     camera->SetBrightnessL( aBrightness );
       
   351 
       
   352     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::SetBrightnessL()" )
       
   353     }
       
   354 
       
   355 
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 EXPORT_C TInt CMusEngLiveSession::CurrentBrightnessL() const
       
   361     {
       
   362     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::CurrentBrightnessL()" )
       
   363     
       
   364     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   365 
       
   366     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   367     TInt currentBrightness = camera->BrightnessL();
       
   368 
       
   369     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::CurrentBrightnessL(): %d",
       
   370               currentBrightness )
       
   371 
       
   372     return currentBrightness;
       
   373     }
       
   374 
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 // -----------------------------------------------------------------------------
       
   379 //
       
   380 EXPORT_C TInt CMusEngLiveSession::MaxBrightnessL() const
       
   381     {
       
   382     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::MaxBrightnessL()" )
       
   383     
       
   384     // maximum brightness is not in camera info, but a constant 100
       
   385 
       
   386     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::MaxBrightnessL(): %d",
       
   387               KMaxBrightness )
       
   388 
       
   389     return KMaxBrightness;
       
   390     }
       
   391 
       
   392 
       
   393 // -----------------------------------------------------------------------------
       
   394 //
       
   395 // -----------------------------------------------------------------------------
       
   396 //
       
   397 EXPORT_C TInt CMusEngLiveSession::MinBrightnessL() const
       
   398     {
       
   399     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::MinBrightnessL()" )
       
   400  
       
   401     // maximum brightness is not in camera info, but a constant -100
       
   402 
       
   403     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::MinBrightnessL(): %d",
       
   404               KMinBrightness )
       
   405 
       
   406     return KMinBrightness;
       
   407     }
       
   408 
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 //
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C void CMusEngLiveSession::IncreaseBrightnessL()
       
   415     {
       
   416     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::IncreaseBrightnessL()" )
       
   417     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   418 
       
   419     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   420 
       
   421     TInt newBrightness = camera->BrightnessL() + KBrightnessStepSize;
       
   422     
       
   423     if ( newBrightness < KMaxBrightness )
       
   424         {
       
   425         camera->SetBrightnessL( newBrightness );
       
   426         }
       
   427     else
       
   428         {
       
   429         camera->SetBrightnessL( KMaxBrightness );
       
   430         }
       
   431 
       
   432     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::IncreaseBrightnessL()" )
       
   433     }
       
   434 
       
   435 
       
   436 // -----------------------------------------------------------------------------
       
   437 //
       
   438 // -----------------------------------------------------------------------------
       
   439 //
       
   440 EXPORT_C void CMusEngLiveSession::DecreaseBrightnessL()
       
   441     {
       
   442     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::DecreaseBrightnessL()" )
       
   443     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   444 
       
   445     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   446 
       
   447     TInt newBrightness = camera->BrightnessL() - KBrightnessStepSize;
       
   448 
       
   449     if ( newBrightness > KMinBrightness )
       
   450         {
       
   451         camera->SetBrightnessL( newBrightness );
       
   452         }
       
   453     else
       
   454         {
       
   455         camera->SetBrightnessL( KMinBrightness );
       
   456         }
       
   457 
       
   458     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::DecreaseBrightnessL()" )
       
   459     }
       
   460 
       
   461 
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 // -----------------------------------------------------------------------------
       
   465 //
       
   466 EXPORT_C void CMusEngLiveSession::BrightnessDefaultL()
       
   467     {
       
   468     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::BrightnessDefaultL()" )
       
   469     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   470 
       
   471     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   472 
       
   473     camera->SetBrightnessL( iDefaultBrightness );
       
   474 
       
   475     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::BrightnessDefaultL()" )
       
   476     }
       
   477 
       
   478 
       
   479 // -----------------------------------------------------------------------------
       
   480 //
       
   481 // -----------------------------------------------------------------------------
       
   482 //
       
   483 EXPORT_C void CMusEngLiveSession::BrightnessAutoL()
       
   484     {
       
   485     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::BrightnessAutoL()" )
       
   486     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   487 
       
   488     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   489 
       
   490     camera->SetBrightnessL( CCamera::EBrightnessAuto );
       
   491 
       
   492     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::BrightnessAutoL()" )
       
   493     }
       
   494 
       
   495 
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 // -----------------------------------------------------------------------------
       
   499 //
       
   500 EXPORT_C void CMusEngLiveSession::RecordL( TBool aRecord )
       
   501     {
       
   502     MUS_LOG1( "mus: [ENGINE]  -> CMusEngLiveSession::RecordL( %d )", aRecord )    
       
   503     
       
   504     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   505 
       
   506     CMceMediaSink* fileSink = MusEngMceUtils::GetMediaSink( *iSession, 
       
   507                                                             KMceFileSink );
       
   508     
       
   509     __ASSERT_ALWAYS( fileSink, User::Leave( KErrNotReady ) );
       
   510     
       
   511     if( aRecord && !fileSink->IsEnabled() )
       
   512         {
       
   513         fileSink->EnableL();        
       
   514         }
       
   515     else if ( !aRecord && fileSink->IsEnabled() )
       
   516         {
       
   517         fileSink->DisableL();        
       
   518         }
       
   519     else
       
   520         {
       
   521         // NOP
       
   522         }
       
   523 
       
   524     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::RecordL( %d )", aRecord ) 
       
   525     }    
       
   526 
       
   527 
       
   528 // -----------------------------------------------------------------------------
       
   529 //
       
   530 // -----------------------------------------------------------------------------
       
   531 //
       
   532 EXPORT_C TBool CMusEngLiveSession::IsRecording()
       
   533     {
       
   534     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::IsRecording()" )    
       
   535     
       
   536     TBool isRecording( EFalse );
       
   537   
       
   538     CMceMediaSink* fileSink = MusEngMceUtils::GetMediaSink( *iSession, 
       
   539                                                             KMceFileSink );
       
   540     if ( fileSink )
       
   541         {
       
   542         isRecording = fileSink->IsEnabled();
       
   543         }
       
   544         
       
   545     MUS_LOG1( "mus: [ENGINE]  <- CMusEngLiveSession::IsRecording(%d)",
       
   546               isRecording )
       
   547                  
       
   548     return isRecording;
       
   549     }
       
   550 
       
   551 
       
   552 // -----------------------------------------------------------------------------
       
   553 // Enable camera if not already enabled
       
   554 // -----------------------------------------------------------------------------
       
   555 //
       
   556 EXPORT_C void CMusEngLiveSession::PlayL()
       
   557     {
       
   558     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::PlayL()" )
       
   559 
       
   560     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   561     
       
   562     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   563 
       
   564     if ( !camera->IsEnabled() )
       
   565         {
       
   566         camera->EnableL();
       
   567         }
       
   568     else
       
   569         {
       
   570         MUS_LOG( "mus: [ENGINE]    Camera already enabled, ignore request" )
       
   571         }
       
   572         
       
   573     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::PlayL()" )
       
   574     }
       
   575 
       
   576 
       
   577 // -----------------------------------------------------------------------------
       
   578 // Disable camera if not already disabled
       
   579 // -----------------------------------------------------------------------------
       
   580 //
       
   581 EXPORT_C void CMusEngLiveSession::PauseL()
       
   582     {
       
   583     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::PauseL()" )
       
   584 
       
   585     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   586 
       
   587     CMceCameraSource* camera = MusEngMceUtils::GetCameraL( *iSession );
       
   588 
       
   589     if ( camera->IsEnabled() )
       
   590         {
       
   591         camera->DisableL();
       
   592         }
       
   593     else
       
   594         {
       
   595         MUS_LOG( "mus: [ENGINE]    Camera already disabled, ignore request" )
       
   596         }
       
   597 
       
   598     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::PauseL()" )
       
   599     }
       
   600 
       
   601 
       
   602 // -----------------------------------------------------------------------------
       
   603 //
       
   604 // -----------------------------------------------------------------------------
       
   605 //
       
   606 EXPORT_C TBool CMusEngLiveSession::IsPlayingL()
       
   607     {
       
   608     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   609     
       
   610     return ( MusEngMceUtils::GetCameraL( *iSession )->IsEnabled() );
       
   611     }
       
   612     
       
   613 
       
   614 // -----------------------------------------------------------------------------
       
   615 //
       
   616 // -----------------------------------------------------------------------------
       
   617 //
       
   618 void CMusEngLiveSession::InitializeZoomStepSize()
       
   619     {
       
   620     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::InitializeZoomStepSize()" )
       
   621     
       
   622     iBigZoomStep = ( iCameraInfo.iMaxZoom + iCameraInfo.iMaxDigitalZoom - 
       
   623             iCameraInfo.iMinZoom ) / KZoomBigStepCount;
       
   624             
       
   625     if ( iBigZoomStep < KZoomStepMinSize )
       
   626         iBigZoomStep = KZoomStepMinSize;
       
   627 
       
   628     iSmallZoomStep = ( iCameraInfo.iMaxZoom + iCameraInfo.iMaxDigitalZoom - 
       
   629             iCameraInfo.iMinZoom ) / KZoomSmallStepCount;
       
   630     
       
   631     if ( iSmallZoomStep < KZoomStepMinSize )
       
   632         iSmallZoomStep = KZoomStepMinSize;
       
   633 
       
   634     MUS_LOG2( "mus: [ENGINE]  iSmallZoomStep = %d, iBigZoomStep = %d", 
       
   635             iSmallZoomStep, iBigZoomStep )
       
   636     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::InitializeZoomStepSize()" )   
       
   637     }
       
   638 
       
   639 // -----------------------------------------------------------------------------
       
   640 //
       
   641 // -----------------------------------------------------------------------------
       
   642 //
       
   643 void CMusEngLiveSession::CompleteSessionStructureL( 
       
   644                                             CMceStreamBundle& /*aLocalBundle*/ )
       
   645     {
       
   646     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::CompleteSessionStructureL()" )
       
   647 
       
   648     __ASSERT_ALWAYS( iSession, User::Leave( KErrNotReady ) );
       
   649 
       
   650     // Create outgoing video stream
       
   651     CMceVideoStream* videoStream = CMceVideoStream::NewLC();
       
   652     
       
   653     CMceRtpSink* rtpsink = CMceRtpSink::NewLC();
       
   654     videoStream->AddSinkL( rtpsink );
       
   655     CleanupStack::Pop( rtpsink );
       
   656 
       
   657     CMceCameraSource* camera = CMceCameraSource::NewLC( *iManager );
       
   658     camera->DisableL(); // Start session in pause mode.
       
   659     camera->GetCameraInfo( iCameraInfo );
       
   660     iDefaultZoomFactor = camera->ZoomFactorL();
       
   661     
       
   662     InitializeZoomStepSize();
       
   663         
       
   664     videoStream->SetSourceL( camera );
       
   665     CleanupStack::Pop( camera );
       
   666 
       
   667     iSession->AddStreamL( videoStream );
       
   668     CleanupStack::Pop( videoStream );    
       
   669 
       
   670     // Construct recording stream if needed
       
   671     if ( iRecordedFile != KNullDesC )
       
   672         {
       
   673         CMceVideoStream* streamForRecording = CMceVideoStream::NewLC();
       
   674         
       
   675         CMceFileSink* fileSink = CMceFileSink::NewLC( iRecordedFile );
       
   676         fileSink->DisableL(); // Start in not recording mode
       
   677         streamForRecording->AddSinkL( fileSink );
       
   678         CleanupStack::Pop( fileSink );
       
   679         
       
   680         streamForRecording->SetSourceL( camera );
       
   681         iSession->AddStreamL( streamForRecording );
       
   682         CleanupStack::Pop( streamForRecording );
       
   683         }
       
   684 
       
   685     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::CompleteSessionStructureL()" )
       
   686     }
       
   687 
       
   688 
       
   689 // -----------------------------------------------------------------------------
       
   690 //
       
   691 // -----------------------------------------------------------------------------
       
   692 //
       
   693 void CMusEngLiveSession::HandleSessionStateChanged( 
       
   694                                                 CMceSession& aSession,
       
   695                                                 TInt aStatusCode,
       
   696                                                 const TDesC8& aReasonPhrase )
       
   697     {
       
   698     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::HandleSessionStateChanged" )
       
   699     
       
   700     MUS_ENG_LOG_SESSION_STATE_AND_STATUS( aSession, aStatusCode, aReasonPhrase )
       
   701     
       
   702     if ( iSession && 
       
   703          iSession == &aSession && 
       
   704          aSession.State() == CMceSession::EEstablished &&
       
   705          iStoreEncoderConfigInfo )
       
   706         {
       
   707         iStoreEncoderConfigInfo = EFalse;
       
   708         TRAPD( error, StoreEncoderConfigInfoL() )
       
   709         if ( error != KErrNone && error != KErrNotFound )
       
   710             {
       
   711             // Only acceptable error is absence of repository entry,
       
   712             // otherwise we inform user about failed session.
       
   713             iSessionObserver.SessionFailed();
       
   714             }
       
   715         }
       
   716      
       
   717     CMusEngMceSession::HandleSessionStateChanged( aSession,
       
   718                                                   aStatusCode, 
       
   719                                                   aReasonPhrase );
       
   720     
       
   721     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::HandleSessionStateChanged" )
       
   722     }
       
   723 
       
   724 
       
   725 // -----------------------------------------------------------------------------
       
   726 // Sets video codec attributes
       
   727 // -----------------------------------------------------------------------------
       
   728 //
       
   729 void CMusEngLiveSession::AdjustVideoCodecL( CMceVideoCodec& aVideoCodec )
       
   730     {
       
   731     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::AdjustVideoCodecL()" )
       
   732     
       
   733     CMusEngMceOutSession::AdjustVideoCodecL( aVideoCodec );
       
   734     
       
   735     // Starting with 80Kbps  will give better quality than starting with
       
   736     // 64kbps.And if network behaves bad than anyhow we will drop down or
       
   737     // if network is good guy than we climp up to 128. 
       
   738     // Esp in operator variance. No constant defined in MCE so defining
       
   739     // one here.
       
   740     const TInt  KMushInitialBitrate = 80000;  
       
   741     MUS_LOG1( "mus: [ENGINE] - Intial bit rate set to %d",KMushInitialBitrate);
       
   742     User::LeaveIfError( aVideoCodec.SetBitrate( KMushInitialBitrate ) );
       
   743                 
       
   744     if ( aVideoCodec.SdpName() == KMceSDPNameH263() ||
       
   745          aVideoCodec.SdpName() == KMceSDPNameH2632000() )
       
   746         {
       
   747         // Set H.263 codec to allow all bitrates, set maximum to level 45 and
       
   748         // start using level 10 and let the rate control raise it if possible
       
   749         // Label:H263
       
   750         User::LeaveIfError( aVideoCodec.SetAllowedBitrates( 
       
   751                                                 KMceAllowedH263BitrateAll ) );
       
   752         aVideoCodec.SetMaxBitrateL( KMceH263Level45Bitrate );        
       
   753         }
       
   754     else if ( aVideoCodec.SdpName() == KMceSDPNameH264() )
       
   755         {
       
   756         User::LeaveIfError( aVideoCodec.SetAllowedBitrates( 
       
   757                                         KMceAvcCodecProfileIdBaseline | 
       
   758                                         KMceAvcCodecProfileIopConstraintSet | 
       
   759                                         KMceAvcBitrateLevel1b ) );
       
   760         
       
   761         SetCodecConfigKeyL( aVideoCodec );
       
   762         SetEncodingDeviceL( aVideoCodec );                             
       
   763         }
       
   764     else
       
   765         {
       
   766         // NOP
       
   767         }
       
   768     
       
   769     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::AdjustVideoCodecL()" )
       
   770     }
       
   771     
       
   772     
       
   773 // -----------------------------------------------------------------------------
       
   774 //
       
   775 // -----------------------------------------------------------------------------
       
   776 //
       
   777 void CMusEngLiveSession::AdjustAudioCodecL( CMceAudioCodec& aAudioCodec )
       
   778     {
       
   779     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::AdjustAudioCodecL()" )
       
   780     
       
   781     CMusEngMceOutSession::AdjustAudioCodecL( aAudioCodec );
       
   782     
       
   783     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::AdjustAudioCodecL()" )
       
   784     }
       
   785 
       
   786 
       
   787 // -----------------------------------------------------------------------------
       
   788 //
       
   789 // -----------------------------------------------------------------------------
       
   790 //
       
   791 void CMusEngLiveSession::DoCodecSelectionL( CMceVideoStream& aVideoStream )
       
   792     {
       
   793     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::DoCodecSelectionL()" )
       
   794     
       
   795     CMusEngMceSession::DoCodecSelectionL( aVideoStream );
       
   796     
       
   797     if ( iVideoCodecList &&
       
   798          iVideoCodecList->Length() > 0 &&
       
   799          iVideoCodecList->FindF( KMceSDPNameH264 ) == KErrNotFound )
       
   800         {        
       
   801         // We know that recipient doesn't support AVC, so we do not offer it
       
   802         const RPointerArray<CMceVideoCodec>& codecs = aVideoStream.Codecs();
       
   803     
       
   804         for ( TInt codecIndex = 0; codecIndex < codecs.Count(); ++codecIndex )
       
   805             {
       
   806             if ( codecs[codecIndex]->SdpName() == KMceSDPNameH264() )
       
   807                 {
       
   808                 aVideoStream.RemoveCodecL( *codecs[codecIndex] );
       
   809                 // Since succesfull removal of a codec has changed the
       
   810                 // indexing, we have to reset the index
       
   811                 codecIndex = 0;
       
   812                 }
       
   813             }
       
   814         }
       
   815      
       
   816     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::DoCodecSelectionL()" )
       
   817     }
       
   818     
       
   819 
       
   820 // -----------------------------------------------------------------------------
       
   821 //
       
   822 // -----------------------------------------------------------------------------
       
   823 //
       
   824 void CMusEngLiveSession::StreamStateChanged( CMceMediaStream& aStream,
       
   825                                              CMceMediaSink& aSink )
       
   826     {
       
   827     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::StreamStateChanged( sink )" )
       
   828     
       
   829     if ( !iSession )
       
   830         {
       
   831         return;
       
   832         }
       
   833     
       
   834     MUS_ENG_LOG_STREAM_STATE( aStream )
       
   835     
       
   836     CMceVideoStream* recordingStream = 
       
   837                             MusEngMceUtils::GetRecordingStream( *iSession );
       
   838     
       
   839     if ( recordingStream &&
       
   840          recordingStream == &aStream &&
       
   841          aStream.State() == CMceMediaStream::ENoResources &&
       
   842          aSink.IsEnabled() == EFalse )
       
   843         {
       
   844         iLiveSessionObserver.DiskFull();
       
   845         }
       
   846     else
       
   847         {
       
   848         // Cannot handle, forward to a base class
       
   849         CMusEngMceSession::StreamStateChanged( aStream, aSink );
       
   850         }
       
   851     
       
   852     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::StreamStateChanged( sink )" )
       
   853     }
       
   854     
       
   855 
       
   856 // -----------------------------------------------------------------------------
       
   857 //
       
   858 // -----------------------------------------------------------------------------
       
   859 //
       
   860 CMusEngLiveSession::CMusEngLiveSession(
       
   861                         MMusEngSessionObserver& aSessionObserver,
       
   862                         MMusEngOutSessionObserver& aOutSessionObserver,
       
   863                         MMusEngLiveSessionObserver& aLiveSessionObserver,
       
   864                         const TRect& aRect,
       
   865                         const TDesC& aRecordedFile )
       
   866     : CMusEngMceOutSession( aRect,
       
   867                             aSessionObserver,
       
   868                             aOutSessionObserver ),
       
   869       iLiveSessionObserver( aLiveSessionObserver ),
       
   870       iDefaultZoomFactor( -1 ),
       
   871       iDefaultBrightness( 0 ),
       
   872       iRecordedFile( aRecordedFile ),
       
   873       iZoomInTime(0),
       
   874       iZoomOutTime(0),
       
   875       iSmallZoomStep( KZoomStepMinSize ),
       
   876       iBigZoomStep( KZoomStepMinSize )
       
   877     {
       
   878     }
       
   879 
       
   880 
       
   881 // -----------------------------------------------------------------------------
       
   882 //
       
   883 // -----------------------------------------------------------------------------
       
   884 //
       
   885 void CMusEngLiveSession::ConstructL( TUint aSipProfileId )
       
   886     {
       
   887     MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::ConstructL()" )
       
   888 
       
   889     CMusEngMceOutSession::ConstructL( aSipProfileId );
       
   890 
       
   891     MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::ConstructL()" )
       
   892     }
       
   893 
       
   894 
       
   895 // -----------------------------------------------------------------------------
       
   896 //
       
   897 // -----------------------------------------------------------------------------
       
   898 //
       
   899 void CMusEngLiveSession::SetEncodingDeviceL( CMceVideoCodec& aVideoCodec )
       
   900     {
       
   901     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::SetEncodingDeviceL()" )
       
   902 
       
   903     // We try to read encoding device UID. If we do not succeed, we use default
       
   904     
       
   905     const TUid KDefaultEncodingDevice( TUid::Uid( 0x20001C13 ) );
       
   906     TUid encodingDevice( KDefaultEncodingDevice );
       
   907     TRAPD( error, 
       
   908            encodingDevice = MultimediaSharingSettings::EncodingDeviceL() )
       
   909     __ASSERT_ALWAYS( error == KErrNone || error == KErrNotFound, 
       
   910                      User::Leave( error ) );
       
   911     aVideoCodec.SetPreferredEncodingDecodingDeviceL( encodingDevice );
       
   912     
       
   913     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::SetEncodingDeviceL()" )
       
   914     }
       
   915     
       
   916 
       
   917 // -----------------------------------------------------------------------------
       
   918 //
       
   919 // -----------------------------------------------------------------------------
       
   920 //
       
   921 void CMusEngLiveSession::SetCodecConfigKeyL( CMceVideoCodec& aVideoCodec )
       
   922     {
       
   923     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::SetCodecConfigKeyL()" )
       
   924     
       
   925     HBufC8* configKey( NULL );
       
   926         
       
   927     // We try to read config key. If we do not succeed, we prepare to
       
   928     // write keys to CenRep for the next time.
       
   929     TRAPD( error, configKey = ReadCodecConfigKeyL( aVideoCodec ) )
       
   930     
       
   931     if ( error == KErrNone )
       
   932         {
       
   933         // There is a repository for config keys
       
   934         if ( configKey )
       
   935             {
       
   936             // ...and key is found.
       
   937             CleanupStack::PushL( configKey );
       
   938             aVideoCodec.SetConfigKeyL( *configKey );
       
   939             CleanupStack::PopAndDestroy( configKey );
       
   940             }
       
   941         else
       
   942             {
       
   943             // ...but key is not found, so it must be written to CenRep when
       
   944             // available. 
       
   945             iStoreEncoderConfigInfo = ETrue;
       
   946             }
       
   947         }
       
   948     else if ( error == KErrNotFound )
       
   949         {
       
   950         // There is no repository for config keys so there is no point
       
   951         // trying to write anything there. Session setup can still continue.
       
   952         MUS_LOG1( "mus: [ENGINE]    No repository for config keys [%d]", error )
       
   953         }            
       
   954     else
       
   955         {
       
   956         User::Leave( error );
       
   957         }
       
   958     
       
   959     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::SetCodecConfigKeyL()" )
       
   960     }
       
   961 
       
   962 
       
   963 // -----------------------------------------------------------------------------
       
   964 //
       
   965 // -----------------------------------------------------------------------------
       
   966 //
       
   967 HBufC8* CMusEngLiveSession::ReadCodecConfigKeyL( 
       
   968                                     const CMceVideoCodec& aVideoCodec ) const
       
   969     {
       
   970     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::ReadCodecConfigKeyL()" )
       
   971     
       
   972     HBufC8* key( NULL );
       
   973  
       
   974     HBufC8* encoderInfo = MultimediaSharingSettings::EncoderConfigInfoLC();
       
   975     __ASSERT_ALWAYS( encoderInfo, User::Leave( KErrNotFound ) );
       
   976     
       
   977     TPtrC8 keyId( ConfigKeyIdL( aVideoCodec ) ); 
       
   978     
       
   979     TInt tokenStartPosition( encoderInfo->FindC( keyId ) );
       
   980     if ( tokenStartPosition > KErrNotFound )
       
   981         {
       
   982         TInt tokenLength( encoderInfo->Mid( tokenStartPosition ).FindC( 
       
   983                                                 KMusEncoderInfoTokenizer ) );
       
   984         if ( tokenLength > KErrNotFound )
       
   985             {
       
   986             // Separate key from token by removing keyId
       
   987             TInt keyStartPosition = tokenStartPosition + keyId.Length();
       
   988             TInt keyLength = tokenLength - keyId.Length(); 
       
   989             TPtrC8 keyPtr = encoderInfo->Mid( keyStartPosition, keyLength );
       
   990             key = keyPtr.AllocL();
       
   991             }
       
   992         }
       
   993     
       
   994     CleanupStack::PopAndDestroy( encoderInfo );
       
   995     
       
   996     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::ReadCodecConfigKeyL()" )
       
   997         
       
   998     return key;   
       
   999     }
       
  1000     
       
  1001 
       
  1002 // -----------------------------------------------------------------------------
       
  1003 //
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 void CMusEngLiveSession::StoreEncoderConfigInfoL() const
       
  1007     {
       
  1008     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::StoreEncoderConfigInfoL()" )
       
  1009     
       
  1010     HBufC8* configInfoInCenRep = MultimediaSharingSettings::EncoderConfigInfoLC();
       
  1011     __ASSERT_ALWAYS( configInfoInCenRep, User::Leave( KErrNotFound ) );
       
  1012     
       
  1013     TBuf8<NCentralRepositoryConstants::KMaxBinaryLength> keys;
       
  1014     keys.Append( *configInfoInCenRep );
       
  1015     
       
  1016     CMceVideoStream* stream = MusEngMceUtils::GetVideoOutStreamL( *iSession );
       
  1017     const RPointerArray<CMceVideoCodec>& codecs = stream->Codecs();
       
  1018     
       
  1019     for ( TInt codecIndex = 0; codecIndex < codecs.Count(); ++codecIndex )
       
  1020         {
       
  1021         if ( codecs[codecIndex]->SdpName().FindF( KMceSDPNameH264 ) >= 0 )
       
  1022             {
       
  1023             const TPtrC8 keyId = ConfigKeyIdL( *codecs[codecIndex] );
       
  1024             HBufC8* configKey = codecs[codecIndex]->ConfigKeyL();
       
  1025             CleanupStack::PushL( configKey );
       
  1026             
       
  1027             if ( configKey &&
       
  1028                  keys.FindF( keyId ) == KErrNotFound &&
       
  1029                  configInfoInCenRep->FindF( keyId ) == KErrNotFound )
       
  1030                 {
       
  1031                 
       
  1032                 if ( keys.Length() + 
       
  1033                      keyId.Length() + 
       
  1034                      configKey->Length() +
       
  1035                      KMusEncoderInfoTokenizer().Length() <
       
  1036                      NCentralRepositoryConstants::KMaxBinaryLength )
       
  1037                     {
       
  1038                     keys.Append( keyId );                    
       
  1039                     keys.Append( *configKey );
       
  1040                     keys.Append( KMusEncoderInfoTokenizer );
       
  1041                     }
       
  1042                 }
       
  1043                 
       
  1044             CleanupStack::PopAndDestroy( configKey );
       
  1045             }
       
  1046         }
       
  1047     
       
  1048     MultimediaSharingSettings::SetEncoderConfigInfoL( keys );    
       
  1049     
       
  1050     CleanupStack::PopAndDestroy( configInfoInCenRep );
       
  1051         
       
  1052     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::StoreEncoderConfigInfoL()" )
       
  1053     }
       
  1054 
       
  1055 
       
  1056 // -----------------------------------------------------------------------------
       
  1057 //
       
  1058 // -----------------------------------------------------------------------------
       
  1059 //
       
  1060 const TPtrC8 CMusEngLiveSession::ConfigKeyIdL(
       
  1061                                     const CMceVideoCodec& aVideoCodec ) const
       
  1062     {
       
  1063     MUS_LOG( "mus: [ENGINE] -> CMusEngLiveSession::ConfigKeyIdL()" )
       
  1064     
       
  1065     // Currently works only for AVC
       
  1066     __ASSERT_ALWAYS( aVideoCodec.SdpName().FindF( KMceSDPNameH264 ) >= 0,
       
  1067                      User::Leave( KErrArgument ) );
       
  1068     
       
  1069     TPtrC8 configKeyTokenId;
       
  1070     
       
  1071     if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1 )
       
  1072         {
       
  1073         configKeyTokenId.Set( KMusAvcBitrateLevel1() );
       
  1074         }
       
  1075     else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1b )
       
  1076         {
       
  1077         configKeyTokenId.Set( KMusAvcBitrateLevel1b() );
       
  1078         }
       
  1079     else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_1 )
       
  1080         {
       
  1081         configKeyTokenId.Set( KMusAvcBitrateLevel1_1() );
       
  1082         }
       
  1083     else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_2 )
       
  1084         {
       
  1085         configKeyTokenId.Set( KMusAvcBitrateLevel1_2() );
       
  1086         }
       
  1087     else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel1_3 )
       
  1088         {
       
  1089         configKeyTokenId.Set( KMusAvcBitrateLevel1_3() );
       
  1090         }
       
  1091     else if ( aVideoCodec.AllowedBitrates() & KMceAvcBitrateLevel2 )
       
  1092         {
       
  1093         configKeyTokenId.Set( KMusAvcBitrateLevel2() );
       
  1094         }
       
  1095     else
       
  1096         {
       
  1097         User::Leave( KErrNotFound );
       
  1098         }
       
  1099     
       
  1100     MUS_LOG( "mus: [ENGINE] <- CMusEngLiveSession::ConfigKeyIdL()" )
       
  1101 
       
  1102     return configKeyTokenId;
       
  1103     }
       
  1104 
       
  1105 
       
  1106 // -----------------------------------------------------------------------------
       
  1107 //  Calculate the zoom step based time escaped
       
  1108 // -----------------------------------------------------------------------------
       
  1109 TInt CMusEngLiveSession::ZoomStepSize( TInt64& aTime )
       
  1110     {
       
  1111 //    MUS_LOG( "mus: [ENGINE]  -> CMusEngLiveSession::ZoomStepSize()" )    
       
  1112     TTime now;
       
  1113     now.HomeTime();
       
  1114     TInt64 timeNow = now.Int64();   
       
  1115     TInt stepSize = ( ( timeNow - aTime ) <= KZoomFasterTime ) ? iBigZoomStep : iSmallZoomStep;
       
  1116     
       
  1117     aTime = now.Int64();
       
  1118     
       
  1119     MUS_LOG1( "mus: [ENGINE]  stepSize = %d", stepSize );    
       
  1120 //    MUS_LOG( "mus: [ENGINE]  <- CMusEngLiveSession::ZoomStepSize()" )
       
  1121     return stepSize;
       
  1122     }
       
  1123 
       
  1124