Various event updates and cleanups.

Original commit message from CVS:
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
This commit is contained in:
Wim Taymans 2005-07-27 18:37:25 +00:00
parent 03846ac272
commit a9166d4c28
7 changed files with 221 additions and 108 deletions

View file

@ -1,3 +1,28 @@
2005-07-27 Wim Taymans <wim@fluendo.com>
* ext/amrnb/amrnbparse.c: (gst_amrnbparse_event),
(gst_amrnbparse_loop):
* ext/dv/gstdvdec.c: (gst_dvdec_handle_sink_event),
(gst_dvdec_handle_src_event), (gst_dvdec_decode_frame):
* ext/mad/gstid3tag.c: (gst_id3_tag_src_event),
(gst_id3_tag_sink_event), (gst_id3_tag_chain):
* ext/mad/gstmad.c: (gst_mad_src_query), (index_seek),
(normal_seek), (gst_mad_sink_event), (gst_mad_chain):
* ext/mpeg2dec/gstmpeg2dec.c:
* ext/shout2/gstshout2.c: (gst_shout2send_event):
* ext/sidplay/gstsiddec.cc:
* gst/avi/gstavidemux.c: (gst_avi_demux_handle_src_event),
(gst_avi_demux_send_event), (gst_avi_demux_stream_header),
(gst_avi_demux_handle_seek), (gst_avi_demux_process_next_entry):
* gst/goom/gstgoom.c: (gst_goom_event):
* gst/realmedia/rmdemux.c: (gst_rmdemux_sink_event),
(gst_rmdemux_chain), (gst_rmdemux_send_event),
(gst_rmdemux_add_stream):
* gst/wavparse/gstwavparse.c: (gst_wavparse_handle_seek),
(gst_wavparse_stream_headers), (gst_wavparse_stream_data),
(gst_wavparse_loop), (gst_wavparse_srcpad_event):
Various event updates and cleanups.
2005-07-25 Christian Schaller <uraeus@gnome.org> 2005-07-25 Christian Schaller <uraeus@gnome.org>

View file

@ -243,7 +243,6 @@ gst_amrnbparse_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS: case GST_EVENT_EOS:
case GST_EVENT_DISCONTINUOUS:
default: default:
break; break;
} }
@ -430,7 +429,7 @@ need_pause:
eos: eos:
{ {
GST_LOG_OBJECT (amrnbparse, "pausing task"); GST_LOG_OBJECT (amrnbparse, "pausing task");
gst_pad_push_event (amrnbparse->srcpad, gst_event_new (GST_EVENT_EOS)); gst_pad_push_event (amrnbparse->srcpad, gst_event_new_eos ());
gst_pad_pause_task (pad); gst_pad_pause_task (pad);
return; return;
} }

View file

