multimediacommscontroller/mmccinterface/src/mmccinterface.cpp
changeset 0 1bce908db942
child 49 64c62431ac08
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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:    Mcc Interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 // INCLUDE FILES
       
    23 #include <ecom/ecom.h>
       
    24 #include <mmf/common/mmfbase.h>
       
    25 #include <ecam.h>
       
    26 
       
    27 #include "mmccinterface.h"
       
    28 #include "mmcctranscoder.h"
       
    29 
       
    30 #include "mccuids.hrh"
       
    31 #include "mccinternalcodecs.h"
       
    32 #include "mmccnetworksettings.h"
       
    33 #include "mccdef.h"       
       
    34 #include "mmccevent.h"
       
    35 #include "mmcccodecamr.h"
       
    36 #include "mmcccodecdtmf.h"
       
    37 #include "mmcccodecinformation.h"
       
    38 #include "mmcccodecinformationfactory.h"
       
    39 #include "mmccevents.h"
       
    40 #include "mmccinterfacelogs.h"
       
    41 #include "mmcccodech263.h"
       
    42 
       
    43 const TUid KImplementMccController  = { KImplUidMccController };
       
    44 
       
    45 // EXTERNAL DATA STRUCTURES
       
    46 
       
    47 // EXTERNAL FUNCTION PROTOTYPES  
       
    48 
       
    49 // CONSTANTS
       
    50 
       
    51 // MACROS
       
    52 
       
    53 // LOCAL CONSTANTS AND MACROS
       
    54 
       
    55 // MODULE DATA STRUCTURES
       
    56 
       
    57 // LOCAL FUNCTION PROTOTYPES
       
    58 
       
    59 // FORWARD DECLARATIONS
       
    60 
       
    61 // ============================= LOCAL FUNCTIONS ===============================
       
    62 
       
    63 
       
    64 // ============================ MEMBER FUNCTIONS ===============================
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CMccInterface::CMccInterface
       
    68 // C++ default constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 // ---------------------------------------------------------------------------
       
    71 //
       
    72 CMccInterface::CMccInterface() : 
       
    73     iMessageDest( KMccControllerUidInterface ),
       
    74     iAudioPlayDeviceCustomCommands( iController ),
       
    75     iAudioRecordDeviceCustomCommands( iController )
       
    76     {
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CMccInterface::ConstructL
       
    81 // Symbian 2nd phase constructor can leave.
       
    82 // ---------------------------------------------------------------------------
       
    83 //
       
    84 void CMccInterface::ConstructL( MMccCtrlObserver& aObserver )
       
    85     {
       
    86     __INTERFACE( "MccInterface::ConstructL" )
       
    87    
       
    88     // Open Controller
       
    89     OpenControllerL( KImplementMccController );
       
    90 
       
    91     iMccEvent = CMccEvent::NewL( iController, aObserver );
       
    92     iMccEvent->RequestEventNotification();
       
    93 
       
    94     CapabilitiesL();
       
    95     __INTERFACE( "MccInterface::ConstructL, exit" )
       
    96     }
       
    97 
       
    98 
       
    99 // ---------------------------------------------------------------------------
       
   100 // CMccInterface::NewL()
       
   101 // Static constructor.
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C CMccInterface* CMccInterface::NewL( MMccCtrlObserver& aObserver )
       
   105     {
       
   106     CMccInterface* self = new(ELeave) CMccInterface();
       
   107     CleanupStack::PushL( self );
       
   108     self->ConstructL( aObserver );
       
   109     CleanupStack::Pop( self );
       
   110     return self;
       
   111     }
       
   112 
       
   113 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CMccInterface::~CMccInterface()
       
   116 // Destructor
       
   117 // ---------------------------------------------------------------------------
       
   118 //
       
   119 CMccInterface::~CMccInterface()
       
   120     {
       
   121     __INTERFACE( "MccInterface::~CMccInterface" )
       
   122     delete iMccEvent;
       
   123     
       
   124     iController.Close();
       
   125     iCodecInformation.ResetAndDestroy();
       
   126     iCodecInformation.Close();
       
   127     
       
   128     iEndpointInfos.Reset();
       
   129     iEndpointInfos.Close();
       
   130     
       
   131     REComSession::FinalClose();
       
   132     __INTERFACE( "MccInterface::~CMccInterface, exit" )
       
   133     }
       
   134 
       
   135 
       
   136 
       
   137 // -----------------------------------------------------------------------------
       
   138 // CMccInterface::CapabilitiesL()
       
   139 // Get supported codecs from controller.
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CMccInterface::CapabilitiesL()
       
   143     {
       
   144     __INTERFACE( "MccInterface::CapabilitiesL" )
       
   145     RArray<TFourCC> codecs;            
       
   146     CMccCodecInformationFactory* codecFactory = CMccCodecInformationFactory::NewL();
       
   147     CleanupStack::PushL( codecFactory );
       
   148     
       
   149     GetSupportedCodecs( codecs );
       
   150     
       
   151     TFourCC fourccValue;
       
   152     
       
   153     TInt codecCount = codecs.Count();
       
   154     __INTERFACE_INT1( "MccInterface::CapabilitiesL, count of found codecs:", codecCount )
       
   155     for ( TInt k = 0; k < codecCount; k++ )
       
   156         {
       
   157         fourccValue = codecs[k];
       
   158         
       
   159         CMccCodecInformation* codec = codecFactory->CreateCodecInformationL( fourccValue );
       
   160         if ( codec )
       
   161             {
       
   162             CleanupStack::PushL( codec );
       
   163             __INTERFACE_STR8( "MccInterface::CapabilitiesL, appending:", codec->SdpName() )
       
   164             iCodecInformation.AppendL( codec );            
       
   165             CleanupStack::Pop( codec );
       
   166             }
       
   167         
       
   168         if ( fourccValue == KMccFourCCIdG711 )
       
   169             {
       
   170             codec = codecFactory->CreateCodecInformationL( fourccValue );
       
   171             CleanupStack::PushL( codec );
       
   172             if ( 0 == codec->SdpName().CompareF( KPCMUSdpName ) )
       
   173                 {
       
   174                 codec->SetSdpName( KPCMASdpName );
       
   175                 }
       
   176             else
       
   177                 {
       
   178                 codec->SetSdpName( KPCMUSdpName );
       
   179                 }
       
   180             
       
   181             __INTERFACE_STR8( "MccInterface::CapabilitiesL, appending:", codec->SdpName() )
       
   182             iCodecInformation.AppendL( codec );
       
   183             CleanupStack::Pop( codec );
       
   184             }
       
   185             
       
   186         if ( fourccValue == KMccFourCCIdH263 )
       
   187             {
       
   188             codec = codecFactory->CreateCodecInformationL( fourccValue );
       
   189             CleanupStack::PushL( codec );
       
   190             if ( 0 == codec->SdpName().CompareF( KH2632000SdpName ) )
       
   191                 {
       
   192                 // Changes also sdpname
       
   193                 codec->SetCodecMode( KH263FormatModeOld );
       
   194                 }
       
   195             else
       
   196                 {
       
   197                 // Changes also sdpname
       
   198                 codec->SetCodecMode( KH263FormatModeNew );
       
   199                 }
       
   200             
       
   201             __INTERFACE_STR8( "MccInterface::CapabilitiesL, appending:", codec->SdpName() )
       
   202             iCodecInformation.AppendL( codec );
       
   203             CleanupStack::Pop( codec );
       
   204             }
       
   205         }
       
   206     
       
   207     codecs.Close();
       
   208     CleanupStack::PopAndDestroy( codecFactory );
       
   209     __INTERFACE( "MccInterface::CapabilitiesL, exit" )
       
   210     }
       
   211     
       
   212 // -----------------------------------------------------------------------------
       
   213 // CMccInterface::GetSupportedCodecs()
       
   214 // Get supported codecs.
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 TInt CMccInterface::GetSupportedCodecs( RArray<TFourCC>& aCodecs )
       
   218     {
       
   219     __INTERFACE( "MccInterface::GetSupportedCodecs" )
       
   220     TInt err = KErrNone;
       
   221     TMccSession session;
       
   222     
       
   223     TInt count = session.iFourCCArray.Count();
       
   224     for ( TInt i = 0; i < count; i++)
       
   225         {
       
   226         session.iFourCCArray[i] = NULL;
       
   227         }
       
   228 
       
   229     TMccSessionPckg package( session );
       
   230 
       
   231     err = iController.CustomCommandSync( iMessageDest,
       
   232                                          EMccGetSupportedCodecs,
       
   233                                          package,
       
   234                                          KNullDesC8,
       
   235                                          package );
       
   236 
       
   237     if ( !err ) 
       
   238         {
       
   239         count =  package().iFourCCArray.Count();
       
   240         __INTERFACE_INT1( "MccInterface::GetSupportedCodecs, found", count )
       
   241         for( TInt i = 0; i < count; i++ )
       
   242             {
       
   243             if ( package().iFourCCArray[i] != NULL )
       
   244                 {
       
   245                 aCodecs.Append( package().iFourCCArray[i] );
       
   246                 }
       
   247             }
       
   248         }
       
   249     
       
   250     __INTERFACE_INT1( "MccInterface::GetSupportedCodecs, exit with ", err )
       
   251     return err;
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // CMccInterface::OpenControllerL()
       
   256 // Opens Mcc Controller
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 void CMccInterface::OpenControllerL( const TUid& aControllerUid )
       
   260     {
       
   261     __INTERFACE( "MccInterface::OpenControllerL" )
       
   262     TInt error = KErrNone;
       
   263     TMMFPrioritySettings settings;
       
   264     settings.iPriority = EPriorityNormal;
       
   265     
       
   266     CMMFControllerImplementationInformation* implInfo = 
       
   267         CMMFControllerImplementationInformation::NewL( aControllerUid );
       
   268         
       
   269     CleanupStack::PushL( implInfo );
       
   270 
       
   271     __INTERFACE_INT1( "MccInterface::OpenController, heapsize:", 
       
   272                       implInfo->HeapSpaceRequired() )
       
   273     
       
   274     error = iController.Open( *implInfo, settings );
       
   275     if ( error )
       
   276         {
       
   277         iController.Close();
       
   278         __INTERFACE_INT1( "MccInterface::OpenController, exit with", error)
       
   279         User::Leave( error );
       
   280         }
       
   281         
       
   282     CleanupStack::PopAndDestroy( implInfo );
       
   283 
       
   284     __INTERFACE_INT1( "MccInterface::OpenController, exit with", error)
       
   285     }
       
   286     
       
   287 // ---------------------------------------------------------------------------
       
   288 // CMccInterface::SetRemoteAddress
       
   289 // Set remote IP address and port number for a given RTP session.
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C TInt CMccInterface::SetRemoteAddress( TUint32 aSessionId, 
       
   293                                                TUint32 aLinkId,
       
   294                                                const TInetAddr& aRemoteAddr,
       
   295                                                TUint aRemoteRtcpPort )
       
   296     {
       
   297     __INTERFACE( "MccInterface::SetRemoteAddress" )
       
   298     TInt err = KErrNone;
       
   299     TMccAddress addr;
       
   300     addr.iSessionID = aSessionId;
       
   301     addr.iLinkID = aLinkId;
       
   302     addr.iAddress = aRemoteAddr;
       
   303     TMccAddressPckg package( addr );
       
   304 	if ( aRemoteRtcpPort == 0 )
       
   305 		{
       
   306 		err = iController.CustomCommandSync( iMessageDest,
       
   307                                          EMccSetRemoteAddress,
       
   308                                          package,
       
   309                                          KNullDesC8 );
       
   310 
       
   311 		}
       
   312 	if ( aRemoteRtcpPort != 0)
       
   313 		{
       
   314 		 __INTERFACE_INT1( "RtcpPort = ", aRemoteRtcpPort )
       
   315    
       
   316    		err = iController.CustomCommandSync( iMessageDest,
       
   317                                          EMccSetRemoteRtcpAddr,
       
   318                                          package,
       
   319                                          KNullDesC8 );
       
   320 		}
       
   321     __INTERFACE_INT1( "MccInterface::SetRemoteAddress, exit with ", err )
       
   322     return err;
       
   323     }
       
   324 
       
   325 // ---------------------------------------------------------------------------
       
   326 // CMccInterface::CreateSession
       
   327 // Creates a new RTP session with a remote participant.
       
   328 // ---------------------------------------------------------------------------
       
   329 //
       
   330 EXPORT_C TInt CMccInterface::CreateSession( TUint32& aSessionId )
       
   331     {
       
   332     __INTERFACE( "MccInterface::CreateSession" )
       
   333     TMccCreateSession pktSession;
       
   334     TMccCreateSessionPckg package( pktSession );
       
   335 
       
   336     TInt result = iController.CustomCommandSync( iMessageDest,
       
   337                                                  EMccCreateSession,
       
   338                                                  package,
       
   339                                                  KNullDesC8,
       
   340                                                  package );
       
   341 
       
   342     if ( result == KErrNone )
       
   343         {
       
   344         aSessionId = package().iSessionID;
       
   345         }
       
   346 
       
   347     __INTERFACE_INT1( "MccInterface::CreateSession, exit with ", result )
       
   348     return result;
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------------------------
       
   352 // CMccInterface::CreateLink
       
   353 // Creates a new Mcc link with a remote participant.
       
   354 // ---------------------------------------------------------------------------
       
   355 //
       
   356 EXPORT_C TInt CMccInterface::CreateLink( TUint32 aSessionId,
       
   357                                          TInt aLinkType,
       
   358                                          TUint32& aLinkId,
       
   359                                          TMccNetSettings& aNetSettings )
       
   360     {    
       
   361     __INTERFACE( "MccInterface::CreateLink")
       
   362     
       
   363     TMccCreateLink pktLink;
       
   364     pktLink.iSessionID = aSessionId;
       
   365     pktLink.iLinkType = aLinkType;
       
   366     pktLink.iIapId = aNetSettings.iIapId;
       
   367     pktLink.iRemoteAddress = aNetSettings.iRemoteAddress;
       
   368     pktLink.iLocalAddress.SetPort( aNetSettings.iLocalAddress.Port() );
       
   369     pktLink.iIpTOS = aNetSettings.iMediaQosValue;
       
   370     TMccCreateLinkPckg package( pktLink );
       
   371 
       
   372     TInt result = iController.CustomCommandSync( iMessageDest,
       
   373                                                  EMccCreateLink,
       
   374                                                  package,
       
   375                                                  KNullDesC8,
       
   376                                                  package );
       
   377 
       
   378     if ( KErrNone == result )
       
   379         {
       
   380         aLinkId = package().iLinkID;
       
   381         }
       
   382 
       
   383     __INTERFACE_INT1( "MccInterface::CreateLink, exit with ", result )
       
   384     return result;
       
   385     }
       
   386 
       
   387 // ---------------------------------------------------------------------------
       
   388 // CMccInterface::CloseSession
       
   389 // Closes RTP session.
       
   390 // ---------------------------------------------------------------------------
       
   391 //
       
   392 EXPORT_C TInt CMccInterface::CloseSession( TUint32 aSessionId )
       
   393     {
       
   394     __INTERFACE( "MccInterface::CloseSession" )
       
   395     TInt err = KErrNone;
       
   396     TMccSession sessID;
       
   397     sessID.iSessionID = aSessionId;
       
   398     TMccSessionPckg package( sessID );
       
   399 
       
   400     err = iController.CustomCommandSync( iMessageDest,
       
   401                                          EMccCloseSession,
       
   402                                          package,
       
   403                                          KNullDesC8 );
       
   404                                          
       
   405     __INTERFACE_INT1( "MccInterface::CloseSession, exit with ", err )
       
   406     return err;
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // CMccInterface::CloseLink
       
   411 // Closes Mcc link.
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 EXPORT_C TInt CMccInterface::CloseLink( TUint32 aSessionId, TUint32 aLinkId )
       
   415     {
       
   416     __INTERFACE( "MccInterface::CloseLink" )
       
   417     
       
   418     TInt err = KErrNone;
       
   419     TMccGenericMessage message;
       
   420     message.iSessionID = aSessionId;
       
   421     message.iLinkID = aLinkId;
       
   422     TMccGenericMsgBuffer package( message );
       
   423 
       
   424     err = iController.CustomCommandSync( iMessageDest,
       
   425                                          EMccCloseLink,
       
   426                                          package,
       
   427                                          KNullDesC8 );
       
   428                                          
       
   429     __INTERFACE_INT1( "MccInterface::CloseLink, exit with ", err )
       
   430     return err;
       
   431     }
       
   432 
       
   433 // ---------------------------------------------------------------------------
       
   434 // CMccInterface::CreateStream
       
   435 // Creates a stream to a RTP session.
       
   436 // ---------------------------------------------------------------------------
       
   437 //
       
   438 EXPORT_C TInt CMccInterface::CreateStream( TUint32 aSessionId, 
       
   439                                            TUint32 aLinkId,
       
   440                                            TUint32& aStreamId,
       
   441                                            TInt aStreamType,
       
   442                                            CMccCodecInformation& aCodecInformation )
       
   443     {
       
   444     __INTERFACE( "MccInterface::CreateStream" )
       
   445 
       
   446     TMccGenericMessage genMessage;
       
   447     genMessage.iSessionID = aSessionId;
       
   448     genMessage.iLinkID = aLinkId;
       
   449         
       
   450     TMccGenericMsgBuffer msgBuffer( genMessage );
       
   451     TMccCreateStreamParam message;
       
   452     message.iPayloadType = aCodecInformation.PayloadType();
       
   453     message.iFourCC = aCodecInformation.FourCC();
       
   454     message.iStreamType = aStreamType;
       
   455     message.iPrioritySettings.iPriority = aCodecInformation.Priority();
       
   456     message.iPrioritySettings.iPref =
       
   457     TMdaPriorityPreference( aCodecInformation.PriorityPreference() );
       
   458     message.iStandByTimer = aCodecInformation.JitterBufInactivityTimeOut();
       
   459     TMccCreateStreamParamPckg messagePckg( message );
       
   460      
       
   461     /* Call the controller */
       
   462     TInt err = iController.CustomCommandSync( iMessageDest, EMccCreateStream,
       
   463                                          msgBuffer, messagePckg,
       
   464                                          msgBuffer );
       
   465 
       
   466     if( err != KErrNone )
       
   467         {
       
   468         return err;
       
   469         }
       
   470 
       
   471     aStreamId = msgBuffer().iStreamID;
       
   472     err = this->SetCodec( aSessionId, aLinkId, aStreamId, aCodecInformation );
       
   473         
       
   474     __INTERFACE_INT1( "MccInterface::CreateStream, exit with ", err )
       
   475     return err;
       
   476     }
       
   477 
       
   478 // ---------------------------------------------------------------------------
       
   479 // CMccInterface::DeleteStream
       
   480 // Deletes media stream in a given session.
       
   481 // ---------------------------------------------------------------------------
       
   482 //
       
   483 EXPORT_C TInt CMccInterface::DeleteStream( TUint32 aSessionId, 
       
   484                                            TUint32 aLinkId, 
       
   485                                            TUint32 aStreamId )
       
   486     {
       
   487     __INTERFACE( "MccInterface::DeleteStream" )
       
   488     TInt err = KErrNone;
       
   489     TMccSession sessID;
       
   490     sessID.iSessionID = aSessionId;
       
   491     sessID.iLinkID = aLinkId;
       
   492     sessID.iStreamID = aStreamId;
       
   493     TMccSessionPckg package( sessID );
       
   494 
       
   495     err = iController.CustomCommandSync( iMessageDest,
       
   496                                          EMccDeleteStream,
       
   497                                          package,
       
   498                                          KNullDesC8 );
       
   499 
       
   500     __INTERFACE_INT1( "MccInterface::DeleteStream, exit with ", err )
       
   501     return err;
       
   502     }
       
   503 
       
   504 // ---------------------------------------------------------------------------
       
   505 // CMccInterface::StartInactivityTimer
       
   506 // Starts inactivity timer for a stream in a given session.
       
   507 // ---------------------------------------------------------------------------
       
   508 //
       
   509 EXPORT_C TInt CMccInterface::StartInactivityTimer( TUint32 aSessionId,
       
   510                                                    TUint32 aLinkId,
       
   511                                                    TUint32 aStreamId,
       
   512                                                    TUint32 aTimeoutTime,
       
   513                                                    TUint32 /*aEndpointId*/ )
       
   514     {
       
   515     __INTERFACE( "MccInterface::StartInactivityTimer" )
       
   516     TMccInactivityTimer inactivityTimer;
       
   517     inactivityTimer.iSessionID = aSessionId;
       
   518     inactivityTimer.iLinkID = aLinkId;
       
   519     inactivityTimer.iStreamID = aStreamId;
       
   520     inactivityTimer.iTimeoutTime = aTimeoutTime;
       
   521     TMccInactivityTimerPckg package( inactivityTimer );
       
   522     
       
   523     TInt err = iController.CustomCommandSync( iMessageDest,
       
   524                                               EMccInactivityTimerStart,
       
   525                                               package,
       
   526                                               KNullDesC8 );
       
   527     
       
   528     __INTERFACE_INT1( "MccInterface::StartInactivityTimer, exit with ", err )
       
   529     return err;
       
   530     } 
       
   531 
       
   532 // ---------------------------------------------------------------------------
       
   533 // CMccInterface::StopInactivityTimer
       
   534 // Stops inactivity timer for a stream in a given session.
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 EXPORT_C TInt CMccInterface::StopInactivityTimer( TUint32 aSessionId,
       
   538                                                   TUint32 aLinkId,
       
   539                                                   TUint32 aStreamId,
       
   540                                                   TUint32 aEndpointId )
       
   541     {
       
   542     __INTERFACE( "MccInterface::StopInactivityTimer" )
       
   543     TMccGenericMessage genMessage;
       
   544     genMessage.iSessionID = aSessionId;
       
   545     genMessage.iLinkID = aLinkId;
       
   546     genMessage.iStreamID = aStreamId;
       
   547     genMessage.iEndpointID = aEndpointId;
       
   548     TMccGenericMsgBuffer msgBuffer( genMessage );
       
   549     
       
   550     TInt err = iController.CustomCommandSync( iMessageDest,
       
   551                                               EMccInactivityTimerStop,
       
   552                                               msgBuffer,
       
   553                                               KNullDesC8 );
       
   554 
       
   555     __INTERFACE_INT1( "MccInterface::StopInactivityTimer, exit with ", err )
       
   556     return err;
       
   557     }
       
   558 
       
   559 // ---------------------------------------------------------------------------
       
   560 // CMccInterface::PrepareStream
       
   561 // Prepares a stream so that it is ready to be started.
       
   562 // ---------------------------------------------------------------------------
       
   563 //
       
   564 EXPORT_C TInt CMccInterface::PrepareStream( TUint32 aSessionId, 
       
   565                                             TUint32 aLinkId, 
       
   566                                             TUint32 aStreamId,
       
   567                                             TUint32 aSinkSourceId )
       
   568     {
       
   569     __INTERFACE( "MccInterface::PrepareStream" )
       
   570     TInt err = KErrNone;
       
   571     TMccSession sessID;
       
   572     sessID.iSessionID = aSessionId;
       
   573     sessID.iLinkID = aLinkId;
       
   574     sessID.iStreamID = aStreamId;
       
   575     sessID.iEndpointID = aSinkSourceId;
       
   576     TMccSessionPckg package( sessID );
       
   577 
       
   578     err = iController.CustomCommandSync( iMessageDest,
       
   579                                          EMccPrepareStream,
       
   580                                          package,
       
   581                                          KNullDesC8 );
       
   582 
       
   583     __INTERFACE_INT1( "MccInterface::PrepareStream, exit with ", err )
       
   584     return err;
       
   585     }
       
   586 
       
   587 
       
   588 // ---------------------------------------------------------------------------
       
   589 // CMccInterface::StartStream
       
   590 // Starts to send/receive media stream in a given session.
       
   591 // ---------------------------------------------------------------------------
       
   592 //
       
   593 EXPORT_C TInt CMccInterface::StartStream( TUint32 aSessionId, 
       
   594                                           TUint32 aLinkId, 
       
   595                                           TUint32 aStreamId,
       
   596                                           TUint32 aSinkSourceId,
       
   597                                           TBool aPaused,
       
   598                                           TBool aEnableRTCP )
       
   599     {
       
   600     __INTERFACE( "MccInterface::StartStream" )
       
   601     TInt err = KErrNone;
       
   602     TMccStream params;
       
   603     params.iSessionID = aSessionId;
       
   604     params.iLinkID = aLinkId;
       
   605     params.iStreamID = aStreamId;
       
   606     params.iEndpointID = aSinkSourceId;
       
   607     params.iStreamPaused = aPaused;
       
   608     params.iEnableRTCP = aEnableRTCP;
       
   609     TMccStreamPckg package( params );
       
   610 
       
   611     err = iController.CustomCommandSync( iMessageDest,
       
   612                                          EMccStartStream,
       
   613                                          package,
       
   614                                          KNullDesC8 );
       
   615 
       
   616     __INTERFACE_INT1( "MccInterface::StartStream, exit with ", err )
       
   617     return err;
       
   618     }
       
   619 
       
   620 
       
   621 // ---------------------------------------------------------------------------
       
   622 // CMccInterface::PauseStream
       
   623 // Pauses media stream in a given session. No RTP packets are send/received anymore.
       
   624 // ---------------------------------------------------------------------------
       
   625 //
       
   626 EXPORT_C TInt CMccInterface::PauseStream( TUint32 aSessionId, 
       
   627                                           TUint32 aLinkId, 
       
   628                                           TUint32 aStreamId,
       
   629                                           TUint32 aSinkSourceId,
       
   630                                           TBool aEnableRTCP )
       
   631     {
       
   632     __INTERFACE( "MccInterface::PauseStream" )
       
   633     TInt err = KErrNone;
       
   634     TMccStream params;
       
   635     params.iSessionID = aSessionId;
       
   636     params.iLinkID = aLinkId;
       
   637     params.iStreamID = aStreamId;
       
   638     params.iEndpointID = aSinkSourceId;
       
   639     params.iEnableRTCP = aEnableRTCP;
       
   640     TMccStreamPckg package( params );
       
   641 
       
   642     err = iController.CustomCommandSync( iMessageDest,
       
   643                                          EMccPauseStream,
       
   644                                          package,
       
   645                                          KNullDesC8 );
       
   646                                          
       
   647     __INTERFACE_INT1( "MccInterface::PauseStream, exit with ", err )
       
   648     return err;
       
   649     }
       
   650 
       
   651 
       
   652 // ---------------------------------------------------------------------------
       
   653 // CMccInterface::ResumeStream
       
   654 // Resumes paused media stream in a given session.
       
   655 // ---------------------------------------------------------------------------
       
   656 //
       
   657 EXPORT_C TInt CMccInterface::ResumeStream( TUint32 aSessionId, 
       
   658                                            TUint32 aLinkId, 
       
   659                                            TUint32 aStreamId,
       
   660                                            TUint32 aSinkSourceId,
       
   661                                            TBool aEnableRTCP )
       
   662     {
       
   663     __INTERFACE( "MccInterface::ResumeStream" )
       
   664     TInt err = KErrNone;
       
   665     TMccStream params;
       
   666     params.iSessionID = aSessionId;
       
   667     params.iLinkID = aLinkId;
       
   668     params.iStreamID = aStreamId;
       
   669     params.iEndpointID = aSinkSourceId;
       
   670     params.iEnableRTCP = aEnableRTCP;
       
   671     TMccStreamPckg package( params );
       
   672 
       
   673     err = iController.CustomCommandSync( iMessageDest,
       
   674                                          EMccResumeStream,
       
   675                                          package,
       
   676                                          KNullDesC8 );
       
   677 
       
   678     __INTERFACE_INT1( "MccInterface::ResumeStream, exit with ", err )
       
   679     return err;
       
   680     }
       
   681 
       
   682 
       
   683 // ---------------------------------------------------------------------------
       
   684 // CMccInterface::StopStream
       
   685 // Stops sending/receiving media stream in a given session.
       
   686 // ---------------------------------------------------------------------------
       
   687 //
       
   688 EXPORT_C TInt CMccInterface::StopStream( TUint32 aSessionId, 
       
   689                                          TUint32 aLinkId, 
       
   690                                          TUint32 aStreamId,
       
   691                                          TUint32 aSinkSourceId )
       
   692     {
       
   693     __INTERFACE( "MccInterface::StopStream" )
       
   694     TInt err = KErrNone;
       
   695     TMccSession sessID;
       
   696     sessID.iSessionID = aSessionId;
       
   697     sessID.iLinkID = aLinkId;
       
   698     sessID.iStreamID = aStreamId;
       
   699     sessID.iEndpointID = aSinkSourceId;
       
   700     TMccSessionPckg package( sessID );
       
   701 
       
   702     err = iController.CustomCommandSync( iMessageDest,
       
   703                                          EMccStopStream,
       
   704                                          package,
       
   705                                          KNullDesC8 );
       
   706 
       
   707 
       
   708     __INTERFACE_INT1( "MccInterface::StopStream, exit with ", err )
       
   709     return err;
       
   710     }
       
   711 
       
   712 // -----------------------------------------------------------------------------
       
   713 // CMccInterfaceImpl::GetCodecL()
       
   714 // Gets current codec used in a given stream.
       
   715 // -----------------------------------------------------------------------------
       
   716 //
       
   717 EXPORT_C CMccCodecInformation* CMccInterface::CodecL( TUint32 aSessionId,
       
   718                                                       TUint32 aLinkId,
       
   719                                                       TUint32 aStreamId )
       
   720     {
       
   721     __INTERFACE( "MccInterface::GetCodecL" )    
       
   722     TMccGenericMessage msg;
       
   723     msg.iSessionID = aSessionId;
       
   724     msg.iLinkID = aLinkId;
       
   725     msg.iStreamID = aStreamId;
       
   726     TMccGenericMsgBuffer msgBuffer( msg );
       
   727     
       
   728     TMccCodecInfo codecInfo;
       
   729     TMccCodecInfoBuffer codecBuffer( codecInfo );
       
   730     
       
   731     TInt err = iController.CustomCommandSync( iMessageDest, EMccGetCodec, msgBuffer,
       
   732                                          KNullDesC8, codecBuffer );
       
   733     
       
   734     if ( err != KErrNone )
       
   735         {
       
   736         User::Leave( err );
       
   737         }
       
   738         
       
   739     // Now we need to find the correspoding codec from iCodecArray & clone it.
       
   740     // Then we need to set the parameters returned from controller which are in codecInfo
       
   741     // to that cloned codec.
       
   742     TInt count = iCodecInformation.Count();
       
   743     TInt index = KErrNotFound;
       
   744     TInt counter = 0;
       
   745     
       
   746     // If fourcc match, we've got the right one.
       
   747     TFourCC fourcc;
       
   748     while ( counter < count )
       
   749         {
       
   750         fourcc = iCodecInformation[counter]->FourCC();
       
   751         if( fourcc == codecBuffer().iFourCC )
       
   752             {
       
   753             index = counter;
       
   754             counter = count;
       
   755             }
       
   756         
       
   757         counter++;
       
   758         }
       
   759     
       
   760     if( index == KErrNotFound )
       
   761         {
       
   762         User::Leave( KErrNotFound );
       
   763         }
       
   764 
       
   765     CMccCodecInformation* retCodec = iCodecInformation[index]->CloneDetailedL();
       
   766     retCodec->SetValues( codecBuffer() );
       
   767     retCodec->CreateFmtpAttrListL();
       
   768             
       
   769     __INTERFACE( "MccInterface::GetCodecL, exit" )    
       
   770     return retCodec;
       
   771     }
       
   772 
       
   773 // ---------------------------------------------------------------------------
       
   774 // CMccInterface::SetCodec
       
   775 // Sets codec to be used in a given stream.
       
   776 // ---------------------------------------------------------------------------
       
   777 //
       
   778 EXPORT_C TInt CMccInterface::SetCodec( TUint32 aSessionId, 
       
   779                                        TUint32 aLinkId, 
       
   780                                        TUint32 aStreamId, 
       
   781                                        CMccCodecInformation& aCodecInformation
       
   782                                        )
       
   783     {
       
   784     __INTERFACE( "MccInterface::SetCodec" )      
       
   785     TMccCodecInfo codecInfo;
       
   786     
       
   787     aCodecInformation.GetValues( codecInfo );         
       
   788     codecInfo.iSessionID = aSessionId;
       
   789     codecInfo.iLinkID    = aLinkId;
       
   790     codecInfo.iStreamID  = aStreamId;
       
   791     TMccCodecInfoBuffer infoBuffer( codecInfo );
       
   792     
       
   793     __INTERFACE_INT1( "MccInterface SessionID", codecInfo.iSessionID )     
       
   794     __INTERFACE_INT1( "MccInterface LinkID", codecInfo.iLinkID )     
       
   795     __INTERFACE_INT1( "MccInterface StreamID", codecInfo.iStreamID )     
       
   796     __INTERFACE_INT1( "MccInterface FourCC", codecInfo.iFourCC.FourCC() )      
       
   797     __INTERFACE_INT1( "MccInterface AlgoUsed", codecInfo.iAlgoUsed )      
       
   798     __INTERFACE_INT1( "MccInterface Bitrate", codecInfo.iBitrate )      
       
   799     __INTERFACE_INT1( "MccInterface CodecMode", codecInfo.iCodecMode )      
       
   800     __INTERFACE_INT1( "MccInterface EnableDTX", codecInfo.iEnableDTX )      
       
   801     __INTERFACE_INT1( "MccInterface MaxPtime", codecInfo.iMaxPtime )      
       
   802     __INTERFACE_INT1( "MccInterface Ptime", codecInfo.iPtime )      
       
   803     __INTERFACE_INT1( "MccInterface PayloadType", codecInfo.iPayloadType )      
       
   804     __INTERFACE_INT1( "MccInterface RedundantPayload", 
       
   805                       codecInfo.iRedundantPayload )      
       
   806     __INTERFACE_INT1( "MccInterface RedundancyCount", codecInfo.iRedundancyCount )      
       
   807     __INTERFACE_INT1( "MccInterface FrameSize", codecInfo.iFrameSize )      
       
   808     __INTERFACE_INT1( "MccInterface HwFrameTime", codecInfo.iHwFrameTime )      
       
   809     __INTERFACE_INT1( "MccInterface BitrateMask", codecInfo.iBitrateMask )      
       
   810     __INTERFACE_INT1( "MccInterface AverageBitrate", codecInfo.iAverageBitrate )      
       
   811     __INTERFACE_INT1( "MccInterface Framerate", (TInt) codecInfo.iFramerate )
       
   812     __INTERFACE_INT1( "MccInterface iComfortNoiseGenerationPt", 
       
   813                       codecInfo.iComfortNoiseGenerationPt )      
       
   814     __INTERFACE_INT1( "MccInterface VideoWidth", codecInfo.iVideoWidth )     
       
   815     __INTERFACE_INT1( "MccInterface VideoHeight", codecInfo.iVideoHeight )     
       
   816     __INTERFACE_INT1( "MccInterface JitterBufInactivityTimeOut", 
       
   817                       codecInfo.iJitterBufInactivityTimeOut )     
       
   818     __INTERFACE_INT1( "MccInterface JitterBufThreshold", 
       
   819                       codecInfo.iJitterBufThreshold )     
       
   820     __INTERFACE_INT1( "MccInterface JitterBufBufferLength", 
       
   821                       codecInfo.iJitterBufBufferLength )     
       
   822     __INTERFACE_INT1( "MccInterface JitterBufPlayToneTimeout", 
       
   823                       codecInfo.iJitterBufPlayToneTimeout )     
       
   824     __INTERFACE_INT1( "MccInterface JitterBufPlayToneFrequency", 
       
   825                       codecInfo.iJitterBufPlayToneFrequency )     
       
   826     __INTERFACE_INT1( "MccInterface JitterBufPlayToneDuration", 
       
   827                       codecInfo.iJitterBufPlayToneDuration )     
       
   828     __INTERFACE_INT1( "MccInterface Priority", codecInfo.iPriority.iPriority )     
       
   829     __INTERFACE_INT1( "MccInterface Preference", codecInfo.iPriority.iPref )
       
   830     __INTERFACE_INT1( "MccInterface iModeChangePeriod", 
       
   831                       codecInfo.iModeChangePeriod )     
       
   832     __INTERFACE_INT1( "MccInterface iNeighbor", codecInfo.iNeighbor )        
       
   833     __INTERFACE_INT1( "MccInterface Keepalive interval", 
       
   834                       codecInfo.iKeepaliveInterval )
       
   835     __INTERFACE_INT1( "MccInterface Keepalive payloadtype", 
       
   836                       codecInfo.iKeepalivePT )   
       
   837     __INTERFACE_INT1( "MccInterface Keepalive data len", 
       
   838                       codecInfo.iKeepaliveData.Length() )   
       
   839     __INTERFACE_INT1( "MccInterface MaxRed", codecInfo.iMaxRed )  
       
   840     
       
   841     TInt err = iController.CustomCommandSync( iMessageDest,
       
   842                                          EMccSetCodec,
       
   843                                          infoBuffer,
       
   844                                          KNullDesC8,
       
   845                                          infoBuffer );
       
   846     
       
   847     // Return payloadtype allocated
       
   848     aCodecInformation.SetPayloadType( infoBuffer().iPayloadType );
       
   849     
       
   850     __INTERFACE_INT1( "MccInterface Final PayloadType",
       
   851         aCodecInformation.PayloadType() )
       
   852     __INTERFACE_INT1( "MccInterface::SetCodec err",
       
   853         err )
       
   854     
       
   855     return err;    
       
   856     }
       
   857   
       
   858 // ---------------------------------------------------------------------------
       
   859 // CMccInterface::GetCapabilities
       
   860 // Get Capabilities
       
   861 // ---------------------------------------------------------------------------
       
   862 //
       
   863 EXPORT_C TInt CMccInterface::GetCapabilities(
       
   864                   RPointerArray<CMccCodecInformation>& aCodecInformation ) const
       
   865     {
       
   866     __INTERFACE( "MccInterface::GetCapabilities" )      
       
   867     TInt count = iCodecInformation.Count();
       
   868     aCodecInformation.ResetAndDestroy();
       
   869     
       
   870     if( count )
       
   871         {
       
   872         CMccCodecInformation* tempCodec = NULL;
       
   873         TInt err( KErrNone );
       
   874         
       
   875         for ( TInt i = 0; i < count; i++ )
       
   876             {
       
   877             // FIX ME for leavescan, easiest way to do this is to introduce an API
       
   878             // break so we can do harm on offending clients.
       
   879             TRAP( err, (tempCodec = iCodecInformation[i]->CloneDefaultsL()) );
       
   880             
       
   881             if( err != KErrNone )
       
   882                 {
       
   883                 aCodecInformation.ResetAndDestroy();
       
   884                 return err;
       
   885                 }
       
   886             
       
   887             err = aCodecInformation.Append( tempCodec );
       
   888             
       
   889             if (err != KErrNone )
       
   890                 {
       
   891                 delete tempCodec;
       
   892                 }
       
   893             }
       
   894 
       
   895         return err;
       
   896         }
       
   897     else
       
   898         {
       
   899         return KErrNotReady;
       
   900         }
       
   901     }
       
   902 
       
   903 
       
   904 // ---------------------------------------------------------------------------
       
   905 // CMccInterface::SendMediaSignalL
       
   906 // Sends media signalling to uplink if possible
       
   907 // ---------------------------------------------------------------------------
       
   908 //
       
   909 EXPORT_C void CMccInterface::SendMediaSignalL( const TMccEvent& aEvent )
       
   910     {
       
   911     __INTERFACE( "MccInterface::SendMediaSignalL" )      
       
   912     TMccEventPackage pack( aEvent );
       
   913     TInt err = iController.CustomCommandSync( iMessageDest, 
       
   914                                               EMccSendMediaSignal,
       
   915                                               pack, KNullDesC8 );
       
   916     User::LeaveIfError( err );
       
   917     }
       
   918 /*
       
   919 // ---------------------------------------------------------------------------
       
   920 // CMccInterface::GetCodecDefaultsL
       
   921 // ---------------------------------------------------------------------------
       
   922 //
       
   923 EXPORT_C CMccCodecInformation* CMccInterface::GetCodecDefaultsL(
       
   924     const TUid aType, TInt aStreamType, const TDesC8& aParam )
       
   925     {
       
   926     __INTERFACE( "MccInterface::GetCodecDefaultsL" )      
       
   927     TMccCodecInfo codecInfo;
       
   928     
       
   929     TMccGenericMessage msg;
       
   930     msg.iSessionID = 0;
       
   931     msg.iLinkID = 0;
       
   932     msg.iStreamID = aType.iUid;
       
   933     msg.iParam1 = aParam;
       
   934     TMccGenericMsgBuffer msgBuffer( msg );
       
   935 
       
   936     if (aStreamType == EMccAudioUplinkStream ||
       
   937         aStreamType == EMccAudioDownlinkStream ||
       
   938         aStreamType == KMccAudioLocalStream )
       
   939         {
       
   940         codecInfo.iType = KUidMediaTypeAudio;
       
   941         }
       
   942     else
       
   943         {
       
   944         codecInfo.iType = KUidMediaTypeVideo;        
       
   945         }    
       
   946         
       
   947     TMccCodecInfoBuffer codecBuffer( codecInfo );
       
   948     
       
   949     User::LeaveIfError(iController.CustomCommandSync( iMessageDest, EMccGetCodec, msgBuffer,
       
   950                                          KNullDesC8, codecBuffer ) );
       
   951     
       
   952     // Now we need to find the correspoding codec from iCodecArray & clone it.
       
   953     // Then we need to set the parameters returned from controller which are in codecInfo
       
   954     // to that cloned codec.
       
   955     TInt count = iCodecInformation.Count();
       
   956     TInt index = KErrNotFound;
       
   957     TInt counter = 0;
       
   958     
       
   959     // If fourcc match, we've got the right one.
       
   960     TFourCC fourcc;
       
   961     while ( counter < count )
       
   962         {
       
   963         fourcc = iCodecInformation[counter]->FourCC();
       
   964         if( fourcc == codecBuffer().iFourCC )
       
   965             {
       
   966             index = counter;
       
   967             counter = count;
       
   968             }        
       
   969         counter++;
       
   970         }
       
   971     
       
   972     // See if we've found the correct codec...
       
   973     if( index == KErrNotFound )
       
   974         {
       
   975         User::Leave( KErrNotFound );
       
   976         }
       
   977 
       
   978     CMccCodecInformation* retCodec = iCodecInformation[index]->CloneDetailedL();
       
   979     retCodec->SetValues( codecBuffer() );
       
   980     retCodec->CreateFmtpAttrListL();                
       
   981     return retCodec;    
       
   982     }
       
   983 */
       
   984 
       
   985 // ---------------------------------------------------------------------------
       
   986 // CMccInterface::GetDefaultCapabilities
       
   987 // ---------------------------------------------------------------------------
       
   988 //
       
   989 EXPORT_C TInt CMccInterface::GetCapabilities( const TUid /*aType*/, TInt /*aStreamType*/,
       
   990     const TDesC8& /*aParam*/, RPointerArray<CMccCodecInformation>& /*aCapabilities*/ )
       
   991     {
       
   992     return KErrNotSupported;
       
   993     }
       
   994 
       
   995 // ---------------------------------------------------------------------------
       
   996 // CMccInterface::LinkExists
       
   997 // ---------------------------------------------------------------------------
       
   998 //
       
   999 EXPORT_C TBool CMccInterface::LinkExists( TUint32 /*aSessionId*/,
       
  1000     TUint32& /*aLinkId*/, const TMccNetSettings& /*aNetSettings*/ )
       
  1001     {
       
  1002     __INTERFACE( "MccInterface::LinkExists" )      
       
  1003     return EFalse;
       
  1004     }
       
  1005 
       
  1006 // ---------------------------------------------------------------------------
       
  1007 // CMccInterface::GetSSRC
       
  1008 // Get Synchronization source
       
  1009 // ---------------------------------------------------------------------------
       
  1010 //
       
  1011 EXPORT_C TInt CMccInterface::GetSSRC( TUint32 aSessionId,
       
  1012                                          TUint32 aLinkId,
       
  1013                                          TUint32 aStreamId,
       
  1014                                          TUint32 aEndpointId,
       
  1015                                          TUint32& aSSRC )
       
  1016     {
       
  1017     __INTERFACE( "MccInterface::GetSSRC" )      
       
  1018     TMccGenericMessage message;
       
  1019     message.iSessionID = aSessionId;
       
  1020     message.iLinkID    = aLinkId;
       
  1021     message.iStreamID  = aStreamId;
       
  1022     message.iEndpointID  = aEndpointId;
       
  1023     TMccGenericMsgBuffer messagePckg( message );
       
  1024     
       
  1025     // payload contains SSRC info
       
  1026     TMccSSRC     ssrc;
       
  1027     TMccSSRCPckg ssrcPckg ( ssrc );
       
  1028     
       
  1029     TInt err = iController.CustomCommandSync( iMessageDest, 
       
  1030                                               EMccGetSSRC,
       
  1031                                               messagePckg, 
       
  1032                                               KNullDesC8,
       
  1033                                               ssrcPckg 
       
  1034                                              );
       
  1035 
       
  1036     if ( err == KErrNone )
       
  1037         {
       
  1038         aSSRC = ssrcPckg().iSSRC;// ssrc.iSSRC; 
       
  1039         }
       
  1040         
       
  1041     __INTERFACE_INT1( "MccInterface::GetSSRC, exit with", err)      
       
  1042     return err;
       
  1043     }
       
  1044         
       
  1045 // ---------------------------------------------------------------------------
       
  1046 // CMccInterface::AddDataSink
       
  1047 // ---------------------------------------------------------------------------
       
  1048 //
       
  1049 EXPORT_C TInt CMccInterface::AddDataSink( const TUid aSinkType, 
       
  1050     const TDesC8& aParam, TUint32& aSinkSourceId )
       
  1051     {
       
  1052     __INTERFACE_INT1( "MccInterface::AddDataSink, type", aSinkType.iUid )
       
  1053     __INTERFACE_INT1( "MccInterface::AddDataSink, initdata len:", aParam.Length() )
       
  1054         
       
  1055     TInt err = KErrNone;
       
  1056     TMMFMessageDestination handleInfo;
       
  1057     err = iController.AddDataSink( aSinkType, aParam, handleInfo );
       
  1058     if ( err == KErrNone )
       
  1059         {
       
  1060         TMccSession sessID;
       
  1061         TMccSessionPckg package( sessID );
       
  1062 
       
  1063         err = iController.CustomCommandSync( iMessageDest,
       
  1064                                              EMccGetSinkId,
       
  1065                                              package,
       
  1066                                              KNullDesC8,
       
  1067                                              package );
       
  1068         
       
  1069         if ( !err )
       
  1070             {
       
  1071             aSinkSourceId = package().iEndpointID;
       
  1072             
       
  1073             StoreEndpointInfo( aSinkSourceId, handleInfo );
       
  1074             }
       
  1075         }
       
  1076 
       
  1077     __INTERFACE_INT1( "MccInterface::AddDataSink, exit with", err)      
       
  1078     return err;        
       
  1079     }
       
  1080 
       
  1081 // ---------------------------------------------------------------------------
       
  1082 // CMccInterface::AddDataSource
       
  1083 // ---------------------------------------------------------------------------
       
  1084 //
       
  1085 EXPORT_C TInt CMccInterface::AddDataSource( const TUid aSourceType,
       
  1086     const TDesC8& aParam, TUint32& aSinkSourceId )
       
  1087     {
       
  1088     __INTERFACE_INT1( "MccInterface::AddDataSource, type", aSourceType.iUid )
       
  1089     __INTERFACE_INT1( "MccInterface::AddDataSource, initdata len:", aParam.Length() )
       
  1090     
       
  1091     TInt err = KErrNone;
       
  1092     TMMFMessageDestination handleInfo;
       
  1093     err = iController.AddDataSource( aSourceType, aParam, handleInfo );        
       
  1094     if ( err == KErrNone )
       
  1095         {
       
  1096         TMccSession sessID;
       
  1097         TMccSessionPckg package( sessID );
       
  1098 
       
  1099         err = iController.CustomCommandSync( iMessageDest,
       
  1100                                              EMccGetSourceId,
       
  1101                                              package,
       
  1102                                              KNullDesC8,
       
  1103                                              package );
       
  1104         
       
  1105         if ( !err )
       
  1106             {
       
  1107             aSinkSourceId = package().iEndpointID;
       
  1108             
       
  1109             StoreEndpointInfo( aSinkSourceId, handleInfo );
       
  1110             }
       
  1111         }
       
  1112 
       
  1113     __INTERFACE_INT1( "MccInterface::AddDataSource, exit with", err)      
       
  1114     return err;        
       
  1115     }
       
  1116 
       
  1117 // ---------------------------------------------------------------------------
       
  1118 // CMccInterface::GetSupportedBitrates
       
  1119 // Gets supported bit rates from the codec of the specified stream
       
  1120 // ---------------------------------------------------------------------------
       
  1121 //
       
  1122 EXPORT_C TBool CMccInterface::StreamsExists( TUint32 aSessionId,
       
  1123     TUint32 aLinkId )
       
  1124     {
       
  1125     __INTERFACE( "MccInterface::StreamsExists" )
       
  1126     TMccGenericMessage genMessage;
       
  1127     genMessage.iSessionID = aSessionId;
       
  1128     genMessage.iLinkID = aLinkId;
       
  1129     TMccGenericMsgBuffer messagePckg( genMessage );
       
  1130 
       
  1131     TInt result = iController.CustomCommandSync( iMessageDest,
       
  1132                                                  EMccStreamsExists,
       
  1133                                                  messagePckg,
       
  1134                                                  KNullDesC8 );
       
  1135 
       
  1136     TBool ret = EFalse;
       
  1137     if ( result == KErrNone )
       
  1138         {
       
  1139         ret = ETrue;
       
  1140         }
       
  1141 
       
  1142     __INTERFACE_INT1( "MccInterface::StreamsExists, exit with ", ret )
       
  1143     return ret;
       
  1144     }
       
  1145 
       
  1146 // ---------------------------------------------------------------------------
       
  1147 // CMccInterface::UpdateDataSink
       
  1148 // ---------------------------------------------------------------------------
       
  1149 //
       
  1150 EXPORT_C TInt CMccInterface::UpdateDataSink( TUint32 aSessionId, TUint32 aLinkId, 
       
  1151                              TUint32 aStreamId, TUint32 aEndpointId,
       
  1152                              const TDesC8& aParam )
       
  1153     {
       
  1154     __INTERFACE( "MccInterface::UpdateDataSink" )
       
  1155     TInt err = KErrNone;
       
  1156     TMccStream params;
       
  1157     params.iSessionID = aSessionId;
       
  1158     params.iLinkID = aLinkId;
       
  1159     params.iStreamID = aStreamId;
       
  1160     params.iEndpointID = aEndpointId;
       
  1161     TMccStreamPckg package( params );
       
  1162 
       
  1163     err = iController.CustomCommandSync( iMessageDest,
       
  1164                                          EMccUpdateDataSink,
       
  1165                                          package,
       
  1166                                          aParam );
       
  1167                                          
       
  1168     __INTERFACE_INT1( "MccInterface::UpdateDataSink, exit with ", err )
       
  1169     return err;
       
  1170     }
       
  1171         
       
  1172 // ---------------------------------------------------------------------------
       
  1173 // CMccInterface::UpdateDataSource
       
  1174 // ---------------------------------------------------------------------------
       
  1175 //
       
  1176 EXPORT_C TInt CMccInterface::UpdateDataSource( TUint32 aSessionId, TUint32 aLinkId, 
       
  1177                            TUint32 aStreamId, TUint32 aEndpointId,
       
  1178                            const TDesC8& aParam )
       
  1179     {
       
  1180     __INTERFACE( "MccInterface::UpdateDataSource" )
       
  1181     TInt err = KErrNone;
       
  1182     TMccStream params;
       
  1183     params.iSessionID = aSessionId;
       
  1184     params.iLinkID = aLinkId;
       
  1185     params.iStreamID = aStreamId;
       
  1186     params.iEndpointID = aEndpointId;
       
  1187     TMccStreamPckg package( params );
       
  1188 
       
  1189     err = iController.CustomCommandSync( iMessageDest,
       
  1190                                          EMccUpdateDataSource,
       
  1191                                          package,
       
  1192                                          aParam );
       
  1193                                          
       
  1194     __INTERFACE_INT1( "MccInterface::UpdateDataSource, exit with ", err )
       
  1195     return err;
       
  1196     }
       
  1197 
       
  1198 // ---------------------------------------------------------------------------
       
  1199 // CMccInterface::RemoveDataSink
       
  1200 // ---------------------------------------------------------------------------
       
  1201 //    
       
  1202 EXPORT_C TInt CMccInterface::RemoveDataSink( 
       
  1203     TUint32 /*aSessionId*/, 
       
  1204     TUint32 /*aLinkId*/, 
       
  1205     TUint32 /*aStreamId*/, 
       
  1206     TUint32 aEndpointId )
       
  1207     {
       
  1208     TInt err = KErrNone;
       
  1209     
       
  1210     TMMFMessageDestination sourceHandleInfo = FindEndpointInfo( aEndpointId, err );
       
  1211     if ( !err )
       
  1212         {
       
  1213         err = iController.RemoveDataSink( sourceHandleInfo );
       
  1214         RemoveEndpointInfo( aEndpointId );
       
  1215         }
       
  1216         
       
  1217     return err;
       
  1218     }
       
  1219 
       
  1220 // ---------------------------------------------------------------------------
       
  1221 // CMccInterface::RemoveDataSource
       
  1222 // ---------------------------------------------------------------------------
       
  1223 //
       
  1224 EXPORT_C TInt CMccInterface::RemoveDataSource( 
       
  1225     TUint32 /*aSessionId*/, 
       
  1226     TUint32 /*aLinkId*/, 
       
  1227     TUint32 /*aStreamId*/, 
       
  1228     TUint32 aEndpointId )
       
  1229     {
       
  1230     TInt err = KErrNone;
       
  1231     
       
  1232     TMMFMessageDestination sinkHandleInfo = FindEndpointInfo( aEndpointId, err );
       
  1233     if ( !err )
       
  1234         {
       
  1235         err = iController.RemoveDataSource( sinkHandleInfo );
       
  1236         RemoveEndpointInfo( aEndpointId );
       
  1237         }
       
  1238         
       
  1239     return err;
       
  1240     }
       
  1241 
       
  1242 // ---------------------------------------------------------------------------
       
  1243 // CMccInterface::Reuse
       
  1244 // ---------------------------------------------------------------------------
       
  1245 //
       
  1246 EXPORT_C TInt CMccInterface::Reuse( TUint32 aSessionId, TUint32 aLinkId, 
       
  1247                              TUint32 aStreamId, TUint32 aEndpointId )
       
  1248     {
       
  1249     __INTERFACE( "MccInterface::Reuse" )
       
  1250     TInt err = KErrNone;
       
  1251     TMccStream params;
       
  1252     params.iSessionID = aSessionId;
       
  1253     params.iLinkID = aLinkId;
       
  1254     params.iStreamID = aStreamId;
       
  1255     params.iEndpointID = aEndpointId;
       
  1256     TMccStreamPckg package( params );
       
  1257 
       
  1258     err = iController.CustomCommandSync( iMessageDest,
       
  1259                                          EMccReuse,
       
  1260                                          package,
       
  1261                                          KNullDesC8 );
       
  1262                                          
       
  1263     __INTERFACE_INT1( "MccInterface::Reuse, exit with ", err )
       
  1264     return err;
       
  1265     }
       
  1266 
       
  1267 // ---------------------------------------------------------------------------
       
  1268 // CMccInterface::ReferenceCount
       
  1269 // ---------------------------------------------------------------------------
       
  1270 //    
       
  1271 EXPORT_C TInt CMccInterface::ReferenceCount( 
       
  1272     TUint32 aSessionId, 
       
  1273     TUint32 aLinkId, 
       
  1274     TUint32 aStreamId, 
       
  1275     TUint32 aEndpointId,
       
  1276     TUint& aCount )
       
  1277     {
       
  1278     __INTERFACE( "MccInterface::ReferenceCount" )
       
  1279     
       
  1280     TMccGenericMessage genMessage;
       
  1281     genMessage.iSessionID = aSessionId;
       
  1282     genMessage.iLinkID = aLinkId;
       
  1283     genMessage.iStreamID = aStreamId;
       
  1284     genMessage.iEndpointID = aEndpointId;
       
  1285         
       
  1286     TMccGenericMsgBuffer msgBuffer( genMessage );
       
  1287     
       
  1288     TInt err( KErrNone );
       
  1289     
       
  1290     err = iController.CustomCommandSync( iMessageDest,
       
  1291                                          EMccGetReferenceCount,
       
  1292                                          msgBuffer,
       
  1293                                          KNullDesC8,
       
  1294                                          msgBuffer );
       
  1295     
       
  1296     if ( !err )
       
  1297         {
       
  1298         aCount = msgBuffer().iParam4;
       
  1299         __INTERFACE_INT1( "MccInterface::ReferenceCount, refcount:", aCount )
       
  1300         }
       
  1301         
       
  1302     __INTERFACE_INT1( "MccInterface::ReferenceCount, exit with ", err )
       
  1303     return err;
       
  1304     }
       
  1305 
       
  1306 // ---------------------------------------------------------------------------
       
  1307 // CMccInterface::GetParameter
       
  1308 // ---------------------------------------------------------------------------
       
  1309 //
       
  1310 EXPORT_C TInt CMccInterface::GetParameter( TUint32 aSessionId, TUint32 aLinkId, 
       
  1311     TUint32 aStreamId, TUint32 aEndpointId,
       
  1312     TUint32 aParam, TDes8& aVal )
       
  1313     {
       
  1314     __INTERFACE( "MccInterface::GetParameter" )
       
  1315     
       
  1316     TInt retVal( KErrNone );
       
  1317     
       
  1318     switch( aParam )
       
  1319         {
       
  1320         case KMccCamZoomFactor:
       
  1321         case KMccCamDigitZoomFactor:
       
  1322         case KMccCamContrast:
       
  1323         case KMccCamBrightness:
       
  1324         case KMccCamWhiteBalance:
       
  1325         case KMccCamExposure:
       
  1326             {
       
  1327             TPckgBuf<TInt> buffer;
       
  1328             retVal = GetCameraParameter( aParam, buffer() );
       
  1329             aVal = buffer;        
       
  1330             break;
       
  1331             }   
       
  1332         case KMccCamInfo:
       
  1333             {
       
  1334             TMccVideoInfoBuf2 buffer;
       
  1335             buffer.Copy( aVal );
       
  1336             
       
  1337             TRAP( retVal, buffer().iInfo = 
       
  1338                 GetCameraInfoL( buffer().iCameraIndex ) );
       
  1339             aVal = buffer;        
       
  1340             break;                
       
  1341             }
       
  1342         case KMccCamCount:
       
  1343             {
       
  1344             TPckgBuf<TInt> buffer;
       
  1345             TRAP( retVal, buffer() = GetNumOfCamerasL() );
       
  1346             aVal = buffer;        
       
  1347             break;                
       
  1348             }
       
  1349 	    case KMccCamLocalVideo:
       
  1350 		    {
       
  1351 		    retVal = GetViewFinderSettings( aParam, aEndpointId, aVal );
       
  1352 		    break;
       
  1353 		    }
       
  1354         case KMccMicGain:
       
  1355             {
       
  1356             TPckgBuf<TInt> buffer;
       
  1357             retVal = GetGain( buffer() );
       
  1358             aVal = buffer;        
       
  1359             break;                
       
  1360             }
       
  1361         case KMccMicMaxGain:
       
  1362             {
       
  1363             TPckgBuf<TInt> buffer;
       
  1364             retVal = MaxGain( aSessionId, aLinkId, aStreamId, buffer() );
       
  1365             aVal = buffer;        
       
  1366             break;                
       
  1367             }
       
  1368         case KMccMicBalance:
       
  1369             {
       
  1370             break;
       
  1371             }
       
  1372         case KMccSpeakerVolume:
       
  1373             {
       
  1374             TPckgBuf<TInt> buffer;
       
  1375             retVal = Volume( buffer() );
       
  1376             aVal = buffer;        
       
  1377             break;                
       
  1378             }
       
  1379         case KMccSpeakerMaxVolume:
       
  1380             {
       
  1381             TPckgBuf<TInt> buffer;
       
  1382             retVal = MaxVolume( aSessionId, aLinkId, aStreamId, buffer() );
       
  1383             aVal = buffer;        
       
  1384             break;                
       
  1385             }
       
  1386         case KMccSpeakerBalance:
       
  1387             {
       
  1388             break;
       
  1389             }
       
  1390         case KMccSpeakerRouting:
       
  1391             {
       
  1392             TPckgBuf<TUint32> buffer;
       
  1393             retVal = AudioRouting( aSessionId, aLinkId, aStreamId, buffer() );
       
  1394             aVal = buffer;                
       
  1395             break;
       
  1396             }
       
  1397         case KMccFileInfo:
       
  1398         case KMccFileName:
       
  1399         case KMccFileDuration:
       
  1400         case KMccFilePosition:
       
  1401         case KMccFileVideoFrameRate:
       
  1402         case KMccFileVideoBitRate:
       
  1403         case KMccFileVideoFrameSize:
       
  1404         case KMccFileAudioBitRate:
       
  1405         case KMccFileAudioFourCC:
       
  1406         case KMccFileVideoFourCC:
       
  1407         case KMccFileFastForward:
       
  1408 		case KMccDisplayLocalVideo:
       
  1409         case KMccConfigKey:
       
  1410             {
       
  1411     	    retVal = GetEndpointParameter( aParam, 
       
  1412     	                                   aSessionId,
       
  1413     	                                   aLinkId,
       
  1414     	                                   aStreamId,
       
  1415     	                                   aEndpointId, 
       
  1416     	                                   aVal );
       
  1417             break; 
       
  1418             }
       
  1419         default:
       
  1420             {
       
  1421             retVal = KErrArgument;
       
  1422             break;
       
  1423             }
       
  1424         }
       
  1425     __INTERFACE( "MccInterface::GetParameter, exit" )
       
  1426     return retVal;    
       
  1427     }
       
  1428     
       
  1429 // ---------------------------------------------------------------------------
       
  1430 // CMccInterface::SetParameter
       
  1431 // ---------------------------------------------------------------------------
       
  1432 //
       
  1433 EXPORT_C TInt CMccInterface::SetParameter( TUint32 aSessionId, TUint32 aLinkId, 
       
  1434     TUint32 aStreamId, TUint32 aEndpointId,
       
  1435     TUint32 aParam, const TDesC8& aVal )
       
  1436     {
       
  1437     TInt retVal( KErrNone );
       
  1438 
       
  1439     switch( aParam )
       
  1440         {
       
  1441         case KMccCamZoomFactor:
       
  1442         case KMccCamDigitZoomFactor:
       
  1443         case KMccCamContrast:
       
  1444         case KMccCamBrightness:
       
  1445         case KMccCamWhiteBalance:
       
  1446         case KMccCamExposure:
       
  1447             {
       
  1448             TPckgBuf<TInt> buffer;
       
  1449             buffer.Copy( aVal );
       
  1450             retVal = SetCameraParameter( aParam, buffer() );
       
  1451             break;    
       
  1452             }
       
  1453         case KMccCamLocalVideo:
       
  1454             {
       
  1455             if ( aVal.Length() )
       
  1456                 {
       
  1457                 retVal = EnableViewFinder( aVal );                
       
  1458                 }
       
  1459             else    
       
  1460                 {
       
  1461                 retVal = DisableViewFinder();                
       
  1462                 }
       
  1463             break;
       
  1464             }
       
  1465         case KMccMicGain:
       
  1466             {
       
  1467             TPckgBuf<TInt> buffer;
       
  1468             buffer.Copy( aVal );        
       
  1469             retVal = SetGain( buffer() );
       
  1470             break;                
       
  1471             }
       
  1472         case KMccMicBalance:
       
  1473         break;
       
  1474         case KMccSpeakerVolume:
       
  1475             {
       
  1476             TPckgBuf<TInt> buffer;
       
  1477             buffer.Copy( aVal );        
       
  1478             retVal = SetVolume( buffer() );
       
  1479             break;
       
  1480             }
       
  1481         case KMccSpeakerBalance:
       
  1482         break;
       
  1483         case KMccSpeakerRouting:
       
  1484             {
       
  1485             TPckgBuf<TInt> buffer;
       
  1486             buffer.Copy( aVal );        
       
  1487             retVal = SetAudioRouting( aSessionId, aLinkId, aStreamId, buffer() );
       
  1488             break;
       
  1489             }
       
  1490         case KMccFileInfo:
       
  1491         case KMccFileName:
       
  1492         case KMccFileDuration:
       
  1493         case KMccFilePosition:
       
  1494         case KMccFileVideoFrameRate:
       
  1495         case KMccFileVideoBitRate:
       
  1496         case KMccFileVideoFrameSize:
       
  1497         case KMccFileAudioBitRate:
       
  1498         case KMccFileAudioFourCC:
       
  1499         case KMccFileVideoFourCC:
       
  1500         case KMccFileFastForward:
       
  1501 	    case KMccDisplayLocalVideo:
       
  1502 		case KMccRtpCName:
       
  1503         case KMccConfigKey:
       
  1504     	    {
       
  1505     	    retVal = SetEndpointParameter( aParam, 
       
  1506     	                                   aSessionId,
       
  1507     	                                   aLinkId, 
       
  1508     	                                   aStreamId, 
       
  1509     	                                   aEndpointId, 
       
  1510     	                                   aVal );
       
  1511             break; 
       
  1512             }
       
  1513         default:
       
  1514             {
       
  1515             retVal = KErrArgument;   
       
  1516             break;
       
  1517             }        
       
  1518         }
       
  1519     return retVal;    
       
  1520     }
       
  1521 
       
  1522 // ---------------------------------------------------------------------------
       
  1523 // CMccInterface::AddBundle
       
  1524 // ---------------------------------------------------------------------------
       
  1525 //
       
  1526 EXPORT_C TInt CMccInterface::AddBundle( TUint32 /*aSessionId*/, 
       
  1527     TMccStreamBundle& /*aBundle*/, TUint32& /*aBundleId*/ )
       
  1528     {
       
  1529     return KErrNone;
       
  1530     }
       
  1531 
       
  1532 // ---------------------------------------------------------------------------
       
  1533 // CMccInterface::RemoveBundle
       
  1534 // ---------------------------------------------------------------------------
       
  1535 //
       
  1536 EXPORT_C TInt CMccInterface::RemoveBundle( TUint32 /*aSessionId*/, TUint32 /*aBundleId*/ )
       
  1537     {
       
  1538     return KErrNone;
       
  1539     }
       
  1540 
       
  1541 // ---------------------------------------------------------------------------
       
  1542 // CMccInterface::GetBundles
       
  1543 // ---------------------------------------------------------------------------
       
  1544 //
       
  1545 EXPORT_C TInt CMccInterface::GetBundles( TUint32 /*aSessionId*/,
       
  1546     RArray<TMccStreamBundle>& /*aBundles*/)
       
  1547     {
       
  1548     return KErrNone;
       
  1549     }
       
  1550 
       
  1551 // ---------------------------------------------------------------------------
       
  1552 // CMccInterface::TranscodeFile
       
  1553 // ---------------------------------------------------------------------------
       
  1554 //
       
  1555 EXPORT_C TInt CMccInterface::TranscodeFile( 
       
  1556     const TDesC8& aSourceFile, 
       
  1557     const TDesC8& aDestFile,
       
  1558     TUint32 aQuality, 
       
  1559     TUint32& aSessionId,  
       
  1560     const CMccCodecInformation* aVideoCodec,
       
  1561     const CMccCodecInformation* aAudioCodec )
       
  1562     {
       
  1563     __INTERFACE( "MccInterface::TranscodeFile" )
       
  1564     
       
  1565     TMccCreateSession msg;
       
  1566     TMccCreateSessionPckg msgPkg( msg );
       
  1567         
       
  1568     TMccTranscodeFileMsg fileMsg;
       
  1569     TInt cnvRet = CnvUtfConverter::ConvertToUnicodeFromUtf8( fileMsg.iSourceFile, aSourceFile );
       
  1570     TInt cnvRet2 = CnvUtfConverter::ConvertToUnicodeFromUtf8( fileMsg.iDesFile, aDestFile );
       
  1571     
       
  1572     if ( cnvRet != 0 || cnvRet2 != 0 )
       
  1573         {
       
  1574         __INTERFACE_INT2( "MccInterface::TranscodeFile, file name conversion error [src,dest]:", 
       
  1575                           cnvRet, cnvRet2 )
       
  1576         return KErrGeneral;
       
  1577         }
       
  1578     
       
  1579     fileMsg.iQuality = aQuality;
       
  1580     
       
  1581     if ( aVideoCodec )
       
  1582         {
       
  1583         fileMsg.iVideoCodec.iBitrate = aVideoCodec->Bitrate();
       
  1584         fileMsg.iVideoCodec.iFramerate = aVideoCodec->Framerate();
       
  1585         fileMsg.iVideoCodec.iSamplingFreq = aVideoCodec->SamplingFreq();
       
  1586         fileMsg.iVideoCodec.iVideoWidth = aVideoCodec->FrameWidth();
       
  1587         fileMsg.iVideoCodec.iVideoHeight = aVideoCodec->FrameHeight();
       
  1588         fileMsg.iVideoCodec.iMimeType = aVideoCodec->SdpName();
       
  1589         TUid videoCodecFourCC;
       
  1590         videoCodecFourCC.iUid = aVideoCodec->FourCC();
       
  1591         fileMsg.iVideoCodec.iFourCC = videoCodecFourCC;
       
  1592         }
       
  1593     if ( aAudioCodec )
       
  1594         {
       
  1595         fileMsg.iAudioCodec.iBitrate = aAudioCodec->Bitrate();
       
  1596         fileMsg.iAudioCodec.iFramerate = aAudioCodec->Framerate();
       
  1597         fileMsg.iAudioCodec.iSamplingFreq = aAudioCodec->SamplingFreq();
       
  1598         fileMsg.iAudioCodec.iVideoWidth = aAudioCodec->FrameWidth();
       
  1599         fileMsg.iAudioCodec.iVideoHeight = aAudioCodec->FrameHeight();
       
  1600         fileMsg.iAudioCodec.iMimeType = aAudioCodec->SdpName();
       
  1601         TUid audioCodecFourCC;
       
  1602         audioCodecFourCC.iUid = aAudioCodec->FourCC();
       
  1603         fileMsg.iAudioCodec.iFourCC = audioCodecFourCC;
       
  1604         }
       
  1605         
       
  1606     TMccTranscodeFileMsgBuffer fileMsgBuffer( fileMsg );
       
  1607  
       
  1608     TInt err = iController.CustomCommandSync( iMessageDest, 
       
  1609                                               EMccTranscodeFile,
       
  1610                                               fileMsgBuffer, 
       
  1611                                               KNullDesC8,
       
  1612                                               msgPkg );
       
  1613     aSessionId = msgPkg().iSessionID;                                             
       
  1614                                               
       
  1615     __INTERFACE_INT1( "MccInterface::TranscodeFile, exit with ", err )
       
  1616     
       
  1617     return err;
       
  1618     }
       
  1619   
       
  1620 // ---------------------------------------------------------------------------
       
  1621 // CMccInterface::CancelTranscodeFile
       
  1622 // ---------------------------------------------------------------------------
       
  1623 //
       
  1624 EXPORT_C TInt CMccInterface::CancelTranscodeFile( TUint32 aSessionId )
       
  1625     {
       
  1626     __INTERFACE( "MccInterface::CancelTranscodeFile" )
       
  1627 
       
  1628     TMccCreateSession msg;
       
  1629     msg.iSessionID = aSessionId;
       
  1630     TMccCreateSessionPckg msgPkg( msg );
       
  1631       
       
  1632     TInt err = iController.CustomCommandSync( iMessageDest, 
       
  1633                                               EMccCancelTranscodeFile,
       
  1634                                               msgPkg, 
       
  1635                                               KNullDesC8);
       
  1636                                               
       
  1637       __INTERFACE_INT1( "MccInterface::CancelTranscodeFile, exit with ", err )                                     
       
  1638       
       
  1639       return err;
       
  1640     }
       
  1641 
       
  1642 // -----------------------------------------------------------------------------
       
  1643 // CMccInterface::MediaQualityRequest
       
  1644 // Request media quality reports
       
  1645 // -----------------------------------------------------------------------------
       
  1646 //
       
  1647 EXPORT_C TInt CMccInterface::MediaQualityRequest( 
       
  1648     const TMccMediaQualityConfig& aConfig )
       
  1649     {
       
  1650     __INTERFACE( "MccInterface::MediaQualityRequest in" )
       
  1651 
       
  1652     TInt error( KErrNone );
       
  1653 
       
  1654     if( KErrNone != aConfig.CheckConfig() )
       
  1655         {
       
  1656         #ifdef TRACE_MCP_INTERFACE
       
  1657             RDebug::Print( _L("CMccInterface::MediaQualityRequest invalid config!") );
       
  1658         #endif
       
  1659 
       
  1660         error = KErrArgument;
       
  1661         }
       
  1662     else
       
  1663         {
       
  1664         TMMFMessageDestination dest;
       
  1665         dest = FindEndpointInfo( aConfig.iEndpointId, error );
       
  1666 
       
  1667         if ( error )
       
  1668             {
       
  1669             __INTERFACE_INT1( "MccInterface::MediaQualityRequest, endpoint not found ", error )
       
  1670             }
       
  1671         else
       
  1672             {
       
  1673             TMMFMessageDestinationPckg destPckg( dest );
       
  1674             TMccMediaQualConfBuf confBuf( aConfig );
       
  1675 
       
  1676             error = iController.CustomCommandSync( destPckg,
       
  1677                                            EStartMediaQualityObserving,
       
  1678                                            confBuf,
       
  1679                                            KNullDesC8 );
       
  1680                                            
       
  1681             }
       
  1682         }
       
  1683 
       
  1684     __INTERFACE( "MccInterface::MediaQualityRequest out" )
       
  1685     return error;
       
  1686     }
       
  1687 
       
  1688 // -----------------------------------------------------------------------------
       
  1689 // CMccInterface::CancelMediaQualityRequest
       
  1690 // Cancels an outstanding media quality request
       
  1691 // -----------------------------------------------------------------------------
       
  1692 //
       
  1693 EXPORT_C TInt CMccInterface::CancelMediaQualityRequest( 
       
  1694         const TMccMediaQualityConfig& aConfig )
       
  1695     {
       
  1696     __INTERFACE( "MccInterface::CancelMediaQualityRequest in" )
       
  1697 
       
  1698     TInt error( KErrNone );
       
  1699 
       
  1700     if( KErrNone != aConfig.CheckConfig() )
       
  1701         {
       
  1702         #ifdef TRACE_MCP_INTERFACE
       
  1703             RDebug::Print( _L("CMccInterface::MediaQualityRequest invalid config!") );
       
  1704         #endif
       
  1705         
       
  1706         error = KErrArgument;
       
  1707         }
       
  1708     else
       
  1709         {
       
  1710         TMMFMessageDestination dest;
       
  1711         dest = FindEndpointInfo( aConfig.iEndpointId, error );
       
  1712     
       
  1713         if ( error )
       
  1714             {
       
  1715             __INTERFACE_INT1( "MccInterface::MediaQualityRequest, endpoint not found ", error )
       
  1716             }
       
  1717         else
       
  1718             {
       
  1719             TMMFMessageDestinationPckg destPckg( dest );
       
  1720             TMccMediaQualConfBuf confBuf( aConfig );
       
  1721     
       
  1722             error = iController.CustomCommandSync( destPckg, 
       
  1723                                            ECancelMediaQualityObserving, 
       
  1724                                            confBuf,
       
  1725                                            KNullDesC8 );
       
  1726             }
       
  1727         }
       
  1728         
       
  1729     __INTERFACE( "MccInterface::CancelMediaQualityRequest out" )
       
  1730     return error;
       
  1731     }
       
  1732     
       
  1733 // ---------------------------------------------------------------------------
       
  1734 // CMccInterface::GetSupportedBitrates
       
  1735 // Gets supported bit rates from the codec of the specified stream
       
  1736 // ---------------------------------------------------------------------------
       
  1737 //
       
  1738 TInt CMccInterface::GetSupportedBitrates( TUint32 aSessionId,
       
  1739                                           TUint32 aLinkId,
       
  1740                                           TUint32 aStreamId,
       
  1741                                           RArray<TUint>& aBitrates )
       
  1742     {
       
  1743     TMccGenericMessage message;
       
  1744     message.iSessionID = aSessionId;
       
  1745     message.iLinkID = aLinkId;
       
  1746     message.iStreamID = aStreamId;
       
  1747     TMccGenericMsgBuffer messagePckg( message );
       
  1748 
       
  1749     TMccBitrates bitrates;
       
  1750     TMccBitratesPckg bitratePckg( bitrates );
       
  1751 
       
  1752     TInt err = iController.CustomCommandSync( iMessageDest, 
       
  1753                                               EMccGetSupportedBitrates,
       
  1754                                               messagePckg, KNullDesC8,
       
  1755                                               bitratePckg );
       
  1756 
       
  1757     if ( err != KErrNone )
       
  1758         {
       
  1759         return err;
       
  1760         }
       
  1761 
       
  1762     // The package should now contain the bitrates
       
  1763     for ( TInt i = 0; i < KMaxBitrates; i++ )
       
  1764         {
       
  1765         if ( bitratePckg().iBitrates[i] != 0 )
       
  1766             {
       
  1767             aBitrates.Append( bitratePckg().iBitrates[i] );
       
  1768             }
       
  1769         }
       
  1770     return err;
       
  1771     }
       
  1772 
       
  1773 
       
  1774 // ---------------------------------------------------------------------------
       
  1775 // CMccInterface::SendRTCPReceiverReport
       
  1776 // Sends RTCP receiver report to uplink if possible.
       
  1777 // ---------------------------------------------------------------------------
       
  1778 //
       
  1779 TInt CMccInterface::SendRTCPReceiverReport( TUint32 aSessionId,
       
  1780                                             TUint32 aLinkId,
       
  1781                                             TUint32 aStreamId )
       
  1782     {
       
  1783     __INTERFACE( "MccInterface::SendRTCPReceiverReport" )
       
  1784     TMccGenericMessage genMessage;
       
  1785     genMessage.iSessionID = aSessionId;
       
  1786     genMessage.iLinkID = aLinkId;
       
  1787     genMessage.iStreamID = aStreamId;
       
  1788         
       
  1789     TMccGenericMsgBuffer msgBuffer( genMessage );
       
  1790     
       
  1791     TInt err( KErrNone );
       
  1792     
       
  1793     err = iController.CustomCommandSync( iMessageDest,
       
  1794                                          EMccSendRtcpRR,
       
  1795                                          msgBuffer,
       
  1796                                          KNullDesC8 );
       
  1797     
       
  1798     __INTERFACE_INT1( "MccInterface::SendRTCPReceiverReport, exit with ", err )
       
  1799     return err;
       
  1800     }
       
  1801 
       
  1802 // ---------------------------------------------------------------------------
       
  1803 // CMccInterface::SendRTCPSenderReport
       
  1804 // Sends RTCP sender report to uplink if possible.
       
  1805 // ---------------------------------------------------------------------------
       
  1806 //
       
  1807 TInt CMccInterface::SendRTCPSenderReport( TUint32 aSessionId,
       
  1808                                           TUint32 aLinkId,
       
  1809                                           TUint32 aStreamId )
       
  1810     {
       
  1811     __INTERFACE( "MccInterface::SendRTCPSenderReport" )
       
  1812     TMccGenericMessage genMessage;
       
  1813     genMessage.iSessionID = aSessionId;
       
  1814     genMessage.iLinkID = aLinkId;
       
  1815     genMessage.iStreamID = aStreamId;
       
  1816         
       
  1817     TMccGenericMsgBuffer msgBuffer( genMessage );
       
  1818     
       
  1819     TInt err( KErrNone );
       
  1820     
       
  1821     err = iController.CustomCommandSync( iMessageDest,
       
  1822                                          EMccSendRtcpSR,
       
  1823                                          msgBuffer,
       
  1824                                          KNullDesC8 );
       
  1825 
       
  1826     __INTERFACE_INT1( "MccInterface::SendRTCPSenderReport, exit with ", err )
       
  1827     return err;
       
  1828     }
       
  1829 
       
  1830 // ---------------------------------------------------------------------------
       
  1831 // CMccInterface::SendRTCPAnyData
       
  1832 // Sends Non-RTCP data to uplink if possible.
       
  1833 // ---------------------------------------------------------------------------
       
  1834 //
       
  1835 TInt CMccInterface::SendRTCPAnyData( TUint32 aSessionId,
       
  1836                                               TUint32 aLinkId,
       
  1837                                               TUint32 aStreamId,
       
  1838                                               const TDesC8& aData )
       
  1839     {
       
  1840     __INTERFACE( "MccInterface::SendRTCPAnyData" )
       
  1841     TMccGenericMessage genMessage;
       
  1842     genMessage.iSessionID = aSessionId;
       
  1843     genMessage.iLinkID = aLinkId;
       
  1844     genMessage.iStreamID = aStreamId;
       
  1845         
       
  1846     TMccGenericMsgBuffer msgBuffer( genMessage );
       
  1847     
       
  1848     TInt err( KErrNone );
       
  1849     
       
  1850     err = iController.CustomCommandSync( iMessageDest,
       
  1851                                          EMccSendRtcpData,
       
  1852                                          msgBuffer,
       
  1853                                          aData );
       
  1854                                          
       
  1855     __INTERFACE_INT1( "MccInterface::SendRTCPAnyData, exit with ", err )
       
  1856     return err;
       
  1857     }
       
  1858     
       
  1859 // ---------------------------------------------------------------------------
       
  1860 // CMccInterface::EnableViewFinder
       
  1861 // ---------------------------------------------------------------------------
       
  1862 //
       
  1863 TInt CMccInterface::EnableViewFinder( const TDesC8& aParam )
       
  1864     {
       
  1865     __INTERFACE( "MccInterface::EnableViewFinder" )
       
  1866     return iController.CustomCommandSync( iMessageDest,
       
  1867                                          EMccEnableViewFinder,
       
  1868                                          aParam,
       
  1869                                          KNullDesC8 );    
       
  1870     }
       
  1871 
       
  1872 // ---------------------------------------------------------------------------
       
  1873 // CMccInterface::DisableViewFinder
       
  1874 // ---------------------------------------------------------------------------
       
  1875 //
       
  1876 TInt CMccInterface::DisableViewFinder()
       
  1877     {
       
  1878     __INTERFACE( "MccInterface::DisableViewFinder" )
       
  1879     return iController.CustomCommandSync( iMessageDest,
       
  1880                                          EMccDisableViewFinder,
       
  1881                                          KNullDesC8,
       
  1882                                          KNullDesC8 );        
       
  1883     }
       
  1884     
       
  1885 // ---------------------------------------------------------------------------
       
  1886 // CMccInterface::GetViewFinderSettings
       
  1887 // ---------------------------------------------------------------------------
       
  1888 //
       
  1889 TInt CMccInterface::GetViewFinderSettings( 
       
  1890     TUint32 aParam, TUint32 aEndPointId, TDes8& aVal )
       
  1891     {
       
  1892     __INTERFACE( "MccInterface::GetViewFinderSettings")
       
  1893     
       
  1894     TMccGenericMessage message;
       
  1895     message.iParam2 = aParam;
       
  1896     message.iEndpointID = aEndPointId;
       
  1897     TMccGenericMsgBuffer package( message );
       
  1898     
       
  1899     TInt err = iController.CustomCommandSync( iMessageDest,
       
  1900                                               EMccGetViewFinderSettings,
       
  1901                                               package,
       
  1902                                               aVal,
       
  1903                                               aVal );
       
  1904     
       
  1905     __INTERFACE_INT1( "MccInterface::GetViewFinderSettings, exit with", err )
       
  1906     return err;
       
  1907     }
       
  1908     
       
  1909 // -----------------------------------------------------------------------------
       
  1910 // CMccInterfaceImpl::GetCameraInfoL()
       
  1911 // Gets current codec used in a given stream.
       
  1912 // -----------------------------------------------------------------------------
       
  1913 //
       
  1914 TCameraInfo CMccInterface::GetCameraInfoL(TInt aDeviceIndex )
       
  1915     {
       
  1916     __INTERFACE( "MccInterface::GetCameraInfoL" )    
       
  1917     TMccGenericMessage msg;
       
  1918     msg.iParam2 = aDeviceIndex;
       
  1919     TMccGenericMsgBuffer msgBuffer( msg );
       
  1920     
       
  1921     TCameraInfo camInfo;
       
  1922     TPckgBuf<TCameraInfo> camBuffer( camInfo );
       
  1923     
       
  1924     TInt err = iController.CustomCommandSync( iMessageDest, EMccGetCamInfo, msgBuffer,
       
  1925                                          KNullDesC8, camBuffer );
       
  1926     
       
  1927     if ( err != KErrNone )
       
  1928         {
       
  1929         User::Leave( err );
       
  1930         }
       
  1931         
       
  1932     __INTERFACE( "MccInterface::GetCameraInfoL, exit" )    
       
  1933     return camBuffer();
       
  1934     }
       
  1935 
       
  1936 
       
  1937 // -----------------------------------------------------------------------------
       
  1938 // CMccInterfaceImpl::GetNumOfCamerasL()
       
  1939 // Gets current codec used in a given stream.
       
  1940 // -----------------------------------------------------------------------------
       
  1941 //
       
  1942 TInt CMccInterface::GetNumOfCamerasL()
       
  1943     {
       
  1944     __INTERFACE( "MccInterface::GetNumOfCamerasL" )    
       
  1945     TMccGenericMessage msg;
       
  1946     TMccGenericMsgBuffer msgBuffer( msg );
       
  1947     TPckgBuf<TInt> buffer;    
       
  1948         
       
  1949     TInt err = iController.CustomCommandSync( iMessageDest, EMccGetNumOfCams, msgBuffer,
       
  1950                                          KNullDesC8, buffer );
       
  1951     
       
  1952     if ( err != KErrNone )
       
  1953         {
       
  1954         User::Leave( err );
       
  1955         }
       
  1956         
       
  1957     __INTERFACE( "MccInterface::GetNumOfCamerasL, exit" )    
       
  1958     return buffer();
       
  1959     }
       
  1960 
       
  1961 // ---------------------------------------------------------------------------
       
  1962 // CMccInterface::GetSupportedBitrates
       
  1963 // Gets supported bit rates from the codec of the specified stream
       
  1964 // ---------------------------------------------------------------------------
       
  1965 //
       
  1966 TInt CMccInterface::GetCameraParameter(TUint32 aParam, TInt& aVal)
       
  1967     {
       
  1968     __INTERFACE( "MccInterface::GetCameraParameter (TUint32) ")
       
  1969 
       
  1970     TMccGenericMessage msg;
       
  1971     msg.iMessageFunction = aParam;
       
  1972     TMccGenericMsgBuffer package( msg );
       
  1973         
       
  1974     TInt err = iController.CustomCommandSync( 
       
  1975         iMessageDest, EMccGetCamValue1, package, KNullDesC8, package );
       
  1976     
       
  1977     aVal = package().iParam4;
       
  1978     
       
  1979     __INTERFACE_INT1( "MccInterface::GetCameraParameter, exit with ", err )
       
  1980     return err;
       
  1981     }
       
  1982     
       
  1983 // ---------------------------------------------------------------------------
       
  1984 // CMccInterface::GetSupportedBitrates
       
  1985 // Gets supported bit rates from the codec of the specified stream
       
  1986 // ---------------------------------------------------------------------------
       
  1987 //
       
  1988 TInt CMccInterface::SetCameraParameter(TUint32 aParam, TInt aVal)
       
  1989     {
       
  1990     __INTERFACE( "MccInterface::SetCameraParameter (TUint32)")
       
  1991     TMccGenericMessage message;
       
  1992     message.iMessageFunction = aParam;
       
  1993     message.iParam4 = aVal;
       
  1994     TMccGenericMsgBuffer package( message );
       
  1995     TInt err = iController.CustomCommandSync( iMessageDest,
       
  1996                                          EMccSetCamValue1,
       
  1997                                          package,
       
  1998                                          KNullDesC8);
       
  1999                                          
       
  2000     __INTERFACE_INT1( "MccInterface::SetCameraParameter, exit with ", err )
       
  2001     return err;
       
  2002     }
       
  2003 
       
  2004 // ---------------------------------------------------------------------------
       
  2005 // CMccInterface::GetSupportedBitrates
       
  2006 // Gets supported bit rates from the codec of the specified stream
       
  2007 // ---------------------------------------------------------------------------
       
  2008 //
       
  2009 TInt CMccInterface::GetCameraParameter(TUint32 aParam, TReal& aVal)
       
  2010     {
       
  2011     __INTERFACE( "MccInterface::GetCameraParameter (TReal)")
       
  2012 
       
  2013     TMccGenericMessage message;
       
  2014     message.iMessageFunction = aParam;
       
  2015     TMccGenericMsgBuffer package( message );
       
  2016         
       
  2017     TInt err = iController.CustomCommandSync( iMessageDest,
       
  2018                                          EMccGetCamValue2,
       
  2019                                          package,
       
  2020                                          KNullDesC8,
       
  2021                                          package );
       
  2022                                          
       
  2023     aVal = package().iParam3;
       
  2024 
       
  2025     __INTERFACE_INT1( "MccInterface::GetCameraParameter, exit with ", err )
       
  2026     return err;
       
  2027     }
       
  2028 
       
  2029 // ---------------------------------------------------------------------------
       
  2030 // CMccInterface::GetSupportedBitrates
       
  2031 // Gets supported bit rates from the codec of the specified stream
       
  2032 // ---------------------------------------------------------------------------
       
  2033 //
       
  2034 TInt CMccInterface::SetCameraParameter(TUint32 aParam, TReal aVal)
       
  2035     {
       
  2036     __INTERFACE( "MccInterface::SetCameraParameter (TReal)")
       
  2037     TMccGenericMessage message;
       
  2038     message.iMessageFunction = aParam;
       
  2039     message.iParam3 = aVal;
       
  2040     TMccGenericMsgBuffer package( message );
       
  2041     
       
  2042     TInt err = iController.CustomCommandSync( iMessageDest,
       
  2043                                          EMccSetCamValue2,
       
  2044                                          package,
       
  2045                                          KNullDesC8 );
       
  2046                                          
       
  2047     __INTERFACE_INT1( "MccInterface::SetCameraParameter, exit with ", err )
       
  2048     return err;
       
  2049     }
       
  2050 
       
  2051 // ---------------------------------------------------------------------------
       
  2052 // CMccInterface::SetEndpointParameter
       
  2053 // ---------------------------------------------------------------------------
       
  2054 //
       
  2055 TInt CMccInterface::SetEndpointParameter( 
       
  2056     TUint32 aParam, 
       
  2057     TUint32 aSessionId,
       
  2058     TUint32 aLinkId,
       
  2059     TUint32 aStreamId,
       
  2060     TUint32 aEndPointId,
       
  2061     const TDesC8& aVal )
       
  2062     {
       
  2063     __INTERFACE( "MccInterface::SetEndpointParameter")
       
  2064     TMccGenericMessage message;
       
  2065     message.iParam2 = aParam;
       
  2066     message.iSessionID = aSessionId;
       
  2067     message.iLinkID = aLinkId;
       
  2068     message.iStreamID = aStreamId;
       
  2069     message.iEndpointID = aEndPointId;
       
  2070     TMccGenericMsgBuffer package( message );                           
       
  2071                                          
       
  2072     TInt err = iController.CustomCommandSync( iMessageDest,
       
  2073                                               EMccSetEndpointParameter,
       
  2074                                               package,
       
  2075                                               aVal );
       
  2076                                          
       
  2077     __INTERFACE_INT1( "MccInterface::SetEndpointParameter, exit with", err)
       
  2078     return err;
       
  2079     }
       
  2080 	
       
  2081 // ---------------------------------------------------------------------------
       
  2082 // CMccInterface::GetEndpointParameter
       
  2083 // ---------------------------------------------------------------------------
       
  2084 //
       
  2085 TInt CMccInterface::GetEndpointParameter( 
       
  2086     TUint32 aParam, 
       
  2087     TUint32 /*aSessionId*/,
       
  2088     TUint32 /*aLinkId*/,
       
  2089     TUint32 /*aStreamId*/,
       
  2090     TUint32 aEndPointId, 
       
  2091     TDes8& aVal )
       
  2092     {
       
  2093     __INTERFACE( "MccInterface::GetEndpointParameter")
       
  2094     
       
  2095     TMccGenericMessage message;
       
  2096     message.iParam2 = aParam;
       
  2097     message.iEndpointID = aEndPointId;
       
  2098     TMccGenericMsgBuffer package( message );
       
  2099     
       
  2100     TInt err = iController.CustomCommandSync( iMessageDest,
       
  2101                                               EMccGetEndpointParameter,
       
  2102                                               package,
       
  2103                                               aVal,
       
  2104                                               aVal );
       
  2105     
       
  2106     __INTERFACE_INT1( "MccInterface::GetEndpointParameter, exit with", err )
       
  2107     return err;
       
  2108     }
       
  2109 
       
  2110 // ---------------------------------------------------------------------------
       
  2111 // CMccInterface::SetAudioRouting
       
  2112 // ---------------------------------------------------------------------------
       
  2113 //    
       
  2114 TInt CMccInterface::SetAudioRouting( 
       
  2115     TUint32 aSessionId, 
       
  2116     TUint32 aLinkId, 
       
  2117     TUint32 aStreamId,
       
  2118     TUint32 aRoutingDestination )
       
  2119     {
       
  2120     __INTERFACE_INT1( "MccInterface::SetAudioRouting, routing to ", 
       
  2121                       aRoutingDestination )
       
  2122     
       
  2123     TInt err = KErrNone;
       
  2124     TMccGenericMessage params;
       
  2125     params.iSessionID = aSessionId;
       
  2126     params.iLinkID = aLinkId;
       
  2127     params.iStreamID = aStreamId;
       
  2128     params.iParam2 = aRoutingDestination;
       
  2129     TMccGenericMsgBuffer package( params );
       
  2130 
       
  2131     err = iController.CustomCommandSync( iMessageDest,
       
  2132                                          EMccSetAudioRoute,
       
  2133                                          package,
       
  2134                                          KNullDesC8 );
       
  2135                                          
       
  2136     __INTERFACE_INT1( "MccInterface::SetAudioRouting, exit with ", err )
       
  2137     return err;
       
  2138     }
       
  2139 
       
  2140 // ---------------------------------------------------------------------------
       
  2141 // CMccInterface::AudioRouting
       
  2142 // ---------------------------------------------------------------------------
       
  2143 //
       
  2144 TInt CMccInterface::AudioRouting( 
       
  2145     TUint32 aSessionId, 
       
  2146     TUint32 aLinkId, 
       
  2147     TUint32 aStreamId, 
       
  2148     TUint32& aRoutingDestination )
       
  2149     {
       
  2150     __INTERFACE( "MccInterface::AudioRouting")
       
  2151 
       
  2152     TMccGenericMessage params;
       
  2153     params.iSessionID = aSessionId;
       
  2154     params.iLinkID = aLinkId;
       
  2155     params.iStreamID = aStreamId;
       
  2156     TMccGenericMsgBuffer package( params );
       
  2157         
       
  2158     TInt err = iController.CustomCommandSync( iMessageDest,
       
  2159                                               EMccGetAudioRoute,
       
  2160                                               package,
       
  2161                                               KNullDesC8,
       
  2162                                               package );
       
  2163                                          
       
  2164     aRoutingDestination = package().iParam2;
       
  2165 
       
  2166     __INTERFACE_INT1( "MccInterface::AudioRouting, routing currently to ",
       
  2167                       aRoutingDestination )   
       
  2168     __INTERFACE_INT1( "MccInterface::AudioRouting, exit with ", err )
       
  2169     return err;
       
  2170     }
       
  2171     
       
  2172 // ---------------------------------------------------------------------------
       
  2173 // CMccInterface::Volume
       
  2174 // Gets current volume.
       
  2175 // ---------------------------------------------------------------------------
       
  2176 //
       
  2177 TInt CMccInterface::Volume( TInt& aVolume ) const
       
  2178     {
       
  2179     __INTERFACE( "MccInterface::Volume" )
       
  2180     TInt err = iAudioPlayDeviceCustomCommands.GetVolume( aVolume );
       
  2181     __INTERFACE_INT1( "MccInterface::Volume, exit with" ,aVolume )    
       
  2182     return err;
       
  2183     }
       
  2184 
       
  2185 
       
  2186 // ---------------------------------------------------------------------------
       
  2187 // CMccInterface::MaxVolume
       
  2188 // Gets current maximum volume supported.
       
  2189 // ---------------------------------------------------------------------------
       
  2190 //
       
  2191 TInt CMccInterface::MaxVolume( TUint32 /*aSessionId*/, 
       
  2192                                         TUint32 /*aLinkId*/, 
       
  2193                                         TUint32 /*aStreamId*/, 
       
  2194                                         TInt& aMaxVolume )
       
  2195     {
       
  2196     __INTERFACE( "MccInterface::MaxVolume" )
       
  2197     
       
  2198     TInt err = iAudioPlayDeviceCustomCommands.GetMaxVolume( aMaxVolume );
       
  2199 
       
  2200     __INTERFACE_INT1( "MccInterface::MaxVolume, exit err = ", err )
       
  2201     __INTERFACE_INT1( "MccInterface::MaxVolume, exit volume = ", aMaxVolume )
       
  2202     return err;
       
  2203     }
       
  2204 
       
  2205 
       
  2206 // ---------------------------------------------------------------------------
       
  2207 // CMccInterface::SetVolume
       
  2208 // Sets volume to all streams.
       
  2209 // ---------------------------------------------------------------------------
       
  2210 //
       
  2211 TInt CMccInterface::SetVolume( TInt aVolume )
       
  2212     {
       
  2213     __INTERFACE_INT1( "MccInterface::SetVolume", aVolume )
       
  2214     return iAudioPlayDeviceCustomCommands.SetVolume( aVolume );
       
  2215     }
       
  2216 
       
  2217 // ---------------------------------------------------------------------------
       
  2218 // CMccInterface::Balance
       
  2219 // Gets current balance in a given stream
       
  2220 // ---------------------------------------------------------------------------
       
  2221 //
       
  2222 TInt CMccInterface::Balance( TUint32 aSessionId, 
       
  2223                                       TUint32 aLinkId, 
       
  2224                                       TUint32 aStreamId, 
       
  2225                                       TInt& aBalance,
       
  2226                                       TMccDevice aStreamType
       
  2227                                      ) 
       
  2228     {
       
  2229     __INTERFACE( "MccInterface::Balance" )
       
  2230     TInt err = KErrNone;
       
  2231     
       
  2232     TMccStream stream;
       
  2233     stream.iSessionID = aSessionId;
       
  2234     stream.iLinkID    = aLinkId;
       
  2235     stream.iStreamID  = aStreamId;
       
  2236     
       
  2237     TMccStreamPckg package( stream );
       
  2238 
       
  2239     err = iController.CustomCommandSync( iMessageDest,
       
  2240                                          EMccStreamSettings,
       
  2241                                          package,
       
  2242                                          KNullDesC8 );
       
  2243 
       
  2244     if ( KErrNone != err )
       
  2245         {
       
  2246         return err;
       
  2247         }
       
  2248 
       
  2249 
       
  2250     if ( aStreamType == EMccAudioPlay ) 
       
  2251         {
       
  2252         err = iAudioPlayDeviceCustomCommands.GetBalance( aBalance );
       
  2253         }
       
  2254     else if ( aStreamType == EMccAudioRecord )
       
  2255         {
       
  2256         err = iAudioRecordDeviceCustomCommands.GetBalance( aBalance );
       
  2257         }
       
  2258     else
       
  2259         {
       
  2260         err = KErrNotSupported;
       
  2261         }
       
  2262     return err;
       
  2263     }
       
  2264 
       
  2265 // ---------------------------------------------------------------------------
       
  2266 // CMccInterface::SetBalance
       
  2267 // Sets balance in a given stream.
       
  2268 // ---------------------------------------------------------------------------
       
  2269 //
       
  2270 TInt CMccInterface::SetBalance( TUint32 aSessionId, 
       
  2271                                          TUint32 aLinkId, 
       
  2272                                          TUint32 aStreamId, 
       
  2273                                          TInt aBalance,
       
  2274                                          TMccDevice aStreamType
       
  2275                                          )
       
  2276     {
       
  2277     __INTERFACE( "MccInterface::SetBalance" )    
       
  2278     TInt err = KErrNone;
       
  2279     
       
  2280     TMccStream stream;
       
  2281     stream.iSessionID = aSessionId;
       
  2282     stream.iLinkID    = aLinkId;
       
  2283     stream.iStreamID  = aStreamId;
       
  2284     
       
  2285     TMccStreamPckg package( stream );
       
  2286 
       
  2287     err = iController.CustomCommandSync( iMessageDest,
       
  2288                                          EMccStreamSettings,
       
  2289                                          package,
       
  2290                                          KNullDesC8 );
       
  2291 
       
  2292     if ( KErrNone != err )
       
  2293         {
       
  2294         return err;
       
  2295         }
       
  2296 
       
  2297     if ( aStreamType == EMccAudioPlay ) 
       
  2298         {
       
  2299         return iAudioPlayDeviceCustomCommands.SetBalance(aBalance);
       
  2300         }
       
  2301     else if ( aStreamType == EMccAudioRecord ) 
       
  2302         { 
       
  2303         return iAudioRecordDeviceCustomCommands.SetBalance(aBalance);
       
  2304         }
       
  2305     else 
       
  2306         {
       
  2307         return KErrNotSupported;
       
  2308         }                                        
       
  2309 
       
  2310     }
       
  2311 
       
  2312 
       
  2313 // ---------------------------------------------------------------------------
       
  2314 // CMccInterface::GetGain
       
  2315 // Gets current gain used in recording.
       
  2316 // ---------------------------------------------------------------------------
       
  2317 //
       
  2318 TInt CMccInterface::GetGain( TInt& aGain ) const
       
  2319     {
       
  2320     __INTERFACE( "MccInterface::GetGain" )    
       
  2321     return iAudioRecordDeviceCustomCommands.GetGain( aGain );
       
  2322     }
       
  2323 
       
  2324 
       
  2325 // ---------------------------------------------------------------------------
       
  2326 // CMccInterface::SetGain
       
  2327 // Sets uplink/record gain to all ongoing sessions.
       
  2328 // ---------------------------------------------------------------------------
       
  2329 //
       
  2330 TInt CMccInterface::SetGain( TInt aGain )
       
  2331     {
       
  2332     __INTERFACE( "MccInterface::SetGain" )    
       
  2333     return iAudioRecordDeviceCustomCommands.SetGain( aGain );
       
  2334     }
       
  2335 
       
  2336 
       
  2337 // ---------------------------------------------------------------------------
       
  2338 // CMccInterface::MaxGain
       
  2339 // Gets current maximum gain supported.
       
  2340 // ---------------------------------------------------------------------------
       
  2341 //
       
  2342 TInt CMccInterface::MaxGain( TUint32 /*aSessionId*/, 
       
  2343                                       TUint32 /*aLinkId*/, 
       
  2344                                       TUint32 /*aStreamId*/, 
       
  2345                                       TInt& aMaxGain ) 
       
  2346     {
       
  2347     __INTERFACE( "MccInterface::MaxGain" )    
       
  2348     
       
  2349     TInt err = iAudioRecordDeviceCustomCommands.GetMaxGain( aMaxGain );
       
  2350     
       
  2351     __INTERFACE_INT1( "MccInterface::MaxGain, exit err = ", err )
       
  2352     __INTERFACE_INT1( "MccInterface::MaxGain, exit gain = ", aMaxGain )
       
  2353     
       
  2354     return err;
       
  2355     }
       
  2356 
       
  2357 // ---------------------------------------------------------------------------
       
  2358 // CMccInterface::StoreEndpointInfo
       
  2359 // ---------------------------------------------------------------------------
       
  2360 //
       
  2361 TInt CMccInterface::StoreEndpointInfo( 
       
  2362     TUint32 aEndpointId, 
       
  2363     const TMMFMessageDestination& aHandleInfo )
       
  2364     {
       
  2365     TMccEndpointInfo info;
       
  2366     info.iEndpointId = aEndpointId;
       
  2367     info.iHandleInfo = aHandleInfo;
       
  2368     return iEndpointInfos.Append( info );
       
  2369     }
       
  2370 
       
  2371 // ---------------------------------------------------------------------------
       
  2372 // CMccInterface::FindEndpointInfo
       
  2373 // ---------------------------------------------------------------------------
       
  2374 //    
       
  2375 TMMFMessageDestination CMccInterface::FindEndpointInfo( 
       
  2376     TUint32 aEndpointId, TInt& aError )
       
  2377     {
       
  2378     // Have to do in ackward way because TMMFMessageDestination does not
       
  2379     // have setters
       
  2380     TMccEndpointInfo info;
       
  2381     info.iEndpointId = aEndpointId;
       
  2382     
       
  2383     TIdentityRelation<TMccEndpointInfo> comparison( EndpointInfoMatch );
       
  2384     TInt index = iEndpointInfos.Find( info, comparison );
       
  2385     if ( index != KErrNotFound )
       
  2386         {
       
  2387         aError = KErrNone;
       
  2388         return TMMFMessageDestination( 
       
  2389                 iEndpointInfos[ index ].iHandleInfo.InterfaceId(),
       
  2390                 iEndpointInfos[ index ].iHandleInfo.DestinationHandle() );
       
  2391         }
       
  2392     else
       
  2393         {
       
  2394         aError = KErrNotFound;
       
  2395         }
       
  2396     return TMMFMessageDestination();
       
  2397     }
       
  2398 
       
  2399 // ---------------------------------------------------------------------------
       
  2400 // CMccInterface::RemoveEndpointInfo
       
  2401 // ---------------------------------------------------------------------------
       
  2402 //                           
       
  2403 TInt CMccInterface::RemoveEndpointInfo( TUint32 aEndpointId )
       
  2404     {
       
  2405     TMccEndpointInfo info;
       
  2406     info.iEndpointId = aEndpointId;
       
  2407     
       
  2408     TIdentityRelation<TMccEndpointInfo> comparison( EndpointInfoMatch );
       
  2409     TInt index = iEndpointInfos.Find( info, comparison );
       
  2410     if ( index != KErrNotFound )
       
  2411         {
       
  2412         iEndpointInfos.Remove( index );
       
  2413         return KErrNone;
       
  2414         }
       
  2415         
       
  2416     return KErrNotFound;
       
  2417     }
       
  2418 
       
  2419 // ---------------------------------------------------------------------------
       
  2420 // CMccInterface::EndpointInfoMatch
       
  2421 // ---------------------------------------------------------------------------
       
  2422 //   
       
  2423 TBool CMccInterface::EndpointInfoMatch( 
       
  2424     const TMccEndpointInfo& aInfo1, 
       
  2425     const TMccEndpointInfo& aInfo2 )
       
  2426     {
       
  2427     return ( aInfo1.iEndpointId == aInfo2.iEndpointId );
       
  2428     }
       
  2429 
       
  2430 // ---------------------------------------------------------------------------
       
  2431 // CMccInterface::GetController
       
  2432 // ---------------------------------------------------------------------------
       
  2433 // 
       
  2434 void CMccInterface::GetController( RMMFController& aController )
       
  2435     {
       
  2436     aController = iController;
       
  2437     }
       
  2438     
       
  2439 //  End of File