diff -r 9b2c3c7a1a9c -r 567bb019e3e3 gst_plugins_symbian/tsrc/gstreamertestmodule/src/GStreamerTestClassBlocks.cpp --- a/gst_plugins_symbian/tsrc/gstreamertestmodule/src/GStreamerTestClassBlocks.cpp Wed Mar 31 22:03:18 2010 +0300 +++ b/gst_plugins_symbian/tsrc/gstreamertestmodule/src/GStreamerTestClassBlocks.cpp Tue Aug 31 15:30:33 2010 +0300 @@ -30,6 +30,7 @@ #include "debug.h" #include #include +#include _LIT8(defaultMedia,"audio/x-raw-int"); @@ -113,6 +114,9 @@ iFakesink = NULL; iFilesink = NULL; iEncoder = NULL; + iAACEncoder = NULL; + iQtMux = NULL; + iAmrMux = NULL; iFilter = NULL; iWavenc = NULL; iBus = NULL; @@ -184,6 +188,14 @@ g_error_free (err); break; } + case GST_MESSAGE_STATE_CHANGED: + { + GstState* state = NULL; + GstState * pending = NULL; + gst_element_get_state(GST_ELEMENT (objects->iPipeline),state,pending,-1 ); + //int x = 10; + } + break; default: break; } @@ -264,7 +276,12 @@ ENTRY( "SetExpectedEvents", CGStreamerTestClass::SetExpectedEvents ), ENTRY( "SetMainLoopRun", CGStreamerTestClass::SetMainLoopRun ), ENTRY( "SetCapsInPipeLine", CGStreamerTestClass::SetCapsInPipeLine ), - + ENTRY( "StopRecording", CGStreamerTestClass::StopRecording ), + ENTRY( "SeekElement", CGStreamerTestClass::SeekElement ), + ENTRY( "CheckProperties", CGStreamerTestClass::CheckProperties ), + ENTRY( "GstReliabilitytestPlaypause", CGStreamerTestClass::GstReliabilitytestPlaypause ), + ENTRY( "GstReliabilitytestRecording", CGStreamerTestClass::GstReliabilitytestRecording ), + ENTRY( "PlayBack", CGStreamerTestClass::PlayBack ), }; const TInt count = sizeof( KFunctions ) / @@ -577,6 +594,142 @@ return KErrNone; } +/*** block b from ../../../docs/manual/highlevel-components.xml ***/ +static gboolean +my_bus_callback (GstBus *bus, + GstMessage *message, + gpointer data) +{ + + GMainLoop *loop = ( GMainLoop * )data; + + switch (GST_MESSAGE_TYPE (message)) { + case GST_MESSAGE_ERROR: { + GError *err; + gchar *debug; + + gst_message_parse_error (message, &err, &debug); + g_print ("Error: %s\n", err->message); + g_error_free (err); + g_free (debug); + + g_main_loop_quit (loop); + break; + } + case GST_MESSAGE_EOS: + + /* end-of-stream */ + g_main_loop_quit (loop); + break; + default: + /* unhandled message */ + break; + } + + /* remove message from the queue */ + return TRUE; +} + +/*** block c from ../../../docs/manual/highlevel-components.xml ***/ +GstElement *pipeline; +GstPad* devsoundsinkpad = NULL; + +static void +cb_newpad (GstElement *decodebin, + GstPad *pad, + gboolean last, + gpointer data) +{ + GstCaps *caps; + GstStructure *str; + GstPadLinkReturn linkret= GST_PAD_LINK_OK ; + + /* check media type */ + caps = gst_pad_get_caps (pad); + str = gst_caps_get_structure (caps, 0); + if (!g_strrstr (gst_structure_get_name (str), "audio")) { + gst_caps_unref (caps); + return; + } + gst_caps_unref (caps); + + /* link'n'play */ + linkret = gst_pad_link (pad, devsoundsinkpad); +} + + +gboolean cb_autoplug( GstBin * *bin, + GstPad *pad, + GstCaps *caps, + gpointer user_data) +{ + + GstCaps* sinkcaps = NULL; + gboolean supported = FALSE; + + sinkcaps = gst_pad_get_caps( devsoundsinkpad ); + + supported = gst_caps_is_subset( caps, sinkcaps ); + + if( supported ) + { + return FALSE; + } + + return TRUE; + +} + + + +TInt CGStreamerTestClass::PlayBack( CStifItemParser& aItem ) +{ + GMainLoop *loop; + GstElement *src, *dec, *sink; + GstBus *bus; + + FTRACE(FPrint(_L("CGStreamerTestClass::PlayBack"))); + + iLog->Log(_L(">>filesrc creation ")); + + src = gst_element_factory_make ("filesrc", "source"); + + iLog->Log(_L("<iPipeline),src, NULL); + + iLog->Log(_L(">>decodebin2 creation ")); + dec = gst_element_factory_make ("decodebin2", "decoder"); + iLog->Log(_L("<iPipeline), src, dec, sink, NULL); + + devsoundsinkpad = gst_element_get_pad( sink, "sink"); + + g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL); + g_signal_connect (dec, "autoplug-continue", G_CALLBACK (cb_autoplug), NULL); + + gst_element_link (src, dec); + + iLog->Log(_L("<Log(_L("<iAACEncoder) + { + error = KErrAlreadyExists; + } + else + { + iObjects->iAACEncoder = gst_element_factory_make("nokiaaacenc", "nokiaaacenc"); + if( iObjects->iAACEncoder == NULL ) + iLog->Log(_L(" iObjects->iAACEncoder == NULL")); + } + break; + } + case ENOKIAQTMUX: + { + if(iObjects->iQtMux) + { + error = KErrAlreadyExists; + } + else + { + iObjects->iQtMux = gst_element_factory_make("mp4mux", "mp4mux"); + if( iObjects->iQtMux == NULL ) + iLog->Log(_L(" iObjects->iQtMux == NULL")); + } + break; + } + case ENOKIAAMRMUX: + { + if(iObjects->iAmrMux) + { + error = KErrAlreadyExists; + } + else + { + iObjects->iAmrMux = gst_element_factory_make("amrmux", "amrmux"); + if( iObjects->iAmrMux == NULL ) + iLog->Log(_L(" iObjects->iAmrMux == NULL")); + } + break; + } case ERESAMPLER: { if(iObjects->iResampler) @@ -890,6 +1087,42 @@ } break; } + case ENOKIAAACENCODER: + { + if(!iObjects->iAACEncoder) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAQTMUX: + { + if(!iObjects->iQtMux) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAAMRMUX: + { + if(!iObjects->iAmrMux) + { + error = KErrNotFound; + } + else + { + gboolean header; + g_object_get (G_OBJECT (iObjects->iAmrMux), "header", &header, NULL); + + } + break; + } case ERESAMPLER: { if(!iObjects->iResampler) @@ -956,6 +1189,17 @@ FTRACE(FPrint(_L("CGStreamerTestClass::GetElementProperties SamplesRecorded[%d]"),value)); iLog->Log(_L("CGStreamerTestClass::GetElementProperties SamplesRecorded[%d]"),value); } + else if(!property.Compare(KTagLeftBalanceProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + } + + else if(!property.Compare(KTagRightBalanceProperty())) + { + + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + + } delete prop; } break; @@ -1119,6 +1363,42 @@ } break; } + case ENOKIAAACENCODER: + { + if(!iObjects->iAACEncoder) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAQTMUX: + { + if(!iObjects->iQtMux) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAAMRMUX: + { + if(!iObjects->iAmrMux) + { + error = KErrNotFound; + } + else + { + TInt value; + aItem.GetNextInt(value); + g_object_set (G_OBJECT (iObjects->iAmrMux), "header", (gboolean)value, NULL); + } + break; + } case ERESAMPLER: { if(!iObjects->iResampler) @@ -1239,6 +1519,18 @@ error = KErrNotFound; } } + else if(!property.Compare(KTagNumBuffersProperty())) + { + TInt value; + if(!aItem.GetNextInt(value)) + { + g_object_set (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), value, NULL); + } + else + { + error = KErrNotFound; + } + } delete prop; } break; @@ -1492,6 +1784,45 @@ } break; } + case ENOKIAAACENCODER: + { + iLog->Log(_L("<iAACEncoder) + { + error = KErrNotFound; + } + else + { + gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iAACEncoder, NULL); + } + break; + } + case ENOKIAQTMUX: + { + + if(!iObjects->iQtMux) + { + error = KErrNotFound; + } + else + { + gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iQtMux, NULL); + } + break; + } + case ENOKIAAMRMUX: + { + + if(!iObjects->iAmrMux) + { + error = KErrNotFound; + } + else + { + gst_bin_add_many(GST_BIN (iObjects->iPipeline),iObjects->iAmrMux, NULL); + } + break; + } case ERESAMPLER: { if(!iObjects->iResampler) @@ -1566,6 +1897,8 @@ return error; } + + TInt CGStreamerTestClass::SetCapsInPipeLine( CStifItemParser& aItem ) { TInt error(KErrNone); @@ -2249,6 +2582,42 @@ } break; } + case ENOKIAAACENCODER: + { + if(!iObjects->iAACEncoder) + { + error = KErrNotFound; + } + else + { + array.Append(iObjects->iAACEncoder); + } + break; + } + case ENOKIAQTMUX: + { + if(!iObjects->iQtMux) + { + error = KErrNotFound; + } + else + { + array.Append(iObjects->iQtMux); + } + break; + } + case ENOKIAAMRMUX: + { + if(!iObjects->iAmrMux) + { + error = KErrNotFound; + } + else + { + array.Append(iObjects->iAmrMux); + } + break; + } case ERESAMPLER: { if(!iObjects->iResampler) @@ -2326,7 +2695,31 @@ } else { - linkOK = gst_element_link(array[i-1],array[i]); + if( array[i] == iObjects->iQtMux) + { + iLog->Log(_L("array[i] == iObjects->iQtMux")); + GstPad* qtsinkpad = gst_element_get_request_pad( array[i], "audio_%d"); + if( !qtsinkpad ) + { + iLog->Log(_L("qtsinkpad failed")); + } + GstPad* aacencsrcpad = gst_element_get_pad( array[i-1], "src"); + if( !aacencsrcpad ) + { + iLog->Log(_L("aacencsrcpad failed")); + } + + //linkOK = gst_pad_link (aacencsrcpad,qtsinkpad); + if( gst_pad_link (aacencsrcpad,qtsinkpad) != GST_PAD_LINK_OK ) + { + iLog->Log(_L("gst_pad_link (aacencsrcpad,qtsinkpad) failed")); + linkOK = 0; + } + } + else + { + linkOK = gst_element_link(array[i-1],array[i]); + } } } } @@ -2337,4 +2730,420 @@ } + + + + + + + + + + + +TInt CGStreamerTestClass::StopRecording( CStifItemParser& /*aItem*/ ) + { + FTRACE(FPrint(_L("CGStreamerTestClass::StopRecording"))); + iLog->Log(_L(">>CGStreamerTestClass::StopRecording")); + gst_element_send_event (iObjects->iPipeline, gst_event_new_eos ()); + iLog->Log(_L("<Log(_L(">>CGStreamerTestClass::GstReliabilitytestRecording")); + TInt i=0; + aItem.GetNextInt(i); + while(--i) + { + gst_element_set_state (iObjects->iPipeline, GST_STATE_PLAYING ); + sleep (60); + } + iLog->Log(_L("<Log(_L(">>CGStreamerTestClass::GstReliabilitytestPlaypause")); + TInt i=0; + aItem.GetNextInt(i); + //aItem.GetNextInt(element); + while( --i ) + { + gst_element_set_state (iObjects->iPipeline, GST_STATE_PLAYING ); + sleep(10); + gst_element_set_state (iObjects->iPipeline, GST_STATE_PAUSED ); + sleep(2); + } + iLog->Log(_L("<Log(_L(">>CGStreamerTestClass::CheckProperties")); + TInt error = KErrNone; + TInt element; + TInt ValueExpected(0); + aItem.GetNextInt(element); + switch(element) + { + case EFILESOURCE: + { + if(!iObjects->iSource) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EFILESINK: + { + if(!iObjects->iSink) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EFAKESOURCE: + { + if(!iObjects->iSource) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EFAKESINK: + { + if(!iObjects->iSink) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EWAVPARSE: + { + if(!iObjects->iWavparse) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EMP3DECODER: + { + if(!iObjects->iDecoder) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EWAVEENCODER: + { + if(!iObjects->iEncoder) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAAACENCODER: + { + if(!iObjects->iAACEncoder) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAQTMUX: + { + if(!iObjects->iQtMux) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ENOKIAAMRMUX: + { + if(!iObjects->iAmrMux) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ERESAMPLER: + { + if(!iObjects->iResampler) + { + error = KErrNotFound; + } + else + { + } + break; + } + case ECONVERTER: + { + if(!iObjects->iConverter) + { + error = KErrNotFound; + } + else + { + } + break; + } + case EDEVSOUNDSRC: + { + if(!iObjects->iSource) + { + error = KErrNotFound; + } + else + { + TPtrC property; + TInt value(0); + aItem.GetNextString(property); + aItem.GetNextInt(ValueExpected); + HBufC8* prop = HBufC8::NewL(property.Length()+ 1); + TPtr8 des = prop->Des(); + des.Copy(property); + if(!property.Compare(KTagGainProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties GetGain[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties GetGain[%d]"),value); + } + else if(!property.Compare(KTagRateProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + value = convert_devsound_rate(value); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties GetRate[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties GetRate[%d]"),value); + } + else if(!property.Compare(KTagChannelsProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties Channels[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties channels[%d]"),value); + } + else if(!property.Compare(KTagMaxGainProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties MaxGain[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties Max Gain[%d]"),value); + } + else if(!property.Compare(KTagSamplesRecordedProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties SamplesRecorded[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties SamplesRecorded[%d]"),value); + } + + else if(!property.Compare(KTagLeftBalanceProperty())) + { + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + } + + else if(!property.Compare(KTagRightBalanceProperty())) + { + + g_object_get (G_OBJECT (iObjects->iSource),(const char *)(des.PtrZ()), &value, NULL); + + } + + if(value == ValueExpected) + { + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties EDEVSOUNDSRC OK"))); + iLog->Log(_L("CGStreamerTestClass::CheckProperties EDEVSOUNDSRC OK " )); + } + else + { + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties EDEVSOUNDSRC Error ValueExpected [%d]"),ValueExpected)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties EDEVSOUNDSRC ValueExpected [%d]"),ValueExpected); + error = KErrGeneral; + gst_element_set_state (iObjects->iPipeline,GST_STATE_NULL); + } + delete prop; + } + break; + } + case EDEVSOUNDSINK: + { + if(!iObjects->iSink) + { + error = KErrNotFound; + } + else + { + TPtrC property; + TInt value(0); + aItem.GetNextString(property); + HBufC8* prop = HBufC8::NewL(property.Length()+ 1); + TPtr8 des = prop->Des(); + des.Copy(property); + if(!property.Compare(KTagVolumeProperty())) + { + g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties Volume[%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties Volume[%d]"),value); + } + else if(!property.Compare(KTagRateProperty())) + { + g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties rate [%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties rate[%d]"),value); + } + else if(!property.Compare(KTagChannelsProperty())) + { + g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties channels [%d]"),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties channels[%d]"),value); + } + else if(!property.Compare(KTagMaxVolumeProperty())) + { + g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties max vol[%d] "),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties max vol[%d]"),value); + } + else if(!property.Compare(KTagSamplesPlayedProperty())) + { + g_object_get (G_OBJECT (iObjects->iSink),(const char *)(des.PtrZ()), &value, NULL); + FTRACE(FPrint(_L("CGStreamerTestClass::CheckProperties samples played[%d] "),value)); + iLog->Log(_L("CGStreamerTestClass::CheckProperties samples played[%d]"),value); + } + delete prop; + } + break; + } + default: + error = KErrNotFound; + break; + } + iLog->Log(_L(">>CGStreamerTestClass::CheckProperties Error[%d]"),error); + return error; + iLog->Log(_L("<Log(_L(">>CGStreamerTestClass::SeekElement")); + // + TInt time; + GstFormat fmt = GST_FORMAT_TIME; + gint64 pos1, len1 , pos2 , len2; + + aItem.GetNextInt(time); + if (gst_element_query_position (iObjects->iPipeline, &fmt, &pos1) + && gst_element_query_duration (iObjects->iPipeline, &fmt, &len1)) { + iLog->Log(_L("CGStreamerTestClass:: before seek query position and duration error")); + } + pos1 = (pos1 / GST_SECOND ) ; + len1 = (len1 / GST_SECOND ) ; + time = pos1 + (time); + if (!gst_element_seek (iObjects->iPipeline, 1.0 , GST_FORMAT_TIME, GST_SEEK_FLAG_ACCURATE, + GST_SEEK_TYPE_SET, time*GST_SECOND , + GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE)) { + iLog->Log(_L("<iPipeline, &fmt, &pos2) + && gst_element_query_duration (iObjects->iPipeline, &fmt, &len2)) { + iLog->Log(_L("CGStreamerTestClass:: after seek query position and duration error")); + } + pos2 = (pos2 / GST_SECOND ) ; + len2 = (len2 / GST_SECOND ) ; + iLog->Log(_L("<