gstreamer_core/tsrc/examples/helloworld/src/helloworld.c
branchRCL_3
changeset 30 7e817e7e631c
parent 29 567bb019e3e3
equal deleted inserted replaced
29:567bb019e3e3 30:7e817e7e631c
     9 #define LOG_FILENAME_LINE __FILE__, __LINE__
     9 #define LOG_FILENAME_LINE __FILE__, __LINE__
    10 
    10 
    11 
    11 
    12 void create_xml(int result)
    12 void create_xml(int result)
    13 {
    13 {
    14 
       
    15     if(result)
    14     if(result)
    16     {
       
    17         assert_failed = 1;
    15         assert_failed = 1;
    18     } 
    16     
    19 
       
    20     testResultXml(xmlfile);
    17     testResultXml(xmlfile);
    21     close_log_file();
    18     close_log_file();
    22 
       
    23     if(result)
       
    24     {
       
    25         exit (-1);
       
    26     }    
       
    27 
       
    28 }
    19 }
    29 
    20 
    30 static void
    21 static void
    31 event_loop (GstElement * pipe)
    22 event_loop (GstElement * pipe)
    32 {
    23 {
    83   /* create a new bin to hold the elements */
    74   /* create a new bin to hold the elements */
    84   bin = gst_pipeline_new ("pipeline");
    75   bin = gst_pipeline_new ("pipeline");
    85   g_assert (bin);
    76   g_assert (bin);
    86 
    77 
    87   /* create a disk reader */
    78   /* create a disk reader */
    88   filesrc = gst_element_factory_make (/*"filesrc"*/"audiotestsrc", "disk_source");
    79   filesrc = gst_element_factory_make ("filesrc", "disk_source");
    89   g_assert (filesrc);
    80   g_assert (filesrc);
    90   g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
    81   g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
    91 
    82 
    92   /* now it's time to get the decoder */
    83   /* now it's time to get the decoder */
    93   //decoder = gst_element_factory_make ("mad", "decode");
    84   decoder = gst_element_factory_make ("mad", "decode");
    94 //  if (!decoder) {
    85   if (!decoder) {
    95 //    std_log(LOG_FILENAME_LINE, "could not find plugin mad");
    86     std_log(LOG_FILENAME_LINE, "could not find plugin mad");
    96 //    g_print ("could not find plugin \"mad\"");
    87     g_print ("could not find plugin \"mad\"");
    97 //    return -1;
    88     return -1;
    98 //  }
    89   }
    99 
    90 
   100   /* also, we need to add some converters to make sure the audio stream
    91   /* also, we need to add some converters to make sure the audio stream
   101    * from the decoder is converted into a format the audio sink can
    92    * from the decoder is converted into a format the audio sink can
   102    * understand (if necessary) */
    93    * understand (if necessary) */
   103 //  conv = gst_element_factory_make ("audioconvert", "audioconvert");
    94   conv = gst_element_factory_make ("audioconvert", "audioconvert");
   104 //  if (!conv) {
    95   if (!conv) {
   105 //    std_log(LOG_FILENAME_LINE, "could not create \"audioconvert\" element!");
    96     std_log(LOG_FILENAME_LINE, "could not create \"audioconvert\" element!");
   106 //    g_print ("could not create \"audioconvert\" element!");
    97     g_print ("could not create \"audioconvert\" element!");
   107 //    return -1;
    98     return -1;
   108 //  }
    99   }
   109 //  resample = gst_element_factory_make ("audioresample", "audioresample");
   100   resample = gst_element_factory_make ("audioresample", "audioresample");
   110 //  if (!conv) {
   101   if (!conv) {
   111 //    std_log(LOG_FILENAME_LINE, "could not create \"audioresample\" element!");
   102     std_log(LOG_FILENAME_LINE, "could not create \"audioresample\" element!");
   112 //    g_print ("could not create \"audioresample\" element!");
   103     g_print ("could not create \"audioresample\" element!");
   113 //    return -1;
   104     return -1;
   114 //  }
   105   }
   115 
   106 
   116   /* and an audio sink */
   107   /* and an audio sink */
   117   audiosink = gst_element_factory_make ("devsoundsink", "play_audio");
   108   audiosink = gst_element_factory_make ("devsoundsink", "play_audio");
   118   g_assert (audiosink);
   109   g_assert (audiosink);
   119 
   110 
   120   /* add objects to the main pipeline */
   111   /* add objects to the main pipeline */
   121   gst_bin_add_many (GST_BIN (bin), filesrc/*, decoder, conv,
   112   gst_bin_add_many (GST_BIN (bin), filesrc, decoder, conv,
   122       resample*/, audiosink, NULL);
   113       resample, audiosink, NULL);
   123 
   114 
   124   /* link the elements */
   115   /* link the elements */
   125   gst_element_link_many (filesrc, /*decoder, conv, resample,*/ audiosink, NULL);
   116   gst_element_link_many (filesrc, decoder, conv, resample, audiosink, NULL);
   126 
   117 
   127   /* start playing */
   118   /* start playing */
   128   std_log(LOG_FILENAME_LINE, "START PLAYING");
   119   std_log(LOG_FILENAME_LINE, "START PLAYING");
   129   gst_element_set_state (bin, GST_STATE_PLAYING);
   120   gst_element_set_state (bin, GST_STATE_PLAYING);
   130   std_log(LOG_FILENAME_LINE, "STOP PLAYING ");
   121   std_log(LOG_FILENAME_LINE, "STOP PLAYING ");