+2005-07-27 Wim Taymans <wim@fluendo.com>
+
+ * 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 <rbultje@ronald.bitfreak.net>
* gst/videoscale/gstvideoscale.c: (gst_videoscale_prepare_images):
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);
}
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"));
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);
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);
{
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
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 "-%"
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);
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;
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
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++) {
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);
/* 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;
/* 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 */
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;
}
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));
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;
}
}
{
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
*
* 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;
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;
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)
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK:{
- gint64 value;
- GstFormat my_format = GST_FORMAT_TIME;
-
- /* 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);
-
- res = gst_pad_send_event (GST_PAD_PEER (dec->sinkpad), real_seek);
- }
+ 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
+ * 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);
+
gst_event_unref (event);
break;
}
}
return res;
+
+error:
+ gst_event_unref (event);
+ return res;
}
static gboolean
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
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 ();
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;
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);
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);
GST_STREAM_UNLOCK (self->sinkpad);
+ gst_object_unref (self);
+
return TRUE;
}
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;
}
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);
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;
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 =
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)) {
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);
}
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"));
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);
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);