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