/* * Initial main.c file generated by Glade. Edit as required. * Glade will not overwrite this file. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "interface.h" #include "support.h" #include "codecs.h" extern gboolean _gst_plugin_spew; gboolean idle_func(gpointer data); GstElement *show; GstElement *src; GstPipeline *pipeline; void eof(GstSrc *src) { g_print("have eos, quitting\n"); exit(0); } void have_type(GstSink *sink) { gint type; GstType *gsttype; GstElement *parse = NULL; type = gst_util_get_int_arg(GTK_OBJECT(sink),"type"); gsttype = gst_type_find_by_id(type); g_print("have type %d:%s\n", type, gsttype->mime); gst_bin_remove(GST_BIN(pipeline), GST_ELEMENT(sink)); gst_pad_disconnect(gst_element_get_pad(src,"src"), gst_element_get_pad(GST_ELEMENT(sink),"sink")); if (strstr(gsttype->mime, "mpeg-system")) { parse = gst_elementfactory_make("mpeg1parse","parse"); gtk_signal_connect(GTK_OBJECT(parse),"new_pad", GTK_SIGNAL_FUNC(mpeg1_new_pad_created),pipeline); } else if (strstr(gsttype->mime, "avi")) { parse = gst_elementfactory_make("parseavi","parse"); gtk_signal_connect(GTK_OBJECT(parse),"new_pad", GTK_SIGNAL_FUNC(avi_new_pad_created),pipeline); } else if (strstr(gsttype->mime, "mpeg1")) { mpeg1_setup_video_thread(gst_element_get_pad(src,"src"), show, pipeline); } else { g_print("unknown media type\n"); exit(0); } if (parse) { gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse)); gst_pad_connect(gst_element_get_pad(src,"src"), gst_element_get_pad(parse,"sink")); } gtk_object_set(GTK_OBJECT(src),"offset",0,NULL); } int main (int argc, char *argv[]) { GtkWidget *window1; GstElement *typefind; bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); textdomain (PACKAGE); gnome_init ("gstreamer", VERSION, argc, argv); gst_init(&argc,&argv); gst_plugin_load("mpeg1parse"); gst_plugin_load("mp1videoparse"); gst_plugin_load("mp3parse"); gst_plugin_load("parsewav"); gst_plugin_load("parseavi"); gst_plugin_load("videosink"); show = gst_elementfactory_make("videosink","show"); g_return_val_if_fail(show != NULL, -1); window1 = create_window1 (gst_util_get_widget_arg(GTK_OBJECT(show),"widget")); gtk_widget_show (window1); pipeline = gst_pipeline_new("pipeline"); g_return_val_if_fail(pipeline != NULL, -1); src = gst_elementfactory_make("disksrc","src"); g_return_val_if_fail(src != NULL, -1); gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL); g_print("should be using file '%s'\n",argv[1]); typefind = gst_elementfactory_make("typefind","typefind"); g_return_val_if_fail(typefind != NULL, -1); gtk_signal_connect(GTK_OBJECT(typefind),"have_type", GTK_SIGNAL_FUNC(have_type),NULL); gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src)); gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(typefind)); 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(typefind,"sink")); g_print("setting to RUNNING state\n"); gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING); /* * The following code was added by Glade to create one of each component * (except popup menus), just so that you see something after building * the project. Delete any components that you don't want shown initially. */ while (1) { gst_src_push(GST_SRC(src)); } return 0; }