multimediacommsengine/mmcesrv/mmcemediamanager/src/mceadoptedsrvstream.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 "mceadoptedsrvstream.h"
       
    22 #include "mceevents.h"
       
    23 #include "mcecomcodec.h"
       
    24 #include "mcesrvsink.h"
       
    25 #include "mcesrvsource.h"
       
    26 #include "mcecommediasink.h"
       
    27 #include "mcecommediasource.h"
       
    28 #include "mcemediamanager.h"
       
    29 
       
    30 
       
    31 
       
    32 // ============================ MEMBER FUNCTIONS ===============================
       
    33 
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CMceAdoptedSrvStream::NewL
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 CMceAdoptedSrvStream* CMceAdoptedSrvStream::NewL( const CMceSrvStream& aStream )
       
    40     {
       
    41     __ASSERT_ALWAYS( !aStream.IsAdopted(), User::Leave( KErrArgument ) );
       
    42     __ASSERT_ALWAYS( aStream.IsMccPrepared(), User::Leave( KErrArgument ) );
       
    43     
       
    44     CMceAdoptedSrvStream* self = new (ELeave) CMceAdoptedSrvStream( aStream );
       
    45     return self;
       
    46     
       
    47     }
       
    48 
       
    49 // -----------------------------------------------------------------------------
       
    50 // CMceAdoptedSrvStream::CMceAdoptedSrvStream
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CMceAdoptedSrvStream::CMceAdoptedSrvStream( const CMceSrvStream& aStream )
       
    54     : CMceSrvStream( NULL, NULL, NULL )
       
    55     {
       
    56     
       
    57     iCodecId = aStream.Codec().Id();
       
    58     iSourceId = aStream.Source().Data().Id();
       
    59     iSinkId = aStream.Sink().Data().Id();
       
    60     iSessionId = aStream.SessionId();
       
    61     iLinkId = aStream.LinkId();
       
    62     iIapId = aStream.IapId();
       
    63     iLocalMediaPort = aStream.LocalMediaPort();
       
    64     
       
    65     iSourceEndpointId = aStream.Source().Id();
       
    66     iSinkEndpointId = aStream.Sink().Id();
       
    67     iManager = aStream.iManager;
       
    68 
       
    69     }
       
    70     
       
    71     
       
    72 // -----------------------------------------------------------------------------
       
    73 // CMceAdoptedSrvStream::~CMceAdoptedSrvStream
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CMceAdoptedSrvStream::~CMceAdoptedSrvStream()
       
    77     {
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // CMceAdoptedSrvStream::IsAdopted
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 TBool CMceAdoptedSrvStream::IsAdopted() const
       
    85     {
       
    86     return ETrue;
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CMceAdoptedSrvStream::State
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CMceSrvStream::TState CMceAdoptedSrvStream::State() const
       
    94     {
       
    95     
       
    96     CMceSrvStream::TState state = EAdopted;
       
    97     
       
    98     if ( iMerged )
       
    99         {
       
   100         state = EStopped;
       
   101         }
       
   102 
       
   103     return state;
       
   104             
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CMceAdoptedSrvStream::IsMccPrepared
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 TBool CMceAdoptedSrvStream::IsMccPrepared() const
       
   112     {
       
   113     return ETrue;
       
   114     }
       
   115 
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // CMceAdoptedSrvStream::SessionId
       
   119 // -----------------------------------------------------------------------------
       
   120 //
       
   121 TUint32 CMceAdoptedSrvStream::SessionId() const
       
   122     {
       
   123     return iSessionId;
       
   124     }
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // CMceAdoptedSrvStream::LinkId
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 TUint32 CMceAdoptedSrvStream::LinkId() const
       
   132     {
       
   133     return iLinkId;
       
   134     }
       
   135     
       
   136 // -----------------------------------------------------------------------------
       
   137 // CMceAdoptedSrvStream::SetLinkId
       
   138 // -----------------------------------------------------------------------------
       
   139 //
       
   140 void CMceAdoptedSrvStream::SetLinkId( TUint32 aLinkId )
       
   141     {
       
   142     iLinkId = aLinkId;
       
   143     }
       
   144     
       
   145 // -----------------------------------------------------------------------------
       
   146 // CMceAdoptedSrvStream::IapId
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 TUint32 CMceAdoptedSrvStream::IapId() const
       
   150     {
       
   151     return iIapId;
       
   152     }
       
   153     
       
   154 // -----------------------------------------------------------------------------
       
   155 // CMceAdoptedSrvStream::LocalMediaPort
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 TUint CMceAdoptedSrvStream::LocalMediaPort() const
       
   159     {
       
   160     return iLocalMediaPort;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CMceAdoptedSrvStream::Cleanup
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 void CMceAdoptedSrvStream::Cleanup()
       
   168     {
       
   169 
       
   170     if ( iManager->CanReleaseEndpoint( *this, iSourceEndpointId ) )
       
   171         {
       
   172         iManager->ReleaseSource( *this, iSourceEndpointId );
       
   173         }
       
   174         
       
   175     if ( iManager->CanReleaseEndpoint( *this, iSinkEndpointId ) )
       
   176         {
       
   177         iManager->ReleaseSink( *this, iSinkEndpointId );
       
   178         }
       
   179         
       
   180     }
       
   181 
       
   182 
       
   183 
       
   184 // -----------------------------------------------------------------------------
       
   185 // CMceAdoptedSrvStream::IsEqual
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 TBool CMceAdoptedSrvStream::IsEqual( const CMceSrvStream& aStream ) const
       
   189     {
       
   190     TBool equal = EFalse;
       
   191     if ( &aStream )
       
   192         {
       
   193         if ( !aStream.IsAdopted() )
       
   194             {
       
   195             
       
   196             equal = iCodecId == aStream.Codec().Id() &&
       
   197                     iSourceId == aStream.Source().Data().Id() &&
       
   198                     iSinkId == aStream.Sink().Data().Id();
       
   199             }
       
   200         else
       
   201             {
       
   202             const CMceAdoptedSrvStream& stream = 
       
   203                 reinterpret_cast<const CMceAdoptedSrvStream&>( aStream );
       
   204             equal = iCodecId == stream.iCodecId &&
       
   205                     iSourceId == stream.iSourceId &&
       
   206                     iSinkId == stream.iSinkId;
       
   207             }
       
   208         }
       
   209     
       
   210     return equal;
       
   211 
       
   212     }
       
   213 
       
   214 
       
   215 // -----------------------------------------------------------------------------
       
   216 // CMceAdoptedSrvStream::Invalidate
       
   217 // -----------------------------------------------------------------------------
       
   218 //
       
   219 void CMceAdoptedSrvStream::Invalidate()
       
   220     {
       
   221     iMerged = ETrue;
       
   222     }
       
   223 
       
   224 
       
   225