multimediacommsengine/mmcecli/src/mcecodec.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "mcecodec.h"
       
    22 #include "mcesession.h"
       
    23 #include "mcemanager.h"
       
    24 #include "mcemediastream.h"
       
    25 #include "mceclientserver.h"
       
    26 #include "mcefactory.h"
       
    27 #include "mceevents.h"
       
    28 #include "mcestreamobserver.h"
       
    29 #include "mceclientserver.h"
       
    30 #include "mcecomcodec.h"
       
    31 
       
    32 
       
    33 #define _FLAT_DATA static_cast<CMceComCodec*>( iFlatData )
       
    34 #define FLAT_DATA( data ) _FLAT_DATA->data
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CMceCodec::~CMceCodec
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 CMceCodec::~CMceCodec()
       
    43     {
       
    44     delete iFlatData;
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CMceCodec::InitializeL
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 void CMceCodec::InitializeL( CMceMediaStream& aParent )
       
    52     {    
       
    53     iStream = &aParent;
       
    54         
       
    55     if ( !Id().IsAssigned() )
       
    56         {
       
    57         FLAT_DATA( iID ) = iStream->Session()->Manager().NextMediaId();
       
    58         }
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CMceCodec::SetStateL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 EXPORT_C void CMceCodec::SetStateL( CMceCodec::TState aState )
       
    66     {
       
    67     FLAT_DATA( iState ) = aState;
       
    68     }
       
    69 
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // CMceCodec::SetStandByTimerL
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void CMceCodec::SetStandByTimerL( TUint32 /*aTimerValue*/ )
       
    76     {
       
    77     // NOT SUPPORTED YET
       
    78     User::Leave( KErrNotSupported );
       
    79     }
       
    80 
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CMceCodec::SetMMFPriorityL
       
    84 // -----------------------------------------------------------------------------
       
    85 //
       
    86 EXPORT_C void CMceCodec::SetMMFPriorityL( TInt aPriority )
       
    87     {
       
    88     FLAT_DATA( iPriority ) = aPriority;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CMceCodec::SetMMFPriorityPreferenceL
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 EXPORT_C void CMceCodec::SetMMFPriorityPreferenceL( TInt aPriorityPreference )
       
    96     {
       
    97     FLAT_DATA( iPriorityPreference ) = aPriorityPreference;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CMceCodec::SetKeepAliveTimerL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C void CMceCodec::SetKeepAliveTimerL( TUint8 aTimerValue )
       
   105     {
       
   106     FLAT_DATA( iKeepAliveTimer ) = aTimerValue;
       
   107     }
       
   108 
       
   109 // -----------------------------------------------------------------------------
       
   110 // CMceCodec::SetKeepAlivePayloadTypeL
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 EXPORT_C void CMceCodec::SetKeepAlivePayloadTypeL( TUint8 aKeepAlivePT )
       
   114     {
       
   115     FLAT_DATA( iKeepAlivePayloadType ) = aKeepAlivePT;
       
   116     }
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CMceCodec::SetKeepAliveDataL
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 EXPORT_C void CMceCodec::SetKeepAliveDataL( const TDesC8& aData )        
       
   123     {
       
   124     _FLAT_DATA->SetKeepAliveDataL( aData );    
       
   125     }
       
   126 
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMceCodec::State
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 EXPORT_C CMceCodec::TState CMceCodec::State() const
       
   133     {
       
   134     return static_cast<CMceCodec::TState>( FLAT_DATA( iState ) );
       
   135     }
       
   136     
       
   137 // -----------------------------------------------------------------------------
       
   138 // CMceCodec::Type
       
   139 // -----------------------------------------------------------------------------
       
   140 //   
       
   141 EXPORT_C TMceCodecType CMceCodec::Type() const
       
   142     {
       
   143     return iType;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CMceCodec::FourCC
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 EXPORT_C TUint32 CMceCodec::FourCC() const
       
   151     {
       
   152     return FLAT_DATA( iFourCC );
       
   153     }
       
   154        
       
   155 // -----------------------------------------------------------------------------
       
   156 // CMceCodec::Bitrate
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 EXPORT_C TUint CMceCodec::Bitrate() const
       
   160     {
       
   161     return FLAT_DATA( iBitrate );
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CMceAudioCodec::AllowedBitrates
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 EXPORT_C TUint CMceCodec::AllowedBitrates() const
       
   169     {
       
   170     return FLAT_DATA( iAllowedBitrates );
       
   171     }
       
   172     
       
   173 // -----------------------------------------------------------------------------
       
   174 // CMceCodec::FrameSize
       
   175 // -----------------------------------------------------------------------------
       
   176 //
       
   177 EXPORT_C TUint CMceCodec::FrameSize() const
       
   178     {
       
   179     return FLAT_DATA( iFrameSize );
       
   180     }
       
   181     
       
   182 // -----------------------------------------------------------------------------
       
   183 // CMceCodec::CodecMode
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 EXPORT_C TUint CMceCodec::CodecMode() const
       
   187     {
       
   188     return FLAT_DATA( iCodecMode );
       
   189     }    
       
   190 
       
   191 // -----------------------------------------------------------------------------
       
   192 // CMceCodec::PayloadType
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 EXPORT_C TUint8 CMceCodec::PayloadType() const
       
   196     {
       
   197     return FLAT_DATA( iPayloadType );
       
   198     }
       
   199 
       
   200     
       
   201 // -----------------------------------------------------------------------------
       
   202 // CMceCodec::SdpName
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 EXPORT_C const TDesC8& CMceCodec::SdpName() const
       
   206     {
       
   207     return FLAT_DATA( iSdpName );
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // 
       
   212 // -----------------------------------------------------------------------------
       
   213 //	
       
   214 EXPORT_C TInt CMceCodec::MMFPriority() const
       
   215     {
       
   216     return FLAT_DATA( iPriority );
       
   217     }
       
   218 
       
   219 
       
   220 // -----------------------------------------------------------------------------
       
   221 // 
       
   222 // -----------------------------------------------------------------------------
       
   223 //	
       
   224 EXPORT_C TInt CMceCodec::MMFPriorityPreference() const
       
   225     {
       
   226     return FLAT_DATA( iPriorityPreference );
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // 
       
   231 // -----------------------------------------------------------------------------
       
   232 //	
       
   233 EXPORT_C TUint8 CMceCodec::KeepAliveTimer() const
       
   234     {
       
   235     return FLAT_DATA( iKeepAliveTimer );
       
   236     }
       
   237 
       
   238 // -----------------------------------------------------------------------------
       
   239 // 
       
   240 // -----------------------------------------------------------------------------
       
   241 //	
       
   242 EXPORT_C TUint8 CMceCodec::KeepAlivePayloadType() const
       
   243     {
       
   244     return FLAT_DATA( iKeepAlivePayloadType );
       
   245     }
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // 
       
   249 // -----------------------------------------------------------------------------
       
   250 //	
       
   251 EXPORT_C const TDesC8& CMceCodec::KeepAliveData() const
       
   252     {
       
   253     if ( FLAT_DATA( iKeepAliveData ) )
       
   254         {
       
   255         return *FLAT_DATA( iKeepAliveData );
       
   256         }
       
   257     return KNullDesC8;
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CMceCodec::Preference
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 EXPORT_C TInt CMceCodec::Preference() const
       
   265     {
       
   266     return FLAT_DATA( iPreference );
       
   267     }
       
   268 	    
       
   269 // -----------------------------------------------------------------------------
       
   270 // CMceCodec::SetPreference
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 EXPORT_C void CMceCodec::SetPreferenceL( TInt aPeference )
       
   274     {
       
   275     FLAT_DATA( iPreference ) = aPeference;
       
   276     }
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // CMceCodec::Id
       
   280 // -----------------------------------------------------------------------------
       
   281 //
       
   282 TMceMediaId CMceCodec::Id() const
       
   283     {
       
   284     return FLAT_DATA( iID );
       
   285     }
       
   286      
       
   287 // -----------------------------------------------------------------------------
       
   288 // CMceCodec::SerializationId
       
   289 // -----------------------------------------------------------------------------
       
   290 //
       
   291 TUint64 CMceCodec::SerializationId() const
       
   292     {
       
   293     return FLAT_DATA( SerializationId() );
       
   294     }
       
   295      
       
   296 // -----------------------------------------------------------------------------
       
   297 // CMceCodec::InternalizeFlatL
       
   298 // -----------------------------------------------------------------------------
       
   299 //
       
   300 void CMceCodec::InternalizeFlatL( RReadStream& aReadStream )
       
   301     {
       
   302     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   303     _FLAT_DATA->InternalizeFlatL( aReadStream );
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CMceCodec::ExternalizeFlatL
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 void CMceCodec::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   311     {
       
   312     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   313     _FLAT_DATA->ExternalizeFlatL( aWriteStream );
       
   314     }
       
   315 
       
   316 // -----------------------------------------------------------------------------
       
   317 // CMceCodec::InternalizeL
       
   318 // -----------------------------------------------------------------------------
       
   319 //
       
   320 void CMceCodec::InternalizeL( MMceComSerializationContext& aSerCtx )
       
   321     {
       
   322     InternalizeFlatL( aSerCtx.ReadStream() );
       
   323     }
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CMceCodec::ExternalizeL
       
   327 // -----------------------------------------------------------------------------
       
   328 //
       
   329 void CMceCodec::ExternalizeL( MMceComSerializationContext& aSerCtx )
       
   330     {
       
   331     ExternalizeFlatL( aSerCtx.WriteStream() );
       
   332     }
       
   333 
       
   334 // -----------------------------------------------------------------------------
       
   335 // CMceCodec::BaseFactory
       
   336 // -----------------------------------------------------------------------------
       
   337 //
       
   338 TMceFactory CMceCodec::BaseFactory()
       
   339     {
       
   340     return TMceFactory();
       
   341     }
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CMceCodec::FlatData
       
   345 // -----------------------------------------------------------------------------
       
   346 //    
       
   347 CMceComCodec* CMceCodec::FlatData()
       
   348     {
       
   349     return iFlatData;
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CMceCodec::Attach
       
   354 // -----------------------------------------------------------------------------
       
   355 //
       
   356 void CMceCodec::Attach( CMceMediaStream& aParent )
       
   357     {
       
   358     iStream = &aParent;
       
   359     }
       
   360     
       
   361 // -----------------------------------------------------------------------------
       
   362 // CMceCodec::EventReceivedL
       
   363 // -----------------------------------------------------------------------------
       
   364 //
       
   365 TInt CMceCodec::EventReceivedL( TMceEvent& aEvent )
       
   366     {
       
   367     TInt status = KMceEventNotOwner;
       
   368     TBool idMatch = aEvent.Id().iCodecID == Id();
       
   369     if ( !idMatch )
       
   370         {
       
   371         return KMceEventNotOwner;
       
   372         }
       
   373         
       
   374     if ( aEvent.Id().IsCodecId() )
       
   375         {
       
   376         status = KMceEventUpdate;
       
   377         }
       
   378     else
       
   379         {
       
   380         status = KMceEventNotConsumed;
       
   381         }
       
   382     
       
   383     return status;
       
   384     }
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CMceCodec::Updated
       
   388 // -----------------------------------------------------------------------------
       
   389 //
       
   390 void CMceCodec::Updated()
       
   391     {
       
   392     }
       
   393 
       
   394 // -----------------------------------------------------------------------------
       
   395 // CMceCodec::SetSdpNameL
       
   396 // -----------------------------------------------------------------------------
       
   397 //
       
   398 void CMceCodec::SetSdpNameL( const TDesC8& /*aSdpName*/ )
       
   399     {
       
   400     }
       
   401     
       
   402 // -----------------------------------------------------------------------------
       
   403 // CMceCodec::CMceCodec
       
   404 // -----------------------------------------------------------------------------
       
   405 //
       
   406 CMceCodec::CMceCodec()
       
   407     {
       
   408     }
       
   409 
       
   410 // -----------------------------------------------------------------------------
       
   411 // CMceCodec::ConstructL
       
   412 // -----------------------------------------------------------------------------
       
   413 //
       
   414 void CMceCodec::ConstructL( CMceComCodec* aFlatData )
       
   415     {
       
   416     iFlatData = aFlatData;
       
   417     FLAT_DATA( iID ) = TMceMediaId();//as not assigned
       
   418     }
       
   419