Compile an Mp3 player based on GStreamer and an mp3 player based on gstreamer

Source: Internet
Author: User
Tags gstreamer

Compile an Mp3 player based on GStreamer and an mp3 player based on gstreamer

I. Introduction

The author's system is CentOS6. Based on this, this article develops Mp3 players and uses the mp3 decoding library libmad and gstreamer0.10-plugins-uugly. The detailed steps are as follows.

 

Ii. Procedure

1) download

wget ftp://ftp.pbone.net/mirror/atrpms.net/el5-x86_64/atrpms/stable/libmad0-0.15.1b-4.el5.x86_64.rpmwget ftp://ftp.pbone.net/mirror/atrpms.net/el5-x86_64/atrpms/stable/libmad-0.15.1b-4.el5.x86_64.rpmwget ftp://195.220.108.108/linux/centos/6.7/os/x86_64/Packages/libid3tag-0.15.1b-11.el6.x86_64.rpmwget ftp://ftp.pbone.net/mirror/atrpms.net/el6-x86_64/atrpms/stable/libdvdread3-0.9.7-5.el6.x86_64.rpmwget ftp://195.220.108.108/linux/Mandriva/official/2007.0/x86_64/media/main/release/gstreamer0.10-plugins-ugly-0.10.4-1mdv2007.0.x86_64.rpm

2) Installation

yum install gstreamer-devel
rpm -ivh libmad0-0.15.1b-4.el5.x86_64.rpm libmad-0.15.1b-4.el5.x86_64.rpmrpm -ivh libid3tag-0.15.1b-11.el6.x86_64.rpm libdvdread3-0.9.7-5.el6.x86_64.rpm rpm -ivh gstreamer0.10-plugins-ugly-0.10.4-1mdv2007.0.x86_64.rpm

 

Iii. Source Code

/**
 * http://files.cnblogs.com/files/274914765qq/mp3.zip
 */
 
# Include <gst/gst. h> # include <glib. h> // message processing function static gboolean bus_call (maid * bus, stststmessage * msg, gpointer data) {GMainLoop * loop = (GMainLoop *) data; switch (maid (msg )) {case stst_message_eos: g_print ("End of stream \ n"); g_main_loop_quit (loop); break; case stst_message_error: {gchar * debug; GError * error; maid (msg, & error, & debug); g_free (debug); g_printerr ("ERR OR: % 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; ststelement * pipeline, * source, * decoder, * sink; // defines the component GstBus * bus; stst_init (& argc, & argv); loop = g_main_loop_new (NULL, FALSE); // create a main loop. After g_main_loop_run is executed, the cycle if (argc! = 2) {g_printerr ("Usage: % s \ n", argv [0]); return-1 ;} // create a pipeline and component pipeline = maid ("audio-player"); source = maid ("filesrc", "file-source"); decoder = maid ("mad ", "mad-decoder"); sink = maid ("autoaudiosink", "audio-output"); if (! Pipeline |! Source |! Decoder |! Sink) {g_printerr ("One element cocould not be created. exiting. \ n "); return-1 ;}// set the location parameter of source, that is, the file address g_object_set (G_OBJECT (source)," location ", argv [1], NULL ); // obtain the pipe's message bus = maid (pipeline); // Add the message monitor maid (bus, bus_call, loop ); // Add the component to the MPs queue. A pipe is a special component that can make data flow more easily. It can be used to connect the components ststst_bin_add_eline (ststst_bin (pipeline), source, decoder, sink, NULL). // connect the components ststst_element_link_der (source, sink, NULL); // start playing ststst_element_set_state (pipeline, stst_state_playing); g_print ("Running \ n"); // start loop g_main_loop_run (loop); g_print ("Returned, stopping playback \ n "); maid (pipeline, stst_state_null); maid (pipeline); return 0 ;}

Compile

gcc -Wall -g -o mp3 mp3.c `pkg-config --cflags --libs gstreamer-0.10`

Run

./mp3 xxx.mp3

 

Reference: http://blog.chinaunix.net/uid-25885064-id-3450774.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.