Created
July 25, 2013 07:33
-
-
Save yujuwon/6077577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <gst/gst.h> | |
| static void cb_new_pad (GstElement *element, GstPad *pad, gpointer data) | |
| { | |
| gchar *name; | |
| name = gst_pad_get_name (pad); | |
| g_print ("A new pad %s was created\n", name); | |
| g_free (name); | |
| /* here, you would setup a new pad link for the newly created pad */ | |
| [..] | |
| } | |
| int main (int argc, char *argv[]) | |
| { | |
| GstElement *pipeline, *source, *demux; | |
| GMainLoop *loop; | |
| /* init */ | |
| gst_init (&argc, &argv); | |
| /* create elements */ | |
| pipeline = gst_pipeline_new ("my_pipeline"); | |
| source = gst_element_factory_make ("filesrc", "source"); | |
| g_object_set (source, "location", argv[1], NULL); | |
| demux = gst_element_factory_make ("oggdemux", "demuxer"); | |
| /* you would normally check that the elements were created properly */ | |
| /* put together a pipeline */ | |
| gst_bin_add_many (GST_BIN (pipeline), source, demux, NULL); | |
| gst_element_link_pads (source, "src", demux, "sink"); | |
| /* listen for newly created pads */ | |
| g_signal_connect (demux, "pad-added", G_CALLBACK (cb_new_pad), NULL); | |
| /* start the pipeline */ | |
| gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING); | |
| loop = g_main_loop_new (NULL, FALSE); | |
| g_main_loop_run (loop); | |
| [..] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment