gst_plugins_symbian/tsrc/gstreamertestmodule/src/GStreamerTestClassBlocks.cpp
changeset 2 5505e8908944
child 8 4a7fac7dd34a
child 29 567bb019e3e3
equal deleted inserted replaced
1:4c282e7dd6d3 2:5505e8908944
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
       
     3 *
       
     4 * This library is free software; you can redistribute it and/or
       
     5 * modify it under the terms of the GNU Lesser General Public
       
     6 * License as published by the Free Software Foundation; either
       
     7 * version 2 of the License, or (at your option) any later version.
       
     8 *
       
     9 * This library is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    12 * Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public
       
    15 * License along with this library; if not, write to the
       
    16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    17 * Boston, MA 02111-1307, USA.
       
    18 *
       
    19 * Description:
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 #include <e32svr.h>
       
    27 #include <StifParser.h>
       
    28 #include <StifTestInterface.h>
       
    29 #include "GStreamerTestClass.h"
       
    30 #include "debug.h"
       
    31 #include <stdlib.h>
       
    32 #include <string.h>
       
    33 
       
    34 
       
    35 _LIT8(defaultMedia,"audio/x-raw-int");
       
    36 _LIT8(amrMedia,"audio/amr");
       
    37 _LIT8(g711Media,"audio/x-alaw");
       
    38 _LIT8(g729Media,"audio/g729");
       
    39 _LIT8(iLbcMedia,"audio/ilbc");
       
    40 _LIT8(mp3Media,"audio/mp3");
       
    41 
       
    42 
       
    43 CGlibEventHandler* CGlibEventHandler::NewL()
       
    44 {
       
    45     CGlibEventHandler* self = new(ELeave) CGlibEventHandler();
       
    46     CleanupStack::PushL(self);
       
    47     self->ConstructL();
       
    48     CleanupStack::Pop();
       
    49     return self;
       
    50 }
       
    51 
       
    52 
       
    53 CGlibEventHandler::~CGlibEventHandler()
       
    54 {
       
    55     iTimer.Close();
       
    56 }
       
    57     
       
    58 
       
    59 void CGlibEventHandler::Start()
       
    60 {
       
    61     iTimer.After(iStatus, TTimeIntervalMicroSeconds32(1000));
       
    62     SetActive();    
       
    63 }
       
    64     
       
    65     
       
    66 void CGlibEventHandler::Stop()
       
    67 {
       
    68     Cancel();
       
    69 }
       
    70     
       
    71     
       
    72 void CGlibEventHandler::RunL()
       
    73 {
       
    74     g_main_context_iteration(NULL, FALSE);
       
    75     iTimer.After(iStatus, TTimeIntervalMicroSeconds32(1000));
       
    76     SetActive();    
       
    77 }
       
    78     
       
    79     
       
    80 void CGlibEventHandler::DoCancel()
       
    81 {
       
    82     iTimer.Cancel();    
       
    83 }
       
    84 
       
    85 
       
    86 CGlibEventHandler::CGlibEventHandler():CActive(EPriorityStandard)
       
    87 {
       
    88     iTimer.CreateLocal();
       
    89     CActiveScheduler::Add(this);
       
    90 }
       
    91     
       
    92 void CGlibEventHandler::ConstructL()
       
    93 {
       
    94     
       
    95 }
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // CGstObjects::CGstObjects
       
    99 // C++ default constructor can NOT contain any code, that
       
   100 // might leave.
       
   101 // -----------------------------------------------------------------------------
       
   102 //
       
   103 CGstObjects::CGstObjects(void* aParent): iParent(aParent)
       
   104     {
       
   105     iPipeline = NULL;
       
   106     iLoop = NULL;
       
   107     iConverter = NULL;
       
   108     iResampler = NULL;
       
   109     iSink = NULL;        
       
   110     iSource = NULL;
       
   111     iWavparse = NULL;
       
   112     iDecoder = NULL;
       
   113     iFakesink = NULL;
       
   114     iFilesink = NULL;
       
   115     iEncoder = NULL;
       
   116     iFilter = NULL;
       
   117     iWavenc = NULL;
       
   118     iBus = NULL;
       
   119     iCaps = NULL;
       
   120     iG711EncoderIntfc = NULL;
       
   121     iG729EncoderIntfc = NULL;
       
   122     iIlbcEncoderIntfc = NULL;
       
   123     iSpeechEncoderIntfc = NULL;
       
   124     iErrconcealmentIntfc = NULL;
       
   125     iG711DecoderIntfc = NULL;
       
   126     iG729DecoderIntfc = NULL;
       
   127     iIlbcDecoderIntfc = NULL;  
       
   128     fp=NULL;
       
   129     iCGlibEventHandler = NULL;
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CGstObjects::NewL
       
   134 // Static constructor.
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 CGstObjects* CGstObjects::NewL(void* aParent)
       
   138     {
       
   139     CGstObjects* self = new (ELeave) CGstObjects(aParent);
       
   140     CleanupStack::PushL(self);
       
   141     self->ConstructL();
       
   142     CleanupStack::Pop(self);
       
   143     return self;
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // CGstObjects::ConstructL
       
   148 // Symbian two-phase constructor
       
   149 // -----------------------------------------------------------------------------
       
   150 //
       
   151 void CGstObjects::ConstructL()
       
   152     {
       
   153     iCGlibEventHandler = CGlibEventHandler::NewL();
       
   154     iCGlibEventHandler->Start();
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CGstObjects::~CGstObjects
       
   159 // Destructor deallocate memory.
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 CGstObjects::~CGstObjects()
       
   163     {
       
   164     }
       
   165 
       
   166 gboolean
       
   167 bus_call (GstBus     *bus,
       
   168           GstMessage *msg,
       
   169           gpointer    data)
       
   170 {
       
   171   CGstObjects* objects = (CGstObjects*) data;
       
   172   switch (GST_MESSAGE_TYPE (msg)) {
       
   173     case GST_MESSAGE_EOS:
       
   174         gst_element_set_state (GST_ELEMENT (objects->iPipeline), GST_STATE_NULL);        
       
   175         //g_main_loop_quit(objects->iLoop);
       
   176         ((CGStreamerTestClass*)objects->iParent)->Signal(KErrNone);
       
   177       break;
       
   178     case GST_MESSAGE_ERROR: {
       
   179       gchar *debug;
       
   180       GError *err;
       
   181       gst_message_parse_error (msg, &err, &debug);
       
   182       g_free (debug);
       
   183       g_print ("Error: %s\n", err->message);
       
   184       g_error_free (err);
       
   185       break;
       
   186     }
       
   187     default:
       
   188       break;
       
   189   }
       
   190 
       
   191   return TRUE;
       
   192 }
       
   193 
       
   194 
       
   195 static void 
       
   196 new_pad_cb (GstElement *wavparse, GstPad *new_pad, gpointer data)
       
   197  {
       
   198     CGstObjects* objects = (CGstObjects*) data; 
       
   199     gst_element_set_state ((_GstElement *)objects->iPipeline, GST_STATE_PAUSED);
       
   200      
       
   201     if(! gst_element_link_many (wavparse,objects->iConverter, objects->iResampler, objects->iSink, NULL))
       
   202         g_print ("link(wavparse,conv,remaple sink) failed!\n");  
       
   203  
       
   204     gst_element_set_state ((_GstElement *)objects->iPipeline, GST_STATE_PLAYING);
       
   205  }
       
   206 // ============================ MEMBER FUNCTIONS ===============================
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CGStreamerTestClass::Delete
       
   210 // Delete here all resources allocated and opened from test methods. 
       
   211 // Called from destructor. 
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 void CGStreamerTestClass::Delete() 
       
   215 {
       
   216     
       
   217     FTRACE(FPrint(_L("CGStreamerTestClass::Delete")));
       
   218     
       
   219     iExpectedEvents.Close();
       
   220     iOcurredEvents.Close();
       
   221     iObjects->iCGlibEventHandler->Stop();
       
   222     //fclose(iObjects->fp);
       
   223     gst_object_unref(GST_OBJECT (iObjects->iPipeline));
       
   224     delete iObjects->iCGlibEventHandler;
       
   225     //g_main_loop_unref(iObjects->iLoop);
       
   226     delete iObjects;
       
   227     iObjects = NULL;
       
   228     iLog->Log(_L("Deleting test class..."));
       
   229 	iLog->Log(_L(""));
       
   230 	iLog->Log(_L(""));
       
   231 				
       
   232 }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CGStreamerTestClass::RunMethodL
       
   236 // Run specified method. Contains also table of test mothods and their names.
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 TInt CGStreamerTestClass::RunMethodL( 
       
   240     CStifItemParser& aItem ) 
       
   241     {
       
   242 
       
   243     static TStifFunctionInfo const KFunctions[] =
       
   244         {  
       
   245         // Copy this line for every implemented function.
       
   246         // First string is the function name used in TestScripter script file.
       
   247         // Second is the actual implementation member function. 
       
   248         
       
   249 
       
   250 		ENTRY( "CreatePipeLine", CGStreamerTestClass::CreatePipeLine ),  	
       
   251 		ENTRY( "CreateElement", CGStreamerTestClass::CreateElement ),  
       
   252 		ENTRY( "InitGStreamer", CGStreamerTestClass::InitGStreamer ),
       
   253 		ENTRY( "InitPipeLine", CGStreamerTestClass::InitPipeLine ),
       
   254 		ENTRY( "SetElementProperties", CGStreamerTestClass::SetElementProperties ),
       
   255 		ENTRY( "GetElementProperties", CGStreamerTestClass::GetElementProperties ),
       
   256 		ENTRY( "AddElementToPipeline", CGStreamerTestClass::AddElementToPipeline ),
       
   257 		ENTRY( "SetPipelineState", CGStreamerTestClass::SetPipelineState ),
       
   258 		ENTRY( "LinkElementsInPipeline", CGStreamerTestClass::LinkElementsInPipeline ),
       
   259 		ENTRY( "GetElementsCustomIntfc", CGStreamerTestClass::GetElementsCustomIntfc ),
       
   260 		ENTRY( "CustomIntfcProp", CGStreamerTestClass::CustomIntfcProp ),
       
   261 		
       
   262         ENTRY( "SetTimeout", CGStreamerTestClass::SetTimeout ),
       
   263         ENTRY( "SetAllowedPanic", CGStreamerTestClass::SetAllowedPanic ),
       
   264         ENTRY( "SetExpectedEvents", CGStreamerTestClass::SetExpectedEvents ),
       
   265         ENTRY( "SetMainLoopRun", CGStreamerTestClass::SetMainLoopRun ),
       
   266         ENTRY( "SetCapsInPipeLine", CGStreamerTestClass::SetCapsInPipeLine ),
       
   267 		
       
   268         };
       
   269 
       
   270     const TInt count = sizeof( KFunctions ) / 
       
   271                         sizeof( TStifFunctionInfo );
       
   272 
       
   273     return RunInternalL( KFunctions, count, aItem );
       
   274 
       
   275     }
       
   276 
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // CGStreamerTestClass::EventName
       
   280 // Return descriptor with the notification description
       
   281 // -----------------------------------------------------------------------------
       
   282 TPtrC CGStreamerTestClass::EventName( TInt aKey )
       
   283 {
       
   284 	static TText* const badKeyword = (TText*)L"BadKeyword";
       
   285 	static TText* const keywords[] =
       
   286 	{
       
   287 
       
   288 		(TText*)L"EEOSReceived",
       
   289 		
       
   290 	};
       
   291 
       
   292 			
       
   293 
       
   294 	if( (TUint)aKey >= (sizeof( keywords )/sizeof(TText*)) )
       
   295 		{
       
   296 		iLog->Log(_L("Keyword out of bounds"));
       
   297 		TPtrC keyword( badKeyword );
       
   298 		return keyword;
       
   299 		}
       
   300 	else
       
   301 		{
       
   302 		TPtrC keyword( keywords[aKey] );
       
   303 		return keyword;
       
   304 		}
       
   305 }
       
   306 
       
   307 // -----------------------------------------------------------------------------
       
   308 // CGStreamerTestClass::AddExpectedEvent
       
   309 // Add an event to the expected events' list
       
   310 // -----------------------------------------------------------------------------
       
   311 void CGStreamerTestClass::AddExpectedEvent(TGSTExpectedEvent event, TInt ms)
       
   312 {
       
   313 	FTRACE(FPrint(_L("CGStreamerTestClass::AddExpectedEvent")));
       
   314 	iExpectedEvents.Append(event);
       
   315 	TPtrC eventName = EventName(event);
       
   316 	iLog->Log(_L("Adding expected event:(0x%02x)%S Total=%d"), event, &eventName, iExpectedEvents.Count() );
       
   317 
       
   318 	if ( iTimeoutController && !iTimeoutController->IsActive() )
       
   319 		{
       
   320 		if (ms > 0)
       
   321 			{
       
   322 			iTimeoutController->Start( TTimeIntervalMicroSeconds(ms * 1000) );
       
   323 			}
       
   324 		else
       
   325 			{
       
   326 			iLog->Log(_L("Timeout with default value (1s)"));
       
   327 			iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
       
   328 			}
       
   329 		}
       
   330 }
       
   331 
       
   332 // -----------------------------------------------------------------------------
       
   333 // CGStreamerTestClass::RemoveExpectedEvent
       
   334 // Remove the indicated event from the expected events' list
       
   335 // -----------------------------------------------------------------------------
       
   336 TBool CGStreamerTestClass::RemoveExpectedEvent(TGSTExpectedEvent aEvent)
       
   337 {
       
   338 	FTRACE(FPrint(_L("CGStreamerTestClass::RemoveExpectedEvent")));
       
   339 	TBool match = EFalse;
       
   340 	for (TUint i=0; i < iExpectedEvents.Count() ; i++)
       
   341 		{
       
   342 		if (iExpectedEvents[i] == aEvent)
       
   343 			{
       
   344 			iExpectedEvents.Remove(i);
       
   345 			match = ETrue;
       
   346 			break;
       
   347 			}
       
   348 		}
       
   349 
       
   350 	return match;
       
   351 }
       
   352 
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CGStreamerTestClass::RemoveAllExpectedEvents
       
   356 // Remove the indicated event from the expected events' list
       
   357 // -----------------------------------------------------------------------------
       
   358 void CGStreamerTestClass::RemoveAllExpectedEvents()
       
   359 {
       
   360 	FTRACE(FPrint(_L("CGStreamerTestClass::RemoveAllExpectedEvents")));
       
   361 	iLog->Log(_L("Removing all expected events"));
       
   362 	
       
   363 	iExpectedEvents.Reset();
       
   364 	iOcurredEvents.Reset();
       
   365 }
       
   366 
       
   367 
       
   368 // -----------------------------------------------------------------------------
       
   369 // CGStreamerTestClass::ProcessEvent
       
   370 // -----------------------------------------------------------------------------
       
   371 void CGStreamerTestClass::ProcessEvent(TGSTExpectedEvent aEvent, TInt aError)
       
   372 {
       
   373 	FTRACE(FPrint(_L("CGStreamerTestClass::ProcessExpectedEvent")));
       
   374 	TPtrC nameEvent = EventName(aEvent);
       
   375 
       
   376 	// Check for error
       
   377 	if (aError == KErrNone)
       
   378 		{
       
   379 		// Remove the event
       
   380 		if (RemoveExpectedEvent(aEvent))
       
   381 			{
       
   382 			iLog->Log(_L("Expected Event: (0x%02x)%S has ocurred Total=%d"), aEvent, &nameEvent,iExpectedEvents.Count());
       
   383 			}
       
   384 		else
       
   385 			{
       
   386 			iLog->Log(_L("Event: (0x%02x)%S has ocurred"), aEvent, &nameEvent);
       
   387 			return;
       
   388 			}
       
   389 
       
   390 		
       
   391 
       
   392 		// All expected events have ocurred
       
   393 		if (iExpectedEvents.Count() == 0 )
       
   394 			{
       
   395 			Signal();
       
   396 			iTimeoutController->Cancel();
       
   397 			}
       
   398 		
       
   399 		
       
   400 		}
       
   401 	else
       
   402 		{
       
   403 		iLog->Log(_L("[Error] Event: (0x%02x)%S return with error code=%d"), aEvent, &nameEvent, aError);
       
   404 		if (iExpectedEvents.Count() != 0 )
       
   405 			{
       
   406 			RemoveExpectedEvent(aEvent);
       
   407 			}
       
   408 		iTimeoutController->Cancel();
       
   409 		Signal(KErrCallbackErrorCode);
       
   410 		}
       
   411 }
       
   412 
       
   413 // -----------------------------------------------------------------------------
       
   414 // CGStreamerTestClass::HandleTimeout
       
   415 // Review if all the expected events have ocurred once the time is over
       
   416 // -----------------------------------------------------------------------------
       
   417 
       
   418 void CGStreamerTestClass::HandleTimeout(TInt aError)
       
   419 {
       
   420 	FTRACE(FPrint(_L("CGStreamerTestClass::HandleTimeout")));
       
   421 	// All expected events have ocurred
       
   422 	if (aError != KErrNone)
       
   423 		{
       
   424 		if (iExpectedEvents.Count() == 0 )
       
   425 			{
       
   426 			iLog->Log(_L("Timing out but events have ocurred"));
       
   427 			Signal();
       
   428 			}
       
   429 		else
       
   430 			{
       
   431 			RemoveAllExpectedEvents();
       
   432 			iLog->Log(_L("Timing out and events still pending"));
       
   433 			Signal(KErrEventPending);
       
   434 			}
       
   435 		}
       
   436 	else
       
   437 		{
       
   438 		iLog->Log(_L("Timing out return a error %d"), aError);
       
   439 		Signal(aError);
       
   440 		}
       
   441 }
       
   442 
       
   443 // -----------------------------------------------------------------------------
       
   444 // CGStreamerTestClass::SetTimeout
       
   445 // Create a timer and set a timeout
       
   446 // When the timeout is reached the test case is marked as failed
       
   447 // It's used rather than the "timeout" keyword in the configuration file
       
   448 // because in this way the log continues
       
   449 // -----------------------------------------------------------------------------
       
   450 TInt CGStreamerTestClass::SetTimeout( CStifItemParser& aItem )
       
   451 {
       
   452 	FTRACE(FPrint(_L("CGStreamerTestClass::SetTimeout")));
       
   453 	TInt timeout=0;
       
   454 	TInt error = aItem.GetNextInt(timeout) ;
       
   455 	if ( iTimeoutController )
       
   456 		{
       
   457 		if ( timeout > 0 )
       
   458 			{
       
   459 			iTimeoutController->Start( TTimeIntervalMicroSeconds(timeout*1000) );
       
   460 			}
       
   461 		else
       
   462 			{
       
   463 			iTimeoutController->Start( TTimeIntervalMicroSeconds(1000000) );
       
   464 			}
       
   465 		}
       
   466 	else
       
   467 		{
       
   468 		iLog->Log(_L("Timeout Controller doesn't exist"));
       
   469 		error = KErrTimeoutController;
       
   470 		}
       
   471 	return error;
       
   472 }
       
   473 
       
   474 
       
   475 // -----------------------------------------------------------------------------
       
   476 // Uses the TestModuleBase API to allow a panic as exit reason for a test case
       
   477 // -----------------------------------------------------------------------------
       
   478 TInt CGStreamerTestClass::SetAllowedPanic( CStifItemParser& aItem )
       
   479 {
       
   480 	FTRACE(FPrint(_L("CGStreamerTestClass::SetAllowedPanic")));
       
   481 	TInt error = KErrNone;
       
   482 	TInt panicCode;
       
   483 	TPtrC panicType;
       
   484 	if (  ( KErrNone == aItem.GetNextString(panicType) ) &&
       
   485 	( KErrNone == aItem.GetNextInt(panicCode) )  )
       
   486 		{
       
   487 		iLog->Log(_L("Allowing panic: %S %d"), &panicType, panicCode);
       
   488 		iTestModuleIf.SetExitReason( CTestModuleIf::EPanic, panicCode );
       
   489 		iNormalExitReason = EFalse;
       
   490 		}
       
   491 	else
       
   492 		{
       
   493 		iLog->Log(KMsgBadTestParameters);
       
   494 		error = KErrBadTestParameter;
       
   495 		}
       
   496 	return error;
       
   497 }
       
   498 
       
   499 // -----------------------------------------------------------------------------
       
   500 // CGStreamerTestClass::SetExpectedEvents()
       
   501 // -----------------------------------------------------------------------------
       
   502 TInt CGStreamerTestClass::SetExpectedEvents( CStifItemParser& aItem )
       
   503 {
       
   504 	FTRACE(FPrint(_L("CGStreamerTestClass::SetExpectedEvents")));
       
   505 	TInt error = KErrNone;
       
   506 	TInt event=0;
       
   507 	while ( KErrNone == aItem.GetNextInt(event))
       
   508 		{
       
   509 		TInt timeout=0;
       
   510 		aItem.GetNextInt(timeout);
       
   511 		AddExpectedEvent(static_cast<TGSTExpectedEvent>(event), timeout); // Default timeout value
       
   512 		}
       
   513 	return error;
       
   514 }
       
   515 
       
   516 
       
   517 // -----------------------------------------------------------------------------
       
   518 // CGStreamerTestClass::ExampleL
       
   519 // Example test method function.
       
   520 // (other items were commented in a header).
       
   521 // -----------------------------------------------------------------------------
       
   522 //
       
   523 TInt CGStreamerTestClass::ExampleL( CStifItemParser& aItem )
       
   524     {
       
   525 
       
   526     // Print to UI
       
   527     _LIT( KGStreamerTestClass, "GStreamerTestClass" );
       
   528     _LIT( KExample, "In Example" );
       
   529     TestModuleIf().Printf( 0, KGStreamerTestClass, KExample );
       
   530     // Print to log file
       
   531     iLog->Log( KExample );
       
   532 
       
   533     TInt i = 0;
       
   534     TPtrC string;
       
   535     _LIT( KParam, "Param[%i]: %S" );
       
   536     while ( aItem.GetNextString ( string ) == KErrNone )
       
   537         {
       
   538         TestModuleIf().Printf( i, KGStreamerTestClass, 
       
   539                                 KParam, i, &string );
       
   540         i++;
       
   541         }
       
   542 
       
   543     return KErrNone;
       
   544 
       
   545     }
       
   546     
       
   547 
       
   548 // -----------------------------------------------------------------------------
       
   549 // CGStreamerTestClass::CreatePipeLine
       
   550 // Create Pipeline
       
   551 // -----------------------------------------------------------------------------
       
   552 //
       
   553 
       
   554 TInt CGStreamerTestClass::InitGStreamer( CStifItemParser& /*aItem*/ )
       
   555     {   
       
   556     FTRACE(FPrint(_L("CGStreamerTestClass::InitGStreamer")));
       
   557     iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer 1 "));
       
   558     char* initstatus = getenv("GST_INIT_STATUS");
       
   559     iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer 1.1 [%d] [%s] "),initstatus,&initstatus);
       
   560     if(!initstatus)
       
   561         {
       
   562         iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer Initializing GST "));
       
   563         gst_init(NULL,NULL);    
       
   564         setenv("GST_INIT_STATUS","INITIALIZED",1);        
       
   565         }
       
   566     else
       
   567         {
       
   568         iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer GST already INIT "));
       
   569         }
       
   570     iObjects = CGstObjects::NewL(this);
       
   571     //iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer 2 [%x]"),iObjects->iLoop);
       
   572     //iObjects->iLoop = g_main_loop_new (NULL, FALSE); 
       
   573     iLog->Log(_L(">>CGStreamerTestClass::InitGStreamer 3 [%x]"),iObjects->iSink);
       
   574     //iObjects->fp = freopen("e:\\out.txt","w",stderr); 
       
   575 
       
   576     iLog->Log(_L("<<CGStreamerTestClass::InitGStreamer"));
       
   577     return KErrNone;
       
   578     }
       
   579 
       
   580 // -----------------------------------------------------------------------------
       
   581 // CGStreamerTestClass::CreatePipeLine
       
   582 // Create Pipeline
       
   583 // -----------------------------------------------------------------------------
       
   584 //
       
   585 
       
   586 TInt CGStreamerTestClass::InitPipeLine( CStifItemParser& /*aItem*/ )
       
   587     {   
       
   588     FTRACE(FPrint(_L("CGStreamerTestClass::InitPipeLine")));
       
   589     iLog->Log(_L(">>CGStreamerTestClass::InitPipeLine"));   
       
   590     iObjects->iBus = gst_pipeline_get_bus (GST_PIPELINE (iObjects->iPipeline));
       
   591     gpointer data(iObjects);
       
   592     gst_bus_add_watch(iObjects->iBus, bus_call, data);
       
   593     gst_object_unref (iObjects->iBus);
       
   594     iLog->Log(_L("<<CGStreamerTestClass::InitPipeLine"));   
       
   595     return KErrNone;
       
   596     }
       
   597 
       
   598 TInt CGStreamerTestClass::SetMainLoopRun( CStifItemParser& /*aItem*/ )
       
   599     {
       
   600     TInt error(KErrNone);
       
   601     iLog->Log(_L(">>CGStreamerTestClass::SetMainLoopRun"));
       
   602     //g_main_loop_run(iObjects->iLoop);
       
   603     iLog->Log(_L("<<CGStreamerTestClass::SetMainLoopRun Error[%d]"),error);
       
   604     return error;
       
   605     }
       
   606 // -----------------------------------------------------------------------------
       
   607 // CGStreamerTestClass::CreatePipeLine
       
   608 // Create Pipeline
       
   609 // -----------------------------------------------------------------------------
       
   610 //
       
   611 
       
   612 TInt CGStreamerTestClass::CreatePipeLine( CStifItemParser& /*aItem*/ )
       
   613 	{	
       
   614 	FTRACE(FPrint(_L("CGStreamerTestClass::CreatePipeLine")));
       
   615 	iLog->Log(_L(">>CGStreamerTestClass::CreatePipeLine"));
       
   616 
       
   617 	TInt error(KErrNone);
       
   618 	
       
   619 	if(!iObjects->iPipeline)
       
   620 	    {
       
   621 	    iObjects->iPipeline = gst_pipeline_new ("pipeline");
       
   622 	    }
       
   623 	else
       
   624 	    {
       
   625 	    error = KErrAlreadyExists;
       
   626 	    }
       
   627 	iLog->Log(_L("<<CGStreamerTestClass::CreatePipeLine Error[%d]"),error);
       
   628 	return error;
       
   629 	}
       
   630 
       
   631 TInt CGStreamerTestClass::CreateElement( CStifItemParser& aItem )
       
   632 	{	
       
   633 	FTRACE(FPrint(_L("CGStreamerTestClass::CreateElement")));
       
   634 	iLog->Log(_L(">>CGStreamerTestClass::CreateElement"));
       
   635 	TInt error = KErrNone;
       
   636 	TInt element;
       
   637 	aItem.GetNextInt(element);
       
   638 	switch(element)
       
   639 	    {
       
   640 	    case   EFILESOURCE:
       
   641 	        {
       
   642 	        if(iObjects->iSource)
       
   643 	            {
       
   644 	            error = KErrAlreadyExists;
       
   645 	            }
       
   646 	        else
       
   647 	            {
       
   648 	            iObjects->iSource = gst_element_factory_make("filesrc","filesrc");
       
   649                 if(!iObjects->iSource)
       
   650                     {
       
   651                     error = KErrNotFound;
       
   652                     }
       
   653 	            }
       
   654 	        break;
       
   655 	        }
       
   656 	    case   EFILESINK:
       
   657             {
       
   658             if(iObjects->iSink)
       
   659                 {
       
   660                 error = KErrAlreadyExists;
       
   661                 iLog->Log(_L(">>CGStreamerTestClass::CreateElement Creating FileSink Error [%x]"),iObjects->iSink);
       
   662                 }
       
   663             else
       
   664                 {
       
   665                 iObjects->iSink = gst_element_factory_make("filesink","filesink");
       
   666                 if(!iObjects->iSink)
       
   667                     {
       
   668                     error = KErrNotFound;
       
   669                     iLog->Log(_L(">>CGStreamerTestClass::CreateElement NoElement"));
       
   670                     }
       
   671                 }
       
   672             break;
       
   673             }
       
   674 	    case   EFAKESOURCE:
       
   675             {
       
   676             if(iObjects->iSource)
       
   677                 {
       
   678                 error = KErrAlreadyExists;
       
   679                 }
       
   680             else
       
   681                 {
       
   682                 iObjects->iSource = gst_element_factory_make("fakesrc","fakesrc");
       
   683                 if(!iObjects->iSource)
       
   684                     {
       
   685                     error = KErrNotFound;
       
   686                     }
       
   687                 }
       
   688             break;
       
   689             }
       
   690 	    case   EFAKESINK:
       
   691             {
       
   692             if(iObjects->iSink)
       
   693                 {
       
   694                 error = KErrAlreadyExists;
       
   695                 }
       
   696             else
       
   697                 {
       
   698                 iObjects->iSink = gst_element_factory_make("fakesink","fakesink");
       
   699                 if(!iObjects->iSink)
       
   700                     {
       
   701                     error = KErrNotFound;
       
   702                     }
       
   703                 }
       
   704             break;
       
   705             }
       
   706 	    case   EWAVPARSE:
       
   707             {
       
   708             if(iObjects->iWavparse)
       
   709                 {
       
   710                 error = KErrAlreadyExists;
       
   711                 }
       
   712             else
       
   713                 {
       
   714                 iObjects->iWavparse = gst_element_factory_make("wavparse","wavparse");   
       
   715                 g_signal_connect (iObjects->iWavparse, "pad-added", G_CALLBACK (new_pad_cb),iObjects);
       
   716                 }
       
   717             break;
       
   718             }
       
   719 	    case   EMP3DECODER:
       
   720             {
       
   721             if(iObjects->iDecoder)
       
   722                 {
       
   723                 error = KErrAlreadyExists;
       
   724                 }
       
   725             else
       
   726                 {
       
   727                 iObjects->iDecoder = gst_element_factory_make("mad", "decoder");             
       
   728                 }
       
   729             break;
       
   730             }
       
   731 	    case   EWAVEENCODER:
       
   732             {
       
   733             if(iObjects->iEncoder)
       
   734                 {
       
   735                 error = KErrAlreadyExists;
       
   736                 }
       
   737             else
       
   738                 {
       
   739                 iObjects->iEncoder = gst_element_factory_make("wavenc", "wavencoder");             
       
   740                 }
       
   741             break;
       
   742             }
       
   743 	    case   ERESAMPLER:
       
   744             {
       
   745             if(iObjects->iResampler)
       
   746                 {
       
   747                 error = KErrAlreadyExists;
       
   748                 }
       
   749             else
       
   750                 {
       
   751                 iObjects->iResampler = gst_element_factory_make("audioresample", "audioresample");             
       
   752                 }
       
   753             break;
       
   754             }
       
   755 	    case   ECONVERTER:
       
   756             {
       
   757             if(iObjects->iConverter)
       
   758                 {
       
   759                 error = KErrAlreadyExists;
       
   760                 }
       
   761             else
       
   762                 {
       
   763                 iObjects->iConverter = gst_element_factory_make("audioconvert", "audioconvert");             
       
   764                 }
       
   765             break;
       
   766             }
       
   767         case   EDEVSOUNDSRC:
       
   768             {
       
   769             if(iObjects->iSource)
       
   770                 {
       
   771                 error = KErrAlreadyExists;
       
   772                 }
       
   773             else
       
   774                 {
       
   775                 iObjects->iSource = gst_element_factory_make("devsoundsrc","devsoundsrc");
       
   776                 if(!iObjects->iSource)
       
   777                     {
       
   778                     error = KErrNotFound;
       
   779                     }          
       
   780                 }
       
   781             break;
       
   782             }            
       
   783         case   EDEVSOUNDSINK:
       
   784             {
       
   785             if(iObjects->iSink)
       
   786                 {
       
   787                 error = KErrAlreadyExists;
       
   788                 }
       
   789             else
       
   790                 {
       
   791                 iObjects->iSink = gst_element_factory_make("devsoundsink","devsoundsink");
       
   792                 if(!iObjects->iSink)
       
   793                     {
       
   794                     error = KErrNotFound;
       
   795                     }
       
   796                 }
       
   797             break;
       
   798             }
       
   799         default:
       
   800             error = KErrNotFound;
       
   801 	        break;
       
   802 	    }
       
   803 	iLog->Log(_L("<<CGStreamerTestClass::CreateElement Error[%d]"),error);
       
   804 	return error;
       
   805 	}
       
   806 
       
   807 TInt CGStreamerTestClass::GetElementProperties( CStifItemParser& aItem )
       
   808     {   
       
   809     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties")));
       
   810     iLog->Log(_L(">>CGStreamerTestClass::GetElementProperties"));
       
   811     TInt error = KErrNone;
       
   812     TInt element;
       
   813     aItem.GetNextInt(element);
       
   814     switch(element)
       
   815         {
       
   816         case   EFILESOURCE:
       
   817             {
       
   818             if(!iObjects->iSource)
       
   819                 {
       
   820                 error = KErrNotFound;
       
   821                 }
       
   822             else
       
   823                 {
       
   824                 }
       
   825             break;
       
   826             }
       
   827         case   EFILESINK:
       
   828             {
       
   829             if(!iObjects->iSink)
       
   830                 {
       
   831                 error = KErrNotFound;
       
   832                 }
       
   833             else
       
   834                 {
       
   835                 }
       
   836             break;
       
   837             }
       
   838         case   EFAKESOURCE:
       
   839             {
       
   840             if(!iObjects->iSource)
       
   841                 {
       
   842                 error = KErrNotFound;
       
   843                 }
       
   844             else
       
   845                 {
       
   846                 }
       
   847             break;
       
   848             }
       
   849         case   EFAKESINK:
       
   850             {
       
   851             if(!iObjects->iSink)
       
   852                 {
       
   853                 error = KErrNotFound;
       
   854                 }
       
   855             else
       
   856                 {
       
   857                 }
       
   858             break;
       
   859             }
       
   860         case   EWAVPARSE:
       
   861             {
       
   862             if(!iObjects->iWavparse)
       
   863                 {
       
   864                 error = KErrNotFound;
       
   865                 }
       
   866             else
       
   867                 {
       
   868                 }
       
   869             break;
       
   870             }
       
   871         case   EMP3DECODER:
       
   872             {
       
   873             if(!iObjects->iDecoder)
       
   874                 {
       
   875                 error = KErrNotFound;
       
   876                 }
       
   877             else
       
   878                 {
       
   879                 }
       
   880             break;
       
   881             }
       
   882         case   EWAVEENCODER:
       
   883             {
       
   884             if(!iObjects->iEncoder)
       
   885                 {
       
   886                 error = KErrNotFound;
       
   887                 }
       
   888             else
       
   889                 {
       
   890                 }
       
   891             break;
       
   892             }
       
   893         case   ERESAMPLER:
       
   894             {
       
   895             if(!iObjects->iResampler)
       
   896                 {
       
   897                 error = KErrNotFound;
       
   898                 }
       
   899             else
       
   900                 {
       
   901                 }
       
   902             break;
       
   903             }
       
   904         case   ECONVERTER:
       
   905             {
       
   906             if(!iObjects->iConverter)
       
   907                 {
       
   908                 error = KErrNotFound;
       
   909                 }
       
   910             else
       
   911                 {
       
   912                 }
       
   913             break;
       
   914             }
       
   915         case   EDEVSOUNDSRC:
       
   916             {
       
   917             if(!iObjects->iSource)
       
   918                 {
       
   919                 error = KErrNotFound;
       
   920                 }
       
   921             else
       
   922                 {
       
   923                 TPtrC property;
       
   924                 TInt value(0);
       
   925                 aItem.GetNextString(property);
       
   926                 HBufC8* prop = HBufC8::NewL(property.Length()+ 1);
       
   927                 TPtr8 des = prop->Des();
       
   928                 des.Copy(property);
       
   929                 if(!property.Compare(KTagGainProperty()))
       
   930                     {
       
   931                     g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); 
       
   932                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties Gain[%d]"),value));
       
   933                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties Gain[%d]"),value);
       
   934                     }
       
   935                 else if(!property.Compare(KTagRateProperty()))
       
   936                     {
       
   937                     g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL);
       
   938                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties Rate[%d]"),value));
       
   939                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties Rate[%d]"),value);
       
   940                     }
       
   941                 else if(!property.Compare(KTagChannelsProperty()))
       
   942                     {
       
   943                     g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); 
       
   944                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties Channels[%d]"),value));
       
   945                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties channels[%d]"),value);
       
   946                     }
       
   947                 else if(!property.Compare(KTagMaxGainProperty()))
       
   948                     {
       
   949                     g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); 
       
   950                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties MaxGain[%d]"),value));
       
   951                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties Max Gain[%d]"),value);
       
   952                     }
       
   953                 else if(!property.Compare(KTagSamplesRecordedProperty()))
       
   954                     {
       
   955                     g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); 
       
   956                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties SamplesRecorded[%d]"),value));
       
   957                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties SamplesRecorded[%d]"),value);
       
   958                     }
       
   959                 delete prop;
       
   960                 }
       
   961             break;
       
   962             }            
       
   963         case   EDEVSOUNDSINK:
       
   964             {
       
   965             if(!iObjects->iSink)
       
   966                 {
       
   967                 error = KErrNotFound;
       
   968                 }
       
   969             else
       
   970                 {
       
   971                 TPtrC property;
       
   972                 TInt value(0);
       
   973                 aItem.GetNextString(property);
       
   974                 HBufC8* prop = HBufC8::NewL(property.Length()+ 1);
       
   975                 TPtr8 des = prop->Des();
       
   976                 des.Copy(property);
       
   977                 if(!property.Compare(KTagVolumeProperty()))
       
   978                     {
       
   979                     g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); 
       
   980                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties Volume[%d]"),value));
       
   981                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties Volume[%d]"),value);
       
   982                     }
       
   983                 else if(!property.Compare(KTagRateProperty()))
       
   984                     {
       
   985                     g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); 
       
   986                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties rate [%d]"),value));
       
   987                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties rate[%d]"),value);
       
   988                     }
       
   989                 else if(!property.Compare(KTagChannelsProperty()))
       
   990                     {
       
   991                     g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); 
       
   992                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties channels [%d]"),value));
       
   993                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties channels[%d]"),value);
       
   994                     }
       
   995                 else if(!property.Compare(KTagMaxVolumeProperty()))
       
   996                     {
       
   997                     g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); 
       
   998                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties max vol[%d] "),value));
       
   999                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties max vol[%d]"),value);
       
  1000                     }
       
  1001                 else if(!property.Compare(KTagSamplesPlayedProperty()))
       
  1002                     {
       
  1003                     g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); 
       
  1004                     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties samples played[%d] "),value));
       
  1005                     iLog->Log(_L("CGStreamerTestClass::GetElementProperties samples played[%d]"),value);
       
  1006                     }
       
  1007                 delete prop;
       
  1008                 }
       
  1009             break;
       
  1010             }
       
  1011         default:
       
  1012             error = KErrNotFound;
       
  1013             break;
       
  1014         }
       
  1015     iLog->Log(_L(">>CGStreamerTestClass::GetElementProperties Error[%d]"),error);
       
  1016     return error;
       
  1017     }
       
  1018 
       
  1019 
       
  1020 TInt CGStreamerTestClass::SetElementProperties( CStifItemParser& aItem )
       
  1021     {   
       
  1022     FTRACE(FPrint(_L("CGStreamerTestClass::SetElementProperties")));
       
  1023     iLog->Log(_L(">>CGStreamerTestClass::SetElementProperties"));
       
  1024     TInt error = KErrNone;
       
  1025     TInt element;
       
  1026     aItem.GetNextInt(element);
       
  1027     switch(element)
       
  1028         {
       
  1029         case   EFILESOURCE:
       
  1030             {
       
  1031             if(!iObjects->iSource)
       
  1032                 {
       
  1033                 error = KErrNotFound;
       
  1034                 }
       
  1035             else
       
  1036                 {
       
  1037                 TPtrC location;
       
  1038                 TFileName filename;
       
  1039                 
       
  1040                 char carray[1024];
       
  1041                 aItem.GetNextString(location);
       
  1042                 filename.Copy(location);
       
  1043                 wcstombs(carray, (const wchar_t *)filename.PtrZ(), 1024);
       
  1044                 g_object_set (G_OBJECT (iObjects->iSource), "location", carray, NULL);
       
  1045                 }
       
  1046             break;
       
  1047             }
       
  1048         case   EFILESINK:
       
  1049             {
       
  1050             if(!iObjects->iSink)
       
  1051                 {
       
  1052                 error = KErrNotFound;
       
  1053                 }
       
  1054             else
       
  1055                 {
       
  1056                 TPtrC location;
       
  1057                 TFileName filename;
       
  1058                 
       
  1059                 char carray[1024];
       
  1060                 aItem.GetNextString(location);
       
  1061                 filename.Copy(location);
       
  1062                 wcstombs(carray, (const wchar_t *)filename.PtrZ(), 1024);
       
  1063                 g_object_set (G_OBJECT (iObjects->iSink), "location", carray, NULL);             
       
  1064                 }
       
  1065             break;
       
  1066             }
       
  1067         case   EFAKESOURCE:
       
  1068             {
       
  1069             if(!iObjects->iSource)
       
  1070                 {
       
  1071                 error = KErrNotFound;
       
  1072                 }
       
  1073             else
       
  1074                 {
       
  1075                 }
       
  1076             break;
       
  1077             }
       
  1078         case   EFAKESINK:
       
  1079             {
       
  1080             if(!iObjects->iSink)
       
  1081                 {
       
  1082                 error = KErrNotFound;
       
  1083                 }
       
  1084             else
       
  1085                 {
       
  1086                 }
       
  1087             break;
       
  1088             }
       
  1089         case   EWAVPARSE:
       
  1090             {
       
  1091             if(!iObjects->iWavparse)
       
  1092                 {
       
  1093                 error = KErrNotFound;
       
  1094                 }
       
  1095             else
       
  1096                 {
       
  1097                 }
       
  1098             break;
       
  1099             }
       
  1100         case   EMP3DECODER:
       
  1101             {
       
  1102             if(!iObjects->iDecoder)
       
  1103                 {
       
  1104                 error = KErrNotFound;
       
  1105                 }
       
  1106             else
       
  1107                 {
       
  1108                 }
       
  1109             break;
       
  1110             }
       
  1111         case   EWAVEENCODER:
       
  1112             {
       
  1113             if(!iObjects->iEncoder)
       
  1114                 {
       
  1115                 error = KErrNotFound;
       
  1116                 }
       
  1117             else
       
  1118                 {
       
  1119                 }
       
  1120             break;
       
  1121             }
       
  1122         case   ERESAMPLER:
       
  1123             {
       
  1124             if(!iObjects->iResampler)
       
  1125                 {
       
  1126                 error = KErrNotFound;
       
  1127                 }
       
  1128             else
       
  1129                 {
       
  1130                 }
       
  1131             break;
       
  1132             }
       
  1133         case   ECONVERTER:
       
  1134             {
       
  1135             if(!iObjects->iConverter)
       
  1136                 {
       
  1137                 error = KErrNotFound;
       
  1138                 }
       
  1139             else
       
  1140                 {
       
  1141                 }
       
  1142             break;
       
  1143             }
       
  1144         case   EDEVSOUNDSRC:
       
  1145             {
       
  1146             if(!iObjects->iSource)
       
  1147                 {
       
  1148                 error = KErrNotFound;
       
  1149                 }
       
  1150             else
       
  1151                 {
       
  1152                 TPtrC property;
       
  1153                 aItem.GetNextString(property);
       
  1154                 HBufC8* prop = HBufC8::NewL(property.Length()+ 1);
       
  1155                 TPtr8 des = prop->Des();
       
  1156                 des.Copy(property);
       
  1157                 if(!property.Compare(KTagGainProperty()))
       
  1158                     {
       
  1159                     TInt value;
       
  1160                     if(!aItem.GetNextInt(value))
       
  1161                         {
       
  1162                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1163                         FTRACE(FPrint(_L("CGStreamerTestClass::SetElementProperties Gain [%d]"),value));
       
  1164                         }
       
  1165                     else
       
  1166                         {
       
  1167                         error = KErrNotFound;
       
  1168                         }
       
  1169                     }
       
  1170                 else if(!property.Compare(KTagRateProperty()))
       
  1171                     {
       
  1172                     TInt value;
       
  1173                     if(!aItem.GetNextInt(value))
       
  1174                         {
       
  1175                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1176                         }
       
  1177                     else
       
  1178                         {
       
  1179                         error = KErrNotFound;
       
  1180                         }
       
  1181                     }
       
  1182                 else if(!property.Compare(KTagChannelsProperty()))
       
  1183                     {
       
  1184                     TInt value;
       
  1185                     if(!aItem.GetNextInt(value))
       
  1186                         {
       
  1187                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1188                         }
       
  1189                     else
       
  1190                         {
       
  1191                         error = KErrNotFound;
       
  1192                         }
       
  1193                     }
       
  1194                 else if(!property.Compare(KTagLeftBalanceProperty()))
       
  1195                     {
       
  1196                     TInt value;
       
  1197                     if(!aItem.GetNextInt(value))
       
  1198                         {
       
  1199                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1200                         }
       
  1201                     else
       
  1202                         {
       
  1203                         error = KErrNotFound;
       
  1204                         }
       
  1205                     }
       
  1206                 else if(!property.Compare(KTagRightBalanceProperty()))
       
  1207                     {
       
  1208                     TInt value;
       
  1209                     if(!aItem.GetNextInt(value))
       
  1210                         {
       
  1211                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1212                         }
       
  1213                     else
       
  1214                         {
       
  1215                         error = KErrNotFound;
       
  1216                         }
       
  1217                     }
       
  1218                 else if(!property.Compare(KTagPriorityProperty()))
       
  1219                     {
       
  1220                     TInt value;
       
  1221                     if(!aItem.GetNextInt(value))
       
  1222                         {
       
  1223                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1224                         }
       
  1225                     else
       
  1226                         {
       
  1227                         error = KErrNotFound;
       
  1228                         }
       
  1229                     }
       
  1230                 else if(!property.Compare(KTagPereferenceProperty()))
       
  1231                     {
       
  1232                     TInt value;
       
  1233                     if(!aItem.GetNextInt(value))
       
  1234                         {
       
  1235                         g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); 
       
  1236                         }
       
  1237                     else
       
  1238                         {
       
  1239                         error = KErrNotFound;
       
  1240                         }
       
  1241                     }
       
  1242                 delete prop;
       
  1243                 }
       
  1244             break;
       
  1245             }            
       
  1246         case   EDEVSOUNDSINK:
       
  1247             {
       
  1248             if(!iObjects->iSink)
       
  1249                 {
       
  1250                 error = KErrNotFound;
       
  1251                 }
       
  1252             else
       
  1253                 {
       
  1254                 TPtrC property;
       
  1255                 aItem.GetNextString(property);
       
  1256                 HBufC8* prop = HBufC8::NewL(property.Length()+ 1);
       
  1257                 TPtr8 des = prop->Des();
       
  1258                 des.Copy(property);
       
  1259                 if(!property.Compare(KTagVolumeProperty()))
       
  1260                     {
       
  1261                     TInt value;
       
  1262                     if(!aItem.GetNextInt(value))
       
  1263                         {
       
  1264                         FTRACE(FPrint(_L("CGStreamerTestClass::SetElementProperties Volume [%d]"),value));
       
  1265                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1266                         }
       
  1267                     else
       
  1268                         {
       
  1269                         error = KErrNotFound;
       
  1270                         }
       
  1271                     }
       
  1272                 else if(!property.Compare(KTagRateProperty()))
       
  1273                     {
       
  1274                     TInt value;
       
  1275                     if(!aItem.GetNextInt(value))
       
  1276                         {
       
  1277                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1278                         }
       
  1279                     else
       
  1280                         {
       
  1281                         error = KErrNotFound;
       
  1282                         }
       
  1283                     }
       
  1284                 else if(!property.Compare(KTagChannelsProperty()))
       
  1285                     {
       
  1286                     TInt value;
       
  1287                     if(!aItem.GetNextInt(value))
       
  1288                         {
       
  1289                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1290                         }
       
  1291                     else
       
  1292                         {
       
  1293                         error = KErrNotFound;
       
  1294                         }
       
  1295                     }
       
  1296                 else if(!property.Compare(KTagLeftBalanceProperty()))
       
  1297                     {
       
  1298                     TInt value;
       
  1299                     if(!aItem.GetNextInt(value))
       
  1300                         {
       
  1301                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1302                         }
       
  1303                     else
       
  1304                         {
       
  1305                         error = KErrNotFound;
       
  1306                         }
       
  1307                     }
       
  1308                 else if(!property.Compare(KTagRightBalanceProperty()))
       
  1309                     {
       
  1310                     TInt value;
       
  1311                     if(!aItem.GetNextInt(value))
       
  1312                         {
       
  1313                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1314                         }
       
  1315                     else
       
  1316                         {
       
  1317                         error = KErrNotFound;
       
  1318                         }
       
  1319                     }
       
  1320                 else if(!property.Compare(KTagVolumeRampProperty()))
       
  1321                     {
       
  1322                     TInt value;
       
  1323                     if(!aItem.GetNextInt(value))
       
  1324                         {
       
  1325                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1326                         }
       
  1327                     else
       
  1328                         {
       
  1329                         error = KErrNotFound;
       
  1330                         }
       
  1331                     }
       
  1332                 else if(!property.Compare(KTagPriorityProperty()))
       
  1333                     {
       
  1334                     TInt value;
       
  1335                     if(!aItem.GetNextInt(value))
       
  1336                         {
       
  1337                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1338                         }
       
  1339                     else
       
  1340                         {
       
  1341                         error = KErrNotFound;
       
  1342                         }
       
  1343                     }
       
  1344                 else if(!property.Compare(KTagPereferenceProperty()))
       
  1345                     {
       
  1346                     TInt value;
       
  1347                     if(!aItem.GetNextInt(value))
       
  1348                         {
       
  1349                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1350                         }
       
  1351                     else
       
  1352                         {
       
  1353                         error = KErrNotFound;
       
  1354                         }
       
  1355                     }
       
  1356                 else if(!property.Compare(KTagMimeTypeProperty()))
       
  1357                     {
       
  1358                     TPtrC mimetype;
       
  1359                     TFileName mime;
       
  1360                     char carray[1024];
       
  1361 
       
  1362                     if(!aItem.GetNextString(mimetype))
       
  1363                         {
       
  1364                         mime.Copy(mimetype);
       
  1365                         wcstombs(carray, (const wchar_t *)mime.PtrZ(), 1024);
       
  1366                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), carray, NULL); 
       
  1367                         }
       
  1368                     else
       
  1369                         {
       
  1370                         error = KErrNotFound;
       
  1371                         }
       
  1372                     }
       
  1373                 else if(!property.Compare(KTagFourCCProperty()))
       
  1374                     {
       
  1375                     TInt value;
       
  1376                     if(!aItem.GetNextInt(value))
       
  1377                         {
       
  1378                         g_object_set (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), value, NULL); 
       
  1379                         }
       
  1380                     else
       
  1381                         {
       
  1382                         error = KErrNotFound;
       
  1383                         }
       
  1384                     }
       
  1385                 delete prop;
       
  1386                 }
       
  1387             break;
       
  1388             }
       
  1389         default:
       
  1390             error = KErrNotFound;
       
  1391             break;
       
  1392         }
       
  1393     iLog->Log(_L("<<CGStreamerTestClass::SetElementProperties Error[%d]"),error);
       
  1394     return error;
       
  1395     }
       
  1396 
       
  1397 TInt CGStreamerTestClass::AddElementToPipeline( CStifItemParser& aItem )
       
  1398     {   
       
  1399     FTRACE(FPrint(_L("CGStreamerTestClass::AddElementToPipeline")));
       
  1400     iLog->Log(_L(">>CGStreamerTestClass::AddElementToPipeline"));
       
  1401     TInt element;
       
  1402     TInt error(KErrNone);
       
  1403     if(!iObjects->iPipeline)
       
  1404         {
       
  1405         return KErrNotReady;
       
  1406         }
       
  1407     
       
  1408     aItem.GetNextInt(element);
       
  1409     switch(element)
       
  1410         {
       
  1411         case   EFILESOURCE:
       
  1412             {
       
  1413             if(!iObjects->iSource)
       
  1414                 {
       
  1415                 error = KErrNotFound;
       
  1416                 }
       
  1417             else
       
  1418                 {
       
  1419                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSource, NULL);
       
  1420                 }
       
  1421             break;
       
  1422             }
       
  1423         case   EFILESINK:
       
  1424             {
       
  1425             if(!iObjects->iSink)
       
  1426                 {
       
  1427                 error = KErrNotFound;
       
  1428                 }
       
  1429             else
       
  1430                 {
       
  1431                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSink, NULL);             
       
  1432                 }
       
  1433             break;
       
  1434             }
       
  1435         case   EFAKESOURCE:
       
  1436             {
       
  1437             if(!iObjects->iSource)
       
  1438                 {
       
  1439                 error = KErrNotFound;
       
  1440                 }
       
  1441             else
       
  1442                 {
       
  1443                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSource, NULL);                             
       
  1444                 }
       
  1445             break;
       
  1446             }
       
  1447         case   EFAKESINK:
       
  1448             {
       
  1449             if(!iObjects->iSink)
       
  1450                 {
       
  1451                 error = KErrNotFound;
       
  1452                 }
       
  1453             else
       
  1454                 {
       
  1455                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSink, NULL);
       
  1456                 }
       
  1457             break;
       
  1458             }
       
  1459         case   EWAVPARSE:
       
  1460             {
       
  1461             if(!iObjects->iWavparse)
       
  1462                 {
       
  1463                 error = KErrNotFound;
       
  1464                 }
       
  1465             else
       
  1466                 {
       
  1467                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iWavparse, NULL);
       
  1468                 }
       
  1469             break;
       
  1470             }
       
  1471         case   EMP3DECODER:
       
  1472             {
       
  1473             if(!iObjects->iDecoder)
       
  1474                 {
       
  1475                 error = KErrNotFound;
       
  1476                 }
       
  1477             else
       
  1478                 {
       
  1479                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iDecoder, NULL);
       
  1480                 }
       
  1481             break;
       
  1482             }
       
  1483         case   EWAVEENCODER:
       
  1484             {
       
  1485             if(!iObjects->iEncoder)
       
  1486                 {
       
  1487                 error = KErrNotFound;
       
  1488                 }
       
  1489             else
       
  1490                 {
       
  1491                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iEncoder, NULL);
       
  1492                 }
       
  1493             break;
       
  1494             }
       
  1495         case   ERESAMPLER:
       
  1496             {
       
  1497             if(!iObjects->iResampler)
       
  1498                 {
       
  1499                 error = KErrNotFound;
       
  1500                 }
       
  1501             else
       
  1502                 {
       
  1503                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iResampler, NULL);
       
  1504                 }
       
  1505             break;
       
  1506             }
       
  1507         case   ECONVERTER:
       
  1508             {
       
  1509             if(!iObjects->iConverter)
       
  1510                 {
       
  1511                 error = KErrNotFound;
       
  1512                 }
       
  1513             else
       
  1514                 {
       
  1515                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iConverter, NULL);
       
  1516                 }
       
  1517             break;
       
  1518             }
       
  1519         case   EDEVSOUNDSRC:
       
  1520             {
       
  1521             if(!iObjects->iSource)
       
  1522                 {
       
  1523                 error = KErrNotFound;
       
  1524                 }
       
  1525             else
       
  1526                 {
       
  1527                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSource, NULL);
       
  1528                 }
       
  1529             break;
       
  1530             }            
       
  1531         case   EDEVSOUNDSINK:
       
  1532             {
       
  1533             if(!iObjects->iSink)
       
  1534                 {
       
  1535                 error = KErrNotFound;
       
  1536                 }
       
  1537             else
       
  1538                 {
       
  1539                 gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iSink, NULL);
       
  1540                 }
       
  1541             break;
       
  1542             }
       
  1543         default:
       
  1544             error = KErrNotFound;
       
  1545             break;
       
  1546         }
       
  1547     iLog->Log(_L("<<CGStreamerTestClass::AddElementToPipeline Error[%d]"),error);
       
  1548     return error;
       
  1549     }
       
  1550 
       
  1551 TInt CGStreamerTestClass::SetPipelineState( CStifItemParser& aItem )
       
  1552     {   
       
  1553     FTRACE(FPrint(_L("CGStreamerTestClass::SetPipelineState")));
       
  1554     iLog->Log(_L(">>CGStreamerTestClass::SetPipelineState"));
       
  1555     TInt element;
       
  1556     TInt error(KErrNone);
       
  1557     GstStateChangeReturn ret(GST_STATE_CHANGE_SUCCESS);
       
  1558     if(!iObjects->iPipeline)
       
  1559         {
       
  1560         return KErrNotFound;
       
  1561         }
       
  1562     
       
  1563     aItem.GetNextInt(element);
       
  1564     ret = gst_element_set_state (iObjects->iPipeline, static_cast<GstState>(element) ); 
       
  1565     iLog->Log(_L("<<CGStreamerTestClass::SetPipelineState Error[%d] ret[%d]"),error,ret);
       
  1566     return error;
       
  1567     }
       
  1568 
       
  1569 TInt CGStreamerTestClass::SetCapsInPipeLine( CStifItemParser& aItem )
       
  1570     {
       
  1571     TInt error(KErrNone);
       
  1572     TInt width(16);
       
  1573     TInt depth(16);
       
  1574     TInt signedProp(1);
       
  1575     TInt endianess(1234);
       
  1576     TInt rate(16000);
       
  1577     TInt channels(1);    
       
  1578     TPtrC media;
       
  1579 
       
  1580     TInt value(0);
       
  1581     FTRACE(FPrint(_L("CGStreamerTestClass::SetCapsInPipeLine")));
       
  1582     iLog->Log(_L(">>CGStreamerTestClass::SetCapsInPipeLine"));
       
  1583     
       
  1584     error = aItem.GetNextString(media);
       
  1585     HBufC8* mediaString = HBufC8::NewL(media.Length()+1);
       
  1586     TPtr8 des = mediaString->Des();
       
  1587     
       
  1588     if(error == KErrNone)
       
  1589         {
       
  1590         des.Copy(media);
       
  1591         
       
  1592         if(!des.Compare(defaultMedia()) || !des.Compare(mp3Media()))
       
  1593             {
       
  1594             width = 16;
       
  1595             depth = 16;
       
  1596             signedProp = 1;
       
  1597             endianess = 1234;
       
  1598             rate = 16000;
       
  1599             channels = 1;            
       
  1600             }
       
  1601         else if(!des.Compare(amrMedia()) || !des.Compare(g711Media())
       
  1602                 || !des.Compare(g729Media()) || !des.Compare(iLbcMedia()))
       
  1603             {
       
  1604             width = 8;
       
  1605             depth = 8;
       
  1606             signedProp = 1;
       
  1607             endianess = 1234;
       
  1608             rate = 8000;
       
  1609             channels = 1;  
       
  1610             }
       
  1611         }
       
  1612     else
       
  1613         {
       
  1614         des.Copy(defaultMedia());
       
  1615         }
       
  1616     
       
  1617     if(!aItem.GetNextInt(value))
       
  1618         {
       
  1619         width = value;
       
  1620         }
       
  1621     if(!aItem.GetNextInt(value))
       
  1622         {
       
  1623         depth = value;
       
  1624         }
       
  1625     if(!aItem.GetNextInt(value))
       
  1626         {
       
  1627         signedProp = value;
       
  1628         }
       
  1629     if(!aItem.GetNextInt(value))
       
  1630         {
       
  1631         endianess = value;
       
  1632         }
       
  1633     if(!aItem.GetNextInt(value))
       
  1634         {
       
  1635         rate = value;
       
  1636         }
       
  1637     if(!aItem.GetNextInt(value))
       
  1638         {
       
  1639         channels = value;
       
  1640         }
       
  1641     
       
  1642     iObjects->iCaps = gst_caps_new_simple ((const char *)des.PtrZ(),
       
  1643                                 "width", G_TYPE_INT, width,
       
  1644                                 "depth", G_TYPE_INT, depth,
       
  1645                                 "signed",G_TYPE_BOOLEAN, signedProp,
       
  1646                                 "endianness",G_TYPE_INT, endianess,
       
  1647                                 "rate", G_TYPE_INT, rate,
       
  1648                                 "channels", G_TYPE_INT, channels, NULL);
       
  1649     
       
  1650     delete mediaString;
       
  1651     iLog->Log(_L("<<CGStreamerTestClass::SetCapsInPipeLine Error[%d]"),error);
       
  1652     return error;
       
  1653     }
       
  1654 
       
  1655 
       
  1656 TInt CGStreamerTestClass::CustomIntfcProp( CStifItemParser& aItem )
       
  1657     {
       
  1658     FTRACE(FPrint(_L("CGStreamerTestClass::CustomIntfcProp")));
       
  1659     iLog->Log(_L(">>CGStreamerTestClass::CustomIntfcProp"));
       
  1660     TInt element;
       
  1661     TInt error(KErrNone);
       
  1662     if(!iObjects->iPipeline)
       
  1663         {
       
  1664         return KErrNotReady;
       
  1665         }
       
  1666 
       
  1667     while((aItem.GetNextInt(element) == KErrNone) && (error == KErrNone))
       
  1668         {
       
  1669         iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp element[%d]"),element);
       
  1670         switch(element)
       
  1671             {
       
  1672             case   EG711ENCODER:
       
  1673                 {
       
  1674                 if(!iObjects->iG711EncoderIntfc)
       
  1675                     {
       
  1676                     error = KErrNotFound;
       
  1677                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp error[%d]"),error);
       
  1678                     }
       
  1679                 else
       
  1680                     {
       
  1681                     TInt ciProp(0);
       
  1682                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp"));
       
  1683                     aItem.GetNextInt(ciProp);
       
  1684                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp ciprop[%d]"),ciProp);
       
  1685                     switch(ciProp)
       
  1686                         {
       
  1687                         case EG711SetEncoderMode:
       
  1688                             {
       
  1689                             TInt encoderMode(0);
       
  1690                             error = aItem.GetNextInt(encoderMode);
       
  1691                             if(error == KErrNone)
       
  1692                                 {
       
  1693                                 error = iObjects->iG711EncoderIntfc->SetEncoderMode(TG711EncodeMode(encoderMode));
       
  1694                                 }
       
  1695                             }
       
  1696                             break;
       
  1697                         case EG711SetVadMode:
       
  1698                             {
       
  1699                             TInt vadMode(0);
       
  1700                             error = aItem.GetNextInt(vadMode);
       
  1701                             if(!error)
       
  1702                                 {
       
  1703                                 error = iObjects->iG711EncoderIntfc->SetVadMode(vadMode);
       
  1704                                 }
       
  1705                             }
       
  1706                             break;
       
  1707                         case EG711GetVadMode:
       
  1708                             {
       
  1709                             TInt vadMode(0);
       
  1710                             iLog->Log(_L("iG711EncoderIntfc vadMode[%d]"),vadMode);
       
  1711                             error = iObjects->iG711EncoderIntfc->GetVadMode(&vadMode);
       
  1712                             iLog->Log(_L("iG711EncoderIntfc vadMode[%d]"),vadMode);
       
  1713                             }
       
  1714                             break;
       
  1715                         default:
       
  1716                             error = KErrArgument;
       
  1717                             break;
       
  1718                         }
       
  1719                     }
       
  1720                 break;
       
  1721                 }            
       
  1722             case   EG729ENCODER:
       
  1723                 {
       
  1724                 if(!iObjects->iG729EncoderIntfc)
       
  1725                     {
       
  1726                     error = KErrNotFound;
       
  1727                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp error[%d]"),error);
       
  1728                     }
       
  1729                 else
       
  1730                     {
       
  1731                     TInt ciProp(0);
       
  1732                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp"));
       
  1733                     aItem.GetNextInt(ciProp);
       
  1734                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp ciprop[%d]"),ciProp);
       
  1735                     switch(ciProp)
       
  1736                         {
       
  1737                         case EG729SetVadMode:
       
  1738                             {
       
  1739                             TInt vadMode(0);
       
  1740                             error = aItem.GetNextInt(vadMode);
       
  1741                             if(!error)
       
  1742                                 {
       
  1743                                 error = iObjects->iG729EncoderIntfc->SetVadMode(vadMode);
       
  1744                                 }
       
  1745                             }
       
  1746                             break;
       
  1747                         case EG729GetVadMode:
       
  1748                             {
       
  1749                             TInt vadMode(0);
       
  1750                             iLog->Log(_L("iG729EncoderIntfc vadMode[%d]"),vadMode);
       
  1751                             error = iObjects->iG729EncoderIntfc->GetVadMode(&vadMode);
       
  1752                             iLog->Log(_L("iG729EncoderIntfc vadMode[%d]"),vadMode);
       
  1753                             }
       
  1754                             break;
       
  1755                         default:
       
  1756                             error = KErrArgument;
       
  1757                             break;
       
  1758                         }
       
  1759                     }
       
  1760                 break;
       
  1761                 }            
       
  1762             case   EILBCENCODER:
       
  1763                 {
       
  1764                 if(!iObjects->iIlbcEncoderIntfc)
       
  1765                     {
       
  1766                     error = KErrNotFound;
       
  1767                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp error[%d]"),error);
       
  1768                     }
       
  1769                 else
       
  1770                     {
       
  1771                     TInt ciProp(0);
       
  1772                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp"));
       
  1773                     aItem.GetNextInt(ciProp);
       
  1774                     iLog->Log(_L("CGStreamerTestClass::CustomIntfcProp ciprop[%d]"),ciProp);
       
  1775                     switch(ciProp)
       
  1776                         {
       
  1777                         case EIlbcSetEncoderMode:
       
  1778                             {
       
  1779                             TInt encoderMode(0);
       
  1780                             error = aItem.GetNextInt(encoderMode);
       
  1781                             if(error == KErrNone)
       
  1782                                 {
       
  1783                                 error = iObjects->iIlbcEncoderIntfc->SetEncoderMode(TIlbcEncodeMode(encoderMode));
       
  1784                                 }
       
  1785                             }
       
  1786                             break;                        
       
  1787                         case EIlbcSetVadMode:
       
  1788                             {
       
  1789                             TInt vadMode(0);
       
  1790                             error = aItem.GetNextInt(vadMode);
       
  1791                             if(!error)
       
  1792                                 {
       
  1793                                 error = iObjects->iIlbcEncoderIntfc->SetVadMode(vadMode);
       
  1794                                 }
       
  1795                             }
       
  1796                             break;
       
  1797                         case EIlbcGetVadMode:
       
  1798                             {
       
  1799                             TInt vadMode(1);
       
  1800                             iLog->Log(_L("iIlbcEncoderIntfc vadMode[%d]"),vadMode);
       
  1801                             error = iObjects->iIlbcEncoderIntfc->GetVadMode(&vadMode);
       
  1802                             iLog->Log(_L("iIlbcEncoderIntfc vadMode[%d]"),vadMode);
       
  1803                             }
       
  1804                             break;
       
  1805                         default:
       
  1806                             error = KErrArgument;
       
  1807                             break;
       
  1808                         }
       
  1809                     }
       
  1810                 break;
       
  1811                 }            
       
  1812             case   ESPEECHENCODER:
       
  1813                 {
       
  1814                 if(!iObjects->iSpeechEncoderIntfc)
       
  1815                     {
       
  1816                     error = KErrNotFound;
       
  1817                     }
       
  1818                 else
       
  1819                     {
       
  1820                     TInt ciProp(0);
       
  1821                     aItem.GetNextInt(ciProp);
       
  1822                     switch(ciProp)
       
  1823                         {
       
  1824                         case ESPENGetSupportedBitrates:
       
  1825                             {
       
  1826                             //guint* bitRates[];
       
  1827                             //error = iSpeechEncoderIntfc->GetSupportedBitrates(&bitRates);
       
  1828                             }
       
  1829                             break;
       
  1830                         case ESPENSetVadMode:
       
  1831                             {
       
  1832                             gboolean vadMode(0);
       
  1833                             error = aItem.GetNextInt(vadMode);
       
  1834                             if(!error)
       
  1835                                 {
       
  1836                                 error = iObjects->iSpeechEncoderIntfc->SetVadMode(vadMode);
       
  1837                                 }
       
  1838                             }
       
  1839                             break;
       
  1840                         case ESPENGetVadMode:
       
  1841                             {
       
  1842                             gboolean vadMode(0);
       
  1843                             error = iObjects->iSpeechEncoderIntfc->GetVadMode(&vadMode);
       
  1844                             iLog->Log(_L("iSpeechEncoderIntfc vadMode[%d]"),vadMode);
       
  1845                             }
       
  1846                             break;
       
  1847                         case ESPENSetBitrate:
       
  1848                             {
       
  1849                             guint bitRate(0);
       
  1850                             error = aItem.GetNextInt(bitRate);
       
  1851                             if(!error)
       
  1852                                 {
       
  1853                                 error = iObjects->iSpeechEncoderIntfc->SetBitrate(bitRate);
       
  1854                                 }
       
  1855                             }
       
  1856                             break;
       
  1857                         case ESPENGetBitrate:
       
  1858                             {
       
  1859                             guint bitRate(0);
       
  1860                             error = iObjects->iSpeechEncoderIntfc->GetBitrate(&bitRate);
       
  1861                             iLog->Log(_L("iSpeechEncoderIntfc bitRate[%d]"),bitRate);
       
  1862                             }
       
  1863                             break;
       
  1864                         default:
       
  1865                             error = KErrArgument;
       
  1866                             break;
       
  1867                         }
       
  1868                     }
       
  1869                 break;
       
  1870                 }            
       
  1871             case   EG711DECODER:
       
  1872                 {
       
  1873                 if(!iObjects->iG711DecoderIntfc)
       
  1874                     {
       
  1875                     error = KErrNotFound;
       
  1876                     }
       
  1877                 else
       
  1878                     {
       
  1879                     TInt ciProp(0);
       
  1880                     aItem.GetNextInt(ciProp);
       
  1881                     switch(ciProp)
       
  1882                         {
       
  1883                         case EG711SetDecoderMode:
       
  1884                             {
       
  1885                             TInt decMode(0);
       
  1886                              error = aItem.GetNextInt(decMode);
       
  1887                              if(!error)
       
  1888                                  {
       
  1889                                  error = iObjects->iG711DecoderIntfc->SetDecoderMode(TG711DecodeMode(decMode));
       
  1890                                  }
       
  1891                             }
       
  1892                             break;
       
  1893                         case EG711SetCng:
       
  1894                             {
       
  1895                             TInt cng(0);
       
  1896                              error = aItem.GetNextInt(cng);
       
  1897                              if(!error)
       
  1898                                  {
       
  1899                                  error = iObjects->iG711DecoderIntfc->SetCng(cng);
       
  1900                                  }
       
  1901                             }
       
  1902                             break;
       
  1903                         case EG711GetCng:
       
  1904                             {
       
  1905                             TInt cng(0);
       
  1906                             error = iObjects->iG711DecoderIntfc->GetCng(&cng);
       
  1907                             iLog->Log(_L("iG711DecoderIntfc cng[%d]"),cng);
       
  1908                             }
       
  1909                             break;
       
  1910                         case EG711SetPlc:
       
  1911                             {
       
  1912                             TInt plc(0);
       
  1913                             error = aItem.GetNextInt(plc);
       
  1914                             if(!error)
       
  1915                                 {
       
  1916                                 error = iObjects->iG711DecoderIntfc->SetPlc(plc);
       
  1917                                 }
       
  1918                             }
       
  1919                             break;
       
  1920                         default:
       
  1921                             error = KErrArgument;
       
  1922                             break;
       
  1923                         }
       
  1924                     }
       
  1925                 break;
       
  1926                 }
       
  1927             case   EILBCDECODER:
       
  1928                 {
       
  1929                 if(!iObjects->iIlbcDecoderIntfc)
       
  1930                     {
       
  1931                     error = KErrNotFound;
       
  1932                     }
       
  1933                 else
       
  1934                     {
       
  1935                     TInt ciProp(0);
       
  1936                     aItem.GetNextInt(ciProp);
       
  1937                     switch(ciProp)
       
  1938                         {
       
  1939                         case EIlbcSetDecoderMode:
       
  1940                             {
       
  1941                             TInt decMode(0);
       
  1942                              error = aItem.GetNextInt(decMode);
       
  1943                              if(!error)
       
  1944                                  {
       
  1945                                  error = iObjects->iIlbcDecoderIntfc->SetDecoderMode(TIlbcDecodeMode(decMode));
       
  1946                                  }
       
  1947                             }
       
  1948                             break;
       
  1949                         case EIlbcSetCng:
       
  1950                             {
       
  1951                             TInt cng(0);
       
  1952                              error = aItem.GetNextInt(cng);
       
  1953                              if(!error)
       
  1954                                  {
       
  1955                                  error = iObjects->iIlbcDecoderIntfc->SetCng(cng);
       
  1956                                  }
       
  1957                             }
       
  1958                             break;
       
  1959                         case EIlbcGetCng:
       
  1960                             {
       
  1961                             TInt cng(0);
       
  1962                             error = iObjects->iIlbcDecoderIntfc->GetCng(&cng);
       
  1963                             iLog->Log(_L("iIlbcDecoderIntfc cng[%d]"),cng);
       
  1964                             }
       
  1965                             break;
       
  1966                         default:
       
  1967                             error = KErrArgument;
       
  1968                             break;
       
  1969                         }
       
  1970                     }
       
  1971                 break;
       
  1972                 }
       
  1973             case   EG729DECODER:
       
  1974                 {
       
  1975                 if(!iObjects->iG729DecoderIntfc)
       
  1976                     {
       
  1977                     error = KErrNotFound;
       
  1978                     }
       
  1979                 else
       
  1980                     {
       
  1981                     TInt ciProp(0);
       
  1982                     aItem.GetNextInt(ciProp);
       
  1983                     switch(ciProp)
       
  1984                         {
       
  1985                         case EG729BadLsfNextBuffer:
       
  1986                             {
       
  1987                             error = iObjects->iG729DecoderIntfc->BadLsfNextBuffer();
       
  1988                             }
       
  1989                             break;
       
  1990                         default:
       
  1991                             error = KErrArgument;
       
  1992                             break;
       
  1993                         }
       
  1994                     }
       
  1995                 break;
       
  1996                 }
       
  1997             case   EERRORCONCEALMENT:
       
  1998                 {
       
  1999                 if(!iObjects->iErrconcealmentIntfc)
       
  2000                     {
       
  2001                     error = KErrNotFound;
       
  2002                     iLog->Log(_L("iErrconcealmentIntfc error[%d]"),error);
       
  2003                     }
       
  2004                 else
       
  2005                     {
       
  2006                     TInt ciProp(0);
       
  2007                     aItem.GetNextInt(ciProp);
       
  2008                     switch(ciProp)
       
  2009                         {
       
  2010                         case EECConcealErrorForNextBuffer:
       
  2011                             {
       
  2012                             error = iObjects->iErrconcealmentIntfc->ConcealErrorForNextBuffer();
       
  2013                             iLog->Log(_L("iErrconcealmentIntfc ConcealErrorForNextBuffer error[%d]"),error);
       
  2014                             }
       
  2015                             break;
       
  2016                         case EECSetFrameMode:
       
  2017                             {
       
  2018                             TInt frmMode(0);
       
  2019                             error = aItem.GetNextInt(frmMode);
       
  2020                             if(!error)
       
  2021                                 {
       
  2022                                 error = iObjects->iErrconcealmentIntfc->SetFrameMode(frmMode);
       
  2023                                 iLog->Log(_L("iErrconcealmentIntfc SetFrameMode[%d]"),frmMode);
       
  2024                                 }
       
  2025                             }
       
  2026                             break;
       
  2027                         case EECFrameModeRqrdForEC:
       
  2028                             {
       
  2029                             TInt frmModeReq(0);
       
  2030                             error = iObjects->iErrconcealmentIntfc->FrameModeRqrdForEC(&frmModeReq);
       
  2031                             iLog->Log(_L("iErrconcealmentIntfc frmModeReq[%d]"),frmModeReq);
       
  2032                             }
       
  2033                             break;
       
  2034                         default:
       
  2035                             error = KErrArgument;
       
  2036                             break;
       
  2037                         }
       
  2038                     }
       
  2039                 break;
       
  2040                 }
       
  2041             default:
       
  2042                 error = KErrArgument;
       
  2043                 break;
       
  2044             }
       
  2045         }
       
  2046     iLog->Log(_L("<<CGStreamerTestClass::CustomIntfcProp Error[%d]"),error);
       
  2047     return error;
       
  2048     }
       
  2049 
       
  2050 TInt CGStreamerTestClass::GetElementsCustomIntfc( CStifItemParser& aItem )
       
  2051     {
       
  2052     FTRACE(FPrint(_L("CGStreamerTestClass::GetElementsCustomIntfc")));
       
  2053     iLog->Log(_L(">>CGStreamerTestClass::GetElementsCustomIntfc"));
       
  2054     TInt element;
       
  2055     TInt error(KErrNone);
       
  2056     if(!iObjects->iPipeline)
       
  2057         {
       
  2058         return KErrNotReady;
       
  2059         }
       
  2060 
       
  2061     while((aItem.GetNextInt(element) == KErrNone) && (error == KErrNone))
       
  2062         {
       
  2063         switch(element)
       
  2064             {
       
  2065             case   EDEVSOUNDSRC:
       
  2066                 {
       
  2067                 if(!iObjects->iSource)
       
  2068                     {
       
  2069                     error = KErrNotFound;
       
  2070                     }
       
  2071                 else
       
  2072                     {
       
  2073                     TInt customInterface(0);
       
  2074                     aItem.GetNextInt(customInterface);
       
  2075                     switch(customInterface)
       
  2076                         {
       
  2077                         case EG711ENCODER:
       
  2078                             {
       
  2079                             iObjects->iG711EncoderIntfc = GST_G711_ENCODER_GET_IFACE(iObjects->iSource);
       
  2080                             iLog->Log(_L("iG711EncoderIntfc"));
       
  2081                             }
       
  2082                             break;
       
  2083                         case EG729ENCODER:
       
  2084                             {
       
  2085                             iObjects->iG729EncoderIntfc = GST_G729_ENCODER_GET_IFACE(iObjects->iSource);
       
  2086                             }
       
  2087                             break;
       
  2088                         case EILBCENCODER:
       
  2089                             {
       
  2090                             iObjects->iIlbcEncoderIntfc = GST_ILBC_ENCODER_GET_IFACE(iObjects->iSource);
       
  2091                             }
       
  2092                             break;
       
  2093                         case ESPEECHENCODER:
       
  2094                             {
       
  2095                             iObjects->iSpeechEncoderIntfc = GST_SPEECH_ENCODER_CONFIG_GET_IFACE(iObjects->iSource);
       
  2096                             }
       
  2097                             break;
       
  2098                         default:
       
  2099                             break;
       
  2100                         }
       
  2101                     }
       
  2102                 break;
       
  2103                 }            
       
  2104             case   EDEVSOUNDSINK:
       
  2105                 {
       
  2106                 if(!iObjects->iSink)
       
  2107                     {
       
  2108                     error = KErrNotFound;
       
  2109                     }
       
  2110                 else
       
  2111                     {
       
  2112                     TInt customInterface(0);
       
  2113                     aItem.GetNextInt(customInterface);
       
  2114                     switch(customInterface)
       
  2115                         {
       
  2116                         case EG711DECODER:
       
  2117                             {
       
  2118                             iObjects->iG711DecoderIntfc = GST_G711_DECODER_GET_IFACE(iObjects->iSink);
       
  2119                             }
       
  2120                             break;
       
  2121                         case EG729DECODER:
       
  2122                             {
       
  2123                             iObjects->iG729DecoderIntfc = GST_G729_DECODER_GET_IFACE(iObjects->iSink);
       
  2124                             }
       
  2125                             break;                            
       
  2126                         case EILBCDECODER:
       
  2127                             {
       
  2128                             iObjects->iIlbcDecoderIntfc = GST_ILBC_DECODER_GET_IFACE(iObjects->iSink);
       
  2129                             }
       
  2130                             break;                            
       
  2131                         case EERRORCONCEALMENT:
       
  2132                             {
       
  2133                             iObjects->iErrconcealmentIntfc = GST_ERROR_CONCEALMENT_GET_IFACE(iObjects->iSink);
       
  2134                             }
       
  2135                             break;
       
  2136                         default:
       
  2137                             break;
       
  2138                         }
       
  2139                     }
       
  2140                 break;
       
  2141                 }
       
  2142             default:
       
  2143                 error = KErrArgument;
       
  2144                 break;
       
  2145             }
       
  2146         }
       
  2147     iLog->Log(_L("<<CGStreamerTestClass::GetElementsCustomIntfc Error[%d]"),error);
       
  2148     return error;
       
  2149     }
       
  2150 
       
  2151 
       
  2152 TInt CGStreamerTestClass::LinkElementsInPipeline( CStifItemParser& aItem )
       
  2153     {   
       
  2154     FTRACE(FPrint(_L("CGStreamerTestClass::LinkElementsInPipeline")));
       
  2155     iLog->Log(_L(">>CGStreamerTestClass::LinkElementsInPipeline"));
       
  2156     TInt element;
       
  2157     TInt error(KErrNone);
       
  2158     if(!iObjects->iPipeline)
       
  2159         {
       
  2160         return KErrNotReady;
       
  2161         }
       
  2162     RPointerArray<GstElement> array;
       
  2163     
       
  2164     while((aItem.GetNextInt(element) == KErrNone) && (error == KErrNone))
       
  2165         {
       
  2166         switch(element)
       
  2167             {
       
  2168             case   EFILESOURCE:
       
  2169                 {
       
  2170                 if(!iObjects->iSource)
       
  2171                     {
       
  2172                     error = KErrNotFound;
       
  2173                     }
       
  2174                 else
       
  2175                     {
       
  2176                     array.Append(iObjects->iSource);
       
  2177                     }
       
  2178                 break;
       
  2179                 }
       
  2180             case   EFILESINK:
       
  2181                 {
       
  2182                 if(!iObjects->iSink)
       
  2183                     {
       
  2184                     error = KErrNotFound;
       
  2185                     }
       
  2186                 else
       
  2187                     {
       
  2188                     array.Append(iObjects->iSink);             
       
  2189                     }
       
  2190                 break;
       
  2191                 }
       
  2192             case   EFAKESOURCE:
       
  2193                 {
       
  2194                 if(!iObjects->iSource)
       
  2195                     {
       
  2196                     error = KErrNotFound;
       
  2197                     }
       
  2198                 else
       
  2199                     {
       
  2200                     array.Append(iObjects->iSource);                             
       
  2201                     }
       
  2202                 break;
       
  2203                 }
       
  2204             case   EFAKESINK:
       
  2205                 {
       
  2206                 if(!iObjects->iSink)
       
  2207                     {
       
  2208                     error = KErrNotFound;
       
  2209                     }
       
  2210                 else
       
  2211                     {
       
  2212                     array.Append(iObjects->iSink);
       
  2213                     }
       
  2214                 break;
       
  2215                 }
       
  2216             case   EWAVPARSE:
       
  2217                 {
       
  2218                 if(!iObjects->iWavparse)
       
  2219                     {
       
  2220                     error = KErrNotFound;
       
  2221                     }
       
  2222                 else
       
  2223                     {
       
  2224                     array.Append(iObjects->iWavparse);
       
  2225                     }
       
  2226                 break;
       
  2227                 }
       
  2228             case   EMP3DECODER:
       
  2229                 {
       
  2230                 if(!iObjects->iDecoder)
       
  2231                     {
       
  2232                     error = KErrNotFound;
       
  2233                     }
       
  2234                 else
       
  2235                     {
       
  2236                     array.Append(iObjects->iDecoder);
       
  2237                     }
       
  2238                 break;
       
  2239                 }
       
  2240             case   EWAVEENCODER:
       
  2241                 {
       
  2242                 if(!iObjects->iEncoder)
       
  2243                     {
       
  2244                     error = KErrNotFound;
       
  2245                     }
       
  2246                 else
       
  2247                     {
       
  2248                     array.Append(iObjects->iEncoder);
       
  2249                     }
       
  2250                 break;
       
  2251                 }
       
  2252             case   ERESAMPLER:
       
  2253                 {
       
  2254                 if(!iObjects->iResampler)
       
  2255                     {
       
  2256                     error = KErrNotFound;
       
  2257                     }
       
  2258                 else
       
  2259                     {
       
  2260                     array.Append(iObjects->iResampler);
       
  2261                     }
       
  2262                 break;
       
  2263                 }
       
  2264             case   ECONVERTER:
       
  2265                 {
       
  2266                 if(!iObjects->iConverter)
       
  2267                     {
       
  2268                     error = KErrNotFound;
       
  2269                     }
       
  2270                 else
       
  2271                     {
       
  2272                     array.Append(iObjects->iConverter);
       
  2273                     }
       
  2274                 break;
       
  2275                 }
       
  2276             case   EDEVSOUNDSRC:
       
  2277                 {
       
  2278                 if(!iObjects->iSource)
       
  2279                     {
       
  2280                     error = KErrNotFound;
       
  2281                     }
       
  2282                 else
       
  2283                     {
       
  2284                     array.Append(iObjects->iSource);
       
  2285                     }
       
  2286                 break;
       
  2287                 }            
       
  2288             case   EDEVSOUNDSINK:
       
  2289                 {
       
  2290                 if(!iObjects->iSink)
       
  2291                     {
       
  2292                     error = KErrNotFound;
       
  2293                     }
       
  2294                 else
       
  2295                     {
       
  2296                     array.Append(iObjects->iSink);
       
  2297                     }
       
  2298                 break;
       
  2299                 }
       
  2300             default:
       
  2301                 error = KErrNotFound;
       
  2302                 break;
       
  2303             }
       
  2304         }
       
  2305     
       
  2306     if(error)
       
  2307         {
       
  2308         return error;
       
  2309         }
       
  2310     
       
  2311     gboolean linkOK(0);
       
  2312     TInt count = array.Count();
       
  2313     if(count < 2)
       
  2314         {
       
  2315         return KErrArgument;
       
  2316         }
       
  2317     else
       
  2318         {
       
  2319         for(TInt i = 1; i < count ; i++)
       
  2320             {
       
  2321             if(iObjects->iCaps)
       
  2322                 {
       
  2323                 linkOK = gst_element_link_filtered(array[i-1],array[i],iObjects->iCaps);
       
  2324                 gst_caps_unref(iObjects->iCaps);
       
  2325                 iObjects->iCaps = NULL;
       
  2326                 }
       
  2327             else
       
  2328                 {
       
  2329                 linkOK = gst_element_link(array[i-1],array[i]);
       
  2330                 }
       
  2331             }        
       
  2332         }
       
  2333     
       
  2334     array.Close();
       
  2335     iLog->Log(_L("<<CGStreamerTestClass::LinkElementsInPipeline Error[%d]"),linkOK);
       
  2336     return error;
       
  2337     }
       
  2338 
       
  2339 
       
  2340 //  End of File