[totem] Add reverse-frame-stepping to the movie player
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem] Add reverse-frame-stepping to the movie player
- Date: Thu, 12 Nov 2009 13:46:31 +0000 (UTC)
commit 57d551421a48f3b7bd08cefdadae0c0e8e46d0b3
Author: Bastien Nocera <hadess hadess net>
Date: Wed Nov 11 18:12:24 2009 +0000
Add reverse-frame-stepping to the movie player
** DEBUG version **
https://bugzilla.gnome.org/show_bug.cgi?id=595958
src/backend/bacon-video-widget-gst-0.10.c | 57 ++++++++++++++++++++++++++---
src/backend/bacon-video-widget.h | 1 +
src/totem-object.c | 6 +++-
3 files changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index 82e348e..6e8d645 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -3684,14 +3684,58 @@ bacon_video_widget_seek (BaconVideoWidget *bvw, double position, GError **error)
}
gboolean
-bacon_video_widget_step (BaconVideoWidget *bvw, GError **error)
+bacon_video_widget_step (BaconVideoWidget *bvw, gboolean forward, GError **error)
{
- GstEvent *event;
+ if (forward == TRUE) {
+ GstEvent *event;
- event = gst_event_new_step (GST_FORMAT_BUFFERS, 1, 1.0, TRUE, FALSE);
+ event = gst_event_new_step (GST_FORMAT_BUFFERS, 1, 1.0, TRUE, FALSE);
- gst_element_send_event (bvw->priv->play, event);
- return TRUE;
+ return gst_element_send_event (bvw->priv->play, event);
+ } else {
+ GstEvent *event;
+ GstFormat fmt;
+ gint64 cur = 0;
+
+ fmt = GST_FORMAT_TIME;
+ if (gst_element_query_position (bvw->priv->play, &fmt, &cur)) {
+ g_message ("playback direction to reverse (%"G_GINT64_FORMAT")", cur);
+ event = gst_event_new_seek (-1.0,
+ fmt, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, G_GINT64_CONSTANT (0),
+ GST_SEEK_TYPE_SET, cur);
+ if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
+ g_message ("failed to seek orig failed");
+ } else {
+ gst_element_get_state (bvw->priv->play, NULL, NULL, GST_CLOCK_TIME_NONE);
+ }
+ } else {
+ g_message ("failed to query orig position");
+ }
+
+ event = gst_event_new_step (GST_FORMAT_BUFFERS, 1, 1.0, TRUE, FALSE);
+ if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
+ g_message ("step failed");
+ } else {
+ gst_element_get_state (bvw->priv->play, NULL, NULL, GST_CLOCK_TIME_NONE);
+ }
+ fmt = GST_FORMAT_TIME;
+ cur = 0;
+ if (gst_element_query_position (bvw->priv->play, &fmt, &cur)) {
+ g_message ("playback direction to forward (%"G_GINT64_FORMAT")", cur);
+ event = gst_event_new_seek (1.0,
+ fmt, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, cur,
+ GST_SEEK_TYPE_SET, GST_CLOCK_TIME_NONE);
+ if (gst_element_send_event (bvw->priv->play, event) == FALSE) {
+ g_message ("failed to seek back failed");
+ } else {
+ gst_element_get_state (bvw->priv->play, NULL, NULL, GST_CLOCK_TIME_NONE);
+ }
+ } else {
+ g_message ("failed to query post position");
+ }
+ }
+
+ return FALSE;
}
static void
@@ -6019,7 +6063,7 @@ bacon_video_widget_get_current_frame (BaconVideoWidget * bvw)
/* 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, GST_CLOCK_TIME_NONE);
}
/* no video info */
@@ -6454,6 +6498,7 @@ bacon_video_widget_new (int width, int height,
g_object_unref (bvw);
return NULL;
}
+ g_object_set (bvw->priv->play, "flags", 0x00000015, NULL);
bvw->priv->bus = gst_element_get_bus (bvw->priv->play);
diff --git a/src/backend/bacon-video-widget.h b/src/backend/bacon-video-widget.h
index 8126cad..6ab9816 100644
--- a/src/backend/bacon-video-widget.h
+++ b/src/backend/bacon-video-widget.h
@@ -185,6 +185,7 @@ gboolean bacon_video_widget_seek_time (BaconVideoWidget *bvw,
gint64 _time,
GError **error);
gboolean bacon_video_widget_step (BaconVideoWidget *bvw,
+ gboolean forward,
GError **error);
gboolean bacon_video_widget_can_direct_seek (BaconVideoWidget *bvw);
double bacon_video_widget_get_position (BaconVideoWidget *bvw);
diff --git a/src/totem-object.c b/src/totem-object.c
index 0c4a9e5..bcb6b16 100644
--- a/src/totem-object.c
+++ b/src/totem-object.c
@@ -3537,9 +3537,13 @@ totem_action_handle_key_press (Totem *totem, GdkEventKey *event)
totem_action_play_pause (totem);
}
break;
+ case GDK_comma:
+ totem_action_pause (totem);
+ bacon_video_widget_step (totem->bvw, FALSE, NULL);
+ break;
case GDK_period:
totem_action_pause (totem);
- bacon_video_widget_step (totem->bvw, NULL);
+ bacon_video_widget_step (totem->bvw, TRUE, NULL);
break;
#ifdef HAVE_XFREE
case XF86XK_AudioPause:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]