natfw/natfwicecandidatehandler/src/cicestreamcollection.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:    Represents stream collection.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "cicestreamcollection.h"
       
    22 #include "icecandidatehandlerlogs.h"
       
    23 
       
    24 // ======== MEMBER FUNCTIONS ========
       
    25 
       
    26 CIceStreamCollection::CIceStreamCollection( TUint aCollectionId )
       
    27     :
       
    28     iCollectionId( aCollectionId )
       
    29     {
       
    30     __ICEDP( "CIceStreamCollection::CIceStreamCollection" )
       
    31     }
       
    32      
       
    33 
       
    34 CIceStreamCollection* CIceStreamCollection::NewL( TUint aCollectionId )
       
    35     {
       
    36     __ICEDP( "CIceStreamCollection::NewL" )
       
    37 
       
    38     CIceStreamCollection* self 
       
    39         = CIceStreamCollection::NewLC( aCollectionId );
       
    40     CleanupStack::Pop( self );
       
    41     
       
    42     return self;
       
    43     }
       
    44 
       
    45 
       
    46 CIceStreamCollection* CIceStreamCollection::NewLC( TUint aCollectionId )
       
    47     {
       
    48     __ICEDP( "CIceStreamCollection::NewLC" )
       
    49 
       
    50     CIceStreamCollection* self 
       
    51         = new( ELeave ) CIceStreamCollection( aCollectionId );
       
    52     CleanupStack::PushL( self );
       
    53     
       
    54     return self;
       
    55     }
       
    56     
       
    57   
       
    58 CIceStreamCollection::~CIceStreamCollection()
       
    59     {
       
    60     __ICEDP( "CIceStreamCollection::~CIceStreamCollection" )
       
    61     
       
    62     iMediaComponents.Close();
       
    63     }
       
    64     
       
    65     
       
    66 // ---------------------------------------------------------------------------
       
    67 // CIceStreamCollection::StreamCollectionId
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 TUint CIceStreamCollection::StreamCollectionId() const
       
    71     {
       
    72     __ICEDP( "CIceStreamCollection::StreamCollectionId" )
       
    73     
       
    74     return iCollectionId;
       
    75     }
       
    76     
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // CIceStreamCollection::AddMediaComponentL
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 void CIceStreamCollection::AddMediaComponentL( TUint aStreamId, 
       
    83         TUint aComponentId )
       
    84     {
       
    85     __ICEDP( "CIceStreamCollection::AddMediaComponentL" )
       
    86     
       
    87     TIceMediaComponent item = TIceMediaComponent( aStreamId, aComponentId );
       
    88     TInt ind( iMediaComponents.Find( item ) );
       
    89     __ASSERT_DEBUG( KErrNotFound == ind, User::Leave( KErrAlreadyExists ) );
       
    90     
       
    91     iMediaComponents.AppendL( item );
       
    92     }
       
    93 
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // CIceStreamCollection::RemoveMediaComponent
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CIceStreamCollection::RemoveMediaComponent( TUint aStreamId )
       
   100     {
       
   101     __ICEDP( "CIceStreamCollection::RemoveMediaComponent" )
       
   102     
       
   103     for ( TInt i( iMediaComponents.Count() - 1 ); i >= 0; --i )
       
   104         {
       
   105         if ( iMediaComponents[i].StreamId() == aStreamId )
       
   106             {
       
   107             iMediaComponents.Remove( i );
       
   108             }
       
   109         }
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CIceStreamCollection::HasMediaComponent
       
   115 // ---------------------------------------------------------------------------
       
   116 //
       
   117 TBool CIceStreamCollection::HasMediaComponent( TUint aStreamId ) const
       
   118     {
       
   119     TInt count( iMediaComponents.Count() );
       
   120     for ( TInt i( 0 ); i < count; ++i )
       
   121         {
       
   122         if ( iMediaComponents[i].StreamId() == aStreamId )
       
   123             {
       
   124             return ETrue;
       
   125             }
       
   126         }
       
   127     
       
   128     return EFalse;
       
   129     }
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // CIceStreamCollection::NumOfMediaComponents
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 TInt CIceStreamCollection::NumOfMediaComponents() const
       
   137     {
       
   138     return iMediaComponents.Count();
       
   139     }