Redhat Linux View whether the GCC is installed

2023-01-08   ES  

1, gst_element_factory_find finds a factory object (Factory Object). For example, “MAD” is used for MP3 factory objects. The MAD factory we use here mainly uses the decoder element of MP3

2, then use gst_element_factory_create to get the Element object is a module used to implement certain functions. For example, Filesrc is used to read the Location file, play_audio is used to play music, Decoder is used for MP3 decoding and so on. The above two steps can be achieved with gst_element_factory_make (“Factory Name”, “Element name”).

3, PAD (pad) is a connection channel between elements and outside. You can obtain Element’s PAD through gst_element_get_pad ().

4, cabinet (BIN)

Box cabinet (BIN) is a container component in the GSTreamer framework, which is usually used to accommodate other component objects. The cabinets in GSTREAMER mainly have two types of GSTPIPIPELINE (pipe), GSThread (thread)

5, state (component status)

After the connection is completed, we can start the data stream processing by modifying BIN. Generally, there are several types: null (the initial state of the newly created), ready Playing (being processed).

code:

<span style = "font-family: kaiti_gb2312; font-size: 14px;"># Include <gst/gst.h> 
 #include <glib.h> 
 // Define the message processing function, 
 Static gboolean bus_call (GSTBUS *Bus, GSTMESSAGE *MSG, GPOINTER DATA) 
 {{ 
     GmainLoop *loop = (gmainloop *) data; // This is the pointer of the main cycle, quit the loop when receiving EOS messages 
     switch (gst_message_type (MSG)) 
     {{ 
         case gst_message_eos: 
             g_print ("end of stream \ n"); 
             g_main_loop_quit (loop); 
             Break; 
         case gst_message_error: 
         {{ 
                            GCHAR *Debug; 
                            Get *error; 

                            gst_message_parse_error (msg, & error, & debug); 
                            g_free (debug); 
                            g_printerr ("error:%s \ n", error-> message); 
                            g_error_free (error); 
                            g_main_loop_quit (loop); 
                            Break; 
         } 
         DEFAULT: 
              Break; 
     } 
     Return true; 
 } 

 int Main (int argc, char *argv []) 
 {{ 
     GmainLoop *loop; 
     Gstelement*pipeline,*source,*decoder,*sink; // Define components 
     Gstbus *bus; 

     gst_init (& argc, & argv); 
     loop = g_main_loop_new (null, false); // Create the main loop, officially start the loop after executing g_main_loop_run 

     if (ARGC! = 2) 
     {{ 
         g_printerr ("usage:%s <MP3 FILENAME> \ N", ARGV [0]); 
         Return -1; 
     } 
     // Create pipes and components 
     pipeline = gst_pipeline_new ("Audio-Player"); 
     Source = gst_element_factory_make ("Filesrc", "File-Source"); 
     decoder = gst_element_factory_make ("MAD", "Mad-Decoder"); 
     sink = gst_element_factory_make ("AutoAudiosink", "Audio-OUTPUT"); 

     if (! pipeline ||! Source ||! Decoder ||! Sink) { 
         g_printerr ("One Element Could Not Be Created.exiting. \ N"); 
         Return -1; 
     } 
     // Set the Location parameter of the source. That is the file address. 
     g_object_Set (g_object (source), "local", argv [1], null); 
     // get the message bus of the pipeline 
     bus = gst_pipeline_get_bus (gst_pipeline (pipeline)); 
    // Add message monitor 
     gst_bus_add_watch (bus, bus_call, loop); 
     gst_object_unref (bus); 
     // Add the component to the pipeline. Pipeline is a special component that can better allow data to flow 
     gst_bin_add_many (gst_bin (pipeline), source, decoder, sink, null); 
    // Connect the component in order 
    gst_element_link_many (source, decoder, sink, null); 
    //Start playing 
     gst_element_set_state (pipeline, gst_state_playing); 
     g_print ("running \ n"); 
     // Start the loop 
     g_main_loop_run (loop); 
     g_print ("Returnet, Stopping Playback \ N"); 
     gst_element_set_state (pipeline, gst_state_null); 
     gst_object_unref (gst_object (pipeline)); 
     Return 0; 
 } </span>

compilation:gcc -Wall -g musicplayer.c -o player $(pkg-config –cflags –libs gstreamer-1.0) 

execute: ./ player canon.mp3

Reference blog post address:

1、http://www.cnblogs.com/phinecos/archive/2009/06/07/1498166.html

2、http://www.ibm.com/developerworks/cn/linux/l-gstreamer/

source

Related Posts

Develop mobile application market -Dayone supplement

Android+Qualcomm MIPI to LVDS display debug — Based on SD65DSI84

Computer network (7th edition) -Chapter 5 Transportation Layer -Important Concept

POJ 2236 Wireless Network Geometry+Classification

Redhat Linux View whether the GCC is installed

Random Posts

Create uboot environment variable BIN file

date and time type

MVP (RXJAVA+RETROFIT+FRESCO+Recyclerview) Brother

Netty Implementing HTTP server

Deepfakes Super Evolution! Repeatedly changing the face and flowing water, there is no PS trace at all, Twitter 100,000 praises