Check for seekability and use gst_pad_push() instead of gst_pad_send_event()

Original commit message from CVS:
Check for seekability and use gst_pad_push() instead of gst_pad_send_event()
This commit is contained in:
Ronald S. Bultje 2003-09-12 11:39:29 +00:00
parent f663868fcd
commit f04b1b7858

View file

@ -934,13 +934,27 @@ gst_avimux_write_index (GstAviMux *avimux)
avimux->avi_hdr.flags |= GST_RIFF_AVIH_HASINDEX;
}
static gboolean
gst_avimux_can_seek(GstAviMux *avimux)
{
const GstEventMask *masks = gst_pad_get_event_masks(GST_PAD_PEER(avimux->srcpad));
while (masks->type != 0) {
if (masks->type == GST_EVENT_SEEK) {
return TRUE;
}
}
return FALSE;
}
static void
gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
{
GstBuffer *header;
GstEvent *event;
if (avimux->is_bigfile)
if (avimux->is_bigfile && gst_avimux_can_seek(avimux))
{
/* sarch back */
event = gst_event_new_seek (GST_FORMAT_BYTES |
@ -948,7 +962,7 @@ gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
GST_SEEK_FLAG_FLUSH,
avimux->avix_start);
/* if the event succeeds */
if (gst_pad_send_event(GST_PAD_PEER(avimux->srcpad), event)) {
gst_pad_push(avimux->srcpad, GST_BUFFER(event));
/* rewrite AVIX header */
header = gst_avimux_riff_get_avix_header(avimux->datax_size);
@ -959,8 +973,7 @@ gst_avimux_bigfile(GstAviMux *avimux, gboolean last)
GST_SEEK_METHOD_SET |
GST_SEEK_FLAG_FLUSH,
avimux->total_data);
gst_pad_send_event(GST_PAD_PEER(avimux->srcpad), event);
}
gst_pad_push(avimux->srcpad, GST_BUFFER(event));
}
avimux->avix_start = avimux->total_data;
@ -1046,7 +1059,12 @@ gst_avimux_stop_file (GstAviMux *avimux)
if (avimux->audio_pad_connected) {
/* calculate bps if needed */
if (!avimux->auds.av_bps) {
if (avimux->audio_time) {
avimux->auds_hdr.rate = (GST_SECOND * avimux->audio_size) / avimux->audio_time;
} else {
gst_element_error (GST_ELEMENT (avimux), "Audio stream available, but no audio data transferred (or data with invalid timestamps). Resulting AVI will be corrupt");
avimux->auds_hdr.rate = 0;
}
avimux->auds.av_bps = avimux->auds_hdr.rate * avimux->auds_hdr.scale;
}
avimux->avi_hdr.max_bps += avimux->auds.av_bps;
@ -1058,6 +1076,7 @@ gst_avimux_stop_file (GstAviMux *avimux)
}
/* seek and rewrite the header */
if (gst_avimux_can_seek(avimux)) {
header = gst_avimux_riff_get_avi_header(avimux);
event = gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET, 0);
@ -1066,6 +1085,7 @@ gst_avimux_stop_file (GstAviMux *avimux)
event = gst_event_new_seek (GST_FORMAT_BYTES |
GST_SEEK_METHOD_SET, avimux->total_data);
gst_pad_push(avimux->srcpad, GST_BUFFER(event));
}
avimux->write_header = TRUE;
}
@ -1078,7 +1098,7 @@ gst_avimux_restart_file (GstAviMux *avimux)
gst_avimux_stop_file(avimux);
event = gst_event_new(GST_EVENT_EOS);
gst_pad_send_event(avimux->srcpad, event);
gst_pad_push(avimux->srcpad, GST_BUFFER(event));
gst_avimux_start_file(avimux);
}