leo_sobral@2: #include leo_sobral@2: leo_sobral@2: static gboolean leo_sobral@2: bus_call (GstBus *bus, leo_sobral@2: GstMessage *msg, leo_sobral@2: gpointer data) leo_sobral@2: { leo_sobral@2: GMainLoop *loop = data; leo_sobral@2: leo_sobral@2: switch (GST_MESSAGE_TYPE (msg)) { leo_sobral@2: case GST_MESSAGE_EOS: leo_sobral@2: g_print ("End-of-stream\n"); leo_sobral@2: g_main_loop_quit (loop); leo_sobral@2: break; leo_sobral@2: case GST_MESSAGE_ERROR: { leo_sobral@2: gchar *debug; leo_sobral@2: GError *err; leo_sobral@2: leo_sobral@2: gst_message_parse_error (msg, &err, &debug); leo_sobral@2: g_free (debug); leo_sobral@2: leo_sobral@2: g_print ("Error: %s\n", err->message); leo_sobral@2: g_error_free (err); leo_sobral@2: leo_sobral@2: g_main_loop_quit (loop); leo_sobral@2: break; leo_sobral@2: } leo_sobral@2: default: leo_sobral@2: break; leo_sobral@2: } leo_sobral@2: leo_sobral@2: return TRUE; leo_sobral@2: } leo_sobral@2: leo_sobral@2: gint leo_sobral@2: main (gint argc, leo_sobral@2: gchar *argv[]) leo_sobral@2: { leo_sobral@2: GstElement *pipeline, *filesrc, *decoder, *filter, *sink; leo_sobral@2: GMainLoop *loop; leo_sobral@2: leo_sobral@2: /* initialization */ leo_sobral@2: gst_init (&argc, &argv); leo_sobral@2: loop = g_main_loop_new (NULL, FALSE); leo_sobral@2: if (argc != 2) { leo_sobral@2: g_print ("Usage: %s \n", argv[0]); leo_sobral@2: return 01; leo_sobral@2: } leo_sobral@2: leo_sobral@2: /* create elements */ leo_sobral@2: pipeline = gst_pipeline_new ("mythtvsrc_pipeline"); leo_sobral@2: gst_bus_add_watch (gst_pipeline_get_bus (GST_PIPELINE (pipeline)), leo_sobral@2: bus_call, loop); leo_sobral@2: leo_sobral@2: filesrc = gst_element_factory_make ("mythtvsrc", "mythtvsrc"); leo_sobral@2: decoder = gst_element_factory_make ("mad", "my_decoder"); leo_sobral@2: filter = gst_element_factory_make ("my_filter", "my_filter"); leo_sobral@2: sink = gst_element_factory_make ("osssink", "audiosink"); leo_sobral@2: if (!sink || !decoder) { leo_sobral@2: g_print ("Decoder or output could not be found - check your install\n"); leo_sobral@2: return -1; leo_sobral@2: } else if (!filter) { leo_sobral@2: g_print ("Your self-written filter could not be found. Make sure it " leo_sobral@2: "is installed correctly in $(libdir)/gstreamer-0.9/ and that " leo_sobral@2: "you've ran gst-register-0.9 to register it. Check availability " leo_sobral@2: "of the plugin afterwards using \"gst-inspect-0.9 my_filter\""); leo_sobral@2: return -1; leo_sobral@2: } leo_sobral@2: leo_sobral@2: g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); leo_sobral@2: leo_sobral@2: /* link everything together */ leo_sobral@2: gst_element_link_many (filesrc, decoder, filter, sink, NULL); leo_sobral@2: gst_bin_add_many (GST_BIN (pipeline), filesrc, decoder, filter, sink, NULL); leo_sobral@2: leo_sobral@2: /* run */ leo_sobral@2: gst_element_set_state (pipeline, GST_STATE_PLAYING); leo_sobral@2: g_main_loop_run (loop); leo_sobral@2: leo_sobral@2: /* clean up */ leo_sobral@2: gst_element_set_state (pipeline, GST_STATE_NULL); leo_sobral@2: gst_object_unref (GST_OBJECT (pipeline)); leo_sobral@2: leo_sobral@2: return 0; leo_sobral@2: }