From 5dc30ab5210837443a253e2b829e25814dc01a34 Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Fri, 18 Jun 2004 22:32:44 +0000 Subject: [PATCH] ext/dvdnav/gst-dvd: Grab the gconf key from the right spot Original commit message from CVS: * ext/dvdnav/gst-dvd: Grab the gconf key from the right spot * gst/debug/gstnavseek.c: (gst_navseek_init), (gst_navseek_segseek), (gst_navseek_handle_src_event), (gst_navseek_chain): * gst/debug/gstnavseek.h: Add 's', 'e' and 'l' keypresses to navseek to define the start,end and loop parameters of a segment seek. * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_init), (gst_videotestsrc_get_event_masks), (gst_videotestsrc_handle_src_event), (gst_videotestsrc_get): * gst/videotestsrc/gstvideotestsrc.h: Add seeking support to videotestsrc Initialise the timestamp_offset variable. --- ChangeLog | 16 ++++++++++++ gst/debug/gstnavseek.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++- gst/debug/gstnavseek.h | 5 ++++ 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 663126f..69908e3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2004-06-19 Jan Schmidt + * ext/dvdnav/gst-dvd: + Grab the gconf key from the right spot + * gst/debug/gstnavseek.c: (gst_navseek_init), + (gst_navseek_segseek), (gst_navseek_handle_src_event), + (gst_navseek_chain): + * gst/debug/gstnavseek.h: + Add 's', 'e' and 'l' keypresses to navseek to define the start,end + and loop parameters of a segment seek. + * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_init), + (gst_videotestsrc_get_event_masks), + (gst_videotestsrc_handle_src_event), (gst_videotestsrc_get): + * gst/videotestsrc/gstvideotestsrc.h: + Add seeking support to videotestsrc + Initialise the timestamp_offset variable. + 2004-06-18 Wim Taymans * ext/sidplay/gstsiddec.cc: diff --git a/gst/debug/gstnavseek.c b/gst/debug/gstnavseek.c index 476fa83..6e75834 100644 --- a/gst/debug/gstnavseek.c +++ b/gst/debug/gstnavseek.c @@ -145,7 +145,14 @@ gst_navseek_init (GTypeInstance * instance, gpointer g_class) gst_pad_set_getcaps_function (navseek->srcpad, gst_pad_proxy_getcaps); gst_pad_set_event_function (navseek->srcpad, gst_navseek_handle_src_event); + GST_FLAG_SET (GST_ELEMENT (navseek), GST_ELEMENT_EVENT_AWARE); + navseek->seek_offset = 5.0; + navseek->loop = FALSE; + navseek->grab_seg_start = FALSE; + navseek->grab_seg_end = FALSE; + navseek->segment_start = GST_CLOCK_TIME_NONE; + navseek->segment_end = GST_CLOCK_TIME_NONE; } static void @@ -170,6 +177,32 @@ gst_navseek_seek (GstNavSeek * navseek, gint64 offset) } } +static void +gst_navseek_segseek (GstNavSeek * navseek) +{ + GstEvent *event; + + if ((navseek->segment_start == GST_CLOCK_TIME_NONE) || + (navseek->segment_end == GST_CLOCK_TIME_NONE) || + (!GST_PAD_IS_LINKED (navseek->sinkpad))) { + return; + } + + if (navseek->loop) { + event = + gst_event_new_segment_seek (GST_SEEK_METHOD_SET | GST_FORMAT_TIME | + GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_SEGMENT_LOOP, + navseek->segment_start, navseek->segment_end); + } else { + event = + gst_event_new_segment_seek (GST_SEEK_METHOD_SET | GST_FORMAT_TIME | + GST_SEEK_FLAG_ACCURATE, navseek->segment_start, navseek->segment_end); + } + + g_return_if_fail (event != NULL); + gst_pad_send_event (gst_pad_get_peer (navseek->sinkpad), event); +} + static gboolean gst_navseek_handle_src_event (GstPad * pad, GstEvent * event) { @@ -199,6 +232,16 @@ gst_navseek_handle_src_event (GstPad * pad, GstEvent * event) } else if (strcmp (key, "Right") == 0) { /* Seek forward */ gst_navseek_seek (navseek, navseek->seek_offset * GST_SECOND); + } else if (strcmp (key, "s") == 0) { + /* Grab the next frame as the start frame of a segment */ + navseek->grab_seg_start = TRUE; + } else if (strcmp (key, "e") == 0) { + /* Grab the next frame as the end frame of a segment */ + navseek->grab_seg_end = TRUE; + } else if (strcmp (key, "l") == 0) { + /* Toggle the loop flag. If we have both start and end segment times send a seek */ + navseek->loop = !navseek->loop; + gst_navseek_segseek (navseek); } } else { break; @@ -210,7 +253,7 @@ gst_navseek_handle_src_event (GstPad * pad, GstEvent * event) default: break; } - if (event) { + if ((event) && GST_PAD_IS_LINKED (navseek->sinkpad)) { return gst_pad_send_event (gst_pad_get_peer (navseek->sinkpad), event); } return TRUE; @@ -259,6 +302,28 @@ gst_navseek_chain (GstPad * pad, GstData * _data) GstNavSeek *navseek; navseek = GST_NAVSEEK (gst_pad_get_parent (pad)); + + if (GST_IS_BUFFER (_data) && + GST_BUFFER_TIMESTAMP_IS_VALID (GST_BUFFER (_data))) { + if (navseek->grab_seg_start) { + navseek->segment_start = GST_BUFFER_TIMESTAMP (GST_BUFFER (_data)); + navseek->segment_end = GST_CLOCK_TIME_NONE; + navseek->grab_seg_start = FALSE; + } + + if (navseek->grab_seg_end) { + navseek->segment_end = GST_BUFFER_TIMESTAMP (GST_BUFFER (_data)); + navseek->grab_seg_end = FALSE; + gst_navseek_segseek (navseek); + } + } + + if (GST_IS_EVENT (_data) && + (GST_EVENT_TYPE (GST_EVENT (_data)) == GST_EVENT_SEGMENT_DONE) && + navseek->loop) { + gst_navseek_segseek (navseek); + } + gst_pad_push (navseek->srcpad, _data); } diff --git a/gst/debug/gstnavseek.h b/gst/debug/gstnavseek.h index 27a2723..c4eb1bd 100644 --- a/gst/debug/gstnavseek.h +++ b/gst/debug/gstnavseek.h @@ -46,6 +46,11 @@ struct _GstNavSeek { GstPad *srcpad; gdouble seek_offset; + gboolean loop; + gboolean grab_seg_start; + gboolean grab_seg_end; + GstClockTime segment_start; + GstClockTime segment_end; }; struct _GstNavSeekClass { -- 2.7.4