7 extern gboolean _gst_plugin_spew;
10 static gchar *desired_stream;
12 void mpeg2parse_write_ac3(GstPad *pad,GstBuffer *buf) {
14 // g_print("MPEG2PARSE: got AC3 buffer of size %d\n",GST_BUFFER_SIZE(buf));
15 write(ac3fd,GST_BUFFER_DATA(buf),GST_BUFFER_SIZE(buf));
16 gst_buffer_unref(buf);
19 void mpeg2parse_info_chain(GstPad *pad,GstBuffer *buf) {
20 // g_print("MPEG2PARSE: got buffer of size %d\n",GST_BUFFER_SIZE(buf));
21 gst_buffer_unref(buf);
24 void mpeg2parse_newpad(GstElement *parser,GstPad *pad) {
27 g_print("MPEG2PARSE: have new pad \"%s\" from parser\n",
28 gst_pad_get_name(pad));
30 infopad = gst_pad_new("sink",GST_PAD_SINK);
31 if (strcmp(gst_pad_get_name(pad),desired_stream) == 0)
32 gst_pad_set_chain_function(infopad,mpeg2parse_write_ac3);
34 gst_pad_set_chain_function(infopad,mpeg2parse_info_chain);
35 gst_pad_connect(pad,infopad);
38 int main(int argc,char *argv[]) {
39 GstPipeline *pipeline;
40 GstElement *src, *parse, *out;
44 g_print("have %d args\n",argc);
46 _gst_plugin_spew = TRUE;
47 gst_init(&argc,&argv);
48 // gst_plugin_load("mpeg2parse");
49 gst_plugin_load_all();
51 ac3fd = creat("output.ac3",S_IREAD|S_IWRITE);
53 pipeline = gst_pipeline_new("pipeline");
54 g_return_if_fail(pipeline != NULL);
56 if (strstr(argv[1],"video_ts")) {
57 src = gst_elementfactory_make("dvdsrc","src");
58 g_print("using DVD source\n");
60 src = gst_elementfactory_make("disksrc","src");
61 g_return_if_fail(src != NULL);
62 gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
64 gtk_object_set(GTK_OBJECT(src),"bytesperread",atoi(argv[2]),NULL);
65 g_print("block size is %d\n",atoi(argv[2]));
67 g_print("should be using file '%s'\n",argv[1]);
69 parse = gst_elementfactory_make("mpeg2parse","parse");
70 g_return_if_fail(parse != NULL);
72 gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpeg2parse_newpad,NULL);
74 gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
75 gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
77 gst_pad_connect(gst_element_get_pad(src,"src"),
78 gst_element_get_pad(parse,"sink"));
80 g_print("setting to RUNNING state\n");
81 gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
83 if (argc >= 4) c = atoi(argv[3]);
85 g_print("c is %d\n",c);
87 if (argc >= 5) desired_stream = argv[4];
88 else desired_stream = "private_stream_1.0";
93 gst_src_push(GST_SRC(src));