From d04099240bf8867f4b16f332112bf206d303f3f5 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 14 Dec 2001 18:11:52 +0000 Subject: [PATCH] gst/gst.c (gst_main, gst_main_quit): upd. Original commit message from CVS: 2001-12-14 Michael Meeks * gst/gst.c (gst_main, gst_main_quit): upd. * gst/gstutils.c (gst_util_has_arg): impl. (gst_util_get_int64_arg): impl. * plugins/mpeg2/video/gstmpeg2play.c (gst_mpeg2play_class_init): min frames per sec = 0. * plugins/mikmod/gstmikmod.c (gst_mikmod_class_init): s/16bit/use16bit/ properties can't begin with a non alpha. * tools/gstreamer-guilaunch.c: fresh from the ministy of nasty hacks. * tools/Makefile.am: enable gstreamer-guilaunch for Gnome 2.0 * tools/gstreamer-launch.c (main): upd. (idle_func): quit the mainloop. --- ChangeLog | 23 ++++ gst/gst.c | 26 +++- gst/gstelement.c | 26 ++-- gst/gstutils.c | 49 ++++++++ gst/gstutils.h | 3 + gstplay/ChangeLog | 24 ++-- gstplay/Makefile.am | 3 +- gstplay/callbacks.c | 18 ++- gstplay/gstmediaplay.c | 2 + gstplay/gstmediaplay.glade2 | 21 ++-- gstplay/gstplay.c | 240 ++++++++++++++++-------------------- gstplay/gstplay.h | 7 +- gstplay/gstplayprivate.h | 31 +---- gstplay/main.c | 16 ++- tools/Makefile.am | 8 ++ tools/gstreamer-guilaunch.c | 16 ++- tools/gstreamer-launch.c | 14 +-- 17 files changed, 292 insertions(+), 235 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0e207386d..9d34c88118 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2001-12-14 Michael Meeks + + * gst/gst.c (gst_main, gst_main_quit): upd. + + * gst/gstutils.c (gst_util_has_arg): impl. + (gst_util_get_int64_arg): impl. + + * plugins/mpeg2/video/gstmpeg2play.c + (gst_mpeg2play_class_init): min frames per sec = 0. + + * plugins/mikmod/gstmikmod.c (gst_mikmod_class_init): + s/16bit/use16bit/ properties can't begin with a non + alpha. + + * tools/gstreamer-guilaunch.c: fresh from the ministy + of nasty hacks. + + * tools/Makefile.am: enable gstreamer-guilaunch for + Gnome 2.0 + + * tools/gstreamer-launch.c (main): upd. + (idle_func): quit the mainloop. + 2001-12-14 Michael Meeks * plugins/audiofile/gstafsrc.c (gst_afsrc_class_init): upd. diff --git a/gst/gst.c b/gst/gst.c index 6b47f66aa8..11c5ef8833 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -73,7 +73,8 @@ gst_init (int *argc, char **argv[]) GstTrace *gst_trace; #endif - if (!g_thread_supported ()) g_thread_init (NULL); + if (!g_thread_supported ()) + g_thread_init (NULL); #ifdef USE_GLIB2 g_type_init(); @@ -343,6 +344,10 @@ gst_init_check (int *argc, return ret; } +#ifdef USE_GLIB2 +static GSList *mainloops = NULL; +#endif + /** * gst_main: * @@ -351,7 +356,14 @@ gst_init_check (int *argc, void gst_main (void) { -#ifndef USE_GLIB2 +#ifdef USE_GLIB2 + GMainLoop *loop; + + loop = g_main_loop_new (NULL, FALSE); + mainloops = g_slist_prepend (mainloops, loop); + + g_main_loop_run (loop); +#else gtk_main (); #endif } @@ -364,7 +376,15 @@ gst_main (void) void gst_main_quit (void) { -#ifndef USE_GLIB2 +#ifdef USE_GLIB2 + if (!mainloops) + g_warning ("Quit more loops than there are"); + else { + GMainLoop *loop = mainloops->data; + mainloops = g_slist_delete_link (mainloops, mainloops); + g_main_loop_quit (loop); + } +#else gtk_main_quit (); #endif } diff --git a/gst/gstelement.c b/gst/gstelement.c index 0915058330..a27ee6b6b7 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1335,16 +1335,18 @@ gst_element_populate_std_props (GObjectClass * klass, if (prop_id == fd_id) { pspec = g_param_spec_int ("fd", "File-descriptor", - "File-descriptor for the file being read", 0, G_MAXINT, 0, flags); - + "File-descriptor for the file being read", + 0, G_MAXINT, 0, flags); } else if (prop_id == blocksize_id) { pspec = g_param_spec_ulong ("blocksize", "Block Size", - "Block size to read per buffer", 0, G_MAXULONG, 4096, flags); + "Block size to read per buffer", + 0, G_MAXULONG, 4096, flags); } else if (prop_id == bytesperread_id) { - pspec = g_param_spec_int ("bytesperread", "bytesperread", "bytesperread", + pspec = g_param_spec_int ("bytesperread", "bytesperread", + "bytesperread", G_MININT, G_MAXINT, 0, flags); } @@ -1354,7 +1356,8 @@ gst_element_populate_std_props (GObjectClass * klass, } else if (prop_id == filesize_id) { pspec = g_param_spec_int64 ("filesize", "File Size", - "Size of the file being read", 0, G_MAXINT64, 0, flags); + "Size of the file being read", + 0, G_MAXINT64, 0, flags); } else if (prop_id == mmapsize_id) { @@ -1365,21 +1368,25 @@ gst_element_populate_std_props (GObjectClass * klass, } else if (prop_id == location_id) { pspec = g_param_spec_string ("location", "File Location", - "Location of the file to read", NULL, flags); + "Location of the file to read", + NULL, flags); } else if (prop_id == offset_id) { pspec = g_param_spec_int64 ("offset", "File Offset", - "Byte offset of current read pointer", 0, G_MAXINT64, 0, flags); + "Byte offset of current read pointer", + 0, G_MAXINT64, 0, flags); } else if (prop_id == silent_id) { - pspec = g_param_spec_boolean ("silent", "silent", "silent", FALSE, flags); + pspec = g_param_spec_boolean ("silent", "silent", "silent", + FALSE, flags); } else if (prop_id == touch_id) { pspec = g_param_spec_boolean ("touch", "Touch read data", - "Touch data to force disk read before push ()", TRUE, flags); + "Touch data to force disk read before " + "push ()", TRUE, flags); } else { g_warning ("Unknown - 'standard' property '%s' id %d from klass %s", @@ -1426,3 +1433,4 @@ gst_element_install_std_props (GstElementClass * klass, const char *first_name, va_end (args); } + diff --git a/gst/gstutils.c b/gst/gstutils.c index 5e9c55f295..49ccd7b64c 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -93,6 +93,27 @@ gst_util_get_long_arg (GObject * object, const gchar * argname) return g_value_get_long (&value); } +/** + * gst_util_get_long_arg: + * @object: the object to query + * @argname: the name of the argument + * + * Retrieves a property of an object as a long. + * + * Returns: the property of the object + */ +gint64 +gst_util_get_int64_arg (GObject *object, const gchar *argname) +{ + GValue value; + + ZERO (value); + g_value_init (&value, G_TYPE_INT64); + g_object_get_property (G_OBJECT (object), argname, &value); + + return g_value_get_int64 (&value); +} + /** * gst_util_get_float_arg: * @object: the object to query @@ -568,3 +589,31 @@ gst_print_element_args (GString * buf, gint indent, GstElement * element) } g_free (property_specs); } + +/** + * gst_util_has_arg: + * @object: an object + * @argname: a property it might have + * @arg_type: the type of the argument it should have + * + * Determines whether this @object has a property of name + * @argname and of type @arg_type + * + * Return value: TRUE if it has the prop, else FALSE + **/ +gboolean +gst_util_has_arg (GObject *object, const gchar *argname, GType arg_type) +{ + GParamSpec *pspec; + + pspec = g_object_class_find_property ( + G_OBJECT_GET_CLASS (object), argname); + + if (!pspec) + return FALSE; + + if (pspec->value_type != arg_type) + return FALSE; + + return TRUE; +} diff --git a/gst/gstutils.h b/gst/gstutils.h index 6a71367e4e..0e854124d4 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -31,9 +31,12 @@ extern "C" { #endif /* __cplusplus */ +gboolean gst_util_has_arg (GObject *object, const gchar *argname, + GType arg_type); gint gst_util_get_int_arg (GObject *object, const gchar *argname); gboolean gst_util_get_bool_arg (GObject *object, const gchar *argname); glong gst_util_get_long_arg (GObject *object, const gchar *argname); +gint64 gst_util_get_int64_arg (GObject *object, const gchar *argname); gfloat gst_util_get_float_arg (GObject *object, const gchar *argname); gdouble gst_util_get_double_arg (GObject *object, const gchar *argname); const gchar* gst_util_get_string_arg (GObject *object, const gchar *argname); diff --git a/gstplay/ChangeLog b/gstplay/ChangeLog index c6907f1e27..64bfa967ea 100644 --- a/gstplay/ChangeLog +++ b/gstplay/ChangeLog @@ -1,23 +1,19 @@ -2001-12-14 Wim Taymans +2001-12-14 Michael Meeks - * (gst_play_set_uri): use filesrc again. + * gstplay.c (gst_play_set_uri): remove bogus + priv->offset_element set. -2001-12-13 Michael Meeks + * gstplayprivate.h: kill, move into - * gstplay.c (gst_play_object_introspect): copy and - port to GObject. - (gst_play_get_arg): use UINT for compat. - (gst_play_set_uri): use disksrc instead. + * gstplay.c: here & lots of cleanup. - * gststatusarea.c (gst_status_area_expose): needs - pangoizing, conditionaly build. + * gstplay.h: use an opaque typedef for GstPlayPrivate, + lots of ugly casts die. - * gstmediaplay.c (gst_media_play_init): upd. - (gst_media_play_show_playlist): + * main.c (main): use gtk_main; gst_main no longer hits + the GUI mainloop. - * gstplay.h (gst_glade_xml_new): add. - - * callbacks.c (on_preferences1_activate): glade hacks. + * gstmediaplay.c (gst_media_play_init): show the toplevel 2001-12-06 Arik Devens diff --git a/gstplay/Makefile.am b/gstplay/Makefile.am index e7b390ee0f..d576e31605 100644 --- a/gstplay/Makefile.am +++ b/gstplay/Makefile.am @@ -30,8 +30,7 @@ libgstmediaplayinclude_HEADERS = \ noinst_HEADERS = \ gstmediaplay.h \ gststatusarea.h \ - callbacks.h \ - gstplayprivate.h + callbacks.h libgstmediaplay_la_LDFLAGS = -rdynamic libgstmediaplay_la_CFLAGS = $(GNOME_CFLAGS) $(LIBGLADE_GNOME_CFLAGS) $(GST_CFLAGS) -DDATADIR=\""$(gladedir)/"\" diff --git a/gstplay/callbacks.c b/gstplay/callbacks.c index aa938c7936..e9d8f6a7ec 100644 --- a/gstplay/callbacks.c +++ b/gstplay/callbacks.c @@ -67,14 +67,18 @@ on_preferences1_activate (GtkMenuItem *menuitem, gpointer user_data) GladeXML *xml; struct stat statbuf; - if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) { + if (stat (DATADIR"gstmediaplay.glade", &statbuf) == 0) xml = gst_glade_xml_new (DATADIR"gstmediaplay.glade", "preferences"); - } else xml = gst_glade_xml_new ("gstmediaplay.glade", "preferences"); + + glade_xml_signal_autoconnect (xml); + + gtk_widget_show (glade_xml_get_widget (xml, "preferences")); } -void on_about_activate (GtkWidget *widget, gpointer data) +void +on_about_activate (GtkWidget *widget, gpointer data) { GladeXML *xml; struct stat statbuf; @@ -85,12 +89,14 @@ void on_about_activate (GtkWidget *widget, gpointer data) else xml = gst_glade_xml_new ("gstmediaplay.glade", "about"); - /* connect the signals in the interface */ glade_xml_signal_autoconnect (xml); + + gtk_widget_show (glade_xml_get_widget (xml, "about")); } -void on_gstplay_destroy (GtkWidget *widget, gpointer data) +void +on_gstplay_destroy (GtkWidget *widget, gpointer data) { - gst_main_quit(); + gtk_main_quit(); } diff --git a/gstplay/gstmediaplay.c b/gstplay/gstmediaplay.c index 9cd1dc29b0..1e0305183f 100644 --- a/gstplay/gstmediaplay.c +++ b/gstplay/gstmediaplay.c @@ -205,6 +205,8 @@ gst_media_play_init (GstMediaPlay *mplay) gtk_widget_show (GTK_WIDGET (mplay->play)); + gtk_widget_show (GTK_WIDGET (glade_xml_get_widget (mplay->xml, "gstplay"))); + mplay->status = (GstStatusArea *) glade_xml_get_widget (mplay->xml, "status_area"); gst_status_area_set_state (mplay->status, GST_STATUS_AREA_STATE_INIT); gst_status_area_set_playtime (mplay->status, "00:00 / 00:00"); diff --git a/gstplay/gstmediaplay.glade2 b/gstplay/gstmediaplay.glade2 index 9165556885..3e2bfb8402 100644 --- a/gstplay/gstmediaplay.glade2 +++ b/gstplay/gstmediaplay.glade2 @@ -14,7 +14,7 @@ gstmediaplay GstMediaPlay yes - yes + no GTK_WIN_POS_CENTER @@ -430,14 +430,6 @@ - - - - button1 - play.xpm - yes - - @@ -658,18 +650,20 @@ Arik Devens <arik@gnome.org> GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN yes - + yes - yes + 273,80 + GTK_SELECTION_SINGLE + yes + GTK_SHADOW_IN + 2 yes - CList:title track name GTK_JUSTIFY_CENTER no @@ -683,7 +677,6 @@ Arik Devens <arik@gnome.org> - CList:title track length GTK_JUSTIFY_CENTER no diff --git a/gstplay/gstplay.c b/gstplay/gstplay.c index 135d1e0a61..d63811c7de 100644 --- a/gstplay/gstplay.c +++ b/gstplay/gstplay.c @@ -7,7 +7,6 @@ #include #include "gstplay.h" -#include "gstplayprivate.h" static void gst_play_class_init (GstPlayClass *klass); static void gst_play_init (GstPlay *play); @@ -43,6 +42,28 @@ enum { static GtkObject *parent_class = NULL; static guint gst_play_signals[LAST_SIGNAL] = {0}; +struct _GstPlayPrivate { + GstElement *pipeline; + GstElement *video_element, *audio_element; + GstElement *video_show; + GtkWidget *video_widget; + GstElement *src; + GstElement *cache; + GstElement *typefind; + + guchar *uri; + gboolean muted; + gboolean can_seek; + + GstElement *offset_element; + GstElement *bit_rate_element; + GstElement *media_time_element; + GstElement *current_time_element; + + guint source_width; + guint source_height; +}; + GtkType gst_play_get_type (void) { @@ -218,30 +239,24 @@ static void gst_play_have_size (GstElement *element, guint width, guint height, GstPlay *play) { - GstPlayPrivate *priv; + play->priv->source_width = width; + play->priv->source_height = height; - priv = (GstPlayPrivate *) play->priv; - - priv->source_width = width; - priv->source_height = height; - - gtk_widget_set_usize (priv->video_widget, width, height); + gtk_widget_set_usize (play->priv->video_widget, width, height); } static void gst_play_frame_displayed (GstElement *element, GstPlay *play) { - GstPlayPrivate *priv; static int stolen = FALSE; - priv = (GstPlayPrivate *)play->priv; - gdk_threads_enter (); if (!stolen) { - gtk_widget_realize (priv->video_widget); - gtk_socket_steal (GTK_SOCKET (priv->video_widget), - gst_util_get_int_arg (G_OBJECT (priv->video_show), "xid")); - gtk_widget_show (priv->video_widget); + gtk_widget_realize (play->priv->video_widget); + gtk_socket_steal (GTK_SOCKET (play->priv->video_widget), + gst_util_get_int_arg ( + G_OBJECT (play->priv->video_show), "xid")); + gtk_widget_show (play->priv->video_widget); stolen = TRUE; } gdk_threads_leave (); @@ -269,10 +284,9 @@ gst_play_object_introspect (GstObject *object, const gchar *property, GstElement element = GST_ELEMENT (object); -#warning this looks grim, did I port it right ? pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (element), property); - if (!pspec) { + if (pspec) { *target = element; GST_DEBUG(0, "gstplay: using element \"%s\" for %s property\n", gst_element_get_name(element), property); @@ -310,36 +324,33 @@ gst_play_object_introspect (GstObject *object, const gchar *property, GstElement static void gst_play_object_added (GstAutoplug* autoplug, GstObject *object, GstPlay *play) { - GstPlayPrivate *priv; - g_return_if_fail (play != NULL); - priv = (GstPlayPrivate *)play->priv; - - if (GST_FLAG_IS_SET (object, GST_ELEMENT_NO_SEEK)) { - priv->can_seek = FALSE; - } + if (GST_FLAG_IS_SET (object, GST_ELEMENT_NO_SEEK)) + play->priv->can_seek = FALSE; // first come first serve here... - if (!priv->offset_element) - gst_play_object_introspect (object, "offset", &priv->offset_element); - if (!priv->bit_rate_element) - gst_play_object_introspect (object, "bit_rate", &priv->bit_rate_element); - if (!priv->media_time_element) - gst_play_object_introspect (object, "media_time", &priv->media_time_element); - if (!priv->current_time_element) - gst_play_object_introspect (object, "current_time", &priv->current_time_element); + if (!play->priv->offset_element) + gst_play_object_introspect (object, "offset", + &play->priv->offset_element); + if (!play->priv->bit_rate_element) + gst_play_object_introspect (object, "bit_rate", + &play->priv->bit_rate_element); + if (!play->priv->media_time_element) + gst_play_object_introspect (object, "media_time", + &play->priv->media_time_element); + if (!play->priv->current_time_element) + gst_play_object_introspect (object, "current_time", + &play->priv->current_time_element); } static void gst_play_cache_empty (GstElement *element, GstPlay *play) { - GstPlayPrivate *priv; + GstPlayPrivate *priv = play->priv; GstElement *new_element; - priv = (GstPlayPrivate *)play->priv; - gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); new_element = gst_bin_get_by_name (GST_BIN (priv->pipeline), "new_element"); @@ -355,14 +366,12 @@ gst_play_cache_empty (GstElement *element, GstPlay *play) static void gst_play_have_type (GstElement *sink, GstCaps *caps, GstPlay *play) { - GstPlayPrivate *priv; GstElement *new_element; GstAutoplug *autoplug; + GstPlayPrivate *priv = play->priv; GST_DEBUG (0,"GstPipeline: play have type\n"); - priv = (GstPlayPrivate *)play->priv; - gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); gst_element_disconnect (priv->cache, "src", priv->typefind, "sink"); @@ -398,6 +407,7 @@ gst_play_have_type (GstElement *sink, GstCaps *caps, GstPlay *play) gst_element_set_state (priv->pipeline, GST_STATE_PLAYING); } +#if 0 static gboolean connect_pads (GstElement *new_element, GstElement *target, gboolean add) { @@ -420,6 +430,7 @@ connect_pads (GstElement *new_element, GstElement *target, gboolean add) } return FALSE; } +#endif GstPlayReturn gst_play_set_uri (GstPlay *play, const guchar *uri) @@ -441,22 +452,20 @@ gst_play_set_uri (GstPlay *play, const guchar *uri) priv->src = gst_elementfactory_make ("gnomevfssrc", "srcelement"); if (!priv->src) { - if (strstr (uri, "file:/")) { - uri += strlen ("file:/"); - } + if (strstr (uri, "file:/")) + uri += strlen ("file:/"); else return GST_PLAY_CANNOT_PLAY; } } - if (priv->src == NULL) { + if (!priv->src) priv->src = gst_elementfactory_make ("filesrc", "srcelement"); - } priv->uri = g_strdup (uri); - //priv->src = gst_elementfactory_make ("dvdsrc", "disk_src"); - priv->offset_element = priv->src; + /* priv->src = gst_elementfactory_make ("dvdsrc", "disk_src"); */ + g_return_val_if_fail (priv->src != NULL, GST_PLAY_CANNOT_PLAY); g_object_set (G_OBJECT (priv->src), "location", priv->uri, NULL); @@ -486,23 +495,18 @@ gst_play_set_uri (GstPlay *play, const guchar *uri) static void gst_play_realize (GtkWidget *widget) { - GstPlay *play; - GstPlayPrivate *priv; + GstPlay *play = GST_PLAY (widget); - g_return_if_fail (GST_IS_PLAY (widget)); + g_return_if_fail (play != NULL); //g_print ("realize\n"); - play = GST_PLAY (widget); - priv = (GstPlayPrivate *)play->priv; + play->priv->video_widget = gtk_socket_new (); - priv->video_widget = gtk_socket_new (); - - gtk_container_add (GTK_CONTAINER (widget), priv->video_widget); + gtk_container_add (GTK_CONTAINER (widget), play->priv->video_widget); - if (GTK_WIDGET_CLASS (parent_class)->realize) { + if (GTK_WIDGET_CLASS (parent_class)->realize) GTK_WIDGET_CLASS (parent_class)->realize (widget); - } //gtk_socket_steal (GTK_SOCKET (priv->video_widget), // gst_util_get_int_arg (GTK_OBJECT(priv->video_element), "xid")); @@ -515,14 +519,13 @@ gst_play_realize (GtkWidget *widget) void gst_play_play (GstPlay *play) { - GstPlayPrivate *priv; + GstPlayPrivate *priv = play->priv; g_return_if_fail (play != NULL); g_return_if_fail (GST_IS_PLAY (play)); - priv = (GstPlayPrivate *)play->priv; - - if (play->state == GST_PLAY_PLAYING) return; + if (play->state == GST_PLAY_PLAYING) + return; if (play->state == GST_PLAY_STOPPED) gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_READY); @@ -538,14 +541,13 @@ gst_play_play (GstPlay *play) void gst_play_pause (GstPlay *play) { - GstPlayPrivate *priv; + GstPlayPrivate *priv = play->priv; g_return_if_fail (play != NULL); g_return_if_fail (GST_IS_PLAY (play)); - priv = (GstPlayPrivate *)play->priv; - - if (play->state != GST_PLAY_PLAYING) return; + if (play->state != GST_PLAY_PLAYING) + return; gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_PAUSED); @@ -559,19 +561,18 @@ gst_play_pause (GstPlay *play) void gst_play_stop (GstPlay *play) { - GstPlayPrivate *priv; + GstPlayPrivate *priv = play->priv; g_return_if_fail (play != NULL); g_return_if_fail (GST_IS_PLAY (play)); - priv = (GstPlayPrivate *)play->priv; + if (play->state == GST_PLAY_STOPPED) + return; - if (play->state == GST_PLAY_STOPPED) return; - - // FIXME until state changes are handled properly + /* FIXME until state changes are handled properly */ gst_element_set_state (GST_ELEMENT (priv->pipeline), GST_STATE_READY); - gtk_object_set (GTK_OBJECT (priv->src), "offset", 0, NULL); - //gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_NULL); + g_object_set (G_OBJECT (priv->src), "offset", 0, NULL); + /* gst_element_set_state (GST_ELEMENT (priv->pipeline),GST_STATE_NULL); */ play->state = GST_PLAY_STOPPED; g_idle_remove_by_data (priv->pipeline); @@ -583,67 +584,48 @@ gst_play_stop (GstPlay *play) GtkWidget * gst_play_get_video_widget (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - return priv->video_widget; + return play->priv->video_widget; } gint gst_play_get_source_width (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - return priv->source_width; + return play->priv->source_width; } gint gst_play_get_source_height (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - return priv->source_height; + return play->priv->source_height; } gulong gst_play_get_media_size (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - return gst_util_get_long_arg (G_OBJECT (priv->src), "filesize"); + if (gst_util_has_arg (G_OBJECT (play->priv->src), + "filesize", G_TYPE_INT64)) + return gst_util_get_int64_arg ( + G_OBJECT (play->priv->src), "filesize"); + else + return 0; } gulong gst_play_get_media_offset (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - if (priv->offset_element) - return gst_util_get_long_arg (G_OBJECT (priv->offset_element), "offset"); + if (play->priv->offset_element) + return gst_util_get_long_arg ( + G_OBJECT (play->priv->offset_element), "offset"); else return 0; } @@ -652,20 +634,19 @@ gulong gst_play_get_media_total_time (GstPlay *play) { gulong total_time, bit_rate; - GstPlayPrivate *priv; g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; + if (play->priv->media_time_element) + return gst_util_get_long_arg ( + G_OBJECT (play->priv->media_time_element), "media_time"); - if (priv->media_time_element) { - return gst_util_get_long_arg (G_OBJECT (priv->media_time_element), "media_time"); - } + if (!play->priv->bit_rate_element) + return 0; - if (priv->bit_rate_element == NULL) return 0; - - bit_rate = gst_util_get_long_arg (G_OBJECT (priv->bit_rate_element), "bit_rate"); + bit_rate = gst_util_get_long_arg ( + G_OBJECT (play->priv->bit_rate_element), "bit_rate"); if (bit_rate) total_time = (gst_play_get_media_size (play) * 8) / bit_rate; @@ -679,20 +660,20 @@ gulong gst_play_get_media_current_time (GstPlay *play) { gulong current_time, bit_rate; - GstPlayPrivate *priv; - g_return_val_if_fail (play != NULL, 0); g_return_val_if_fail (GST_IS_PLAY (play), 0); - priv = (GstPlayPrivate *)play->priv; - - if (priv->current_time_element) { - return gst_util_get_long_arg (G_OBJECT (priv->current_time_element), "current_time"); + if (play->priv->current_time_element) { + return gst_util_get_long_arg ( + G_OBJECT (play->priv->current_time_element), + "current_time"); } - if (priv->bit_rate_element == NULL) return 0; + if (!play->priv->bit_rate_element) + return 0; - bit_rate = gst_util_get_long_arg (G_OBJECT (priv->bit_rate_element), "bit_rate"); + bit_rate = gst_util_get_long_arg ( + G_OBJECT (play->priv->bit_rate_element), "bit_rate"); if (bit_rate) current_time = (gst_play_get_media_offset (play) * 8) / bit_rate; @@ -705,40 +686,27 @@ gst_play_get_media_current_time (GstPlay *play) gboolean gst_play_media_can_seek (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, FALSE); g_return_val_if_fail (GST_IS_PLAY (play), FALSE); - priv = (GstPlayPrivate *)play->priv; - - return priv->can_seek; + return play->priv->can_seek; } void gst_play_media_seek (GstPlay *play, gulong offset) { - GstPlayPrivate *priv; - - g_return_if_fail (play != NULL); g_return_if_fail (GST_IS_PLAY (play)); - priv = (GstPlayPrivate *)play->priv; - - gtk_object_set (GTK_OBJECT (priv->src), "offset", offset, NULL); + if (play->priv->offset_element) + g_object_set (G_OBJECT (play->priv->src), + "offset", offset, NULL); } GstElement* gst_play_get_pipeline (GstPlay *play) { - GstPlayPrivate *priv; - - g_return_val_if_fail (play != NULL, NULL); g_return_val_if_fail (GST_IS_PLAY (play), NULL); - priv = (GstPlayPrivate *)play->priv; - - return GST_ELEMENT (priv->pipeline); + return GST_ELEMENT (play->priv->pipeline); } static void @@ -770,7 +738,7 @@ gst_play_get_arg (GtkObject *object, GtkArg *arg, guint id) g_return_if_fail (arg != NULL); play = GST_PLAY (object); - priv = (GstPlayPrivate *)play->priv; + priv = play->priv; switch (id) { case ARG_URI: diff --git a/gstplay/gstplay.h b/gstplay/gstplay.h index b4ac81be0c..567e64b8fb 100644 --- a/gstplay/gstplay.h +++ b/gstplay/gstplay.h @@ -39,13 +39,14 @@ typedef enum { GST_PLAY_TYPE_VIDEO = (1 << 1), } GstPlayMediaTypeFlags; +typedef struct _GstPlayPrivate GstPlayPrivate; + struct _GstPlay { GtkHBox parent; - GstPlayState state; + GstPlayState state; GstPlayMediaTypeFlags flags; - - gpointer priv; + GstPlayPrivate *priv; }; #define GST_PLAY_STATE(play) ((play)->state) diff --git a/gstplay/gstplayprivate.h b/gstplay/gstplayprivate.h index 2b80f179a5..4ce7837a82 100644 --- a/gstplay/gstplayprivate.h +++ b/gstplay/gstplayprivate.h @@ -1,30 +1 @@ -#ifndef __GSTPLAY_PRIVATE_H__ -#define __GSTPLAY_PRIVATE_H__ - -#include - -typedef struct _GstPlayPrivate GstPlayPrivate; - -struct _GstPlayPrivate { - GstElement *pipeline; - GstElement *video_element, *audio_element; - GstElement *video_show; - GtkWidget *video_widget; - GstElement *src; - GstElement *cache; - GstElement *typefind; - - guchar *uri; - gboolean muted; - gboolean can_seek; - - GstElement *offset_element; - GstElement *bit_rate_element; - GstElement *media_time_element; - GstElement *current_time_element; - - guint source_width; - guint source_height; -}; - -#endif /* __GSTPLAY_PRIVATE_H__ */ +#error Bogus header diff --git a/gstplay/main.c b/gstplay/main.c index 8206a47a32..5981eca9b5 100644 --- a/gstplay/main.c +++ b/gstplay/main.c @@ -28,20 +28,24 @@ main (int argc, char *argv[]) if (argc > 1) { int i; - //gst_media_play_show_playlist (play); - gst_media_play_start_uri (play, argv[1]); + gst_media_play_show_playlist (play); + gst_media_play_start_uri (play, argv [1]); - for (i=1;iplay))); + xmlSaveFile ("gstmediaplay.gst", gst_xml_write ( + gst_play_get_pipeline (play->play))); #endif gdk_threads_enter(); +#ifdef USE_GLIB2 + gtk_main (); +#else gst_main(); +#endif gdk_threads_leave(); return 0; diff --git a/tools/Makefile.am b/tools/Makefile.am index 9bffc780cd..e1be919d7b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -12,7 +12,15 @@ GST_LOADSAVE_SRC = gstreamer-compprep endif if USE_GLIB2 +if HAVE_LIBGLADE_GNOME +GST_GUI_LAUNCH = gstreamer-guilaunch +gstreamer_guilaunch_CFLAGS = \ + $(LIBGLADE_GNOME_CFLAGS) $(CFLAGS) +gstreamer_guilaunch_LDADD = \ + $(LIBGLADE_GNOME_LIBS) $(LDADD) +else GST_GUI_LAUNCH = +endif else GST_GUI_LAUNCH = gstreamer-guilaunch endif diff --git a/tools/gstreamer-guilaunch.c b/tools/gstreamer-guilaunch.c index 91f6c3b33a..864d861630 100644 --- a/tools/gstreamer-guilaunch.c +++ b/tools/gstreamer-guilaunch.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -9,6 +10,12 @@ #include #include +#ifdef USE_GLIB2 +#define GTK_ENABLE_BROKEN +#include +#include +#undef GTK_ENABLE_BROKEN +#endif #include GtkWidget *start_but, *pause_but, *parse_but, *status; @@ -604,13 +611,18 @@ pause_callback( GtkWidget *widget, } } -int main(int argc,char *argv[]) { +int +main (int argc, char *argv[]) +{ GtkWidget *window; GtkWidget *vbox; GtkWidget *parse_line, *pipe_combo, *notebook, *pane; GtkWidget *tree_root, *tree_root_item, *page_scroll; - gst_init(&argc,&argv); +#ifdef USE_GLIB2 + gtk_init (&argc, &argv); +#endif + gst_init (&argc, &argv); /***** set up the GUI *****/ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); diff --git a/tools/gstreamer-launch.c b/tools/gstreamer-launch.c index 837ca6d26e..66fedec7d7 100644 --- a/tools/gstreamer-launch.c +++ b/tools/gstreamer-launch.c @@ -4,7 +4,7 @@ #include #include -static int launch_argc; +static int launch_argc; static char **launch_argv; #ifndef USE_GLIB2 @@ -62,9 +62,7 @@ gboolean idle_func (gpointer data) { if (!gst_bin_iterate (GST_BIN (data))) { -#ifndef USE_GLIB2 - gtk_main_quit (); -#endif + gst_main_quit (); g_print ("iteration ended\n"); return FALSE; } @@ -174,12 +172,8 @@ main(int argc, char *argv[]) exit (-1); } - g_idle_add(idle_func,pipeline); -#ifdef USE_GLIB2 - g_main_loop_run (g_main_loop_new (NULL, FALSE)); -#else - gtk_main(); -#endif + g_idle_add (idle_func, pipeline); + gst_main (); gst_element_set_state (pipeline, GST_STATE_NULL); }