multimediacommsengine/mmcecli/src/mceavsink.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 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 "mceavsink.h"
       
    22 #include "mcemanager.h"
       
    23 #include "mcecomavsink.h"
       
    24 #include "mce.h"
       
    25 #include "mcemediastream.h"
       
    26 #include "mcefactory.h"
       
    27 #include "mceevents.h"
       
    28 #include "mceclilogs.h"
       
    29 
       
    30 #include <w32std.h>
       
    31 
       
    32 
       
    33 #define _FLAT_DATA static_cast<CMceComAvSink*>( iFlatData )
       
    34 #define FLAT_DATA( data ) _FLAT_DATA->data
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // 
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 CMceAvSink* CMceAvSink::NewL()
       
    44     {
       
    45     CMceAvSink* self = CMceAvSink::NewLC();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // 
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CMceAvSink* CMceAvSink::NewLC()
       
    56     {
       
    57     CMceAvSink* self = new (ELeave) CMceAvSink();
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     return self;
       
    61     }
       
    62 
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // 
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CMceAvSink::~CMceAvSink()
       
    69     {
       
    70     delete iFlatData;
       
    71     iParents.Close();
       
    72     iProxyClients.Close();
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CMceAvSink::Type
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TMceSinkType CMceAvSink::Type() const
       
    80     {
       
    81     return FLAT_DATA( Type() );
       
    82     }
       
    83     
       
    84 
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CMceAvSink::IsEnabled
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 TBool CMceAvSink::IsEnabled() const
       
    91     {
       
    92     return FLAT_DATA( IsEnabled() );
       
    93     }
       
    94 
       
    95     
       
    96 // -----------------------------------------------------------------------------
       
    97 // CMceAvSink::Id
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TMceMediaId CMceAvSink::Id() const
       
   101     {
       
   102     return FLAT_DATA( iID ); 
       
   103     }
       
   104 
       
   105     
       
   106 // -----------------------------------------------------------------------------
       
   107 // CMceAvSink::ConstructL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CMceAvSink::ConstructL() 
       
   111     {
       
   112     iFlatData = CMceComAvSink::NewL();
       
   113     FLAT_DATA( iID ) = TMceMediaId();//as not assigned
       
   114     
       
   115     }
       
   116     
       
   117 
       
   118 // -----------------------------------------------------------------------------
       
   119 // CMceAvSink::CMceAvSink
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 CMceAvSink::CMceAvSink()
       
   123     {
       
   124     }
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CMceAvSink::SerializationId
       
   128 // -----------------------------------------------------------------------------
       
   129 //
       
   130 TUint64 CMceAvSink::SerializationId() const
       
   131     {
       
   132     return FLAT_DATA( SerializationId() );
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CMceAvSink::InternalizeFlatL
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 void CMceAvSink::InternalizeFlatL( RReadStream& aReadStream )
       
   140     {
       
   141     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   142     _FLAT_DATA->InternalizeFlatL( aReadStream );
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // CMceAvSink::ExternalizeFlatL
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CMceAvSink::ExternalizeFlatL( RWriteStream& aWriteStream )
       
   150     {
       
   151     __ASSERT_ALWAYS( iFlatData , User::Leave( KErrNotReady ) );
       
   152     _FLAT_DATA->ExternalizeFlatL( aWriteStream );
       
   153     }
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CMceAvSink::InternalizeL
       
   157 // -----------------------------------------------------------------------------
       
   158 //
       
   159 void CMceAvSink::InternalizeL( MMceComSerializationContext& aSerCtx )
       
   160     {
       
   161     InternalizeFlatL( aSerCtx.ReadStream() );
       
   162     }
       
   163 
       
   164 // -----------------------------------------------------------------------------
       
   165 // CMceAvSink::ExternalizeL
       
   166 // -----------------------------------------------------------------------------
       
   167 //
       
   168 void CMceAvSink::ExternalizeL( MMceComSerializationContext& aSerCtx )
       
   169     {
       
   170     ExternalizeFlatL( aSerCtx.WriteStream() );
       
   171     }
       
   172     
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CMceAvSink::Factory
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 TMceSinkFactory CMceAvSink::Factory()
       
   179     {
       
   180     return TMceSinkFactory();
       
   181     }
       
   182 
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CMceAvSink::ServesProxyClient
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 TBool CMceAvSink::ServesProxyClient( const CMceMediaSink& aClient ) const
       
   189     {
       
   190     TBool found = EFalse;
       
   191     TInt index = 0;
       
   192     while ( !found && index < iProxyClients.Count() )
       
   193         {
       
   194         found = iProxyClients[ index ++ ]->Id() == aClient.Id();
       
   195         }
       
   196     
       
   197     return found;
       
   198     
       
   199     }
       
   200 
       
   201 
       
   202 // -----------------------------------------------------------------------------
       
   203 // CMceAvSink::AddProxyClientL
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CMceAvSink::AddProxyClientL( CMceMediaSink& aClient )
       
   207     {
       
   208     iProxyClients.AppendL( &aClient );
       
   209     ReferenceCount()++;
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CMceAvSink::RemoveProxyClient
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 void CMceAvSink::RemoveProxyClient( CMceMediaSink& aClient )
       
   217     {
       
   218     TInt index = iProxyClients.Find( &aClient );
       
   219     if ( index >= 0 )
       
   220         {
       
   221         iProxyClients.Remove( index );
       
   222         ReferenceCount()--;
       
   223         }
       
   224     }
       
   225 
       
   226 // -----------------------------------------------------------------------------
       
   227 // CMceAvSink::EnableL
       
   228 // -----------------------------------------------------------------------------
       
   229 //
       
   230 void CMceAvSink::EnableL()
       
   231     {
       
   232 	_FLAT_DATA->Enabled( ETrue );
       
   233     }
       
   234 
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CMceAvSink::DisableL
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CMceAvSink::DisableL()
       
   241     {
       
   242 	_FLAT_DATA->Enabled( EFalse );
       
   243     }
       
   244 
       
   245 
       
   246 
       
   247 // -----------------------------------------------------------------------------
       
   248 // CMceAvSink::InitializeL
       
   249 // -----------------------------------------------------------------------------
       
   250 //
       
   251 void CMceAvSink::InitializeL( CMceManager* /*aManager*/ )
       
   252     {
       
   253     // NOP
       
   254     }
       
   255     
       
   256 
       
   257 // -----------------------------------------------------------------------------
       
   258 // CMceAvSink::InitializeL
       
   259 // -----------------------------------------------------------------------------
       
   260 //
       
   261 void CMceAvSink::InitializeL( CMceMediaStream& aParent )
       
   262     {
       
   263     StreamAddedL( aParent );
       
   264     iStream = iParents[0];
       
   265     
       
   266     if ( !Id().IsAssigned() )
       
   267         {
       
   268 	    __ASSERT_ALWAYS( iStream->Session(), User::Leave( KErrNotFound ) );
       
   269         FLAT_DATA( iID ) = iStream->Session()->Manager().NextMediaId();
       
   270         MCECLI_DEBUG("CMceAvSink::InitializeL, initialized:" );
       
   271         MCECLI_DEBUG_DVALUE("id", Id().iId );
       
   272         
       
   273         }    
       
   274     }
       
   275 
       
   276 
       
   277 // -----------------------------------------------------------------------------
       
   278 // CMceAvSink::StreamAddedL
       
   279 // -----------------------------------------------------------------------------
       
   280 //
       
   281 void CMceAvSink::StreamAddedL( CMceMediaStream& aParent )
       
   282     {
       
   283     
       
   284     if ( iParents.Find( &aParent ) == KErrNotFound )
       
   285         {
       
   286         iParents.AppendL( &aParent );
       
   287         }
       
   288     
       
   289     }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // CMceAvSink::UnInitialize
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 void CMceAvSink::UnInitialize( CMceMediaStream& aParent )
       
   296     {
       
   297     TInt index = iParents.Find( &aParent );
       
   298     if ( index >= 0 )
       
   299         {
       
   300         iParents.Remove( index );
       
   301         }
       
   302     iStream = NULL;
       
   303     
       
   304     if ( iParents.Count() > 0 )
       
   305         {
       
   306         iStream = iParents[0];
       
   307         }
       
   308     
       
   309     }
       
   310     
       
   311 // -----------------------------------------------------------------------------
       
   312 // CMceAvSink::EventReceivedL
       
   313 // -----------------------------------------------------------------------------
       
   314 //
       
   315 TInt CMceAvSink::EventReceivedL( TMceEvent& /*aEvent*/ )
       
   316     {
       
   317     TInt status = KMceEventNotOwner;
       
   318     return status;
       
   319     
       
   320     }
       
   321 
       
   322 // -----------------------------------------------------------------------------
       
   323 // CMceAvSink::UpdateL
       
   324 // -----------------------------------------------------------------------------
       
   325 //
       
   326 void CMceAvSink::UpdateL( CMceAvSink& aUpdate )
       
   327     {
       
   328     _FLAT_DATA->UpdateL( *aUpdate.iFlatData );
       
   329     }
       
   330 
       
   331 // -----------------------------------------------------------------------------
       
   332 // CMceAvSink::ReferenceCount
       
   333 // -----------------------------------------------------------------------------
       
   334 //
       
   335 TInt& CMceAvSink::ReferenceCount()
       
   336     {
       
   337     return FLAT_DATA( ReferenceCount() );
       
   338     }
       
   339 
       
   340 // -----------------------------------------------------------------------------
       
   341 // CMceAvSink::Updated
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CMceAvSink::Updated()
       
   345     {
       
   346     //NOP
       
   347     }
       
   348 
       
   349 
       
   350 // -----------------------------------------------------------------------------
       
   351 // CMceAvSink::HandleEvent
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 TInt CMceAvSink::HandleEvent( TMceEvent& /*aEvent*/ )
       
   355     {
       
   356     TInt status = KMceEventNotConsumed;
       
   357     return status;
       
   358     
       
   359     }
       
   360 
       
   361 
       
   362 
       
   363 
       
   364