multimediacommsengine/mmcesrv/mmcemediamanager/src/mcemediaidle.cpp
changeset 0 1bce908db942
child 49 64c62431ac08
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 "mcemediaidle.h"
       
    22 #include "mcepreparingoffererstreams.h"
       
    23 #include "mceansweringmedia.h"
       
    24 #include "mcecomsession.h"
       
    25 #include "mcesdpsession.h"
       
    26 #include "mcemmlogs.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // TMceMediaIdle::SetAsCurrentStateL
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 void TMceMediaIdle::SetAsCurrentStateL( CMceComSession& aSession )
       
    34     {
       
    35     MCEMM_DEBUG("TMceMediaIdle::SetAsCurrentStateL() ");
       
    36     
       
    37     TMceMediaIdle*
       
    38         self = new (ELeave) TMceMediaIdle( aSession );
       
    39 
       
    40     CleanupStack::PushL( self );
       
    41     aSession.SetNegotiationStateL( self );
       
    42     CleanupStack::Pop( self );
       
    43     
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // TMceMediaIdle::TMceMediaIdle
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 TMceMediaIdle::TMceMediaIdle ( CMceComSession& aSession )
       
    51     : TMceMediaState( aSession )
       
    52     {
       
    53     }
       
    54 
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // TMceMediaIdle::DecodeL
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 TMceSipWarningCode TMceMediaIdle::DecodeL( CSdpDocument& aSdpDocument )
       
    61     {
       
    62     
       
    63     MCEMM_DEBUG("TMceMediaIdle::DecodeL(), Entry ");
       
    64     SetRole( EMceRoleAnswerer );
       
    65     
       
    66     TMceSipWarningCode code = 
       
    67         iSession.SdpSession().DecodeOfferL( aSdpDocument, iSession );
       
    68         
       
    69     MCEMM_DEBUG("TMceMediaIdle::DecodeL(), Exit ");
       
    70     
       
    71     return code;
       
    72     
       
    73     }
       
    74 
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // TMceMediaIdle::UpdateL
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void TMceMediaIdle::UpdateL()
       
    81     {
       
    82 
       
    83     MCEMM_DEBUG("TMceMediaIdle::UpdateL(), Entry ");
       
    84     
       
    85     if ( iRole == EMceRoleOfferer )
       
    86         {
       
    87         OfferL();
       
    88         }
       
    89     else
       
    90         {
       
    91         AnswerL();
       
    92         }
       
    93     
       
    94     MCEMM_DEBUG("TMceMediaIdle::UpdateL(), Exit ");
       
    95     }
       
    96 
       
    97     
       
    98 // -----------------------------------------------------------------------------
       
    99 // TMceMediaIdle::OfferL
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 void TMceMediaIdle::OfferL()
       
   103     {
       
   104     MCEMM_DEBUG("TMceMediaIdle::OfferL(), Entry ");
       
   105     
       
   106     // for all streams requested, copy bound stream information and validate
       
   107     iSession.PrepareL();
       
   108     // create mcc streams structure
       
   109     iSession.PrepareL( iSession.SdpSession().Manager() );
       
   110 
       
   111     //prepare all inactive streams for offer
       
   112     TMceSrvStreamIterator streams( iSession.MccStreams() );
       
   113     CMceSrvStream* stream = NULL;
       
   114     while( streams.Next( stream, CMceSrvStream::EInactive ) )
       
   115         {
       
   116         iSession.SdpSession().Manager().ValidateMccStreamL( *stream );
       
   117         MCEMM_DEBUG_STREAM( "TMceMediaIdle::OfferL(): validated inactive stream", *stream );
       
   118         }
       
   119     
       
   120     //set next state, this state will become unusable
       
   121     TMcePreparingOffererStreams::SetAsCurrentStateL( iSession );
       
   122     
       
   123     MCEMM_DEBUG("TMceMediaIdle::OfferL(), Exit ");
       
   124     }
       
   125 
       
   126 
       
   127 // -----------------------------------------------------------------------------
       
   128 // TMceMediaIdle::AnswerL
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void TMceMediaIdle::AnswerL()
       
   132     {
       
   133     MCEMM_DEBUG("TMceMediaIdle::AnswerL(), Entry ");
       
   134 
       
   135     // for all streams requested, copy bound stream information and validate
       
   136     iSession.PrepareL();
       
   137     // create mcc streams structure
       
   138     iSession.PrepareL( iSession.SdpSession().Manager() );
       
   139 
       
   140     TMceSrvStreamIterator streams( iSession.MccStreams() );
       
   141     CMceSrvStream* stream = NULL;
       
   142     
       
   143     while( streams.Next( stream ) )
       
   144         {
       
   145         iSession.SdpSession().Manager().InitializeMccStreamL( *stream );
       
   146         iSession.SdpSession().Manager().ValidateMccStreamL( *stream );
       
   147         MCEMM_DEBUG_STREAM( "TMceMediaIdle::AnswerL(): \
       
   148 initialized & validated stream", *stream );
       
   149         }
       
   150         
       
   151     //set next state, this state will become unusable
       
   152     TMceAnsweringMedia::SetAsCurrentStateL( iSession );
       
   153 
       
   154     
       
   155     MCEMM_DEBUG("TMceMediaIdle::AnswerL(), Exit ");
       
   156     }
       
   157 
       
   158