gst_plugins_symbian/tsrc/gstreamertestmodule/src/GStreamerTestClassBlocks.cpp
changeset 20 7e3786c5ed27
parent 16 8e837d1bf446
equal deleted inserted replaced
19:24ed0baaf8e5 20:7e3786c5ed27
   279         ENTRY( "StopRecording", CGStreamerTestClass::StopRecording ),
   279         ENTRY( "StopRecording", CGStreamerTestClass::StopRecording ),
   280         ENTRY( "SeekElement", CGStreamerTestClass::SeekElement ),
   280         ENTRY( "SeekElement", CGStreamerTestClass::SeekElement ),
   281         ENTRY( "CheckProperties", CGStreamerTestClass::CheckProperties ),
   281         ENTRY( "CheckProperties", CGStreamerTestClass::CheckProperties ),
   282         ENTRY( "GstReliabilitytestPlaypause", CGStreamerTestClass::GstReliabilitytestPlaypause ),
   282         ENTRY( "GstReliabilitytestPlaypause", CGStreamerTestClass::GstReliabilitytestPlaypause ),
   283         ENTRY( "GstReliabilitytestRecording", CGStreamerTestClass::GstReliabilitytestRecording ),
   283         ENTRY( "GstReliabilitytestRecording", CGStreamerTestClass::GstReliabilitytestRecording ),
       
   284         ENTRY( "PlayBack", CGStreamerTestClass::PlayBack ),  
   284         };
   285         };
   285 
   286 
   286     const TInt count = sizeof( KFunctions ) / 
   287     const TInt count = sizeof( KFunctions ) / 
   287                         sizeof( TStifFunctionInfo );
   288                         sizeof( TStifFunctionInfo );
   288 
   289 
   590     //iObjects->fp = freopen("e:\\out.txt","w",stderr); 
   591     //iObjects->fp = freopen("e:\\out.txt","w",stderr); 
   591 
   592 
   592     iLog->Log(_L("<<CGStreamerTestClass::InitGStreamer"));
   593     iLog->Log(_L("<<CGStreamerTestClass::InitGStreamer"));
   593     return KErrNone;
   594     return KErrNone;
   594     }
   595     }
       
   596 
       
   597 /*** block b  from ../../../docs/manual/highlevel-components.xml ***/
       
   598 static gboolean
       
   599 my_bus_callback (GstBus     *bus,
       
   600          GstMessage *message,
       
   601          gpointer    data)
       
   602 {
       
   603       
       
   604   GMainLoop *loop = ( GMainLoop * )data;
       
   605 
       
   606   switch (GST_MESSAGE_TYPE (message)) {
       
   607     case GST_MESSAGE_ERROR: {
       
   608       GError *err;
       
   609       gchar *debug;
       
   610 
       
   611       gst_message_parse_error (message, &err, &debug);
       
   612       g_print ("Error: %s\n", err->message);
       
   613       g_error_free (err);
       
   614       g_free (debug);
       
   615 
       
   616       g_main_loop_quit (loop);
       
   617       break;
       
   618     }
       
   619     case GST_MESSAGE_EOS:
       
   620         
       
   621        /* end-of-stream */
       
   622       g_main_loop_quit (loop);
       
   623       break;
       
   624     default:
       
   625       /* unhandled message */
       
   626       break;
       
   627   }
       
   628 
       
   629   /* remove message from the queue */
       
   630   return TRUE;
       
   631 }
       
   632 
       
   633 /*** block c  from ../../../docs/manual/highlevel-components.xml ***/
       
   634 GstElement *pipeline;
       
   635 GstPad* devsoundsinkpad = NULL;
       
   636 
       
   637 static void
       
   638 cb_newpad (GstElement *decodebin,
       
   639        GstPad     *pad,
       
   640        gboolean    last,
       
   641        gpointer    data)
       
   642 {
       
   643     GstCaps *caps;
       
   644       GstStructure *str;
       
   645       GstPadLinkReturn linkret= GST_PAD_LINK_OK ;
       
   646 
       
   647       /* check media type */
       
   648       caps = gst_pad_get_caps (pad);
       
   649       str = gst_caps_get_structure (caps, 0);
       
   650       if (!g_strrstr (gst_structure_get_name (str), "audio")) {
       
   651         gst_caps_unref (caps);
       
   652         return;
       
   653       }
       
   654       gst_caps_unref (caps);
       
   655 
       
   656       /* link'n'play */
       
   657       linkret = gst_pad_link (pad, devsoundsinkpad);
       
   658 }
       
   659 
       
   660 
       
   661 gboolean  cb_autoplug( GstBin * *bin,
       
   662                         GstPad        *pad,
       
   663                         GstCaps       *caps,
       
   664                         gpointer       user_data)
       
   665 {
       
   666     
       
   667     GstCaps* sinkcaps = NULL;    
       
   668     gboolean supported = FALSE; 
       
   669     
       
   670     sinkcaps = gst_pad_get_caps( devsoundsinkpad );
       
   671         
       
   672     supported = gst_caps_is_subset( caps, sinkcaps );
       
   673     
       
   674     if( supported )
       
   675     {
       
   676       return FALSE;
       
   677     }
       
   678    
       
   679     return TRUE;
       
   680 
       
   681 }
       
   682 
       
   683 
       
   684 
       
   685 TInt CGStreamerTestClass::PlayBack( CStifItemParser& aItem )
       
   686 {
       
   687       GMainLoop *loop;
       
   688       GstElement *src, *dec, *sink;
       
   689       GstBus *bus;            
       
   690       
       
   691       FTRACE(FPrint(_L("CGStreamerTestClass::PlayBack")));     
       
   692       
       
   693       iLog->Log(_L(">>filesrc creation "));
       
   694 
       
   695       src = gst_element_factory_make ("filesrc", "source");
       
   696       
       
   697       iLog->Log(_L("<<filesrc creation "));
       
   698       
       
   699       TPtrC location;
       
   700       TFileName filename;
       
   701       
       
   702       char carray[1024];
       
   703       aItem.GetNextString(location);
       
   704       filename.Copy(location);
       
   705       wcstombs(carray, (const wchar_t *)filename.PtrZ(), 1024);
       
   706                       
       
   707       g_object_set (G_OBJECT (src), "location", carray, NULL);
       
   708       
       
   709      // gst_bin_add_many(GST_BIN (iObjects->iPipeline),src, NULL);
       
   710       
       
   711       iLog->Log(_L(">>decodebin2 creation "));
       
   712       dec = gst_element_factory_make ("decodebin2", "decoder");
       
   713       iLog->Log(_L("<<decodebin2 creation "));       
       
   714 
       
   715       /* create audio output */     
       
   716       sink = gst_element_factory_make ("devsoundsink", "sink");
       
   717             
       
   718       gst_bin_add_many (GST_BIN (iObjects->iPipeline), src, dec, sink, NULL);
       
   719       
       
   720       devsoundsinkpad = gst_element_get_pad( sink, "sink");          
       
   721       
       
   722       g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL);
       
   723       g_signal_connect (dec, "autoplug-continue", G_CALLBACK (cb_autoplug), NULL);
       
   724       
       
   725       gst_element_link (src, dec);        
       
   726            
       
   727       iLog->Log(_L("<<Setting pipeline to Play"));
       
   728             
       
   729       return KErrNone;   
       
   730     
       
   731 }
   595 
   732 
   596 // -----------------------------------------------------------------------------
   733 // -----------------------------------------------------------------------------
   597 // CGStreamerTestClass::CreatePipeLine
   734 // CGStreamerTestClass::CreatePipeLine
   598 // Create Pipeline
   735 // Create Pipeline
   599 // -----------------------------------------------------------------------------
   736 // -----------------------------------------------------------------------------