@ -466,44 +466,56 @@ static gboolean
gst_id3_tag_src_event (GstPad * pad, GstEvent * event) gst_id3_tag_src_event (GstPad * pad, GstEvent * event)
{ {
GstID3Tag *tag; GstID3Tag *tag;
gboolean res = FALSE;
tag = GST_ID3_TAG (gst_pad_get_parent (pad)); tag = GST_ID3_TAG (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_SEEK: case GST_EVENT_SEEK:
if (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_BYTES && {
gdouble rate;
GstFormat format;
GstSeekType cur_type, stop_type;
GstSeekFlags flags;
gint64 cur, stop;
gst_event_parse_seek (event, &rate, &format, &flags,
&cur_type, &cur, &stop_type, &stop);
if (format == GST_FORMAT_BYTES &&
tag->state == GST_ID3_TAG_STATE_NORMAL && tag->state == GST_ID3_TAG_STATE_NORMAL &&
GST_PAD_PEER (tag->sinkpad)) { gst_pad_is_linked (tag->sinkpad)) {
GstEvent *new; GstEvent *new;
gint diff = 0; gint diff = 0;
switch (GST_EVENT_SEEK_METHOD (event)) { switch (cur_type) {
case GST_SEEK_METHOD_SET: case GST_SEEK_TYPE_SET:
diff = tag->v2tag_size - tag->v2tag_size_new; diff = tag->v2tag_size - tag->v2tag_size_new;
break; break;
case GST_SEEK_METHOD_CUR: case GST_SEEK_TYPE_CUR:
break; break;
case GST_SEEK_METHOD_END: case GST_SEEK_TYPE_END:
diff = diff = cur ? tag->v1tag_size_new - tag->v1tag_size : 0;
GST_EVENT_SEEK_OFFSET (event) ? tag->v1tag_size_new -
tag->v1tag_size : 0;
break; break;
default: default:
g_assert_not_reached (); g_assert_not_reached ();
break; break;
} }
new = gst_event_new_seek (GST_EVENT_SEEK_TYPE (event), new = gst_event_new_seek (rate, format, flags,
GST_EVENT_SEEK_OFFSET (event) + diff); cur_type, cur + diff, stop_type, stop);
gst_event_unref (event); gst_pad_push_event (tag->sinkpad, new);
return gst_pad_push_event (tag->sinkpad, new); res = TRUE;
} }
break; break;
}
default: default:
break; break;
} }
gst_event_unref (event); gst_event_unref (event);
return FALSE; gst_object_unref (tag);
return res;
} }
GstTagList * GstTagList *
@ -773,7 +785,8 @@ gst_id3_tag_sink_event (GstPad * pad, GstEvent * event)
GstID3Tag *tag = GST_ID3_TAG (gst_pad_get_parent (pad)); GstID3Tag *tag = GST_ID3_TAG (gst_pad_get_parent (pad));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_NEWSEGMENT:
#if 0
switch (tag->state) { switch (tag->state) {
case GST_ID3_TAG_STATE_READING_V2_TAG:{ case GST_ID3_TAG_STATE_READING_V2_TAG:{
gint64 value, end_value; gint64 value, end_value;
@ -844,16 +857,22 @@ gst_id3_tag_sink_event (GstPad * pad, GstEvent * event)
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
#endif
break; break;
case GST_EVENT_TAG: case GST_EVENT_TAG:
{
GstTagList *list;
gst_event_parse_tag (event, &list);
if (tag->event_tags) { if (tag->event_tags) {
gst_tag_list_insert (tag->event_tags, gst_event_tag_get_list (event), gst_tag_list_insert (tag->event_tags, list, GST_TAG_MERGE_PREPEND);
GST_TAG_MERGE_PREPEND);
} else { } else {
tag->event_tags = gst_tag_list_copy (gst_event_tag_get_list (event)); tag->event_tags = gst_tag_list_copy (list);
} }
gst_event_unref (event); gst_event_unref (event);
break; break;
}
case GST_EVENT_EOS: case GST_EVENT_EOS:
if (tag->v1tag_render && IS_MUXER (tag)) { if (tag->v1tag_render && IS_MUXER (tag)) {
GstTagList *merged; GstTagList *merged;
@ -1088,19 +1107,21 @@ gst_id3_tag_chain (GstPad * pad, GstBuffer * buffer)
/* seek to beginning */ /* seek to beginning */
GST_LOG_OBJECT (tag, "seeking back to beginning"); GST_LOG_OBJECT (tag, "seeking back to beginning");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_NORMAL); gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_NORMAL);
#if 0
if (!gst_pad_push_event (tag->sinkpad, if (!gst_pad_push_event (tag->sinkpad,
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET | gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH, tag->v2tag_size))) { GST_SEEK_FLAG_FLUSH, tag->v2tag_size))) {
GST_ELEMENT_ERROR (tag, CORE, SEEK, (NULL), GST_ELEMENT_ERROR (tag, CORE, SEEK, (NULL),
("can't seek back to beginning from reading ID3v1 tag")); ("can't seek back to beginning from reading ID3v1 tag"));
} }
#endif
} else { } else {
gst_id3_tag_send_tag_event (tag); gst_id3_tag_send_tag_event (tag);
/* set eos, we're done parsing tags */ /* set eos, we're done parsing tags */
GST_LOG_OBJECT (tag, "setting EOS after reading ID3v1 tag"); GST_LOG_OBJECT (tag, "setting EOS after reading ID3v1 tag");
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL); gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL);
//gst_element_set_eos (GST_ELEMENT (tag)); //gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push_event (tag->srcpad, gst_event_new (GST_EVENT_EOS)); gst_pad_push_event (tag->srcpad, gst_event_new_eos ());
} }
return GST_FLOW_OK; return GST_FLOW_OK;
case GST_ID3_TAG_STATE_READING_V2_TAG: case GST_ID3_TAG_STATE_READING_V2_TAG:
@ -1164,12 +1185,14 @@ gst_id3_tag_chain (GstPad * pad, GstBuffer * buffer)
return GST_FLOW_OK; return GST_FLOW_OK;
/* seek to ID3v1 tag */ /* seek to ID3v1 tag */
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG); gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_SEEKING_TO_V1_TAG);
#if 0
if (gst_pad_push_event (tag->sinkpad, if (gst_pad_push_event (tag->sinkpad,
gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END | gst_event_new_seek (GST_FORMAT_BYTES | GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH, -128))) { GST_SEEK_FLAG_FLUSH, -128))) {
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_OK; return GST_FLOW_OK;
} }
#endif
gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL_START); gst_id3_tag_set_state (tag, GST_ID3_TAG_STATE_NORMAL_START);
/* fall through */ /* fall through */
case GST_ID3_TAG_STATE_NORMAL_START: case GST_ID3_TAG_STATE_NORMAL_START:
@ -1212,7 +1235,7 @@ gst_id3_tag_chain (GstPad * pad, GstBuffer * buffer)
if (tag->parse_mode == GST_ID3_TAG_PARSE_ANY) { if (tag->parse_mode == GST_ID3_TAG_PARSE_ANY) {
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
//gst_element_set_eos (GST_ELEMENT (tag)); //gst_element_set_eos (GST_ELEMENT (tag));
gst_pad_push_event (tag->srcpad, gst_event_new (GST_EVENT_EOS)); gst_pad_push_event (tag->srcpad, gst_event_new_eos ());
} else { } else {
if (GST_BUFFER_OFFSET_IS_VALID (buffer)) { if (GST_BUFFER_OFFSET_IS_VALID (buffer)) {
if (buffer->offset >= tag->v1tag_offset) { if (buffer->offset >= tag->v1tag_offset) {

View file

@ -638,6 +638,12 @@ error:
static gboolean static gboolean
index_seek (GstMad * mad, GstPad * pad, GstEvent * event) index_seek (GstMad * mad, GstPad * pad, GstEvent * event)
{ {
gdouble rate;
GstFormat format;
GstSeekFlags flags;
GstSeekType cur_type, stop_type;
gint64 cur, stop;
/* since we know the exact byteoffset of the frame, /* since we know the exact byteoffset of the frame,
make sure to try bytes first */ make sure to try bytes first */
@ -649,10 +655,12 @@ index_seek (GstMad * mad, GstPad * pad, GstEvent * event)
const GstFormat *try_formats = try_all_formats; const GstFormat *try_formats = try_all_formats;
const GstFormat *peer_formats; const GstFormat *peer_formats;
gst_event_parse_seek (event, &rate, &format, &flags,
&cur_type, &cur, &stop_type, &stop);
GstIndexEntry *entry = gst_index_get_assoc_entry (mad->index, mad->index_id, GstIndexEntry *entry = gst_index_get_assoc_entry (mad->index, mad->index_id,
GST_INDEX_LOOKUP_BEFORE, 0, GST_INDEX_LOOKUP_BEFORE, 0,
GST_EVENT_SEEK_FORMAT (event), format, cur);
GST_EVENT_SEEK_OFFSET (event));
GST_DEBUG ("index seek"); GST_DEBUG ("index seek");
@ -674,18 +682,17 @@ index_seek (GstMad * mad, GstPad * pad, GstEvent * event)
GST_DEBUG ("index %s %" G_GINT64_FORMAT GST_DEBUG ("index %s %" G_GINT64_FORMAT
" -> %s %" G_GINT64_FORMAT, " -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick, gst_format_get_details (format)->nick,
GST_EVENT_SEEK_OFFSET (event), cur, gst_format_get_details (*try_formats)->nick, value);
gst_format_get_details (*try_formats)->nick, value);
seek_event = gst_event_new_seek (*try_formats | seek_event = gst_event_new_seek (rate, *try_formats, flags,
GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, value); cur_type, value, stop_type, stop);
if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event)) { if (gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event)) {
/* seek worked, we're done, loop will exit */ /* seek worked, we're done, loop will exit */
mad->restart = TRUE; mad->restart = TRUE;
g_assert (GST_EVENT_SEEK_FORMAT (event) == GST_FORMAT_TIME); g_assert (format == GST_FORMAT_TIME);
mad->segment_start = GST_EVENT_SEEK_OFFSET (event); mad->segment_start = cur;
return TRUE; return TRUE;
} }
} }
@ -698,8 +705,13 @@ index_seek (GstMad * mad, GstPad * pad, GstEvent * event)
static gboolean static gboolean
normal_seek (GstMad * mad, GstPad * pad, GstEvent * event) normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
{ {
gint64 time_offset, bytes_offset; gdouble rate;
GstFormat format; GstFormat format, conv;
GstSeekFlags flags;
GstSeekType cur_type, stop_type;
gint64 cur, stop;
gint64 time_cur, time_stop;
gint64 bytes_cur, bytes_stop;
guint flush; guint flush;
/* const GstFormat *peer_formats; */ /* const GstFormat *peer_formats; */
@ -707,39 +719,46 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
GST_DEBUG ("normal seek"); GST_DEBUG ("normal seek");
format = GST_FORMAT_TIME; gst_event_parse_seek (event, &rate, &format, &flags,
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_TIME) { &cur_type, &cur, &stop_type, &stop);
if (!gst_mad_convert_src (pad, GST_EVENT_SEEK_FORMAT (event),
GST_EVENT_SEEK_OFFSET (event), &format, &time_offset)) { if (format != GST_FORMAT_TIME) {
/* probably unsupported seek format */ conv = GST_FORMAT_TIME;
GST_DEBUG ("failed to convert format %u into GST_FORMAT_TIME", if (!gst_mad_convert_src (pad, format, cur, &conv, &time_cur))
GST_EVENT_SEEK_FORMAT (event)); goto convert_error;
return FALSE; if (!gst_mad_convert_src (pad, format, stop, &conv, &time_stop))
} goto convert_error;
} else { } else {
time_offset = GST_EVENT_SEEK_OFFSET (event); time_cur = cur;
time_stop = stop;
} }
GST_DEBUG ("seek to time %" GST_TIME_FORMAT, GST_TIME_ARGS (time_offset)); GST_DEBUG ("seek to time %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
GST_TIME_ARGS (time_cur), GST_TIME_ARGS (time_stop));
/* shave off the flush flag, we'll need it later */ /* shave off the flush flag, we'll need it later */
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; flush = flags & GST_SEEK_FLAG_FLUSH;
/* assume the worst */ /* assume the worst */
res = FALSE; res = FALSE;
format = GST_FORMAT_BYTES; conv = GST_FORMAT_BYTES;
if (gst_mad_convert_sink (pad, GST_FORMAT_TIME, time_offset, if (!gst_mad_convert_sink (pad, GST_FORMAT_TIME, time_cur, &conv, &bytes_cur))
&format, &bytes_offset)) { goto convert_error;
if (!gst_mad_convert_sink (pad, GST_FORMAT_TIME, time_stop, &conv,
&bytes_stop))
goto convert_error;
{
GstEvent *seek_event; GstEvent *seek_event;
/* conversion succeeded, create the seek */ /* conversion succeeded, create the seek */
seek_event = seek_event =
gst_event_new_seek (format | GST_EVENT_SEEK_METHOD (event) | flush, gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, cur_type,
bytes_offset); bytes_cur, stop_type, bytes_stop);
/* do the seek */ /* do the seek */
res = gst_pad_send_event (GST_PAD_PEER (mad->sinkpad), seek_event); res = gst_pad_push_event (mad->sinkpad, seek_event);
} }
#if 0 #if 0
peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad)); peer_formats = gst_pad_get_formats (GST_PAD_PEER (mad->sinkpad));
@ -774,6 +793,14 @@ normal_seek (GstMad * mad, GstPad * pad, GstEvent * event)
#endif #endif
return res; return res;
/* ERRORS */
convert_error:
{
/* probably unsupported seek format */
GST_DEBUG ("failed to convert format %u into GST_FORMAT_TIME", format);
return FALSE;
}
} }
static gboolean static gboolean
@ -934,16 +961,20 @@ gst_mad_sink_event (GstPad * pad, GstEvent * event)
GST_DEBUG ("handling event %d", GST_EVENT_TYPE (event)); GST_DEBUG ("handling event %d", GST_EVENT_TYPE (event));
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_NEWSEGMENT:
/* this isn't really correct? */ /* this isn't really correct? */
GST_STREAM_LOCK (pad);
result = gst_pad_push_event (mad->srcpad, event); result = gst_pad_push_event (mad->srcpad, event);
mad->tempsize = 0; mad->tempsize = 0;
/* we don't need to restart when we get here */ /* we don't need to restart when we get here */
mad->restart = FALSE; mad->restart = FALSE;
GST_STREAM_UNLOCK (pad);
break; break;
case GST_EVENT_EOS: case GST_EVENT_EOS:
GST_STREAM_LOCK (pad);
mad->caps_set = FALSE; /* could be a new stream */ mad->caps_set = FALSE; /* could be a new stream */
result = gst_pad_push_event (mad->srcpad, event); result = gst_pad_push_event (mad->srcpad, event);
GST_STREAM_UNLOCK (pad);
break; break;
default: default:
result = gst_pad_push_event (mad->srcpad, event); result = gst_pad_push_event (mad->srcpad, event);

