2001-02-27 22:27:38 +00:00
|
|
|
#include <gnome.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
GstElement *parse2, *queue;
|
|
|
|
GtkWidget *appwindow;
|
|
|
|
|
|
|
|
void eof(GstElement *src) {
|
|
|
|
g_print("have eos, quitting\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean idle_func(gpointer data) {
|
|
|
|
gst_bin_iterate(GST_BIN(data));
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
void mpegdemux_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
2001-02-27 22:27:38 +00:00
|
|
|
|
2001-10-17 10:21:27 +00:00
|
|
|
g_print("***** a new pad %s was created %p\n", gst_pad_get_name(pad), pipeline);
|
2001-02-27 22:27:38 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
|
|
|
|
|
|
|
|
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
|
|
|
|
|
|
|
gst_pad_connect(pad, gst_element_get_pad(queue,"sink"));
|
|
|
|
}
|
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[]) {
|
|
|
|
GstPipeline *pipeline;
|
|
|
|
GstElement *src, *parse;
|
2001-04-12 18:11:19 +00:00
|
|
|
GstElement *decode, *show, *thread, *color;
|
2001-04-02 14:21:08 +00:00
|
|
|
GtkWidget *gtk_socket;
|
2001-02-27 22:27:38 +00:00
|
|
|
|
|
|
|
g_print("have %d args\n",argc);
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
|
|
|
|
//gst_plugin_load("mpeg1parse");
|
|
|
|
|
|
|
|
pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
|
|
|
|
g_return_val_if_fail(pipeline != NULL, -1);
|
|
|
|
thread = GST_ELEMENT(gst_thread_new("thread"));
|
|
|
|
g_return_val_if_fail(thread != NULL, -1);
|
|
|
|
|
|
|
|
if (strstr(argv[1],"video_ts")) {
|
|
|
|
src = gst_elementfactory_make("dvdsrc","src");
|
|
|
|
g_print("using DVD source\n");
|
|
|
|
} else
|
|
|
|
src = gst_elementfactory_make("disksrc","src");
|
|
|
|
|
|
|
|
g_return_val_if_fail(src != NULL, -1);
|
|
|
|
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
|
|
|
|
if (argc >= 3) {
|
|
|
|
gtk_object_set(GTK_OBJECT(src),"bytesperread",atoi(argv[2]),NULL);
|
|
|
|
g_print("block size is %d\n",atoi(argv[2]));
|
|
|
|
}
|
|
|
|
g_print("should be using file '%s'\n",argv[1]);
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
parse = gst_elementfactory_make("mpegdemux","parse");
|
2001-02-27 22:27:38 +00:00
|
|
|
//parse = gst_elementfactory_make("mpeg1parse","parse");
|
|
|
|
g_return_val_if_fail(parse != NULL, -1);
|
|
|
|
|
|
|
|
queue = gst_elementfactory_make("queue","queue");
|
2001-03-04 22:26:33 +00:00
|
|
|
g_return_val_if_fail(queue != NULL, -1);
|
2001-02-27 22:27:38 +00:00
|
|
|
|
|
|
|
/****
|
|
|
|
* you can substitute mpeg2play with you own player here
|
2001-03-04 22:26:33 +00:00
|
|
|
* optionally you can remove the parse2 element. make
|
2001-02-27 22:27:38 +00:00
|
|
|
* sure to remove the pad connections too and don't add the
|
|
|
|
* mp2videoparse element to the bin.
|
|
|
|
**/
|
2001-02-27 22:43:12 +00:00
|
|
|
//parse2 = gst_elementfactory_make("mp2videoparse","parse");
|
2001-03-04 22:26:33 +00:00
|
|
|
//g_return_val_if_fail(parse2 != NULL, -1);
|
2001-02-27 22:43:12 +00:00
|
|
|
decode = gst_elementfactory_make("mpeg2dec","decode_video");
|
2001-03-04 22:26:33 +00:00
|
|
|
g_return_val_if_fail(decode != NULL, -1);
|
2001-02-27 22:27:38 +00:00
|
|
|
|
2001-04-12 18:11:19 +00:00
|
|
|
color = gst_elementfactory_make("colorspace","color");
|
|
|
|
g_return_val_if_fail(color != NULL, -1);
|
|
|
|
|
2001-04-02 14:21:08 +00:00
|
|
|
show = gst_elementfactory_make("xvideosink","show");
|
2001-02-27 22:43:12 +00:00
|
|
|
//gtk_object_set(GTK_OBJECT(show),"xv_enabled",FALSE,NULL);
|
2001-03-04 22:26:33 +00:00
|
|
|
g_return_val_if_fail(show != NULL, -1);
|
2001-02-27 22:27:38 +00:00
|
|
|
|
|
|
|
appwindow = gnome_app_new("MPEG player","MPEG player");
|
2001-04-02 14:21:08 +00:00
|
|
|
|
|
|
|
gtk_socket = gtk_socket_new ();
|
|
|
|
gtk_widget_show (gtk_socket);
|
2001-05-25 21:00:07 +00:00
|
|
|
gtk_widget_set_usize(gtk_socket,320,240);
|
2001-04-02 14:21:08 +00:00
|
|
|
|
2001-02-27 22:27:38 +00:00
|
|
|
gnome_app_set_contents(GNOME_APP(appwindow),
|
2001-04-02 14:21:08 +00:00
|
|
|
GTK_WIDGET(gtk_socket));
|
|
|
|
|
|
|
|
gtk_widget_realize (gtk_socket);
|
|
|
|
gtk_socket_steal (GTK_SOCKET (gtk_socket),
|
|
|
|
gst_util_get_int_arg (GTK_OBJECT(show), "xid"));
|
2001-02-27 22:27:38 +00:00
|
|
|
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(queue));
|
|
|
|
|
2001-02-27 22:43:12 +00:00
|
|
|
//gst_bin_add(GST_BIN(thread),GST_ELEMENT(parse2));
|
2001-02-27 22:27:38 +00:00
|
|
|
gst_bin_add(GST_BIN(thread),GST_ELEMENT(decode));
|
2001-04-12 18:11:19 +00:00
|
|
|
gst_bin_add(GST_BIN(thread),GST_ELEMENT(color));
|
2001-02-27 22:27:38 +00:00
|
|
|
gst_bin_add(GST_BIN(thread),GST_ELEMENT(show));
|
|
|
|
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(thread));
|
|
|
|
|
2001-12-04 22:12:50 +00:00
|
|
|
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpegdemux_newpad, pipeline);
|
2001-02-27 22:27:38 +00:00
|
|
|
|
|
|
|
gtk_signal_connect(GTK_OBJECT(src),"eos",GTK_SIGNAL_FUNC(eof),NULL);
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(src,"src"),
|
|
|
|
gst_element_get_pad(parse,"sink"));
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(queue,"src"),
|
2001-02-27 22:43:12 +00:00
|
|
|
// gst_element_get_pad(parse2,"sink"));
|
|
|
|
//gst_pad_connect(gst_element_get_pad(parse2,"src"),
|
2001-02-27 22:27:38 +00:00
|
|
|
gst_element_get_pad(decode,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
2001-04-12 18:11:19 +00:00
|
|
|
gst_element_get_pad(color,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(color,"src"),
|
2001-02-27 22:27:38 +00:00
|
|
|
gst_element_get_pad(show,"sink"));
|
|
|
|
|
2001-04-02 14:21:08 +00:00
|
|
|
gtk_widget_show_all(appwindow);
|
|
|
|
|
2001-02-27 22:27:38 +00:00
|
|
|
g_print("setting to PLAYING state\n");
|
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
gtk_idle_add(idle_func,pipeline);
|
|
|
|
|
|
|
|
gdk_threads_enter();
|
|
|
|
gtk_main();
|
|
|
|
gdk_threads_leave();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|