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