View file

@ -1024,9 +1024,10 @@ gst_mpeg2dec_chain (GstPad * pad, GstBuffer * buf)
} }
if (mpeg2dec->pending_event) { if (mpeg2dec->pending_event) {
done = done = TRUE;
GST_EVENT_SEEK_FLAGS (mpeg2dec-> #if 0
pending_event) & GST_SEEK_FLAG_FLUSH; GST_EVENT_SEEK_FLAGS (mpeg2dec->pending_event) & GST_SEEK_FLAG_FLUSH;
#endif
gst_mpeg2dec_src_event (mpeg2dec->srcpad, mpeg2dec->pending_event); gst_mpeg2dec_src_event (mpeg2dec->srcpad, mpeg2dec->pending_event);
mpeg2dec->pending_event = NULL; mpeg2dec->pending_event = NULL;
@ -1116,15 +1117,18 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
gboolean ret = TRUE; gboolean ret = TRUE;
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_NEWSEGMENT:
{ {
#if 0
gint64 time; gint64 time;
gint64 end_time; /* 0.9 just to call gint64 end_time; /* 0.9 just to call
gst_event_discont_get_value, non gst_event_discont_get_value, non
used anywhere else */ used anywhere else */
#endif
GST_STREAM_LOCK (pad); GST_STREAM_LOCK (pad);
#if 0
if (!gst_event_discont_get_value (event, GST_FORMAT_TIME, &time, if (!gst_event_discont_get_value (event, GST_FORMAT_TIME, &time,
&end_time) &end_time)
|| !GST_CLOCK_TIME_IS_VALID (time)) { || !GST_CLOCK_TIME_IS_VALID (time)) {
@ -1137,6 +1141,7 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
GST_TIME_FORMAT ")", mpeg2dec->next_time, GST_TIME_FORMAT ")", mpeg2dec->next_time,
GST_TIME_ARGS (mpeg2dec->next_time)); GST_TIME_ARGS (mpeg2dec->next_time));
} }
#endif
// what's hell is that // what's hell is that
/* /*
@ -1151,24 +1156,27 @@ gst_mpeg2dec_sink_event (GstPad * pad, GstEvent * event)
} }
*/ */
GST_STREAM_UNLOCK (pad);
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
GST_STREAM_UNLOCK (pad);
break; break;
} }
case GST_EVENT_FLUSH: case GST_EVENT_FLUSH_START:
{ ret = gst_pad_event_default (pad, event);
break;
case GST_EVENT_FLUSH_STOP:
GST_STREAM_LOCK (pad);
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE; mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
gst_mpeg2dec_flush_decoder (mpeg2dec); gst_mpeg2dec_flush_decoder (mpeg2dec);
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
GST_STREAM_UNLOCK (pad);
break; break;
}
case GST_EVENT_EOS: case GST_EVENT_EOS:
GST_STREAM_LOCK (pad); GST_STREAM_LOCK (pad);
if (mpeg2dec->index && mpeg2dec->closed) { if (mpeg2dec->index && mpeg2dec->closed) {
gst_index_commit (mpeg2dec->index, mpeg2dec->index_id); gst_index_commit (mpeg2dec->index, mpeg2dec->index_id);
} }
GST_STREAM_UNLOCK (pad);
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
GST_STREAM_UNLOCK (pad);
break; break;
default: default:
@ -1445,14 +1453,21 @@ index_seek (GstPad * pad, GstEvent * event)
{ {
GstIndexEntry *entry; GstIndexEntry *entry;
GstMpeg2dec *mpeg2dec; GstMpeg2dec *mpeg2dec;
gdouble rate;
GstFormat format;
GstSeekFlags flags;
GstSeekType cur_type, stop_type;
gint64 cur, stop;
mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad)); mpeg2dec = GST_MPEG2DEC (GST_PAD_PARENT (pad));
entry = gst_index_get_assoc_entry (mpeg2dec->index, mpeg2dec->index_id, gst_event_parse_seek (event, &rate, &format, &flags,
GST_INDEX_LOOKUP_BEFORE, GST_ASSOCIATION_FLAG_KEY_UNIT, &cur_type, &cur, &stop_type, &stop);
GST_EVENT_SEEK_FORMAT (event), GST_EVENT_SEEK_OFFSET (event));
if ((entry) && GST_PAD_PEER (mpeg2dec->sinkpad)) { entry = gst_index_get_assoc_entry (mpeg2dec->index, mpeg2dec->index_id,
GST_INDEX_LOOKUP_BEFORE, GST_ASSOCIATION_FLAG_KEY_UNIT, format, cur);
if ((entry) && gst_pad_is_linked (mpeg2dec->sinkpad)) {
const GstFormat *peer_formats, *try_formats; const GstFormat *peer_formats, *try_formats;
/* since we know the exact byteoffset of the frame, make sure to seek on bytes first */ /* since we know the exact byteoffset of the frame, make sure to seek on bytes first */
@ -1478,16 +1493,15 @@ index_seek (GstPad * pad, GstEvent * event)
GST_CAT_DEBUG (GST_CAT_SEEK, "index %s %" G_GINT64_FORMAT GST_CAT_DEBUG (GST_CAT_SEEK, "index %s %" G_GINT64_FORMAT
" -> %s %" G_GINT64_FORMAT, " -> %s %" G_GINT64_FORMAT,
gst_format_get_details (GST_EVENT_SEEK_FORMAT (event))->nick, gst_format_get_details (format)->nick,
GST_EVENT_SEEK_OFFSET (event), cur, gst_format_get_details (*try_formats)->nick, value);
gst_format_get_details (*try_formats)->nick, value);
/* lookup succeeded, create the seek */ /* lookup succeeded, create the seek */
seek_event = seek_event =
gst_event_new_seek (*try_formats | GST_SEEK_METHOD_SET | gst_event_new_seek (rate, *try_formats, flags, cur_type, value,
GST_SEEK_FLAG_FLUSH, value); stop_type, stop);
/* do the seek */ /* do the seek */
if (gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event)) { if (gst_pad_push_event (mpeg2dec->sinkpad, seek_event)) {
/* seek worked, we're done, loop will exit */ /* seek worked, we're done, loop will exit */
#if 0 #if 0
mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event); mpeg2dec->segment_start = GST_EVENT_SEEK_OFFSET (event);
@ -1505,9 +1519,14 @@ index_seek (GstPad * pad, GstEvent * event)
static gboolean static gboolean
normal_seek (GstPad * pad, GstEvent * event) normal_seek (GstPad * pad, GstEvent * event)
{ {
gint64 time_offset, bytes_offset;
GstFormat format;
guint flush; guint flush;
gdouble rate;
GstFormat format, conv;
GstSeekFlags flags;
GstSeekType cur_type, stop_type;
gint64 cur, stop;
gint64 time_cur, bytes_cur;
gint64 time_stop, bytes_stop;
GstMpeg2dec *mpeg2dec; GstMpeg2dec *mpeg2dec;
@ -1518,39 +1537,48 @@ normal_seek (GstPad * pad, GstEvent * event)
GST_DEBUG ("normal seek"); GST_DEBUG ("normal seek");
format = GST_FORMAT_TIME; gst_event_parse_seek (event, &rate, &format, &flags,
if (GST_EVENT_SEEK_FORMAT (event) != GST_FORMAT_TIME) { &cur_type, &cur, &stop_type, &stop);
if (!gst_mpeg2dec_src_convert (pad, GST_EVENT_SEEK_FORMAT (event),
GST_EVENT_SEEK_OFFSET (event), &format, &time_offset)) { conv = GST_FORMAT_TIME;
/* probably unsupported seek format */ if (format != GST_FORMAT_TIME) {
GST_DEBUG ("failed to convert format %u into GST_FORMAT_TIME", if (!gst_mpeg2dec_src_convert (pad, format, cur, &conv, &time_cur))
GST_EVENT_SEEK_FORMAT (event)); goto convert_failed;
return FALSE; if (!gst_mpeg2dec_src_convert (pad, format, stop, &conv, &time_stop))
} goto convert_failed;
} else { } else {
time_offset = GST_EVENT_SEEK_OFFSET (event); time_cur = cur;
time_stop = stop;
} }
GST_DEBUG ("seek to time %" GST_TIME_FORMAT, GST_TIME_ARGS (time_offset)); GST_DEBUG ("seek to time %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
GST_TIME_ARGS (time_cur), GST_TIME_ARGS (time_stop));
/* shave off the flush flag, we'll need it later */ /* shave off the flush flag, we'll need it later */
flush = GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH; flush = flags & GST_SEEK_FLAG_FLUSH;
/* assume the worst */ /* assume the worst */
res = FALSE; res = FALSE;
format = GST_FORMAT_BYTES; conv = GST_FORMAT_BYTES;
if (gst_mpeg2dec_sink_convert (pad, GST_FORMAT_TIME, time_offset, if (!gst_mpeg2dec_sink_convert (pad, GST_FORMAT_TIME, time_cur,
&format, &bytes_offset)) { &format, &bytes_cur))
goto convert_failed;
if (!gst_mpeg2dec_sink_convert (pad, GST_FORMAT_TIME, time_stop,
&format, &bytes_stop))
goto convert_failed;
{
GstEvent *seek_event; GstEvent *seek_event;
/* conversion succeeded, create the seek */ /* conversion succeeded, create the seek */
seek_event = seek_event =
gst_event_new_seek (format | GST_EVENT_SEEK_METHOD (event) | flush, gst_event_new_seek (rate, GST_FORMAT_BYTES, flags,
bytes_offset); cur_type, bytes_cur, stop_type, bytes_stop);
/* do the seek */ /* do the seek */
res = gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), seek_event); res = gst_pad_push_event (mpeg2dec->sinkpad, seek_event);
} }
#if 0 #if 0
@ -1591,6 +1619,14 @@ normal_seek (GstPad * pad, GstEvent * event)
#endif #endif
return res; return res;
/* ERRORS */
convert_failed:
{
/* probably unsupported seek format */
GST_DEBUG ("failed to convert format %u into GST_FORMAT_TIME", format);
return FALSE;
}
} }
@ -1623,11 +1659,7 @@ gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event)
break; break;
case GST_EVENT_NAVIGATION: case GST_EVENT_NAVIGATION:
/* Forward a navigation event unchanged */ /* Forward a navigation event unchanged */
if (GST_PAD_PEER (mpeg2dec->sinkpad)) return gst_pad_push_event (mpeg2dec->sinkpad, event);
return gst_pad_send_event (GST_PAD_PEER (mpeg2dec->sinkpad), event);
res = FALSE;
break;
default: default:
res = FALSE; res = FALSE;
break; break;
@ -1639,20 +1671,24 @@ gst_mpeg2dec_src_event (GstPad * pad, GstEvent * event)
static GstElementStateReturn static GstElementStateReturn
gst_mpeg2dec_change_state (GstElement * element) gst_mpeg2dec_change_state (GstElement * element)
{ {
GstElementStateReturn ret;
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element); GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (element);
switch (GST_STATE_TRANSITION (element)) { switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_NULL_TO_READY: case GST_STATE_NULL_TO_READY:
break; break;
case GST_STATE_READY_TO_PAUSED: case GST_STATE_READY_TO_PAUSED:
{
mpeg2dec->next_time = 0; mpeg2dec->next_time = 0;
gst_mpeg2dec_reset (mpeg2dec); gst_mpeg2dec_reset (mpeg2dec);
break; break;
}
case GST_STATE_PAUSED_TO_PLAYING: case GST_STATE_PAUSED_TO_PLAYING:
default:
break; break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
switch (GST_STATE_TRANSITION (element)) {
case GST_STATE_PLAYING_TO_PAUSED: case GST_STATE_PLAYING_TO_PAUSED:
break; break;
case GST_STATE_PAUSED_TO_READY: case GST_STATE_PAUSED_TO_READY:
@ -1663,8 +1699,7 @@ gst_mpeg2dec_change_state (GstElement * element)
default: default:
break; break;
} }
return ret;
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
} }
static void static void

