2 #include "gstsplitmuxpartreader.h"
3 #include "gstsplitmuxsrc.h"
5 GST_DEBUG_CATEGORY_EXTERN (splitmux_debug);
7 static const gchar *const path = "out001.mp4";
9 typedef struct _CustomData
11 GstSplitMuxPartReader *reader;
17 part_prepared (GstSplitMuxPartReader * reader)
19 g_print ("Part prepared\n");
23 handle_message (GstBus * bus, GstMessage * msg, CustomData * data)
28 switch (GST_MESSAGE_TYPE (msg)) {
29 case GST_MESSAGE_ERROR:
30 gst_message_parse_error (msg, &err, &debug_info);
31 g_print ("Error received from element %s: %s\n",
32 GST_OBJECT_NAME (msg->src), err->message);
33 g_print ("Debugging information: %s\n", debug_info ? debug_info : "none");
36 g_main_loop_quit (data->main_loop);
39 g_print ("End-Of-Stream reached.\n");
40 g_main_loop_quit (data->main_loop);
50 start_reader (CustomData * data)
52 g_print ("Preparing part reader for %s\n", path);
53 gst_splitmux_part_reader_prepare (data->reader);
58 handle_get_pad (GstSplitMuxPartReader * reader, GstPad * src_pad,
61 /* Create a dummy target pad for the reader */
62 GstPad *new_pad = g_object_new (SPLITMUX_TYPE_SRC_PAD,
63 "name", GST_PAD_NAME (src_pad), "direction", GST_PAD_SRC, NULL);
65 g_print ("Creating new dummy pad %s\n", GST_PAD_NAME (src_pad));
71 main (int argc, char **argv)
75 gst_init (&argc, &argv);
77 data.main_loop = g_main_loop_new (NULL, FALSE);
79 data.reader = g_object_new (GST_TYPE_SPLITMUX_PART_READER, NULL);
80 data.bus = gst_element_get_bus (GST_ELEMENT_CAST (data.reader));
82 /* Listen for bus messages */
83 gst_bus_add_watch (data.bus, (GstBusFunc) handle_message, &data);
85 gst_splitmux_part_reader_set_location (data.reader, path);
87 /* Connect to prepare signal */
88 g_signal_connect (data.reader, "prepared", (GCallback) part_prepared, &data);
89 gst_splitmux_part_reader_set_callbacks (data.reader, &data,
90 (GstSplitMuxPartReaderPadCb) handle_get_pad);
92 g_idle_add ((GSourceFunc) start_reader, &data);
95 g_main_loop_run (data.main_loop);
97 gst_splitmux_part_reader_unprepare (data.reader);
99 g_main_loop_unref (data.main_loop);
100 gst_object_unref (data.bus);
101 g_object_unref (data.reader);