[longomatch] Fix indentation of C code using gst-indent
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Fix indentation of C code using gst-indent
- Date: Mon, 5 Jul 2010 18:47:40 +0000 (UTC)
commit 0b69b0293bb4e43692903ec2ed336b81f233e923
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Jul 4 18:55:24 2010 +0200
Fix indentation of C code using gst-indent
libcesarplayer/src/bacon-resize.c | 109 +-
libcesarplayer/src/bacon-video-widget-gst-0.10.c | 4976 ++++++++++------------
libcesarplayer/src/bacon-video-widget.h | 147 +-
libcesarplayer/src/gst-camera-capturer.c | 173 +-
libcesarplayer/src/gst-camera-capturer.h | 53 +-
libcesarplayer/src/gst-smart-video-scaler.c | 227 +-
libcesarplayer/src/gst-smart-video-scaler.h | 4 +-
libcesarplayer/src/gst-video-editor.c | 1263 +++---
libcesarplayer/src/gst-video-editor.h | 17 +-
libcesarplayer/src/gstscreenshot.c | 132 +-
libcesarplayer/src/gstscreenshot.h | 2 +-
libcesarplayer/src/gstvideowidget.c | 604 ++--
libcesarplayer/src/gstvideowidget.h | 21 +-
libcesarplayer/src/main.c | 11 +-
libcesarplayer/src/video-utils.c | 111 +-
libcesarplayer/src/video-utils.h | 4 +-
16 files changed, 3483 insertions(+), 4371 deletions(-)
---
diff --git a/libcesarplayer/src/bacon-resize.c b/libcesarplayer/src/bacon-resize.c
index 1927c2b..98feea2 100644
--- a/libcesarplayer/src/bacon-resize.c
+++ b/libcesarplayer/src/bacon-resize.c
@@ -34,12 +34,9 @@
#endif
static void bacon_resize_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec);
+ guint property_id, const GValue * value, GParamSpec * pspec);
static void bacon_resize_get_property (GObject * object,
- guint property_id,
- GValue * value, GParamSpec * pspec);
+ guint property_id, GValue * value, GParamSpec * pspec);
#ifdef HAVE_XVIDMODE
static void bacon_resize_finalize (GObject * object);
#endif /* HAVE_XVIDMODE */
@@ -81,25 +78,22 @@ G_DEFINE_TYPE (BaconResize, bacon_resize, G_TYPE_OBJECT)
#endif /* HAVE_XVIDMODE */
g_object_class_install_property (object_class, PROP_HAVE_XVIDMODE,
- g_param_spec_boolean ("have-xvidmode",
- NULL, NULL, FALSE,
- G_PARAM_READABLE));
+ g_param_spec_boolean ("have-xvidmode",
+ NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_VIDEO_WIDGET,
- g_param_spec_object ("video-widget",
- "video-widget",
- "The related video widget",
- GTK_TYPE_WIDGET,
- G_PARAM_WRITABLE |
- G_PARAM_CONSTRUCT_ONLY));
+ g_param_spec_object ("video-widget",
+ "video-widget",
+ "The related video widget",
+ GTK_TYPE_WIDGET, G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}
static void
bacon_resize_init (BaconResize * resize)
{
resize->priv =
- G_TYPE_INSTANCE_GET_PRIVATE (resize, BACON_TYPE_RESIZE,
- BaconResizePrivate);
+ G_TYPE_INSTANCE_GET_PRIVATE (resize, BACON_TYPE_RESIZE,
+ BaconResizePrivate);
resize->priv->have_xvidmode = FALSE;
resize->priv->resized = FALSE;
@@ -109,8 +103,8 @@ BaconResize *
bacon_resize_new (GtkWidget * video_widget)
{
return
- BACON_RESIZE (g_object_new
- (BACON_TYPE_RESIZE, "video-widget", video_widget, NULL));
+ BACON_RESIZE (g_object_new
+ (BACON_TYPE_RESIZE, "video-widget", video_widget, NULL));
}
#ifdef HAVE_XVIDMODE
@@ -120,7 +114,7 @@ bacon_resize_finalize (GObject * object)
BaconResize *self = BACON_RESIZE (object);
g_signal_handlers_disconnect_by_func (self->priv->video_widget,
- screen_changed_cb, self);
+ screen_changed_cb, self);
G_OBJECT_CLASS (bacon_resize_parent_class)->finalize (object);
}
@@ -128,33 +122,29 @@ bacon_resize_finalize (GObject * object)
static void
bacon_resize_set_property (GObject * object,
- guint property_id,
- const GValue * value, GParamSpec * pspec)
+ guint property_id, const GValue * value, GParamSpec * pspec)
{
- switch (property_id)
- {
+ switch (property_id) {
case PROP_VIDEO_WIDGET:
set_video_widget (BACON_RESIZE (object),
- GTK_WIDGET (g_value_get_object (value)));
+ GTK_WIDGET (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ }
}
static void
bacon_resize_get_property (GObject * object,
- guint property_id,
- GValue * value, GParamSpec * pspec)
+ guint property_id, GValue * value, GParamSpec * pspec)
{
- switch (property_id)
- {
+ switch (property_id) {
case PROP_HAVE_XVIDMODE:
g_value_set_boolean (value, BACON_RESIZE (object)->priv->have_xvidmode);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
- }
+ }
}
static void
@@ -175,7 +165,7 @@ set_video_widget (BaconResize * resize, GtkWidget * video_widget)
screen = gtk_widget_get_screen (video_widget);
g_signal_connect (G_OBJECT (video_widget),
- "screen-changed", G_CALLBACK (screen_changed_cb), resize);
+ "screen-changed", G_CALLBACK (screen_changed_cb), resize);
XLockDisplay (GDK_DISPLAY_XDISPLAY (display));
@@ -189,9 +179,8 @@ set_video_widget (BaconResize * resize, GtkWidget * video_widget)
/* We don't use the output here, checking whether XRRGetScreenInfo works */
xr_screen_conf =
- XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY (display),
- GDK_WINDOW_XWINDOW (gdk_screen_get_root_window
- (screen)));
+ XRRGetScreenInfo (GDK_DISPLAY_XDISPLAY (display),
+ GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)));
if (xr_screen_conf == NULL)
goto bail;
@@ -236,8 +225,8 @@ bacon_resize_resize (BaconResize * resize)
goto bail;
res =
- XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock,
- &modeline);
+ XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock,
+ &modeline);
if (!res)
goto bail;
@@ -252,36 +241,32 @@ bacon_resize_resize (BaconResize * resize)
/* Find the XRandR mode that corresponds to the real size */
resize->priv->xr_screen_conf =
- XRRGetScreenInfo (Display, GDK_WINDOW_XWINDOW (root));
+ XRRGetScreenInfo (Display, GDK_WINDOW_XWINDOW (root));
xr_sizes = XRRConfigSizes (resize->priv->xr_screen_conf, &xr_nsize);
resize->priv->xr_original_size =
- XRRConfigCurrentConfiguration (resize->priv->xr_screen_conf,
- &(resize->priv->xr_current_rotation));
- if (gdk_error_trap_pop ())
- {
- g_warning ("XRRConfigSizes or XRRConfigCurrentConfiguration failed");
- goto bail;
- }
+ XRRConfigCurrentConfiguration (resize->priv->xr_screen_conf,
+ &(resize->priv->xr_current_rotation));
+ if (gdk_error_trap_pop ()) {
+ g_warning ("XRRConfigSizes or XRRConfigCurrentConfiguration failed");
+ goto bail;
+ }
- for (i = 0; i < xr_nsize; i++)
- {
- if (modeline.hdisplay == xr_sizes[i].width
- && modeline.vdisplay == xr_sizes[i].height)
- {
- found = TRUE;
- break;
- }
+ for (i = 0; i < xr_nsize; i++) {
+ if (modeline.hdisplay == xr_sizes[i].width
+ && modeline.vdisplay == xr_sizes[i].height) {
+ found = TRUE;
+ break;
}
+ }
if (!found)
goto bail;
gdk_error_trap_push ();
XRRSetScreenConfig (Display,
- resize->priv->xr_screen_conf,
- GDK_WINDOW_XWINDOW (root),
- (SizeID) i,
- resize->priv->xr_current_rotation, CurrentTime);
+ resize->priv->xr_screen_conf,
+ GDK_WINDOW_XWINDOW (root),
+ (SizeID) i, resize->priv->xr_current_rotation, CurrentTime);
gdk_flush ();
if (gdk_error_trap_pop ())
g_warning ("XRRSetScreenConfig failed");
@@ -320,8 +305,8 @@ bacon_resize_restore (BaconResize * resize)
screen = gtk_widget_get_screen (resize->priv->video_widget);
root = gdk_screen_get_root_window (screen);
res =
- XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock,
- &modeline);
+ XF86VidModeGetModeLine (Display, GDK_SCREEN_XNUMBER (screen), &dotclock,
+ &modeline);
if (!res)
goto bail;
@@ -334,10 +319,10 @@ bacon_resize_restore (BaconResize * resize)
gdk_error_trap_push ();
XRRSetScreenConfig (Display,
- resize->priv->xr_screen_conf,
- GDK_WINDOW_XWINDOW (root),
- resize->priv->xr_original_size,
- resize->priv->xr_current_rotation, CurrentTime);
+ resize->priv->xr_screen_conf,
+ GDK_WINDOW_XWINDOW (root),
+ resize->priv->xr_original_size,
+ resize->priv->xr_current_rotation, CurrentTime);
gdk_flush ();
if (gdk_error_trap_pop ())
g_warning ("XRRSetScreenConfig failed");
diff --git a/libcesarplayer/src/bacon-video-widget-gst-0.10.c b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
index 7f1f926..39de270 100644
--- a/libcesarplayer/src/bacon-video-widget-gst-0.10.c
+++ b/libcesarplayer/src/bacon-video-widget-gst-0.10.c
@@ -142,10 +142,10 @@ struct BaconVideoWidgetPrivate
char *mrl;
GstElement *play;
- GstXOverlay *xoverlay; /* protect with lock */
- GstColorBalance *balance; /* protect with lock */
- GstNavigation *navigation; /* protect with lock */
- guint interface_update_id; /* protect with lock */
+ GstXOverlay *xoverlay; /* protect with lock */
+ GstColorBalance *balance; /* protect with lock */
+ GstNavigation *navigation; /* protect with lock */
+ guint interface_update_id; /* protect with lock */
GMutex *lock;
guint update_id;
@@ -155,7 +155,7 @@ struct BaconVideoWidgetPrivate
gboolean media_has_video;
gboolean media_has_audio;
- gint seekable; /* -1 = don't know, FALSE = no */
+ gint seekable; /* -1 = don't know, FALSE = no */
gint64 stream_length;
gint64 current_time_nanos;
gint64 current_time;
@@ -181,13 +181,13 @@ struct BaconVideoWidgetPrivate
gboolean auto_resize;
gboolean uses_fakesink;
- gint video_width; /* Movie width */
- gint video_height; /* Movie height */
- gboolean window_resized; /* Whether the window has already been resized
- for this media */
- const GValue *movie_par; /* Movie pixel aspect ratio */
- gint video_width_pixels; /* Scaled movie width */
- gint video_height_pixels; /* Scaled movie height */
+ gint video_width; /* Movie width */
+ gint video_height; /* Movie height */
+ gboolean window_resized; /* Whether the window has already been resized
+ for this media */
+ const GValue *movie_par; /* Movie pixel aspect ratio */
+ gint video_width_pixels; /* Scaled movie width */
+ gint video_height_pixels; /* Scaled movie height */
gint video_fps_n;
gint video_fps_d;
@@ -217,7 +217,7 @@ struct BaconVideoWidgetPrivate
gboolean buffering;
/* for easy codec installation */
- GList *missing_plugins; /* GList of GstMessages */
+ GList *missing_plugins; /* GList of GstMessages */
gboolean plugin_install_in_progress;
/* Bacon resize */
@@ -225,25 +225,20 @@ struct BaconVideoWidgetPrivate
};
static void bacon_video_widget_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec);
+ guint property_id, const GValue * value, GParamSpec * pspec);
static void bacon_video_widget_get_property (GObject * object,
- guint property_id,
- GValue * value,
- GParamSpec * pspec);
+ guint property_id, GValue * value, GParamSpec * pspec);
static void bvw_update_interface_implementations (BaconVideoWidget * bvw);
static void bacon_video_widget_finalize (GObject * object);
static void bvw_update_interface_implementations (BaconVideoWidget * bvw);
static gboolean bacon_video_widget_configure_event (GtkWidget * widget,
- GdkEventConfigure * event,
- BaconVideoWidget * bvw);
+ GdkEventConfigure * event, BaconVideoWidget * bvw);
static void size_changed_cb (GdkScreen * screen, BaconVideoWidget * bvw);
static void bvw_process_pending_tag_messages (BaconVideoWidget * bvw);
static void bvw_stop_play_pipeline (BaconVideoWidget * bvw);
static GError *bvw_error_from_gst_error (BaconVideoWidget * bvw,
- GstMessage * m);
+ GstMessage * m);
@@ -264,11 +259,10 @@ bvw_get_missing_plugins_foo (const GList * missing_plugins, MsgToStrFunc func)
{
GPtrArray *arr = g_ptr_array_new ();
- while (missing_plugins != NULL)
- {
- g_ptr_array_add (arr, func (GST_MESSAGE (missing_plugins->data)));
- missing_plugins = missing_plugins->next;
- }
+ while (missing_plugins != NULL) {
+ g_ptr_array_add (arr, func (GST_MESSAGE (missing_plugins->data)));
+ missing_plugins = missing_plugins->next;
+ }
g_ptr_array_add (arr, NULL);
return (gchar **) g_ptr_array_free (arr, FALSE);
}
@@ -277,21 +271,21 @@ static gchar **
bvw_get_missing_plugins_details (const GList * missing_plugins)
{
return bvw_get_missing_plugins_foo (missing_plugins,
- gst_missing_plugin_message_get_installer_detail);
+ gst_missing_plugin_message_get_installer_detail);
}
static gchar **
bvw_get_missing_plugins_descriptions (const GList * missing_plugins)
{
return bvw_get_missing_plugins_foo (missing_plugins,
- gst_missing_plugin_message_get_description);
+ gst_missing_plugin_message_get_description);
}
static void
bvw_clear_missing_plugins_messages (BaconVideoWidget * bvw)
{
g_list_foreach (bvw->priv->missing_plugins,
- (GFunc) gst_mini_object_unref, NULL);
+ (GFunc) gst_mini_object_unref, NULL);
g_list_free (bvw->priv->missing_plugins);
bvw->priv->missing_plugins = NULL;
}
@@ -304,35 +298,28 @@ bvw_check_if_video_decoder_is_missing (BaconVideoWidget * bvw)
if (bvw->priv->media_has_video || bvw->priv->missing_plugins == NULL)
return;
- for (l = bvw->priv->missing_plugins; l != NULL; l = l->next)
- {
- GstMessage *msg = GST_MESSAGE (l->data);
- gchar *d, *f;
-
- if ((d = gst_missing_plugin_message_get_installer_detail (msg)))
- {
- if ((f = strstr (d, "|decoder-")) && strstr (f, "video"))
- {
- GError *err;
-
- /* create a fake GStreamer error so we get a nice warning message */
- err =
- g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN,
- "x");
- msg =
- gst_message_new_error (GST_OBJECT (bvw->priv->play), err,
- NULL);
- g_error_free (err);
- err = bvw_error_from_gst_error (bvw, msg);
- gst_message_unref (msg);
- g_signal_emit (bvw, bvw_signals[SIGNAL_ERROR], 0, err->message);
- g_error_free (err);
- g_free (d);
- break;
- }
- g_free (d);
- }
+ for (l = bvw->priv->missing_plugins; l != NULL; l = l->next) {
+ GstMessage *msg = GST_MESSAGE (l->data);
+ gchar *d, *f;
+
+ if ((d = gst_missing_plugin_message_get_installer_detail (msg))) {
+ if ((f = strstr (d, "|decoder-")) && strstr (f, "video")) {
+ GError *err;
+
+ /* create a fake GStreamer error so we get a nice warning message */
+ err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN, "x");
+ msg = gst_message_new_error (GST_OBJECT (bvw->priv->play), err, NULL);
+ g_error_free (err);
+ err = bvw_error_from_gst_error (bvw, msg);
+ gst_message_unref (msg);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_ERROR], 0, err->message);
+ g_error_free (err);
+ g_free (d);
+ break;
+ }
+ g_free (d);
}
+ }
}
static void
@@ -342,212 +329,172 @@ bvw_error_msg (BaconVideoWidget * bvw, GstMessage * msg)
gchar *dbg = NULL;
GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (bvw->priv->play),
- GST_DEBUG_GRAPH_SHOW_ALL ^
- GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS,
- "totem-error");
+ GST_DEBUG_GRAPH_SHOW_ALL ^
+ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, "totem-error");
gst_message_parse_error (msg, &err, &dbg);
- if (err)
- {
- GST_ERROR ("message = %s", GST_STR_NULL (err->message));
- GST_ERROR ("domain = %d (%s)", err->domain,
- GST_STR_NULL (g_quark_to_string (err->domain)));
- GST_ERROR ("code = %d", err->code);
- GST_ERROR ("debug = %s", GST_STR_NULL (dbg));
- GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src);
- GST_ERROR ("uri = %s", GST_STR_NULL (bvw->priv->mrl));
-
- g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
- GST_STR_NULL (dbg));
-
- g_error_free (err);
- }
+ if (err) {
+ GST_ERROR ("message = %s", GST_STR_NULL (err->message));
+ GST_ERROR ("domain = %d (%s)", err->domain,
+ GST_STR_NULL (g_quark_to_string (err->domain)));
+ GST_ERROR ("code = %d", err->code);
+ GST_ERROR ("debug = %s", GST_STR_NULL (dbg));
+ GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src);
+ GST_ERROR ("uri = %s", GST_STR_NULL (bvw->priv->mrl));
+
+ g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
+ GST_STR_NULL (dbg));
+
+ g_error_free (err);
+ }
g_free (dbg);
}
static void
get_media_size (BaconVideoWidget * bvw, gint * width, gint * height)
{
- if (bvw->priv->logo_mode)
- {
- if (bvw->priv->logo_pixbuf)
- {
- *width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf);
- *height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf);
- }
- else
- {
- *width = 0;
- *height = 0;
- }
+ if (bvw->priv->logo_mode) {
+ if (bvw->priv->logo_pixbuf) {
+ *width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf);
+ *height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf);
+ } else {
+ *width = 0;
+ *height = 0;
}
- else
- {
- if (bvw->priv->media_has_video)
- {
- GValue *disp_par = NULL;
- guint movie_par_n, movie_par_d, disp_par_n, disp_par_d, num, den;
-
- /* Create and init the fraction value */
- disp_par = g_new0 (GValue, 1);
- g_value_init (disp_par, GST_TYPE_FRACTION);
-
- /* Square pixel is our default */
- gst_value_set_fraction (disp_par, 1, 1);
-
- /* Now try getting display's pixel aspect ratio */
- if (bvw->priv->xoverlay)
- {
- GObjectClass *klass;
- GParamSpec *pspec;
-
- klass = G_OBJECT_GET_CLASS (bvw->priv->xoverlay);
- pspec =
- g_object_class_find_property (klass, "pixel-aspect-ratio");
-
- if (pspec != NULL)
- {
- GValue disp_par_prop = { 0, };
-
- g_value_init (&disp_par_prop, pspec->value_type);
- g_object_get_property (G_OBJECT (bvw->priv->xoverlay),
- "pixel-aspect-ratio",
- &disp_par_prop);
-
- if (!g_value_transform (&disp_par_prop, disp_par))
- {
- GST_WARNING
- ("Transform failed, assuming pixel-aspect-ratio = 1/1");
- gst_value_set_fraction (disp_par, 1, 1);
- }
-
- g_value_unset (&disp_par_prop);
- }
- }
-
- disp_par_n = gst_value_get_fraction_numerator (disp_par);
- disp_par_d = gst_value_get_fraction_denominator (disp_par);
-
- GST_DEBUG ("display PAR is %d/%d", disp_par_n, disp_par_d);
-
- /* If movie pixel aspect ratio is enforced, use that */
- if (bvw->priv->ratio_type != BVW_RATIO_AUTO)
- {
- switch (bvw->priv->ratio_type)
- {
- case BVW_RATIO_SQUARE:
- movie_par_n = 1;
- movie_par_d = 1;
- break;
- case BVW_RATIO_FOURBYTHREE:
- movie_par_n = 4 * bvw->priv->video_height;
- movie_par_d = 3 * bvw->priv->video_width;
- break;
- case BVW_RATIO_ANAMORPHIC:
- movie_par_n = 16 * bvw->priv->video_height;
- movie_par_d = 9 * bvw->priv->video_width;
- break;
- case BVW_RATIO_DVB:
- movie_par_n = 20 * bvw->priv->video_height;
- movie_par_d = 9 * bvw->priv->video_width;
- break;
- /* handle these to avoid compiler warnings */
- case BVW_RATIO_AUTO:
- default:
- movie_par_n = 0;
- movie_par_d = 0;
- g_assert_not_reached ();
- }
- }
- else
- {
- /* Use the movie pixel aspect ratio if any */
- if (bvw->priv->movie_par)
- {
- movie_par_n =
- gst_value_get_fraction_numerator (bvw->priv->movie_par);
- movie_par_d =
- gst_value_get_fraction_denominator (bvw->priv->movie_par);
- }
- else
- {
- /* Square pixels */
- movie_par_n = 1;
- movie_par_d = 1;
- }
- }
-
- GST_DEBUG ("movie PAR is %d/%d", movie_par_n, movie_par_d);
-
- if (bvw->priv->video_width == 0 || bvw->priv->video_height == 0)
- {
- GST_DEBUG ("width and/or height 0, assuming 1/1 ratio");
- num = 1;
- den = 1;
- }
- else if (!gst_video_calculate_display_ratio (&num, &den,
- bvw->priv->video_width,
- bvw->priv->
- video_height,
- movie_par_n,
- movie_par_d,
- disp_par_n,
- disp_par_d))
- {
- GST_WARNING ("overflow calculating display aspect ratio!");
- num = 1; /* FIXME: what values to use here? */
- den = 1;
- }
-
- GST_DEBUG ("calculated scaling ratio %d/%d for video %dx%d", num,
- den, bvw->priv->video_width, bvw->priv->video_height);
-
- /* now find a width x height that respects this display ratio.
- * prefer those that have one of w/h the same as the incoming video
- * using wd / hd = num / den */
-
- /* start with same height, because of interlaced video */
- /* check hd / den is an integer scale factor, and scale wd with the PAR */
- if (bvw->priv->video_height % den == 0)
- {
- GST_DEBUG ("keeping video height");
- bvw->priv->video_width_pixels =
- (guint) gst_util_uint64_scale (bvw->priv->video_height, num,
- den);
- bvw->priv->video_height_pixels = bvw->priv->video_height;
- }
- else if (bvw->priv->video_width % num == 0)
- {
- GST_DEBUG ("keeping video width");
- bvw->priv->video_width_pixels = bvw->priv->video_width;
- bvw->priv->video_height_pixels =
- (guint) gst_util_uint64_scale (bvw->priv->video_width, den,
- num);
- }
- else
- {
- GST_DEBUG ("approximating while keeping video height");
- bvw->priv->video_width_pixels =
- (guint) gst_util_uint64_scale (bvw->priv->video_height, num,
- den);
- bvw->priv->video_height_pixels = bvw->priv->video_height;
- }
- GST_DEBUG ("scaling to %dx%d", bvw->priv->video_width_pixels,
- bvw->priv->video_height_pixels);
-
- *width = bvw->priv->video_width_pixels;
- *height = bvw->priv->video_height_pixels;
-
- /* Free the PAR fraction */
- g_value_unset (disp_par);
- g_free (disp_par);
- }
- else
- {
- *width = 0;
- *height = 0;
- }
+ } else {
+ if (bvw->priv->media_has_video) {
+ GValue *disp_par = NULL;
+ guint movie_par_n, movie_par_d, disp_par_n, disp_par_d, num, den;
+
+ /* Create and init the fraction value */
+ disp_par = g_new0 (GValue, 1);
+ g_value_init (disp_par, GST_TYPE_FRACTION);
+
+ /* Square pixel is our default */
+ gst_value_set_fraction (disp_par, 1, 1);
+
+ /* Now try getting display's pixel aspect ratio */
+ if (bvw->priv->xoverlay) {
+ GObjectClass *klass;
+ GParamSpec *pspec;
+
+ klass = G_OBJECT_GET_CLASS (bvw->priv->xoverlay);
+ pspec = g_object_class_find_property (klass, "pixel-aspect-ratio");
+
+ if (pspec != NULL) {
+ GValue disp_par_prop = { 0, };
+
+ g_value_init (&disp_par_prop, pspec->value_type);
+ g_object_get_property (G_OBJECT (bvw->priv->xoverlay),
+ "pixel-aspect-ratio", &disp_par_prop);
+
+ if (!g_value_transform (&disp_par_prop, disp_par)) {
+ GST_WARNING ("Transform failed, assuming pixel-aspect-ratio = 1/1");
+ gst_value_set_fraction (disp_par, 1, 1);
+ }
+
+ g_value_unset (&disp_par_prop);
+ }
+ }
+
+ disp_par_n = gst_value_get_fraction_numerator (disp_par);
+ disp_par_d = gst_value_get_fraction_denominator (disp_par);
+
+ GST_DEBUG ("display PAR is %d/%d", disp_par_n, disp_par_d);
+
+ /* If movie pixel aspect ratio is enforced, use that */
+ if (bvw->priv->ratio_type != BVW_RATIO_AUTO) {
+ switch (bvw->priv->ratio_type) {
+ case BVW_RATIO_SQUARE:
+ movie_par_n = 1;
+ movie_par_d = 1;
+ break;
+ case BVW_RATIO_FOURBYTHREE:
+ movie_par_n = 4 * bvw->priv->video_height;
+ movie_par_d = 3 * bvw->priv->video_width;
+ break;
+ case BVW_RATIO_ANAMORPHIC:
+ movie_par_n = 16 * bvw->priv->video_height;
+ movie_par_d = 9 * bvw->priv->video_width;
+ break;
+ case BVW_RATIO_DVB:
+ movie_par_n = 20 * bvw->priv->video_height;
+ movie_par_d = 9 * bvw->priv->video_width;
+ break;
+ /* handle these to avoid compiler warnings */
+ case BVW_RATIO_AUTO:
+ default:
+ movie_par_n = 0;
+ movie_par_d = 0;
+ g_assert_not_reached ();
+ }
+ } else {
+ /* Use the movie pixel aspect ratio if any */
+ if (bvw->priv->movie_par) {
+ movie_par_n = gst_value_get_fraction_numerator (bvw->priv->movie_par);
+ movie_par_d =
+ gst_value_get_fraction_denominator (bvw->priv->movie_par);
+ } else {
+ /* Square pixels */
+ movie_par_n = 1;
+ movie_par_d = 1;
+ }
+ }
+
+ GST_DEBUG ("movie PAR is %d/%d", movie_par_n, movie_par_d);
+
+ if (bvw->priv->video_width == 0 || bvw->priv->video_height == 0) {
+ GST_DEBUG ("width and/or height 0, assuming 1/1 ratio");
+ num = 1;
+ den = 1;
+ } else if (!gst_video_calculate_display_ratio (&num, &den,
+ bvw->priv->video_width,
+ bvw->priv->video_height,
+ movie_par_n, movie_par_d, disp_par_n, disp_par_d)) {
+ GST_WARNING ("overflow calculating display aspect ratio!");
+ num = 1; /* FIXME: what values to use here? */
+ den = 1;
+ }
+
+ GST_DEBUG ("calculated scaling ratio %d/%d for video %dx%d", num,
+ den, bvw->priv->video_width, bvw->priv->video_height);
+
+ /* now find a width x height that respects this display ratio.
+ * prefer those that have one of w/h the same as the incoming video
+ * using wd / hd = num / den */
+
+ /* start with same height, because of interlaced video */
+ /* check hd / den is an integer scale factor, and scale wd with the PAR */
+ if (bvw->priv->video_height % den == 0) {
+ GST_DEBUG ("keeping video height");
+ bvw->priv->video_width_pixels =
+ (guint) gst_util_uint64_scale (bvw->priv->video_height, num, den);
+ bvw->priv->video_height_pixels = bvw->priv->video_height;
+ } else if (bvw->priv->video_width % num == 0) {
+ GST_DEBUG ("keeping video width");
+ bvw->priv->video_width_pixels = bvw->priv->video_width;
+ bvw->priv->video_height_pixels =
+ (guint) gst_util_uint64_scale (bvw->priv->video_width, den, num);
+ } else {
+ GST_DEBUG ("approximating while keeping video height");
+ bvw->priv->video_width_pixels =
+ (guint) gst_util_uint64_scale (bvw->priv->video_height, num, den);
+ bvw->priv->video_height_pixels = bvw->priv->video_height;
+ }
+ GST_DEBUG ("scaling to %dx%d", bvw->priv->video_width_pixels,
+ bvw->priv->video_height_pixels);
+
+ *width = bvw->priv->video_width_pixels;
+ *height = bvw->priv->video_height_pixels;
+
+ /* Free the PAR fraction */
+ g_value_unset (disp_par);
+ g_free (disp_par);
+ } else {
+ *width = 0;
+ *height = 0;
}
+ }
}
static void
@@ -561,7 +508,7 @@ bacon_video_widget_realize (GtkWidget * widget)
GdkEventMask event_mask;
event_mask = gtk_widget_get_events (widget)
- | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK;
+ | GDK_POINTER_MOTION_MASK | GDK_KEY_PRESS_MASK;
gtk_widget_set_events (widget, event_mask);
GTK_WIDGET_CLASS (parent_class)->realize (widget);
@@ -577,31 +524,29 @@ bacon_video_widget_realize (GtkWidget * widget)
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_EXPOSURE_MASK |
- GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK;
+ GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
bvw->priv->video_window = gdk_window_new (window,
- &attributes, attributes_mask);
+ &attributes, attributes_mask);
gdk_window_set_user_data (bvw->priv->video_window, widget);
gdk_color_parse ("black", &colour);
gdk_colormap_alloc_color (gtk_widget_get_colormap (widget),
- &colour, TRUE, TRUE);
+ &colour, TRUE, TRUE);
gdk_window_set_background (window, &colour);
gtk_widget_set_style (widget,
- gtk_style_attach (gtk_widget_get_style (widget),
- window));
+ gtk_style_attach (gtk_widget_get_style (widget), window));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
/* Connect to configure event on the top level window */
g_signal_connect (G_OBJECT (gtk_widget_get_toplevel (widget)),
- "configure-event",
- G_CALLBACK (bacon_video_widget_configure_event), bvw);
+ "configure-event", G_CALLBACK (bacon_video_widget_configure_event), bvw);
/* get screen size changes */
g_signal_connect (G_OBJECT (gtk_widget_get_screen (widget)),
- "size-changed", G_CALLBACK (size_changed_cb), bvw);
+ "size-changed", G_CALLBACK (size_changed_cb), bvw);
/* nice hack to show the logo fullsize, while still being resizable */
get_media_size (BACON_VIDEO_WIDGET (widget), &w, &h);
@@ -659,8 +604,7 @@ bacon_video_widget_hide (GtkWidget * widget)
static gboolean
bacon_video_widget_configure_event (GtkWidget * widget,
- GdkEventConfigure * event,
- BaconVideoWidget * bvw)
+ GdkEventConfigure * event, BaconVideoWidget * bvw)
{
GstXOverlay *xoverlay = NULL;
@@ -669,10 +613,9 @@ bacon_video_widget_configure_event (GtkWidget * widget,
xoverlay = bvw->priv->xoverlay;
- if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay))
- {
- gst_x_overlay_expose (xoverlay);
- }
+ if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay)) {
+ gst_x_overlay_expose (xoverlay);
+ }
return FALSE;
}
@@ -697,166 +640,137 @@ bacon_video_widget_expose_event (GtkWidget * widget, GdkEventExpose * event)
g_mutex_lock (bvw->priv->lock);
xoverlay = bvw->priv->xoverlay;
- if (xoverlay == NULL)
- {
- bvw_update_interface_implementations (bvw);
- xoverlay = bvw->priv->xoverlay;
- }
+ if (xoverlay == NULL) {
+ bvw_update_interface_implementations (bvw);
+ xoverlay = bvw->priv->xoverlay;
+ }
if (xoverlay != NULL)
gst_object_ref (xoverlay);
g_mutex_unlock (bvw->priv->lock);
- if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay))
- {
+ if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay)) {
#ifdef WIN32
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_HWND (bvw->priv->
- video_window));
+ gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
+ GDK_WINDOW_HWND (bvw->priv->video_window));
#else
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_XID (bvw->priv->video_window));
+ gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
+ GDK_WINDOW_XID (bvw->priv->video_window));
#endif
- }
+ }
/* Start with a nice black canvas */
win = gtk_widget_get_window (widget);
gdk_draw_rectangle (win, gtk_widget_get_style (widget)->black_gc, TRUE, 0,
- 0, widget->allocation.width, widget->allocation.height);
+ 0, widget->allocation.width, widget->allocation.height);
/* if there's only audio and no visualisation, draw the logo as well */
draw_logo = bvw->priv->media_has_audio && !bvw->priv->media_has_video;
- if (bvw->priv->logo_mode || draw_logo)
- {
- if (bvw->priv->logo_pixbuf != NULL)
- {
- GdkPixbuf *frame;
- GdkPixbuf *drawing;
- guchar *pixels;
- int rowstride;
- gint width, height, alloc_width, alloc_height, logo_x, logo_y;
- gfloat ratio;
-
- /* Checking if allocated space is smaller than our logo */
-
-
- width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf);
- height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf);
- alloc_width = widget->allocation.width;
- alloc_height = widget->allocation.height;
-
- if ((gfloat) alloc_width / width > (gfloat) alloc_height / height)
- {
- ratio = (gfloat) alloc_height / height;
- }
- else
- {
- ratio = (gfloat) alloc_width / width;
- }
-
- width *= ratio;
- height *= ratio;
-
- logo_x = (alloc_width / 2) - (width / 2);
- logo_y = (alloc_height / 2) - (height / 2);
-
-
- /* Drawing our frame */
-
- if (bvw->priv->expand_logo && !bvw->priv->drawing_mode)
- {
- /* Scaling to available space */
-
- frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE, 8, widget->allocation.width,
- widget->allocation.height);
-
- gdk_pixbuf_composite (bvw->priv->logo_pixbuf,
- frame,
- 0, 0,
- alloc_width, alloc_height,
- logo_x, logo_y, ratio, ratio,
- GDK_INTERP_BILINEAR, 255);
-
- rowstride = gdk_pixbuf_get_rowstride (frame);
-
- pixels = gdk_pixbuf_get_pixels (frame) +
- rowstride * event->area.y + event->area.x * 3;
-
- gdk_draw_rgb_image_dithalign (widget->window,
- widget->style->black_gc,
- event->area.x, event->area.y,
- event->area.width,
- event->area.height,
- GDK_RGB_DITHER_NORMAL, pixels,
- rowstride, event->area.x,
- event->area.y);
-
- g_object_unref (frame);
- }
- else
- {
- gdk_window_clear_area (win,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
-
- if (width <= 1 || height <= 1)
- {
- if (xoverlay != NULL)
- gst_object_unref (xoverlay);
- gdk_window_end_paint (win);
- return TRUE;
- }
-
- frame = gdk_pixbuf_scale_simple (bvw->priv->logo_pixbuf,
- width, height,
- GDK_INTERP_BILINEAR);
- gdk_draw_pixbuf (win, gtk_widget_get_style (widget)->fg_gc[0],
- frame, 0, 0, logo_x, logo_y, width, height,
- GDK_RGB_DITHER_NONE, 0, 0);
-
- if (bvw->priv->drawing_mode
- && bvw->priv->drawing_pixbuf != NULL)
- {
- drawing =
- gdk_pixbuf_scale_simple (bvw->priv->drawing_pixbuf, width,
- height, GDK_INTERP_BILINEAR);
- gdk_draw_pixbuf (win,
- gtk_widget_get_style (widget)->fg_gc[0],
- drawing, 0, 0, logo_x, logo_y, width,
- height, GDK_RGB_DITHER_NONE, 0, 0);
- g_object_unref (drawing);
- }
-
- g_object_unref (frame);
- }
- }
- else if (win)
- {
- /* No pixbuf, just draw a black background then */
- gdk_window_clear_area (win,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
- }
- }
- else
- {
- /* no logo, pass the expose to gst */
- if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay))
- gst_x_overlay_expose (xoverlay);
- else
- {
- /* No xoverlay to expose yet */
- gdk_window_clear_area (win,
- 0, 0,
- widget->allocation.width,
- widget->allocation.height);
- }
+ if (bvw->priv->logo_mode || draw_logo) {
+ if (bvw->priv->logo_pixbuf != NULL) {
+ GdkPixbuf *frame;
+ GdkPixbuf *drawing;
+ guchar *pixels;
+ int rowstride;
+ gint width, height, alloc_width, alloc_height, logo_x, logo_y;
+ gfloat ratio;
+
+ /* Checking if allocated space is smaller than our logo */
+
+
+ width = gdk_pixbuf_get_width (bvw->priv->logo_pixbuf);
+ height = gdk_pixbuf_get_height (bvw->priv->logo_pixbuf);
+ alloc_width = widget->allocation.width;
+ alloc_height = widget->allocation.height;
+
+ if ((gfloat) alloc_width / width > (gfloat) alloc_height / height) {
+ ratio = (gfloat) alloc_height / height;
+ } else {
+ ratio = (gfloat) alloc_width / width;
+ }
+
+ width *= ratio;
+ height *= ratio;
+
+ logo_x = (alloc_width / 2) - (width / 2);
+ logo_y = (alloc_height / 2) - (height / 2);
+
+
+ /* Drawing our frame */
+
+ if (bvw->priv->expand_logo && !bvw->priv->drawing_mode) {
+ /* Scaling to available space */
+
+ frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ FALSE, 8, widget->allocation.width, widget->allocation.height);
+
+ gdk_pixbuf_composite (bvw->priv->logo_pixbuf,
+ frame,
+ 0, 0,
+ alloc_width, alloc_height,
+ logo_x, logo_y, ratio, ratio, GDK_INTERP_BILINEAR, 255);
+
+ rowstride = gdk_pixbuf_get_rowstride (frame);
+
+ pixels = gdk_pixbuf_get_pixels (frame) +
+ rowstride * event->area.y + event->area.x * 3;
+
+ gdk_draw_rgb_image_dithalign (widget->window,
+ widget->style->black_gc,
+ event->area.x, event->area.y,
+ event->area.width,
+ event->area.height,
+ GDK_RGB_DITHER_NORMAL, pixels,
+ rowstride, event->area.x, event->area.y);
+
+ g_object_unref (frame);
+ } else {
+ gdk_window_clear_area (win,
+ 0, 0, widget->allocation.width, widget->allocation.height);
+
+ if (width <= 1 || height <= 1) {
+ if (xoverlay != NULL)
+ gst_object_unref (xoverlay);
+ gdk_window_end_paint (win);
+ return TRUE;
+ }
+
+ frame = gdk_pixbuf_scale_simple (bvw->priv->logo_pixbuf,
+ width, height, GDK_INTERP_BILINEAR);
+ gdk_draw_pixbuf (win, gtk_widget_get_style (widget)->fg_gc[0],
+ frame, 0, 0, logo_x, logo_y, width, height,
+ GDK_RGB_DITHER_NONE, 0, 0);
+
+ if (bvw->priv->drawing_mode && bvw->priv->drawing_pixbuf != NULL) {
+ drawing =
+ gdk_pixbuf_scale_simple (bvw->priv->drawing_pixbuf, width,
+ height, GDK_INTERP_BILINEAR);
+ gdk_draw_pixbuf (win,
+ gtk_widget_get_style (widget)->fg_gc[0],
+ drawing, 0, 0, logo_x, logo_y, width,
+ height, GDK_RGB_DITHER_NONE, 0, 0);
+ g_object_unref (drawing);
+ }
+
+ g_object_unref (frame);
+ }
+ } else if (win) {
+ /* No pixbuf, just draw a black background then */
+ gdk_window_clear_area (win,
+ 0, 0, widget->allocation.width, widget->allocation.height);
+ }
+ } else {
+ /* no logo, pass the expose to gst */
+ if (xoverlay != NULL && GST_IS_X_OVERLAY (xoverlay))
+ gst_x_overlay_expose (xoverlay);
+ else {
+ /* No xoverlay to expose yet */
+ gdk_window_clear_area (win,
+ 0, 0, widget->allocation.width, widget->allocation.height);
}
+ }
if (xoverlay != NULL)
gst_object_unref (xoverlay);
@@ -889,20 +803,17 @@ bacon_video_widget_motion_notify (GtkWidget * widget, GdkEventMotion * event)
g_return_val_if_fail (bvw->priv->play != NULL, FALSE);
- if (!bvw->priv->logo_mode)
- {
- GstNavigation *nav = bvw_get_navigation_iface (bvw);
- if (nav)
- {
- gst_navigation_send_mouse_event (nav, "mouse-move", 0, event->x,
- event->y);
- gst_object_unref (GST_OBJECT (nav));
- }
+ if (!bvw->priv->logo_mode) {
+ GstNavigation *nav = bvw_get_navigation_iface (bvw);
+ if (nav) {
+ gst_navigation_send_mouse_event (nav, "mouse-move", 0, event->x,
+ event->y);
+ gst_object_unref (GST_OBJECT (nav));
}
+ }
if (GTK_WIDGET_CLASS (parent_class)->motion_notify_event)
- res |=
- GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
+ res |= GTK_WIDGET_CLASS (parent_class)->motion_notify_event (widget, event);
return res;
}
@@ -915,25 +826,21 @@ bacon_video_widget_button_press (GtkWidget * widget, GdkEventButton * event)
g_return_val_if_fail (bvw->priv->play != NULL, FALSE);
- if (!bvw->priv->logo_mode)
- {
- GstNavigation *nav = bvw_get_navigation_iface (bvw);
- if (nav)
- {
- gst_navigation_send_mouse_event (nav,
- "mouse-button-press",
- event->button, event->x, event->y);
- gst_object_unref (GST_OBJECT (nav));
-
- /* FIXME need to check whether the backend will have handled
- * the button press
- res = TRUE; */
- }
+ if (!bvw->priv->logo_mode) {
+ GstNavigation *nav = bvw_get_navigation_iface (bvw);
+ if (nav) {
+ gst_navigation_send_mouse_event (nav,
+ "mouse-button-press", event->button, event->x, event->y);
+ gst_object_unref (GST_OBJECT (nav));
+
+ /* FIXME need to check whether the backend will have handled
+ * the button press
+ res = TRUE; */
}
+ }
if (GTK_WIDGET_CLASS (parent_class)->button_press_event)
- res |=
- GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
+ res |= GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event);
return res;
}
@@ -946,30 +853,27 @@ bacon_video_widget_button_release (GtkWidget * widget, GdkEventButton * event)
g_return_val_if_fail (bvw->priv->play != NULL, FALSE);
- if (!bvw->priv->logo_mode)
- {
- GstNavigation *nav = bvw_get_navigation_iface (bvw);
- if (nav)
- {
- gst_navigation_send_mouse_event (nav,
- "mouse-button-release",
- event->button, event->x, event->y);
- gst_object_unref (GST_OBJECT (nav));
-
- res = TRUE;
- }
+ if (!bvw->priv->logo_mode) {
+ GstNavigation *nav = bvw_get_navigation_iface (bvw);
+ if (nav) {
+ gst_navigation_send_mouse_event (nav,
+ "mouse-button-release", event->button, event->x, event->y);
+ gst_object_unref (GST_OBJECT (nav));
+
+ res = TRUE;
}
+ }
if (GTK_WIDGET_CLASS (parent_class)->button_release_event)
res |=
- GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
+ GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
return res;
}
static void
bacon_video_widget_size_request (GtkWidget * widget,
- GtkRequisition * requisition)
+ GtkRequisition * requisition)
{
requisition->width = 240;
requisition->height = 180;
@@ -988,24 +892,19 @@ resize_video_window (BaconVideoWidget * bvw)
allocation = >K_WIDGET (bvw)->allocation;
get_media_size (bvw, &w, &h);
- if (!w || !h)
- {
- w = allocation->width;
- h = allocation->height;
- }
+ if (!w || !h) {
+ w = allocation->width;
+ h = allocation->height;
+ }
width = w;
height = h;
/* calculate ratio for fitting video into the available space */
- if ((gfloat) allocation->width / width >
- (gfloat) allocation->height / height)
- {
- ratio = (gfloat) allocation->height / height;
- }
- else
- {
- ratio = (gfloat) allocation->width / width;
- }
+ if ((gfloat) allocation->width / width > (gfloat) allocation->height / height) {
+ ratio = (gfloat) allocation->height / height;
+ } else {
+ ratio = (gfloat) allocation->width / width;
+ }
/* apply zoom factor */
ratio = ratio * bvw->priv->zoom;
@@ -1021,7 +920,7 @@ resize_video_window (BaconVideoWidget * bvw)
static void
bacon_video_widget_size_allocate (GtkWidget * widget,
- GtkAllocation * allocation)
+ GtkAllocation * allocation)
{
BaconVideoWidget *bvw = BACON_VIDEO_WIDGET (widget);
@@ -1030,23 +929,19 @@ bacon_video_widget_size_allocate (GtkWidget * widget,
widget->allocation = *allocation;
- if (GTK_WIDGET_REALIZED (widget))
- {
+ if (GTK_WIDGET_REALIZED (widget)) {
- gdk_window_move_resize (gtk_widget_get_window (widget),
- allocation->x, allocation->y,
- allocation->width, allocation->height);
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x, allocation->y, allocation->width, allocation->height);
- resize_video_window (bvw);
- }
+ resize_video_window (bvw);
+ }
}
static gboolean
bvw_boolean_handled_accumulator (GSignalInvocationHint * ihint,
- GValue * return_accu,
- const GValue * handler_return,
- gpointer foobar)
+ GValue * return_accu, const GValue * handler_return, gpointer foobar)
{
gboolean continue_emission;
gboolean signal_handled;
@@ -1091,138 +986,119 @@ bacon_video_widget_class_init (BaconVideoWidgetClass * klass)
/* Properties */
g_object_class_install_property (object_class, PROP_LOGO_MODE,
- g_param_spec_boolean ("logo_mode", NULL,
- NULL, FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("logo_mode", NULL, NULL, FALSE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_EXPAND_LOGO,
- g_param_spec_boolean ("expand_logo", NULL,
- NULL, TRUE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("expand_logo", NULL,
+ NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_POSITION,
- g_param_spec_int ("position", NULL, NULL,
- 0, G_MAXINT, 0,
- G_PARAM_READABLE));
+ g_param_spec_int ("position", NULL, NULL,
+ 0, G_MAXINT, 0, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_STREAM_LENGTH,
- g_param_spec_int64 ("stream_length", NULL,
- NULL, 0, G_MAXINT64, 0,
- G_PARAM_READABLE));
+ g_param_spec_int64 ("stream_length", NULL,
+ NULL, 0, G_MAXINT64, 0, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_PLAYING,
- g_param_spec_boolean ("playing", NULL,
- NULL, FALSE,
- G_PARAM_READABLE));
+ g_param_spec_boolean ("playing", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_SEEKABLE,
- g_param_spec_boolean ("seekable", NULL,
- NULL, FALSE,
- G_PARAM_READABLE));
+ g_param_spec_boolean ("seekable", NULL, NULL, FALSE, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_VOLUME,
- g_param_spec_int ("volume", NULL, NULL,
- 0, 100, 0,
- G_PARAM_READABLE));
+ g_param_spec_int ("volume", NULL, NULL, 0, 100, 0, G_PARAM_READABLE));
g_object_class_install_property (object_class, PROP_SHOW_CURSOR,
- g_param_spec_boolean ("showcursor", NULL,
- NULL, FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("showcursor", NULL,
+ NULL, FALSE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_MEDIADEV,
- g_param_spec_string ("mediadev", NULL,
- NULL, FALSE,
- G_PARAM_READWRITE));
+ g_param_spec_string ("mediadev", NULL, NULL, FALSE, G_PARAM_READWRITE));
/* Signals */
bvw_signals[SIGNAL_ERROR] =
- g_signal_new ("error",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, error),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("error",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, error),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
bvw_signals[SIGNAL_EOS] =
- g_signal_new ("eos",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, eos),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("eos",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, eos),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_SEGMENT_DONE] =
- g_signal_new ("segment_done",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, segment_done),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("segment_done",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, segment_done),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_READY_TO_SEEK] =
- g_signal_new ("ready_to_seek",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, ready_to_seek),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("ready_to_seek",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, ready_to_seek),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_GOT_DURATION] =
- g_signal_new ("got_duration",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, got_duration),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("got_duration",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, got_duration),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_GOT_METADATA] =
- g_signal_new ("got-metadata",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, got_metadata),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("got-metadata",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, got_metadata),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_REDIRECT] =
- g_signal_new ("got-redirect",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, got_redirect),
- NULL, NULL, g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("got-redirect",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, got_redirect),
+ NULL, NULL, g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
bvw_signals[SIGNAL_TITLE_CHANGE] =
- g_signal_new ("title-change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, title_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("title-change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, title_change),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
bvw_signals[SIGNAL_CHANNELS_CHANGE] =
- g_signal_new ("channels-change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, channels_change),
- NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+ g_signal_new ("channels-change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, channels_change),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
bvw_signals[SIGNAL_TICK] =
- g_signal_new ("tick",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, tick),
- NULL, NULL,
- baconvideowidget_marshal_VOID__INT64_INT64_FLOAT_BOOLEAN,
- G_TYPE_NONE, 4, G_TYPE_INT64, G_TYPE_INT64, G_TYPE_FLOAT,
- G_TYPE_BOOLEAN);
+ g_signal_new ("tick",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, tick),
+ NULL, NULL,
+ baconvideowidget_marshal_VOID__INT64_INT64_FLOAT_BOOLEAN,
+ G_TYPE_NONE, 4, G_TYPE_INT64, G_TYPE_INT64, G_TYPE_FLOAT, G_TYPE_BOOLEAN);
bvw_signals[SIGNAL_BUFFERING] =
- g_signal_new ("buffering",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, buffering),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
+ g_signal_new ("buffering",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, buffering),
+ NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
bvw_signals[SIGNAL_STATE_CHANGE] =
- g_signal_new ("state_change",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (BaconVideoWidgetClass, state_change),
- NULL, NULL,
- g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ g_signal_new ("state_change",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (BaconVideoWidgetClass, state_change),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
/* missing plugins signal:
* - string array: details of missing plugins for libgimme-codec
@@ -1231,14 +1107,11 @@ bacon_video_widget_class_init (BaconVideoWidgetClass * klass)
* return value: callback must return TRUE to indicate that it took some
* action, FALSE will be interpreted as no action taken
*/
- bvw_signals[SIGNAL_MISSING_PLUGINS] = g_signal_new ("missing-plugins", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, 0, /* signal is enough, we don't need a vfunc */
- bvw_boolean_handled_accumulator,
- NULL,
- baconvideowidget_marshal_BOOLEAN__BOXED_BOXED_BOOLEAN,
- G_TYPE_BOOLEAN, 3,
- G_TYPE_STRV,
- G_TYPE_STRV,
- G_TYPE_BOOLEAN);
+ bvw_signals[SIGNAL_MISSING_PLUGINS] = g_signal_new ("missing-plugins", G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, 0, /* signal is enough, we don't need a vfunc */
+ bvw_boolean_handled_accumulator,
+ NULL,
+ baconvideowidget_marshal_BOOLEAN__BOXED_BOXED_BOOLEAN,
+ G_TYPE_BOOLEAN, 3, G_TYPE_STRV, G_TYPE_STRV, G_TYPE_BOOLEAN);
}
static void
@@ -1250,8 +1123,8 @@ bacon_video_widget_init (BaconVideoWidget * bvw)
GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
bvw->priv = priv =
- G_TYPE_INSTANCE_GET_PRIVATE (bvw, BACON_TYPE_VIDEO_WIDGET,
- BaconVideoWidgetPrivate);
+ G_TYPE_INSTANCE_GET_PRIVATE (bvw, BACON_TYPE_VIDEO_WIDGET,
+ BaconVideoWidgetPrivate);
priv->update_id = 0;
priv->tagcache = NULL;
@@ -1285,11 +1158,10 @@ bvw_update_stream_info (BaconVideoWidget * bvw)
/* if we're not interactive, we want to announce metadata
* only later when we can be sure we got it all */
if (bvw->priv->use_type == BVW_USE_TYPE_VIDEO ||
- bvw->priv->use_type == BVW_USE_TYPE_AUDIO)
- {
- g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
- g_signal_emit (bvw, bvw_signals[SIGNAL_CHANNELS_CHANGE], 0);
- }
+ bvw->priv->use_type == BVW_USE_TYPE_AUDIO) {
+ g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_CHANNELS_CHANGE], 0);
+ }
}
static void
@@ -1301,51 +1173,40 @@ bvw_handle_application_message (BaconVideoWidget * bvw, GstMessage * msg)
msg_name = gst_structure_get_name (msg->structure);
g_return_if_fail (msg_name != NULL);
- GST_DEBUG ("Handling application message: %" GST_PTR_FORMAT,
- msg->structure);
+ GST_DEBUG ("Handling application message: %" GST_PTR_FORMAT, msg->structure);
- if (strcmp (msg_name, "stream-changed") == 0)
- {
- bvw_update_stream_info (bvw);
- }
- else if (strcmp (msg_name, "video-size") == 0)
- {
- /* if we're not interactive, we want to announce metadata
- * only later when we can be sure we got it all */
- if (bvw->priv->use_type == BVW_USE_TYPE_VIDEO ||
- bvw->priv->use_type == BVW_USE_TYPE_AUDIO)
- {
- g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
- }
-
- if (bvw->priv->auto_resize
- && !bvw->priv->fullscreen_mode && !bvw->priv->window_resized)
- {
- bacon_video_widget_set_scale_ratio (bvw, 1);
- }
- else
- {
- bacon_video_widget_size_allocate (GTK_WIDGET (bvw),
- >K_WIDGET (bvw)->allocation);
-
- /* Uhm, so this ugly hack here makes media loading work for
- * weird laptops with NVIDIA graphics cards... Dunno what the
- * bug is really, but hey, it works. :). */
- window = gtk_widget_get_window (GTK_WIDGET (bvw));
- if (window)
- {
- gdk_window_hide (window);
- gdk_window_show (window);
-
- bacon_video_widget_expose_event (GTK_WIDGET (bvw), NULL);
- }
- }
- bvw->priv->window_resized = TRUE;
+ if (strcmp (msg_name, "stream-changed") == 0) {
+ bvw_update_stream_info (bvw);
+ } else if (strcmp (msg_name, "video-size") == 0) {
+ /* if we're not interactive, we want to announce metadata
+ * only later when we can be sure we got it all */
+ if (bvw->priv->use_type == BVW_USE_TYPE_VIDEO ||
+ bvw->priv->use_type == BVW_USE_TYPE_AUDIO) {
+ g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
}
- else
- {
- g_message ("Unhandled application message %s", msg_name);
+
+ if (bvw->priv->auto_resize
+ && !bvw->priv->fullscreen_mode && !bvw->priv->window_resized) {
+ bacon_video_widget_set_scale_ratio (bvw, 1);
+ } else {
+ bacon_video_widget_size_allocate (GTK_WIDGET (bvw),
+ >K_WIDGET (bvw)->allocation);
+
+ /* Uhm, so this ugly hack here makes media loading work for
+ * weird laptops with NVIDIA graphics cards... Dunno what the
+ * bug is really, but hey, it works. :). */
+ window = gtk_widget_get_window (GTK_WIDGET (bvw));
+ if (window) {
+ gdk_window_hide (window);
+ gdk_window_show (window);
+
+ bacon_video_widget_expose_event (GTK_WIDGET (bvw), NULL);
+ }
}
+ bvw->priv->window_resized = TRUE;
+ } else {
+ g_message ("Unhandled application message %s", msg_name);
+ }
}
static void
@@ -1363,87 +1224,69 @@ bvw_handle_element_message (BaconVideoWidget * bvw, GstMessage * msg)
if (type_name == NULL)
goto unhandled;
- if (strcmp (type_name, "redirect") == 0)
- {
- const gchar *new_location;
+ if (strcmp (type_name, "redirect") == 0) {
+ const gchar *new_location;
- new_location =
- gst_structure_get_string (msg->structure, "new-location");
- GST_DEBUG ("Got redirect to '%s'", GST_STR_NULL (new_location));
+ new_location = gst_structure_get_string (msg->structure, "new-location");
+ GST_DEBUG ("Got redirect to '%s'", GST_STR_NULL (new_location));
- if (new_location && *new_location)
- {
- g_signal_emit (bvw, bvw_signals[SIGNAL_REDIRECT], 0, new_location);
- goto done;
- }
- }
- else if (strcmp (type_name, "progress") == 0)
- {
- /* this is similar to buffering messages, but shouldn't affect pipeline
- * state; qtdemux emits those when headers are after movie data and
- * it is in streaming mode and has to receive all the movie data first */
- if (!bvw->priv->buffering)
- {
- gint percent = 0;
-
- if (gst_structure_get_int (msg->structure, "percent", &percent))
- g_signal_emit (bvw, bvw_signals[SIGNAL_BUFFERING], 0, percent);
- }
+ if (new_location && *new_location) {
+ g_signal_emit (bvw, bvw_signals[SIGNAL_REDIRECT], 0, new_location);
goto done;
}
- else if (strcmp (type_name, "prepare-xwindow-id") == 0 ||
- strcmp (type_name, "have-xwindow-id") == 0)
- {
- /* we handle these synchronously or want to ignore them */
- goto done;
- }
- else if (gst_is_missing_plugin_message (msg))
- {
- bvw->priv->missing_plugins =
- g_list_prepend (bvw->priv->missing_plugins, gst_message_ref (msg));
- goto done;
- }
- else
- {
+ } else if (strcmp (type_name, "progress") == 0) {
+ /* this is similar to buffering messages, but shouldn't affect pipeline
+ * state; qtdemux emits those when headers are after movie data and
+ * it is in streaming mode and has to receive all the movie data first */
+ if (!bvw->priv->buffering) {
+ gint percent = 0;
+
+ if (gst_structure_get_int (msg->structure, "percent", &percent))
+ g_signal_emit (bvw, bvw_signals[SIGNAL_BUFFERING], 0, percent);
+ }
+ goto done;
+ } else if (strcmp (type_name, "prepare-xwindow-id") == 0 ||
+ strcmp (type_name, "have-xwindow-id") == 0) {
+ /* we handle these synchronously or want to ignore them */
+ goto done;
+ } else if (gst_is_missing_plugin_message (msg)) {
+ bvw->priv->missing_plugins =
+ g_list_prepend (bvw->priv->missing_plugins, gst_message_ref (msg));
+ goto done;
+ } else {
#if 0
- GstNavigationMessageType nav_msg_type =
- gst_navigation_message_get_type (msg);
-
- switch (nav_msg_type)
- {
- case GST_NAVIGATION_MESSAGE_MOUSE_OVER:
- {
- gint active;
- if (!gst_navigation_message_parse_mouse_over (msg, &active))
- break;
- if (active)
- {
- if (bvw->priv->cursor == NULL)
- {
- bvw->priv->cursor = gdk_cursor_new (GDK_HAND2);
- }
- }
- else
- {
- if (bvw->priv->cursor != NULL)
- {
- gdk_cursor_unref (bvw->priv->cursor);
- bvw->priv->cursor = NULL;
- }
- }
- gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (bvw)),
- bvw->priv->cursor);
- break;
- }
- default:
- break;
- }
-#endif
+ GstNavigationMessageType nav_msg_type =
+ gst_navigation_message_get_type (msg);
+
+ switch (nav_msg_type) {
+ case GST_NAVIGATION_MESSAGE_MOUSE_OVER:
+ {
+ gint active;
+ if (!gst_navigation_message_parse_mouse_over (msg, &active))
+ break;
+ if (active) {
+ if (bvw->priv->cursor == NULL) {
+ bvw->priv->cursor = gdk_cursor_new (GDK_HAND2);
+ }
+ } else {
+ if (bvw->priv->cursor != NULL) {
+ gdk_cursor_unref (bvw->priv->cursor);
+ bvw->priv->cursor = NULL;
+ }
+ }
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (bvw)),
+ bvw->priv->cursor);
+ break;
+ }
+ default:
+ break;
}
+#endif
+ }
unhandled:
GST_WARNING ("Unhandled element message %s from %s: %" GST_PTR_FORMAT,
- GST_STR_NULL (type_name), GST_STR_NULL (src_name), msg);
+ GST_STR_NULL (type_name), GST_STR_NULL (src_name), msg);
done:
g_free (src_name);
@@ -1465,18 +1308,16 @@ bvw_signal_eos_delayed (gpointer user_data)
static void
bvw_reconfigure_tick_timeout (BaconVideoWidget * bvw, guint msecs)
{
- if (bvw->priv->update_id != 0)
- {
- GST_INFO ("removing tick timeout");
- g_source_remove (bvw->priv->update_id);
- bvw->priv->update_id = 0;
- }
- if (msecs > 0)
- {
- GST_INFO ("adding tick timeout (at %ums)", msecs);
- bvw->priv->update_id =
- g_timeout_add (msecs, (GSourceFunc) bvw_query_timeout, bvw);
- }
+ if (bvw->priv->update_id != 0) {
+ GST_INFO ("removing tick timeout");
+ g_source_remove (bvw->priv->update_id);
+ bvw->priv->update_id = 0;
+ }
+ if (msecs > 0) {
+ GST_INFO ("adding tick timeout (at %ums)", msecs);
+ bvw->priv->update_id =
+ g_timeout_add (msecs, (GSourceFunc) bvw_query_timeout, bvw);
+ }
}
/* returns TRUE if the error/signal has been handled and should be ignored */
@@ -1488,22 +1329,21 @@ bvw_emit_missing_plugins_signal (BaconVideoWidget * bvw, gboolean prerolled)
details = bvw_get_missing_plugins_details (bvw->priv->missing_plugins);
descriptions =
- bvw_get_missing_plugins_descriptions (bvw->priv->missing_plugins);
+ bvw_get_missing_plugins_descriptions (bvw->priv->missing_plugins);
GST_LOG ("emitting missing-plugins signal (prerolled=%d)", prerolled);
g_signal_emit (bvw, bvw_signals[SIGNAL_MISSING_PLUGINS], 0,
- details, descriptions, prerolled, &handled);
+ details, descriptions, prerolled, &handled);
GST_DEBUG ("missing-plugins signal was %shandled", (handled) ? "" : "not ");
g_strfreev (descriptions);
g_strfreev (details);
- if (handled)
- {
- bvw->priv->plugin_install_in_progress = TRUE;
- bvw_clear_missing_plugins_messages (bvw);
- }
+ if (handled) {
+ bvw->priv->plugin_install_in_progress = TRUE;
+ bvw_clear_missing_plugins_messages (bvw);
+ }
/* if it wasn't handled, we might need the list of missing messages again
* later to create a proper error message with details of what's missing */
@@ -1520,11 +1360,10 @@ bvw_check_missing_plugins_error (BaconVideoWidget * bvw, GstMessage * err_msg)
gboolean ret = FALSE;
GError *err = NULL;
- if (bvw->priv->missing_plugins == NULL)
- {
- GST_DEBUG ("no missing-plugin messages");
- return FALSE;
- }
+ if (bvw->priv->missing_plugins == NULL) {
+ GST_DEBUG ("no missing-plugin messages");
+ return FALSE;
+ }
gst_message_parse_error (err_msg, &err, NULL);
@@ -1537,20 +1376,16 @@ bvw_check_missing_plugins_error (BaconVideoWidget * bvw, GstMessage * err_msg)
* in playbin, but for now we'll work around it here) */
if (is_error (err, CORE, MISSING_PLUGIN) ||
is_error (err, STREAM, CODEC_NOT_FOUND) ||
- (is_error (err, STREAM, WRONG_TYPE) && error_src_is_playbin))
- {
- ret = bvw_emit_missing_plugins_signal (bvw, FALSE);
- if (ret)
- {
- /* If it was handled, stop playback to make sure we're not processing any
- * other error messages that might also be on the bus */
- bacon_video_widget_stop (bvw);
- }
- }
- else
- {
- GST_DEBUG ("not an error code we are looking for, doing nothing");
+ (is_error (err, STREAM, WRONG_TYPE) && error_src_is_playbin)) {
+ ret = bvw_emit_missing_plugins_signal (bvw, FALSE);
+ if (ret) {
+ /* If it was handled, stop playback to make sure we're not processing any
+ * other error messages that might also be on the bus */
+ bacon_video_widget_stop (bvw);
}
+ } else {
+ GST_DEBUG ("not an error code we are looking for, doing nothing");
+ }
g_error_free (err);
return ret;
@@ -1560,11 +1395,10 @@ bvw_check_missing_plugins_error (BaconVideoWidget * bvw, GstMessage * err_msg)
static gboolean
bvw_check_missing_plugins_on_preroll (BaconVideoWidget * bvw)
{
- if (bvw->priv->missing_plugins == NULL)
- {
- GST_DEBUG ("no missing-plugin messages");
- return FALSE;
- }
+ if (bvw->priv->missing_plugins == NULL) {
+ GST_DEBUG ("no missing-plugin messages");
+ return FALSE;
+ }
return bvw_emit_missing_plugins_signal (bvw, TRUE);
}
@@ -1581,286 +1415,245 @@ bvw_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
msg_type = GST_MESSAGE_TYPE (message);
/* somebody else is handling the message, probably in poll_for_state_change */
- if (bvw->priv->ignore_messages_mask & msg_type)
- {
- GST_LOG ("Ignoring %s message from element %" GST_PTR_FORMAT
- " as requested: %" GST_PTR_FORMAT,
- GST_MESSAGE_TYPE_NAME (message), message->src, message);
- return;
- }
+ if (bvw->priv->ignore_messages_mask & msg_type) {
+ GST_LOG ("Ignoring %s message from element %" GST_PTR_FORMAT
+ " as requested: %" GST_PTR_FORMAT,
+ GST_MESSAGE_TYPE_NAME (message), message->src, message);
+ return;
+ }
- if (msg_type != GST_MESSAGE_STATE_CHANGED)
- {
- gchar *src_name = gst_object_get_name (message->src);
- GST_LOG ("Handling %s message from element %s",
- gst_message_type_get_name (msg_type), src_name);
- g_free (src_name);
- }
+ if (msg_type != GST_MESSAGE_STATE_CHANGED) {
+ gchar *src_name = gst_object_get_name (message->src);
+ GST_LOG ("Handling %s message from element %s",
+ gst_message_type_get_name (msg_type), src_name);
+ g_free (src_name);
+ }
- switch (msg_type)
- {
+ switch (msg_type) {
case GST_MESSAGE_ERROR:
- {
- bvw_error_msg (bvw, message);
+ {
+ bvw_error_msg (bvw, message);
- if (!bvw_check_missing_plugins_error (bvw, message))
- {
- GError *error;
+ if (!bvw_check_missing_plugins_error (bvw, message)) {
+ GError *error;
- error = bvw_error_from_gst_error (bvw, message);
+ error = bvw_error_from_gst_error (bvw, message);
- bvw->priv->target_state = GST_STATE_NULL;
- if (bvw->priv->play)
- gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
+ bvw->priv->target_state = GST_STATE_NULL;
+ if (bvw->priv->play)
+ gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
- bvw->priv->buffering = FALSE;
+ bvw->priv->buffering = FALSE;
- g_signal_emit (bvw, bvw_signals[SIGNAL_ERROR], 0,
- error->message, TRUE, FALSE);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_ERROR], 0,
+ error->message, TRUE, FALSE);
- g_error_free (error);
- }
- break;
+ g_error_free (error);
}
+ break;
+ }
case GST_MESSAGE_WARNING:
- {
- GST_WARNING ("Warning message: %" GST_PTR_FORMAT, message);
- break;
- }
+ {
+ GST_WARNING ("Warning message: %" GST_PTR_FORMAT, message);
+ break;
+ }
case GST_MESSAGE_TAG:
- {
- GstTagList *tag_list, *result;
- GstElementFactory *f;
-
- gst_message_parse_tag (message, &tag_list);
-
- GST_DEBUG ("Tags: %" GST_PTR_FORMAT, tag_list);
-
- /* all tags (replace previous tags, title/artist/etc. might change
- * in the middle of a stream, e.g. with radio streams) */
- result = gst_tag_list_merge (bvw->priv->tagcache, tag_list,
- GST_TAG_MERGE_REPLACE);
- if (bvw->priv->tagcache)
- gst_tag_list_free (bvw->priv->tagcache);
- bvw->priv->tagcache = result;
-
- /* media-type-specific tags */
- if (GST_IS_ELEMENT (message->src) &&
- (f = gst_element_get_factory (GST_ELEMENT (message->src))))
- {
- const gchar *klass = gst_element_factory_get_klass (f);
- GstTagList **cache = NULL;
-
- if (g_strrstr (klass, "Video"))
- {
- cache = &bvw->priv->videotags;
- }
- else if (g_strrstr (klass, "Audio"))
- {
- cache = &bvw->priv->audiotags;
- }
-
- if (cache)
- {
- result =
- gst_tag_list_merge (*cache, tag_list,
- GST_TAG_MERGE_REPLACE);
- if (*cache)
- gst_tag_list_free (*cache);
- *cache = result;
- }
- }
-
- /* clean up */
- gst_tag_list_free (tag_list);
-
- /* if we're not interactive, we want to announce metadata
- * only later when we can be sure we got it all */
- if (bvw->priv->use_type == BVW_USE_TYPE_VIDEO ||
- bvw->priv->use_type == BVW_USE_TYPE_AUDIO)
- {
- /* If we updated metadata and we have a new title, send it
- * using TITLE_CHANGE, so that the UI knows it has a new
- * streaming title */
- GValue value = { 0, };
-
- g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0);
-
- bacon_video_widget_get_metadata (bvw, BVW_INFO_TITLE, &value);
- if (g_value_get_string (&value))
- g_signal_emit (bvw, bvw_signals[SIGNAL_TITLE_CHANGE], 0,
- g_value_get_string (&value));
- g_value_unset (&value);
- }
- break;
+ {
+ GstTagList *tag_list, *result;
+ GstElementFactory *f;
+
+ gst_message_parse_tag (message, &tag_list);
+
+ GST_DEBUG ("Tags: %" GST_PTR_FORMAT, tag_list);
+
+ /* all tags (replace previous tags, title/artist/etc. might change
+ * in the middle of a stream, e.g. with radio streams) */
+ result = gst_tag_list_merge (bvw->priv->tagcache, tag_list,
+ GST_TAG_MERGE_REPLACE);
+ if (bvw->priv->tagcache)
+ gst_tag_list_free (bvw->priv->tagcache);
+ bvw->priv->tagcache = result;
+
+ /* media-type-specific tags */
+ if (GST_IS_ELEMENT (message->src) &&
+ (f = gst_element_get_factory (GST_ELEMENT (message->src)))) {
+ const gchar *klass = gst_element_factory_get_klass (f);
+ GstTagList **cache = NULL;
+
+ if (g_strrstr (klass, "Video")) {
+ cache = &bvw->priv->videotags;
+ } else if (g_strrstr (klass, "Audio")) {
+ cache = &bvw->priv->audiotags;
+ }
+
+ if (cache) {
+ result = gst_tag_list_merge (*cache, tag_list, GST_TAG_MERGE_REPLACE);
+ if (*cache)
+ gst_tag_list_free (*cache);
+ *cache = result;
+ }
+ }
+
+ /* clean up */
+ gst_tag_list_free (tag_list);
+
+ /* if we're not interactive, we want to announce metadata
+ * only later when we can be sure we got it all */
+ if (bvw->priv->use_type == BVW_USE_TYPE_VIDEO ||
+ bvw->priv->use_type == BVW_USE_TYPE_AUDIO) {
+ /* If we updated metadata and we have a new title, send it
+ * using TITLE_CHANGE, so that the UI knows it has a new
+ * streaming title */
+ GValue value = { 0, };
+
+ g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0);
+
+ bacon_video_widget_get_metadata (bvw, BVW_INFO_TITLE, &value);
+ if (g_value_get_string (&value))
+ g_signal_emit (bvw, bvw_signals[SIGNAL_TITLE_CHANGE], 0,
+ g_value_get_string (&value));
+ g_value_unset (&value);
}
+ break;
+ }
case GST_MESSAGE_EOS:
GST_DEBUG ("EOS message");
/* update slider one last time */
bvw_query_timeout (bvw);
if (bvw->priv->eos_id == 0)
- bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
+ bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
break;
case GST_MESSAGE_BUFFERING:
- {
- gint percent = 0;
-
- /* FIXME: use gst_message_parse_buffering() once core 0.10.11 is out */
- gst_structure_get_int (message->structure, "buffer-percent",
- &percent);
- g_signal_emit (bvw, bvw_signals[SIGNAL_BUFFERING], 0, percent);
-
- if (percent >= 100)
- {
- /* a 100% message means buffering is done */
- bvw->priv->buffering = FALSE;
- /* if the desired state is playing, go back */
- if (bvw->priv->target_state == GST_STATE_PLAYING)
- {
- GST_DEBUG
- ("Buffering done, setting pipeline back to PLAYING");
- gst_element_set_state (bvw->priv->play, GST_STATE_PLAYING);
- }
- else
- {
- GST_DEBUG ("Buffering done, keeping pipeline PAUSED");
- }
- }
- else if (bvw->priv->buffering == FALSE &&
- bvw->priv->target_state == GST_STATE_PLAYING)
- {
- GstState cur_state;
-
- gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0);
- if (cur_state == GST_STATE_PLAYING)
- {
- GST_DEBUG ("Buffering ... temporarily pausing playback");
- gst_element_set_state (bvw->priv->play, GST_STATE_PAUSED);
- }
- else
- {
- GST_DEBUG ("Buffering ... prerolling, not doing anything");
- }
- bvw->priv->buffering = TRUE;
- }
- else
- {
- GST_LOG ("Buffering ... %d", percent);
- }
- break;
+ {
+ gint percent = 0;
+
+ /* FIXME: use gst_message_parse_buffering() once core 0.10.11 is out */
+ gst_structure_get_int (message->structure, "buffer-percent", &percent);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_BUFFERING], 0, percent);
+
+ if (percent >= 100) {
+ /* a 100% message means buffering is done */
+ bvw->priv->buffering = FALSE;
+ /* if the desired state is playing, go back */
+ if (bvw->priv->target_state == GST_STATE_PLAYING) {
+ GST_DEBUG ("Buffering done, setting pipeline back to PLAYING");
+ gst_element_set_state (bvw->priv->play, GST_STATE_PLAYING);
+ } else {
+ GST_DEBUG ("Buffering done, keeping pipeline PAUSED");
+ }
+ } else if (bvw->priv->buffering == FALSE &&
+ bvw->priv->target_state == GST_STATE_PLAYING) {
+ GstState cur_state;
+
+ gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0);
+ if (cur_state == GST_STATE_PLAYING) {
+ GST_DEBUG ("Buffering ... temporarily pausing playback");
+ gst_element_set_state (bvw->priv->play, GST_STATE_PAUSED);
+ } else {
+ GST_DEBUG ("Buffering ... prerolling, not doing anything");
+ }
+ bvw->priv->buffering = TRUE;
+ } else {
+ GST_LOG ("Buffering ... %d", percent);
}
+ break;
+ }
case GST_MESSAGE_APPLICATION:
- {
- bvw_handle_application_message (bvw, message);
- break;
- }
+ {
+ bvw_handle_application_message (bvw, message);
+ break;
+ }
case GST_MESSAGE_STATE_CHANGED:
- {
- GstState old_state, new_state;
- gchar *src_name;
-
- gst_message_parse_state_changed (message, &old_state, &new_state,
- NULL);
-
- if (old_state == new_state)
- break;
-
- /* we only care about playbin (pipeline) state changes */
- if (GST_MESSAGE_SRC (message) != GST_OBJECT (bvw->priv->play))
- break;
-
- src_name = gst_object_get_name (message->src);
- GST_DEBUG ("%s changed state from %s to %s", src_name,
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (new_state));
- g_free (src_name);
-
- /* now do stuff */
- if (new_state <= GST_STATE_PAUSED)
- {
- bvw_query_timeout (bvw);
- bvw_reconfigure_tick_timeout (bvw, 0);
- g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, FALSE);
-
- }
- else if (new_state == GST_STATE_PAUSED)
- {
- bvw_reconfigure_tick_timeout (bvw, 500);
- g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, FALSE);
-
- }
- else if (new_state > GST_STATE_PAUSED)
- {
- bvw_reconfigure_tick_timeout (bvw, 200);
- g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, TRUE);
- }
-
-
- if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED)
- {
- GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (bvw->priv->play),
- GST_DEBUG_GRAPH_SHOW_ALL ^
- GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS,
- "totem-prerolled");
+ {
+ GstState old_state, new_state;
+ gchar *src_name;
+
+ gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
+
+ if (old_state == new_state)
+ break;
+
+ /* we only care about playbin (pipeline) state changes */
+ if (GST_MESSAGE_SRC (message) != GST_OBJECT (bvw->priv->play))
+ break;
+
+ src_name = gst_object_get_name (message->src);
+ GST_DEBUG ("%s changed state from %s to %s", src_name,
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (new_state));
+ g_free (src_name);
+
+ /* now do stuff */
+ if (new_state <= GST_STATE_PAUSED) {
+ bvw_query_timeout (bvw);
+ bvw_reconfigure_tick_timeout (bvw, 0);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, FALSE);
+
+ } else if (new_state == GST_STATE_PAUSED) {
+ bvw_reconfigure_tick_timeout (bvw, 500);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, FALSE);
+
+ } else if (new_state > GST_STATE_PAUSED) {
+ bvw_reconfigure_tick_timeout (bvw, 200);
+ g_signal_emit (bvw, bvw_signals[SIGNAL_STATE_CHANGE], 0, TRUE);
+ }
+
+
+ if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
+ GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (bvw->priv->play),
+ GST_DEBUG_GRAPH_SHOW_ALL ^
+ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS, "totem-prerolled");
bvw->priv->stream_length = 0;
- if (bacon_video_widget_get_stream_length (bvw) == 0)
- {
+ if (bacon_video_widget_get_stream_length (bvw) == 0) {
GST_DEBUG ("Failed to query duration in PAUSED state?!");
}
break;
- bvw_update_stream_info (bvw);
- if (!bvw_check_missing_plugins_on_preroll (bvw))
- {
- /* show a non-fatal warning message if we can't decode the video */
- bvw_check_if_video_decoder_is_missing (bvw);
- }
- g_signal_emit (bvw, bvw_signals[SIGNAL_READY_TO_SEEK], 0, FALSE);
-
- }
- else if (old_state == GST_STATE_PAUSED
- && new_state == GST_STATE_READY)
- {
- bvw->priv->media_has_video = FALSE;
- bvw->priv->media_has_audio = FALSE;
-
- /* clean metadata cache */
- if (bvw->priv->tagcache)
- {
- gst_tag_list_free (bvw->priv->tagcache);
- bvw->priv->tagcache = NULL;
- }
- if (bvw->priv->audiotags)
- {
- gst_tag_list_free (bvw->priv->audiotags);
- bvw->priv->audiotags = NULL;
- }
- if (bvw->priv->videotags)
- {
- gst_tag_list_free (bvw->priv->videotags);
- bvw->priv->videotags = NULL;
- }
-
- bvw->priv->video_width = 0;
- bvw->priv->video_height = 0;
- }
- break;
+ bvw_update_stream_info (bvw);
+ if (!bvw_check_missing_plugins_on_preroll (bvw)) {
+ /* show a non-fatal warning message if we can't decode the video */
+ bvw_check_if_video_decoder_is_missing (bvw);
+ }
+ g_signal_emit (bvw, bvw_signals[SIGNAL_READY_TO_SEEK], 0, FALSE);
+
+ } else if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_READY) {
+ bvw->priv->media_has_video = FALSE;
+ bvw->priv->media_has_audio = FALSE;
+
+ /* clean metadata cache */
+ if (bvw->priv->tagcache) {
+ gst_tag_list_free (bvw->priv->tagcache);
+ bvw->priv->tagcache = NULL;
+ }
+ if (bvw->priv->audiotags) {
+ gst_tag_list_free (bvw->priv->audiotags);
+ bvw->priv->audiotags = NULL;
+ }
+ if (bvw->priv->videotags) {
+ gst_tag_list_free (bvw->priv->videotags);
+ bvw->priv->videotags = NULL;
+ }
+
+ bvw->priv->video_width = 0;
+ bvw->priv->video_height = 0;
}
+ break;
+ }
case GST_MESSAGE_ELEMENT:
- {
- bvw_handle_element_message (bvw, message);
- break;
- }
+ {
+ bvw_handle_element_message (bvw, message);
+ break;
+ }
case GST_MESSAGE_DURATION:
- {
- /* force _get_stream_length() to do new duration query */
- /*bvw->priv->stream_length = 0;
- if (bacon_video_widget_get_stream_length (bvw) == 0)
- {
- GST_DEBUG ("Failed to query duration after DURATION message?!");
- }
- break;*/
- }
+ {
+ /* force _get_stream_length() to do new duration query */
+ /*bvw->priv->stream_length = 0;
+ if (bacon_video_widget_get_stream_length (bvw) == 0)
+ {
+ GST_DEBUG ("Failed to query duration after DURATION message?!");
+ }
+ break; */
+ }
case GST_MESSAGE_CLOCK_PROVIDE:
case GST_MESSAGE_CLOCK_LOST:
@@ -1871,7 +1664,7 @@ bvw_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
default:
GST_LOG ("Unhandled message: %" GST_PTR_FORMAT, message);
break;
- }
+ }
}
@@ -1884,13 +1677,10 @@ got_video_size (BaconVideoWidget * bvw)
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
msg = gst_message_new_application (GST_OBJECT (bvw->priv->play),
- gst_structure_new ("video-size", "width",
- G_TYPE_INT,
- bvw->priv->
- video_width, "height",
- G_TYPE_INT,
- bvw->priv->
- video_height, NULL));
+ gst_structure_new ("video-size", "width",
+ G_TYPE_INT,
+ bvw->priv->video_width, "height",
+ G_TYPE_INT, bvw->priv->video_height, NULL));
gst_element_post_message (bvw->priv->play, msg);
}
@@ -1904,26 +1694,20 @@ got_time_tick (GstElement * play, gint64 time_nanos, BaconVideoWidget * bvw)
bvw->priv->current_time = (gint64) time_nanos / GST_MSECOND;
- if (bvw->priv->stream_length == 0)
- {
- bvw->priv->current_position = 0;
- }
- else
- {
- bvw->priv->current_position =
- (gdouble) bvw->priv->current_time / bvw->priv->stream_length;
- }
+ if (bvw->priv->stream_length == 0) {
+ bvw->priv->current_position = 0;
+ } else {
+ bvw->priv->current_position =
+ (gdouble) bvw->priv->current_time / bvw->priv->stream_length;
+ }
- if (bvw->priv->stream_length == 0)
- {
- seekable = bacon_video_widget_is_seekable (bvw);
- }
- else
- {
- if (bvw->priv->seekable == -1)
- g_object_notify (G_OBJECT (bvw), "seekable");
- seekable = TRUE;
- }
+ if (bvw->priv->stream_length == 0) {
+ seekable = bacon_video_widget_is_seekable (bvw);
+ } else {
+ if (bvw->priv->seekable == -1)
+ g_object_notify (G_OBJECT (bvw), "seekable");
+ seekable = TRUE;
+ }
bvw->priv->is_live = (bvw->priv->stream_length == 0);
@@ -1935,8 +1719,8 @@ got_time_tick (GstElement * play, gint64 time_nanos, BaconVideoWidget * bvw)
*/
g_signal_emit (bvw, bvw_signals[SIGNAL_TICK], 0,
- bvw->priv->current_time, bvw->priv->stream_length,
- bvw->priv->current_position, seekable);
+ bvw->priv->current_time, bvw->priv->stream_length,
+ bvw->priv->current_position, seekable);
}
static void
@@ -1945,44 +1729,39 @@ bvw_set_device_on_element (BaconVideoWidget * bvw, GstElement * element)
if (bvw->priv->media_device == NULL)
return;
- if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "device"))
- {
- GST_DEBUG ("Setting device to '%s'", bvw->priv->media_device);
- g_object_set (element, "device", bvw->priv->media_device, NULL);
- }
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "device")) {
+ GST_DEBUG ("Setting device to '%s'", bvw->priv->media_device);
+ g_object_set (element, "device", bvw->priv->media_device, NULL);
+ }
}
static void
playbin_source_notify_cb (GObject * play, GParamSpec * p,
- BaconVideoWidget * bvw)
+ BaconVideoWidget * bvw)
{
GObject *source = NULL;
/* CHECKME: do we really need these taglist frees here (tpm)? */
- if (bvw->priv->tagcache)
- {
- gst_tag_list_free (bvw->priv->tagcache);
- bvw->priv->tagcache = NULL;
- }
- if (bvw->priv->audiotags)
- {
- gst_tag_list_free (bvw->priv->audiotags);
- bvw->priv->audiotags = NULL;
- }
- if (bvw->priv->videotags)
- {
- gst_tag_list_free (bvw->priv->videotags);
- bvw->priv->videotags = NULL;
- }
+ if (bvw->priv->tagcache) {
+ gst_tag_list_free (bvw->priv->tagcache);
+ bvw->priv->tagcache = NULL;
+ }
+ if (bvw->priv->audiotags) {
+ gst_tag_list_free (bvw->priv->audiotags);
+ bvw->priv->audiotags = NULL;
+ }
+ if (bvw->priv->videotags) {
+ gst_tag_list_free (bvw->priv->videotags);
+ bvw->priv->videotags = NULL;
+ }
g_object_get (play, "source", &source, NULL);
- if (source)
- {
- GST_DEBUG ("Got source of type %s", G_OBJECT_TYPE_NAME (source));
- bvw_set_device_on_element (bvw, GST_ELEMENT (source));
- g_object_unref (source);
- }
+ if (source) {
+ GST_DEBUG ("Got source of type %s", G_OBJECT_TYPE_NAME (source));
+ bvw_set_device_on_element (bvw, GST_ELEMENT (source));
+ g_object_unref (source);
+ }
}
static gboolean
@@ -1994,33 +1773,24 @@ bvw_query_timeout (BaconVideoWidget * bvw)
/* check length/pos of stream */
prev_len = bvw->priv->stream_length;
- if (gst_element_query_duration (bvw->priv->play, &fmt, &len))
- {
- if (len != -1 && fmt == GST_FORMAT_TIME)
- {
- bvw->priv->stream_length = len / GST_MSECOND;
- if (bvw->priv->stream_length != prev_len)
- {
- g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
- }
- }
- }
- else
- {
- GST_INFO ("could not get duration");
+ if (gst_element_query_duration (bvw->priv->play, &fmt, &len)) {
+ if (len != -1 && fmt == GST_FORMAT_TIME) {
+ bvw->priv->stream_length = len / GST_MSECOND;
+ if (bvw->priv->stream_length != prev_len) {
+ g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
+ }
}
+ } else {
+ GST_INFO ("could not get duration");
+ }
- if (gst_element_query_position (bvw->priv->play, &fmt, &pos))
- {
- if (pos != -1 && fmt == GST_FORMAT_TIME)
- {
- got_time_tick (GST_ELEMENT (bvw->priv->play), pos, bvw);
- }
- }
- else
- {
- GST_INFO ("could not get position");
+ if (gst_element_query_position (bvw->priv->play, &fmt, &pos)) {
+ if (pos != -1 && fmt == GST_FORMAT_TIME) {
+ got_time_tick (GST_ELEMENT (bvw->priv->play), pos, bvw);
}
+ } else {
+ GST_INFO ("could not get position");
+ }
return TRUE;
}
@@ -2037,23 +1807,21 @@ caps_set (GObject * obj, GParamSpec * pspec, BaconVideoWidget * bvw)
/* Get video decoder caps */
s = gst_caps_get_structure (caps, 0);
- if (s)
- {
- /* We need at least width/height and framerate */
- if (!
- (gst_structure_get_fraction
- (s, "framerate", &bvw->priv->video_fps_n, &bvw->priv->video_fps_d)
- && gst_structure_get_int (s, "width", &bvw->priv->video_width)
- && gst_structure_get_int (s, "height", &bvw->priv->video_height)))
- return;
-
- /* Get the movie PAR if available */
- bvw->priv->movie_par =
- gst_structure_get_value (s, "pixel-aspect-ratio");
-
- /* Now set for real */
- bacon_video_widget_set_aspect_ratio (bvw, bvw->priv->ratio_type);
- }
+ if (s) {
+ /* We need at least width/height and framerate */
+ if (!
+ (gst_structure_get_fraction
+ (s, "framerate", &bvw->priv->video_fps_n, &bvw->priv->video_fps_d)
+ && gst_structure_get_int (s, "width", &bvw->priv->video_width)
+ && gst_structure_get_int (s, "height", &bvw->priv->video_height)))
+ return;
+
+ /* Get the movie PAR if available */
+ bvw->priv->movie_par = gst_structure_get_value (s, "pixel-aspect-ratio");
+
+ /* Now set for real */
+ bacon_video_widget_set_aspect_ratio (bvw, bvw->priv->ratio_type);
+ }
gst_caps_unref (caps);
}
@@ -2065,52 +1833,46 @@ parse_stream_info (BaconVideoWidget * bvw)
gint n_audio, n_video;
g_object_get (G_OBJECT (bvw->priv->play), "n-audio", &n_audio,
- "n-video", &n_video, NULL);
+ "n-video", &n_video, NULL);
bvw->priv->media_has_video = FALSE;
- if (n_video > 0)
- {
- gint i;
+ if (n_video > 0) {
+ gint i;
- bvw->priv->media_has_video = TRUE;
- if (bvw->priv->video_window)
- gdk_window_show (bvw->priv->video_window);
+ bvw->priv->media_has_video = TRUE;
+ if (bvw->priv->video_window)
+ gdk_window_show (bvw->priv->video_window);
- for (i = 0; i < n_video && videopad == NULL; i++)
- g_signal_emit_by_name (bvw->priv->play, "get-video-pad", i,
- &videopad);
- }
+ for (i = 0; i < n_video && videopad == NULL; i++)
+ g_signal_emit_by_name (bvw->priv->play, "get-video-pad", i, &videopad);
+ }
bvw->priv->media_has_audio = FALSE;
- if (n_audio > 0)
- {
- bvw->priv->media_has_audio = TRUE;
- if (!bvw->priv->media_has_video && bvw->priv->video_window)
- {
- gint flags;
+ if (n_audio > 0) {
+ bvw->priv->media_has_audio = TRUE;
+ if (!bvw->priv->media_has_video && bvw->priv->video_window) {
+ gint flags;
- g_object_get (bvw->priv->play, "flags", &flags, NULL);
+ g_object_get (bvw->priv->play, "flags", &flags, NULL);
- gdk_window_hide (bvw->priv->video_window);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
- flags &= ~GST_PLAY_FLAGS_VIS;
+ gdk_window_hide (bvw->priv->video_window);
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
+ flags &= ~GST_PLAY_FLAGS_VIS;
- g_object_set (bvw->priv->play, "flags", flags, NULL);
- }
+ g_object_set (bvw->priv->play, "flags", flags, NULL);
}
+ }
- if (videopad)
- {
- GstCaps *caps;
+ if (videopad) {
+ GstCaps *caps;
- if ((caps = gst_pad_get_negotiated_caps (videopad)))
- {
- caps_set (G_OBJECT (videopad), NULL, bvw);
- gst_caps_unref (caps);
- }
- g_signal_connect (videopad, "notify::caps", G_CALLBACK (caps_set), bvw);
- gst_object_unref (videopad);
+ if ((caps = gst_pad_get_negotiated_caps (videopad))) {
+ caps_set (G_OBJECT (videopad), NULL, bvw);
+ gst_caps_unref (caps);
}
+ g_signal_connect (videopad, "notify::caps", G_CALLBACK (caps_set), bvw);
+ gst_object_unref (videopad);
+ }
}
static void
@@ -2122,8 +1884,7 @@ playbin_stream_changed_cb (GstElement * obj, gpointer data)
/* we're being called from the streaming thread, so don't do anything here */
GST_LOG ("streams have changed");
msg = gst_message_new_application (GST_OBJECT (bvw->priv->play),
- gst_structure_new ("stream-changed",
- NULL));
+ gst_structure_new ("stream-changed", NULL));
gst_element_post_message (bvw->priv->play, msg);
}
@@ -2134,22 +1895,20 @@ bacon_video_widget_finalize (GObject * object)
GST_INFO ("finalizing");
- if (bvw->priv->bus)
- {
- /* make bus drop all messages to make sure none of our callbacks is ever
- * called again (main loop might be run again to display error dialog) */
- gst_bus_set_flushing (bvw->priv->bus, TRUE);
+ if (bvw->priv->bus) {
+ /* make bus drop all messages to make sure none of our callbacks is ever
+ * called again (main loop might be run again to display error dialog) */
+ gst_bus_set_flushing (bvw->priv->bus, TRUE);
- if (bvw->priv->sig_bus_sync)
- g_signal_handler_disconnect (bvw->priv->bus, bvw->priv->sig_bus_sync);
+ if (bvw->priv->sig_bus_sync)
+ g_signal_handler_disconnect (bvw->priv->bus, bvw->priv->sig_bus_sync);
- if (bvw->priv->sig_bus_async)
- g_signal_handler_disconnect (bvw->priv->bus,
- bvw->priv->sig_bus_async);
+ if (bvw->priv->sig_bus_async)
+ g_signal_handler_disconnect (bvw->priv->bus, bvw->priv->sig_bus_async);
- gst_object_unref (bvw->priv->bus);
- bvw->priv->bus = NULL;
- }
+ gst_object_unref (bvw->priv->bus);
+ bvw->priv->bus = NULL;
+ }
g_free (bvw->priv->media_device);
bvw->priv->media_device = NULL;
@@ -2161,46 +1920,39 @@ bacon_video_widget_finalize (GObject * object)
- if (bvw->priv->play != NULL && GST_IS_ELEMENT (bvw->priv->play))
- {
- gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
- gst_object_unref (bvw->priv->play);
- bvw->priv->play = NULL;
- }
+ if (bvw->priv->play != NULL && GST_IS_ELEMENT (bvw->priv->play)) {
+ gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
+ gst_object_unref (bvw->priv->play);
+ bvw->priv->play = NULL;
+ }
- if (bvw->priv->update_id)
- {
- g_source_remove (bvw->priv->update_id);
- bvw->priv->update_id = 0;
- }
+ if (bvw->priv->update_id) {
+ g_source_remove (bvw->priv->update_id);
+ bvw->priv->update_id = 0;
+ }
- if (bvw->priv->interface_update_id)
- {
- g_source_remove (bvw->priv->interface_update_id);
- bvw->priv->interface_update_id = 0;
- }
+ if (bvw->priv->interface_update_id) {
+ g_source_remove (bvw->priv->interface_update_id);
+ bvw->priv->interface_update_id = 0;
+ }
- if (bvw->priv->tagcache)
- {
- gst_tag_list_free (bvw->priv->tagcache);
- bvw->priv->tagcache = NULL;
- }
- if (bvw->priv->audiotags)
- {
- gst_tag_list_free (bvw->priv->audiotags);
- bvw->priv->audiotags = NULL;
- }
- if (bvw->priv->videotags)
- {
- gst_tag_list_free (bvw->priv->videotags);
- bvw->priv->videotags = NULL;
- }
+ if (bvw->priv->tagcache) {
+ gst_tag_list_free (bvw->priv->tagcache);
+ bvw->priv->tagcache = NULL;
+ }
+ if (bvw->priv->audiotags) {
+ gst_tag_list_free (bvw->priv->audiotags);
+ bvw->priv->audiotags = NULL;
+ }
+ if (bvw->priv->videotags) {
+ gst_tag_list_free (bvw->priv->videotags);
+ bvw->priv->videotags = NULL;
+ }
- if (bvw->priv->cursor != NULL)
- {
- gdk_cursor_unref (bvw->priv->cursor);
- bvw->priv->cursor = NULL;
- }
+ if (bvw->priv->cursor != NULL) {
+ gdk_cursor_unref (bvw->priv->cursor);
+ bvw->priv->cursor = NULL;
+ }
if (bvw->priv->eos_id != 0)
g_source_remove (bvw->priv->eos_id);
@@ -2212,14 +1964,13 @@ bacon_video_widget_finalize (GObject * object)
static void
bacon_video_widget_set_property (GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
BaconVideoWidget *bvw;
bvw = BACON_VIDEO_WIDGET (object);
- switch (property_id)
- {
+ switch (property_id) {
case PROP_LOGO_MODE:
bacon_video_widget_set_logo_mode (bvw, g_value_get_boolean (value));
break;
@@ -2236,19 +1987,18 @@ bacon_video_widget_set_property (GObject * object, guint property_id,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
- }
+ }
}
static void
bacon_video_widget_get_property (GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
BaconVideoWidget *bvw;
bvw = BACON_VIDEO_WIDGET (object);
- switch (property_id)
- {
+ switch (property_id) {
case PROP_LOGO_MODE:
g_value_set_boolean (value, bacon_video_widget_get_logo_mode (bvw));
break;
@@ -2276,7 +2026,7 @@ bacon_video_widget_get_property (GObject * object, guint property_id,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
- }
+ }
}
/* ============================================================= */
@@ -2350,18 +2100,15 @@ bacon_video_widget_set_subtitle (BaconVideoWidget * bvw, int subtitle)
g_object_get (bvw->priv->play, "flags", &flags, NULL);
- if (subtitle == -2)
- {
- flags &= ~GST_PLAY_FLAGS_TEXT;
- subtitle = -1;
- }
- else
- {
- flags |= GST_PLAY_FLAGS_TEXT;
- }
+ if (subtitle == -2) {
+ flags &= ~GST_PLAY_FLAGS_TEXT;
+ subtitle = -1;
+ } else {
+ flags |= GST_PLAY_FLAGS_TEXT;
+ }
g_object_set (bvw->priv->play, "flags", flags, "current-text", subtitle,
- NULL);
+ NULL);
}
/**
@@ -2402,107 +2149,76 @@ get_lang_list_for_type (BaconVideoWidget * bvw, const gchar * type_name)
GList *ret = NULL;
gint num = 0;
- if (g_str_equal (type_name, "AUDIO"))
- {
- gint i, n;
-
- g_object_get (G_OBJECT (bvw->priv->play), "n-audio", &n, NULL);
- if (n == 0)
- return NULL;
-
- for (i = 0; i < n; i++)
- {
- GstTagList *tags = NULL;
-
- g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-audio-tags",
- i, &tags);
-
- if (tags)
- {
- gchar *lc = NULL, *cd = NULL;
-
- gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
- gst_tag_list_get_string (tags, GST_TAG_CODEC, &lc);
-
- if (lc)
- {
- ret = g_list_prepend (ret, lc);
- g_free (cd);
- }
- else if (cd)
- {
- ret = g_list_prepend (ret, cd);
- }
- else
- {
- ret =
- g_list_prepend (ret,
- g_strdup_printf ("%s %d", type_name,
- num++));
- }
- gst_tag_list_free (tags);
- }
- else
- {
- ret =
- g_list_prepend (ret,
- g_strdup_printf ("%s %d", type_name, num++));
- }
- }
- }
- else if (g_str_equal (type_name, "TEXT"))
- {
- gint i, n = 0;
-
- g_object_get (G_OBJECT (bvw->priv->play), "n-text", &n, NULL);
- if (n == 0)
- return NULL;
-
- for (i = 0; i < n; i++)
- {
- GstTagList *tags = NULL;
-
- g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-text-tags",
- i, &tags);
-
- if (tags)
- {
- gchar *lc = NULL, *cd = NULL;
-
- gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
- gst_tag_list_get_string (tags, GST_TAG_CODEC, &lc);
-
- if (lc)
- {
- ret = g_list_prepend (ret, lc);
- g_free (cd);
- }
- else if (cd)
- {
- ret = g_list_prepend (ret, cd);
- }
- else
- {
- ret =
- g_list_prepend (ret,
- g_strdup_printf ("%s %d", type_name,
- num++));
- }
- gst_tag_list_free (tags);
- }
- else
- {
- ret =
- g_list_prepend (ret,
- g_strdup_printf ("%s %d", type_name, num++));
- }
- }
+ if (g_str_equal (type_name, "AUDIO")) {
+ gint i, n;
+
+ g_object_get (G_OBJECT (bvw->priv->play), "n-audio", &n, NULL);
+ if (n == 0)
+ return NULL;
+
+ for (i = 0; i < n; i++) {
+ GstTagList *tags = NULL;
+
+ g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-audio-tags",
+ i, &tags);
+
+ if (tags) {
+ gchar *lc = NULL, *cd = NULL;
+
+ gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
+ gst_tag_list_get_string (tags, GST_TAG_CODEC, &lc);
+
+ if (lc) {
+ ret = g_list_prepend (ret, lc);
+ g_free (cd);
+ } else if (cd) {
+ ret = g_list_prepend (ret, cd);
+ } else {
+ ret =
+ g_list_prepend (ret, g_strdup_printf ("%s %d", type_name, num++));
+ }
+ gst_tag_list_free (tags);
+ } else {
+ ret = g_list_prepend (ret, g_strdup_printf ("%s %d", type_name, num++));
+ }
}
- else
- {
- g_critical ("Invalid stream type '%s'", type_name);
+ } else if (g_str_equal (type_name, "TEXT")) {
+ gint i, n = 0;
+
+ g_object_get (G_OBJECT (bvw->priv->play), "n-text", &n, NULL);
+ if (n == 0)
return NULL;
+
+ for (i = 0; i < n; i++) {
+ GstTagList *tags = NULL;
+
+ g_signal_emit_by_name (G_OBJECT (bvw->priv->play), "get-text-tags",
+ i, &tags);
+
+ if (tags) {
+ gchar *lc = NULL, *cd = NULL;
+
+ gst_tag_list_get_string (tags, GST_TAG_LANGUAGE_CODE, &lc);
+ gst_tag_list_get_string (tags, GST_TAG_CODEC, &lc);
+
+ if (lc) {
+ ret = g_list_prepend (ret, lc);
+ g_free (cd);
+ } else if (cd) {
+ ret = g_list_prepend (ret, cd);
+ } else {
+ ret =
+ g_list_prepend (ret, g_strdup_printf ("%s %d", type_name, num++));
+ }
+ gst_tag_list_free (tags);
+ } else {
+ ret = g_list_prepend (ret, g_strdup_printf ("%s %d", type_name, num++));
+ }
}
+ } else {
+ g_critical ("Invalid stream type '%s'", type_name);
+ return NULL;
+ }
return g_list_reverse (ret);
}
@@ -2611,18 +2327,17 @@ bacon_video_widget_set_language (BaconVideoWidget * bvw, int language)
static guint
connection_speed_enum_to_kbps (gint speed)
{
- static const guint conv_table[] =
- { 14400, 19200, 28800, 33600, 34400, 56000,
+ static const guint conv_table[] = { 14400, 19200, 28800, 33600, 34400, 56000,
112000, 256000, 384000, 512000, 1536000, 10752000
};
g_return_val_if_fail (speed >= 0
- && (guint) speed < G_N_ELEMENTS (conv_table), 0);
+ && (guint) speed < G_N_ELEMENTS (conv_table), 0);
/* must round up so that the correct streams are chosen and not ignored
* due to rounding errors when doing kbps <=> bps */
return (conv_table[speed] / 1000) +
- (((conv_table[speed] % 1000) != 0) ? 1 : 0);
+ (((conv_table[speed] % 1000) != 0) ? 1 : 0);
}
/**
@@ -2657,20 +2372,18 @@ bacon_video_widget_set_connection_speed (BaconVideoWidget * bvw, int speed)
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
- if (bvw->priv->connection_speed != speed)
- {
- bvw->priv->connection_speed = speed;
- }
+ if (bvw->priv->connection_speed != speed) {
+ bvw->priv->connection_speed = speed;
+ }
if (bvw->priv->play != NULL &&
g_object_class_find_property (G_OBJECT_GET_CLASS (bvw->priv->play),
- "connection-speed"))
- {
- guint kbps = connection_speed_enum_to_kbps (speed);
+ "connection-speed")) {
+ guint kbps = connection_speed_enum_to_kbps (speed);
- GST_LOG ("Setting connection speed %d (= %d kbps)", speed, kbps);
- g_object_set (bvw->priv->play, "connection-speed", kbps, NULL);
- }
+ GST_LOG ("Setting connection speed %d (= %d kbps)", speed, kbps);
+ g_object_set (bvw->priv->play, "connection-speed", kbps, NULL);
+ }
}
@@ -2679,8 +2392,7 @@ get_num_audio_channels (BaconVideoWidget * bvw)
{
gint channels;
- switch (bvw->priv->speakersetup)
- {
+ switch (bvw->priv->speakersetup) {
case BVW_AUDIO_SOUND_STEREO:
channels = 2;
break;
@@ -2699,7 +2411,7 @@ get_num_audio_channels (BaconVideoWidget * bvw)
case BVW_AUDIO_SOUND_AC3PASSTHRU:
default:
g_return_val_if_reached (-1);
- }
+ }
return channels;
}
@@ -2715,16 +2427,15 @@ fixate_to_num (const GstCaps * in_caps, gint channels)
out_caps = gst_caps_copy (in_caps);
count = gst_caps_get_size (out_caps);
- for (n = 0; n < count; n++)
- {
- s = gst_caps_get_structure (out_caps, n);
- v = gst_structure_get_value (s, "channels");
- if (!v)
- continue;
-
- /* get channel count (or list of ~) */
- gst_structure_fixate_field_nearest_int (s, "channels", channels);
- }
+ for (n = 0; n < count; n++) {
+ s = gst_caps_get_structure (out_caps, n);
+ v = gst_structure_get_value (s, "channels");
+ if (!v)
+ continue;
+
+ /* get channel count (or list of ~) */
+ gst_structure_fixate_field_nearest_int (s, "channels", channels);
+ }
return out_caps;
}
@@ -2753,17 +2464,15 @@ set_audio_filter (BaconVideoWidget * bvw)
gst_caps_unref (caps);
/* set */
- if (res && gst_caps_is_empty (res))
- {
- gst_caps_unref (res);
- res = NULL;
- }
+ if (res && gst_caps_is_empty (res)) {
+ gst_caps_unref (res);
+ res = NULL;
+ }
g_object_set (bvw->priv->audio_capsfilter, "caps", res, NULL);
- if (res)
- {
- gst_caps_unref (res);
- }
+ if (res) {
+ gst_caps_unref (res);
+ }
/* reset */
pad = gst_element_get_pad (bvw->priv->audio_capsfilter, "src");
@@ -2801,7 +2510,7 @@ bacon_video_widget_get_audio_out_type (BaconVideoWidget * bvw)
**/
gboolean
bacon_video_widget_set_audio_out_type (BaconVideoWidget * bvw,
- BvwAudioOutType type)
+ BvwAudioOutType type)
{
g_return_val_if_fail (bvw != NULL, FALSE);
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
@@ -2843,146 +2552,108 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
gst_message_parse_error (err_msg, &e, NULL);
- if (is_error (e, RESOURCE, NOT_FOUND) || is_error (e, RESOURCE, OPEN_READ))
- {
+ if (is_error (e, RESOURCE, NOT_FOUND) || is_error (e, RESOURCE, OPEN_READ)) {
#if 0
- if (strchr (mrl, ':') &&
- (g_str_has_prefix (mrl, "dvd") ||
- g_str_has_prefix (mrl, "cd") || g_str_has_prefix (mrl, "vcd")))
- {
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_INVALID_DEVICE,
- e->message);
- }
- else
- {
+ if (strchr (mrl, ':') &&
+ (g_str_has_prefix (mrl, "dvd") ||
+ g_str_has_prefix (mrl, "cd") || g_str_has_prefix (mrl, "vcd"))) {
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_INVALID_DEVICE,
+ e->message);
+ } else {
#endif
- if (e->code == GST_RESOURCE_ERROR_NOT_FOUND)
- {
- if (GST_IS_BASE_AUDIO_SINK (err_msg->src))
- {
- ret =
- g_error_new_literal (BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
- _
- ("The requested audio output was not found. "
- "Please select another audio output in the Multimedia "
- "Systems Selector."));
- }
- else
- {
- ret =
- g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_NOT_FOUND,
- _("Location not found."));
- }
- }
- else
- {
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_PERMISSION,
- _("Could not open location; "
- "you might not have permission to open the file."));
- }
+ if (e->code == GST_RESOURCE_ERROR_NOT_FOUND) {
+ if (GST_IS_BASE_AUDIO_SINK (err_msg->src)) {
+ ret =
+ g_error_new_literal (BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
+ _
+ ("The requested audio output was not found. "
+ "Please select another audio output in the Multimedia "
+ "Systems Selector."));
+ } else {
+ ret =
+ g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_NOT_FOUND,
+ _("Location not found."));
+ }
+ } else {
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_PERMISSION,
+ _("Could not open location; "
+ "you might not have permission to open the file."));
+ }
#if 0
- }
-#endif
- }
- else if (is_error (e, RESOURCE, BUSY))
- {
- if (GST_IS_VIDEO_SINK (err_msg->src))
- {
- /* a somewhat evil check, but hey.. */
- ret = g_error_new_literal (BVW_ERROR,
- GST_ERROR_VIDEO_PLUGIN,
- _
- ("The video output is in use by another application. "
- "Please close other video applications, or select "
- "another video output in the Multimedia Systems Selector."));
- }
- else if (GST_IS_BASE_AUDIO_SINK (err_msg->src))
- {
- ret = g_error_new_literal (BVW_ERROR,
- GST_ERROR_AUDIO_BUSY,
- _
- ("The audio output is in use by another application. "
- "Please select another audio output in the Multimedia Systems Selector. "
- "You may want to consider using a sound server."));
- }
- }
- else if (e->domain == GST_RESOURCE_ERROR)
- {
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_GENERIC,
- e->message);
- }
- else if (is_error (e, CORE, MISSING_PLUGIN) ||
- is_error (e, STREAM, CODEC_NOT_FOUND))
- {
- if (bvw->priv->missing_plugins != NULL)
- {
- gchar **descs, *msg = NULL;
- guint num;
-
- descs =
- bvw_get_missing_plugins_descriptions (bvw->priv->missing_plugins);
- num = g_list_length (bvw->priv->missing_plugins);
-
- if (is_error (e, CORE, MISSING_PLUGIN))
- {
- /* should be exactly one missing thing (source or converter) */
- msg =
- g_strdup_printf (_
- ("The playback of this movie requires a %s "
- "plugin which is not installed."),
- descs[0]);
- }
- else
- {
- gchar *desc_list;
-
- desc_list = g_strjoinv ("\n", descs);
- msg = g_strdup_printf (ngettext (_("The playback of this movie "
- "requires a %s plugin which is not installed."),
- _("The playback "
- "of this movie requires the following decoders which are not "
- "installed:\n\n%s"), num),
- (num == 1) ? descs[0] : desc_list);
- g_free (desc_list);
- }
- ret =
- g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED, msg);
- g_free (msg);
- g_strfreev (descs);
- }
- else
- {
- GST_LOG ("no missing plugin messages, posting generic error");
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED,
- e->message);
- }
- }
- else if (is_error (e, STREAM, WRONG_TYPE) ||
- is_error (e, STREAM, NOT_IMPLEMENTED))
- {
- if (src_typename)
- {
- ret = g_error_new (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED, "%s: %s",
- src_typename, e->message);
- }
- else
- {
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED,
- e->message);
- }
- }
- else if (is_error (e, STREAM, FAILED) &&
- src_typename && strncmp (src_typename, "GstTypeFind", 11) == 0)
- {
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_READ_ERROR,
- _("Cannot play this file over the network. "
- "Try downloading it to disk first."));
- }
- else
- {
- /* generic error, no code; take message */
- ret = g_error_new_literal (BVW_ERROR, GST_ERROR_GENERIC, e->message);
}
+#endif
+ } else if (is_error (e, RESOURCE, BUSY)) {
+ if (GST_IS_VIDEO_SINK (err_msg->src)) {
+ /* a somewhat evil check, but hey.. */
+ ret = g_error_new_literal (BVW_ERROR,
+ GST_ERROR_VIDEO_PLUGIN,
+ _
+ ("The video output is in use by another application. "
+ "Please close other video applications, or select "
+ "another video output in the Multimedia Systems Selector."));
+ } else if (GST_IS_BASE_AUDIO_SINK (err_msg->src)) {
+ ret = g_error_new_literal (BVW_ERROR,
+ GST_ERROR_AUDIO_BUSY,
+ _
+ ("The audio output is in use by another application. "
+ "Please select another audio output in the Multimedia Systems Selector. "
+ "You may want to consider using a sound server."));
+ }
+ } else if (e->domain == GST_RESOURCE_ERROR) {
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_GENERIC, e->message);
+ } else if (is_error (e, CORE, MISSING_PLUGIN) ||
+ is_error (e, STREAM, CODEC_NOT_FOUND)) {
+ if (bvw->priv->missing_plugins != NULL) {
+ gchar **descs, *msg = NULL;
+ guint num;
+
+ descs = bvw_get_missing_plugins_descriptions (bvw->priv->missing_plugins);
+ num = g_list_length (bvw->priv->missing_plugins);
+
+ if (is_error (e, CORE, MISSING_PLUGIN)) {
+ /* should be exactly one missing thing (source or converter) */
+ msg =
+ g_strdup_printf (_
+ ("The playback of this movie requires a %s "
+ "plugin which is not installed."), descs[0]);
+ } else {
+ gchar *desc_list;
+
+ desc_list = g_strjoinv ("\n", descs);
+ msg = g_strdup_printf (ngettext (_("The playback of this movie "
+ "requires a %s plugin which is not installed."),
+ _("The playback "
+ "of this movie requires the following decoders which are not "
+ "installed:\n\n%s"), num),
+ (num == 1) ? descs[0] : desc_list);
+ g_free (desc_list);
+ }
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED, msg);
+ g_free (msg);
+ g_strfreev (descs);
+ } else {
+ GST_LOG ("no missing plugin messages, posting generic error");
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED,
+ e->message);
+ }
+ } else if (is_error (e, STREAM, WRONG_TYPE) ||
+ is_error (e, STREAM, NOT_IMPLEMENTED)) {
+ if (src_typename) {
+ ret = g_error_new (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED, "%s: %s",
+ src_typename, e->message);
+ } else {
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_CODEC_NOT_HANDLED,
+ e->message);
+ }
+ } else if (is_error (e, STREAM, FAILED) &&
+ src_typename && strncmp (src_typename, "GstTypeFind", 11) == 0) {
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_READ_ERROR,
+ _("Cannot play this file over the network. "
+ "Try downloading it to disk first."));
+ } else {
+ /* generic error, no code; take message */
+ ret = g_error_new_literal (BVW_ERROR, GST_ERROR_GENERIC, e->message);
+ }
g_error_free (e);
bvw_clear_missing_plugins_messages (bvw);
@@ -2992,8 +2663,7 @@ bvw_error_from_gst_error (BaconVideoWidget * bvw, GstMessage * err_msg)
static gboolean
poll_for_state_change_full (BaconVideoWidget * bvw, GstElement * element,
- GstState state, GstMessage ** err_msg,
- gint64 timeout)
+ GstState state, GstMessage ** err_msg, gint64 timeout)
{
GstBus *bus;
GstMessageType events, saved_events;
@@ -3006,82 +2676,74 @@ poll_for_state_change_full (BaconVideoWidget * bvw, GstElement * element,
saved_events = bvw->priv->ignore_messages_mask;
- if (element != NULL && element == bvw->priv->play)
- {
- /* we do want the main handler to process state changed messages for
- * playbin as well, otherwise it won't hook up the timeout etc. */
- bvw->priv->ignore_messages_mask |= (events ^ GST_MESSAGE_STATE_CHANGED);
- }
- else
- {
- bvw->priv->ignore_messages_mask |= events;
- }
+ if (element != NULL && element == bvw->priv->play) {
+ /* we do want the main handler to process state changed messages for
+ * playbin as well, otherwise it won't hook up the timeout etc. */
+ bvw->priv->ignore_messages_mask |= (events ^ GST_MESSAGE_STATE_CHANGED);
+ } else {
+ bvw->priv->ignore_messages_mask |= events;
+ }
- while (TRUE)
- {
- GstMessage *message;
- GstElement *src;
-
- message = gst_bus_poll (bus, events, timeout);
-
- if (!message)
- goto timed_out;
-
- src = (GstElement *) GST_MESSAGE_SRC (message);
-
- switch (GST_MESSAGE_TYPE (message))
- {
- case GST_MESSAGE_STATE_CHANGED:
- {
- GstState old, new, pending;
-
- if (src == element)
- {
- gst_message_parse_state_changed (message, &old, &new,
- &pending);
- if (new == state)
- {
- gst_message_unref (message);
- goto success;
- }
- }
- break;
- }
- case GST_MESSAGE_ERROR:
- {
- bvw_error_msg (bvw, message);
- *err_msg = message;
- message = NULL;
- goto error;
- break;
- }
- case GST_MESSAGE_EOS:
- {
- GError *e = NULL;
-
- gst_message_unref (message);
- e = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_GENERIC,
- _("Media file could not be played."));
- *err_msg =
- gst_message_new_error (GST_OBJECT (bvw->priv->play), e, NULL);
- g_error_free (e);
- goto error;
- break;
- }
- default:
- g_assert_not_reached ();
- break;
- }
-
- gst_message_unref (message);
+ while (TRUE) {
+ GstMessage *message;
+ GstElement *src;
+
+ message = gst_bus_poll (bus, events, timeout);
+
+ if (!message)
+ goto timed_out;
+
+ src = (GstElement *) GST_MESSAGE_SRC (message);
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_STATE_CHANGED:
+ {
+ GstState old, new, pending;
+
+ if (src == element) {
+ gst_message_parse_state_changed (message, &old, &new, &pending);
+ if (new == state) {
+ gst_message_unref (message);
+ goto success;
+ }
+ }
+ break;
+ }
+ case GST_MESSAGE_ERROR:
+ {
+ bvw_error_msg (bvw, message);
+ *err_msg = message;
+ message = NULL;
+ goto error;
+ break;
+ }
+ case GST_MESSAGE_EOS:
+ {
+ GError *e = NULL;
+
+ gst_message_unref (message);
+ e = g_error_new_literal (BVW_ERROR, GST_ERROR_FILE_GENERIC,
+ _("Media file could not be played."));
+ *err_msg =
+ gst_message_new_error (GST_OBJECT (bvw->priv->play), e, NULL);
+ g_error_free (e);
+ goto error;
+ break;
+ }
+ default:
+ g_assert_not_reached ();
+ break;
}
+ gst_message_unref (message);
+ }
+
g_assert_not_reached ();
success:
/* state change succeeded */
GST_DEBUG ("state change to %s succeeded",
- gst_element_state_get_name (state));
+ gst_element_state_get_name (state));
bvw->priv->ignore_messages_mask = saved_events;
return TRUE;
@@ -3089,13 +2751,13 @@ timed_out:
/* it's taking a long time to open -- just tell totem it was ok, this allows
* the user to stop the loading process with the normal stop button */
GST_DEBUG ("state change to %s timed out, returning success and handling "
- "errors asynchronously", gst_element_state_get_name (state));
+ "errors asynchronously", gst_element_state_get_name (state));
bvw->priv->ignore_messages_mask = saved_events;
return TRUE;
error:
GST_DEBUG ("error while waiting for state change to %s: %" GST_PTR_FORMAT,
- gst_element_state_get_name (state), *err_msg);
+ gst_element_state_get_name (state), *err_msg);
/* already set *err_msg */
bvw->priv->ignore_messages_mask = saved_events;
return FALSE;
@@ -3123,8 +2785,7 @@ error:
gboolean
bacon_video_widget_open (BaconVideoWidget * bvw,
- const gchar * mrl, const gchar * subtitle_uri,
- GError ** error)
+ const gchar * mrl, const gchar * subtitle_uri, GError ** error)
{
GstMessage *err_msg = NULL;
@@ -3139,10 +2800,9 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
/* So we aren't closed yet... */
- if (bvw->priv->mrl)
- {
- bacon_video_widget_close (bvw);
- }
+ if (bvw->priv->mrl) {
+ bacon_video_widget_close (bvw);
+ }
GST_DEBUG ("mrl = %s", GST_STR_NULL (mrl));
GST_DEBUG ("subtitle_uri = %s", GST_STR_NULL (subtitle_uri));
@@ -3153,46 +2813,36 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
/* Only use the URI when FUSE isn't available for a file */
path = g_file_get_path (file);
- if (path)
- {
- bvw->priv->mrl = g_filename_to_uri (path, NULL, NULL);
- g_free (path);
- }
- else
- {
- bvw->priv->mrl = g_strdup (mrl);
- }
+ if (path) {
+ bvw->priv->mrl = g_filename_to_uri (path, NULL, NULL);
+ g_free (path);
+ } else {
+ bvw->priv->mrl = g_strdup (mrl);
+ }
g_object_unref (file);
- if (g_str_has_prefix (mrl, "icy:") != FALSE)
- {
- /* Handle "icy://" URLs from QuickTime */
- g_free (bvw->priv->mrl);
- bvw->priv->mrl = g_strdup_printf ("http:%s", mrl + 4);
- }
- else if (g_str_has_prefix (mrl, "icyx:") != FALSE)
- {
- /* Handle "icyx://" URLs from Orban/Coding Technologies AAC/aacPlus Player */
- g_free (bvw->priv->mrl);
- bvw->priv->mrl = g_strdup_printf ("http:%s", mrl + 5);
- }
- else if (g_str_has_prefix (mrl, "dvd:///"))
- {
- /* this allows to play backups of dvds */
- g_free (bvw->priv->mrl);
- bvw->priv->mrl = g_strdup ("dvd://");
- g_free (bvw->priv->media_device);
- bvw->priv->media_device = g_strdup (mrl + strlen ("dvd://"));
- }
- else if (g_str_has_prefix (mrl, "vcd:///"))
- {
- /* this allows to play backups of vcds */
- g_free (bvw->priv->mrl);
- bvw->priv->mrl = g_strdup ("vcd://");
- g_free (bvw->priv->media_device);
- bvw->priv->media_device = g_strdup (mrl + strlen ("vcd://"));
- }
+ if (g_str_has_prefix (mrl, "icy:") != FALSE) {
+ /* Handle "icy://" URLs from QuickTime */
+ g_free (bvw->priv->mrl);
+ bvw->priv->mrl = g_strdup_printf ("http:%s", mrl + 4);
+ } else if (g_str_has_prefix (mrl, "icyx:") != FALSE) {
+ /* Handle "icyx://" URLs from Orban/Coding Technologies AAC/aacPlus Player */
+ g_free (bvw->priv->mrl);
+ bvw->priv->mrl = g_strdup_printf ("http:%s", mrl + 5);
+ } else if (g_str_has_prefix (mrl, "dvd:///")) {
+ /* this allows to play backups of dvds */
+ g_free (bvw->priv->mrl);
+ bvw->priv->mrl = g_strdup ("dvd://");
+ g_free (bvw->priv->media_device);
+ bvw->priv->media_device = g_strdup (mrl + strlen ("dvd://"));
+ } else if (g_str_has_prefix (mrl, "vcd:///")) {
+ /* this allows to play backups of vcds */
+ g_free (bvw->priv->mrl);
+ bvw->priv->mrl = g_strdup ("vcd://");
+ g_free (bvw->priv->media_device);
+ bvw->priv->media_device = g_strdup (mrl + strlen ("vcd://"));
+ }
bvw->priv->got_redirect = FALSE;
bvw->priv->media_has_video = FALSE;
@@ -3200,48 +2850,36 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
bvw->priv->stream_length = 0;
bvw->priv->ignore_messages_mask = 0;
- if (g_strrstr (bvw->priv->mrl, "#subtitle:"))
- {
- gchar **uris;
- gchar *subtitle_uri;
-
- uris = g_strsplit (bvw->priv->mrl, "#subtitle:", 2);
- /* Try to fix subtitle uri if needed */
- if (uris[1][0] == '/')
- {
- subtitle_uri = g_strdup_printf ("file://%s", uris[1]);
- }
- else
- {
- if (strchr (uris[1], ':'))
- {
- subtitle_uri = g_strdup (uris[1]);
- }
- else
- {
- gchar *cur_dir = g_get_current_dir ();
- if (!cur_dir)
- {
- g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
- _
- ("Failed to retrieve working directory"));
- return FALSE;
- }
- subtitle_uri =
- g_strdup_printf ("file://%s/%s", cur_dir, uris[1]);
- g_free (cur_dir);
- }
- }
- g_object_set (bvw->priv->play, "uri", bvw->priv->mrl,
- "suburi", subtitle_uri, NULL);
- g_free (subtitle_uri);
- g_strfreev (uris);
+ if (g_strrstr (bvw->priv->mrl, "#subtitle:")) {
+ gchar **uris;
+ gchar *subtitle_uri;
+
+ uris = g_strsplit (bvw->priv->mrl, "#subtitle:", 2);
+ /* Try to fix subtitle uri if needed */
+ if (uris[1][0] == '/') {
+ subtitle_uri = g_strdup_printf ("file://%s", uris[1]);
+ } else {
+ if (strchr (uris[1], ':')) {
+ subtitle_uri = g_strdup (uris[1]);
+ } else {
+ gchar *cur_dir = g_get_current_dir ();
+ if (!cur_dir) {
+ g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
+ _("Failed to retrieve working directory"));
+ return FALSE;
+ }
+ subtitle_uri = g_strdup_printf ("file://%s/%s", cur_dir, uris[1]);
+ g_free (cur_dir);
+ }
}
- else
- {
+ g_object_set (bvw->priv->play, "uri", bvw->priv->mrl,
+ "suburi", subtitle_uri, NULL);
+ g_free (subtitle_uri);
+ g_strfreev (uris);
+ } else {
- g_object_set (bvw->priv->play, "uri", bvw->priv->mrl, NULL);
- }
+ g_object_set (bvw->priv->play, "uri", bvw->priv->mrl, NULL);
+ }
bvw->priv->seekable = -1;
bvw->priv->target_state = GST_STATE_PAUSED;
@@ -3250,72 +2888,57 @@ bacon_video_widget_open (BaconVideoWidget * bvw,
gst_element_set_state (bvw->priv->play, GST_STATE_PAUSED);
if (bvw->priv->use_type == BVW_USE_TYPE_AUDIO ||
- bvw->priv->use_type == BVW_USE_TYPE_VIDEO)
- {
- GST_INFO ("normal playback, handling all errors asynchroneously");
- ret = TRUE;
- }
- else
- {
- /* used as thumbnailer or metadata extractor for properties dialog. In
- * this case, wait for any state change to really finish and process any
- * pending tag messages, so that the information is available right away */
- GST_INFO ("waiting for state changed to PAUSED to complete");
- ret = poll_for_state_change_full (bvw, bvw->priv->play,
- GST_STATE_PAUSED, &err_msg, -1);
-
- bvw_process_pending_tag_messages (bvw);
- bacon_video_widget_get_stream_length (bvw);
- GST_INFO ("stream length = %u", bvw->priv->stream_length);
-
- /* even in case of an error (e.g. no decoders installed) we might still
- * have useful metadata (like codec types, duration, etc.) */
- g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
- }
+ bvw->priv->use_type == BVW_USE_TYPE_VIDEO) {
+ GST_INFO ("normal playback, handling all errors asynchroneously");
+ ret = TRUE;
+ } else {
+ /* used as thumbnailer or metadata extractor for properties dialog. In
+ * this case, wait for any state change to really finish and process any
+ * pending tag messages, so that the information is available right away */
+ GST_INFO ("waiting for state changed to PAUSED to complete");
+ ret = poll_for_state_change_full (bvw, bvw->priv->play,
+ GST_STATE_PAUSED, &err_msg, -1);
+
+ bvw_process_pending_tag_messages (bvw);
+ bacon_video_widget_get_stream_length (bvw);
+ GST_INFO ("stream length = %u", bvw->priv->stream_length);
+
+ /* even in case of an error (e.g. no decoders installed) we might still
+ * have useful metadata (like codec types, duration, etc.) */
+ g_signal_emit (bvw, bvw_signals[SIGNAL_GOT_METADATA], 0, NULL);
+ }
- if (ret)
- {
- g_signal_emit (bvw, bvw_signals[SIGNAL_CHANNELS_CHANGE], 0);
- }
- else
- {
- GST_INFO ("Error on open: %" GST_PTR_FORMAT, err_msg);
- if (bvw_check_missing_plugins_error (bvw, err_msg))
- {
- /* totem will try to start playing, so ignore all messages on the bus */
- bvw->priv->ignore_messages_mask |= GST_MESSAGE_ERROR;
- GST_LOG
- ("missing plugins handled, ignoring error and returning TRUE");
- gst_message_unref (err_msg);
- err_msg = NULL;
- ret = TRUE;
- }
- else
- {
- bvw->priv->ignore_messages_mask |= GST_MESSAGE_ERROR;
- bvw_stop_play_pipeline (bvw);
- g_free (bvw->priv->mrl);
- bvw->priv->mrl = NULL;
- }
+ if (ret) {
+ g_signal_emit (bvw, bvw_signals[SIGNAL_CHANNELS_CHANGE], 0);
+ } else {
+ GST_INFO ("Error on open: %" GST_PTR_FORMAT, err_msg);
+ if (bvw_check_missing_plugins_error (bvw, err_msg)) {
+ /* totem will try to start playing, so ignore all messages on the bus */
+ bvw->priv->ignore_messages_mask |= GST_MESSAGE_ERROR;
+ GST_LOG ("missing plugins handled, ignoring error and returning TRUE");
+ gst_message_unref (err_msg);
+ err_msg = NULL;
+ ret = TRUE;
+ } else {
+ bvw->priv->ignore_messages_mask |= GST_MESSAGE_ERROR;
+ bvw_stop_play_pipeline (bvw);
+ g_free (bvw->priv->mrl);
+ bvw->priv->mrl = NULL;
}
+ }
/* When opening a new media we want to redraw ourselves */
gtk_widget_queue_draw (GTK_WIDGET (bvw));
- if (err_msg != NULL)
- {
- if (error)
- {
- *error = bvw_error_from_gst_error (bvw, err_msg);
+ if (err_msg != NULL) {
+ if (error) {
+ *error = bvw_error_from_gst_error (bvw, err_msg);
- }
- else
- {
- GST_WARNING
- ("Got error, but caller is not collecting error details!");
- }
- gst_message_unref (err_msg);
+ } else {
+ GST_WARNING ("Got error, but caller is not collecting error details!");
}
+ gst_message_unref (err_msg);
+ }
return ret;
@@ -3350,19 +2973,16 @@ bacon_video_widget_play (BaconVideoWidget * bvw)
* not with sinks that don't sync to the clock), we'll get everything
* we need by prerolling the pipeline, and that is done in _open() */
if (bvw->priv->use_type == BVW_USE_TYPE_CAPTURE ||
- bvw->priv->use_type == BVW_USE_TYPE_METADATA)
- {
- return TRUE;
- }
+ bvw->priv->use_type == BVW_USE_TYPE_METADATA) {
+ return TRUE;
+ }
/* just lie and do nothing in this case */
gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0);
- if (bvw->priv->plugin_install_in_progress && cur_state != GST_STATE_PAUSED)
- {
- GST_INFO
- ("plugin install in progress and nothing to play, doing nothing");
- return TRUE;
- }
+ if (bvw->priv->plugin_install_in_progress && cur_state != GST_STATE_PAUSED) {
+ GST_INFO ("plugin install in progress and nothing to play, doing nothing");
+ return TRUE;
+ }
GST_INFO ("play");
gst_element_set_state (bvw->priv->play, GST_STATE_PLAYING);
@@ -3403,7 +3023,7 @@ bacon_video_widget_can_direct_seek (BaconVideoWidget * bvw)
//Sometimes accurate position is requested so we use the ACCURATE flag
gboolean
bacon_video_widget_seek_time (BaconVideoWidget * bvw, gint64 time,
- gfloat rate, gboolean accurate)
+ gfloat rate, gboolean accurate)
{
@@ -3411,39 +3031,34 @@ bacon_video_widget_seek_time (BaconVideoWidget * bvw, gint64 time,
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
- GST_LOG ("Seeking to %" GST_TIME_FORMAT,
- GST_TIME_ARGS (time * GST_MSECOND));
+ GST_LOG ("Seeking to %" GST_TIME_FORMAT, GST_TIME_ARGS (time * GST_MSECOND));
if (time > bvw->priv->stream_length
&& bvw->priv->stream_length > 0
&& !g_str_has_prefix (bvw->priv->mrl, "dvd:")
- && !g_str_has_prefix (bvw->priv->mrl, "vcd:"))
- {
- if (bvw->priv->eos_id == 0)
- bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
- return TRUE;
- }
+ && !g_str_has_prefix (bvw->priv->mrl, "vcd:")) {
+ if (bvw->priv->eos_id == 0)
+ bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
+ return TRUE;
+ }
- if (accurate)
- {
- got_time_tick (bvw->priv->play, time * GST_MSECOND, bvw);
- gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- GST_SEEK_TYPE_SET, time * GST_MSECOND,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
- }
- else
- {
- /* Emit a time tick of where we are going, we are paused */
- got_time_tick (bvw->priv->play, time * GST_MSECOND, bvw);
- gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
- GST_SEEK_TYPE_SET, time * GST_MSECOND,
- GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
- }
+ if (accurate) {
+ got_time_tick (bvw->priv->play, time * GST_MSECOND, bvw);
+ gst_element_seek (bvw->priv->play, rate,
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_SEEK_TYPE_SET, time * GST_MSECOND,
+ GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+ } else {
+ /* Emit a time tick of where we are going, we are paused */
+ got_time_tick (bvw->priv->play, time * GST_MSECOND, bvw);
+ gst_element_seek (bvw->priv->play, rate,
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT,
+ GST_SEEK_TYPE_SET, time * GST_MSECOND,
+ GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+ }
return TRUE;
}
@@ -3452,8 +3067,7 @@ bacon_video_widget_seek_time (BaconVideoWidget * bvw, gint64 time,
gboolean
-bacon_video_widget_seek (BaconVideoWidget * bvw, gdouble position,
- gfloat rate)
+bacon_video_widget_seek (BaconVideoWidget * bvw, gdouble position, gfloat rate)
{
gint64 seek_time, length_nanos;
@@ -3466,15 +3080,15 @@ bacon_video_widget_seek (BaconVideoWidget * bvw, gdouble position,
seek_time = (gint64) (length_nanos * position);
GST_LOG ("Seeking to %3.2f%% %" GST_TIME_FORMAT, position,
- GST_TIME_ARGS (seek_time));
+ GST_TIME_ARGS (seek_time));
return bacon_video_widget_seek_time (bvw, seek_time / GST_MSECOND, rate,
- FALSE);
+ FALSE);
}
gboolean
bacon_video_widget_seek_in_segment (BaconVideoWidget * bvw, gint64 pos,
- gfloat rate)
+ gfloat rate)
{
g_return_val_if_fail (bvw != NULL, FALSE);
@@ -3482,48 +3096,46 @@ bacon_video_widget_seek_in_segment (BaconVideoWidget * bvw, gint64 pos,
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
GST_LOG ("Segment seeking from %" GST_TIME_FORMAT,
- GST_TIME_ARGS (pos * GST_MSECOND));
+ GST_TIME_ARGS (pos * GST_MSECOND));
if (pos > bvw->priv->stream_length
&& bvw->priv->stream_length > 0
&& !g_str_has_prefix (bvw->priv->mrl, "dvd:")
- && !g_str_has_prefix (bvw->priv->mrl, "vcd:"))
- {
- if (bvw->priv->eos_id == 0)
- bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
- return TRUE;
- }
+ && !g_str_has_prefix (bvw->priv->mrl, "vcd:")) {
+ if (bvw->priv->eos_id == 0)
+ bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
+ return TRUE;
+ }
got_time_tick (bvw->priv->play, pos * GST_MSECOND, bvw);
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
- GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
- pos * GST_MSECOND, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
+ GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
+ pos * GST_MSECOND, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
return TRUE;
}
gboolean
bacon_video_widget_set_rate_in_segment (BaconVideoWidget * bvw, gfloat rate,
- gint64 stop)
+ gint64 stop)
{
guint64 pos;
g_return_val_if_fail (bvw != NULL, FALSE);
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
-
+
pos = bacon_video_widget_get_accurate_current_time (bvw);
if (pos == 0)
return FALSE;
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
- GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
- pos * GST_MSECOND, GST_SEEK_TYPE_SET, stop * GST_MSECOND);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
+ GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
+ pos * GST_MSECOND, GST_SEEK_TYPE_SET, stop * GST_MSECOND);
return TRUE;
}
@@ -3532,7 +3144,7 @@ gboolean
bacon_video_widget_set_rate (BaconVideoWidget * bvw, gfloat rate)
{
guint64 pos;
-
+
g_return_val_if_fail (bvw != NULL, FALSE);
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
@@ -3542,10 +3154,10 @@ bacon_video_widget_set_rate (BaconVideoWidget * bvw, gfloat rate)
return FALSE;
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- GST_SEEK_TYPE_SET,
- pos * GST_MSECOND, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_SEEK_TYPE_SET,
+ pos * GST_MSECOND, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
return TRUE;
}
@@ -3553,7 +3165,7 @@ bacon_video_widget_set_rate (BaconVideoWidget * bvw, gfloat rate)
gboolean
bacon_video_widget_new_file_seek (BaconVideoWidget * bvw, gint64 start,
- gint64 stop, gfloat rate)
+ gint64 stop, gfloat rate)
{
g_return_val_if_fail (bvw != NULL, FALSE);
@@ -3561,32 +3173,30 @@ bacon_video_widget_new_file_seek (BaconVideoWidget * bvw, gint64 start,
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
GST_LOG ("Segment seeking from %" GST_TIME_FORMAT,
- GST_TIME_ARGS (start * GST_MSECOND));
+ GST_TIME_ARGS (start * GST_MSECOND));
if (start > bvw->priv->stream_length
&& bvw->priv->stream_length > 0
&& !g_str_has_prefix (bvw->priv->mrl, "dvd:")
- && !g_str_has_prefix (bvw->priv->mrl, "vcd:"))
- {
- if (bvw->priv->eos_id == 0)
- bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
- return TRUE;
- }
+ && !g_str_has_prefix (bvw->priv->mrl, "vcd:")) {
+ if (bvw->priv->eos_id == 0)
+ bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
+ return TRUE;
+ }
GST_LOG ("Segment seeking from %" GST_TIME_FORMAT,
- GST_TIME_ARGS (start * GST_MSECOND));
+ GST_TIME_ARGS (start * GST_MSECOND));
//FIXME Needs to wait until GST_STATE_PAUSED
gst_element_get_state (bvw->priv->play, NULL, NULL, 0);
got_time_tick (bvw->priv->play, start * GST_MSECOND, bvw);
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
- GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
- start * GST_MSECOND, GST_SEEK_TYPE_SET,
- stop * GST_MSECOND);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
+ GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
+ start * GST_MSECOND, GST_SEEK_TYPE_SET, stop * GST_MSECOND);
gst_element_set_state (bvw->priv->play, GST_STATE_PLAYING);
return TRUE;
@@ -3594,7 +3204,7 @@ bacon_video_widget_new_file_seek (BaconVideoWidget * bvw, gint64 start,
gboolean
bacon_video_widget_segment_seek (BaconVideoWidget * bvw, gint64 start,
- gint64 stop, gfloat rate)
+ gint64 stop, gfloat rate)
{
g_return_val_if_fail (bvw != NULL, FALSE);
@@ -3602,33 +3212,31 @@ bacon_video_widget_segment_seek (BaconVideoWidget * bvw, gint64 start,
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), FALSE);
GST_LOG ("Segment seeking from %" GST_TIME_FORMAT,
- GST_TIME_ARGS (start * GST_MSECOND));
+ GST_TIME_ARGS (start * GST_MSECOND));
if (start > bvw->priv->stream_length
&& bvw->priv->stream_length > 0
&& !g_str_has_prefix (bvw->priv->mrl, "dvd:")
- && !g_str_has_prefix (bvw->priv->mrl, "vcd:"))
- {
- if (bvw->priv->eos_id == 0)
- bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
- return TRUE;
- }
+ && !g_str_has_prefix (bvw->priv->mrl, "vcd:")) {
+ if (bvw->priv->eos_id == 0)
+ bvw->priv->eos_id = g_idle_add (bvw_signal_eos_delayed, bvw);
+ return TRUE;
+ }
got_time_tick (bvw->priv->play, start * GST_MSECOND, bvw);
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
- GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
- start * GST_MSECOND, GST_SEEK_TYPE_SET,
- stop * GST_MSECOND);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
+ GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
+ start * GST_MSECOND, GST_SEEK_TYPE_SET, stop * GST_MSECOND);
return TRUE;
}
gboolean
bacon_video_widget_seek_to_next_frame (BaconVideoWidget * bvw, gfloat rate,
- gboolean in_segment)
+ gboolean in_segment)
{
gint fps;
@@ -3644,7 +3252,7 @@ bacon_video_widget_seek_to_next_frame (BaconVideoWidget * bvw, gfloat rate,
//Round framerate to the nearest integer
fps = (bvw->priv->video_fps_n + bvw->priv->video_fps_d / 2) /
- bvw->priv->video_fps_d;
+ bvw->priv->video_fps_d;
pos = bacon_video_widget_get_accurate_current_time (bvw);
if (pos == 0)
return FALSE;
@@ -3658,18 +3266,16 @@ bacon_video_widget_seek_to_next_frame (BaconVideoWidget * bvw, gfloat rate,
bacon_video_widget_pause (bvw);
if (in_segment)
ret = gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
- GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
- final_pos, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
+ GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
+ final_pos, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
else
ret = gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- GST_SEEK_TYPE_SET, final_pos, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_SEEK_TYPE_SET, final_pos, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
gst_x_overlay_expose (bvw->priv->xoverlay);
@@ -3683,7 +3289,7 @@ bacon_video_widget_seek_to_next_frame (BaconVideoWidget * bvw, gfloat rate,
gboolean
bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
- gfloat rate, gboolean in_segment)
+ gfloat rate, gboolean in_segment)
{
gint fps;
gint64 pos;
@@ -3697,7 +3303,7 @@ bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
//Round framerate to the nearest integer
fps = (bvw->priv->video_fps_n + bvw->priv->video_fps_d / 2) /
- bvw->priv->video_fps_d;
+ bvw->priv->video_fps_d;
pos = bacon_video_widget_get_accurate_current_time (bvw);
final_pos = pos * GST_MSECOND - 1 * GST_SECOND / fps;
@@ -3712,18 +3318,16 @@ bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
if (in_segment)
ret = gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
- GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
- final_pos, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE |
+ GST_SEEK_FLAG_SEGMENT, GST_SEEK_TYPE_SET,
+ final_pos, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
else
ret = gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
- GST_SEEK_TYPE_SET, final_pos, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE,
+ GST_SEEK_TYPE_SET, final_pos, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
gst_x_overlay_expose (bvw->priv->xoverlay);
@@ -3736,7 +3340,7 @@ bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
gboolean
bacon_video_widget_segment_stop_update (BaconVideoWidget * bvw, gint64 stop,
- gfloat rate)
+ gfloat rate)
{
g_return_val_if_fail (bvw != NULL, FALSE);
@@ -3747,11 +3351,10 @@ bacon_video_widget_segment_stop_update (BaconVideoWidget * bvw, gint64 stop,
#endif*/
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
- GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
- stop * GST_MSECOND - 1, GST_SEEK_TYPE_SET,
- stop * GST_MSECOND);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
+ GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
+ stop * GST_MSECOND - 1, GST_SEEK_TYPE_SET, stop * GST_MSECOND);
if (bacon_video_widget_is_playing (bvw))
bacon_video_widget_pause (bvw);
@@ -3763,7 +3366,7 @@ bacon_video_widget_segment_stop_update (BaconVideoWidget * bvw, gint64 stop,
gboolean
bacon_video_widget_segment_start_update (BaconVideoWidget * bvw, gint64 start,
- gfloat rate)
+ gfloat rate)
{
g_return_val_if_fail (bvw != NULL, FALSE);
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), FALSE);
@@ -3772,11 +3375,10 @@ bacon_video_widget_segment_start_update (BaconVideoWidget * bvw, gint64 start,
bacon_video_widget_play(bvw);
#endif*/
gst_element_seek (bvw->priv->play, rate,
- GST_FORMAT_TIME,
- GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
- GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
- start * GST_MSECOND, GST_SEEK_TYPE_NONE,
- GST_CLOCK_TIME_NONE);
+ GST_FORMAT_TIME,
+ GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_SEGMENT |
+ GST_SEEK_FLAG_ACCURATE, GST_SEEK_TYPE_SET,
+ start * GST_MSECOND, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);
if (bacon_video_widget_is_playing (bvw))
bacon_video_widget_pause (bvw);
@@ -3794,25 +3396,23 @@ bvw_stop_play_pipeline (BaconVideoWidget * bvw)
GstState cur_state;
gst_element_get_state (bvw->priv->play, &cur_state, NULL, 0);
- if (cur_state > GST_STATE_READY)
- {
- GstMessage *msg;
- GstBus *bus;
-
- GST_INFO ("stopping");
- gst_element_set_state (bvw->priv->play, GST_STATE_READY);
-
- /* process all remaining state-change messages so everything gets
- * cleaned up properly (before the state change to NULL flushes them) */
- GST_INFO ("processing pending state-change messages");
- bus = gst_element_get_bus (bvw->priv->play);
- while ((msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, 0)))
- {
- gst_bus_async_signal_func (bus, msg, NULL);
- gst_message_unref (msg);
- }
- gst_object_unref (bus);
+ if (cur_state > GST_STATE_READY) {
+ GstMessage *msg;
+ GstBus *bus;
+
+ GST_INFO ("stopping");
+ gst_element_set_state (bvw->priv->play, GST_STATE_READY);
+
+ /* process all remaining state-change messages so everything gets
+ * cleaned up properly (before the state change to NULL flushes them) */
+ GST_INFO ("processing pending state-change messages");
+ bus = gst_element_get_bus (bvw->priv->play);
+ while ((msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, 0))) {
+ gst_bus_async_signal_func (bus, msg, NULL);
+ gst_message_unref (msg);
}
+ gst_object_unref (bus);
+ }
gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
bvw->priv->target_state = GST_STATE_NULL;
@@ -3876,16 +3476,14 @@ bacon_video_widget_redraw_last_frame (BaconVideoWidget * bvw)
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
g_return_if_fail (bvw->priv->xoverlay != NULL);
- if (!bvw->priv->logo_mode && !bacon_video_widget_is_playing (bvw))
- {
- gst_x_overlay_expose (bvw->priv->xoverlay);
- }
+ if (!bvw->priv->logo_mode && !bacon_video_widget_is_playing (bvw)) {
+ gst_x_overlay_expose (bvw->priv->xoverlay);
+ }
}
#if 0
static void
-bvw_do_navigation_command (BaconVideoWidget * bvw,
- GstNavigationCommand command)
+bvw_do_navigation_command (BaconVideoWidget * bvw, GstNavigationCommand command)
{
GstNavigation *nav = bvw_get_navigation_iface (bvw);
if (nav == NULL)
@@ -3912,8 +3510,7 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw, BvwDVDEvent type)
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
- switch (type)
- {
+ switch (type) {
case BVW_DVD_ROOT_MENU:
bvw_do_navigation_command (bvw, GST_NAVIGATION_COMMAND_DVD_MENU);
break;
@@ -3922,7 +3519,7 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw, BvwDVDEvent type)
break;
case BVW_DVD_SUBPICTURE_MENU:
bvw_do_navigation_command (bvw,
- GST_NAVIGATION_COMMAND_DVD_SUBPICTURE_MENU);
+ GST_NAVIGATION_COMMAND_DVD_SUBPICTURE_MENU);
break;
case BVW_DVD_AUDIO_MENU:
bvw_do_navigation_command (bvw, GST_NAVIGATION_COMMAND_DVD_AUDIO_MENU);
@@ -3931,8 +3528,7 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw, BvwDVDEvent type)
bvw_do_navigation_command (bvw, GST_NAVIGATION_COMMAND_DVD_ANGLE_MENU);
break;
case BVW_DVD_CHAPTER_MENU:
- bvw_do_navigation_command (bvw,
- GST_NAVIGATION_COMMAND_DVD_CHAPTER_MENU);
+ bvw_do_navigation_command (bvw, GST_NAVIGATION_COMMAND_DVD_CHAPTER_MENU);
break;
case BVW_DVD_NEXT_ANGLE:
bvw_do_navigation_command (bvw, GST_NAVIGATION_COMMAND_NEXT_ANGLE);
@@ -3959,43 +3555,40 @@ bacon_video_widget_dvd_event (BaconVideoWidget * bvw, BvwDVDEvent type)
case BVW_DVD_PREV_CHAPTER:
case BVW_DVD_NEXT_TITLE:
case BVW_DVD_PREV_TITLE:
- {
- const gchar *fmt_name;
- GstFormat fmt;
- gint64 val;
- gint dir;
-
- if (type == BVW_DVD_NEXT_CHAPTER || type == BVW_DVD_NEXT_TITLE)
- dir = 1;
- else
- dir = -1;
-
- if (type == BVW_DVD_NEXT_CHAPTER || type == BVW_DVD_PREV_CHAPTER)
- fmt_name = "chapter";
- else if (type == BVW_DVD_NEXT_TITLE || type == BVW_DVD_PREV_TITLE)
- fmt_name = "title";
- else
- fmt_name = "angle";
-
- fmt = gst_format_get_by_nick (fmt_name);
- if (gst_element_query_position (bvw->priv->play, &fmt, &val))
- {
- GST_DEBUG ("current %s is: %" G_GINT64_FORMAT, fmt_name, val);
- val += dir;
- GST_DEBUG ("seeking to %s: %" G_GINT64_FORMAT, val);
- gst_element_seek (bvw->priv->play, 1.0, fmt, GST_SEEK_FLAG_FLUSH,
- GST_SEEK_TYPE_SET, val, GST_SEEK_TYPE_NONE, 0);
- }
- else
- {
- GST_DEBUG ("failed to query position (%s)", fmt_name);
- }
- break;
+ {
+ const gchar *fmt_name;
+ GstFormat fmt;
+ gint64 val;
+ gint dir;
+
+ if (type == BVW_DVD_NEXT_CHAPTER || type == BVW_DVD_NEXT_TITLE)
+ dir = 1;
+ else
+ dir = -1;
+
+ if (type == BVW_DVD_NEXT_CHAPTER || type == BVW_DVD_PREV_CHAPTER)
+ fmt_name = "chapter";
+ else if (type == BVW_DVD_NEXT_TITLE || type == BVW_DVD_PREV_TITLE)
+ fmt_name = "title";
+ else
+ fmt_name = "angle";
+
+ fmt = gst_format_get_by_nick (fmt_name);
+ if (gst_element_query_position (bvw->priv->play, &fmt, &val)) {
+ GST_DEBUG ("current %s is: %" G_GINT64_FORMAT, fmt_name, val);
+ val += dir;
+ GST_DEBUG ("seeking to %s: %" G_GINT64_FORMAT, val);
+ gst_element_seek (bvw->priv->play, 1.0, fmt, GST_SEEK_FLAG_FLUSH,
+ GST_SEEK_TYPE_SET, val, GST_SEEK_TYPE_NONE, 0);
+ } else {
+ GST_DEBUG ("failed to query position (%s)", fmt_name);
}
+ break;
+ }
default:
GST_WARNING ("unhandled type %d", type);
break;
- }
+ }
}
#endif
@@ -4019,12 +3612,11 @@ bacon_video_widget_set_logo (BaconVideoWidget * bvw, gchar * filename)
bvw->priv->logo_pixbuf = gdk_pixbuf_new_from_file (filename, &error);
- if (error)
- {
- g_warning ("An error occurred trying to open logo %s: %s",
- filename, error->message);
- g_error_free (error);
- }
+ if (error) {
+ g_warning ("An error occurred trying to open logo %s: %s",
+ filename, error->message);
+ g_error_free (error);
+ }
}
/**
@@ -4070,30 +3662,25 @@ bacon_video_widget_set_logo_mode (BaconVideoWidget * bvw, gboolean logo_mode)
logo_mode = logo_mode != FALSE;
- if (priv->logo_mode != logo_mode)
- {
- priv->logo_mode = logo_mode;
-
- if (priv->video_window)
- {
- if (logo_mode)
- {
- gdk_window_hide (priv->video_window);
- GTK_WIDGET_SET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
- }
- else
- {
- gdk_window_show (priv->video_window);
- GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
- }
- }
-
- g_object_notify (G_OBJECT (bvw), "logo_mode");
- g_object_notify (G_OBJECT (bvw), "seekable");
+ if (priv->logo_mode != logo_mode) {
+ priv->logo_mode = logo_mode;
- /* Queue a redraw of the widget */
- gtk_widget_queue_draw (GTK_WIDGET (bvw));
+ if (priv->video_window) {
+ if (logo_mode) {
+ gdk_window_hide (priv->video_window);
+ GTK_WIDGET_SET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
+ } else {
+ gdk_window_show (priv->video_window);
+ GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (bvw), GTK_DOUBLE_BUFFERED);
+ }
}
+
+ g_object_notify (G_OBJECT (bvw), "logo_mode");
+ g_object_notify (G_OBJECT (bvw), "seekable");
+
+ /* Queue a redraw of the widget */
+ gtk_widget_queue_draw (GTK_WIDGET (bvw));
+ }
}
/**
@@ -4114,7 +3701,7 @@ bacon_video_widget_get_logo_mode (BaconVideoWidget * bvw)
void
bacon_video_widget_set_drawing_pixbuf (BaconVideoWidget * bvw,
- GdkPixbuf * drawing)
+ GdkPixbuf * drawing)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4129,7 +3716,7 @@ bacon_video_widget_set_drawing_pixbuf (BaconVideoWidget * bvw,
void
bacon_video_widget_set_drawing_mode (BaconVideoWidget * bvw,
- gboolean drawing_mode)
+ gboolean drawing_mode)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4153,12 +3740,11 @@ bacon_video_widget_pause (BaconVideoWidget * bvw)
g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
g_return_if_fail (bvw->priv->mrl != NULL);
- if (bvw->priv->is_live != FALSE)
- {
- GST_LOG ("Stopping because we have a live stream");
- bacon_video_widget_stop (bvw);
- return;
- }
+ if (bvw->priv->is_live != FALSE) {
+ GST_LOG ("Stopping because we have a live stream");
+ bacon_video_widget_stop (bvw);
+ return;
+ }
GST_LOG ("Pausing");
gst_element_set_state (GST_ELEMENT (bvw->priv->play), GST_STATE_PAUSED);
@@ -4177,7 +3763,7 @@ bacon_video_widget_pause (BaconVideoWidget * bvw)
**/
void
bacon_video_widget_set_subtitle_font (BaconVideoWidget * bvw,
- const gchar * font)
+ const gchar * font)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4199,7 +3785,7 @@ bacon_video_widget_set_subtitle_font (BaconVideoWidget * bvw,
**/
void
bacon_video_widget_set_subtitle_encoding (BaconVideoWidget * bvw,
- const char *encoding)
+ const char *encoding)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4250,12 +3836,11 @@ bacon_video_widget_set_volume (BaconVideoWidget * bvw, double volume)
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
- if (bacon_video_widget_can_set_volume (bvw) != FALSE)
- {
- volume = CLAMP (volume, 0.0, 1.0);
- g_object_set (bvw->priv->play, "volume", (gdouble) volume, NULL);
- g_object_notify (G_OBJECT (bvw), "volume");
- }
+ if (bacon_video_widget_can_set_volume (bvw) != FALSE) {
+ volume = CLAMP (volume, 0.0, 1.0);
+ g_object_set (bvw->priv->play, "volume", (gdouble) volume, NULL);
+ g_object_notify (G_OBJECT (bvw), "volume");
+ }
}
/**
@@ -4289,8 +3874,7 @@ bacon_video_widget_get_volume (BaconVideoWidget * bvw)
* Fullscreen rendering is done only when possible, as xvidmode is required.
**/
void
-bacon_video_widget_set_fullscreen (BaconVideoWidget * bvw,
- gboolean fullscreen)
+bacon_video_widget_set_fullscreen (BaconVideoWidget * bvw, gboolean fullscreen)
{
gboolean have_xvidmode;
@@ -4298,22 +3882,19 @@ bacon_video_widget_set_fullscreen (BaconVideoWidget * bvw,
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
g_object_get (G_OBJECT (bvw->priv->bacon_resize),
- "have-xvidmode", &have_xvidmode, NULL);
+ "have-xvidmode", &have_xvidmode, NULL);
if (have_xvidmode == FALSE)
return;
bvw->priv->fullscreen_mode = fullscreen;
- if (fullscreen == FALSE)
- {
- bacon_resize_restore (bvw->priv->bacon_resize);
- /* Turn fullscreen on when we have xvidmode */
- }
- else if (have_xvidmode != FALSE)
- {
- bacon_resize_resize (bvw->priv->bacon_resize);
- }
+ if (fullscreen == FALSE) {
+ bacon_resize_restore (bvw->priv->bacon_resize);
+ /* Turn fullscreen on when we have xvidmode */
+ } else if (have_xvidmode != FALSE) {
+ bacon_resize_resize (bvw->priv->bacon_resize);
+ }
}
@@ -4328,7 +3909,7 @@ bacon_video_widget_set_fullscreen (BaconVideoWidget * bvw,
**/
void
bacon_video_widget_set_show_cursor (BaconVideoWidget * bvw,
- gboolean show_cursor)
+ gboolean show_cursor)
{
GdkWindow *window;
@@ -4338,19 +3919,15 @@ bacon_video_widget_set_show_cursor (BaconVideoWidget * bvw,
bvw->priv->cursor_shown = show_cursor;
window = gtk_widget_get_window (GTK_WIDGET (bvw));
- if (!window)
- {
- return;
- }
+ if (!window) {
+ return;
+ }
- if (show_cursor == FALSE)
- {
- totem_gdk_window_set_invisible_cursor (window);
- }
- else
- {
- gdk_window_set_cursor (window, bvw->priv->cursor);
- }
+ if (show_cursor == FALSE) {
+ totem_gdk_window_set_invisible_cursor (window);
+ } else {
+ gdk_window_set_cursor (window, bvw->priv->cursor);
+ }
}
/**
@@ -4398,7 +3975,7 @@ bacon_video_widget_get_auto_resize (BaconVideoWidget * bvw)
**/
void
bacon_video_widget_set_auto_resize (BaconVideoWidget * bvw,
- gboolean auto_resize)
+ gboolean auto_resize)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4419,7 +3996,7 @@ bacon_video_widget_set_auto_resize (BaconVideoWidget * bvw,
**/
void
bacon_video_widget_set_aspect_ratio (BaconVideoWidget * bvw,
- BvwAspectRatio ratio)
+ BvwAspectRatio ratio)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4472,26 +4049,21 @@ bacon_video_widget_set_scale_ratio (BaconVideoWidget * bvw, gfloat ratio)
get_media_size (bvw, &w, &h);
- if (ratio == 0.0)
- {
- if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 2.0))
- ratio = 2.0;
- else if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 1.0))
- ratio = 1.0;
- else if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 0.5))
- ratio = 0.5;
- else
- return;
- }
- else
- {
- if (!totem_ratio_fits_screen (bvw->priv->video_window, w, h, ratio))
- {
- GST_DEBUG ("movie doesn't fit on screen @ %.1fx (%dx%d)", w, h,
- ratio);
- return;
- }
+ if (ratio == 0.0) {
+ if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 2.0))
+ ratio = 2.0;
+ else if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 1.0))
+ ratio = 1.0;
+ else if (totem_ratio_fits_screen (bvw->priv->video_window, w, h, 0.5))
+ ratio = 0.5;
+ else
+ return;
+ } else {
+ if (!totem_ratio_fits_screen (bvw->priv->video_window, w, h, ratio)) {
+ GST_DEBUG ("movie doesn't fit on screen @ %.1fx (%dx%d)", w, h, ratio);
+ return;
}
+ }
w = (gfloat) w *ratio;
h = (gfloat) h *ratio;
@@ -4544,26 +4116,24 @@ bacon_video_widget_get_zoom (BaconVideoWidget * bvw)
/* Search for the color balance channel corresponding to type and return it. */
static GstColorBalanceChannel *
bvw_get_color_balance_channel (GstColorBalance * color_balance,
- BvwVideoProperty type)
+ BvwVideoProperty type)
{
const GList *channels;
channels = gst_color_balance_list_channels (color_balance);
- for (; channels != NULL; channels = channels->next)
- {
- GstColorBalanceChannel *c = channels->data;
-
- if (type == BVW_VIDEO_BRIGHTNESS && g_strrstr (c->label, "BRIGHTNESS"))
- return g_object_ref (c);
- else if (type == BVW_VIDEO_CONTRAST && g_strrstr (c->label, "CONTRAST"))
- return g_object_ref (c);
- else if (type == BVW_VIDEO_SATURATION
- && g_strrstr (c->label, "SATURATION"))
- return g_object_ref (c);
- else if (type == BVW_VIDEO_HUE && g_strrstr (c->label, "HUE"))
- return g_object_ref (c);
- }
+ for (; channels != NULL; channels = channels->next) {
+ GstColorBalanceChannel *c = channels->data;
+
+ if (type == BVW_VIDEO_BRIGHTNESS && g_strrstr (c->label, "BRIGHTNESS"))
+ return g_object_ref (c);
+ else if (type == BVW_VIDEO_CONTRAST && g_strrstr (c->label, "CONTRAST"))
+ return g_object_ref (c);
+ else if (type == BVW_VIDEO_SATURATION && g_strrstr (c->label, "SATURATION"))
+ return g_object_ref (c);
+ else if (type == BVW_VIDEO_HUE && g_strrstr (c->label, "HUE"))
+ return g_object_ref (c);
+ }
return NULL;
}
@@ -4582,7 +4152,7 @@ bvw_get_color_balance_channel (GstColorBalance * color_balance,
**/
int
bacon_video_widget_get_video_property (BaconVideoWidget * bvw,
- BvwVideoProperty type)
+ BvwVideoProperty type)
{
int ret;
@@ -4593,39 +4163,31 @@ bacon_video_widget_get_video_property (BaconVideoWidget * bvw,
ret = 0;
- if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance))
- {
- GstColorBalanceChannel *found_channel = NULL;
+ if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance)) {
+ GstColorBalanceChannel *found_channel = NULL;
- found_channel =
- bvw_get_color_balance_channel (bvw->priv->balance, type);
+ found_channel = bvw_get_color_balance_channel (bvw->priv->balance, type);
- if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel))
- {
- gint cur;
+ if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel)) {
+ gint cur;
- cur = gst_color_balance_get_value (bvw->priv->balance,
- found_channel);
+ cur = gst_color_balance_get_value (bvw->priv->balance, found_channel);
- GST_DEBUG ("channel %s: cur=%d, min=%d, max=%d",
- found_channel->label, cur, found_channel->min_value,
- found_channel->max_value);
+ GST_DEBUG ("channel %s: cur=%d, min=%d, max=%d",
+ found_channel->label, cur, found_channel->min_value,
+ found_channel->max_value);
- ret = floor (0.5 +
- ((double) cur - found_channel->min_value) * 65535 /
- ((double) found_channel->max_value -
- found_channel->min_value));
+ ret = floor (0.5 +
+ ((double) cur - found_channel->min_value) * 65535 /
+ ((double) found_channel->max_value - found_channel->min_value));
- GST_DEBUG ("channel %s: returning value %d", found_channel->label,
- ret);
- g_object_unref (found_channel);
- goto done;
- }
- else
- {
- ret = -1;
- }
+ GST_DEBUG ("channel %s: returning value %d", found_channel->label, ret);
+ g_object_unref (found_channel);
+ goto done;
+ } else {
+ ret = -1;
}
+ }
done:
@@ -4646,7 +4208,7 @@ done:
**/
void
bacon_video_widget_set_video_property (BaconVideoWidget * bvw,
- BvwVideoProperty type, int value)
+ BvwVideoProperty type, int value)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
@@ -4656,34 +4218,28 @@ bacon_video_widget_set_video_property (BaconVideoWidget * bvw,
if (!(value <= 65535 && value >= 0))
return;
- if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance))
- {
- GstColorBalanceChannel *found_channel = NULL;
+ if (bvw->priv->balance && GST_IS_COLOR_BALANCE (bvw->priv->balance)) {
+ GstColorBalanceChannel *found_channel = NULL;
- found_channel =
- bvw_get_color_balance_channel (bvw->priv->balance, type);
+ found_channel = bvw_get_color_balance_channel (bvw->priv->balance, type);
- if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel))
- {
- int i_value;
+ if (found_channel && GST_IS_COLOR_BALANCE_CHANNEL (found_channel)) {
+ int i_value;
- i_value = floor (0.5 + value * ((double) found_channel->max_value -
- found_channel->min_value) / 65535 +
- found_channel->min_value);
+ i_value = floor (0.5 + value * ((double) found_channel->max_value -
+ found_channel->min_value) / 65535 + found_channel->min_value);
- GST_DEBUG ("channel %s: set to %d/65535", found_channel->label,
- value);
+ GST_DEBUG ("channel %s: set to %d/65535", found_channel->label, value);
- gst_color_balance_set_value (bvw->priv->balance, found_channel,
- i_value);
+ gst_color_balance_set_value (bvw->priv->balance, found_channel, i_value);
- GST_DEBUG ("channel %s: val=%d, min=%d, max=%d",
- found_channel->label, i_value, found_channel->min_value,
- found_channel->max_value);
+ GST_DEBUG ("channel %s: val=%d, min=%d, max=%d",
+ found_channel->label, i_value, found_channel->min_value,
+ found_channel->max_value);
- g_object_unref (found_channel);
- }
+ g_object_unref (found_channel);
}
+ }
}
/**
@@ -4763,17 +4319,15 @@ bacon_video_widget_get_stream_length (BaconVideoWidget * bvw)
g_return_val_if_fail (bvw != NULL, -1);
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), -1);
- if (bvw->priv->stream_length == 0 && bvw->priv->play != NULL)
- {
- GstFormat fmt = GST_FORMAT_TIME;
- gint64 len = -1;
-
- if (gst_element_query_duration (bvw->priv->play, &fmt, &len)
- && len != -1)
- {
- bvw->priv->stream_length = len / GST_MSECOND;
- }
+ if (bvw->priv->stream_length == 0 && bvw->priv->play != NULL) {
+ GstFormat fmt = GST_FORMAT_TIME;
+ gint64 len = -1;
+
+ if (gst_element_query_duration (bvw->priv->play, &fmt, &len)
+ && len != -1) {
+ bvw->priv->stream_length = len / GST_MSECOND;
}
+ }
return bvw->priv->stream_length;
}
@@ -4826,38 +4380,30 @@ bacon_video_widget_is_seekable (BaconVideoWidget * bvw)
old_seekable = bvw->priv->seekable;
- if (bvw->priv->seekable == -1)
- {
- GstQuery *query;
-
- query = gst_query_new_seeking (GST_FORMAT_TIME);
- if (gst_element_query (bvw->priv->play, query))
- {
- gst_query_parse_seeking (query, NULL, &res, NULL, NULL);
- bvw->priv->seekable = (res) ? 1 : 0;
- }
- else
- {
- GST_DEBUG ("seeking query failed");
- }
- gst_query_unref (query);
- }
+ if (bvw->priv->seekable == -1) {
+ GstQuery *query;
- if (bvw->priv->seekable != -1)
- {
- res = (bvw->priv->seekable != 0);
- goto done;
+ query = gst_query_new_seeking (GST_FORMAT_TIME);
+ if (gst_element_query (bvw->priv->play, query)) {
+ gst_query_parse_seeking (query, NULL, &res, NULL, NULL);
+ bvw->priv->seekable = (res) ? 1 : 0;
+ } else {
+ GST_DEBUG ("seeking query failed");
}
+ gst_query_unref (query);
+ }
+
+ if (bvw->priv->seekable != -1) {
+ res = (bvw->priv->seekable != 0);
+ goto done;
+ }
/* try to guess from duration (this is very unreliable though) */
- if (bvw->priv->stream_length == 0)
- {
- res = (bacon_video_widget_get_stream_length (bvw) > 0);
- }
- else
- {
- res = (bvw->priv->stream_length > 0);
- }
+ if (bvw->priv->stream_length == 0) {
+ res = (bacon_video_widget_get_stream_length (bvw) > 0);
+ } else {
+ res = (bvw->priv->stream_length > 0);
+ }
done:
@@ -4873,43 +4419,25 @@ static struct _metadata_map_info
{
BvwMetadataType type;
const gchar *str;
-} metadata_str_map[] =
-{
- {
- BVW_INFO_TITLE, "title"},
- {
- BVW_INFO_ARTIST, "artist"},
- {
- BVW_INFO_YEAR, "year"},
- {
- BVW_INFO_COMMENT, "comment"},
- {
- BVW_INFO_ALBUM, "album"},
- {
- BVW_INFO_DURATION, "duration"},
- {
- BVW_INFO_TRACK_NUMBER, "track-number"},
- {
- BVW_INFO_HAS_VIDEO, "has-video"},
- {
- BVW_INFO_DIMENSION_X, "dimension-x"},
- {
- BVW_INFO_DIMENSION_Y, "dimension-y"},
- {
- BVW_INFO_VIDEO_BITRATE, "video-bitrate"},
- {
- BVW_INFO_VIDEO_CODEC, "video-codec"},
- {
- BVW_INFO_FPS, "fps"},
- {
- BVW_INFO_HAS_AUDIO, "has-audio"},
- {
- BVW_INFO_AUDIO_BITRATE, "audio-bitrate"},
- {
- BVW_INFO_AUDIO_CODEC, "audio-codec"},
- {
- BVW_INFO_AUDIO_SAMPLE_RATE, "samplerate"},
+} metadata_str_map[] = {
{
+ BVW_INFO_TITLE, "title"}, {
+ BVW_INFO_ARTIST, "artist"}, {
+ BVW_INFO_YEAR, "year"}, {
+ BVW_INFO_COMMENT, "comment"}, {
+ BVW_INFO_ALBUM, "album"}, {
+ BVW_INFO_DURATION, "duration"}, {
+ BVW_INFO_TRACK_NUMBER, "track-number"}, {
+ BVW_INFO_HAS_VIDEO, "has-video"}, {
+ BVW_INFO_DIMENSION_X, "dimension-x"}, {
+ BVW_INFO_DIMENSION_Y, "dimension-y"}, {
+ BVW_INFO_VIDEO_BITRATE, "video-bitrate"}, {
+ BVW_INFO_VIDEO_CODEC, "video-codec"}, {
+ BVW_INFO_FPS, "fps"}, {
+ BVW_INFO_HAS_AUDIO, "has-audio"}, {
+ BVW_INFO_AUDIO_BITRATE, "audio-bitrate"}, {
+ BVW_INFO_AUDIO_CODEC, "audio-codec"}, {
+ BVW_INFO_AUDIO_SAMPLE_RATE, "samplerate"}, {
BVW_INFO_AUDIO_CHANNELS, "channels"}
};
@@ -4917,11 +4445,10 @@ static const gchar *
get_metadata_type_name (BvwMetadataType type)
{
guint i;
- for (i = 0; i < G_N_ELEMENTS (metadata_str_map); ++i)
- {
- if (metadata_str_map[i].type == type)
- return metadata_str_map[i].str;
- }
+ for (i = 0; i < G_N_ELEMENTS (metadata_str_map); ++i) {
+ if (metadata_str_map[i].type == type)
+ return metadata_str_map[i].str;
+ }
return "unknown";
}
@@ -4946,7 +4473,7 @@ bvw_get_current_stream_num (BaconVideoWidget * bvw, const gchar * stream_type)
static GstTagList *
bvw_get_tags_of_current_stream (BaconVideoWidget * bvw,
- const gchar * stream_type)
+ const gchar * stream_type)
{
GstTagList *tags = NULL;
gint stream_num = -1;
@@ -4968,7 +4495,7 @@ bvw_get_tags_of_current_stream (BaconVideoWidget * bvw,
static GstCaps *
bvw_get_caps_of_current_stream (BaconVideoWidget * bvw,
- const gchar * stream_type)
+ const gchar * stream_type)
{
GstCaps *caps = NULL;
gint stream_num = -1;
@@ -4985,11 +4512,10 @@ bvw_get_caps_of_current_stream (BaconVideoWidget * bvw,
g_free (cur_sig_str);
g_free (lower);
- if (current != NULL)
- {
- caps = gst_pad_get_negotiated_caps (current);
- gst_object_unref (current);
- }
+ if (current != NULL) {
+ caps = gst_pad_get_negotiated_caps (current);
+ gst_object_unref (current);
+ }
GST_LOG ("current %s stream caps: %" GST_PTR_FORMAT, stream_type, caps);
return caps;
}
@@ -5001,23 +4527,20 @@ audio_caps_have_LFE (GstStructure * s)
gint i, channels;
if (!gst_structure_get_value (s, "channel-positions") ||
- !gst_structure_get_int (s, "channels", &channels))
- {
- return FALSE;
- }
+ !gst_structure_get_int (s, "channels", &channels)) {
+ return FALSE;
+ }
positions = gst_audio_get_channel_positions (s);
if (positions == NULL)
return FALSE;
- for (i = 0; i < channels; ++i)
- {
- if (positions[i] == GST_AUDIO_CHANNEL_POSITION_LFE)
- {
- g_free (positions);
- return TRUE;
- }
+ for (i = 0; i < channels; ++i) {
+ if (positions[i] == GST_AUDIO_CHANNEL_POSITION_LFE) {
+ g_free (positions);
+ return TRUE;
}
+ }
g_free (positions);
return FALSE;
@@ -5025,184 +4548,156 @@ audio_caps_have_LFE (GstStructure * s)
static void
bacon_video_widget_get_metadata_string (BaconVideoWidget * bvw,
- BvwMetadataType type, GValue * value)
+ BvwMetadataType type, GValue * value)
{
char *string = NULL;
gboolean res = FALSE;
g_value_init (value, G_TYPE_STRING);
- if (bvw->priv->play == NULL)
- {
- g_value_set_string (value, NULL);
- return;
- }
+ if (bvw->priv->play == NULL) {
+ g_value_set_string (value, NULL);
+ return;
+ }
- switch (type)
- {
+ switch (type) {
case BVW_INFO_TITLE:
- if (bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string_index (bvw->priv->tagcache,
- GST_TAG_TITLE, 0, &string);
- }
+ if (bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string_index (bvw->priv->tagcache,
+ GST_TAG_TITLE, 0, &string);
+ }
break;
case BVW_INFO_ARTIST:
- if (bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string_index (bvw->priv->tagcache,
- GST_TAG_ARTIST, 0, &string);
- }
+ if (bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string_index (bvw->priv->tagcache,
+ GST_TAG_ARTIST, 0, &string);
+ }
break;
case BVW_INFO_YEAR:
- if (bvw->priv->tagcache != NULL)
- {
- GDate *date;
-
- if ((res = gst_tag_list_get_date (bvw->priv->tagcache,
- GST_TAG_DATE, &date)))
- {
- string = g_strdup_printf ("%d", g_date_get_year (date));
- g_date_free (date);
- }
- }
+ if (bvw->priv->tagcache != NULL) {
+ GDate *date;
+
+ if ((res = gst_tag_list_get_date (bvw->priv->tagcache,
+ GST_TAG_DATE, &date))) {
+ string = g_strdup_printf ("%d", g_date_get_year (date));
+ g_date_free (date);
+ }
+ }
break;
case BVW_INFO_COMMENT:
- if (bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string_index (bvw->priv->tagcache,
- GST_TAG_COMMENT, 0, &string);
- }
+ if (bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string_index (bvw->priv->tagcache,
+ GST_TAG_COMMENT, 0, &string);
+ }
break;
case BVW_INFO_ALBUM:
- if (bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string_index (bvw->priv->tagcache,
- GST_TAG_ALBUM, 0, &string);
- }
+ if (bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string_index (bvw->priv->tagcache,
+ GST_TAG_ALBUM, 0, &string);
+ }
break;
case BVW_INFO_VIDEO_CODEC:
- {
- GstTagList *tags;
-
- /* try to get this from the stream info first */
- if ((tags = bvw_get_tags_of_current_stream (bvw, "video")))
- {
- res = gst_tag_list_get_string (tags, GST_TAG_CODEC, &string);
- gst_tag_list_free (tags);
- }
-
- /* if that didn't work, try the aggregated tags */
- if (!res && bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string (bvw->priv->tagcache,
- GST_TAG_VIDEO_CODEC, &string);
- }
- break;
+ {
+ GstTagList *tags;
+
+ /* try to get this from the stream info first */
+ if ((tags = bvw_get_tags_of_current_stream (bvw, "video"))) {
+ res = gst_tag_list_get_string (tags, GST_TAG_CODEC, &string);
+ gst_tag_list_free (tags);
}
+
+ /* if that didn't work, try the aggregated tags */
+ if (!res && bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string (bvw->priv->tagcache,
+ GST_TAG_VIDEO_CODEC, &string);
+ }
+ break;
+ }
case BVW_INFO_AUDIO_CODEC:
- {
- GstTagList *tags;
-
- /* try to get this from the stream info first */
- if ((tags = bvw_get_tags_of_current_stream (bvw, "audio")))
- {
- res = gst_tag_list_get_string (tags, GST_TAG_CODEC, &string);
- gst_tag_list_free (tags);
- }
-
- /* if that didn't work, try the aggregated tags */
- if (!res && bvw->priv->tagcache != NULL)
- {
- res = gst_tag_list_get_string (bvw->priv->tagcache,
- GST_TAG_AUDIO_CODEC, &string);
- }
- break;
+ {
+ GstTagList *tags;
+
+ /* try to get this from the stream info first */
+ if ((tags = bvw_get_tags_of_current_stream (bvw, "audio"))) {
+ res = gst_tag_list_get_string (tags, GST_TAG_CODEC, &string);
+ gst_tag_list_free (tags);
}
+
+ /* if that didn't work, try the aggregated tags */
+ if (!res && bvw->priv->tagcache != NULL) {
+ res = gst_tag_list_get_string (bvw->priv->tagcache,
+ GST_TAG_AUDIO_CODEC, &string);
+ }
+ break;
+ }
case BVW_INFO_AUDIO_CHANNELS:
- {
- GstStructure *s;
- GstCaps *caps;
-
- caps = bvw_get_caps_of_current_stream (bvw, "audio");
- if (caps)
- {
- gint channels = 0;
-
- s = gst_caps_get_structure (caps, 0);
- if ((res = gst_structure_get_int (s, "channels", &channels)))
- {
- /* FIXME: do something more sophisticated - but what? */
- if (channels > 2 && audio_caps_have_LFE (s))
- {
- string =
- g_strdup_printf ("%s %d.1", _("Surround"),
- channels - 1);
- }
- else if (channels == 1)
- {
- string = g_strdup (_("Mono"));
- }
- else if (channels == 2)
- {
- string = g_strdup (_("Stereo"));
- }
- else
- {
- string = g_strdup_printf ("%d", channels);
- }
- }
- gst_caps_unref (caps);
- }
- break;
+ {
+ GstStructure *s;
+ GstCaps *caps;
+
+ caps = bvw_get_caps_of_current_stream (bvw, "audio");
+ if (caps) {
+ gint channels = 0;
+
+ s = gst_caps_get_structure (caps, 0);
+ if ((res = gst_structure_get_int (s, "channels", &channels))) {
+ /* FIXME: do something more sophisticated - but what? */
+ if (channels > 2 && audio_caps_have_LFE (s)) {
+ string = g_strdup_printf ("%s %d.1", _("Surround"), channels - 1);
+ } else if (channels == 1) {
+ string = g_strdup (_("Mono"));
+ } else if (channels == 2) {
+ string = g_strdup (_("Stereo"));
+ } else {
+ string = g_strdup_printf ("%d", channels);
+ }
+ }
+ gst_caps_unref (caps);
}
+ break;
+ }
default:
g_assert_not_reached ();
- }
+ }
/* Remove line feeds */
if (string && strstr (string, "\n") != NULL)
g_strdelimit (string, "\n", ' ');
- if (res && string && g_utf8_validate (string, -1, NULL))
- {
- g_value_take_string (value, string);
- GST_DEBUG ("%s = '%s'", get_metadata_type_name (type), string);
- }
- else
- {
- g_value_set_string (value, NULL);
- g_free (string);
- }
+ if (res && string && g_utf8_validate (string, -1, NULL)) {
+ g_value_take_string (value, string);
+ GST_DEBUG ("%s = '%s'", get_metadata_type_name (type), string);
+ } else {
+ g_value_set_string (value, NULL);
+ g_free (string);
+ }
return;
}
static void
bacon_video_widget_get_metadata_int (BaconVideoWidget * bvw,
- BvwMetadataType type, GValue * value)
+ BvwMetadataType type, GValue * value)
{
int integer = 0;
g_value_init (value, G_TYPE_INT);
- if (bvw->priv->play == NULL)
- {
- g_value_set_int (value, 0);
- return;
- }
+ if (bvw->priv->play == NULL) {
+ g_value_set_int (value, 0);
+ return;
+ }
- switch (type)
- {
+ switch (type) {
case BVW_INFO_DURATION:
integer = bacon_video_widget_get_stream_length (bvw) / 1000;
break;
case BVW_INFO_TRACK_NUMBER:
if (bvw->priv->tagcache == NULL)
- break;
+ break;
if (!gst_tag_list_get_uint (bvw->priv->tagcache,
- GST_TAG_TRACK_NUMBER, (guint *) & integer))
- integer = 0;
+ GST_TAG_TRACK_NUMBER, (guint *) & integer))
+ integer = 0;
break;
case BVW_INFO_DIMENSION_X:
integer = bvw->priv->video_width;
@@ -5211,56 +4706,49 @@ bacon_video_widget_get_metadata_int (BaconVideoWidget * bvw,
integer = bvw->priv->video_height;
break;
case BVW_INFO_FPS:
- if (bvw->priv->video_fps_d > 0)
- {
- /* Round up/down to the nearest integer framerate */
- integer = (bvw->priv->video_fps_n + bvw->priv->video_fps_d / 2) /
- bvw->priv->video_fps_d;
- }
- else
- integer = 0;
+ if (bvw->priv->video_fps_d > 0) {
+ /* Round up/down to the nearest integer framerate */
+ integer = (bvw->priv->video_fps_n + bvw->priv->video_fps_d / 2) /
+ bvw->priv->video_fps_d;
+ } else
+ integer = 0;
break;
case BVW_INFO_AUDIO_BITRATE:
if (bvw->priv->audiotags == NULL)
- break;
+ break;
if (gst_tag_list_get_uint (bvw->priv->audiotags, GST_TAG_BITRATE,
- (guint *) & integer) ||
- gst_tag_list_get_uint (bvw->priv->audiotags,
- GST_TAG_NOMINAL_BITRATE,
- (guint *) & integer))
- {
- integer /= 1000;
- }
+ (guint *) & integer) ||
+ gst_tag_list_get_uint (bvw->priv->audiotags,
+ GST_TAG_NOMINAL_BITRATE, (guint *) & integer)) {
+ integer /= 1000;
+ }
break;
case BVW_INFO_VIDEO_BITRATE:
if (bvw->priv->videotags == NULL)
- break;
+ break;
if (gst_tag_list_get_uint (bvw->priv->videotags, GST_TAG_BITRATE,
- (guint *) & integer) ||
- gst_tag_list_get_uint (bvw->priv->videotags,
- GST_TAG_NOMINAL_BITRATE,
- (guint *) & integer))
- {
- integer /= 1000;
- }
+ (guint *) & integer) ||
+ gst_tag_list_get_uint (bvw->priv->videotags,
+ GST_TAG_NOMINAL_BITRATE, (guint *) & integer)) {
+ integer /= 1000;
+ }
break;
case BVW_INFO_AUDIO_SAMPLE_RATE:
- {
- GstStructure *s;
- GstCaps *caps;
-
- caps = bvw_get_caps_of_current_stream (bvw, "audio");
- if (caps)
- {
- s = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (s, "rate", &integer);
- gst_caps_unref (caps);
- }
- break;
+ {
+ GstStructure *s;
+ GstCaps *caps;
+
+ caps = bvw_get_caps_of_current_stream (bvw, "audio");
+ if (caps) {
+ s = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (s, "rate", &integer);
+ gst_caps_unref (caps);
}
+ break;
+ }
default:
g_assert_not_reached ();
- }
+ }
g_value_set_int (value, integer);
GST_DEBUG ("%s = %d", get_metadata_type_name (type), integer);
@@ -5270,55 +4758,51 @@ bacon_video_widget_get_metadata_int (BaconVideoWidget * bvw,
static void
bacon_video_widget_get_metadata_bool (BaconVideoWidget * bvw,
- BvwMetadataType type, GValue * value)
+ BvwMetadataType type, GValue * value)
{
gboolean boolean = FALSE;
g_value_init (value, G_TYPE_BOOLEAN);
- if (bvw->priv->play == NULL)
- {
- g_value_set_boolean (value, FALSE);
- return;
- }
+ if (bvw->priv->play == NULL) {
+ g_value_set_boolean (value, FALSE);
+ return;
+ }
GST_DEBUG ("tagcache = %" GST_PTR_FORMAT, bvw->priv->tagcache);
GST_DEBUG ("videotags = %" GST_PTR_FORMAT, bvw->priv->videotags);
GST_DEBUG ("audiotags = %" GST_PTR_FORMAT, bvw->priv->audiotags);
- switch (type)
- {
+ switch (type) {
case BVW_INFO_HAS_VIDEO:
boolean = bvw->priv->media_has_video;
/* if properties dialog, show the metadata we
* have even if we cannot decode the stream */
if (!boolean && bvw->priv->use_type == BVW_USE_TYPE_METADATA &&
- bvw->priv->tagcache != NULL &&
- gst_structure_has_field ((GstStructure *) bvw->priv->tagcache,
- GST_TAG_VIDEO_CODEC))
- {
- boolean = TRUE;
- }
+ bvw->priv->tagcache != NULL &&
+ gst_structure_has_field ((GstStructure *) bvw->priv->tagcache,
+ GST_TAG_VIDEO_CODEC)) {
+ boolean = TRUE;
+ }
break;
case BVW_INFO_HAS_AUDIO:
boolean = bvw->priv->media_has_audio;
/* if properties dialog, show the metadata we
* have even if we cannot decode the stream */
if (!boolean && bvw->priv->use_type == BVW_USE_TYPE_METADATA &&
- bvw->priv->tagcache != NULL &&
- gst_structure_has_field ((GstStructure *) bvw->priv->tagcache,
- GST_TAG_AUDIO_CODEC))
- {
- boolean = TRUE;
- }
+ bvw->priv->tagcache != NULL &&
+ gst_structure_has_field ((GstStructure *) bvw->priv->tagcache,
+ GST_TAG_AUDIO_CODEC)) {
+ boolean = TRUE;
+ }
break;
default:
g_assert_not_reached ();
- }
+ }
g_value_set_boolean (value, boolean);
GST_DEBUG ("%s = %s", get_metadata_type_name (type),
- (boolean) ? "yes" : "no");
+ (boolean) ? "yes" : "no");
return;
}
@@ -5336,31 +4820,28 @@ bvw_process_pending_tag_messages (BaconVideoWidget * bvw)
/* application message is for stream-info */
events = GST_MESSAGE_TAG | GST_MESSAGE_DURATION | GST_MESSAGE_APPLICATION;
bus = gst_element_get_bus (bvw->priv->play);
- while ((msg = gst_bus_poll (bus, events, 0)))
- {
- gst_bus_async_signal_func (bus, msg, NULL);
- }
+ while ((msg = gst_bus_poll (bus, events, 0))) {
+ gst_bus_async_signal_func (bus, msg, NULL);
+ }
gst_object_unref (bus);
}
static GdkPixbuf *
bacon_video_widget_get_metadata_pixbuf (BaconVideoWidget * bvw,
- GstBuffer * buffer)
+ GstBuffer * buffer)
{
GdkPixbufLoader *loader;
GdkPixbuf *pixbuf;
loader = gdk_pixbuf_loader_new ();
- if (!gdk_pixbuf_loader_write (loader, buffer->data, buffer->size, NULL))
- {
- g_object_unref (loader);
- return NULL;
- }
- if (!gdk_pixbuf_loader_close (loader, NULL))
- {
- g_object_unref (loader);
- return NULL;
- }
+ if (!gdk_pixbuf_loader_write (loader, buffer->data, buffer->size, NULL)) {
+ g_object_unref (loader);
+ return NULL;
+ }
+ if (!gdk_pixbuf_loader_close (loader, NULL)) {
+ g_object_unref (loader);
+ return NULL;
+ }
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
if (pixbuf)
@@ -5375,34 +4856,30 @@ bacon_video_widget_get_best_image (BaconVideoWidget * bvw)
const GValue *cover_value = NULL;
guint i;
- for (i = 0;; i++)
- {
- const GValue *value;
- GstBuffer *buffer;
- GstStructure *caps_struct;
- int type;
-
- value = gst_tag_list_get_value_index (bvw->priv->tagcache,
- GST_TAG_IMAGE, i);
- if (value == NULL)
- break;
-
- buffer = gst_value_get_buffer (value);
-
- caps_struct = gst_caps_get_structure (buffer->caps, 0);
- gst_structure_get_enum (caps_struct,
- "image-type", GST_TYPE_TAG_IMAGE_TYPE, &type);
- if (type == GST_TAG_IMAGE_TYPE_UNDEFINED)
- {
- if (cover_value == NULL)
- cover_value = value;
- }
- else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER)
- {
- cover_value = value;
- break;
- }
+ for (i = 0;; i++) {
+ const GValue *value;
+ GstBuffer *buffer;
+ GstStructure *caps_struct;
+ int type;
+
+ value = gst_tag_list_get_value_index (bvw->priv->tagcache,
+ GST_TAG_IMAGE, i);
+ if (value == NULL)
+ break;
+
+ buffer = gst_value_get_buffer (value);
+
+ caps_struct = gst_caps_get_structure (buffer->caps, 0);
+ gst_structure_get_enum (caps_struct,
+ "image-type", GST_TYPE_TAG_IMAGE_TYPE, &type);
+ if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) {
+ if (cover_value == NULL)
+ cover_value = value;
+ } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) {
+ cover_value = value;
+ break;
}
+ }
return cover_value;
}
@@ -5419,14 +4896,13 @@ bacon_video_widget_get_best_image (BaconVideoWidget * bvw)
**/
void
bacon_video_widget_get_metadata (BaconVideoWidget * bvw,
- BvwMetadataType type, GValue * value)
+ BvwMetadataType type, GValue * value)
{
g_return_if_fail (bvw != NULL);
g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));
g_return_if_fail (GST_IS_ELEMENT (bvw->priv->play));
- switch (type)
- {
+ switch (type) {
case BVW_INFO_TITLE:
case BVW_INFO_ARTIST:
case BVW_INFO_YEAR:
@@ -5470,35 +4946,32 @@ bacon_video_widget_get_metadata (BaconVideoWidget * bvw,
bacon_video_widget_get_metadata_bool (bvw, type, value);
break;
case BVW_INFO_COVER:
- {
- const GValue *cover_value;
-
- g_value_init (value, G_TYPE_OBJECT);
-
- if (bvw->priv->tagcache == NULL)
- break;
- cover_value = bacon_video_widget_get_best_image (bvw);
- if (!cover_value)
- {
- cover_value = gst_tag_list_get_value_index (bvw->priv->tagcache,
- GST_TAG_PREVIEW_IMAGE,
- 0);
- }
- if (cover_value)
- {
- GstBuffer *buffer;
- GdkPixbuf *pixbuf;
-
- buffer = gst_value_get_buffer (cover_value);
- pixbuf = bacon_video_widget_get_metadata_pixbuf (bvw, buffer);
- if (pixbuf)
- g_value_take_object (value, pixbuf);
- }
+ {
+ const GValue *cover_value;
+
+ g_value_init (value, G_TYPE_OBJECT);
+
+ if (bvw->priv->tagcache == NULL)
+ break;
+ cover_value = bacon_video_widget_get_best_image (bvw);
+ if (!cover_value) {
+ cover_value = gst_tag_list_get_value_index (bvw->priv->tagcache,
+ GST_TAG_PREVIEW_IMAGE, 0);
+ }
+ if (cover_value) {
+ GstBuffer *buffer;
+ GdkPixbuf *pixbuf;
+
+ buffer = gst_value_get_buffer (cover_value);
+ pixbuf = bacon_video_widget_get_metadata_pixbuf (bvw, buffer);
+ if (pixbuf)
+ g_value_take_object (value, pixbuf);
}
+ }
break;
default:
g_return_if_reached ();
- }
+ }
return;
}
@@ -5527,20 +5000,18 @@ bacon_video_widget_can_get_frames (BaconVideoWidget * bvw, GError ** error)
/* check for version */
if (!g_object_class_find_property
- (G_OBJECT_GET_CLASS (bvw->priv->play), "frame"))
- {
- g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
- _("Too old version of GStreamer installed."));
- return FALSE;
- }
+ (G_OBJECT_GET_CLASS (bvw->priv->play), "frame")) {
+ g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
+ _("Too old version of GStreamer installed."));
+ return FALSE;
+ }
/* check for video */
- if (!bvw->priv->media_has_video)
- {
- g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
- _("Media contains no supported video streams."));
- return FALSE;
- }
+ if (!bvw->priv->media_has_video) {
+ g_set_error_literal (error, BVW_ERROR, GST_ERROR_GENERIC,
+ _("Media contains no supported video streams."));
+ return FALSE;
+ }
return TRUE;
}
@@ -5581,57 +5052,51 @@ bacon_video_widget_get_current_frame (BaconVideoWidget * bvw)
g_return_val_if_fail (BACON_IS_VIDEO_WIDGET (bvw), NULL);
g_return_val_if_fail (GST_IS_ELEMENT (bvw->priv->play), NULL);
- /*[> when used as thumbnailer, wait for pending seeks to complete <]*/
- /*if (bvw->priv->use_type == BVW_USE_TYPE_CAPTURE)*/
- /*{*/
- /*gst_element_get_state (bvw->priv->play, NULL, NULL, -1);*/
- /*}*/
+ /*[> when used as thumbnailer, wait for pending seeks to complete <] */
+ /*if (bvw->priv->use_type == BVW_USE_TYPE_CAPTURE) */
+ /*{ */
+ /*gst_element_get_state (bvw->priv->play, NULL, NULL, -1); */
+ /*} */
gst_element_get_state (bvw->priv->play, NULL, NULL, -1);
/* no video info */
- if (!bvw->priv->video_width || !bvw->priv->video_height)
- {
- GST_DEBUG ("Could not take screenshot: %s", "no video info");
- g_warning ("Could not take screenshot: %s", "no video info");
- return NULL;
- }
+ if (!bvw->priv->video_width || !bvw->priv->video_height) {
+ GST_DEBUG ("Could not take screenshot: %s", "no video info");
+ g_warning ("Could not take screenshot: %s", "no video info");
+ return NULL;
+ }
/* get frame */
g_object_get (bvw->priv->play, "frame", &buf, NULL);
- if (!buf)
- {
- GST_DEBUG ("Could not take screenshot: %s", "no last video frame");
- g_warning ("Could not take screenshot: %s", "no last video frame");
- return NULL;
- }
+ if (!buf) {
+ GST_DEBUG ("Could not take screenshot: %s", "no last video frame");
+ g_warning ("Could not take screenshot: %s", "no last video frame");
+ return NULL;
+ }
- if (GST_BUFFER_CAPS (buf) == NULL)
- {
- GST_DEBUG ("Could not take screenshot: %s", "no caps on buffer");
- g_warning ("Could not take screenshot: %s", "no caps on buffer");
- return NULL;
- }
+ if (GST_BUFFER_CAPS (buf) == NULL) {
+ GST_DEBUG ("Could not take screenshot: %s", "no caps on buffer");
+ g_warning ("Could not take screenshot: %s", "no caps on buffer");
+ return NULL;
+ }
/* convert to our desired format (RGB24) */
to_caps = gst_caps_new_simple ("video/x-raw-rgb",
- "bpp", G_TYPE_INT, 24,
- "depth", G_TYPE_INT, 24,
- /* Note: we don't ask for a specific width/height here, so that
- * videoscale can adjust dimensions from a non-1/1 pixel aspect
- * ratio to a 1/1 pixel-aspect-ratio */
- "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
- 1, "endianness", G_TYPE_INT, G_BIG_ENDIAN,
- "red_mask", G_TYPE_INT, 0xff0000,
- "green_mask", G_TYPE_INT, 0x00ff00,
- "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
-
- if (bvw->priv->video_fps_n > 0 && bvw->priv->video_fps_d > 0)
- {
- gst_caps_set_simple (to_caps, "framerate", GST_TYPE_FRACTION,
- bvw->priv->video_fps_n, bvw->priv->video_fps_d,
- NULL);
- }
+ "bpp", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24,
+ /* Note: we don't ask for a specific width/height here, so that
+ * videoscale can adjust dimensions from a non-1/1 pixel aspect
+ * ratio to a 1/1 pixel-aspect-ratio */
+ "pixel-aspect-ratio", GST_TYPE_FRACTION, 1,
+ 1, "endianness", G_TYPE_INT, G_BIG_ENDIAN,
+ "red_mask", G_TYPE_INT, 0xff0000,
+ "green_mask", G_TYPE_INT, 0x00ff00,
+ "blue_mask", G_TYPE_INT, 0x0000ff, NULL);
+
+ if (bvw->priv->video_fps_n > 0 && bvw->priv->video_fps_d > 0) {
+ gst_caps_set_simple (to_caps, "framerate", GST_TYPE_FRACTION,
+ bvw->priv->video_fps_n, bvw->priv->video_fps_d, NULL);
+ }
GST_DEBUG ("frame caps: %" GST_PTR_FORMAT, GST_BUFFER_CAPS (buf));
GST_DEBUG ("pixbuf caps: %" GST_PTR_FORMAT, to_caps);
@@ -5641,19 +5106,17 @@ bacon_video_widget_get_current_frame (BaconVideoWidget * bvw)
gst_caps_unref (to_caps);
- if (!buf)
- {
- GST_DEBUG ("Could not take screenshot: %s", "conversion failed");
- g_warning ("Could not take screenshot: %s", "conversion failed");
- return NULL;
- }
+ if (!buf) {
+ GST_DEBUG ("Could not take screenshot: %s", "conversion failed");
+ g_warning ("Could not take screenshot: %s", "conversion failed");
+ return NULL;
+ }
- if (!GST_BUFFER_CAPS (buf))
- {
- GST_DEBUG ("Could not take screenshot: %s", "no caps on output buffer");
- g_warning ("Could not take screenshot: %s", "no caps on output buffer");
- return NULL;
- }
+ if (!GST_BUFFER_CAPS (buf)) {
+ GST_DEBUG ("Could not take screenshot: %s", "no caps on output buffer");
+ g_warning ("Could not take screenshot: %s", "no caps on output buffer");
+ return NULL;
+ }
s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
gst_structure_get_int (s, "width", &outwidth);
@@ -5662,16 +5125,14 @@ bacon_video_widget_get_current_frame (BaconVideoWidget * bvw)
/* create pixbuf from that - use our own destroy function */
pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buf),
- GDK_COLORSPACE_RGB, FALSE, 8, outwidth,
- outheight, GST_ROUND_UP_4 (outwidth * 3),
- destroy_pixbuf, buf);
+ GDK_COLORSPACE_RGB, FALSE, 8, outwidth,
+ outheight, GST_ROUND_UP_4 (outwidth * 3), destroy_pixbuf, buf);
- if (!pixbuf)
- {
- GST_DEBUG ("Could not take screenshot: %s", "could not create pixbuf");
- g_warning ("Could not take screenshot: %s", "could not create pixbuf");
- gst_buffer_unref (buf);
- }
+ if (!pixbuf) {
+ GST_DEBUG ("Could not take screenshot: %s", "could not create pixbuf");
+ g_warning ("Could not take screenshot: %s", "could not create pixbuf");
+ gst_buffer_unref (buf);
+ }
return pixbuf;
}
@@ -5722,19 +5183,17 @@ bacon_video_widget_init_backend (int *argc, char ***argv)
GQuark
bacon_video_widget_error_quark (void)
{
- static GQuark q; /* 0 */
+ static GQuark q; /* 0 */
- if (G_UNLIKELY (q == 0))
- {
- q = g_quark_from_static_string ("bvw-error-quark");
- }
+ if (G_UNLIKELY (q == 0)) {
+ q = g_quark_from_static_string ("bvw-error-quark");
+ }
return q;
}
/* fold function to pick the best colorspace element */
static gboolean
-find_colorbalance_element (GstElement * element, GValue * ret,
- GstElement ** cb)
+find_colorbalance_element (GstElement * element, GValue * ret, GstElement ** cb)
{
GstColorBalanceClass *cb_class;
@@ -5746,21 +5205,16 @@ find_colorbalance_element (GstElement * element, GValue * ret,
GST_DEBUG ("Element %s is a color balance", GST_OBJECT_NAME (element));
cb_class = GST_COLOR_BALANCE_GET_CLASS (element);
- if (GST_COLOR_BALANCE_TYPE (cb_class) == GST_COLOR_BALANCE_HARDWARE)
- {
- gst_object_replace ((GstObject **) cb, (GstObject *) element);
- /* shortcuts the fold */
- return FALSE;
- }
- else if (*cb == NULL)
- {
- gst_object_replace ((GstObject **) cb, (GstObject *) element);
- return TRUE;
- }
- else
- {
- return TRUE;
- }
+ if (GST_COLOR_BALANCE_TYPE (cb_class) == GST_COLOR_BALANCE_HARDWARE) {
+ gst_object_replace ((GstObject **) cb, (GstObject *) element);
+ /* shortcuts the fold */
+ return FALSE;
+ } else if (*cb == NULL) {
+ gst_object_replace ((GstObject **) cb, (GstObject *) element);
+ return TRUE;
+ } else {
+ return TRUE;
+ }
}
static gboolean
@@ -5786,77 +5240,64 @@ bvw_update_interface_implementations (BaconVideoWidget * bvw)
GstIteratorResult ires;
GstIterator *iter;
- if (g_thread_self () != gui_thread)
- {
- if (bvw->priv->balance)
- gst_object_unref (bvw->priv->balance);
- bvw->priv->balance = NULL;
- if (bvw->priv->xoverlay)
- gst_object_unref (bvw->priv->xoverlay);
- bvw->priv->xoverlay = NULL;
- if (bvw->priv->navigation)
- gst_object_unref (bvw->priv->navigation);
- bvw->priv->navigation = NULL;
-
- if (bvw->priv->interface_update_id)
- g_source_remove (bvw->priv->interface_update_id);
- bvw->priv->interface_update_id =
- g_idle_add ((GSourceFunc) bvw_update_interfaces_delayed, bvw);
- return;
- }
+ if (g_thread_self () != gui_thread) {
+ if (bvw->priv->balance)
+ gst_object_unref (bvw->priv->balance);
+ bvw->priv->balance = NULL;
+ if (bvw->priv->xoverlay)
+ gst_object_unref (bvw->priv->xoverlay);
+ bvw->priv->xoverlay = NULL;
+ if (bvw->priv->navigation)
+ gst_object_unref (bvw->priv->navigation);
+ bvw->priv->navigation = NULL;
+
+ if (bvw->priv->interface_update_id)
+ g_source_remove (bvw->priv->interface_update_id);
+ bvw->priv->interface_update_id =
+ g_idle_add ((GSourceFunc) bvw_update_interfaces_delayed, bvw);
+ return;
+ }
g_object_get (bvw->priv->play, "video-sink", &video_sink, NULL);
g_assert (video_sink != NULL);
/* We try to get an element supporting XOverlay interface */
- if (GST_IS_BIN (video_sink))
- {
- GST_DEBUG ("Retrieving xoverlay from bin ...");
- element = gst_bin_get_by_interface (GST_BIN (video_sink),
- GST_TYPE_X_OVERLAY);
- }
- else
- {
- element = gst_object_ref (video_sink);
- }
+ if (GST_IS_BIN (video_sink)) {
+ GST_DEBUG ("Retrieving xoverlay from bin ...");
+ element = gst_bin_get_by_interface (GST_BIN (video_sink),
+ GST_TYPE_X_OVERLAY);
+ } else {
+ element = gst_object_ref (video_sink);
+ }
- if (GST_IS_X_OVERLAY (element))
- {
- GST_DEBUG ("Found xoverlay: %s", GST_OBJECT_NAME (element));
- bvw->priv->xoverlay = GST_X_OVERLAY (element);
- }
- else
- {
- GST_DEBUG ("No xoverlay found");
- if (element)
- gst_object_unref (element);
- bvw->priv->xoverlay = NULL;
- }
+ if (GST_IS_X_OVERLAY (element)) {
+ GST_DEBUG ("Found xoverlay: %s", GST_OBJECT_NAME (element));
+ bvw->priv->xoverlay = GST_X_OVERLAY (element);
+ } else {
+ GST_DEBUG ("No xoverlay found");
+ if (element)
+ gst_object_unref (element);
+ bvw->priv->xoverlay = NULL;
+ }
/* Try to find the navigation interface */
- if (GST_IS_BIN (video_sink))
- {
- GST_DEBUG ("Retrieving navigation from bin ...");
- element = gst_bin_get_by_interface (GST_BIN (video_sink),
- GST_TYPE_NAVIGATION);
- }
- else
- {
- element = gst_object_ref (video_sink);
- }
+ if (GST_IS_BIN (video_sink)) {
+ GST_DEBUG ("Retrieving navigation from bin ...");
+ element = gst_bin_get_by_interface (GST_BIN (video_sink),
+ GST_TYPE_NAVIGATION);
+ } else {
+ element = gst_object_ref (video_sink);
+ }
- if (GST_IS_NAVIGATION (element))
- {
- GST_DEBUG ("Found navigation: %s", GST_OBJECT_NAME (element));
- bvw->priv->navigation = GST_NAVIGATION (element);
- }
- else
- {
- GST_DEBUG ("No navigation found");
- if (element)
- gst_object_unref (element);
- bvw->priv->navigation = NULL;
- }
+ if (GST_IS_NAVIGATION (element)) {
+ GST_DEBUG ("Found navigation: %s", GST_OBJECT_NAME (element));
+ bvw->priv->navigation = GST_NAVIGATION (element);
+ } else {
+ GST_DEBUG ("No navigation found");
+ if (element)
+ gst_object_unref (element);
+ bvw->priv->navigation = NULL;
+ }
/* Find best color balance element (using custom iterator so
* we can prefer hardware implementations to software ones) */
@@ -5865,32 +5306,26 @@ bvw_update_interface_implementations (BaconVideoWidget * bvw)
* the fold function doesn't even get called, while sometimes
* it does ... */
iter = gst_bin_iterate_all_by_interface (GST_BIN (bvw->priv->play),
- GST_TYPE_COLOR_BALANCE);
+ GST_TYPE_COLOR_BALANCE);
/* naively assume no resync */
element = NULL;
- ires = gst_iterator_fold (iter,
- (GstIteratorFoldFunction)
- find_colorbalance_element, NULL, &element);
+ ires = gst_iterator_fold (iter, (GstIteratorFoldFunction)
+ find_colorbalance_element, NULL, &element);
gst_iterator_free (iter);
- if (element)
- {
- bvw->priv->balance = GST_COLOR_BALANCE (element);
- GST_DEBUG ("Best colorbalance found: %s",
- GST_OBJECT_NAME (bvw->priv->balance));
- }
- else if (GST_IS_COLOR_BALANCE (bvw->priv->xoverlay))
- {
- bvw->priv->balance = GST_COLOR_BALANCE (bvw->priv->xoverlay);
- gst_object_ref (bvw->priv->balance);
- GST_DEBUG ("Colorbalance backup found: %s",
- GST_OBJECT_NAME (bvw->priv->balance));
- }
- else
- {
- GST_DEBUG ("No colorbalance found");
- bvw->priv->balance = NULL;
- }
+ if (element) {
+ bvw->priv->balance = GST_COLOR_BALANCE (element);
+ GST_DEBUG ("Best colorbalance found: %s",
+ GST_OBJECT_NAME (bvw->priv->balance));
+ } else if (GST_IS_COLOR_BALANCE (bvw->priv->xoverlay)) {
+ bvw->priv->balance = GST_COLOR_BALANCE (bvw->priv->xoverlay);
+ gst_object_ref (bvw->priv->balance);
+ GST_DEBUG ("Colorbalance backup found: %s",
+ GST_OBJECT_NAME (bvw->priv->balance));
+ } else {
+ GST_DEBUG ("No colorbalance found");
+ bvw->priv->balance = NULL;
+ }
if (old_xoverlay)
gst_object_unref (GST_OBJECT (old_xoverlay));
@@ -5915,32 +5350,30 @@ bvw_element_msg_sync (GstBus * bus, GstMessage * msg, gpointer data)
/* This only gets sent if we haven't set an ID yet. This is our last
* chance to set it before the video sink will create its own window */
- if (gst_structure_has_name (msg->structure, "prepare-xwindow-id"))
- {
- GST_INFO ("Handling sync prepare-xwindow-id message");
+ if (gst_structure_has_name (msg->structure, "prepare-xwindow-id")) {
+ GST_INFO ("Handling sync prepare-xwindow-id message");
- g_mutex_lock (bvw->priv->lock);
- bvw_update_interface_implementations (bvw);
- g_mutex_unlock (bvw->priv->lock);
+ g_mutex_lock (bvw->priv->lock);
+ bvw_update_interface_implementations (bvw);
+ g_mutex_unlock (bvw->priv->lock);
- g_return_if_fail (bvw->priv->xoverlay != NULL);
- g_return_if_fail (bvw->priv->video_window != NULL);
+ g_return_if_fail (bvw->priv->xoverlay != NULL);
+ g_return_if_fail (bvw->priv->video_window != NULL);
#ifdef WIN32
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_HWND (bvw->priv->
- video_window));
+ gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
+ GDK_WINDOW_HWND (bvw->priv->video_window));
#else
- gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
- GDK_WINDOW_XID (bvw->priv->video_window));
+ gst_x_overlay_set_xwindow_id (bvw->priv->xoverlay,
+ GDK_WINDOW_XID (bvw->priv->video_window));
#endif
- }
+ }
}
static void
got_new_video_sink_bin_element (GstBin * video_sink, GstElement * element,
- gpointer data)
+ gpointer data)
{
BaconVideoWidget *bvw = BACON_VIDEO_WIDGET (data);
@@ -5979,12 +5412,10 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
gchar *version_str;
#ifndef GST_DISABLE_GST_INFO
- if (_totem_gst_debug_cat == NULL)
- {
- GST_DEBUG_CATEGORY_INIT (_totem_gst_debug_cat, "totem", 0,
- "Totem GStreamer Backend");
- }
-
+ if (_totem_gst_debug_cat == NULL) {
+ GST_DEBUG_CATEGORY_INIT (_totem_gst_debug_cat, "totem", 0,
+ "Totem GStreamer Backend");
+ }
#endif
version_str = gst_version_string ();
@@ -6000,24 +5431,23 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
GST_INFO ("use_type = %d", type);
bvw->priv->play = gst_element_factory_make ("playbin2", "play");
- if (!bvw->priv->play)
- {
+ if (!bvw->priv->play) {
- g_set_error (err, BVW_ERROR, GST_ERROR_PLUGIN_LOAD,
- _("Failed to create a GStreamer play object. "
- "Please check your GStreamer installation."));
- g_object_ref_sink (bvw);
- g_object_unref (bvw);
- return NULL;
- }
+ g_set_error (err, BVW_ERROR, GST_ERROR_PLUGIN_LOAD,
+ _("Failed to create a GStreamer play object. "
+ "Please check your GStreamer installation."));
+ g_object_ref_sink (bvw);
+ g_object_unref (bvw);
+ return NULL;
+ }
bvw->priv->bus = gst_element_get_bus (bvw->priv->play);
gst_bus_add_signal_watch (bvw->priv->bus);
bvw->priv->sig_bus_async =
- g_signal_connect (bvw->priv->bus, "message",
- G_CALLBACK (bvw_bus_message_cb), bvw);
+ g_signal_connect (bvw->priv->bus, "message",
+ G_CALLBACK (bvw_bus_message_cb), bvw);
bvw->priv->speakersetup = BVW_AUDIO_SOUND_STEREO;
bvw->priv->media_device = g_strdup ("/dev/dvd");
@@ -6028,182 +5458,153 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
bvw->priv->auto_resize = FALSE;
- if (type == BVW_USE_TYPE_VIDEO || type == BVW_USE_TYPE_AUDIO)
- {
+ if (type == BVW_USE_TYPE_VIDEO || type == BVW_USE_TYPE_AUDIO) {
- audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
+ audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
- if (audio_sink == NULL)
- {
- g_warning ("Could not create element 'autoaudiosink'");
- }
- }
- else
- {
- audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");
+ if (audio_sink == NULL) {
+ g_warning ("Could not create element 'autoaudiosink'");
}
+ } else {
+ audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");
+ }
- if (type == BVW_USE_TYPE_VIDEO)
- {
- video_sink =
- gst_element_factory_make (DEFAULT_VIDEO_SINK, "video-sink");
-
- if (video_sink == NULL)
- {
- g_warning ("Could not create element '%s'", DEFAULT_VIDEO_SINK);
- /* Try to fallback on ximagesink */
- video_sink = gst_element_factory_make ("ximagesink", "video-sink");
- }
+ if (type == BVW_USE_TYPE_VIDEO) {
+ video_sink = gst_element_factory_make (DEFAULT_VIDEO_SINK, "video-sink");
- }
- else
- {
- video_sink = gst_element_factory_make ("fakesink", "video-fake-sink");
- if (video_sink)
- g_object_set (video_sink, "sync", TRUE, NULL);
+ if (video_sink == NULL) {
+ g_warning ("Could not create element '%s'", DEFAULT_VIDEO_SINK);
+ /* Try to fallback on ximagesink */
+ video_sink = gst_element_factory_make ("ximagesink", "video-sink");
}
- if (video_sink)
- {
- GstStateChangeReturn ret;
+ } else {
+ video_sink = gst_element_factory_make ("fakesink", "video-fake-sink");
+ if (video_sink)
+ g_object_set (video_sink, "sync", TRUE, NULL);
+ }
- /* need to set bus explicitly as it's not in a bin yet and
- * poll_for_state_change() needs one to catch error messages */
+ if (video_sink) {
+ GstStateChangeReturn ret;
+
+ /* need to set bus explicitly as it's not in a bin yet and
+ * poll_for_state_change() needs one to catch error messages */
+ gst_element_set_bus (video_sink, bvw->priv->bus);
+ /* state change NULL => READY should always be synchronous */
+ ret = gst_element_set_state (video_sink, GST_STATE_READY);
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ /* Drop this video sink */
+ gst_element_set_state (video_sink, GST_STATE_NULL);
+ gst_object_unref (video_sink);
+ /* Try again with autovideosink */
+ video_sink = gst_element_factory_make ("autovideosink", "video-sink");
gst_element_set_bus (video_sink, bvw->priv->bus);
- /* state change NULL => READY should always be synchronous */
ret = gst_element_set_state (video_sink, GST_STATE_READY);
- if (ret == GST_STATE_CHANGE_FAILURE)
- {
- /* Drop this video sink */
- gst_element_set_state (video_sink, GST_STATE_NULL);
- gst_object_unref (video_sink);
- /* Try again with autovideosink */
- video_sink =
- gst_element_factory_make ("autovideosink", "video-sink");
- gst_element_set_bus (video_sink, bvw->priv->bus);
- ret = gst_element_set_state (video_sink, GST_STATE_READY);
- if (ret == GST_STATE_CHANGE_FAILURE)
- {
- GstMessage *err_msg;
-
- err_msg = gst_bus_poll (bvw->priv->bus, GST_MESSAGE_ERROR, 0);
- if (err_msg == NULL)
- {
- g_warning
- ("Should have gotten an error message, please file a bug.");
- g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
- _
- ("Failed to open video output. It may not be available. "
- "Please select another video output in the Multimedia "
- "Systems Selector."));
- }
- else if (err_msg)
- {
- *err = bvw_error_from_gst_error (bvw, err_msg);
- gst_message_unref (err_msg);
- }
- goto sink_error;
- }
- }
- }
- else
- {
- g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
- _("Could not find the video output. "
- "You may need to install additional GStreamer plugins, "
- "or select another video output in the Multimedia Systems "
- "Selector."));
- goto sink_error;
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ GstMessage *err_msg;
+
+ err_msg = gst_bus_poll (bvw->priv->bus, GST_MESSAGE_ERROR, 0);
+ if (err_msg == NULL) {
+ g_warning ("Should have gotten an error message, please file a bug.");
+ g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
+ _
+ ("Failed to open video output. It may not be available. "
+ "Please select another video output in the Multimedia "
+ "Systems Selector."));
+ } else if (err_msg) {
+ *err = bvw_error_from_gst_error (bvw, err_msg);
+ gst_message_unref (err_msg);
+ }
+ goto sink_error;
+ }
}
+ } else {
+ g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
+ _("Could not find the video output. "
+ "You may need to install additional GStreamer plugins, "
+ "or select another video output in the Multimedia Systems "
+ "Selector."));
+ goto sink_error;
+ }
- if (audio_sink)
- {
- GstStateChangeReturn ret;
- GstBus *bus;
-
- /* need to set bus explicitly as it's not in a bin yet and
- * we need one to catch error messages */
- bus = gst_bus_new ();
- gst_element_set_bus (audio_sink, bus);
-
- /* state change NULL => READY should always be synchronous */
- ret = gst_element_set_state (audio_sink, GST_STATE_READY);
- gst_element_set_bus (audio_sink, NULL);
-
- if (ret == GST_STATE_CHANGE_FAILURE)
- {
- /* doesn't work, drop this audio sink */
- gst_element_set_state (audio_sink, GST_STATE_NULL);
- gst_object_unref (audio_sink);
- audio_sink = NULL;
- /* Hopefully, fakesink should always work */
- if (type != BVW_USE_TYPE_AUDIO)
- audio_sink = gst_element_factory_make ("fakesink", "audio-sink");
- if (audio_sink == NULL)
- {
- GstMessage *err_msg;
-
- err_msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
- if (err_msg == NULL)
- {
- g_warning
- ("Should have gotten an error message, please file a bug.");
- g_set_error (err, BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
- _
- ("Failed to open audio output. You may not have "
- "permission to open the sound device, or the sound "
- "server may not be running. "
- "Please select another audio output in the Multimedia "
- "Systems Selector."));
- }
- else if (err)
- {
- *err = bvw_error_from_gst_error (bvw, err_msg);
- gst_message_unref (err_msg);
- }
- gst_object_unref (bus);
- goto sink_error;
- }
- /* make fakesink sync to the clock like a real sink */
- g_object_set (audio_sink, "sync", TRUE, NULL);
- GST_INFO ("audio sink doesn't work, using fakesink instead");
- bvw->priv->uses_fakesink = TRUE;
- }
- gst_object_unref (bus);
- }
- else
- {
- g_set_error (err, BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
- _("Could not find the audio output. "
- "You may need to install additional GStreamer plugins, or "
- "select another audio output in the Multimedia Systems "
- "Selector."));
- goto sink_error;
- }
+ if (audio_sink) {
+ GstStateChangeReturn ret;
+ GstBus *bus;
+
+ /* need to set bus explicitly as it's not in a bin yet and
+ * we need one to catch error messages */
+ bus = gst_bus_new ();
+ gst_element_set_bus (audio_sink, bus);
+
+ /* state change NULL => READY should always be synchronous */
+ ret = gst_element_set_state (audio_sink, GST_STATE_READY);
+ gst_element_set_bus (audio_sink, NULL);
+
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ /* doesn't work, drop this audio sink */
+ gst_element_set_state (audio_sink, GST_STATE_NULL);
+ gst_object_unref (audio_sink);
+ audio_sink = NULL;
+ /* Hopefully, fakesink should always work */
+ if (type != BVW_USE_TYPE_AUDIO)
+ audio_sink = gst_element_factory_make ("fakesink", "audio-sink");
+ if (audio_sink == NULL) {
+ GstMessage *err_msg;
+
+ err_msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
+ if (err_msg == NULL) {
+ g_warning ("Should have gotten an error message, please file a bug.");
+ g_set_error (err, BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
+ _
+ ("Failed to open audio output. You may not have "
+ "permission to open the sound device, or the sound "
+ "server may not be running. "
+ "Please select another audio output in the Multimedia "
+ "Systems Selector."));
+ } else if (err) {
+ *err = bvw_error_from_gst_error (bvw, err_msg);
+ gst_message_unref (err_msg);
+ }
+ gst_object_unref (bus);
+ goto sink_error;
+ }
+ /* make fakesink sync to the clock like a real sink */
+ g_object_set (audio_sink, "sync", TRUE, NULL);
+ GST_INFO ("audio sink doesn't work, using fakesink instead");
+ bvw->priv->uses_fakesink = TRUE;
+ }
+ gst_object_unref (bus);
+ } else {
+ g_set_error (err, BVW_ERROR, GST_ERROR_AUDIO_PLUGIN,
+ _("Could not find the audio output. "
+ "You may need to install additional GStreamer plugins, or "
+ "select another audio output in the Multimedia Systems "
+ "Selector."));
+ goto sink_error;
+ }
/* set back to NULL to close device again in order to avoid interrupts
* being generated after startup while there's nothing to play yet */
gst_element_set_state (audio_sink, GST_STATE_NULL);
- do
- {
- GstElement *bin;
- GstPad *pad;
-
- bvw->priv->audio_capsfilter =
- gst_element_factory_make ("capsfilter", "audiofilter");
- bin = gst_bin_new ("audiosinkbin");
- gst_bin_add_many (GST_BIN (bin), bvw->priv->audio_capsfilter,
- audio_sink, NULL);
- gst_element_link_pads (bvw->priv->audio_capsfilter, "src",
- audio_sink, "sink");
-
- pad = gst_element_get_pad (bvw->priv->audio_capsfilter, "sink");
- gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));
- gst_object_unref (pad);
-
- audio_sink = bin;
- }
+ do {
+ GstElement *bin;
+ GstPad *pad;
+
+ bvw->priv->audio_capsfilter =
+ gst_element_factory_make ("capsfilter", "audiofilter");
+ bin = gst_bin_new ("audiosinkbin");
+ gst_bin_add_many (GST_BIN (bin), bvw->priv->audio_capsfilter,
+ audio_sink, NULL);
+ gst_element_link_pads (bvw->priv->audio_capsfilter, "src",
+ audio_sink, "sink");
+
+ pad = gst_element_get_pad (bvw->priv->audio_capsfilter, "sink");
+ gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));
+ gst_object_unref (pad);
+
+ audio_sink = bin;
+ }
while (0);
@@ -6212,54 +5613,51 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
g_object_set (bvw->priv->play, "audio-sink", audio_sink, NULL);
g_signal_connect (bvw->priv->play, "notify::source",
- G_CALLBACK (playbin_source_notify_cb), bvw);
+ G_CALLBACK (playbin_source_notify_cb), bvw);
g_signal_connect (bvw->priv->play, "video-changed",
- G_CALLBACK (playbin_stream_changed_cb), bvw);
+ G_CALLBACK (playbin_stream_changed_cb), bvw);
g_signal_connect (bvw->priv->play, "audio-changed",
- G_CALLBACK (playbin_stream_changed_cb), bvw);
+ G_CALLBACK (playbin_stream_changed_cb), bvw);
g_signal_connect (bvw->priv->play, "text-changed",
- G_CALLBACK (playbin_stream_changed_cb), bvw);
+ G_CALLBACK (playbin_stream_changed_cb), bvw);
/* assume we're always called from the main Gtk+ GUI thread */
gui_thread = g_thread_self ();
- if (type == BVW_USE_TYPE_VIDEO)
- {
- GstStateChangeReturn ret;
-
- /* wait for video sink to finish changing to READY state,
- * otherwise we won't be able to detect the colorbalance interface */
- ret = gst_element_get_state (video_sink, NULL, NULL, 5 * GST_SECOND);
-
- if (ret != GST_STATE_CHANGE_SUCCESS)
- {
- GST_WARNING ("Timeout setting videosink to READY");
- g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
- _
- ("Failed to open video output. It may not be available. "
- "Please select another video output in the Multimedia Systems Selector."));
- return NULL;
- }
- bvw_update_interface_implementations (bvw);
+ if (type == BVW_USE_TYPE_VIDEO) {
+ GstStateChangeReturn ret;
+ /* wait for video sink to finish changing to READY state,
+ * otherwise we won't be able to detect the colorbalance interface */
+ ret = gst_element_get_state (video_sink, NULL, NULL, 5 * GST_SECOND);
+
+ if (ret != GST_STATE_CHANGE_SUCCESS) {
+ GST_WARNING ("Timeout setting videosink to READY");
+ g_set_error (err, BVW_ERROR, GST_ERROR_VIDEO_PLUGIN,
+ _
+ ("Failed to open video output. It may not be available. "
+ "Please select another video output in the Multimedia Systems Selector."));
+ return NULL;
}
+ bvw_update_interface_implementations (bvw);
+
+ }
/* we want to catch "prepare-xwindow-id" element messages synchronously */
gst_bus_set_sync_handler (bvw->priv->bus, gst_bus_sync_signal_handler, bvw);
bvw->priv->sig_bus_sync =
- g_signal_connect (bvw->priv->bus, "sync-message::element",
- G_CALLBACK (bvw_element_msg_sync), bvw);
-
- if (GST_IS_BIN (video_sink))
- {
- /* video sink bins like gconfvideosink might remove their children and
- * create new ones when set to NULL state, and they are currently set
- * to NULL state whenever playbin re-creates its internal video bin
- * (it sets all elements to NULL state before gst_bin_remove()ing them) */
- g_signal_connect (video_sink, "element-added",
- G_CALLBACK (got_new_video_sink_bin_element), bvw);
- }
+ g_signal_connect (bvw->priv->bus, "sync-message::element",
+ G_CALLBACK (bvw_element_msg_sync), bvw);
+
+ if (GST_IS_BIN (video_sink)) {
+ /* video sink bins like gconfvideosink might remove their children and
+ * create new ones when set to NULL state, and they are currently set
+ * to NULL state whenever playbin re-creates its internal video bin
+ * (it sets all elements to NULL state before gst_bin_remove()ing them) */
+ g_signal_connect (video_sink, "element-added",
+ G_CALLBACK (got_new_video_sink_bin_element), bvw);
+ }
return GTK_WIDGET (bvw);
@@ -6267,16 +5665,14 @@ bacon_video_widget_new (int width, int height, BvwUseType type, GError ** err)
/* errors */
sink_error:
{
- if (video_sink)
- {
- gst_element_set_state (video_sink, GST_STATE_NULL);
- gst_object_unref (video_sink);
- }
- if (audio_sink)
- {
- gst_element_set_state (audio_sink, GST_STATE_NULL);
- gst_object_unref (audio_sink);
- }
+ if (video_sink) {
+ gst_element_set_state (video_sink, GST_STATE_NULL);
+ gst_object_unref (video_sink);
+ }
+ if (audio_sink) {
+ gst_element_set_state (audio_sink, GST_STATE_NULL);
+ gst_object_unref (audio_sink);
+ }
g_object_ref (bvw);
g_object_ref_sink (G_OBJECT (bvw));
diff --git a/libcesarplayer/src/bacon-video-widget.h b/libcesarplayer/src/bacon-video-widget.h
index cde269d..7f9e7a0 100644
--- a/libcesarplayer/src/bacon-video-widget.h
+++ b/libcesarplayer/src/bacon-video-widget.h
@@ -68,8 +68,7 @@ typedef struct
void (*title_change) (BaconVideoWidget * bvw, const char *title);
void (*channels_change) (BaconVideoWidget * bvw);
void (*tick) (BaconVideoWidget * bvw, gint64 current_time,
- gint64 stream_length, float current_position,
- gboolean seekable);
+ gint64 stream_length, float current_position, gboolean seekable);
void (*buffering) (BaconVideoWidget * bvw, guint progress);
void (*state_change) (BaconVideoWidget * bvw, gboolean playing);
void (*got_duration) (BaconVideoWidget * bvw);
@@ -79,7 +78,7 @@ typedef struct
EXPORT GQuark
bacon_video_widget_error_quark (void)
- G_GNUC_CONST;
+ G_GNUC_CONST;
EXPORT GType bacon_video_widget_get_type (void) G_GNUC_CONST;
EXPORT GOptionGroup *bacon_video_widget_get_option_group (void);
/* This can be used if the app does not use popt */
@@ -105,17 +104,13 @@ bacon_video_widget_error_quark (void)
} BvwUseType;
EXPORT GtkWidget *bacon_video_widget_new (int width, int height,
- BvwUseType type,
- GError ** error);
+ BvwUseType type, GError ** error);
- EXPORT char *bacon_video_widget_get_backend_name (BaconVideoWidget *
- bvw);
+ EXPORT char *bacon_video_widget_get_backend_name (BaconVideoWidget * bvw);
/* Actions */
EXPORT gboolean bacon_video_widget_open (BaconVideoWidget * bvw,
- const char *mrl,
- const char *subtitle_uri,
- GError ** error);
+ const char *mrl, const char *subtitle_uri, GError ** error);
EXPORT gboolean bacon_video_widget_play (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_pause (BaconVideoWidget * bvw);
EXPORT gboolean bacon_video_widget_is_playing (BaconVideoWidget * bvw);
@@ -123,53 +118,36 @@ bacon_video_widget_error_quark (void)
/* Seeking and length */
EXPORT gboolean bacon_video_widget_is_seekable (BaconVideoWidget * bvw);
EXPORT gboolean bacon_video_widget_seek (BaconVideoWidget * bvw,
- gdouble position, gfloat rate);
+ gdouble position, gfloat rate);
EXPORT gboolean bacon_video_widget_seek_time (BaconVideoWidget * bvw,
- gint64 time,
- gfloat rate,
- gboolean accurate);
+ gint64 time, gfloat rate, gboolean accurate);
EXPORT gboolean bacon_video_widget_segment_seek (BaconVideoWidget * bvw,
- gint64 start,
- gint64 stop,
- gfloat rate);
+ gint64 start, gint64 stop, gfloat rate);
EXPORT gboolean bacon_video_widget_seek_in_segment (BaconVideoWidget *
- bvw, gint64 pos,
- gfloat rate);
+ bvw, gint64 pos, gfloat rate);
EXPORT gboolean bacon_video_widget_seek_to_next_frame (BaconVideoWidget *
- bvw, gfloat rate,
- gboolean
- in_segment);
+ bvw, gfloat rate, gboolean in_segment);
EXPORT gboolean
- bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
- gfloat rate,
- gboolean in_segment);
+ bacon_video_widget_seek_to_previous_frame (BaconVideoWidget * bvw,
+ gfloat rate, gboolean in_segment);
EXPORT gboolean bacon_video_widget_segment_stop_update (BaconVideoWidget
- * bvw,
- gint64 stop,
- gfloat rate);
+ * bvw, gint64 stop, gfloat rate);
EXPORT gboolean bacon_video_widget_segment_start_update (BaconVideoWidget
- * bvw,
- gint64 start,
- gfloat rate);
+ * bvw, gint64 start, gfloat rate);
EXPORT gboolean bacon_video_widget_new_file_seek (BaconVideoWidget * bvw,
- gint64 start,
- gint64 stop,
- gfloat rate);
+ gint64 start, gint64 stop, gfloat rate);
EXPORT gboolean bacon_video_widget_can_direct_seek (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT double bacon_video_widget_get_position (BaconVideoWidget * bvw);
- EXPORT gint64 bacon_video_widget_get_current_time (BaconVideoWidget *
- bvw);
+ EXPORT gint64 bacon_video_widget_get_current_time (BaconVideoWidget * bvw);
EXPORT gint64 bacon_video_widget_get_stream_length (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT gint64
- bacon_video_widget_get_accurate_current_time (BaconVideoWidget * bvw);
+ bacon_video_widget_get_accurate_current_time (BaconVideoWidget * bvw);
EXPORT gboolean bacon_video_widget_set_rate (BaconVideoWidget * bvw,
- gfloat rate);
+ gfloat rate);
EXPORT gboolean bacon_video_widget_set_rate_in_segment (BaconVideoWidget
- * bvw,
- gfloat rate,
- gint64 stop);
+ * bvw, gfloat rate, gint64 stop);
@@ -177,54 +155,49 @@ bacon_video_widget_error_quark (void)
EXPORT void bacon_video_widget_close (BaconVideoWidget * bvw);
/* Audio volume */
- EXPORT gboolean bacon_video_widget_can_set_volume (BaconVideoWidget *
- bvw);
+ EXPORT gboolean bacon_video_widget_can_set_volume (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_set_volume (BaconVideoWidget * bvw,
- double volume);
+ double volume);
EXPORT double bacon_video_widget_get_volume (BaconVideoWidget * bvw);
/*Drawings Overlay*/
EXPORT void bacon_video_widget_set_drawing_pixbuf (BaconVideoWidget *
- bvw,
- GdkPixbuf * drawing);
+ bvw, GdkPixbuf * drawing);
EXPORT void bacon_video_widget_set_drawing_mode (BaconVideoWidget * bvw,
- gboolean drawing_mode);
+ gboolean drawing_mode);
/* Properties */
EXPORT void bacon_video_widget_set_logo (BaconVideoWidget * bvw,
- char *filename);
+ char *filename);
EXPORT void bacon_video_widget_set_logo_pixbuf (BaconVideoWidget * bvw,
- GdkPixbuf * logo);
+ GdkPixbuf * logo);
EXPORT void bacon_video_widget_set_logo_mode (BaconVideoWidget * bvw,
- gboolean logo_mode);
- EXPORT gboolean bacon_video_widget_get_logo_mode (BaconVideoWidget *
- bvw);
+ gboolean logo_mode);
+ EXPORT gboolean bacon_video_widget_get_logo_mode (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_set_fullscreen (BaconVideoWidget * bvw,
- gboolean fullscreen);
+ gboolean fullscreen);
EXPORT void bacon_video_widget_set_show_cursor (BaconVideoWidget * bvw,
- gboolean show_cursor);
+ gboolean show_cursor);
EXPORT gboolean bacon_video_widget_get_show_cursor (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT gboolean bacon_video_widget_get_auto_resize (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT void bacon_video_widget_set_auto_resize (BaconVideoWidget * bvw,
- gboolean auto_resize);
+ gboolean auto_resize);
EXPORT void bacon_video_widget_set_connection_speed (BaconVideoWidget *
- bvw, int speed);
+ bvw, int speed);
EXPORT int bacon_video_widget_get_connection_speed (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT void bacon_video_widget_set_subtitle_font (BaconVideoWidget * bvw,
- const char *font);
+ const char *font);
EXPORT void bacon_video_widget_set_subtitle_encoding (BaconVideoWidget *
- bvw,
- const char
- *encoding);
+ bvw, const char *encoding);
/* Metadata */
/**
@@ -278,8 +251,7 @@ bacon_video_widget_error_quark (void)
} BvwMetadataType;
EXPORT void bacon_video_widget_get_metadata (BaconVideoWidget * bvw,
- BvwMetadataType type,
- GValue * value);
+ BvwMetadataType type, GValue * value);
/* Picture settings */
@@ -322,30 +294,28 @@ bacon_video_widget_error_quark (void)
} BvwAspectRatio;
EXPORT gboolean bacon_video_widget_can_deinterlace (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT void bacon_video_widget_set_deinterlacing (BaconVideoWidget * bvw,
- gboolean deinterlace);
+ gboolean deinterlace);
EXPORT gboolean bacon_video_widget_get_deinterlacing (BaconVideoWidget *
- bvw);
+ bvw);
EXPORT void bacon_video_widget_set_aspect_ratio (BaconVideoWidget * bvw,
- BvwAspectRatio ratio);
+ BvwAspectRatio ratio);
EXPORT BvwAspectRatio bacon_video_widget_get_aspect_ratio
- (BaconVideoWidget * bvw);
+ (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_set_scale_ratio (BaconVideoWidget * bvw,
- float ratio);
+ float ratio);
EXPORT void bacon_video_widget_set_zoom (BaconVideoWidget * bvw,
- double zoom);
+ double zoom);
EXPORT double bacon_video_widget_get_zoom (BaconVideoWidget * bvw);
EXPORT int bacon_video_widget_get_video_property (BaconVideoWidget * bvw,
- BvwVideoProperty type);
+ BvwVideoProperty type);
EXPORT void bacon_video_widget_set_video_property (BaconVideoWidget *
- bvw,
- BvwVideoProperty type,
- int value);
+ bvw, BvwVideoProperty type, int value);
/* DVD functions */
/**
@@ -393,27 +363,26 @@ bacon_video_widget_error_quark (void)
} BvwDVDEvent;
EXPORT void bacon_video_widget_dvd_event (BaconVideoWidget * bvw,
- BvwDVDEvent type);
+ BvwDVDEvent type);
EXPORT GList *bacon_video_widget_get_languages (BaconVideoWidget * bvw);
EXPORT int bacon_video_widget_get_language (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_set_language (BaconVideoWidget * bvw,
- int language);
+ int language);
EXPORT GList *bacon_video_widget_get_subtitles (BaconVideoWidget * bvw);
EXPORT int bacon_video_widget_get_subtitle (BaconVideoWidget * bvw);
EXPORT void bacon_video_widget_set_subtitle (BaconVideoWidget * bvw,
- int subtitle);
+ int subtitle);
- EXPORT gboolean bacon_video_widget_has_next_track (BaconVideoWidget *
- bvw);
+ EXPORT gboolean bacon_video_widget_has_next_track (BaconVideoWidget * bvw);
EXPORT gboolean bacon_video_widget_has_previous_track (BaconVideoWidget *
- bvw);
+ bvw);
/* Screenshot functions */
EXPORT gboolean bacon_video_widget_can_get_frames (BaconVideoWidget *
- bvw, GError ** error);
+ bvw, GError ** error);
EXPORT GdkPixbuf *bacon_video_widget_get_current_frame (BaconVideoWidget
- * bvw);
+ * bvw);
EXPORT void bacon_video_widget_unref_pixbuf (GdkPixbuf * pixbuf);
/* Audio-out functions */
@@ -439,11 +408,9 @@ bacon_video_widget_error_quark (void)
} BvwAudioOutType;
EXPORT BvwAudioOutType bacon_video_widget_get_audio_out_type
- (BaconVideoWidget * bvw);
+ (BaconVideoWidget * bvw);
EXPORT gboolean bacon_video_widget_set_audio_out_type (BaconVideoWidget *
- bvw,
- BvwAudioOutType
- type);
+ bvw, BvwAudioOutType type);
G_END_DECLS
#endif /* HAVE_BACON_VIDEO_WIDGET_H */
diff --git a/libcesarplayer/src/gst-camera-capturer.c b/libcesarplayer/src/gst-camera-capturer.c
index 74e1468..e8fff73 100644
--- a/libcesarplayer/src/gst-camera-capturer.c
+++ b/libcesarplayer/src/gst-camera-capturer.c
@@ -54,14 +54,15 @@
#define DEFAULT_SOURCE_TYPE GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW
-typedef enum {
- GST_CAMERABIN_FLAG_SOURCE_RESIZE = (1 << 0),
- GST_CAMERABIN_FLAG_SOURCE_COLOR_CONVERSION = (1 << 1),
+typedef enum
+{
+ GST_CAMERABIN_FLAG_SOURCE_RESIZE = (1 << 0),
+ GST_CAMERABIN_FLAG_SOURCE_COLOR_CONVERSION = (1 << 1),
GST_CAMERABIN_FLAG_VIEWFINDER_COLOR_CONVERSION = (1 << 2),
- GST_CAMERABIN_FLAG_VIEWFINDER_SCALE = (1 << 3),
- GST_CAMERABIN_FLAG_AUDIO_CONVERSION = (1 << 4),
- GST_CAMERABIN_FLAG_DISABLE_AUDIO = (1 << 5),
- GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION = (1 << 6)
+ GST_CAMERABIN_FLAG_VIEWFINDER_SCALE = (1 << 3),
+ GST_CAMERABIN_FLAG_AUDIO_CONVERSION = (1 << 4),
+ GST_CAMERABIN_FLAG_DISABLE_AUDIO = (1 << 5),
+ GST_CAMERABIN_FLAG_IMAGE_COLOR_CONVERSION = (1 << 6)
} GstCameraBinFlags;
/* Signals */
@@ -209,17 +210,17 @@ gst_camera_capturer_finalize (GObject * object)
gcc->priv->bus = NULL;
}
- if (gcc->priv->output_file){
+ if (gcc->priv->output_file) {
g_free (gcc->priv->output_file);
gcc->priv->output_file = NULL;
}
- if (gcc->priv->device_id){
+ if (gcc->priv->device_id) {
g_free (gcc->priv->device_id);
gcc->priv->device_id = NULL;
}
- if (gcc->priv->logo_pixbuf){
+ if (gcc->priv->logo_pixbuf) {
g_object_unref (gcc->priv->logo_pixbuf);
gcc->priv->logo_pixbuf = NULL;
}
@@ -282,18 +283,19 @@ gst_camera_capturer_set_audio_bit_rate (GstCameraCapturer * gcc, gint bitrate)
}
static void
-gst_camera_capturer_set_audio_enabled (GstCameraCapturer * gcc, gboolean enabled)
+gst_camera_capturer_set_audio_enabled (GstCameraCapturer * gcc,
+ gboolean enabled)
{
gint flags;
gcc->priv->audio_enabled = enabled;
g_object_get (gcc->priv->main_pipeline, "flags", &flags, NULL);
- if (!enabled){
- flags &= ~GST_CAMERABIN_FLAG_DISABLE_AUDIO;
- GST_INFO_OBJECT (gcc, "Audio disabled");
+ if (!enabled) {
+ flags &= ~GST_CAMERABIN_FLAG_DISABLE_AUDIO;
+ GST_INFO_OBJECT (gcc, "Audio disabled");
} else {
- flags |= GST_CAMERABIN_FLAG_DISABLE_AUDIO;
- GST_INFO_OBJECT (gcc, "Audio enabled");
+ flags |= GST_CAMERABIN_FLAG_DISABLE_AUDIO;
+ GST_INFO_OBJECT (gcc, "Audio enabled");
}
}
@@ -319,13 +321,14 @@ gst_camera_capturer_set_device_id (GstCameraCapturer * gcc,
/* On linux it only makes sense to set the device id
* for the dv1394src element because the gconf one can be set
* through gstreamer-properties */
- if (gcc->priv->source_type == GST_CAMERA_CAPTURE_SOURCE_TYPE_DV){
+ if (gcc->priv->source_type == GST_CAMERA_CAPTURE_SOURCE_TYPE_DV) {
GstElement *source;
- source = gst_bin_get_by_name (GST_BIN(gcc->priv->videosrc), "source_element");
- g_object_set (source, "guid", g_ascii_strtoull(device_id, NULL, 10), NULL);
+ source =
+ gst_bin_get_by_name (GST_BIN (gcc->priv->videosrc), "source_element");
+ g_object_set (source, "guid", g_ascii_strtoull (device_id, NULL, 10), NULL);
}
-#endif
+#endif
GST_INFO_OBJECT (gcc, "Changed device id/name to :\n%s", device_id);
}
@@ -393,7 +396,7 @@ get_media_size (GstCameraCapturer * gcc, gint * width, gint * height)
disp_par_n = gst_value_get_fraction_numerator (disp_par);
disp_par_d = gst_value_get_fraction_denominator (disp_par);
- GST_DEBUG_OBJECT (gcc,"display PAR is %d/%d", disp_par_n, disp_par_d);
+ GST_DEBUG_OBJECT (gcc, "display PAR is %d/%d", disp_par_n, disp_par_d);
/* Use the movie pixel aspect ratio if any */
if (gcc->priv->movie_par) {
@@ -405,10 +408,10 @@ get_media_size (GstCameraCapturer * gcc, gint * width, gint * height)
movie_par_d = 1;
}
- GST_DEBUG_OBJECT (gcc,"movie PAR is %d/%d", movie_par_n, movie_par_d);
+ GST_DEBUG_OBJECT (gcc, "movie PAR is %d/%d", movie_par_n, movie_par_d);
if (gcc->priv->video_width == 0 || gcc->priv->video_height == 0) {
- GST_DEBUG_OBJECT (gcc,"width and/or height 0, assuming 1/1 ratio");
+ GST_DEBUG_OBJECT (gcc, "width and/or height 0, assuming 1/1 ratio");
num = 1;
den = 1;
} else if (!gst_video_calculate_display_ratio (&num, &den,
@@ -420,8 +423,8 @@ get_media_size (GstCameraCapturer * gcc, gint * width, gint * height)
den = 1;
}
- GST_DEBUG_OBJECT (gcc,"calculated scaling ratio %d/%d for video %dx%d", num,
- den, gcc->priv->video_width, gcc->priv->video_height);
+ GST_DEBUG_OBJECT (gcc, "calculated scaling ratio %d/%d for video %dx%d",
+ num, den, gcc->priv->video_width, gcc->priv->video_height);
/* now find a width x height that respects this display ratio.
* prefer those that have one of w/h the same as the incoming video
@@ -430,22 +433,22 @@ get_media_size (GstCameraCapturer * gcc, gint * width, gint * height)
/* start with same height, because of interlaced video */
/* check hd / den is an integer scale factor, and scale wd with the PAR */
if (gcc->priv->video_height % den == 0) {
- GST_DEBUG_OBJECT (gcc,"keeping video height");
+ GST_DEBUG_OBJECT (gcc, "keeping video height");
gcc->priv->video_width_pixels =
(guint) gst_util_uint64_scale (gcc->priv->video_height, num, den);
gcc->priv->video_height_pixels = gcc->priv->video_height;
} else if (gcc->priv->video_width % num == 0) {
- GST_DEBUG_OBJECT (gcc,"keeping video width");
+ GST_DEBUG_OBJECT (gcc, "keeping video width");
gcc->priv->video_width_pixels = gcc->priv->video_width;
gcc->priv->video_height_pixels =
(guint) gst_util_uint64_scale (gcc->priv->video_width, den, num);
} else {
- GST_DEBUG_OBJECT (gcc,"approximating while keeping video height");
+ GST_DEBUG_OBJECT (gcc, "approximating while keeping video height");
gcc->priv->video_width_pixels =
(guint) gst_util_uint64_scale (gcc->priv->video_height, num, den);
gcc->priv->video_height_pixels = gcc->priv->video_height;
}
- GST_DEBUG_OBJECT (gcc,"scaling to %dx%d", gcc->priv->video_width_pixels,
+ GST_DEBUG_OBJECT (gcc, "scaling to %dx%d", gcc->priv->video_width_pixels,
gcc->priv->video_height_pixels);
*width = gcc->priv->video_width_pixels;
@@ -862,8 +865,7 @@ gst_camera_capturer_class_init (GstCameraCapturerClass * klass)
g_param_spec_string ("output_file", NULL,
NULL, FALSE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DEVICE_ID,
- g_param_spec_string ("device_id", NULL,
- NULL, FALSE, G_PARAM_READWRITE));
+ g_param_spec_string ("device_id", NULL, NULL, FALSE, G_PARAM_READWRITE));
/* Signals */
gcc_signals[SIGNAL_ERROR] =
@@ -917,14 +919,12 @@ gst_camera_capture_videosrc_buffer_probe (GstPad * pad, GstBuffer * buf,
}
static void
-cb_new_pad (GstElement *element,
- GstPad *pad,
- gpointer data)
+cb_new_pad (GstElement * element, GstPad * pad, gpointer data)
{
GstCaps *caps;
const gchar *mime;
GstElement *sink;
- GstBin *bin = GST_BIN(data);
+ GstBin *bin = GST_BIN (data);
caps = gst_pad_get_caps (pad);
mime = gst_structure_get_name (gst_caps_get_structure (caps, 0));
@@ -956,23 +956,23 @@ gst_camera_capture_create_dv1394_source_bin (GstCameraCapturer * gcc)
GstPad *src_pad;
bin = gst_bin_new ("videosource");
- source = gst_element_factory_make(DVVIDEOSRC, "source_device");
- demuxer = gst_element_factory_make("ffdemux_dv", NULL);
- queue1 = gst_element_factory_make("queue", "source_video_sink");
- decoder = gst_element_factory_make("ffdec_dvvideo", NULL);
- queue2 = gst_element_factory_make("queue", NULL);
- deinterlacer = gst_element_factory_make("ffdeinterlace", NULL);
- videorate = gst_element_factory_make("videorate", NULL);
- colorspace = gst_element_factory_make("ffmpegcolorspace", NULL);
- videoscale = gst_element_factory_make("videoscale", NULL);
-
- gst_bin_add_many (GST_BIN(bin), source, demuxer, queue1, decoder,
+ source = gst_element_factory_make (DVVIDEOSRC, "source_device");
+ demuxer = gst_element_factory_make ("ffdemux_dv", NULL);
+ queue1 = gst_element_factory_make ("queue", "source_video_sink");
+ decoder = gst_element_factory_make ("ffdec_dvvideo", NULL);
+ queue2 = gst_element_factory_make ("queue", NULL);
+ deinterlacer = gst_element_factory_make ("ffdeinterlace", NULL);
+ videorate = gst_element_factory_make ("videorate", NULL);
+ colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
+ videoscale = gst_element_factory_make ("videoscale", NULL);
+
+ gst_bin_add_many (GST_BIN (bin), source, demuxer, queue1, decoder,
queue2, deinterlacer, colorspace, videorate, videoscale, NULL);
gst_element_link (source, demuxer);
gst_element_link_many (queue1, decoder, queue2, deinterlacer, videorate,
colorspace, videoscale, NULL);
- g_signal_connect (demuxer, "pad-added", G_CALLBACK(cb_new_pad), bin);
+ g_signal_connect (demuxer, "pad-added", G_CALLBACK (cb_new_pad), bin);
/* add ghostpad */
src_pad = gst_element_get_static_pad (videoscale, "src");
@@ -996,19 +996,20 @@ gst_camera_capture_create_source_bin (GstCameraCapturer * gcc)
GstPad *src_pad;
bin = gst_bin_new ("videosource");
- source = gst_element_factory_make(DVVIDEOSRC, "source_device");
- decoder = gst_element_factory_make("decodebin2", NULL);
- deinterlacer = gst_element_factory_make("ffdeinterlace", "source_video_sink");
- videorate = gst_element_factory_make("videorate", NULL);
- colorspace = gst_element_factory_make("ffmpegcolorspace", NULL);
- videoscale = gst_element_factory_make("videoscale", NULL);
-
- gst_bin_add_many (GST_BIN(bin), source, decoder, deinterlacer,
+ source = gst_element_factory_make (DVVIDEOSRC, "source_device");
+ decoder = gst_element_factory_make ("decodebin2", NULL);
+ deinterlacer =
+ gst_element_factory_make ("ffdeinterlace", "source_video_sink");
+ videorate = gst_element_factory_make ("videorate", NULL);
+ colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
+ videoscale = gst_element_factory_make ("videoscale", NULL);
+
+ gst_bin_add_many (GST_BIN (bin), source, decoder, deinterlacer,
colorspace, videorate, videoscale, NULL);
gst_element_link (source, decoder);
gst_element_link_many (deinterlacer, videorate, colorspace, videoscale, NULL);
- g_signal_connect (decoder, "pad-added", G_CALLBACK(cb_new_pad), bin);
+ g_signal_connect (decoder, "pad-added", G_CALLBACK (cb_new_pad), bin);
/* add ghostpad */
src_pad = gst_element_get_static_pad (videoscale, "src");
@@ -1021,7 +1022,7 @@ gst_camera_capture_create_source_bin (GstCameraCapturer * gcc)
gboolean
gst_camera_capturer_set_source (GstCameraCapturer * gcc,
- GstCameraCaptureSourceType source_type, GError **err)
+ GstCameraCaptureSourceType source_type, GError ** err)
{
GstPad *videosrcpad;
@@ -1040,13 +1041,14 @@ gst_camera_capturer_set_source (GstCameraCapturer * gcc,
#else
gcc->priv->videosrc = gst_camera_capture_create_dv1394_source_bin (gcc);
#endif
- /*gcc->priv->audiosrc = gcc->priv->videosrc;*/
+ /*gcc->priv->audiosrc = gcc->priv->videosrc; */
break;
}
- case GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW:
+ case GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW:
default:
{
- gchar *bin = g_strdup_printf ("%s ! videorate ! ffmpegcolorspace ! videoscale",
+ gchar *bin =
+ g_strdup_printf ("%s ! videorate ! ffmpegcolorspace ! videoscale",
RAWVIDEOSRC);
gcc->priv->videosrc = gst_parse_bin_from_description (bin, TRUE, err);
gcc->priv->audiosrc = gst_element_factory_make (AUDIOSRC, "audiosource");
@@ -1102,7 +1104,7 @@ gst_camera_capturer_new (gchar * filename, GError ** err)
}
GST_INFO_OBJECT (gcc, "Disabling audio");
- flags = GST_CAMERABIN_FLAG_DISABLE_AUDIO;
+ flags = GST_CAMERABIN_FLAG_DISABLE_AUDIO;
#ifdef WIN32
flags |= GST_CAMERABIN_FLAG_VIEWFINDER_COLOR_CONVERSION;
#endif
@@ -1210,16 +1212,14 @@ gst_camera_capturer_set_video_encoder (GstCameraCapturer * gcc,
gcc->priv->videoenc =
gst_element_factory_make ("xvidenc", "video-encoder");
g_object_set (gcc->priv->videoenc, "pass", 1,
- "profile", 146,
- "max-key-interval", -1, NULL);
+ "profile", 146, "max-key-interval", -1, NULL);
name = "Xvid video encoder";
break;
case VIDEO_ENCODER_H264:
gcc->priv->videoenc =
gst_element_factory_make ("x264enc", "video-encoder");
- g_object_set (gcc->priv->videoenc, "key-int-max", 25,
- "pass", 17, NULL);
+ g_object_set (gcc->priv->videoenc, "key-int-max", 25, "pass", 17, NULL);
name = "X264 video encoder";
break;
@@ -1266,7 +1266,8 @@ gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
switch (type) {
case AUDIO_ENCODER_MP3:
- gcc->priv->audioenc = gst_element_factory_make ("lamemp3enc", "audio-encoder");
+ gcc->priv->audioenc =
+ gst_element_factory_make ("lamemp3enc", "audio-encoder");
g_object_set (gcc->priv->audioenc, "target", 0, NULL);
name = "Mp3 audio encoder";
break;
@@ -1361,9 +1362,9 @@ gcc_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
switch (msg_type) {
case GST_MESSAGE_ERROR:
{
- if (gcc->priv->main_pipeline){
+ if (gcc->priv->main_pipeline) {
gst_camera_capturer_stop (gcc);
- gst_camera_capturer_close(gcc);
+ gst_camera_capturer_close (gcc);
gst_element_set_state (gcc->priv->main_pipeline, GST_STATE_NULL);
}
gcc_error_msg (gcc, message);
@@ -1387,8 +1388,7 @@ gcc_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
{
GstState old_state, new_state;
- gst_message_parse_state_changed (message, &old_state, &new_state,
- NULL);
+ gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
if (old_state == new_state)
break;
@@ -1400,7 +1400,7 @@ gcc_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_PLAYING) {
gcc_get_video_stream_info (gcc);
resize_video_window (gcc);
- gtk_widget_queue_draw (GTK_WIDGET(gcc));
+ gtk_widget_queue_draw (GTK_WIDGET (gcc));
}
}
@@ -1437,7 +1437,7 @@ gcc_error_msg (GstCameraCapturer * gcc, GstMessage * msg)
static gboolean
gcc_update_interfaces_delayed (GstCameraCapturer * gcc)
{
- GST_DEBUG_OBJECT (gcc,"Delayed updating interface implementations");
+ GST_DEBUG_OBJECT (gcc, "Delayed updating interface implementations");
g_mutex_lock (gcc->priv->lock);
gcc_update_interface_implementations (gcc);
gcc->priv->interface_update_id = 0;
@@ -1511,7 +1511,7 @@ gcc_get_video_stream_info (GstCameraCapturer * gcc)
sourcepad = gst_element_get_pad (gcc->priv->videosrc, "src");
caps = gst_pad_get_negotiated_caps (sourcepad);
- if (!(caps)){
+ if (!(caps)) {
GST_WARNING_OBJECT (gcc, "Could not get stream info");
return -1;
}
@@ -1549,9 +1549,9 @@ gst_camera_capturer_enum_devices (gchar * device_name)
gst_element_get_state (device, NULL, NULL, 5 * GST_SECOND);
probe = GST_PROPERTY_PROBE (device);
- if (!g_strcmp0(device_name,"dv1394src"))
+ if (!g_strcmp0 (device_name, "dv1394src"))
prop_name = "guid";
- else if (!g_strcmp0(device_name,"v4l2src"))
+ else if (!g_strcmp0 (device_name, "v4l2src"))
prop_name = "device";
else
prop_name = "device-name";
@@ -1562,7 +1562,7 @@ gst_camera_capturer_enum_devices (gchar * device_name)
for (i = 0; i < va->n_values; ++i) {
GValue *v = g_value_array_get_nth (va, i);
- GValue valstr = {0, };
+ GValue valstr = { 0, };
g_value_init (&valstr, G_TYPE_STRING);
if (!g_value_transform (v, &valstr))
@@ -1639,7 +1639,7 @@ gst_camera_capturer_get_current_frame (GstCameraCapturer * gcc)
/* no video info */
if (!gcc->priv->video_width || !gcc->priv->video_height) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "no video info");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s", "no video info");
g_warning ("Could not take screenshot: %s", "no video info");
return NULL;
}
@@ -1649,13 +1649,15 @@ gst_camera_capturer_get_current_frame (GstCameraCapturer * gcc)
gst_buffer_ref (last_buffer);
if (!last_buffer) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "no last video frame");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s",
+ "no last video frame");
g_warning ("Could not take screenshot: %s", "no last video frame");
return NULL;
}
if (GST_BUFFER_CAPS (last_buffer) == NULL) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "no caps on buffer");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s",
+ "no caps on buffer");
g_warning ("Could not take screenshot: %s", "no caps on buffer");
return NULL;
}
@@ -1677,9 +1679,9 @@ gst_camera_capturer_get_current_frame (GstCameraCapturer * gcc)
gcc->priv->video_fps_n, gcc->priv->video_fps_d, NULL);
}
- GST_DEBUG_OBJECT (gcc,"frame caps: %" GST_PTR_FORMAT,
+ GST_DEBUG_OBJECT (gcc, "frame caps: %" GST_PTR_FORMAT,
GST_BUFFER_CAPS (gcc->priv->last_buffer));
- GST_DEBUG_OBJECT (gcc,"pixbuf caps: %" GST_PTR_FORMAT, to_caps);
+ GST_DEBUG_OBJECT (gcc, "pixbuf caps: %" GST_PTR_FORMAT, to_caps);
/* bvw_frame_conv_convert () takes ownership of the buffer passed */
buf = bvw_frame_conv_convert (last_buffer, to_caps);
@@ -1688,13 +1690,15 @@ gst_camera_capturer_get_current_frame (GstCameraCapturer * gcc)
gst_buffer_unref (last_buffer);
if (!buf) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "conversion failed");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s",
+ "conversion failed");
g_warning ("Could not take screenshot: %s", "conversion failed");
return NULL;
}
if (!GST_BUFFER_CAPS (buf)) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "no caps on output buffer");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s",
+ "no caps on output buffer");
g_warning ("Could not take screenshot: %s", "no caps on output buffer");
return NULL;
}
@@ -1711,7 +1715,8 @@ gst_camera_capturer_get_current_frame (GstCameraCapturer * gcc)
outheight, GST_ROUND_UP_4 (outwidth * 3), destroy_pixbuf, buf);
if (!pixbuf) {
- GST_DEBUG_OBJECT (gcc,"Could not take screenshot: %s", "could not create pixbuf");
+ GST_DEBUG_OBJECT (gcc, "Could not take screenshot: %s",
+ "could not create pixbuf");
g_warning ("Could not take screenshot: %s", "could not create pixbuf");
}
diff --git a/libcesarplayer/src/gst-camera-capturer.h b/libcesarplayer/src/gst-camera-capturer.h
index 49412fd..e781478 100644
--- a/libcesarplayer/src/gst-camera-capturer.h
+++ b/libcesarplayer/src/gst-camera-capturer.h
@@ -68,35 +68,34 @@ typedef enum
GST_CAMERA_CAPTURE_SOURCE_TYPE_NONE = 0,
GST_CAMERA_CAPTURE_SOURCE_TYPE_DV = 1,
GST_CAMERA_CAPTURE_SOURCE_TYPE_RAW = 2
-}GstCameraCaptureSourceType;
+} GstCameraCaptureSourceType;
-EXPORT GType gst_camera_capturer_get_type (void) G_GNUC_CONST;
+EXPORT GType
+gst_camera_capturer_get_type (void)
+ G_GNUC_CONST;
-EXPORT void gst_camera_capturer_init_backend (int *argc, char ***argv);
-EXPORT GstCameraCapturer *gst_camera_capturer_new (gchar * filename,
- GError ** err);
-EXPORT void gst_camera_capturer_run (GstCameraCapturer * gcc);
-EXPORT void gst_camera_capturer_close (GstCameraCapturer * gcc);
-EXPORT void gst_camera_capturer_start (GstCameraCapturer * gcc);
-EXPORT void gst_camera_capturer_toggle_pause (GstCameraCapturer * gcc);
-EXPORT void gst_camera_capturer_stop (GstCameraCapturer * gcc);
-EXPORT gboolean gst_camera_capturer_set_video_encoder (GstCameraCapturer * gcc,
- VideoEncoderType type,
- GError ** err);
-EXPORT gboolean gst_camera_capturer_set_audio_encoder (GstCameraCapturer * gcc,
- AudioEncoderType type,
- GError ** err);
-EXPORT gboolean gst_camera_capturer_set_video_muxer (GstCameraCapturer * gcc,
- VideoMuxerType type,
- GError ** err);
-EXPORT gboolean gst_camera_capturer_set_source (GstCameraCapturer * gcc,
- GstCameraCaptureSourceType type,
- GError ** err);
-EXPORT GList* gst_camera_capturer_enum_audio_devices (void);
-EXPORT GList* gst_camera_capturer_enum_video_devices (void);
-EXPORT GdkPixbuf* gst_camera_capturer_get_current_frame(GstCameraCapturer *gcc);
-EXPORT void gst_camera_capture_unref_pixbuf (GdkPixbuf * pixbuf);
-EXPORT void gst_camera_capturer_finalize (GObject * object);
+ EXPORT void gst_camera_capturer_init_backend (int *argc, char ***argv);
+ EXPORT GstCameraCapturer *gst_camera_capturer_new (gchar * filename,
+ GError ** err);
+ EXPORT void gst_camera_capturer_run (GstCameraCapturer * gcc);
+ EXPORT void gst_camera_capturer_close (GstCameraCapturer * gcc);
+ EXPORT void gst_camera_capturer_start (GstCameraCapturer * gcc);
+ EXPORT void gst_camera_capturer_toggle_pause (GstCameraCapturer * gcc);
+ EXPORT void gst_camera_capturer_stop (GstCameraCapturer * gcc);
+ EXPORT gboolean gst_camera_capturer_set_video_encoder (GstCameraCapturer *
+ gcc, VideoEncoderType type, GError ** err);
+ EXPORT gboolean gst_camera_capturer_set_audio_encoder (GstCameraCapturer *
+ gcc, AudioEncoderType type, GError ** err);
+ EXPORT gboolean gst_camera_capturer_set_video_muxer (GstCameraCapturer *
+ gcc, VideoMuxerType type, GError ** err);
+ EXPORT gboolean gst_camera_capturer_set_source (GstCameraCapturer * gcc,
+ GstCameraCaptureSourceType type, GError ** err);
+ EXPORT GList *gst_camera_capturer_enum_audio_devices (void);
+ EXPORT GList *gst_camera_capturer_enum_video_devices (void);
+ EXPORT GdkPixbuf *gst_camera_capturer_get_current_frame (GstCameraCapturer
+ * gcc);
+ EXPORT void gst_camera_capture_unref_pixbuf (GdkPixbuf * pixbuf);
+ EXPORT void gst_camera_capturer_finalize (GObject * object);
G_END_DECLS
#endif /* _GST_CAMERA_CAPTURER_H_ */
diff --git a/libcesarplayer/src/gst-smart-video-scaler.c b/libcesarplayer/src/gst-smart-video-scaler.c
index f5aa45e..520fcd5 100644
--- a/libcesarplayer/src/gst-smart-video-scaler.c
+++ b/libcesarplayer/src/gst-smart-video-scaler.c
@@ -50,8 +50,8 @@ gst_smart_video_scaler_init (GstSmartVideoScaler * object)
{
GstSmartVideoScalerPrivate *priv;
object->priv = priv =
- G_TYPE_INSTANCE_GET_PRIVATE (object, GST_TYPE_SMART_VIDEO_SCALER,
- GstSmartVideoScalerPrivate);
+ G_TYPE_INSTANCE_GET_PRIVATE (object, GST_TYPE_SMART_VIDEO_SCALER,
+ GstSmartVideoScalerPrivate);
priv->parin = g_new0 (GValue, 1);
g_value_init (priv->parin, GST_TYPE_FRACTION);
@@ -80,14 +80,13 @@ gst_smart_video_scaler_finalize (GObject * object)
{
GstSmartVideoScaler *gsvs = (GstSmartVideoScaler *) object;
- if (gsvs != NULL)
- {
- gst_element_set_state (GST_ELEMENT (gsvs), GST_STATE_NULL);
- gst_object_unref (gsvs);
- gsvs->priv->videoscale = NULL;
- gsvs->priv->videobox = NULL;
- gsvs->priv->capsfilter = NULL;
- }
+ if (gsvs != NULL) {
+ gst_element_set_state (GST_ELEMENT (gsvs), GST_STATE_NULL);
+ gst_object_unref (gsvs);
+ gsvs->priv->videoscale = NULL;
+ gsvs->priv->videobox = NULL;
+ gsvs->priv->capsfilter = NULL;
+ }
g_free (gsvs->priv->parin);
g_free (gsvs->priv->parout);
@@ -103,8 +102,7 @@ gst_smart_video_scaler_class_init (GstSmartVideoScalerClass * klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
//GstBinClass* parent_class = GST_BIN_CLASS (klass);
- g_type_class_add_private (object_class,
- sizeof (GstSmartVideoScalerPrivate));
+ g_type_class_add_private (object_class, sizeof (GstSmartVideoScalerPrivate));
object_class->finalize = gst_smart_video_scaler_finalize;
}
@@ -120,102 +118,91 @@ gsvs_compute_and_set_values (GstSmartVideoScaler * gsvs)
/*Calculate the new values to set on capsfilter and videobox. */
if (gsvs->priv->widthin == -1 || gsvs->priv->heightin == -1
- || gsvs->priv->widthout == -1 || gsvs->priv->heightout == -1)
- {
- /* FIXME : should we reset videobox/capsfilter properties here ? */
- GST_ERROR
- ("We don't have input and output caps, we can't calculate videobox values");
- return;
- }
+ || gsvs->priv->widthout == -1 || gsvs->priv->heightout == -1) {
+ /* FIXME : should we reset videobox/capsfilter properties here ? */
+ GST_ERROR
+ ("We don't have input and output caps, we can't calculate videobox values");
+ return;
+ }
fdarin =
- (gfloat) gst_value_get_fraction_numerator (gsvs->priv->darin) /
- (gfloat) gst_value_get_fraction_denominator (gsvs->priv->darin);
+ (gfloat) gst_value_get_fraction_numerator (gsvs->priv->darin) /
+ (gfloat) gst_value_get_fraction_denominator (gsvs->priv->darin);
fdarout =
- (gfloat) gst_value_get_fraction_numerator (gsvs->priv->darout) /
- (gfloat) gst_value_get_fraction_denominator (gsvs->priv->darout);
+ (gfloat) gst_value_get_fraction_numerator (gsvs->priv->darout) /
+ (gfloat) gst_value_get_fraction_denominator (gsvs->priv->darout);
fparin =
- (gfloat) gst_value_get_fraction_numerator (gsvs->priv->parin) /
- (gfloat) gst_value_get_fraction_denominator (gsvs->priv->parin);
+ (gfloat) gst_value_get_fraction_numerator (gsvs->priv->parin) /
+ (gfloat) gst_value_get_fraction_denominator (gsvs->priv->parin);
fparout =
- (gfloat) gst_value_get_fraction_numerator (gsvs->priv->parout) /
- (gfloat) gst_value_get_fraction_denominator (gsvs->priv->parout);
+ (gfloat) gst_value_get_fraction_numerator (gsvs->priv->parout) /
+ (gfloat) gst_value_get_fraction_denominator (gsvs->priv->parout);
GST_INFO ("incoming width/height/PAR/DAR : %d/%d/%f/%f",
- gsvs->priv->widthin, gsvs->priv->heightin, fparin, fdarin);
+ gsvs->priv->widthin, gsvs->priv->heightin, fparin, fdarin);
GST_INFO ("outgoing width/height/PAR/DAR : %d/%d/%f/%f",
- gsvs->priv->widthout, gsvs->priv->heightout, fparout, fdarout);
+ gsvs->priv->widthout, gsvs->priv->heightout, fparout, fdarout);
/* for core <= 0.10.22 we always set caps != any, see 574805 for the
details */
gst_version (&mayor, &minor, µ, &nano);
- if (fdarin == fdarout && (mayor >= 0 && minor >= 10 && micro >= 23))
- {
+ if (fdarin == fdarout && (mayor >= 0 && minor >= 10 && micro >= 23)) {
+ GST_INFO
+ ("We have same input and output caps, resetting capsfilter and videobox settings");
+ /* same DAR, set inputcaps on capsfilter, reset videobox values */
+ caps = gst_caps_new_any ();
+ left = 0;
+ right = 0;
+ top = 0;
+ bottom = 0;
+ } else {
+ gint par_d, par_n, dar_d, dar_n;
+ gint extra;
+ gchar scaps[200];
+
+ par_n = gst_value_get_fraction_numerator (gsvs->priv->parout);
+ par_d = gst_value_get_fraction_denominator (gsvs->priv->parout);
+ dar_n = gst_value_get_fraction_numerator (gsvs->priv->darin);
+ dar_d = gst_value_get_fraction_denominator (gsvs->priv->darin);
+
+ if (fdarin > fdarout) {
+ gint newheight;
+
GST_INFO
- ("We have same input and output caps, resetting capsfilter and videobox settings");
- /* same DAR, set inputcaps on capsfilter, reset videobox values */
- caps = gst_caps_new_any ();
- left = 0;
- right = 0;
- top = 0;
- bottom = 0;
- }
- else
- {
- gint par_d, par_n, dar_d, dar_n;
- gint extra;
- gchar scaps[200];
-
- par_n = gst_value_get_fraction_numerator (gsvs->priv->parout);
- par_d = gst_value_get_fraction_denominator (gsvs->priv->parout);
- dar_n = gst_value_get_fraction_numerator (gsvs->priv->darin);
- dar_d = gst_value_get_fraction_denominator (gsvs->priv->darin);
-
- if (fdarin > fdarout)
- {
- gint newheight;
-
- GST_INFO
- ("incoming DAR is greater that ougoing DAR. Adding top/bottom borders");
- /* width, PAR stays the same as output
- calculate newheight = (PAR * widthout) / DAR */
- newheight =
- (par_n * gsvs->priv->widthout * dar_d) / (par_d * dar_n);
- GST_INFO ("newheight should be %d", newheight);
- extra = gsvs->priv->heightout - newheight;
- top = extra / 2;
- bottom = extra - top; /* compensate for odd extra */
- left = right = 0;
- /*calculate filter caps */
- g_sprintf (astr, "width=%d,height=%d", gsvs->priv->widthout,
- newheight);
- }
- else
- {
- gint newwidth;
-
- GST_INFO
- ("incoming DAR is smaller than outgoing DAR. Adding left/right borders");
- /* height, PAR stays the same as output
- calculate newwidth = (DAR * heightout) / PAR */
- newwidth =
- (dar_n * gsvs->priv->heightout * par_n) / (dar_d * par_n);
- GST_INFO ("newwidth should be %d", newwidth);
- extra = gsvs->priv->widthout - newwidth;
- left = extra / 2;
- right = extra - left; /* compensate for odd extra */
- top = bottom = 0;
- /* calculate filter caps */
- g_sprintf (astr, "width=%d,height=%d", newwidth,
- gsvs->priv->heightout);
- }
- g_sprintf (scaps, "video/x-raw-yuv,%s;video/x-raw-rgb,%s", astr, astr);
- caps = gst_caps_from_string (scaps);
+ ("incoming DAR is greater that ougoing DAR. Adding top/bottom borders");
+ /* width, PAR stays the same as output
+ calculate newheight = (PAR * widthout) / DAR */
+ newheight = (par_n * gsvs->priv->widthout * dar_d) / (par_d * dar_n);
+ GST_INFO ("newheight should be %d", newheight);
+ extra = gsvs->priv->heightout - newheight;
+ top = extra / 2;
+ bottom = extra - top; /* compensate for odd extra */
+ left = right = 0;
+ /*calculate filter caps */
+ g_sprintf (astr, "width=%d,height=%d", gsvs->priv->widthout, newheight);
+ } else {
+ gint newwidth;
+
+ GST_INFO
+ ("incoming DAR is smaller than outgoing DAR. Adding left/right borders");
+ /* height, PAR stays the same as output
+ calculate newwidth = (DAR * heightout) / PAR */
+ newwidth = (dar_n * gsvs->priv->heightout * par_n) / (dar_d * par_n);
+ GST_INFO ("newwidth should be %d", newwidth);
+ extra = gsvs->priv->widthout - newwidth;
+ left = extra / 2;
+ right = extra - left; /* compensate for odd extra */
+ top = bottom = 0;
+ /* calculate filter caps */
+ g_sprintf (astr, "width=%d,height=%d", newwidth, gsvs->priv->heightout);
}
+ g_sprintf (scaps, "video/x-raw-yuv,%s;video/x-raw-rgb,%s", astr, astr);
+ caps = gst_caps_from_string (scaps);
+ }
/* set properties on elements */
GST_INFO ("About to set left/right/top/bottom : %d/%d/%d/%d", -left, -right,
- -top, -bottom);
+ -top, -bottom);
g_object_set (G_OBJECT (gsvs->priv->videobox), "left", -left, NULL);
g_object_set (G_OBJECT (gsvs->priv->videobox), "right", -right, NULL);
g_object_set (G_OBJECT (gsvs->priv->videobox), "top", -top, NULL);
@@ -227,7 +214,7 @@ gsvs_compute_and_set_values (GstSmartVideoScaler * gsvs)
static void
gsvs_get_value_from_caps (GstCaps * caps, gboolean force, gint * width,
- gint * height, GValue ** par, GValue ** dar)
+ gint * height, GValue ** par, GValue ** dar)
{
GstStructure *str = NULL;
const GValue *tmp_par = NULL;
@@ -238,32 +225,29 @@ gsvs_get_value_from_caps (GstCaps * caps, gboolean force, gint * width,
gst_value_set_fraction (*par, 1, 1);
gst_value_set_fraction (*dar, 1, 1);
- if (force || (caps && gst_caps_is_fixed (caps)))
- {
- str = gst_caps_get_structure (caps, 0);
- gst_structure_get_int (str, "width", &(*width));
- gst_structure_get_int (str, "height", &(*height));
-
- if (g_strrstr (gst_structure_get_name (str), "pixel-aspect-ratio"))
- {
- tmp_par = gst_structure_get_value (str, "pixel-aspect-ratio");
- gst_value_set_fraction (*par,
- gst_value_get_fraction_numerator (tmp_par),
- gst_value_get_fraction_denominator
- (tmp_par));
- }
- num = gst_value_get_fraction_numerator (*par);
- denom = gst_value_get_fraction_denominator (*par);
- gst_value_set_fraction (*dar, *width * num, *height * denom);
+ if (force || (caps && gst_caps_is_fixed (caps))) {
+ str = gst_caps_get_structure (caps, 0);
+ gst_structure_get_int (str, "width", &(*width));
+ gst_structure_get_int (str, "height", &(*height));
+
+ if (g_strrstr (gst_structure_get_name (str), "pixel-aspect-ratio")) {
+ tmp_par = gst_structure_get_value (str, "pixel-aspect-ratio");
+ gst_value_set_fraction (*par,
+ gst_value_get_fraction_numerator (tmp_par),
+ gst_value_get_fraction_denominator (tmp_par));
}
+ num = gst_value_get_fraction_numerator (*par);
+ denom = gst_value_get_fraction_denominator (*par);
+ gst_value_set_fraction (*dar, *width * num, *height * denom);
+ }
}
static gboolean
gsvs_sink_set_caps (GstPad * pad, GstCaps * caps)
{
GstSmartVideoScaler *gsvs =
- GST_SMART_VIDEO_SCALER (gst_element_get_parent
- (gst_pad_get_parent (pad)));
+ GST_SMART_VIDEO_SCALER (gst_element_get_parent
+ (gst_pad_get_parent (pad)));
GstPad *videoscale_pad = NULL;
videoscale_pad = gst_element_get_static_pad (GST_ELEMENT (gsvs), "sink");
@@ -272,8 +256,7 @@ gsvs_sink_set_caps (GstPad * pad, GstCaps * caps)
return FALSE;
gsvs_get_value_from_caps (caps, FALSE, &gsvs->priv->widthin,
- &gsvs->priv->heightin, &gsvs->priv->parin,
- &gsvs->priv->darin);
+ &gsvs->priv->heightin, &gsvs->priv->parin, &gsvs->priv->darin);
gsvs_compute_and_set_values (gsvs);
return TRUE;
@@ -285,8 +268,7 @@ gst_smart_video_scaler_set_caps (GstSmartVideoScaler * gsvs, GstCaps * caps)
g_return_if_fail (GST_IS_SMART_VIDEO_SCALER (gsvs));
gsvs_get_value_from_caps (caps, FALSE, &gsvs->priv->widthout,
- &gsvs->priv->heightout, &gsvs->priv->parout,
- &gsvs->priv->darout);
+ &gsvs->priv->heightout, &gsvs->priv->parout, &gsvs->priv->darout);
}
@@ -301,30 +283,29 @@ gst_smart_video_scaler_new ()
/*Create bin elements */
gsvs->priv->videoscale =
- gst_element_factory_make ("videoscale", "smart-videoscale");
+ gst_element_factory_make ("videoscale", "smart-videoscale");
g_object_set (G_OBJECT (gsvs->priv->videoscale), "method", 1, NULL);
gsvs->priv->capsfilter =
- gst_element_factory_make ("capsfilter", "smart-capsfilter");
+ gst_element_factory_make ("capsfilter", "smart-capsfilter");
gsvs->priv->videobox =
- gst_element_factory_make ("videobox", "smart-videobox");
+ gst_element_factory_make ("videobox", "smart-videobox");
/*Add and link elements */
gst_bin_add_many (GST_BIN (gsvs), gsvs->priv->videoscale,
- gsvs->priv->capsfilter, gsvs->priv->videobox, NULL);
+ gsvs->priv->capsfilter, gsvs->priv->videobox, NULL);
gst_element_link_many (gsvs->priv->videoscale, gsvs->priv->capsfilter,
- gsvs->priv->videobox, NULL);
+ gsvs->priv->videobox, NULL);
/*Create bin sink pad */
sink_pad = gst_element_get_static_pad (gsvs->priv->videoscale, "sink");
gst_pad_set_active (sink_pad, TRUE);
gst_element_add_pad (GST_ELEMENT (gsvs),
- gst_ghost_pad_new ("sink", sink_pad));
+ gst_ghost_pad_new ("sink", sink_pad));
/*Creat bin src pad */
src_pad = gst_element_get_static_pad (gsvs->priv->videobox, "src");
gst_pad_set_active (src_pad, TRUE);
- gst_element_add_pad (GST_ELEMENT (gsvs),
- gst_ghost_pad_new ("src", src_pad));
+ gst_element_add_pad (GST_ELEMENT (gsvs), gst_ghost_pad_new ("src", src_pad));
gst_pad_set_setcaps_function (sink_pad, gsvs_sink_set_caps);
diff --git a/libcesarplayer/src/gst-smart-video-scaler.h b/libcesarplayer/src/gst-smart-video-scaler.h
index fbe1183..58325d5 100644
--- a/libcesarplayer/src/gst-smart-video-scaler.h
+++ b/libcesarplayer/src/gst-smart-video-scaler.h
@@ -54,10 +54,10 @@ struct _GstSmartVideoScaler
EXPORT GType
gst_smart_video_scaler_get_type (void)
- G_GNUC_CONST;
+ G_GNUC_CONST;
EXPORT GstSmartVideoScaler *gst_smart_video_scaler_new ();
EXPORT void gst_smart_video_scaler_set_caps (GstSmartVideoScaler * gsvs,
- GstCaps * caps);
+ GstCaps * caps);
G_END_DECLS
#endif /* _GST_SMART_VIDEO_SCALER_H_ */
diff --git a/libcesarplayer/src/gst-video-editor.c b/libcesarplayer/src/gst-video-editor.c
index 2492592..7af9edb 100644
--- a/libcesarplayer/src/gst-video-editor.c
+++ b/libcesarplayer/src/gst-video-editor.c
@@ -123,16 +123,13 @@ static int gve_signals[LAST_SIGNAL] = { 0 };
static void gve_error_msg (GstVideoEditor * gve, GstMessage * msg);
static void new_decoded_pad_cb (GstElement * object, GstPad * arg0,
- gpointer user_data);
+ gpointer user_data);
static void gve_bus_message_cb (GstBus * bus, GstMessage * message,
- gpointer data);
+ gpointer data);
static void gst_video_editor_get_property (GObject * object,
- guint property_id, GValue * value,
- GParamSpec * pspec);
+ guint property_id, GValue * value, GParamSpec * pspec);
static void gst_video_editor_set_property (GObject * object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec);
+ guint property_id, const GValue * value, GParamSpec * pspec);
static gboolean gve_query_timeout (GstVideoEditor * gve);
static void gve_apply_new_caps (GstVideoEditor * gve);
static void gve_rewrite_headers (GstVideoEditor * gve);
@@ -151,8 +148,8 @@ gst_video_editor_init (GstVideoEditor * object)
{
GstVideoEditorPrivate *priv;
object->priv = priv =
- G_TYPE_INSTANCE_GET_PRIVATE (object, GST_TYPE_VIDEO_EDITOR,
- GstVideoEditorPrivate);
+ G_TYPE_INSTANCE_GET_PRIVATE (object, GST_TYPE_VIDEO_EDITOR,
+ GstVideoEditorPrivate);
priv->output_file = "new_video.avi";
@@ -179,26 +176,23 @@ gst_video_editor_finalize (GObject * object)
{
GstVideoEditor *gve = (GstVideoEditor *) object;
- if (gve->priv->bus)
- {
- /* make bus drop all messages to make sure none of our callbacks is ever
- called again (main loop might be run again to display error dialog) */
- gst_bus_set_flushing (gve->priv->bus, TRUE);
-
- if (gve->priv->sig_bus_async)
- g_signal_handler_disconnect (gve->priv->bus,
- gve->priv->sig_bus_async);
- gst_object_unref (gve->priv->bus);
- gve->priv->bus = NULL;
- }
+ if (gve->priv->bus) {
+ /* make bus drop all messages to make sure none of our callbacks is ever
+ called again (main loop might be run again to display error dialog) */
+ gst_bus_set_flushing (gve->priv->bus, TRUE);
+
+ if (gve->priv->sig_bus_async)
+ g_signal_handler_disconnect (gve->priv->bus, gve->priv->sig_bus_async);
+ gst_object_unref (gve->priv->bus);
+ gve->priv->bus = NULL;
+ }
if (gve->priv->main_pipeline != NULL
- && GST_IS_ELEMENT (gve->priv->main_pipeline))
- {
- gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL);
- gst_object_unref (gve->priv->main_pipeline);
- gve->priv->main_pipeline = NULL;
- }
+ && GST_IS_ELEMENT (gve->priv->main_pipeline)) {
+ gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL);
+ gst_object_unref (gve->priv->main_pipeline);
+ gve->priv->main_pipeline = NULL;
+ }
g_free (gve->priv->output_file);
g_list_free (gve->priv->gnl_video_filesources);
@@ -227,58 +221,45 @@ gst_video_editor_class_init (GstVideoEditorClass * klass)
/* Properties */
g_object_class_install_property (object_class, PROP_ENABLE_AUDIO,
- g_param_spec_boolean ("enable-audio", NULL,
- NULL, TRUE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("enable-audio", NULL,
+ NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ENABLE_TITLE,
- g_param_spec_boolean ("enable-title", NULL,
- NULL, TRUE,
- G_PARAM_READWRITE));
+ g_param_spec_boolean ("enable-title", NULL,
+ NULL, TRUE, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_VIDEO_BITRATE,
- g_param_spec_int ("video_bitrate", NULL,
- NULL, 100, G_MAXINT,
- 10000,
- G_PARAM_READWRITE));
+ g_param_spec_int ("video_bitrate", NULL,
+ NULL, 100, G_MAXINT, 10000, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_AUDIO_BITRATE,
- g_param_spec_int ("audio_bitrate", NULL,
- NULL, 12000, G_MAXINT,
- 128000,
- G_PARAM_READWRITE));
+ g_param_spec_int ("audio_bitrate", NULL,
+ NULL, 12000, G_MAXINT, 128000, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_HEIGHT,
- g_param_spec_int ("height", NULL, NULL,
- 240, 1080, 480,
- G_PARAM_READWRITE));
+ g_param_spec_int ("height", NULL, NULL,
+ 240, 1080, 480, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_WIDTH,
- g_param_spec_int ("width", NULL, NULL, 320,
- 1920, 720,
- G_PARAM_READWRITE));
+ g_param_spec_int ("width", NULL, NULL, 320,
+ 1920, 720, G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_OUTPUT_FILE,
- g_param_spec_string ("output_file", NULL,
- NULL, "",
- G_PARAM_READWRITE));
+ g_param_spec_string ("output_file", NULL, NULL, "", G_PARAM_READWRITE));
/* Signals */
gve_signals[SIGNAL_ERROR] =
- g_signal_new ("error",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstVideoEditorClass, error),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ g_signal_new ("error",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstVideoEditorClass, error),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
gve_signals[SIGNAL_PERCENT_COMPLETED] =
- g_signal_new ("percent_completed",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GstVideoEditorClass, percent_completed),
- NULL, NULL,
- g_cclosure_marshal_VOID__FLOAT,
- G_TYPE_NONE, 1, G_TYPE_FLOAT);
+ g_signal_new ("percent_completed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (GstVideoEditorClass, percent_completed),
+ NULL, NULL, g_cclosure_marshal_VOID__FLOAT, G_TYPE_NONE, 1, G_TYPE_FLOAT);
}
@@ -289,59 +270,49 @@ gst_video_editor_class_init (GstVideoEditorClass * klass)
/* =========================================== */
static void
-gst_video_editor_set_enable_audio (GstVideoEditor * gve,
- gboolean audio_enabled)
+gst_video_editor_set_enable_audio (GstVideoEditor * gve, gboolean audio_enabled)
{
GstState cur_state;
gst_element_get_state (gve->priv->main_pipeline, &cur_state, NULL, 0);
- if (cur_state > GST_STATE_READY)
- {
- GST_WARNING ("Could not enable/disable audio. Pipeline is playing");
- return;
- }
-
- if (!gve->priv->audio_enabled && audio_enabled)
- {
- /* Audio needs to be enabled and is disabled */
- gst_bin_add_many (GST_BIN (gve->priv->main_pipeline),
- gve->priv->gnl_audio_composition,
- gve->priv->aencode_bin, NULL);
- gst_element_link (gve->priv->aencode_bin, gve->priv->muxer);
- gst_element_set_state (gve->priv->gnl_audio_composition, cur_state);
- gst_element_set_state (gve->priv->aencode_bin, cur_state);
- gve_rewrite_headers (gve);
- gve->priv->audio_enabled = TRUE;
- GST_INFO ("Audio enabled");
- }
- else if (gve->priv->audio_enabled && !audio_enabled)
- {
- /* Audio is enabled and needs to be disabled) */
- gst_element_unlink_many (gve->priv->gnl_audio_composition,
- gve->priv->aencode_bin, gve->priv->muxer,
- NULL);
- gst_element_set_state (gve->priv->gnl_audio_composition,
- GST_STATE_NULL);
- gst_element_set_state (gve->priv->aencode_bin, GST_STATE_NULL);
- gst_object_ref (gve->priv->gnl_audio_composition);
- gst_object_ref (gve->priv->aencode_bin);
- gst_bin_remove_many (GST_BIN (gve->priv->main_pipeline),
- gve->priv->gnl_audio_composition,
- gve->priv->aencode_bin, NULL);
- gve_rewrite_headers (gve);
- gve->priv->audio_enabled = FALSE;
- GST_INFO ("Audio disabled");
- }
+ if (cur_state > GST_STATE_READY) {
+ GST_WARNING ("Could not enable/disable audio. Pipeline is playing");
+ return;
+ }
+
+ if (!gve->priv->audio_enabled && audio_enabled) {
+ /* Audio needs to be enabled and is disabled */
+ gst_bin_add_many (GST_BIN (gve->priv->main_pipeline),
+ gve->priv->gnl_audio_composition, gve->priv->aencode_bin, NULL);
+ gst_element_link (gve->priv->aencode_bin, gve->priv->muxer);
+ gst_element_set_state (gve->priv->gnl_audio_composition, cur_state);
+ gst_element_set_state (gve->priv->aencode_bin, cur_state);
+ gve_rewrite_headers (gve);
+ gve->priv->audio_enabled = TRUE;
+ GST_INFO ("Audio enabled");
+ } else if (gve->priv->audio_enabled && !audio_enabled) {
+ /* Audio is enabled and needs to be disabled) */
+ gst_element_unlink_many (gve->priv->gnl_audio_composition,
+ gve->priv->aencode_bin, gve->priv->muxer, NULL);
+ gst_element_set_state (gve->priv->gnl_audio_composition, GST_STATE_NULL);
+ gst_element_set_state (gve->priv->aencode_bin, GST_STATE_NULL);
+ gst_object_ref (gve->priv->gnl_audio_composition);
+ gst_object_ref (gve->priv->aencode_bin);
+ gst_bin_remove_many (GST_BIN (gve->priv->main_pipeline),
+ gve->priv->gnl_audio_composition, gve->priv->aencode_bin, NULL);
+ gve_rewrite_headers (gve);
+ gve->priv->audio_enabled = FALSE;
+ GST_INFO ("Audio disabled");
+ }
}
static void
-gst_video_editor_set_enable_title (GstVideoEditor * gve,
- gboolean title_enabled)
+gst_video_editor_set_enable_title (GstVideoEditor * gve, gboolean title_enabled)
{
gve->priv->title_enabled = title_enabled;
g_object_set (G_OBJECT (gve->priv->textoverlay), "silent",
- !gve->priv->title_enabled, NULL);
+ !gve->priv->title_enabled, NULL);
}
@@ -352,11 +323,10 @@ gst_video_editor_set_video_bit_rate (GstVideoEditor * gve, gint bitrate)
gve->priv->video_bitrate = bitrate;
gst_element_get_state (gve->priv->video_encoder, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- g_object_set (gve->priv->video_encoder, "bitrate", bitrate, NULL);
- GST_INFO ("Encoding video bitrate changed to :%d (kbps)\n", bitrate);
- }
+ if (cur_state <= GST_STATE_READY) {
+ g_object_set (gve->priv->video_encoder, "bitrate", bitrate, NULL);
+ GST_INFO ("Encoding video bitrate changed to :%d (kbps)\n", bitrate);
+ }
}
static void
@@ -366,11 +336,10 @@ gst_video_editor_set_audio_bit_rate (GstVideoEditor * gve, gint bitrate)
gve->priv->audio_bitrate = bitrate;
gst_element_get_state (gve->priv->audioencoder, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- g_object_set (gve->priv->audioencoder, "bitrate", bitrate, NULL);
- GST_INFO ("Encoding audio bitrate changed to :%d (bps)\n", bitrate);
- }
+ if (cur_state <= GST_STATE_READY) {
+ g_object_set (gve->priv->audioencoder, "bitrate", bitrate, NULL);
+ GST_INFO ("Encoding audio bitrate changed to :%d (bps)\n", bitrate);
+ }
}
static void
@@ -388,32 +357,29 @@ gst_video_editor_set_height (GstVideoEditor * gve, gint height)
}
static void
-gst_video_editor_set_output_file (GstVideoEditor * gve,
- const char *output_file)
+gst_video_editor_set_output_file (GstVideoEditor * gve, const char *output_file)
{
GstState cur_state;
gve->priv->output_file = g_strdup (output_file);
gst_element_get_state (gve->priv->file_sink, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- gst_element_set_state (gve->priv->file_sink, GST_STATE_NULL);
- g_object_set (gve->priv->file_sink, "location", gve->priv->output_file,
- NULL);
- GST_INFO ("Ouput File changed to :%s\n", gve->priv->output_file);
- }
+ if (cur_state <= GST_STATE_READY) {
+ gst_element_set_state (gve->priv->file_sink, GST_STATE_NULL);
+ g_object_set (gve->priv->file_sink, "location", gve->priv->output_file,
+ NULL);
+ GST_INFO ("Ouput File changed to :%s\n", gve->priv->output_file);
+ }
}
static void
gst_video_editor_set_property (GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
GstVideoEditor *gve;
gve = GST_VIDEO_EDITOR (object);
- switch (property_id)
- {
+ switch (property_id) {
case PROP_ENABLE_AUDIO:
gst_video_editor_set_enable_audio (gve, g_value_get_boolean (value));
break;
@@ -438,19 +404,18 @@ gst_video_editor_set_property (GObject * object, guint property_id,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
- }
+ }
}
static void
gst_video_editor_get_property (GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
GstVideoEditor *gve;
gve = GST_VIDEO_EDITOR (object);
- switch (property_id)
- {
+ switch (property_id) {
case PROP_ENABLE_AUDIO:
g_value_set_boolean (value, gve->priv->audio_enabled);
break;
@@ -475,7 +440,7 @@ gst_video_editor_get_property (GObject * object, guint property_id,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
- }
+ }
}
/* =========================================== */
@@ -498,12 +463,11 @@ gve_set_tick_timeout (GstVideoEditor * gve, guint msecs)
{
g_return_if_fail (GST_IS_VIDEO_EDITOR (gve));
- if (msecs > 0)
- {
- GST_INFO ("adding tick timeout (at %ums)", msecs);
- gve->priv->update_id =
- g_timeout_add (msecs, (GSourceFunc) gve_query_timeout, gve);
- }
+ if (msecs > 0) {
+ GST_INFO ("adding tick timeout (at %ums)", msecs);
+ gve->priv->update_id =
+ g_timeout_add (msecs, (GSourceFunc) gve_query_timeout, gve);
+ }
}
static void
@@ -513,14 +477,14 @@ gve_apply_new_caps (GstVideoEditor * gve)
gchar *font;
caps = gst_caps_new_simple ("video/x-raw-yuv",
- "width", G_TYPE_INT, gve->priv->width,
- "height", G_TYPE_INT, gve->priv->height,
- "framerate", GST_TYPE_FRACTION, 25, 1, NULL);
+ "width", G_TYPE_INT, gve->priv->width,
+ "height", G_TYPE_INT, gve->priv->height,
+ "framerate", GST_TYPE_FRACTION, 25, 1, NULL);
g_object_set (G_OBJECT (gve->priv->capsfilter), "caps", caps, NULL);
font =
- g_strdup_printf ("sans bold %d",
- (int) (gve->priv->width * FONT_SIZE_FACTOR));
+ g_strdup_printf ("sans bold %d",
+ (int) (gve->priv->width * FONT_SIZE_FACTOR));
g_object_set (G_OBJECT (gve->priv->textoverlay), "font-desc", font, NULL);
g_free (font);
gst_caps_unref (caps);
@@ -538,56 +502,52 @@ gve_create_video_encode_bin (GstVideoEditor * gve)
gve->priv->vencode_bin = gst_element_factory_make ("bin", "vencodebin");
gve->priv->identity = gst_element_factory_make ("identity", "identity");
gve->priv->ffmpegcolorspace =
- gst_element_factory_make ("ffmpegcolorspace", "ffmpegcolorspace");
+ gst_element_factory_make ("ffmpegcolorspace", "ffmpegcolorspace");
gve->priv->videorate = gst_element_factory_make ("videorate", "videorate");
- gve->priv->videoscale =
- gst_element_factory_make ("videoscale", "videoscale");
- gve->priv->capsfilter =
- gst_element_factory_make ("capsfilter", "capsfilter");
+ gve->priv->videoscale = gst_element_factory_make ("videoscale", "videoscale");
+ gve->priv->capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
gve->priv->videobox = gst_element_factory_make ("videobox", "videobox");
gve->priv->textoverlay =
- gst_element_factory_make ("textoverlay", "textoverlay");
+ gst_element_factory_make ("textoverlay", "textoverlay");
gve->priv->queue = gst_element_factory_make ("queue", "video-encode-queue");
gve->priv->video_encoder =
- gst_element_factory_make (DEFAULT_VIDEO_ENCODER, "video-encoder");
+ gst_element_factory_make (DEFAULT_VIDEO_ENCODER, "video-encoder");
g_object_set (G_OBJECT (gve->priv->identity), "single-segment", TRUE, NULL);
g_object_set (G_OBJECT (gve->priv->textoverlay), "font-desc",
- "sans bold 20", "shaded-background", TRUE, "valignment", 2,
- "halignment", 2, NULL);
+ "sans bold 20", "shaded-background", TRUE, "valignment", 2,
+ "halignment", 2, NULL);
g_object_set (G_OBJECT (gve->priv->video_encoder), "bitrate",
- gve->priv->video_bitrate, NULL);
+ gve->priv->video_bitrate, NULL);
/*Add and link elements */
gst_bin_add_many (GST_BIN (gve->priv->vencode_bin),
- gve->priv->identity,
- gve->priv->ffmpegcolorspace,
- gve->priv->videorate,
- gve->priv->videoscale,
- gve->priv->capsfilter,
- gve->priv->videobox,
- gve->priv->textoverlay,
- gve->priv->queue, gve->priv->video_encoder, NULL);
+ gve->priv->identity,
+ gve->priv->ffmpegcolorspace,
+ gve->priv->videorate,
+ gve->priv->videoscale,
+ gve->priv->capsfilter,
+ gve->priv->videobox,
+ gve->priv->textoverlay, gve->priv->queue, gve->priv->video_encoder, NULL);
gst_element_link_many (gve->priv->identity,
- gve->priv->ffmpegcolorspace,
- gve->priv->videorate,
- gve->priv->videoscale,
- gve->priv->capsfilter,
- gve->priv->videobox,
- gve->priv->textoverlay,
- gve->priv->queue, gve->priv->video_encoder, NULL);
+ gve->priv->ffmpegcolorspace,
+ gve->priv->videorate,
+ gve->priv->videoscale,
+ gve->priv->capsfilter,
+ gve->priv->videobox,
+ gve->priv->textoverlay, gve->priv->queue, gve->priv->video_encoder, NULL);
/*Create bin sink pad */
sinkpad = gst_element_get_static_pad (gve->priv->identity, "sink");
gst_pad_set_active (sinkpad, TRUE);
gst_element_add_pad (GST_ELEMENT (gve->priv->vencode_bin),
- gst_ghost_pad_new ("sink", sinkpad));
+ gst_ghost_pad_new ("sink", sinkpad));
/*Creat bin src pad */
srcpad = gst_element_get_static_pad (gve->priv->video_encoder, "src");
gst_pad_set_active (srcpad, TRUE);
gst_element_add_pad (GST_ELEMENT (gve->priv->vencode_bin),
- gst_ghost_pad_new ("src", srcpad));
+ gst_ghost_pad_new ("src", srcpad));
g_object_unref (srcpad);
g_object_unref (sinkpad);
@@ -604,51 +564,50 @@ gve_create_audio_encode_bin (GstVideoEditor * gve)
gve->priv->aencode_bin = gst_element_factory_make ("bin", "aencodebin");
gve->priv->audioidentity =
- gst_element_factory_make ("identity", "audio-identity");
+ gst_element_factory_make ("identity", "audio-identity");
gve->priv->audioconvert =
- gst_element_factory_make ("audioconvert", "audioconvert");
+ gst_element_factory_make ("audioconvert", "audioconvert");
gve->priv->audioresample =
- gst_element_factory_make ("audioresample", "audioresample");
+ gst_element_factory_make ("audioresample", "audioresample");
gve->priv->audiocapsfilter =
- gst_element_factory_make ("capsfilter", "audiocapsfilter");
+ gst_element_factory_make ("capsfilter", "audiocapsfilter");
gve->priv->audioqueue = gst_element_factory_make ("queue", "audio-queue");
gve->priv->audioencoder =
- gst_element_factory_make (DEFAULT_AUDIO_ENCODER, "audio-encoder");
+ gst_element_factory_make (DEFAULT_AUDIO_ENCODER, "audio-encoder");
g_object_set (G_OBJECT (gve->priv->audioidentity), "single-segment", TRUE,
- NULL);
+ NULL);
g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
- gst_caps_from_string (VORBIS_CAPS), NULL);
+ gst_caps_from_string (VORBIS_CAPS), NULL);
g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
- gve->priv->audio_bitrate, NULL);
+ gve->priv->audio_bitrate, NULL);
/*Add and link elements */
gst_bin_add_many (GST_BIN (gve->priv->aencode_bin),
- gve->priv->audioidentity,
- gve->priv->audioconvert,
- gve->priv->audioresample,
- gve->priv->audiocapsfilter,
- gve->priv->audioqueue, gve->priv->audioencoder, NULL);
+ gve->priv->audioidentity,
+ gve->priv->audioconvert,
+ gve->priv->audioresample,
+ gve->priv->audiocapsfilter,
+ gve->priv->audioqueue, gve->priv->audioencoder, NULL);
gst_element_link_many (gve->priv->audioidentity,
- gve->priv->audioconvert,
- gve->priv->audioresample,
- gve->priv->audiocapsfilter,
- gve->priv->audioqueue,
- gve->priv->audioencoder, NULL);
+ gve->priv->audioconvert,
+ gve->priv->audioresample,
+ gve->priv->audiocapsfilter,
+ gve->priv->audioqueue, gve->priv->audioencoder, NULL);
/*Create bin sink pad */
sinkpad = gst_element_get_static_pad (gve->priv->audioidentity, "sink");
gst_pad_set_active (sinkpad, TRUE);
gst_element_add_pad (GST_ELEMENT (gve->priv->aencode_bin),
- gst_ghost_pad_new ("sink", sinkpad));
+ gst_ghost_pad_new ("sink", sinkpad));
/*Creat bin src pad */
srcpad = gst_element_get_static_pad (gve->priv->audioencoder, "src");
gst_pad_set_active (srcpad, TRUE);
gst_element_add_pad (GST_ELEMENT (gve->priv->aencode_bin),
- gst_ghost_pad_new ("src", srcpad));
+ gst_ghost_pad_new ("src", srcpad));
g_object_unref (srcpad);
g_object_unref (sinkpad);
@@ -657,12 +616,11 @@ gve_create_audio_encode_bin (GstVideoEditor * gve)
GQuark
gst_video_editor_error_quark (void)
{
- static GQuark q; /* 0 */
+ static GQuark q; /* 0 */
- if (G_UNLIKELY (q == 0))
- {
- q = g_quark_from_static_string ("gve-error-quark");
- }
+ if (G_UNLIKELY (q == 0)) {
+ q = g_quark_from_static_string ("gve-error-quark");
+ }
return q;
}
@@ -690,41 +648,37 @@ new_decoded_pad_cb (GstElement * object, GstPad * pad, gpointer user_data)
caps = gst_pad_get_caps (pad);
str = gst_caps_get_structure (caps, 0);
- if (g_strrstr (gst_structure_get_name (str), "video"))
- {
- gst_element_set_state (gve->priv->vencode_bin, GST_STATE_PLAYING);
- videopad =
- gst_element_get_compatible_pad (gve->priv->vencode_bin, pad, NULL);
- /* only link once */
- if (GST_PAD_IS_LINKED (videopad))
- {
- g_object_unref (videopad);
- gst_caps_unref (caps);
- return;
- }
- /* link 'n play */
- GST_INFO ("Found video stream...%" GST_PTR_FORMAT, caps);
- gst_pad_link (pad, videopad);
+ if (g_strrstr (gst_structure_get_name (str), "video")) {
+ gst_element_set_state (gve->priv->vencode_bin, GST_STATE_PLAYING);
+ videopad =
+ gst_element_get_compatible_pad (gve->priv->vencode_bin, pad, NULL);
+ /* only link once */
+ if (GST_PAD_IS_LINKED (videopad)) {
g_object_unref (videopad);
+ gst_caps_unref (caps);
+ return;
}
-
- else if (g_strrstr (gst_structure_get_name (str), "audio"))
- {
- gst_element_set_state (gve->priv->aencode_bin, GST_STATE_PLAYING);
- audiopad =
- gst_element_get_compatible_pad (gve->priv->aencode_bin, pad, NULL);
- /* only link once */
- if (GST_PAD_IS_LINKED (audiopad))
- {
- g_object_unref (audiopad);
- gst_caps_unref (caps);
- return;
- }
- /* link 'n play */
- GST_INFO ("Found audio stream...%" GST_PTR_FORMAT, caps);
- gst_pad_link (pad, audiopad);
+ /* link 'n play */
+ GST_INFO ("Found video stream...%" GST_PTR_FORMAT, caps);
+ gst_pad_link (pad, videopad);
+ g_object_unref (videopad);
+ }
+
+ else if (g_strrstr (gst_structure_get_name (str), "audio")) {
+ gst_element_set_state (gve->priv->aencode_bin, GST_STATE_PLAYING);
+ audiopad =
+ gst_element_get_compatible_pad (gve->priv->aencode_bin, pad, NULL);
+ /* only link once */
+ if (GST_PAD_IS_LINKED (audiopad)) {
g_object_unref (audiopad);
+ gst_caps_unref (caps);
+ return;
}
+ /* link 'n play */
+ GST_INFO ("Found audio stream...%" GST_PTR_FORMAT, caps);
+ gst_pad_link (pad, audiopad);
+ g_object_unref (audiopad);
+ }
gst_caps_unref (caps);
}
@@ -740,61 +694,54 @@ gve_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
msg_type = GST_MESSAGE_TYPE (message);
- switch (msg_type)
- {
+ switch (msg_type) {
case GST_MESSAGE_ERROR:
gve_error_msg (gve, message);
if (gve->priv->main_pipeline)
- gst_element_set_state (gve->priv->main_pipeline, GST_STATE_READY);
+ gst_element_set_state (gve->priv->main_pipeline, GST_STATE_READY);
break;
case GST_MESSAGE_WARNING:
GST_WARNING ("Warning message: %" GST_PTR_FORMAT, message);
break;
case GST_MESSAGE_STATE_CHANGED:
- {
- GstState old_state, new_state;
- gchar *src_name;
-
- gst_message_parse_state_changed (message, &old_state, &new_state,
- NULL);
-
- if (old_state == new_state)
- break;
-
- /* we only care about playbin (pipeline) state changes */
- if (GST_MESSAGE_SRC (message) !=
- GST_OBJECT (gve->priv->main_pipeline))
- break;
-
- src_name = gst_object_get_name (message->src);
-
- GST_INFO ("%s changed state from %s to %s", src_name,
- gst_element_state_get_name (old_state),
- gst_element_state_get_name (new_state));
- g_free (src_name);
-
- if (new_state == GST_STATE_PLAYING)
- gve_set_tick_timeout (gve, TIMEOUT);
- if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_READY)
- {
- if (gve->priv->update_id > 0)
- {
- g_source_remove (gve->priv->update_id);
- gve->priv->update_id = 0;
- }
- }
- break;
+ {
+ GstState old_state, new_state;
+ gchar *src_name;
+
+ gst_message_parse_state_changed (message, &old_state, &new_state, NULL);
+
+ if (old_state == new_state)
+ break;
+
+ /* we only care about playbin (pipeline) state changes */
+ if (GST_MESSAGE_SRC (message) != GST_OBJECT (gve->priv->main_pipeline))
+ break;
+
+ src_name = gst_object_get_name (message->src);
+
+ GST_INFO ("%s changed state from %s to %s", src_name,
+ gst_element_state_get_name (old_state),
+ gst_element_state_get_name (new_state));
+ g_free (src_name);
+
+ if (new_state == GST_STATE_PLAYING)
+ gve_set_tick_timeout (gve, TIMEOUT);
+ if (old_state == GST_STATE_PAUSED && new_state == GST_STATE_READY) {
+ if (gve->priv->update_id > 0) {
+ g_source_remove (gve->priv->update_id);
+ gve->priv->update_id = 0;
+ }
}
+ break;
+ }
case GST_MESSAGE_EOS:
- if (gve->priv->update_id > 0)
- {
- g_source_remove (gve->priv->update_id);
- gve->priv->update_id = 0;
- }
+ if (gve->priv->update_id > 0) {
+ g_source_remove (gve->priv->update_id);
+ gve->priv->update_id = 0;
+ }
gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL);
- g_signal_emit (gve, gve_signals[SIGNAL_PERCENT_COMPLETED], 0,
- (gfloat) 1);
+ g_signal_emit (gve, gve_signals[SIGNAL_PERCENT_COMPLETED], 0, (gfloat) 1);
gve->priv->active_segment = 0;
/* Close file sink properly */
g_object_set (G_OBJECT (gve->priv->file_sink), "location", "", NULL);
@@ -802,7 +749,7 @@ gve_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
default:
GST_LOG ("Unhandled message: %" GST_PTR_FORMAT, message);
break;
- }
+ }
}
static void
@@ -812,20 +759,19 @@ gve_error_msg (GstVideoEditor * gve, GstMessage * msg)
gchar *dbg = NULL;
gst_message_parse_error (msg, &err, &dbg);
- if (err)
- {
- GST_ERROR ("message = %s", GST_STR_NULL (err->message));
- GST_ERROR ("domain = %d (%s)", err->domain,
- GST_STR_NULL (g_quark_to_string (err->domain)));
- GST_ERROR ("code = %d", err->code);
- GST_ERROR ("debug = %s", GST_STR_NULL (dbg));
- GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src);
-
- g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
- GST_STR_NULL (dbg));
- g_signal_emit (gve, gve_signals[SIGNAL_ERROR], 0, err->message);
- g_error_free (err);
- }
+ if (err) {
+ GST_ERROR ("message = %s", GST_STR_NULL (err->message));
+ GST_ERROR ("domain = %d (%s)", err->domain,
+ GST_STR_NULL (g_quark_to_string (err->domain)));
+ GST_ERROR ("code = %d", err->code);
+ GST_ERROR ("debug = %s", GST_STR_NULL (dbg));
+ GST_ERROR ("source = %" GST_PTR_FORMAT, msg->src);
+
+ g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
+ GST_STR_NULL (dbg));
+ g_signal_emit (gve, gve_signals[SIGNAL_ERROR], 0, err->message);
+ g_error_free (err);
+ }
g_free (dbg);
}
@@ -837,32 +783,25 @@ gve_query_timeout (GstVideoEditor * gve)
gchar *title;
gint64 stop_time = gve->priv->stop_times[gve->priv->active_segment];
- if (gst_element_query_position (gve->priv->main_pipeline, &fmt, &pos))
- {
- if (pos != -1 && fmt == GST_FORMAT_TIME)
- {
- g_signal_emit (gve,
- gve_signals[SIGNAL_PERCENT_COMPLETED],
- 0, (float) pos / (float) gve->priv->duration);
- }
+ if (gst_element_query_position (gve->priv->main_pipeline, &fmt, &pos)) {
+ if (pos != -1 && fmt == GST_FORMAT_TIME) {
+ g_signal_emit (gve,
+ gve_signals[SIGNAL_PERCENT_COMPLETED],
+ 0, (float) pos / (float) gve->priv->duration);
}
- else
- {
- GST_INFO ("could not get position");
- }
-
- if (gst_element_query_position (gve->priv->video_encoder, &fmt, &pos))
- {
- if (stop_time - pos <= 0)
- {
- gve->priv->active_segment++;
- title =
- (gchar *) g_list_nth_data (gve->priv->titles,
- gve->priv->active_segment);
- g_object_set (G_OBJECT (gve->priv->textoverlay), "text", title,
- NULL);
- }
+ } else {
+ GST_INFO ("could not get position");
+ }
+
+ if (gst_element_query_position (gve->priv->video_encoder, &fmt, &pos)) {
+ if (stop_time - pos <= 0) {
+ gve->priv->active_segment++;
+ title =
+ (gchar *) g_list_nth_data (gve->priv->titles,
+ gve->priv->active_segment);
+ g_object_set (G_OBJECT (gve->priv->textoverlay), "text", title, NULL);
}
+ }
return TRUE;
}
@@ -876,8 +815,8 @@ gve_query_timeout (GstVideoEditor * gve)
void
gst_video_editor_add_segment (GstVideoEditor * gve, gchar * file,
- gint64 start, gint64 duration, gdouble rate,
- gchar * title, gboolean hasAudio)
+ gint64 start, gint64 duration, gdouble rate,
+ gchar * title, gboolean hasAudio)
{
GstState cur_state;
GstElement *gnl_filesource = NULL;
@@ -890,86 +829,70 @@ gst_video_editor_add_segment (GstVideoEditor * gve, gchar * file,
g_return_if_fail (GST_IS_VIDEO_EDITOR (gve));
gst_element_get_state (gve->priv->main_pipeline, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- final_duration = GST_MSECOND * duration / rate;
+ if (cur_state <= GST_STATE_READY) {
+ final_duration = GST_MSECOND * duration / rate;
+
+ filter = gst_caps_from_string ("video/x-raw-rgb;video/x-raw-yuv");
+ element_name =
+ g_strdup_printf ("gnlvideofilesource%d", gve->priv->segments);
+ gnl_filesource = gst_element_factory_make ("gnlfilesource", element_name);
+ g_object_set (G_OBJECT (gnl_filesource), "location", file, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "media-start",
+ GST_MSECOND * start, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "media-duration",
+ GST_MSECOND * duration, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "start", gve->priv->duration,
+ NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "duration", final_duration, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "caps", filter, NULL);
+ if (gve->priv->segments == 0) {
+ g_object_set (G_OBJECT (gve->priv->textoverlay), "text", title, NULL);
+ }
+ gst_bin_add (GST_BIN (gve->priv->gnl_video_composition), gnl_filesource);
+ gve->priv->gnl_video_filesources =
+ g_list_append (gve->priv->gnl_video_filesources, gnl_filesource);
- filter = gst_caps_from_string ("video/x-raw-rgb;video/x-raw-yuv");
+
+
+ if (hasAudio && rate == 1) {
element_name =
- g_strdup_printf ("gnlvideofilesource%d", gve->priv->segments);
- gnl_filesource =
- gst_element_factory_make ("gnlfilesource", element_name);
+ g_strdup_printf ("gnlaudiofilesource%d", gve->priv->segments);
+ gnl_filesource = gst_element_factory_make ("gnlfilesource", element_name);
g_object_set (G_OBJECT (gnl_filesource), "location", file, NULL);
- g_object_set (G_OBJECT (gnl_filesource), "media-start",
- GST_MSECOND * start, NULL);
- g_object_set (G_OBJECT (gnl_filesource), "media-duration",
- GST_MSECOND * duration, NULL);
- g_object_set (G_OBJECT (gnl_filesource), "start", gve->priv->duration,
- NULL);
- g_object_set (G_OBJECT (gnl_filesource), "duration", final_duration,
- NULL);
- g_object_set (G_OBJECT (gnl_filesource), "caps", filter, NULL);
- if (gve->priv->segments == 0)
- {
- g_object_set (G_OBJECT (gve->priv->textoverlay), "text", title,
- NULL);
- }
- gst_bin_add (GST_BIN (gve->priv->gnl_video_composition),
- gnl_filesource);
- gve->priv->gnl_video_filesources =
- g_list_append (gve->priv->gnl_video_filesources, gnl_filesource);
-
-
-
- if (hasAudio && rate == 1)
- {
- element_name =
- g_strdup_printf ("gnlaudiofilesource%d", gve->priv->segments);
- gnl_filesource =
- gst_element_factory_make ("gnlfilesource", element_name);
- g_object_set (G_OBJECT (gnl_filesource), "location", file, NULL);
- }
- else
- {
- element_name =
- g_strdup_printf ("gnlaudiofakesource%d", gve->priv->segments);
- gnl_filesource =
- gst_element_factory_make ("gnlsource", element_name);
- /* If the file doesn't contain audio, something must be playing */
- /* We use an audiotestsrc mutted and with a low priority */
- element_name =
- g_strdup_printf ("audiotestsource%d", gve->priv->segments);
- audiotestsrc =
- gst_element_factory_make ("audiotestsrc", element_name);
- g_object_set (G_OBJECT (audiotestsrc), "volume", (double) 0, NULL);
- gst_bin_add (GST_BIN (gnl_filesource), audiotestsrc);
- }
- filter = gst_caps_from_string ("audio/x-raw-float;audio/x-raw-int");
- g_object_set (G_OBJECT (gnl_filesource), "media-start",
- GST_MSECOND * start, NULL);
- g_object_set (G_OBJECT (gnl_filesource), "media-duration",
- GST_MSECOND * duration, NULL);
- g_object_set (G_OBJECT (gnl_filesource), "start", gve->priv->duration,
- NULL);
- g_object_set (G_OBJECT (gnl_filesource), "duration", final_duration,
- NULL);
- g_object_set (G_OBJECT (gnl_filesource), "caps", filter, NULL);
- gst_bin_add (GST_BIN (gve->priv->gnl_audio_composition),
- gnl_filesource);
- gve->priv->gnl_audio_filesources =
- g_list_append (gve->priv->gnl_audio_filesources, gnl_filesource);
-
- gve->priv->duration += final_duration;
- gve->priv->segments++;
-
- gve->priv->titles = g_list_append (gve->priv->titles, title);
- gve->priv->stop_times[gve->priv->segments - 1] = gve->priv->duration;
-
- GST_INFO ("New segment: start={%" GST_TIME_FORMAT "} duration={%"
- GST_TIME_FORMAT "} ", GST_TIME_ARGS (start * GST_MSECOND),
- GST_TIME_ARGS (duration * GST_MSECOND));
+ } else {
+ element_name =
+ g_strdup_printf ("gnlaudiofakesource%d", gve->priv->segments);
+ gnl_filesource = gst_element_factory_make ("gnlsource", element_name);
+ /* If the file doesn't contain audio, something must be playing */
+ /* We use an audiotestsrc mutted and with a low priority */
+ element_name = g_strdup_printf ("audiotestsource%d", gve->priv->segments);
+ audiotestsrc = gst_element_factory_make ("audiotestsrc", element_name);
+ g_object_set (G_OBJECT (audiotestsrc), "volume", (double) 0, NULL);
+ gst_bin_add (GST_BIN (gnl_filesource), audiotestsrc);
}
- else
+ filter = gst_caps_from_string ("audio/x-raw-float;audio/x-raw-int");
+ g_object_set (G_OBJECT (gnl_filesource), "media-start",
+ GST_MSECOND * start, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "media-duration",
+ GST_MSECOND * duration, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "start", gve->priv->duration,
+ NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "duration", final_duration, NULL);
+ g_object_set (G_OBJECT (gnl_filesource), "caps", filter, NULL);
+ gst_bin_add (GST_BIN (gve->priv->gnl_audio_composition), gnl_filesource);
+ gve->priv->gnl_audio_filesources =
+ g_list_append (gve->priv->gnl_audio_filesources, gnl_filesource);
+
+ gve->priv->duration += final_duration;
+ gve->priv->segments++;
+
+ gve->priv->titles = g_list_append (gve->priv->titles, title);
+ gve->priv->stop_times[gve->priv->segments - 1] = gve->priv->duration;
+
+ GST_INFO ("New segment: start={%" GST_TIME_FORMAT "} duration={%"
+ GST_TIME_FORMAT "} ", GST_TIME_ARGS (start * GST_MSECOND),
+ GST_TIME_ARGS (duration * GST_MSECOND));
+ } else
GST_WARNING ("Segments can only be added for a state <= GST_STATE_READY");
g_free (element_name);
}
@@ -986,23 +909,21 @@ gst_video_editor_clear_segments_list (GstVideoEditor * gve)
tmp = gve->priv->gnl_video_filesources;
- for (; tmp; tmp = g_list_next (tmp))
- {
- GstElement *object = (GstElement *) tmp->data;
- if (object)
- gst_element_set_state (object, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (gve->priv->gnl_video_composition), object);
- }
+ for (; tmp; tmp = g_list_next (tmp)) {
+ GstElement *object = (GstElement *) tmp->data;
+ if (object)
+ gst_element_set_state (object, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (gve->priv->gnl_video_composition), object);
+ }
tmp = gve->priv->gnl_audio_filesources;
- for (; tmp; tmp = g_list_next (tmp))
- {
- GstElement *object = (GstElement *) tmp->data;
- if (object)
- gst_element_set_state (object, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (gve->priv->gnl_audio_composition), object);
- }
+ for (; tmp; tmp = g_list_next (tmp)) {
+ GstElement *object = (GstElement *) tmp->data;
+ if (object)
+ gst_element_set_state (object, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (gve->priv->gnl_audio_composition), object);
+ }
g_list_free (tmp);
g_list_free (gve->priv->gnl_video_filesources);
@@ -1022,7 +943,7 @@ gst_video_editor_clear_segments_list (GstVideoEditor * gve)
void
gst_video_editor_set_video_encoder (GstVideoEditor * gve, gchar ** err,
- VideoEncoderType codec)
+ VideoEncoderType codec)
{
GstElement *encoder = NULL;
GstState cur_state;
@@ -1035,104 +956,95 @@ gst_video_editor_set_video_encoder (GstVideoEditor * gve, gchar ** err,
gst_element_get_state (gve->priv->main_pipeline, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- switch (codec)
- {
- case VIDEO_ENCODER_H264:
- encoder_name = "x264enc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (encoder), "pass", 17, NULL); //Variable Bitrate-Pass 1
- break;
- case VIDEO_ENCODER_MPEG4:
- encoder_name = "xvidenc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (encoder), "pass", 1, NULL); //Variable Bitrate-Pass 1
- break;
- case VIDEO_ENCODER_XVID:
- encoder_name = "ffenc_mpeg4";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (encoder), "pass", 512, NULL); //Variable Bitrate-Pass 1
-
- break;
- case VIDEO_ENCODER_MPEG2:
- encoder_name = "mpeg2enc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (encoder), "format", 9, NULL); //DVD compilant
- g_object_set (G_OBJECT (encoder), "framerate", 3, NULL); //25 FPS (PAL/SECAM)
- break;
- case VIDEO_ENCODER_THEORA:
- encoder_name = "theoraenc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- break;
- case VIDEO_ENCODER_VP8:
- encoder_name = "vp8enc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- break;
- }
-
- if (encoder)
- {
- if (!g_strcmp0
- (gst_element_get_name (gve->priv->video_encoder), encoder_name))
- {
- GST_WARNING
- ("The video encoder is not changed because it is already in use.");
- gst_object_unref (encoder);
- return;
- }
-
- /*Remove old encoder element */
-
- gst_element_unlink (gve->priv->queue, gve->priv->video_encoder);
- gst_element_unlink (gve->priv->vencode_bin, gve->priv->muxer);
- gst_element_set_state (gve->priv->video_encoder, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (gve->priv->vencode_bin),
- gve->priv->video_encoder);
-
- /*Add new encoder element */
- gve->priv->video_encoder = encoder;
- g_object_set (G_OBJECT (gve->priv->video_encoder), "bitrate",
- gve->priv->video_bitrate, NULL);
- /*Add first to the encoder bin */
- gst_bin_add (GST_BIN (gve->priv->vencode_bin),
- gve->priv->video_encoder);
- gst_element_link (gve->priv->queue, gve->priv->video_encoder);
- /*Remove old encoder bin's src pad */
- oldsrcpad =
- gst_element_get_static_pad (gve->priv->vencode_bin, "src");
- gst_pad_set_active (oldsrcpad, FALSE);
- gst_element_remove_pad (gve->priv->vencode_bin, oldsrcpad);
- /*Create new encoder bin's src pad */
- srcpad =
- gst_element_get_static_pad (gve->priv->video_encoder, "src");
- gst_pad_set_active (srcpad, TRUE);
- gst_element_add_pad (gve->priv->vencode_bin,
- gst_ghost_pad_new ("src", srcpad));
- gst_element_link (gve->priv->vencode_bin, gve->priv->muxer);
-
- gve_rewrite_headers (gve);
- }
+ if (cur_state <= GST_STATE_READY) {
+ switch (codec) {
+ case VIDEO_ENCODER_H264:
+ encoder_name = "x264enc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (encoder), "pass", 17, NULL); //Variable Bitrate-Pass 1
+ break;
+ case VIDEO_ENCODER_MPEG4:
+ encoder_name = "xvidenc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (encoder), "pass", 1, NULL); //Variable Bitrate-Pass 1
+ break;
+ case VIDEO_ENCODER_XVID:
+ encoder_name = "ffenc_mpeg4";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (encoder), "pass", 512, NULL); //Variable Bitrate-Pass 1
+
+ break;
+ case VIDEO_ENCODER_MPEG2:
+ encoder_name = "mpeg2enc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (encoder), "format", 9, NULL); //DVD compilant
+ g_object_set (G_OBJECT (encoder), "framerate", 3, NULL); //25 FPS (PAL/SECAM)
+ break;
+ case VIDEO_ENCODER_THEORA:
+ encoder_name = "theoraenc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ break;
+ case VIDEO_ENCODER_VP8:
+ encoder_name = "vp8enc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ break;
+ }
- else
- {
- error =
- g_strdup_printf
- ("The %s encoder element is not avalaible. Check your GStreamer installation",
- encoder_name);
- GST_ERROR (error);
- *err = g_strdup (error);
- g_free (error);
- }
+ if (encoder) {
+ if (!g_strcmp0
+ (gst_element_get_name (gve->priv->video_encoder), encoder_name)) {
+ GST_WARNING
+ ("The video encoder is not changed because it is already in use.");
+ gst_object_unref (encoder);
+ return;
+ }
+
+ /*Remove old encoder element */
+
+ gst_element_unlink (gve->priv->queue, gve->priv->video_encoder);
+ gst_element_unlink (gve->priv->vencode_bin, gve->priv->muxer);
+ gst_element_set_state (gve->priv->video_encoder, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (gve->priv->vencode_bin),
+ gve->priv->video_encoder);
+
+ /*Add new encoder element */
+ gve->priv->video_encoder = encoder;
+ g_object_set (G_OBJECT (gve->priv->video_encoder), "bitrate",
+ gve->priv->video_bitrate, NULL);
+ /*Add first to the encoder bin */
+ gst_bin_add (GST_BIN (gve->priv->vencode_bin), gve->priv->video_encoder);
+ gst_element_link (gve->priv->queue, gve->priv->video_encoder);
+ /*Remove old encoder bin's src pad */
+ oldsrcpad = gst_element_get_static_pad (gve->priv->vencode_bin, "src");
+ gst_pad_set_active (oldsrcpad, FALSE);
+ gst_element_remove_pad (gve->priv->vencode_bin, oldsrcpad);
+ /*Create new encoder bin's src pad */
+ srcpad = gst_element_get_static_pad (gve->priv->video_encoder, "src");
+ gst_pad_set_active (srcpad, TRUE);
+ gst_element_add_pad (gve->priv->vencode_bin,
+ gst_ghost_pad_new ("src", srcpad));
+ gst_element_link (gve->priv->vencode_bin, gve->priv->muxer);
+
+ gve_rewrite_headers (gve);
}
- else
+
+ else {
+ error =
+ g_strdup_printf
+ ("The %s encoder element is not avalaible. Check your GStreamer installation",
+ encoder_name);
+ GST_ERROR (error);
+ *err = g_strdup (error);
+ g_free (error);
+ }
+ } else
GST_WARNING
- ("The video encoder cannot be changed for a state <= GST_STATE_READY");
+ ("The video encoder cannot be changed for a state <= GST_STATE_READY");
}
void
gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
- AudioEncoderType codec)
+ AudioEncoderType codec)
{
GstElement *encoder = NULL;
GstState cur_state;
@@ -1145,100 +1057,91 @@ gst_video_editor_set_audio_encoder (GstVideoEditor * gve, gchar ** err,
gst_element_get_state (gve->priv->main_pipeline, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- switch (codec)
- {
- case AUDIO_ENCODER_AAC:
- encoder_name = "faac";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
- gst_caps_from_string (FAAC_CAPS), NULL);
- break;
- case AUDIO_ENCODER_MP3:
- encoder_name = "lame";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (encoder), "vbr", 4, NULL); //Variable Bitrate
- g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
- gst_caps_from_string (LAME_CAPS), NULL);
- break;
- case AUDIO_ENCODER_VORBIS:
- encoder_name = "vorbisenc";
- encoder = gst_element_factory_make (encoder_name, encoder_name);
- g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
- gst_caps_from_string (VORBIS_CAPS), NULL);
- break;
- default:
- gst_video_editor_set_enable_audio (gve, FALSE);
- break;
- }
- if (encoder)
- {
- if (!g_strcmp0
- (gst_element_get_name (gve->priv->audioencoder), encoder_name))
- {
- GST_WARNING
- ("The audio encoder is not changed because it is already in use.");
- gst_object_unref (encoder);
- return;
- }
-
- /*Remove old encoder element */
-
- gst_element_unlink (gve->priv->audioqueue, gve->priv->audioencoder);
- if (gve->priv->audio_enabled)
- gst_element_unlink (gve->priv->aencode_bin, gve->priv->muxer);
- gst_element_set_state (gve->priv->audioencoder, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (gve->priv->aencode_bin),
- gve->priv->audioencoder);
-
- /*Add new encoder element */
- gve->priv->audioencoder = encoder;
- if (codec == AUDIO_ENCODER_MP3)
- g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
- gve->priv->audio_bitrate / 1000, NULL);
- else
- g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
- gve->priv->audio_bitrate, NULL);
- /*Add first to the encoder bin */
- gst_bin_add (GST_BIN (gve->priv->aencode_bin),
- gve->priv->audioencoder);
- gst_element_link (gve->priv->audioqueue, gve->priv->audioencoder);
- /*Remove old encoder bin's src pad */
- oldsrcpad =
- gst_element_get_static_pad (gve->priv->aencode_bin, "src");
- gst_pad_set_active (oldsrcpad, FALSE);
- gst_element_remove_pad (gve->priv->aencode_bin, oldsrcpad);
- /*Create new encoder bin's src pad */
- srcpad =
- gst_element_get_static_pad (gve->priv->audioencoder, "src");
- gst_pad_set_active (srcpad, TRUE);
- gst_element_add_pad (gve->priv->aencode_bin,
- gst_ghost_pad_new ("src", srcpad));
- if (gve->priv->audio_enabled)
- gst_element_link (gve->priv->aencode_bin, gve->priv->muxer);
- gve_rewrite_headers (gve);
- }
+ if (cur_state <= GST_STATE_READY) {
+ switch (codec) {
+ case AUDIO_ENCODER_AAC:
+ encoder_name = "faac";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
+ gst_caps_from_string (FAAC_CAPS), NULL);
+ break;
+ case AUDIO_ENCODER_MP3:
+ encoder_name = "lame";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (encoder), "vbr", 4, NULL); //Variable Bitrate
+ g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
+ gst_caps_from_string (LAME_CAPS), NULL);
+ break;
+ case AUDIO_ENCODER_VORBIS:
+ encoder_name = "vorbisenc";
+ encoder = gst_element_factory_make (encoder_name, encoder_name);
+ g_object_set (G_OBJECT (gve->priv->audiocapsfilter), "caps",
+ gst_caps_from_string (VORBIS_CAPS), NULL);
+ break;
+ default:
+ gst_video_editor_set_enable_audio (gve, FALSE);
+ break;
+ }
+ if (encoder) {
+ if (!g_strcmp0
+ (gst_element_get_name (gve->priv->audioencoder), encoder_name)) {
+ GST_WARNING
+ ("The audio encoder is not changed because it is already in use.");
+ gst_object_unref (encoder);
+ return;
+ }
+
+ /*Remove old encoder element */
+ gst_element_unlink (gve->priv->audioqueue, gve->priv->audioencoder);
+ if (gve->priv->audio_enabled)
+ gst_element_unlink (gve->priv->aencode_bin, gve->priv->muxer);
+ gst_element_set_state (gve->priv->audioencoder, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (gve->priv->aencode_bin),
+ gve->priv->audioencoder);
+
+ /*Add new encoder element */
+ gve->priv->audioencoder = encoder;
+ if (codec == AUDIO_ENCODER_MP3)
+ g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
+ gve->priv->audio_bitrate / 1000, NULL);
else
- {
- error =
- g_strdup_printf
- ("The %s encoder element is not avalaible. Check your GStreamer installation",
- encoder_name);
- GST_ERROR (error);
- *err = g_strdup (error);
- g_free (error);
- }
+ g_object_set (G_OBJECT (gve->priv->audioencoder), "bitrate",
+ gve->priv->audio_bitrate, NULL);
+ /*Add first to the encoder bin */
+ gst_bin_add (GST_BIN (gve->priv->aencode_bin), gve->priv->audioencoder);
+ gst_element_link (gve->priv->audioqueue, gve->priv->audioencoder);
+ /*Remove old encoder bin's src pad */
+ oldsrcpad = gst_element_get_static_pad (gve->priv->aencode_bin, "src");
+ gst_pad_set_active (oldsrcpad, FALSE);
+ gst_element_remove_pad (gve->priv->aencode_bin, oldsrcpad);
+ /*Create new encoder bin's src pad */
+ srcpad = gst_element_get_static_pad (gve->priv->audioencoder, "src");
+ gst_pad_set_active (srcpad, TRUE);
+ gst_element_add_pad (gve->priv->aencode_bin,
+ gst_ghost_pad_new ("src", srcpad));
+ if (gve->priv->audio_enabled)
+ gst_element_link (gve->priv->aencode_bin, gve->priv->muxer);
+ gve_rewrite_headers (gve);
+ }
+
+ else {
+ error =
+ g_strdup_printf
+ ("The %s encoder element is not avalaible. Check your GStreamer installation",
+ encoder_name);
+ GST_ERROR (error);
+ *err = g_strdup (error);
+ g_free (error);
}
- else
+ } else
GST_WARNING
- ("The audio encoder cannot be changed for a state <= GST_STATE_READY");
+ ("The audio encoder cannot be changed for a state <= GST_STATE_READY");
}
void
gst_video_editor_set_video_muxer (GstVideoEditor * gve, gchar ** err,
- VideoMuxerType muxerType)
+ VideoMuxerType muxerType)
{
GstElement *muxer = NULL;
GstState cur_state;
@@ -1249,78 +1152,70 @@ gst_video_editor_set_video_muxer (GstVideoEditor * gve, gchar ** err,
gst_element_get_state (gve->priv->main_pipeline, &cur_state, NULL, 0);
- if (cur_state <= GST_STATE_READY)
- {
- switch (muxerType)
- {
- case VIDEO_MUXER_MATROSKA:
- muxer_name = "matroskamux";
- muxer = gst_element_factory_make ("matroskamux", muxer_name);
- break;
- case VIDEO_MUXER_AVI:
- muxer_name = "avimux";
- muxer = gst_element_factory_make ("avimux", muxer_name);
- break;
- case VIDEO_MUXER_OGG:
- muxer_name = "oggmux";
- muxer = gst_element_factory_make ("oggmux", muxer_name);
- break;
- case VIDEO_MUXER_MP4:
- muxer_name = "qtmux";
- muxer = gst_element_factory_make ("qtmux", muxer_name);
- break;
- case VIDEO_MUXER_MPEG_PS:
- muxer_name = "ffmux_dvd";
- //We don't want to mux anything yet as ffmux_dvd is buggy
- //FIXME: Until we don't have audio save the mpeg-ps stream without mux.
- muxer = gst_element_factory_make ("ffmux_dvd", muxer_name);
- break;
- case VIDEO_MUXER_WEBM:
- muxer_name = "webmmux";
- muxer = gst_element_factory_make ("webmmux", muxer_name);
- break;
- }
-
- if (muxer)
- {
- if (!g_strcmp0
- (gst_element_get_name (gve->priv->muxer), muxer_name))
- {
- GST_WARNING
- ("Not changing the video muxer as the new one is the same in use.");
- gst_object_unref (muxer);
- return;
- }
- gst_element_unlink (gve->priv->vencode_bin, gve->priv->muxer);
- if (gve->priv->audio_enabled)
- gst_element_unlink (gve->priv->aencode_bin, gve->priv->muxer);
- gst_element_unlink (gve->priv->muxer, gve->priv->file_sink);
- gst_element_set_state (gve->priv->muxer, GST_STATE_NULL);
- gst_bin_remove (GST_BIN (gve->priv->main_pipeline),
- gve->priv->muxer);
- gst_bin_add (GST_BIN (gve->priv->main_pipeline), muxer);
- gst_element_link_many (gve->priv->vencode_bin, muxer,
- gve->priv->file_sink, NULL);
- if (gve->priv->audio_enabled)
- gst_element_link (gve->priv->aencode_bin, muxer);
- gve->priv->muxer = muxer;
- gve_rewrite_headers (gve);
- }
+ if (cur_state <= GST_STATE_READY) {
+ switch (muxerType) {
+ case VIDEO_MUXER_MATROSKA:
+ muxer_name = "matroskamux";
+ muxer = gst_element_factory_make ("matroskamux", muxer_name);
+ break;
+ case VIDEO_MUXER_AVI:
+ muxer_name = "avimux";
+ muxer = gst_element_factory_make ("avimux", muxer_name);
+ break;
+ case VIDEO_MUXER_OGG:
+ muxer_name = "oggmux";
+ muxer = gst_element_factory_make ("oggmux", muxer_name);
+ break;
+ case VIDEO_MUXER_MP4:
+ muxer_name = "qtmux";
+ muxer = gst_element_factory_make ("qtmux", muxer_name);
+ break;
+ case VIDEO_MUXER_MPEG_PS:
+ muxer_name = "ffmux_dvd";
+ //We don't want to mux anything yet as ffmux_dvd is buggy
+ //FIXME: Until we don't have audio save the mpeg-ps stream without mux.
+ muxer = gst_element_factory_make ("ffmux_dvd", muxer_name);
+ break;
+ case VIDEO_MUXER_WEBM:
+ muxer_name = "webmmux";
+ muxer = gst_element_factory_make ("webmmux", muxer_name);
+ break;
+ }
- else
- {
- error =
- g_strdup_printf
- ("The %s muxer element is not avalaible. Check your GStreamer installation",
- muxer_name);
- GST_ERROR (error);
- *err = g_strdup (error);
- g_free (error);
- }
+ if (muxer) {
+ if (!g_strcmp0 (gst_element_get_name (gve->priv->muxer), muxer_name)) {
+ GST_WARNING
+ ("Not changing the video muxer as the new one is the same in use.");
+ gst_object_unref (muxer);
+ return;
+ }
+ gst_element_unlink (gve->priv->vencode_bin, gve->priv->muxer);
+ if (gve->priv->audio_enabled)
+ gst_element_unlink (gve->priv->aencode_bin, gve->priv->muxer);
+ gst_element_unlink (gve->priv->muxer, gve->priv->file_sink);
+ gst_element_set_state (gve->priv->muxer, GST_STATE_NULL);
+ gst_bin_remove (GST_BIN (gve->priv->main_pipeline), gve->priv->muxer);
+ gst_bin_add (GST_BIN (gve->priv->main_pipeline), muxer);
+ gst_element_link_many (gve->priv->vencode_bin, muxer,
+ gve->priv->file_sink, NULL);
+ if (gve->priv->audio_enabled)
+ gst_element_link (gve->priv->aencode_bin, muxer);
+ gve->priv->muxer = muxer;
+ gve_rewrite_headers (gve);
}
- else
+
+ else {
+ error =
+ g_strdup_printf
+ ("The %s muxer element is not avalaible. Check your GStreamer installation",
+ muxer_name);
+ GST_ERROR (error);
+ *err = g_strdup (error);
+ g_free (error);
+ }
+ } else
GST_WARNING
- ("The video muxer cannot be changed for a state <= GST_STATE_READY");
+ ("The video muxer cannot be changed for a state <= GST_STATE_READY");
}
void
@@ -1337,11 +1232,10 @@ void
gst_video_editor_cancel (GstVideoEditor * gve)
{
g_return_if_fail (GST_IS_VIDEO_EDITOR (gve));
- if (gve->priv->update_id > 0)
- {
- g_source_remove (gve->priv->update_id);
- gve->priv->update_id = 0;
- }
+ if (gve->priv->update_id > 0) {
+ g_source_remove (gve->priv->update_id);
+ gve->priv->update_id = 0;
+ }
gst_element_set_state (gve->priv->main_pipeline, GST_STATE_NULL);
g_signal_emit (gve, gve_signals[SIGNAL_PERCENT_COMPLETED], 0, (gfloat) - 1);
}
@@ -1361,34 +1255,32 @@ gst_video_editor_new (GError ** err)
gve->priv->main_pipeline = gst_pipeline_new ("main_pipeline");
- if (!gve->priv->main_pipeline)
- {
- g_set_error (err, GVC_ERROR, GST_ERROR_PLUGIN_LOAD,
- ("Failed to create a GStreamer Bin. "
- "Please check your GStreamer installation."));
- g_object_ref_sink (gve);
- g_object_unref (gve);
- return NULL;
- }
+ if (!gve->priv->main_pipeline) {
+ g_set_error (err, GVC_ERROR, GST_ERROR_PLUGIN_LOAD,
+ ("Failed to create a GStreamer Bin. "
+ "Please check your GStreamer installation."));
+ g_object_ref_sink (gve);
+ g_object_unref (gve);
+ return NULL;
+ }
/* Create elements */
gve->priv->gnl_video_composition =
- gst_element_factory_make ("gnlcomposition", "gnl-video-composition");
+ gst_element_factory_make ("gnlcomposition", "gnl-video-composition");
gve->priv->gnl_audio_composition =
- gst_element_factory_make ("gnlcomposition", "gnl-audio-composition");
- if (!gve->priv->gnl_video_composition || !gve->priv->gnl_audio_composition)
- {
- g_set_error (err, GVC_ERROR, GST_ERROR_PLUGIN_LOAD,
- ("Failed to create a Gnonlin element. "
- "Please check your GStreamer installation."));
- g_object_ref_sink (gve);
- g_object_unref (gve);
- return NULL;
- }
+ gst_element_factory_make ("gnlcomposition", "gnl-audio-composition");
+ if (!gve->priv->gnl_video_composition || !gve->priv->gnl_audio_composition) {
+ g_set_error (err, GVC_ERROR, GST_ERROR_PLUGIN_LOAD,
+ ("Failed to create a Gnonlin element. "
+ "Please check your GStreamer installation."));
+ g_object_ref_sink (gve);
+ g_object_unref (gve);
+ return NULL;
+ }
gve->priv->muxer =
- gst_element_factory_make (DEFAULT_VIDEO_MUXER, "videomuxer");
+ gst_element_factory_make (DEFAULT_VIDEO_MUXER, "videomuxer");
gve->priv->file_sink = gst_element_factory_make ("filesink", "filesink");
gve_create_video_encode_bin (gve);
gve_create_audio_encode_bin (gve);
@@ -1396,19 +1288,18 @@ gst_video_editor_new (GError ** err)
/* Set elements properties */
g_object_set (G_OBJECT (gve->priv->file_sink), "location",
- gve->priv->output_file, NULL);
+ gve->priv->output_file, NULL);
/* Link elements */
gst_bin_add_many (GST_BIN (gve->priv->main_pipeline),
- gve->priv->gnl_video_composition,
- gve->priv->gnl_audio_composition,
- gve->priv->vencode_bin,
- gve->priv->aencode_bin,
- gve->priv->muxer, gve->priv->file_sink, NULL);
+ gve->priv->gnl_video_composition,
+ gve->priv->gnl_audio_composition,
+ gve->priv->vencode_bin,
+ gve->priv->aencode_bin, gve->priv->muxer, gve->priv->file_sink, NULL);
gst_element_link_many (gve->priv->vencode_bin,
- gve->priv->muxer, gve->priv->file_sink, NULL);
+ gve->priv->muxer, gve->priv->file_sink, NULL);
gst_element_link (gve->priv->aencode_bin, gve->priv->muxer);
@@ -1416,17 +1307,15 @@ gst_video_editor_new (GError ** err)
/*We have to wait for a "new-decoded-pad" message to link the composition with
the encoder tail */
- gve->priv->bus =
- gst_element_get_bus (GST_ELEMENT (gve->priv->main_pipeline));
+ gve->priv->bus = gst_element_get_bus (GST_ELEMENT (gve->priv->main_pipeline));
g_signal_connect (gve->priv->gnl_video_composition, "pad-added",
- G_CALLBACK (new_decoded_pad_cb), gve);
+ G_CALLBACK (new_decoded_pad_cb), gve);
g_signal_connect (gve->priv->gnl_audio_composition, "pad-added",
- G_CALLBACK (new_decoded_pad_cb), gve);
+ G_CALLBACK (new_decoded_pad_cb), gve);
gst_bus_add_signal_watch (gve->priv->bus);
gve->priv->sig_bus_async = g_signal_connect (gve->priv->bus, "message",
- G_CALLBACK
- (gve_bus_message_cb), gve);
+ G_CALLBACK (gve_bus_message_cb), gve);
gst_element_set_state (gve->priv->main_pipeline, GST_STATE_READY);
diff --git a/libcesarplayer/src/gst-video-editor.h b/libcesarplayer/src/gst-video-editor.h
index 9dd6915..85d7819 100644
--- a/libcesarplayer/src/gst-video-editor.h
+++ b/libcesarplayer/src/gst-video-editor.h
@@ -64,27 +64,22 @@ struct _GstVideoEditor
EXPORT GType
gst_video_editor_get_type (void)
- G_GNUC_CONST;
+ G_GNUC_CONST;
EXPORT void gst_video_editor_init_backend (int *argc, char ***argv);
EXPORT GstVideoEditor *gst_video_editor_new (GError ** err);
EXPORT void gst_video_editor_start (GstVideoEditor * gve);
EXPORT void gst_video_editor_cancel (GstVideoEditor * gve);
EXPORT void gst_video_editor_set_video_encoder (GstVideoEditor * gve,
- gchar ** err,
- VideoEncoderType codec);
+ gchar ** err, VideoEncoderType codec);
EXPORT void gst_video_editor_set_audio_encoder (GstVideoEditor * gve,
- gchar ** err,
- AudioEncoderType codec);
+ gchar ** err, AudioEncoderType codec);
EXPORT void gst_video_editor_set_video_muxer (GstVideoEditor * gve,
- gchar ** err,
- VideoMuxerType codec);
+ gchar ** err, VideoMuxerType codec);
EXPORT void gst_video_editor_clear_segments_list (GstVideoEditor * gve);
EXPORT void gst_video_editor_add_segment (GstVideoEditor * gve,
- gchar * file, gint64 start,
- gint64 duration, gdouble rate,
- gchar * title,
- gboolean hasAudio);
+ gchar * file, gint64 start,
+ gint64 duration, gdouble rate, gchar * title, gboolean hasAudio);
G_END_DECLS
#endif /* _GST_VIDEO_EDITOR_H_ */
diff --git a/libcesarplayer/src/gstscreenshot.c b/libcesarplayer/src/gstscreenshot.c
index 9421c26..f1df208 100644
--- a/libcesarplayer/src/gstscreenshot.c
+++ b/libcesarplayer/src/gstscreenshot.c
@@ -40,12 +40,12 @@ feed_fakesrc (GstElement * src, GstBuffer * buf, GstPad * pad, gpointer data)
gst_buffer_set_caps (buf, GST_BUFFER_CAPS (in_buf));
memcpy (GST_BUFFER_DATA (buf), GST_BUFFER_DATA (in_buf),
- GST_BUFFER_SIZE (in_buf));
+ GST_BUFFER_SIZE (in_buf));
GST_BUFFER_SIZE (buf) = GST_BUFFER_SIZE (in_buf);
GST_DEBUG ("feeding buffer %p, size %u, caps %" GST_PTR_FORMAT,
- buf, GST_BUFFER_SIZE (buf), GST_BUFFER_CAPS (buf));
+ buf, GST_BUFFER_SIZE (buf), GST_BUFFER_CAPS (buf));
}
static void
@@ -56,23 +56,22 @@ save_result (GstElement * sink, GstBuffer * buf, GstPad * pad, gpointer data)
*p_buf = gst_buffer_ref (buf);
GST_DEBUG ("received converted buffer %p with caps %" GST_PTR_FORMAT,
- *p_buf, GST_BUFFER_CAPS (*p_buf));
+ *p_buf, GST_BUFFER_CAPS (*p_buf));
}
static gboolean
create_element (const gchar * factory_name, GstElement ** element,
- GError ** err)
+ GError ** err)
{
*element = gst_element_factory_make (factory_name, NULL);
if (*element)
return TRUE;
- if (err && *err == NULL)
- {
- *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN,
- "cannot create element '%s' - please check your GStreamer installation",
- factory_name);
- }
+ if (err && *err == NULL) {
+ *err = g_error_new (GST_CORE_ERROR, GST_CORE_ERROR_MISSING_PLUGIN,
+ "cannot create element '%s' - please check your GStreamer installation",
+ factory_name);
+ }
return FALSE;
}
@@ -97,35 +96,32 @@ bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps)
!create_element ("videoscale", &vscale, &error) ||
!create_element ("capsfilter", &filter1, &error) ||
!create_element ("capsfilter", &filter2, &error) ||
- !create_element ("fakesink", &sink, &error))
- {
- g_warning ("Could not take screenshot: %s", error->message);
- g_error_free (error);
- return NULL;
- }
+ !create_element ("fakesink", &sink, &error)) {
+ g_warning ("Could not take screenshot: %s", error->message);
+ g_error_free (error);
+ return NULL;
+ }
pipeline = gst_pipeline_new ("screenshot-pipeline");
- if (pipeline == NULL)
- {
- g_warning ("Could not take screenshot: %s",
- "no pipeline (unknown error)");
- return NULL;
- }
+ if (pipeline == NULL) {
+ g_warning ("Could not take screenshot: %s", "no pipeline (unknown error)");
+ return NULL;
+ }
GST_DEBUG ("adding elements");
gst_bin_add_many (GST_BIN (pipeline), src, csp, filter1, vscale, filter2,
- sink, NULL);
+ sink, NULL);
g_signal_connect (src, "handoff", G_CALLBACK (feed_fakesrc), buf);
/* set to 'fixed' sizetype */
g_object_set (src, "sizemax", GST_BUFFER_SIZE (buf), "sizetype", 2,
- "num-buffers", 1, "signal-handoffs", TRUE, NULL);
+ "num-buffers", 1, "signal-handoffs", TRUE, NULL);
/* adding this superfluous capsfilter makes linking cheaper */
to_caps_no_par = gst_caps_copy (to_caps);
gst_structure_remove_field (gst_caps_get_structure (to_caps_no_par, 0),
- "pixel-aspect-ratio");
+ "pixel-aspect-ratio");
g_object_set (filter1, "caps", to_caps_no_par, NULL);
gst_caps_unref (to_caps_no_par);
@@ -161,56 +157,44 @@ bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to_caps)
bus = gst_element_get_bus (pipeline);
msg =
- gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 25 * GST_SECOND);
-
- if (msg)
- {
- switch (GST_MESSAGE_TYPE (msg))
- {
- case GST_MESSAGE_EOS:
- {
- if (result)
- {
- GST_DEBUG ("conversion successful: result = %p", result);
- }
- else
- {
- GST_WARNING ("EOS but no result frame?!");
- }
- break;
- }
- case GST_MESSAGE_ERROR:
- {
- gchar *dbg = NULL;
-
- gst_message_parse_error (msg, &error, &dbg);
- if (error)
- {
- g_warning ("Could not take screenshot: %s", error->message);
- GST_DEBUG ("%s [debug: %s]", error->message,
- GST_STR_NULL (dbg));
- g_error_free (error);
- }
- else
- {
- g_warning ("Could not take screenshot (and NULL error!)");
- }
- g_free (dbg);
- result = NULL;
- break;
- }
- default:
- {
- g_return_val_if_reached (NULL);
- }
- }
- }
- else
- {
- g_warning ("Could not take screenshot: %s",
- "timeout during conversion");
- result = NULL;
+ gst_bus_poll (bus, GST_MESSAGE_ERROR | GST_MESSAGE_EOS, 25 * GST_SECOND);
+
+ if (msg) {
+ switch (GST_MESSAGE_TYPE (msg)) {
+ case GST_MESSAGE_EOS:
+ {
+ if (result) {
+ GST_DEBUG ("conversion successful: result = %p", result);
+ } else {
+ GST_WARNING ("EOS but no result frame?!");
+ }
+ break;
+ }
+ case GST_MESSAGE_ERROR:
+ {
+ gchar *dbg = NULL;
+
+ gst_message_parse_error (msg, &error, &dbg);
+ if (error) {
+ g_warning ("Could not take screenshot: %s", error->message);
+ GST_DEBUG ("%s [debug: %s]", error->message, GST_STR_NULL (dbg));
+ g_error_free (error);
+ } else {
+ g_warning ("Could not take screenshot (and NULL error!)");
+ }
+ g_free (dbg);
+ result = NULL;
+ break;
+ }
+ default:
+ {
+ g_return_val_if_reached (NULL);
+ }
}
+ } else {
+ g_warning ("Could not take screenshot: %s", "timeout during conversion");
+ result = NULL;
+ }
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
diff --git a/libcesarplayer/src/gstscreenshot.h b/libcesarplayer/src/gstscreenshot.h
index 2f609fb..4e20bd1 100644
--- a/libcesarplayer/src/gstscreenshot.h
+++ b/libcesarplayer/src/gstscreenshot.h
@@ -23,7 +23,7 @@
#include <gst/gst.h>
G_BEGIN_DECLS
- GstBuffer * bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to);
+ GstBuffer * bvw_frame_conv_convert (GstBuffer * buf, GstCaps * to);
G_END_DECLS
#endif /* __BVW_FRAME_CONV_H__ */
diff --git a/libcesarplayer/src/gstvideowidget.c b/libcesarplayer/src/gstvideowidget.c
index 941ab2d..170ab16 100644
--- a/libcesarplayer/src/gstvideowidget.c
+++ b/libcesarplayer/src/gstvideowidget.c
@@ -96,30 +96,27 @@ gst_video_widget_update_cursor (GstVideoWidget * vw)
if (vw->priv->cursor_visible)
gdk_window_set_cursor (widget->window, NULL);
- else
- {
+ else {
- GdkBitmap *empty_bitmap;
- GdkColor useless;
- GdkCursor *cursor;
- char invisible_cursor_bits[] = { 0x0 };
+ GdkBitmap *empty_bitmap;
+ GdkColor useless;
+ GdkCursor *cursor;
+ char invisible_cursor_bits[] = { 0x0 };
- useless.red = useless.green = useless.blue = useless.pixel = 0;
+ useless.red = useless.green = useless.blue = useless.pixel = 0;
- empty_bitmap = gdk_bitmap_create_from_data (widget->window,
- invisible_cursor_bits, 1,
- 1);
+ empty_bitmap = gdk_bitmap_create_from_data (widget->window,
+ invisible_cursor_bits, 1, 1);
- cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
- empty_bitmap, &useless, &useless,
- 0, 0);
+ cursor = gdk_cursor_new_from_pixmap (empty_bitmap,
+ empty_bitmap, &useless, &useless, 0, 0);
- gdk_window_set_cursor (widget->window, cursor);
+ gdk_window_set_cursor (widget->window, cursor);
- gdk_cursor_unref (cursor);
+ gdk_cursor_unref (cursor);
- g_object_unref (empty_bitmap);
- }
+ g_object_unref (empty_bitmap);
+ }
}
/*
@@ -133,24 +130,20 @@ gst_video_widget_reorder_windows (GstVideoWidget * vw)
g_return_if_fail (vw != NULL);
g_return_if_fail (GST_IS_VIDEO_WIDGET (vw));
- if ((vw->priv->logo_focused) && (GDK_IS_WINDOW (vw->priv->video_window)))
- {
- gdk_window_hide (vw->priv->video_window);
- }
- else if ((!vw->priv->logo_focused) &&
- (GDK_IS_WINDOW (vw->priv->video_window)))
- {
- gdk_window_show (vw->priv->video_window);
- }
+ if ((vw->priv->logo_focused) && (GDK_IS_WINDOW (vw->priv->video_window))) {
+ gdk_window_hide (vw->priv->video_window);
+ } else if ((!vw->priv->logo_focused) &&
+ (GDK_IS_WINDOW (vw->priv->video_window))) {
+ gdk_window_show (vw->priv->video_window);
+ }
if (GDK_IS_WINDOW (vw->priv->video_window))
gdk_window_raise (vw->priv->video_window);
- if (vw->priv->event_catcher)
- {
- if (GDK_IS_WINDOW (vw->priv->event_window))
- gdk_window_raise (vw->priv->event_window);
- }
+ if (vw->priv->event_catcher) {
+ if (GDK_IS_WINDOW (vw->priv->event_window))
+ gdk_window_raise (vw->priv->event_window);
+ }
gtk_widget_queue_draw (GTK_WIDGET (vw));
}
@@ -190,7 +183,7 @@ gst_video_widget_realize (GtkWidget * widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
+ &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, widget);
@@ -207,7 +200,7 @@ gst_video_widget_realize (GtkWidget * widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
vw->priv->video_window = gdk_window_new (widget->window,
- &attributes, attributes_mask);
+ &attributes, attributes_mask);
gdk_window_set_user_data (vw->priv->video_window, widget);
@@ -226,7 +219,7 @@ gst_video_widget_realize (GtkWidget * widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
vw->priv->event_window = gdk_window_new (widget->window,
- &attributes, attributes_mask);
+ &attributes, attributes_mask);
gdk_window_set_user_data (vw->priv->event_window, widget);
@@ -263,19 +256,17 @@ gst_video_widget_unrealize (GtkWidget * widget)
/* Destroying event window */
- if (GDK_IS_WINDOW (vw->priv->event_window))
- {
- gdk_window_set_user_data (vw->priv->event_window, NULL);
- gdk_window_destroy (vw->priv->event_window);
- vw->priv->event_window = NULL;
- }
+ if (GDK_IS_WINDOW (vw->priv->event_window)) {
+ gdk_window_set_user_data (vw->priv->event_window, NULL);
+ gdk_window_destroy (vw->priv->event_window);
+ vw->priv->event_window = NULL;
+ }
- if (GDK_IS_WINDOW (vw->priv->video_window))
- {
- gdk_window_set_user_data (vw->priv->video_window, NULL);
- gdk_window_destroy (vw->priv->video_window);
- vw->priv->video_window = NULL;
- }
+ if (GDK_IS_WINDOW (vw->priv->video_window)) {
+ gdk_window_set_user_data (vw->priv->video_window, NULL);
+ gdk_window_destroy (vw->priv->video_window);
+ vw->priv->video_window = NULL;
+ }
/* Chaining up */
@@ -297,87 +288,75 @@ gst_video_widget_expose (GtkWidget * widget, GdkEventExpose * event)
vw = GST_VIDEO_WIDGET (widget);
- if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget))
- {
- if ((vw->priv->logo_focused) && (vw->priv->logo_pixbuf))
- {
- GdkPixbuf *frame;
- guchar *pixels;
- int rowstride;
- gint width, height, alloc_width, alloc_height, logo_x, logo_y;
- gfloat width_ratio, height_ratio;
-
- frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
- FALSE, 8, widget->allocation.width,
- widget->allocation.height);
-
- width = gdk_pixbuf_get_width (vw->priv->logo_pixbuf);
- height = gdk_pixbuf_get_height (vw->priv->logo_pixbuf);
- alloc_width = widget->allocation.width;
- alloc_height = widget->allocation.height;
-
- /* Checking if allocated space is smaller than our logo */
-
- if ((alloc_width < width) || (alloc_height < height))
- {
- width_ratio = (gfloat) alloc_width / (gfloat) width;
- height_ratio = (gfloat) alloc_height / (gfloat) height;
- width_ratio = MIN (width_ratio, height_ratio);
- height_ratio = width_ratio;
- }
- else
- width_ratio = height_ratio = 1.0;
-
- logo_x = (alloc_width / 2) - (width * width_ratio / 2);
- logo_y = (alloc_height / 2) - (height * height_ratio / 2);
-
- /* Scaling to available space */
-
- gdk_pixbuf_composite (vw->priv->logo_pixbuf,
- frame,
- 0, 0,
- alloc_width, alloc_height,
- logo_x, logo_y, width_ratio, height_ratio,
- GDK_INTERP_BILINEAR, 255);
-
- /* Drawing our frame */
-
- rowstride = gdk_pixbuf_get_rowstride (frame);
-
- pixels = gdk_pixbuf_get_pixels (frame) +
- rowstride * event->area.y + event->area.x * 3;
-
- gdk_draw_rgb_image_dithalign (widget->window,
- widget->style->black_gc,
- event->area.x, event->area.y,
- event->area.width, event->area.height,
- GDK_RGB_DITHER_NORMAL, pixels,
- rowstride, event->area.x,
- event->area.y);
-
- g_object_unref (frame);
- }
- else
- {
- gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
- event->area.x, event->area.y, event->area.width,
- event->area.height);
- }
+ if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_MAPPED (widget)) {
+ if ((vw->priv->logo_focused) && (vw->priv->logo_pixbuf)) {
+ GdkPixbuf *frame;
+ guchar *pixels;
+ int rowstride;
+ gint width, height, alloc_width, alloc_height, logo_x, logo_y;
+ gfloat width_ratio, height_ratio;
+
+ frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB,
+ FALSE, 8, widget->allocation.width, widget->allocation.height);
+
+ width = gdk_pixbuf_get_width (vw->priv->logo_pixbuf);
+ height = gdk_pixbuf_get_height (vw->priv->logo_pixbuf);
+ alloc_width = widget->allocation.width;
+ alloc_height = widget->allocation.height;
+
+ /* Checking if allocated space is smaller than our logo */
+ if ((alloc_width < width) || (alloc_height < height)) {
+ width_ratio = (gfloat) alloc_width / (gfloat) width;
+ height_ratio = (gfloat) alloc_height / (gfloat) height;
+ width_ratio = MIN (width_ratio, height_ratio);
+ height_ratio = width_ratio;
+ } else
+ width_ratio = height_ratio = 1.0;
+
+ logo_x = (alloc_width / 2) - (width * width_ratio / 2);
+ logo_y = (alloc_height / 2) - (height * height_ratio / 2);
+
+ /* Scaling to available space */
+
+ gdk_pixbuf_composite (vw->priv->logo_pixbuf,
+ frame,
+ 0, 0,
+ alloc_width, alloc_height,
+ logo_x, logo_y, width_ratio, height_ratio, GDK_INTERP_BILINEAR, 255);
+
+ /* Drawing our frame */
+
+ rowstride = gdk_pixbuf_get_rowstride (frame);
+
+ pixels = gdk_pixbuf_get_pixels (frame) +
+ rowstride * event->area.y + event->area.x * 3;
+
+ gdk_draw_rgb_image_dithalign (widget->window,
+ widget->style->black_gc,
+ event->area.x, event->area.y,
+ event->area.width, event->area.height,
+ GDK_RGB_DITHER_NORMAL, pixels,
+ rowstride, event->area.x, event->area.y);
+
+ g_object_unref (frame);
+ } else {
+ gdk_draw_rectangle (widget->window, widget->style->black_gc, TRUE,
+ event->area.x, event->area.y, event->area.width, event->area.height);
}
- if (GDK_IS_WINDOW (vw->priv->video_window))
- {
- gint pos_x, pos_y, width, height, depth;
-
- gdk_window_get_geometry (vw->priv->video_window, &pos_x, &pos_y,
- &width, &height, &depth);
- if ((width != vw->priv->video_window_width) ||
- (height != vw->priv->video_window_height))
- {
- gtk_widget_queue_resize (widget);
- }
+ }
+
+ if (GDK_IS_WINDOW (vw->priv->video_window)) {
+ gint pos_x, pos_y, width, height, depth;
+
+ gdk_window_get_geometry (vw->priv->video_window, &pos_x, &pos_y,
+ &width, &height, &depth);
+ if ((width != vw->priv->video_window_width) ||
+ (height != vw->priv->video_window_height)) {
+ gtk_widget_queue_resize (widget);
}
+ }
return FALSE;
}
@@ -385,8 +364,7 @@ gst_video_widget_expose (GtkWidget * widget, GdkEventExpose * event)
/* Size request for our widget */
static void
-gst_video_widget_size_request (GtkWidget * widget,
- GtkRequisition * requisition)
+gst_video_widget_size_request (GtkWidget * widget, GtkRequisition * requisition)
{
GstVideoWidget *vw;
gint width, height;
@@ -397,49 +375,40 @@ gst_video_widget_size_request (GtkWidget * widget,
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->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))
- {
- temp = (vw->priv->scale_factor * vw->priv->source_width + 0.5);
- width = (gint) temp > G_MAXINT ? G_MAXINT : (gint) temp;
- temp = (vw->priv->scale_factor * vw->priv->source_height + 0.5);
- height = (gint) temp > G_MAXINT ? G_MAXINT : (gint) temp;
-
- /* don't make us want to be bigger than the screen */
-
- if (width > gdk_screen_width ())
- {
- height = height * gdk_screen_width () / width;
- width = gdk_screen_width ();
- }
- if (height > gdk_screen_height ())
- {
- width = width * gdk_screen_height () / height;
- height = gdk_screen_height ();
- }
+ (vw->priv->source_height) && (vw->priv->scale_factor)) {
+ temp = (vw->priv->scale_factor * vw->priv->source_width + 0.5);
+ width = (gint) temp > G_MAXINT ? G_MAXINT : (gint) temp;
+ temp = (vw->priv->scale_factor * vw->priv->source_height + 0.5);
+ height = (gint) temp > G_MAXINT ? G_MAXINT : (gint) temp;
+
+ /* don't make us want to be bigger than the screen */
+
+ if (width > gdk_screen_width ()) {
+ height = height * gdk_screen_width () / width;
+ width = gdk_screen_width ();
}
- else
- {
- 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;
- height = 100;
- }
+ if (height > gdk_screen_height ()) {
+ width = width * gdk_screen_height () / height;
+ height = gdk_screen_height ();
+ }
+ } else {
+ 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;
+ height = 100;
}
+ }
if (width < vw->priv->width_mini)
width = vw->priv->width_mini;
@@ -466,30 +435,23 @@ gst_video_widget_allocate (GtkWidget * widget, GtkAllocation * allocation)
/* Choosing best ratio */
- if (vw->priv->scale_override)
- {
- /* Enforcing scale ratio taking the scale ratio from the priv structure */
- scale_factor = vw->priv->scale_factor;
- }
- else if (!vw->priv->auto_resize)
- {
- /* Calculating optimal ratio to fit the allocated window */
- if ((vw->priv->source_width) &&
- (vw->priv->source_height)
- && (GDK_IS_WINDOW (vw->priv->video_window)))
- {
- gfloat w_ratio, h_ratio;
-
- w_ratio = (gfloat) allocation->width / vw->priv->source_width;
- h_ratio = (gfloat) allocation->height / vw->priv->source_height;
-
- scale_factor = MIN (w_ratio, h_ratio);
- }
- }
- else
- {
- scale_factor = 1.0;
+ if (vw->priv->scale_override) {
+ /* Enforcing scale ratio taking the scale ratio from the priv structure */
+ scale_factor = vw->priv->scale_factor;
+ } else if (!vw->priv->auto_resize) {
+ /* Calculating optimal ratio to fit the allocated window */
+ if ((vw->priv->source_width) && (vw->priv->source_height)
+ && (GDK_IS_WINDOW (vw->priv->video_window))) {
+ gfloat w_ratio, h_ratio;
+
+ w_ratio = (gfloat) allocation->width / vw->priv->source_width;
+ h_ratio = (gfloat) allocation->height / vw->priv->source_height;
+
+ scale_factor = MIN (w_ratio, h_ratio);
}
+ } else {
+ scale_factor = 1.0;
+ }
/* Calculating width & height with optimal ratio */
@@ -500,76 +462,64 @@ gst_video_widget_allocate (GtkWidget * widget, GtkAllocation * allocation)
/* When auto resizing we change allocation to our geometry except if our
geometry violates the minimum one */
- 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 (vw->priv->auto_resize) {
+ if (width < vw->priv->width_mini) {
+ allocation->width = vw->priv->width_mini;
+ } else {
+ allocation->width = width;
}
- else
- { /* We do not want to shrink under our minimum geometry */
- 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;
+ if (height < vw->priv->height_mini) {
+ allocation->height = vw->priv->height_mini;
+ } else {
+ allocation->height = height;
}
+ } else { /* We do not want to shrink under our minimum geometry */
+ 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, allocation->y, allocation->width,
- allocation->height);
-
- if (GDK_IS_WINDOW (vw->priv->event_window))
- gdk_window_move_resize (vw->priv->event_window,
- 0, 0, allocation->width, allocation->height);
-
- /* X windows can only be resized to 1,1 not 0,0 so we have to handle
- the case where source size is 0,0 (not set basically). So instead
- of setting the video window to 0,0 we set it to 1,1 to match with
- what X will really do. If we don't do that we have an infinite loop
- with the expose event reacting on video window geometry changes. */
- if (!width)
- width = 1;
- if (!height)
- height = 1;
-
- vw->priv->video_window_width = width;
- vw->priv->video_window_height = height;
-
- if (GDK_IS_WINDOW (vw->priv->video_window))
- {
- gint video_x, video_y;
-
- video_x = (allocation->width / 2) - (width / 2);
- video_y = (allocation->height / 2) - (height / 2);
-
- gdk_window_move_resize (vw->priv->video_window,
- video_x, video_y, width, height);
- }
+ if (GTK_WIDGET_REALIZED (widget)) {
+ gdk_window_move_resize (widget->window,
+ allocation->x, allocation->y, allocation->width, allocation->height);
+
+ if (GDK_IS_WINDOW (vw->priv->event_window))
+ gdk_window_move_resize (vw->priv->event_window,
+ 0, 0, allocation->width, allocation->height);
+
+ /* X windows can only be resized to 1,1 not 0,0 so we have to handle
+ the case where source size is 0,0 (not set basically). So instead
+ of setting the video window to 0,0 we set it to 1,1 to match with
+ what X will really do. If we don't do that we have an infinite loop
+ with the expose event reacting on video window geometry changes. */
+ if (!width)
+ width = 1;
+ if (!height)
+ height = 1;
+
+ vw->priv->video_window_width = width;
+ vw->priv->video_window_height = height;
+
+ if (GDK_IS_WINDOW (vw->priv->video_window)) {
+ gint video_x, video_y;
+
+ video_x = (allocation->width / 2) - (width / 2);
+ video_y = (allocation->height / 2) - (height / 2);
+
+ gdk_window_move_resize (vw->priv->video_window,
+ video_x, video_y, width, height);
}
+ }
}
/* GstVideoWidget methods to set properties */
static void
gst_video_widget_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
+ const GValue * value, GParamSpec * pspec)
{
GstVideoWidget *vw;
@@ -577,8 +527,7 @@ gst_video_widget_set_property (GObject * object, guint prop_id,
vw = GST_VIDEO_WIDGET (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_SCALE_FACTOR:
vw->priv->scale_factor = g_value_get_float (value);
vw->priv->scale_override = TRUE;
@@ -607,25 +556,25 @@ gst_video_widget_set_property (GObject * object, guint prop_id,
vw->priv->source_height = g_value_get_int (value);
break;
case ARG_LOGO:
- {
- GdkPixbuf *image;
+ {
+ GdkPixbuf *image;
- image = (GdkPixbuf *) g_value_get_object (value);
+ image = (GdkPixbuf *) g_value_get_object (value);
- gst_video_widget_set_logo (vw, image);
- }
+ gst_video_widget_set_logo (vw, image);
+ }
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
/* GstVideoWidget methods to get properties */
static void
gst_video_widget_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
+ GValue * value, GParamSpec * pspec)
{
GstVideoWidget *vw;
@@ -633,8 +582,7 @@ gst_video_widget_get_property (GObject * object, guint prop_id,
vw = GST_VIDEO_WIDGET (object);
- switch (prop_id)
- {
+ switch (prop_id) {
case ARG_SCALE_FACTOR:
g_value_set_float (value, vw->priv->scale_factor);
break;
@@ -662,7 +610,7 @@ gst_video_widget_get_property (GObject * object, guint prop_id,
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
- }
+ }
}
/* =========================================== */
@@ -688,70 +636,57 @@ gst_video_widget_class_init (GstVideoWidgetClass * klass)
gobject_class->get_property = gst_video_widget_get_property;
g_object_class_install_property (gobject_class,
- ARG_SCALE_FACTOR,
- g_param_spec_float ("scale_factor",
- "scale factor",
- "size the video should be scaled to",
- 0,
- G_MAXFLOAT / G_MAXINT,
- 1, G_PARAM_READWRITE));
+ ARG_SCALE_FACTOR,
+ g_param_spec_float ("scale_factor",
+ "scale factor",
+ "size the video should be scaled to",
+ 0, G_MAXFLOAT / G_MAXINT, 1, G_PARAM_READWRITE));
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));
+ 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",
- "visible cursor",
- "Is the mouse pointer (cursor) visible or not",
- TRUE,
- G_PARAM_READWRITE));
+ ARG_VISIBLE_CURSOR,
+ g_param_spec_boolean ("visible_cursor",
+ "visible cursor",
+ "Is the mouse pointer (cursor) visible or not",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- ARG_LOGO_FOCUSED,
- g_param_spec_boolean ("logo_focused",
- "logo is focused",
- "Is the logo focused or not",
- TRUE,
- G_PARAM_READWRITE));
+ ARG_LOGO_FOCUSED,
+ g_param_spec_boolean ("logo_focused",
+ "logo is focused",
+ "Is the logo focused or not", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- ARG_EVENT_CATCHER,
- g_param_spec_boolean ("event_catcher",
- "Event catcher",
- "Should the widget catch events over the video window",
- TRUE,
- G_PARAM_READWRITE));
+ ARG_EVENT_CATCHER,
+ g_param_spec_boolean ("event_catcher",
+ "Event catcher",
+ "Should the widget catch events over the video window",
+ TRUE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- ARG_SOURCE_WIDTH,
- g_param_spec_int ("source_width",
- "video source width",
- "Video playback source width",
- 0, G_MAXINT, 1,
- G_PARAM_READWRITE));
+ ARG_SOURCE_WIDTH,
+ g_param_spec_int ("source_width",
+ "video source width",
+ "Video playback source width", 0, G_MAXINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- ARG_SOURCE_HEIGHT,
- g_param_spec_int ("source_height",
- "video source height",
- "Video playback source height",
- 0, G_MAXINT, 1,
- G_PARAM_READWRITE));
+ ARG_SOURCE_HEIGHT,
+ g_param_spec_int ("source_height",
+ "video source height",
+ "Video playback source height", 0, G_MAXINT, 1, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
- ARG_LOGO,
- g_param_spec_object ("logo",
- "Logo",
- "Picture that should appear as a logo when no video",
- gdk_pixbuf_get_type
- (),
- G_PARAM_READWRITE));
+ ARG_LOGO,
+ g_param_spec_object ("logo",
+ "Logo",
+ "Picture that should appear as a logo when no video",
+ gdk_pixbuf_get_type (), G_PARAM_READWRITE));
widget_class->realize = gst_video_widget_realize;
widget_class->unrealize = gst_video_widget_unrealize;
@@ -820,18 +755,17 @@ gst_video_widget_get_video_window (GstVideoWidget * vw)
**/
gboolean
gst_video_widget_set_source_size (GstVideoWidget * vw, guint width,
- guint height)
+ guint height)
{
g_return_val_if_fail (vw != NULL, FALSE);
g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE);
- if (vw->priv->source_width != width || vw->priv->source_height != height)
- {
- vw->priv->source_width = width;
- vw->priv->source_height = height;
- gtk_widget_queue_resize (GTK_WIDGET (vw));
- }
+ if (vw->priv->source_width != width || vw->priv->source_height != height) {
+ vw->priv->source_width = width;
+ vw->priv->source_height = height;
+ gtk_widget_queue_resize (GTK_WIDGET (vw));
+ }
return TRUE;
}
@@ -851,7 +785,7 @@ gst_video_widget_set_source_size (GstVideoWidget * vw, guint width,
**/
gboolean
gst_video_widget_get_source_size (GstVideoWidget * vw, guint * width,
- guint * height)
+ guint * height)
{
g_return_val_if_fail (vw != NULL, FALSE);
g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE);
@@ -881,8 +815,7 @@ gst_video_widget_get_source_size (GstVideoWidget * vw, guint * width,
* Return value: a #gboolean indicating wether the call succeeded or not.
**/
gboolean
-gst_video_widget_set_minimum_size (GstVideoWidget * vw, gint width,
- gint height)
+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);
@@ -909,7 +842,7 @@ gst_video_widget_set_minimum_size (GstVideoWidget * vw, gint width,
**/
gboolean
gst_video_widget_get_minimum_size (GstVideoWidget * vw, gint * width,
- gint * height)
+ gint * height)
{
g_return_val_if_fail (vw != NULL, FALSE);
g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE);
@@ -1017,8 +950,7 @@ gst_video_widget_get_logo_focus (GstVideoWidget * vw)
* Return value: a #gboolean indicating wether the call succeeded or not.
**/
gboolean
-gst_video_widget_set_event_catcher (GstVideoWidget * vw,
- gboolean event_catcher)
+gst_video_widget_set_event_catcher (GstVideoWidget * vw, gboolean event_catcher)
{
g_return_val_if_fail (vw != NULL, FALSE);
g_return_val_if_fail (GST_IS_VIDEO_WIDGET (vw), FALSE);
@@ -1228,23 +1160,21 @@ gst_video_widget_get_type (void)
{
static GType vw_type = 0;
- if (!vw_type)
- {
- static const GTypeInfo vw_info = {
- sizeof (GstVideoWidgetClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gst_video_widget_class_init,
- (GClassFinalizeFunc) NULL,
- NULL /* class_data */ ,
- sizeof (GstVideoWidget),
- 0 /* n_preallocs */ ,
- (GInstanceInitFunc) gst_video_widget_init,
- };
- vw_type = g_type_register_static (GTK_TYPE_WIDGET,
- "GstVideoWidget", &vw_info,
- (GTypeFlags) 0);
- }
+ if (!vw_type) {
+ static const GTypeInfo vw_info = {
+ sizeof (GstVideoWidgetClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gst_video_widget_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL /* class_data */ ,
+ sizeof (GstVideoWidget),
+ 0 /* n_preallocs */ ,
+ (GInstanceInitFunc) gst_video_widget_init,
+ };
+ vw_type = g_type_register_static (GTK_TYPE_WIDGET,
+ "GstVideoWidget", &vw_info, (GTypeFlags) 0);
+ }
return vw_type;
}
diff --git a/libcesarplayer/src/gstvideowidget.h b/libcesarplayer/src/gstvideowidget.h
index b11185c..12d2e02 100644
--- a/libcesarplayer/src/gstvideowidget.h
+++ b/libcesarplayer/src/gstvideowidget.h
@@ -67,48 +67,48 @@ GtkWidget *gst_video_widget_new (void);
/* Set/Get video source size */
gboolean gst_video_widget_set_source_size (GstVideoWidget * vw,
- guint width, guint height);
+ guint width, guint height);
gboolean gst_video_widget_get_source_size (GstVideoWidget * vw,
- guint * width, guint * height);
+ guint * width, guint * height);
/* Set/Get minimum video widget size */
gboolean gst_video_widget_set_minimum_size (GstVideoWidget * vw,
- gint width, gint height);
+ gint width, gint height);
gboolean gst_video_widget_get_minimum_size (GstVideoWidget * vw,
- gint * width, gint * height);
+ gint * width, gint * height);
/* Set/Get mouse pointer visible or not */
gboolean gst_video_widget_set_cursor_visible (GstVideoWidget * vw,
- gboolean visible);
+ gboolean visible);
gboolean gst_video_widget_get_cursor_visible (GstVideoWidget * vw);
/* Set/Get focus on logo or not */
gboolean gst_video_widget_set_logo_focus (GstVideoWidget * vw,
- gboolean focused);
+ gboolean focused);
gboolean gst_video_widget_get_logo_focus (GstVideoWidget * vw);
/* Set/Get if the widget should catch events over embeded window */
gboolean gst_video_widget_set_event_catcher (GstVideoWidget * vw,
- gboolean event_catcher);
+ 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 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 override);
gboolean gst_video_widget_set_scale (GstVideoWidget * vw, gfloat scale);
gfloat gst_video_widget_get_scale (GstVideoWidget * vw);
@@ -120,7 +120,6 @@ void gst_video_widget_set_logo (GstVideoWidget * vw, GdkPixbuf * logo_pixbuf);
GdkPixbuf *gst_video_widget_get_logo (GstVideoWidget * vw);
/*Force the expose callback*/
-void gst_video_widget_force_expose (GtkWidget * widget,
- GdkEventExpose * event);
+void gst_video_widget_force_expose (GtkWidget * widget, GdkEventExpose * event);
#endif /* __GST_VIDEO_WIDGET_H__ */
diff --git a/libcesarplayer/src/main.c b/libcesarplayer/src/main.c
index 58c8cc8..a2726fc 100644
--- a/libcesarplayer/src/main.c
+++ b/libcesarplayer/src/main.c
@@ -29,15 +29,14 @@
static int i = 0;
static gboolean
window_state_event (GtkWidget * widget, GdkEventWindowState * event,
- gpointer gvc)
+ gpointer gvc)
{
i++;
g_print ("%d\n", i);
- if (i == 3)
- {
- gst_video_capturer_rec (GST_VIDEO_CAPTURER (gvc));
+ if (i == 3) {
+ gst_video_capturer_rec (GST_VIDEO_CAPTURER (gvc));
- }
+ }
if (i == 5)
gst_video_capturer_stop (GST_VIDEO_CAPTURER (gvc));
return TRUE;
@@ -56,7 +55,7 @@ create_window (GstVideoCapturer * gvc)
gtk_window_set_title (GTK_WINDOW (window), "Capturer");
g_signal_connect (G_OBJECT (window), "window-state-event",
- G_CALLBACK (window_state_event), gvc);
+ G_CALLBACK (window_state_event), gvc);
return window;
diff --git a/libcesarplayer/src/video-utils.c b/libcesarplayer/src/video-utils.c
index 6ad1e48..ef8d619 100644
--- a/libcesarplayer/src/video-utils.c
+++ b/libcesarplayer/src/video-utils.c
@@ -82,17 +82,16 @@ totem_time_to_string (gint64 msecs)
time = time - (min * 60);
hour = time / (60 * 60);
- if (hour > 0)
- {
- /* hour:minutes:seconds */
- /* Translators: This is a time format, like "9:05:02" for 9
- * hours, 5 minutes, and 2 seconds. You may change ":" to
- * the separator that your locale uses or use "%Id" instead
- * of "%d" if your locale uses localized digits.
- */
- return g_strdup_printf (C_ ("long time format", "%d:%02d:%02d"), hour,
- min, sec);
- }
+ if (hour > 0) {
+ /* hour:minutes:seconds */
+ /* Translators: This is a time format, like "9:05:02" for 9
+ * hours, 5 minutes, and 2 seconds. You may change ":" to
+ * the separator that your locale uses or use "%Id" instead
+ * of "%d" if your locale uses localized digits.
+ */
+ return g_strdup_printf (C_ ("long time format", "%d:%02d:%02d"), hour,
+ min, sec);
+ }
/* minutes:seconds */
/* Translators: This is a time format, like "5:02" for 5
@@ -109,29 +108,22 @@ totem_string_to_time (const char *time_string)
int sec, min, hour, args;
args =
- sscanf (time_string, C_ ("long time format", "%d:%02d:%02d"), &hour, &min,
- &sec);
-
- if (args == 3)
- {
- /* Parsed all three arguments successfully */
- return (hour * (60 * 60) + min * 60 + sec) * 1000;
- }
- else if (args == 2)
- {
- /* Only parsed the first two arguments; treat hour and min as min and sec, respectively */
- return (hour * 60 + min) * 1000;
- }
- else if (args == 1)
- {
- /* Only parsed the first argument; treat hour as sec */
- return hour * 1000;
- }
- else
- {
- /* Error! */
- return -1;
- }
+ sscanf (time_string, C_ ("long time format", "%d:%02d:%02d"), &hour, &min,
+ &sec);
+
+ if (args == 3) {
+ /* Parsed all three arguments successfully */
+ return (hour * (60 * 60) + min * 60 + sec) * 1000;
+ } else if (args == 2) {
+ /* Only parsed the first two arguments; treat hour and min as min and sec, respectively */
+ return (hour * 60 + min) * 1000;
+ } else if (args == 1) {
+ /* Only parsed the first argument; treat hour as sec */
+ return hour * 1000;
+ } else {
+ /* Error! */
+ return -1;
+ }
}
char *
@@ -153,26 +145,19 @@ totem_time_to_string_text (gint64 msecs)
secs = g_strdup_printf (ngettext ("%d second", "%d seconds", sec), sec);
- if (hour > 0)
- {
- /* hour:minutes:seconds */
- string = g_strdup_printf (_("%s %s %s"), hours, mins, secs);
- }
- else if (min > 0)
- {
- /* minutes:seconds */
- string = g_strdup_printf (_("%s %s"), mins, secs);
- }
- else if (sec > 0)
- {
- /* seconds */
- string = g_strdup_printf (_("%s"), secs);
- }
- else
- {
- /* 0 seconds */
- string = g_strdup (_("0 seconds"));
- }
+ if (hour > 0) {
+ /* hour:minutes:seconds */
+ string = g_strdup_printf (_("%s %s %s"), hours, mins, secs);
+ } else if (min > 0) {
+ /* minutes:seconds */
+ string = g_strdup_printf (_("%s %s"), mins, secs);
+ } else if (sec > 0) {
+ /* seconds */
+ string = g_strdup_printf (_("%s"), secs);
+ } else {
+ /* 0 seconds */
+ string = g_strdup (_("0 seconds"));
+ }
g_free (hours);
g_free (mins);
@@ -198,8 +183,7 @@ cb_unset_size (gpointer data)
}
static void
-cb_set_preferred_size (GtkWidget * widget, GtkRequisition * req,
- gpointer data)
+cb_set_preferred_size (GtkWidget * widget, GtkRequisition * req, gpointer data)
{
TotemPrefSize *size = data;
@@ -219,14 +203,14 @@ totem_widget_set_preferred_size (GtkWidget * widget, gint width, gint height)
size->width = width;
size->height = height;
size->sig_id = g_signal_connect (widget, "size-request",
- G_CALLBACK (cb_set_preferred_size), size);
+ G_CALLBACK (cb_set_preferred_size), size);
gtk_widget_queue_resize (widget);
}
gboolean
totem_ratio_fits_screen (GdkWindow * video_window, int video_width,
- int video_height, gfloat ratio)
+ int video_height, gfloat ratio)
{
GdkRectangle fullscreen_rect;
int new_w, new_h;
@@ -240,14 +224,13 @@ totem_ratio_fits_screen (GdkWindow * video_window, int video_width,
screen = gdk_drawable_get_screen (GDK_DRAWABLE (video_window));
gdk_screen_get_monitor_geometry (screen,
- gdk_screen_get_monitor_at_window
- (screen, video_window), &fullscreen_rect);
+ gdk_screen_get_monitor_at_window
+ (screen, video_window), &fullscreen_rect);
if (new_w > (fullscreen_rect.width - 128) ||
- new_h > (fullscreen_rect.height - 128))
- {
- return FALSE;
- }
+ new_h > (fullscreen_rect.height - 128)) {
+ return FALSE;
+ }
return TRUE;
}
diff --git a/libcesarplayer/src/video-utils.h b/libcesarplayer/src/video-utils.h
index 7d330e8..db17113 100644
--- a/libcesarplayer/src/video-utils.h
+++ b/libcesarplayer/src/video-utils.h
@@ -14,6 +14,6 @@ gint64 totem_string_to_time (const char *time_string);
char *totem_time_to_string_text (gint64 msecs);
void totem_widget_set_preferred_size (GtkWidget * widget, gint width,
- gint height);
+ gint height);
gboolean totem_ratio_fits_screen (GdkWindow * window, int video_width,
- int video_height, gfloat ratio);
+ int video_height, gfloat ratio);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]