multimediacommsengine/tsrc/MCETestUI/MCETestUIEngine/src/CMCETestUIEngineVideoStream.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 <MCESession.h>
       
    22 #include <MCEMediaStream.h>
       
    23 #include <MCEVideoStream.h>
       
    24 #include <MCEMediaSource.h>
       
    25 #include <MCEMicSource.h>
       
    26 #include <MCEMediaSink.h>
       
    27 #include <MCERtpSink.h>
       
    28 #include <MCERtpSource.h>
       
    29 #include <MCESpeakerSink.h>
       
    30 #include <MCEVideoCodec.h>
       
    31 
       
    32 #include "MCETestUIEngineConstants.h"
       
    33 #include "CMCETestUIEngineVideoStream.h"
       
    34 #include "CMCETestUIEngineVideoCodec.h"
       
    35 #include "CMCETestUIEngineVideoSink.h"
       
    36 #include "CMCETestUIEngineVideoSource.h"
       
    37 
       
    38 #include "TMCETestUIEngineCmdBase.h"
       
    39 #include "TMCETestUIEngineCmdEnableStream.h"
       
    40 #include "TMCETestUIEngineCmdDisableStream.h"
       
    41 #include "TMCETestUIEngineCmdRemoveStream.h"
       
    42 
       
    43 // ============================ MEMBER FUNCTIONS ===============================
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMCETestUIEngineOutSession::NewL()
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CMCETestUIEngineVideoStream* CMCETestUIEngineVideoStream::NewL(
       
    50     CMCETestUIEngine& aEngine, 
       
    51     CMceVideoStream& aVideoStream )
       
    52     {
       
    53 
       
    54     CMCETestUIEngineVideoStream* self = 
       
    55         new( ELeave )CMCETestUIEngineVideoStream( aEngine, aVideoStream );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;  
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMCETestUIEngineVideoStream::CMCETestUIEngineVideoStream
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CMCETestUIEngineVideoStream::CMCETestUIEngineVideoStream( 
       
    67                 CMCETestUIEngine& aEngine,
       
    68                 CMceVideoStream& aVideoStream )
       
    69     : iEngine( aEngine ),
       
    70       iVideoStream( aVideoStream ),
       
    71       iOneTimeRTCPFlag(1),
       
    72       iVideoDirection( CMCETestUIEngineVideoStream::ENotSpesified )
       
    73     {
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CMCETestUIEngineVideoStream::ConstructL()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CMCETestUIEngineVideoStream::ConstructL()
       
    81     {
       
    82     SolveVideoDirection();
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CMCETestUIEngineVideoStream::~CMCETestUIEngineVideoStream
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CMCETestUIEngineVideoStream::~CMCETestUIEngineVideoStream()
       
    90     {
       
    91     iCommands.ResetAndDestroy();
       
    92     iSources.ResetAndDestroy();
       
    93     iSinks.ResetAndDestroy();
       
    94     iCodecs.ResetAndDestroy();
       
    95     }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CMCETestUIEngineVideoStream::GetCommands
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 const RPointerArray<TMCETestUIEngineCmdBase>& 
       
   102     CMCETestUIEngineVideoStream::GetCommandsL()
       
   103     {	
       
   104     iCommands.ResetAndDestroy();
       
   105     
       
   106     if ( iVideoStream.IsEnabled() )
       
   107         {
       
   108         iCommands.Append( new( ELeave )TMCETestUIEngineCmdDisableVideoStream( 
       
   109             iEngine, *this ) );
       
   110         }
       
   111     else
       
   112         {
       
   113         iCommands.Append( new( ELeave )TMCETestUIEngineCmdEnableVideoStream( 
       
   114             iEngine, *this ) );
       
   115         }	  
       
   116 
       
   117     iCommands.AppendL( new( ELeave )TMCETestUIEngineCmdRemoveStream( 
       
   118         iEngine, iVideoStream ) );
       
   119        
       
   120     return iCommands; 
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CMCETestUIEngineVideoStream::Direction
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 EXPORT_C CMCETestUIEngineVideoStream::TVideoDirection 
       
   128     CMCETestUIEngineVideoStream::VideoDirection() const
       
   129     {
       
   130     return iVideoDirection;    
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CMCETestUIEngineVideoStream::TextualDirection
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 EXPORT_C const TDesC16& 
       
   138     CMCETestUIEngineVideoStream::TextualVideoDirection() const
       
   139     {
       
   140     switch ( VideoDirection() )
       
   141         {
       
   142         case CMCETestUIEngineVideoStream::EUpLink :
       
   143             {
       
   144             return KStreamDirectionUpLink;
       
   145             break;
       
   146             }
       
   147         case CMCETestUIEngineVideoStream::EDownLink :
       
   148             {
       
   149             return KStreamDirectionDownLink;
       
   150             break;
       
   151             }           
       
   152         default:
       
   153             {
       
   154             break;
       
   155             }
       
   156         }
       
   157         
       
   158     return KStreamDirectionNotSpesified;
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CMCETestUIEngineVideoStream::StreamState
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 EXPORT_C const TDesC16& CMCETestUIEngineVideoStream::StreamState() 
       
   166     {
       
   167     TInt state = iVideoStream.State();
       
   168 
       
   169 	switch( state ) 
       
   170 		{
       
   171 		case CMceMediaStream::EUninitialized: 
       
   172 		    return KStreamUninitialized; 
       
   173 		    break;
       
   174 		case CMceMediaStream::EInitialized: 
       
   175 		    return KStreamInitialized; 
       
   176 		    break;
       
   177 		case CMceMediaStream::EBuffering: 
       
   178 		    return KStreamBuffering; 
       
   179 		    break;
       
   180 		case CMceMediaStream::EIdle: 
       
   181 		    return KStreamIdle; 
       
   182 		    break;
       
   183 		case CMceMediaStream::EStreaming: 
       
   184 		    return KStreamStreaming; 
       
   185 		    break;
       
   186 		case CMceMediaStream::EDisabled: 
       
   187 		    return KStreamDisabled; 
       
   188 		    break;
       
   189 		case CMceMediaStream::ENoResources: 
       
   190 		    return KStreamNoResources; 
       
   191 		    break;
       
   192 		case CMceMediaStream::ETranscodingRequired: 
       
   193 		    return KStreamTranscodingRequired; 
       
   194 		    break;
       
   195 		case CMceMediaStream::ETranscoding: 
       
   196 		    return KStreamTranscoding; 
       
   197 		    break;
       
   198 		default: 
       
   199 		    return KSessionStateUnknown; 
       
   200 		    break;
       
   201 		}    
       
   202     }
       
   203      
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CMCETestUIEngineVideoStream::State
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 EXPORT_C const TDesC16& CMCETestUIEngineVideoStream::State() const
       
   210     {
       
   211     if ( iVideoStream.IsEnabled() )
       
   212         {
       
   213         return KStreamStateEnabled;
       
   214         }
       
   215     return KStreamStateDisabled;
       
   216     }
       
   217         
       
   218 // -----------------------------------------------------------------------------
       
   219 // CMCETestUIEngineVideoStream::AudioStream
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 CMceVideoStream& CMCETestUIEngineVideoStream::VideoStream()
       
   223     {        
       
   224     return iVideoStream;
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // CMCETestUIEngineVideoStream::SolveDirection
       
   229 // -----------------------------------------------------------------------------
       
   230 //
       
   231 CMCETestUIEngineVideoStream::TVideoDirection 
       
   232     CMCETestUIEngineVideoStream::SolveVideoDirection()
       
   233     {
       
   234     TBool isUpLink = EFalse;
       
   235     TBool isDownLink = EFalse;
       
   236           
       
   237     if ( iVideoStream.Source() )
       
   238         {
       
   239         if ( iVideoStream.Source()->Type() == KMceRTPSource )
       
   240             {
       
   241             isDownLink = ETrue;
       
   242             }
       
   243         }
       
   244         
       
   245     const RPointerArray<CMceMediaSink>& sinks = iVideoStream.Sinks();
       
   246     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   247         {
       
   248         if ( sinks[i]->Type() == KMceRTPSink )
       
   249             {
       
   250             isUpLink = ETrue;
       
   251             }
       
   252         }
       
   253        
       
   254     if ( isUpLink && isDownLink )
       
   255         {
       
   256         iVideoDirection = CMCETestUIEngineVideoStream::ENotSpesified;
       
   257         }
       
   258     else if ( isUpLink )
       
   259         {
       
   260         iVideoDirection = CMCETestUIEngineVideoStream::EUpLink;
       
   261         }
       
   262     else if ( isDownLink )
       
   263         {
       
   264         iVideoDirection = CMCETestUIEngineVideoStream::EDownLink;
       
   265         }  
       
   266     else
       
   267         {
       
   268         iVideoDirection = CMCETestUIEngineVideoStream::ENotSpesified;
       
   269         }
       
   270         
       
   271     return iVideoDirection; 
       
   272     }
       
   273 
       
   274 // -----------------------------------------------------------------------------
       
   275 // CMCETestUIEngineAudioStream::Sources
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C const RPointerArray<CMCETestUIEngineVideoSource>& 
       
   279 				CMCETestUIEngineVideoStream::SourcesL()
       
   280     {
       
   281 	iSources.ResetAndDestroy();
       
   282 	CMceMediaSource* source = iVideoStream.Source();
       
   283 	
       
   284 	CMCETestUIEngineVideoSource* engineSource = 
       
   285 	    CMCETestUIEngineVideoSource::NewL(iEngine,*source);
       
   286 	CleanupStack::PushL(engineSource);
       
   287 	iSources.AppendL(engineSource);
       
   288 	CleanupStack::Pop(engineSource);
       
   289 
       
   290 	return iSources;
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CMCETestUIEngineVideoStream::Sinks
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 EXPORT_C const RPointerArray<CMCETestUIEngineVideoSink>& 
       
   298     CMCETestUIEngineVideoStream::SinksL()
       
   299     {
       
   300     iSinks.ResetAndDestroy();
       
   301     const RPointerArray<CMceMediaSink>& sinks = iVideoStream.Sinks();
       
   302     
       
   303     for ( TInt i = 0; i < sinks.Count(); ++i )
       
   304         {
       
   305         CMceMediaSink* sink = sinks[i];
       
   306         CMCETestUIEngineVideoSink* engineSink =
       
   307             CMCETestUIEngineVideoSink::NewL( iEngine, *sink);
       
   308         CleanupStack::PushL( engineSink );
       
   309         iSinks.AppendL( engineSink );
       
   310         CleanupStack::Pop( engineSink );                   
       
   311         }
       
   312 	return iSinks;
       
   313     }
       
   314 
       
   315 // -----------------------------------------------------------------------------
       
   316 // CMCETestUIEngineVideoStream::Codecs
       
   317 // -----------------------------------------------------------------------------
       
   318 //
       
   319 EXPORT_C  RPointerArray<CMCETestUIEngineVideoCodec>& 
       
   320     CMCETestUIEngineVideoStream::CodecsL()
       
   321     {
       
   322 	iCodecs.ResetAndDestroy();
       
   323     const RPointerArray<CMceVideoCodec>& codecs = iVideoStream.Codecs();
       
   324     
       
   325     for ( TInt i = 0; i < codecs.Count(); ++i )
       
   326         {
       
   327         CMceVideoCodec* codec = codecs[i];
       
   328         CMCETestUIEngineVideoCodec* engineCodec =
       
   329             CMCETestUIEngineVideoCodec::NewL( iEngine, *codec);
       
   330         CleanupStack::PushL( engineCodec );
       
   331         iCodecs.AppendL( engineCodec );
       
   332         CleanupStack::Pop( engineCodec );                   
       
   333         }
       
   334 	return iCodecs;
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CMCETestUIEngineVideoStream::CurrentCodecs
       
   339 // -----------------------------------------------------------------------------
       
   340 //
       
   341 EXPORT_C RPointerArray<CMCETestUIEngineVideoCodec>& 
       
   342     CMCETestUIEngineVideoStream::CurrentCodecs()
       
   343     {
       
   344 	return iCodecs;
       
   345     }