View file

@ -466,7 +466,7 @@ gst_siddec_sink_event (GstPad * pad, GstEvent * event)
res = start_play_tune (siddec); res = start_play_tune (siddec);
GST_STREAM_UNLOCK (pad); GST_STREAM_UNLOCK (pad);
break; break;
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_NEWSEGMENT:
res = FALSE; res = FALSE;
break; break;
default: default:

View file

@ -268,8 +268,8 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_LOG_OBJECT (rmdemux, "handling event"); GST_LOG_OBJECT (rmdemux, "handling event");
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_DISCONTINUOUS: case GST_EVENT_NEWSEGMENT:
GST_DEBUG_OBJECT (rmdemux, "discontinuous event"); GST_DEBUG_OBJECT (rmdemux, "newsegment event");
gst_event_unref (event); gst_event_unref (event);
break; break;
default: default:
@ -465,8 +465,8 @@ gst_rmdemux_chain (GstPad * pad, GstBuffer * buffer)
rmdemux->have_pads = TRUE; rmdemux->have_pads = TRUE;
gst_rmdemux_send_event (rmdemux, gst_rmdemux_send_event (rmdemux,
gst_event_new_discontinuous (1.0, GST_FORMAT_TIME, (gint64) 0, gst_event_new_newsegment (1.0, GST_FORMAT_TIME, (gint64) 0,
(gint64) - 1, NULL)); (gint64) - 1, 0));
} }
/* The actual header is only 8 bytes */ /* The actual header is only 8 bytes */
@ -720,8 +720,8 @@ gst_rmdemux_add_stream (GstRMDemux * rmdemux, GstRMDemuxStream * stream)
gst_element_add_pad (GST_ELEMENT (rmdemux), stream->pad); gst_element_add_pad (GST_ELEMENT (rmdemux), stream->pad);
gst_pad_push_event (stream->pad, gst_pad_push_event (stream->pad,
gst_event_new_discontinuous (1.0, GST_FORMAT_TIME, (gint64) 0, gst_event_new_newsegment (1.0, GST_FORMAT_TIME, (gint64) 0,
(gint64) - 1, NULL)); (gint64) - 1, 0));
/* If there's some extra data then send it as the first packet */ /* If there's some extra data then send it as the first packet */
if (stream->extra_data_size > 0) { if (stream->extra_data_size > 0) {