From ee8ed3a89d406664a463ec8c9c6f69668e07b0f7 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 27 Jul 2005 18:34:29 +0000 Subject: [PATCH] examples/seeking/seek.c: Update seek example. Original commit message from CVS: * examples/seeking/seek.c: (setup_dynamic_link), (make_dv_pipeline), (make_vorbis_theora_pipeline), (query_rates), (query_positions_elems), (query_positions_pads), (do_seek): Update seek example. * ext/ogg/gstoggdemux.c: (gst_ogg_pad_event), (gst_ogg_pad_typefind), (gst_ogg_demux_chain_elem_pad), (gst_ogg_demux_queue_data), (gst_ogg_demux_chain_peer), (gst_ogg_pad_submit_packet), (gst_ogg_pad_submit_page), (gst_ogg_demux_handle_event), (gst_ogg_demux_deactivate_current_chain), (gst_ogg_demux_activate_chain), (gst_ogg_demux_perform_seek), (gst_ogg_demux_collect_chain_info), (gst_ogg_demux_collect_info), (gst_ogg_demux_chain), (gst_ogg_demux_send_event), (gst_ogg_demux_loop): * ext/ogg/gstoggmux.c: (gst_ogg_mux_collected): * ext/theora/theoradec.c: (theora_dec_src_event), (theora_dec_src_getcaps), (theora_dec_sink_event), (theora_dec_push), (theora_dec_chain): * ext/vorbis/Makefile.am: * ext/vorbis/vorbisdec.c: (vorbis_dec_src_event), (vorbis_dec_sink_event), (vorbis_dec_push), (vorbis_handle_data_packet): * ext/vorbis/vorbisenc.c: (gst_vorbisenc_sink_event), (gst_vorbisenc_chain): * gst/playback/gststreaminfo.c: (cb_probe): * gst/subparse/gstsubparse.c: (gst_subparse_src_event): * gst/videorate/gstvideorate.c: (gst_videorate_event): * gst/videoscale/gstvideoscale.c: (gst_videoscale_handle_src_event): * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_event): * sys/ximage/ximagesink.c: (gst_ximagesink_show_frame), (gst_ximagesink_navigation_send_event): * sys/xvimage/xvimagesink.c: (gst_xvimagesink_navigation_send_event): Various event updates and cleanups --- ChangeLog | 39 ++++++++++++++++++++++++++ examples/seeking/seek.c | 17 ++++++------ ext/ogg/gstoggdemux.c | 44 +++++++++++++++++------------- ext/ogg/gstoggmux.c | 2 +- ext/theora/theoradec.c | 27 +++++++++++------- ext/vorbis/Makefile.am | 2 ++ ext/vorbis/vorbisdec.c | 44 ++++++++++++++++++++++-------- ext/vorbis/vorbisenc.c | 7 +++-- gst/playback/gststreaminfo.c | 4 ++- gst/subparse/gstsubparse.c | 13 +++++++-- gst/videorate/gstvideorate.c | 11 +++++--- gst/videoscale/gstvideoscale.c | 3 +- gst/videotestsrc/gstvideotestsrc.c | 27 ++++++++++-------- sys/ximage/ximagesink.c | 3 +- sys/xvimage/xvimagesink.c | 3 +- tests/examples/seek/seek.c | 17 ++++++------ 16 files changed, 178 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0527eaf612..051ca3e392 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,42 @@ +2005-07-27 Wim Taymans + + * examples/seeking/seek.c: (setup_dynamic_link), + (make_dv_pipeline), (make_vorbis_theora_pipeline), (query_rates), + (query_positions_elems), (query_positions_pads), (do_seek): + Update seek example. + + * ext/ogg/gstoggdemux.c: (gst_ogg_pad_event), + (gst_ogg_pad_typefind), (gst_ogg_demux_chain_elem_pad), + (gst_ogg_demux_queue_data), (gst_ogg_demux_chain_peer), + (gst_ogg_pad_submit_packet), (gst_ogg_pad_submit_page), + (gst_ogg_demux_handle_event), + (gst_ogg_demux_deactivate_current_chain), + (gst_ogg_demux_activate_chain), (gst_ogg_demux_perform_seek), + (gst_ogg_demux_collect_chain_info), (gst_ogg_demux_collect_info), + (gst_ogg_demux_chain), (gst_ogg_demux_send_event), + (gst_ogg_demux_loop): + * ext/ogg/gstoggmux.c: (gst_ogg_mux_collected): + * ext/theora/theoradec.c: (theora_dec_src_event), + (theora_dec_src_getcaps), (theora_dec_sink_event), + (theora_dec_push), (theora_dec_chain): + * ext/vorbis/Makefile.am: + * ext/vorbis/vorbisdec.c: (vorbis_dec_src_event), + (vorbis_dec_sink_event), (vorbis_dec_push), + (vorbis_handle_data_packet): + * ext/vorbis/vorbisenc.c: (gst_vorbisenc_sink_event), + (gst_vorbisenc_chain): + * gst/playback/gststreaminfo.c: (cb_probe): + * gst/subparse/gstsubparse.c: (gst_subparse_src_event): + * gst/videorate/gstvideorate.c: (gst_videorate_event): + * gst/videoscale/gstvideoscale.c: + (gst_videoscale_handle_src_event): + * gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_event): + * sys/ximage/ximagesink.c: (gst_ximagesink_show_frame), + (gst_ximagesink_navigation_send_event): + * sys/xvimage/xvimagesink.c: + (gst_xvimagesink_navigation_send_event): + Various event updates and cleanups + 2005-07-27 Ronald S. Bultje * gst/videoscale/gstvideoscale.c: (gst_videoscale_prepare_images): diff --git a/examples/seeking/seek.c b/examples/seeking/seek.c index 7de7ae1bf3..5bd6ed6d2e 100644 --- a/examples/seeking/seek.c +++ b/examples/seeking/seek.c @@ -86,7 +86,7 @@ setup_dynamic_link (GstElement * element, const gchar * padname, connect->target = target; connect->bin = bin; - g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), + g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link), connect); } @@ -158,7 +158,6 @@ make_dv_pipeline (const gchar * location) rate_pads = g_list_prepend (rate_pads, seekable); seekable = gst_element_get_pad (decoder, "audio"); - seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink")); @@ -976,9 +975,11 @@ do_seek (GtkWidget * widget) g_print ("seek to %" GST_TIME_FORMAT " on pad %s:%s\n", GST_TIME_ARGS (real), GST_DEBUG_PAD_NAME (seekable)); - s_event = - gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + + + s_event = gst_event_new_seek (1.0, + GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_NONE, 0); res = gst_pad_send_event (seekable, s_event); @@ -993,9 +994,9 @@ do_seek (GtkWidget * widget) g_print ("seek to %" GST_TIME_FORMAT " on element %s\n", GST_TIME_ARGS (real), GST_ELEMENT_NAME (seekable)); - s_event = - gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + s_event = gst_event_new_seek (1.0, + GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_NONE, 0); res = gst_element_send_event (seekable, s_event); diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index a505618ca1..d026bfb0f3 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -389,6 +389,10 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event) { gboolean running; gboolean flush; + GstFormat format; + GstSeekFlags flags; + GstSeekType cur_type, stop_type; + gint64 cur, stop; /* can't seek if we are not seekable, FIXME could pass the * seek query upstream after converting it to bytes using @@ -398,17 +402,19 @@ gst_ogg_pad_event (GstPad * pad, GstEvent * event) GST_DEBUG ("seek on non seekable stream"); goto done_unref; } + gst_event_parse_seek (event, NULL, &format, &flags, + &cur_type, &cur, &stop_type, &stop); + /* we can only seek on time */ - if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_TIME) { + if (format != GST_FORMAT_TIME) { res = FALSE; GST_DEBUG ("can only seek on TIME"); goto done_unref; } - ogg->segment_start = GST_EVENT_SEEK_OFFSET (event); - ogg->segment_stop = GST_EVENT_SEEK_ENDOFFSET (event); - ogg->segment_play = - !!(GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_SEGMENT_LOOP); - flush = !!(GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_FLUSH); + ogg->segment_start = cur; + ogg->segment_stop = stop; + ogg->segment_play = !!(flags & GST_SEEK_FLAG_SEGMENT); + flush = !!(flags & GST_SEEK_FLAG_FLUSH); gst_event_unref (event); GST_DEBUG ("segment positions set to %" GST_TIME_FORMAT "-%" @@ -774,9 +780,9 @@ gst_ogg_pad_submit_packet (GstOggPad * pad, ogg_packet * packet) GstEvent *event; /* create the discont event we are going to send out */ - event = gst_event_new_discontinuous (1.0, + event = gst_event_new_newsegment (1.0, GST_FORMAT_TIME, (gint64) chain->start_time - chain->begin_time, - (gint64) chain->last_time - chain->begin_time, NULL); + (gint64) chain->last_time - chain->begin_time, (gint64) 0); gst_ogg_demux_activate_chain (ogg, chain, event); @@ -1082,8 +1088,8 @@ gst_ogg_demux_handle_event (GstPad * pad, GstEvent * event) GstOggDemux *ogg = GST_OGG_DEMUX (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_DISCONTINUOUS: - GST_DEBUG_OBJECT (ogg, "got a discont event"); + case GST_EVENT_NEWSEGMENT: + GST_DEBUG_OBJECT (ogg, "got a new segment event"); ogg_sync_reset (&ogg->sync); gst_event_unref (event); break; @@ -1266,7 +1272,7 @@ gst_ogg_demux_deactivate_current_chain (GstOggDemux * ogg) for (i = 0; i < chain->streams->len; i++) { GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, i); - gst_pad_push_event (GST_PAD (pad), gst_event_new (GST_EVENT_EOS)); + gst_pad_push_event (GST_PAD (pad), gst_event_new_eos ()); gst_element_remove_pad (GST_ELEMENT (ogg), GST_PAD (pad)); } /* if we cannot seek back to the chain, we can destroy the chain @@ -1361,7 +1367,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gboolean flush) if (flush) { gint i; - gst_pad_push_event (ogg->sinkpad, gst_event_new_flush (FALSE)); + gst_pad_push_event (ogg->sinkpad, gst_event_new_flush_start ()); GST_CHAIN_LOCK (ogg); for (i = 0; i < ogg->chains->len; i++) { @@ -1371,7 +1377,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gboolean flush) for (j = 0; j < chain->streams->len; j++) { GstOggPad *pad = g_array_index (chain->streams, GstOggPad *, j); - gst_pad_push_event (GST_PAD (pad), gst_event_new_flush (FALSE)); + gst_pad_push_event (GST_PAD (pad), gst_event_new_flush_start ()); } } GST_CHAIN_UNLOCK (ogg); @@ -1386,7 +1392,7 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gboolean flush) /* we need to stop flushing on the srcpad as we're going to use it * next. We can do this as we have the STREAM lock now. */ - gst_pad_push_event (ogg->sinkpad, gst_event_new_flush (TRUE)); + gst_pad_push_event (ogg->sinkpad, gst_event_new_flush_stop ()); { gint i; @@ -1543,12 +1549,12 @@ gst_ogg_demux_perform_seek (GstOggDemux * ogg, gboolean flush) /* we have to send the flush to the old chain, not the new one */ if (flush) - gst_ogg_demux_send_event (ogg, gst_event_new_flush (TRUE)); + gst_ogg_demux_send_event (ogg, gst_event_new_flush_stop ()); /* create the discont event we are going to send out */ - event = gst_event_new_discontinuous (1.0, + event = gst_event_new_newsegment (1.0, GST_FORMAT_TIME, (gint64) ogg->segment_start, - (gint64) ogg->segment_stop, NULL); + (gint64) ogg->segment_stop, 0); if (chain != ogg->current_chain) { /* switch to different chain, send discont on new chain */ @@ -2177,7 +2183,7 @@ gst_ogg_demux_loop (GstOggPad * pad) gst_element_post_message (GST_ELEMENT (ogg), gst_message_new_segment_done (GST_OBJECT (ogg), ogg->total_time)); } else { - gst_ogg_demux_send_event (ogg, gst_event_new (GST_EVENT_EOS)); + gst_ogg_demux_send_event (ogg, gst_event_new_eos ()); } goto pause; } @@ -2207,7 +2213,7 @@ pause: GST_LOG_OBJECT (ogg, "pausing task, reason %d", ret); gst_pad_pause_task (ogg->sinkpad); if (GST_FLOW_IS_FATAL (ret)) { - gst_ogg_demux_send_event (ogg, gst_event_new (GST_EVENT_EOS)); + gst_ogg_demux_send_event (ogg, gst_event_new_eos ()); GST_ELEMENT_ERROR (ogg, STREAM, STOPPED, ("stream stopped, reason %d", ret), ("stream stopped, reason %d", ret)); diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index 1d7d06558e..d158f5e9eb 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -935,7 +935,7 @@ gst_ogg_mux_collected (GstCollectPads * pads, GstOggMux * ogg_mux) ogg_mux->next_ts = GST_BUFFER_TIMESTAMP (ogg_mux->pulling->buffer); } else { /* no pad to pull on, send EOS */ - gst_pad_push_event (ogg_mux->srcpad, gst_event_new (GST_EVENT_EOS)); + gst_pad_push_event (ogg_mux->srcpad, gst_event_new_eos ()); return GST_FLOW_WRONG_STATE; } } diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c index d5d30c120c..9591f0ebbc 100644 --- a/ext/theora/theoradec.c +++ b/ext/theora/theoradec.c @@ -523,14 +523,21 @@ theora_dec_src_event (GstPad * pad, GstEvent * event) { gboolean res = TRUE; GstTheoraDec *dec; - GstFormat format; dec = GST_THEORA_DEC (GST_PAD_PARENT (pad)); switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK:{ - gint64 value; + GstFormat format, tformat; + gdouble rate; GstEvent *real_seek; + GstSeekFlags flags; + GstSeekType cur_type, stop_type; + gint64 cur, stop; + gint64 tcur, tstop; + + gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, + &stop_type, &stop); /* we have to ask our peer to seek to time here as we know * nothing about how to generate a granulepos from the src @@ -538,17 +545,17 @@ theora_dec_src_event (GstPad * pad, GstEvent * event) * * First bring the requested format to time */ - format = GST_FORMAT_TIME; - if (!(res = theora_dec_src_convert (pad, GST_EVENT_SEEK_FORMAT (event), - GST_EVENT_SEEK_OFFSET (event), &format, &value))) + tformat = GST_FORMAT_TIME; + if (!(res = theora_dec_src_convert (pad, format, cur, &tformat, &tcur))) + goto error; + if (!(res = theora_dec_src_convert (pad, format, stop, &tformat, &tstop))) goto error; /* then seek with time on the peer */ - real_seek = gst_event_new_seek ( - (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | - format, value); + real_seek = gst_event_new_seek (rate, GST_FORMAT_TIME, + flags, cur_type, tcur, stop_type, tstop); - res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek); + res = gst_pad_push_event (dec->sinkpad, real_seek); gst_event_unref (event); break; @@ -594,7 +601,7 @@ theora_dec_sink_event (GstPad * pad, GstEvent * event) ret = gst_pad_push_event (dec->srcpad, event); GST_STREAM_UNLOCK (pad); break; - case GST_EVENT_DISCONTINUOUS: + case GST_EVENT_NEWSEGMENT: GST_STREAM_LOCK (pad); dec->need_keyframe = TRUE; dec->granulepos = -1; diff --git a/ext/vorbis/Makefile.am b/ext/vorbis/Makefile.am index a31ad5e6ad..f6e505ec1c 100644 --- a/ext/vorbis/Makefile.am +++ b/ext/vorbis/Makefile.am @@ -3,11 +3,13 @@ plugin_LTLIBRARIES = libgstvorbis.la libgstvorbis_la_SOURCES = vorbis.c \ vorbisdec.c vorbisenc.c vorbisparse.c libgstvorbis_la_CFLAGS = $(GST_CFLAGS) $(VORBIS_CFLAGS) + ## AM_PATH_VORBIS also sets VORBISENC_LIBS libgstvorbis_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstvorbis_la_LIBADD = \ $(top_builddir)/gst-libs/gst/tag/libgsttagedit-@GST_MAJORMINOR@.la \ $(top_builddir)/gst-libs/gst/audio/libgstaudio-@GST_MAJORMINOR@.la \ + $(top_builddir)/gst-libs/gst/oggmapper/libgstoggmapper-@GST_MAJORMINOR@.la \ $(GST_LIBS) \ $(VORBIS_LIBS) $(VORBISENC_LIBS) diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index 66eb4f87b7..e5821e9509 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -341,19 +341,35 @@ vorbis_dec_src_event (GstPad * pad, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK:{ - gint64 value; - GstFormat my_format = GST_FORMAT_TIME; + GstFormat format, tformat; + gdouble rate; + GstEvent *real_seek; + GstSeekFlags flags; + GstSeekType cur_type, stop_type; + gint64 cur, stop; + gint64 tcur, tstop; - /* convert to time */ - res = vorbis_dec_convert (pad, GST_EVENT_SEEK_FORMAT (event), - GST_EVENT_SEEK_OFFSET (event), &my_format, &value); - if (res) { - GstEvent *real_seek = gst_event_new_seek ( - (GST_EVENT_SEEK_TYPE (event) & ~GST_SEEK_FORMAT_MASK) | - GST_FORMAT_TIME, value); + gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, + &stop_type, &stop); + + /* we have to ask our peer to seek to time here as we know + * nothing about how to generate a granulepos from the src + * formats or anything. + * + * First bring the requested format to time + */ + tformat = GST_FORMAT_TIME; + if (!(res = vorbis_dec_convert (pad, format, cur, &tformat, &tcur))) + goto error; + if (!(res = vorbis_dec_convert (pad, format, stop, &tformat, &tstop))) + goto error; + + /* then seek with time on the peer */ + real_seek = gst_event_new_seek (rate, GST_FORMAT_TIME, + flags, cur_type, tcur, stop_type, tstop); + + res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek); - res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek); - } gst_event_unref (event); break; } @@ -363,6 +379,10 @@ vorbis_dec_src_event (GstPad * pad, GstEvent * event) } return res; + +error: + gst_event_unref (event); + return res; } static gboolean @@ -380,7 +400,7 @@ vorbis_dec_sink_event (GstPad * pad, GstEvent * event) ret = gst_pad_push_event (dec->srcpad, event); GST_STREAM_UNLOCK (pad); break; - case GST_EVENT_DISCONTINUOUS: + case GST_EVENT_NEWSEGMENT: GST_STREAM_LOCK (pad); dec->granulepos = -1; #ifdef HAVE_VORBIS_SYNTHESIS_RESTART diff --git a/ext/vorbis/vorbisenc.c b/ext/vorbis/vorbisenc.c index 471a82f0e5..76b5ab4b88 100644 --- a/ext/vorbis/vorbisenc.c +++ b/ext/vorbis/vorbisenc.c @@ -838,7 +838,10 @@ gst_vorbisenc_sink_event (GstPad * pad, GstEvent * event) break; case GST_EVENT_TAG: if (vorbisenc->tags) { - gst_tag_list_insert (vorbisenc->tags, gst_event_tag_get_list (event), + GstTagList *list; + + gst_event_parse_tag (event, &list); + gst_tag_list_insert (vorbisenc->tags, list, gst_tag_setter_get_merge_mode (GST_TAG_SETTER (vorbisenc))); } else { g_assert_not_reached (); @@ -959,7 +962,7 @@ gst_vorbisenc_chain (GstPad * pad, GstBuffer * buffer) vorbis_block_clear (&vorbisenc->vb); vorbis_dsp_clear (&vorbisenc->vd); vorbis_info_clear (&vorbisenc->vi); - gst_pad_push_event (vorbisenc->srcpad, gst_event_new (GST_EVENT_EOS)); + gst_pad_push_event (vorbisenc->srcpad, gst_event_new_eos ()); //gst_element_set_eos (GST_ELEMENT (vorbisenc)); } return GST_FLOW_OK; diff --git a/gst/playback/gststreaminfo.c b/gst/playback/gststreaminfo.c index f3db83d1b2..23fe015c4b 100644 --- a/gst/playback/gststreaminfo.c +++ b/gst/playback/gststreaminfo.c @@ -179,7 +179,9 @@ cb_probe (GstPad * pad, GstEvent * e, gpointer user_data) if (GST_EVENT_TYPE (e) == GST_EVENT_TAG) { gchar *codec; //, *lang; - GstTagList *list = gst_event_tag_get_list (e); + GstTagList *list; + + gst_event_parse_tag (e, &list); if (gst_tag_list_get_string (list, GST_TAG_VIDEO_CODEC, &codec)) { g_free (info->codec); diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 241166a5a3..a295914892 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -172,13 +172,18 @@ static gboolean gst_subparse_src_event (GstPad * pad, GstEvent * event) { GstSubparse *self = GST_SUBPARSE (gst_pad_get_parent (pad)); + GstFormat format; + GstSeekType type; #define grvif(x,y) g_return_val_if_fail (x, y) - /* we guaranteed these with the eventmask */ grvif (GST_EVENT_TYPE (event) == GST_EVENT_SEEK, FALSE); - grvif (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_TIME, FALSE); - grvif (GST_EVENT_SEEK_METHOD (event) == GST_SEEK_METHOD_SET, FALSE); + + gst_event_parse_seek (event, NULL, &format, NULL, &type, NULL, NULL, NULL); + + /* we guaranteed these with the eventmask */ + grvif (format == GST_FORMAT_TIME, FALSE); + grvif (type == GST_SEEK_TYPE_SET, FALSE); gst_event_unref (event); @@ -190,6 +195,8 @@ gst_subparse_src_event (GstPad * pad, GstEvent * event) GST_STREAM_UNLOCK (self->sinkpad); + gst_object_unref (self); + return TRUE; } diff --git a/gst/videorate/gstvideorate.c b/gst/videorate/gstvideorate.c index 94d6c360af..42f1174f8b 100644 --- a/gst/videorate/gstvideorate.c +++ b/gst/videorate/gstvideorate.c @@ -380,15 +380,18 @@ gst_videorate_event (GstPad * pad, GstEvent * event) goto done; switch (GST_EVENT_TYPE (event)) { - case GST_EVENT_DISCONTINUOUS: + case GST_EVENT_NEWSEGMENT: { - gint64 start, end; + gint64 start, stop; + GstFormat format; GST_STREAM_LOCK (pad); - if (!(gst_event_discont_get_value (event, GST_FORMAT_TIME, &start, &end))) + gst_event_parse_newsegment (event, NULL, &format, &start, &stop, NULL); + + if (format != GST_FORMAT_TIME) { GST_WARNING ("Got discont but doesn't have GST_FORMAT_TIME value"); - else { + } else { gst_videorate_blank_data (videorate); videorate->first_ts = start; } diff --git a/gst/videoscale/gstvideoscale.c b/gst/videoscale/gstvideoscale.c index 5a77cb0ff1..a08e5568a9 100644 --- a/gst/videoscale/gstvideoscale.c +++ b/gst/videoscale/gstvideoscale.c @@ -603,7 +603,8 @@ gst_videoscale_handle_src_event (GstPad * pad, GstEvent * event) case GST_EVENT_NAVIGATION: event = GST_EVENT (gst_mini_object_make_writable (GST_MINI_OBJECT (event))); - structure = event->event_data.structure.structure; + + structure = (GstStructure *) gst_event_get_structure (event); if (gst_structure_get_double (structure, "pointer_x", &a)) { gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, a * videoscale->from_width / videoscale->to_width, NULL); diff --git a/gst/videotestsrc/gstvideotestsrc.c b/gst/videotestsrc/gstvideotestsrc.c index 10d183cdb3..e29e763f46 100644 --- a/gst/videotestsrc/gstvideotestsrc.c +++ b/gst/videotestsrc/gstvideotestsrc.c @@ -340,24 +340,27 @@ gst_videotestsrc_event (GstBaseSrc * bsrc, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_SEEK: { - switch (GST_EVENT_SEEK_FORMAT (event)) { + GstFormat format; + GstSeekType cur_type, stop_type; + GstSeekFlags flags; + gint64 cur, stop; + + gst_event_parse_seek (event, NULL, &format, &flags, &cur_type, &cur, + &stop_type, &stop); + + switch (format) { case GST_FORMAT_TIME: - new_n_frames = - GST_EVENT_SEEK_OFFSET (event) * (double) videotestsrc->rate / - GST_SECOND; + new_n_frames = cur * (double) videotestsrc->rate / GST_SECOND; videotestsrc->segment_start_frame = new_n_frames; videotestsrc->segment_end_frame = - GST_EVENT_SEEK_ENDOFFSET (event) * (double) videotestsrc->rate / - GST_SECOND; - videotestsrc->segment = - GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_SEGMENT_LOOP; + stop * (double) videotestsrc->rate / GST_SECOND; + videotestsrc->segment = flags & GST_SEEK_FLAG_SEGMENT; break; case GST_FORMAT_DEFAULT: - new_n_frames = GST_EVENT_SEEK_OFFSET (event); + new_n_frames = cur; videotestsrc->segment_start_frame = new_n_frames; - videotestsrc->segment_end_frame = GST_EVENT_SEEK_ENDOFFSET (event); - videotestsrc->segment = - GST_EVENT_SEEK_TYPE (event) & GST_SEEK_FLAG_SEGMENT_LOOP; + videotestsrc->segment_end_frame = stop; + videotestsrc->segment = flags & GST_SEEK_FLAG_SEGMENT; break; default: res = FALSE; diff --git a/sys/ximage/ximagesink.c b/sys/ximage/ximagesink.c index 80b4b36b9e..ba31d18641 100644 --- a/sys/ximage/ximagesink.c +++ b/sys/ximage/ximagesink.c @@ -1447,8 +1447,7 @@ gst_ximagesink_navigation_send_event (GstNavigation * navigation, GstXImageSink *ximagesink = GST_XIMAGESINK (navigation); GstEvent *event; - event = gst_event_new (GST_EVENT_NAVIGATION); - event->event_data.structure.structure = structure; + event = gst_event_new_custom (GST_EVENT_NAVIGATION, structure); g_mutex_lock (ximagesink->nav_lock); ximagesink->pend_nav_events = diff --git a/sys/xvimage/xvimagesink.c b/sys/xvimage/xvimagesink.c index e441d017bc..66c7c64637 100644 --- a/sys/xvimage/xvimagesink.c +++ b/sys/xvimage/xvimagesink.c @@ -1702,8 +1702,7 @@ gst_xvimagesink_navigation_send_event (GstNavigation * navigation, GstEvent *event; double x, y; - event = gst_event_new (GST_EVENT_NAVIGATION); - event->event_data.structure.structure = structure; + event = gst_event_new_custom (GST_EVENT_NAVIGATION, structure); /* Converting pointer coordinates to the non scaled geometry */ if (gst_structure_get_double (structure, "pointer_x", &x)) { diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c index 7de7ae1bf3..5bd6ed6d2e 100644 --- a/tests/examples/seek/seek.c +++ b/tests/examples/seek/seek.c @@ -86,7 +86,7 @@ setup_dynamic_link (GstElement * element, const gchar * padname, connect->target = target; connect->bin = bin; - g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), + g_signal_connect (G_OBJECT (element), "pad-added", G_CALLBACK (dynamic_link), connect); } @@ -158,7 +158,6 @@ make_dv_pipeline (const gchar * location) rate_pads = g_list_prepend (rate_pads, seekable); seekable = gst_element_get_pad (decoder, "audio"); - seekable_pads = g_list_prepend (seekable_pads, seekable); rate_pads = g_list_prepend (rate_pads, seekable); rate_pads = g_list_prepend (rate_pads, gst_element_get_pad (decoder, "sink")); @@ -976,9 +975,11 @@ do_seek (GtkWidget * widget) g_print ("seek to %" GST_TIME_FORMAT " on pad %s:%s\n", GST_TIME_ARGS (real), GST_DEBUG_PAD_NAME (seekable)); - s_event = - gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + + + s_event = gst_event_new_seek (1.0, + GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_NONE, 0); res = gst_pad_send_event (seekable, s_event); @@ -993,9 +994,9 @@ do_seek (GtkWidget * widget) g_print ("seek to %" GST_TIME_FORMAT " on element %s\n", GST_TIME_ARGS (real), GST_ELEMENT_NAME (seekable)); - s_event = - gst_event_new_seek (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, real); + s_event = gst_event_new_seek (1.0, + GST_FORMAT_TIME, + GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, real, GST_SEEK_TYPE_NONE, 0); res = gst_element_send_event (seekable, s_event);