From: Julien M. <do...@us...> - 2003-05-21 10:17:41
|
CVS Root: /cvsroot/gstreamer Module: gst-player Changes by: dolphy Date: Wed May 21 2003 03:17:40 PDT Log message: Fixing fd:// v4l:// and setting location. Incorporating latest videowidget with lot of fixes. And UPDATING ChangeLog as it has been ignored by previous committers :) Modified files: . : ChangeLog libs/gst/player : gstmediaplay.c gstvideowidget.c gstvideowidget.h Links: http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/ChangeLog.diff?r1=1.14&r2=1.15 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstmediaplay.c.diff?r1=1.117&r2=1.118 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstvideowidget.c.diff?r1=1.23&r2=1.24 http://cvs.sf.net/cgi-bin/viewcvs.cgi/gstreamer/gst-player/libs/gst/player/gstvideowidget.h.diff?r1=1.12&r2=1.13 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvsroot/gstreamer/gst-player/ChangeLog,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- ChangeLog 3 May 2003 11:18:59 -0000 1.14 +++ ChangeLog 21 May 2003 10:17:26 -0000 1.15 @@ -1,3 +1,24 @@ +2003-05-21 Julien MOUTTE <ju...@mo...> + + * libs/gst/player/gstmediaplay.c: (gst_media_play_have_video_size), + (gst_media_play_information), (gst_media_play_init), + (gst_media_play_set_location): Fixing fd:// and v4l:// integration in + the player. + * libs/gst/player/gstvideowidget.c: (gst_video_widget_expose), + (gst_video_widget_size_request), (gst_video_widget_allocate), + (gst_video_widget_set_property), (gst_video_widget_get_property), + (gst_video_widget_class_init), (gst_video_widget_init), + (gst_video_widget_set_xembed_xid), + (gst_video_widget_set_minimum_size), + (gst_video_widget_get_minimum_size), + (gst_video_widget_set_auto_resize), + (gst_video_widget_get_auto_resize), + (gst_video_widget_get_scale_override), + (gst_video_widget_set_scale_override), + (gst_video_widget_set_scale): Integrated newest videowidget which will + handle the scaling correctly. + * libs/gst/player/gstvideowidget.h: + 2003-05-03 Julien MOUTTE <ju...@mo...> * libs/gst/player/gstvideowidget.c: Index: gstmediaplay.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- gstmediaplay.c 20 May 2003 04:31:08 -0000 1.117 +++ gstmediaplay.c 21 May 2003 10:17:27 -0000 1.118 @@ -56,6 +56,7 @@ const gchar *location; const gchar *location_short; + gboolean auto_resize; gboolean media_has_video; gboolean with_visualisation; @@ -564,15 +565,17 @@ GtkWidget *label; g_return_if_fail(mplay != NULL); g_return_if_fail(GST_IS_MEDIA_PLAY(mplay)); - - if (label=glade_xml_get_widget(mplay->_priv->media_info_xml, "dimensions")) + + if (label=glade_xml_get_widget(mplay->_priv->media_info_xml, "dimensions")) { gtk_label_set_text (GTK_LABEL(label), - g_strdup_printf ("%d x %d", width, height)); + g_strdup_printf ("%d x %d", width, height)); + } - if (mplay->_priv->video_widget) + if (mplay->_priv->video_widget) { gst_video_widget_set_source_size( - GST_VIDEO_WIDGET(mplay->_priv->video_widget), - width, height); + GST_VIDEO_WIDGET(mplay->_priv->video_widget), + width, height); + } } static void @@ -717,7 +720,7 @@ static void gst_media_play_information ( GstPlay *play, - GstElement* element, + GstObject* element, GParamSpec *param, GstMediaPlay *mplay) { @@ -941,6 +944,8 @@ priv->video_widget = gst_video_widget_new (); g_return_if_fail(mplay->_priv->video_widget != NULL); + gst_video_widget_set_minimum_size (GST_VIDEO_WIDGET(priv->video_widget), 300, 300); + logo_path = gst_media_play_get_ui_file("gst-player-logo.png"); priv->logo_pixbuf = gdk_pixbuf_new_from_file (logo_path, NULL); @@ -1320,8 +1325,8 @@ mplay->_priv->media_has_video = FALSE; - gst_video_widget_set_logo_focus ( GST_VIDEO_WIDGET(mplay->_priv->video_widget), - TRUE); + gst_video_widget_set_source_size ( GST_VIDEO_WIDGET(mplay->_priv->video_widget), 0, 0); + gst_video_widget_set_logo_focus ( GST_VIDEO_WIDGET(mplay->_priv->video_widget),TRUE); /* Connecting visualisation if enabled */ @@ -1330,9 +1335,32 @@ gst_play_need_new_video_window ( mplay->_priv->play); - if(strncmp("fd://",location,5)==0){ + /* get a short filename if we can */ + if (GNOME_VFS_OK != gnome_vfs_get_file_info( location, &info, GNOME_VFS_FILE_INFO_DEFAULT)) + mplay->_priv->location_short = location; + else + mplay->_priv->location_short = info.name; + + g_signal_emit (mplay, gst_media_play_signals [CURRENT_LOCATION], + 0, mplay->_priv->location, mplay->_priv->location_short); + + if (g_file_test (location,G_FILE_TEST_EXISTS)) { + g_message ("using filesrc"); + datasrc = gst_element_factory_make ("filesrc", "source"); + if (GST_IS_ELEMENT(datasrc)) + gst_play_set_data_src (mplay->_priv->play, datasrc); + gst_play_set_location (mplay->_priv->play, mplay->_priv->location); + } + else if (g_str_has_prefix (location, "cda://")) { + g_message ("using cdparanoia"); + datasrc = gst_element_factory_make ("cdparanoia", "source"); + } + else if (g_str_has_prefix (location, "v4l://")) { + g_message ("using v4lsrc"); + datasrc = gst_element_factory_make ("v4lsrc", "source"); + } + else if (g_str_has_prefix (location, "fd://")) { GstElement *fdsrc, *queue; - g_message ("location is file descriptor -- using fdsrc"); datasrc = gst_element_factory_make ("thread", "source"); fdsrc = gst_element_factory_make ("fdsrc", "thread_fdsrc"); @@ -1345,32 +1373,14 @@ "src"); g_object_set(G_OBJECT(queue),"max-level",1000000,NULL); - }else{ - /* get a short filename if we can */ - if (GNOME_VFS_OK != gnome_vfs_get_file_info( location, - &info, - GNOME_VFS_FILE_INFO_DEFAULT) - ) - mplay->_priv->location_short = location; - else - mplay->_priv->location_short = info.name; - - g_signal_emit ( mplay, - gst_media_play_signals [CURRENT_LOCATION], - 0, mplay->_priv->location, mplay->_priv->location_short); - - if (g_file_test (location,G_FILE_TEST_EXISTS)) { - datasrc = gst_element_factory_make ("filesrc", "source"); - } - else { - datasrc = gst_element_factory_make ("gnomevfssrc", "source"); - } } - - if (GST_IS_ELEMENT(datasrc)) - gst_play_set_data_src (mplay->_priv->play, datasrc); - - gst_play_set_location (mplay->_priv->play, mplay->_priv->location); + else { + g_message ("using gnomevfssrc"); + datasrc = gst_element_factory_make ("gnomevfssrc", "source"); + if (GST_IS_ELEMENT(datasrc)) + gst_play_set_data_src (mplay->_priv->play, datasrc); + gst_play_set_location (mplay->_priv->play, mplay->_priv->location); + } } const gchar* Index: gstvideowidget.c =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstvideowidget.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- gstvideowidget.c 3 May 2003 11:18:59 -0000 1.23 +++ gstvideowidget.c 21 May 2003 10:17:27 -0000 1.24 @@ -29,6 +29,7 @@ enum { ARG_0, ARG_SCALE_FACTOR, + ARG_AUTO_RESIZE, ARG_VISIBLE_CURSOR, ARG_LOGO_FOCUSED, ARG_EVENT_CATCHER, @@ -47,9 +48,13 @@ gulong xembed_xid; - gint source_width; - gint source_height; + guint source_width; + guint source_height; + + guint width_mini; + guint height_mini; + gboolean auto_resize; gboolean cursor_visible; gboolean event_catcher; gboolean logo_focused; @@ -265,8 +270,10 @@ g_return_val_if_fail(widget != NULL, FALSE); g_return_val_if_fail(GST_IS_VIDEO_WIDGET(widget), FALSE); g_return_val_if_fail(event != NULL, FALSE); - + vw = GST_VIDEO_WIDGET (widget); + + /* g_message ("expose %d,%d",event->area.width, event->area.height);*/ if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) { @@ -355,6 +362,12 @@ vw = GST_VIDEO_WIDGET (widget); + if ( (!vw->priv->auto_resize) && (!vw->priv->scale_override) ){ + requisition->width = vw->priv->width_mini; + requisition->height = vw->priv->height_mini; + return; + } + if ( (vw->priv->source_width) && (vw->priv->source_height) && (vw->priv->scale_factor) ) { @@ -378,6 +391,8 @@ if (vw->priv->logo_pixbuf) { width = gdk_pixbuf_get_width(vw->priv->logo_pixbuf); height = gdk_pixbuf_get_height(vw->priv->logo_pixbuf); + vw->priv->width_mini = width; + vw->priv->height_mini = height; } else { width = 100; @@ -385,6 +400,11 @@ } } + if (width < vw->priv->width_mini) + width = vw->priv->width_mini; + if (height < vw->priv->height_mini) + height = vw->priv->height_mini; + requisition->width = width; requisition->height = height; } @@ -395,23 +415,20 @@ gst_video_widget_allocate (GtkWidget *widget, GtkAllocation *allocation) { GstVideoWidget *vw; - gfloat width_ratio, height_ratio, temp, scale_factor; + gfloat width_ratio, height_ratio, temp, scale_factor = 1.0; guint width, height; g_return_if_fail(widget != NULL); g_return_if_fail(GST_IS_VIDEO_WIDGET(widget)); vw = GST_VIDEO_WIDGET (widget); - - widget->allocation = *allocation; /* Choosing best ratio */ if (vw->priv->scale_override) { scale_factor = vw->priv->scale_factor; - vw->priv->scale_override = FALSE; } - else { + else if (!vw->priv->auto_resize) { /* Ratio get impacted only if video window loaded */ if ( (vw->priv->source_width) && @@ -426,6 +443,9 @@ scale_factor = MIN (width_ratio, height_ratio); } } + else { + scale_factor = 1.0; + } /* Calculating width & height with optimal ratio */ @@ -434,6 +454,31 @@ temp = (scale_factor * vw->priv->source_height + 0.5); height = (gint) temp > G_MAXINT ? G_MAXINT : (gint) temp; + /* If auto resize is set we check that video size is + bigger than minimum size */ + if (vw->priv->auto_resize) { + if (width < vw->priv->width_mini) { + allocation->width = vw->priv->width_mini; + } + else { + allocation->width = width; + } + if (height < vw->priv->height_mini) { + allocation->height = vw->priv->height_mini; + } + else { + allocation->height = height; + } + } /* If not auto resizing we check that allocation is bigger */ + else { /* than minimum size */ + if (allocation->width < vw->priv->width_mini) + allocation->width = vw->priv->width_mini; + if (allocation->height < vw->priv->height_mini) + allocation->height = vw->priv->height_mini; + } + + widget->allocation = *allocation; + if (GTK_WIDGET_REALIZED (widget)) { gdk_window_move_resize ( widget->window, allocation->x, @@ -481,6 +526,10 @@ vw->priv->scale_override = TRUE; gtk_widget_queue_resize (GTK_WIDGET(vw)); break; + case ARG_AUTO_RESIZE: + vw->priv->auto_resize = g_value_get_boolean (value); + gtk_widget_queue_resize (GTK_WIDGET(vw)); + break; case ARG_VISIBLE_CURSOR: vw->priv->cursor_visible = g_value_get_boolean (value); gst_video_widget_update_cursor (vw); @@ -532,6 +581,9 @@ case ARG_SCALE_FACTOR: g_value_set_float (value, vw->priv->scale_factor); break; + case ARG_AUTO_RESIZE: + g_value_set_boolean (value, vw->priv->auto_resize); + break; case ARG_VISIBLE_CURSOR: g_value_set_boolean (value, vw->priv->cursor_visible); break; @@ -581,7 +633,7 @@ gobject_class->set_property = gst_video_widget_set_property; gobject_class->get_property = gst_video_widget_get_property; - + g_object_class_install_property ( gobject_class, ARG_SCALE_FACTOR, @@ -593,6 +645,15 @@ g_object_class_install_property ( gobject_class, + ARG_AUTO_RESIZE, + g_param_spec_boolean ( + "auto_resize", + "auto resize", + "Is the video widget resizing automatically", + FALSE, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, ARG_VISIBLE_CURSOR, g_param_spec_boolean ( "visible_cursor", @@ -674,7 +735,10 @@ vw->priv->source_width = 0; vw->priv->source_height = 0; + vw->priv->width_mini = 0; + vw->priv->height_mini = 0; vw->priv->scale_factor = 1.0; + vw->priv->auto_resize = FALSE; vw->priv->scale_override= FALSE; vw->priv->cursor_visible= TRUE; vw->priv->event_catcher = TRUE; @@ -719,11 +783,19 @@ vw->priv->video_window = gdk_window_foreign_new (xid); if (vw->priv->video_window) { + gint video_x, video_y, video_width, video_height, video_depth; gdk_window_reparent (vw->priv->video_window, widget->window, 0, 0); gdk_window_show (vw->priv->video_window); + gdk_window_get_geometry ( vw->priv->video_window, + &video_x, &video_y, + &video_width, &video_height, &video_depth); + + vw->priv->source_width = video_width; + vw->priv->source_height = video_height; + if (vw->priv->event_catcher) gdk_window_raise (vw->priv->event_window); @@ -765,7 +837,7 @@ * Set video source size of a #GstVideoWidget and queue a resize request * for the widget. * - * The #GstVideoWidget must have already be created + * The #GstVideoWidget must have already been created * before you can make this call. * * Remember you can set these values trough "source_width" and "source_height" @@ -812,6 +884,62 @@ } /** + * gst_video_widget_set_minimum_size: + * @vw: a #GstVideoWidget + * @width: a #gint indicating minimum width. + * @height: a #gint indicating minimum height. + * + * Set minimum size of a #GstVideoWidget and queue a resize request + * for the widget. This method is usefull when the #GstVideoWidget is set + * to auto resize, it won't go under this size. + * + * The #GstVideoWidget must have already been created + * before you can make this call. + * + * Remember you can set these values trough "width_mini" and "height_mini" + * properties, but you will have to queue the resize request yourself. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_set_minimum_size (GstVideoWidget *vw, gint width, gint height) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + + vw->priv->width_mini = width; + vw->priv->height_mini = height; + gtk_widget_queue_resize (GTK_WIDGET(vw)); + + return TRUE; +} + +/** + * gst_video_widget_get_minimum_size: + * @socket_: a #GstVideoWidget + * @width: a pointer to a #gint where minimum width will be put. + * @height: a pointer to a #gint where minimum height will be put. + * + * Fills @width and @height with minimum dimensions. + * + * Remember you can get these values trough "width_mini" and "height_mini" + * properties. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_get_minimum_size (GstVideoWidget *vw, gint *width, gint *height) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + + *width = vw->priv->width_mini; + *height = vw->priv->height_mini; + + return TRUE; +} + +/** * gst_video_widget_set_cursor_visible: * @vw: a #GstVideoWidget * @visible: a #gboolean indicating wether or not the cursor should be visible. @@ -940,6 +1068,86 @@ } /** + * gst_video_widget_set_auto_resize: + * @vw: a #GstVideoWidget + * @resize: a #gboolean indicating auto resize mode that will be used by @vw. + * + * Set if a #GstVideoWidget will auto resize or not. + * + * Remember you can set this flag trough the "auto_resize" property. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_set_auto_resize (GstVideoWidget *vw, gboolean resize) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + vw->priv->auto_resize = resize; + gtk_widget_queue_resize (GTK_WIDGET(vw)); + return TRUE; +} + +/** + * gst_video_widget_get_auto_resize: + * @vw: a #GstVideoWidget + * + * Get used auto resize mode for a #GstVideoWidget. + * + * Remember you can get this value trough "auto_resize" property. + * + * Return value: a #gboolean indicating wether the video widget + * is in auto_resize mode or not. + **/ +gboolean +gst_video_widget_get_auto_resize (GstVideoWidget *vw) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + return vw->priv->auto_resize; +} + +/** + * gst_video_widget_get_scale_override: + * @vw: a #GstVideoWidget + * + * Get scale override mode for a #GstVideoWidget. + * + * Remember you can get this value trough "scale_override" property. + * + * Return value: a #gboolean indicating if scale ratio is enforced or not. + **/ +gboolean +gst_video_widget_get_scale_override (GstVideoWidget *vw) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + return vw->priv->scale_override; +} + +/** + * gst_video_widget_set_scale_override: + * @vw: a #GstVideoWidget + * @override: a #gboolean indicating scale override mode that will + * be used by @vw. + * + * Set scale override mode for a #GstVideoWidget. + * + * Remember you can set this flag trough the "scale_override" property. + * + * Return value: a #gboolean indicating wether the call succeeded or not. + **/ +gboolean +gst_video_widget_set_scale_override (GstVideoWidget *vw, gboolean override) +{ + g_return_val_if_fail(vw != NULL, FALSE); + g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); + vw->priv->scale_override = override; + gtk_widget_queue_resize (GTK_WIDGET(vw)); + return TRUE; +} + +/** * gst_video_widget_set_scale: * @vw: a #GstVideoWidget * @scale: a #gfloat indicating scale factor that will be used by @vw. @@ -956,8 +1164,8 @@ g_return_val_if_fail(vw != NULL, FALSE); g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE); vw->priv->scale_factor = scale; - vw->priv->scale_override = TRUE; - gtk_widget_queue_resize (GTK_WIDGET(vw)); + if (vw->priv->scale_override) + gtk_widget_queue_resize (GTK_WIDGET(vw)); return TRUE; } Index: gstvideowidget.h =================================================================== RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstvideowidget.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- gstvideowidget.h 3 May 2003 11:18:59 -0000 1.12 +++ gstvideowidget.h 21 May 2003 10:17:27 -0000 1.13 @@ -66,6 +66,14 @@ gboolean gst_video_widget_get_source_size ( GstVideoWidget *vw, gint *width, gint *height); +/* Set/Get minimum video widget size */ + +gboolean gst_video_widget_set_minimum_size ( GstVideoWidget *vw, + gint width, gint height); + +gboolean gst_video_widget_get_minimum_size ( GstVideoWidget *vw, + gint *width, gint *height); + /* Set/Get mouse pointer visible or not */ gboolean gst_video_widget_set_cursor_visible ( GstVideoWidget *vw, @@ -84,8 +92,15 @@ gboolean event_catcher); gboolean gst_video_widget_get_event_catcher (GstVideoWidget *vw); +/* Set/Get auto resize mode used by the widget */ + +gboolean gst_video_widget_set_auto_resize (GstVideoWidget *vw, gboolean resize); +gboolean gst_video_widget_get_auto_resize (GstVideoWidget *vw); + /* Set/Get scale factor used by the widget */ +gboolean gst_video_widget_get_scale_override (GstVideoWidget *vw); +gboolean gst_video_widget_set_scale_override (GstVideoWidget *vw, gboolean override); gboolean gst_video_widget_set_scale (GstVideoWidget *vw, gfloat scale); gfloat gst_video_widget_get_scale (GstVideoWidget *vw); |