Try to resolve all synchronization issues, not only the first

This commit is contained in:
Sebastian Dröge 2009-02-04 10:19:51 +01:00
parent c4a0bc9887
commit a79c4e0314

View file

@ -2485,50 +2485,48 @@ gst_mxf_demux_pull_and_handle_klv_packet (GstMXFDemux * demux)
demux->offset += read; demux->offset += read;
if (ret == GST_FLOW_OK && demux->src && demux->essence_tracks) { if (ret == GST_FLOW_OK && demux->src && demux->essence_tracks) {
guint i;
GstMXFDemuxPad *earliest = NULL; GstMXFDemuxPad *earliest = NULL;
guint64 offset;
gint64 position;
earliest = gst_mxf_demux_get_earliest_pad (demux);
if (!earliest)
goto beach;
/* We allow time drifts of at most 500ms */ /* We allow time drifts of at most 500ms */
if (demux->segment.last_stop - earliest->last_stop <= 500 * GST_MSECOND) while ((earliest = gst_mxf_demux_get_earliest_pad (demux)) &&
goto beach; demux->segment.last_stop - earliest->last_stop > 500 * GST_MSECOND) {
guint i;
guint64 offset;
gint64 position;
GST_WARNING_OBJECT (demux, GST_WARNING_OBJECT (demux,
"Found synchronization issue -- trying to solve"); "Found synchronization issue -- trying to solve");
position = earliest->current_essence_track_position; position = earliest->current_essence_track_position;
/* FIXME: This can probably be improved by using the /* FIXME: This can probably be improved by using the
* offset of position-1 if it's in the same partition * offset of position-1 if it's in the same partition
* or the start of the position otherwise. * or the start of the position otherwise.
* This way we won't skip elements from the same essence * This way we won't skip elements from the same essence
* container as etrack->position * container as etrack->position
*/ */
offset = offset =
gst_mxf_demux_find_essence_element (demux, gst_mxf_demux_find_essence_element (demux,
earliest->current_essence_track, &position, FALSE); earliest->current_essence_track, &position, FALSE);
if (offset == -1) { if (offset == -1) {
GST_ERROR_OBJECT (demux, "Failed to find offset for late essence track"); GST_ERROR_OBJECT (demux,
earliest->eos = TRUE; "Failed to find offset for late essence track");
gst_pad_push_event (GST_PAD_CAST (earliest), gst_event_new_eos ()); earliest->eos = TRUE;
goto beach; gst_pad_push_event (GST_PAD_CAST (earliest), gst_event_new_eos ());
continue;
}
demux->offset = offset + demux->run_in;
gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
for (i = 0; i < demux->essence_tracks->len; i++) {
GstMXFDemuxEssenceTrack *etrack =
&g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
etrack->position = -1;
}
earliest->current_essence_track->position = position;
break;
} }
demux->offset = offset + demux->run_in;
gst_mxf_demux_set_partition_for_offset (demux, demux->offset);
for (i = 0; i < demux->essence_tracks->len; i++) {
GstMXFDemuxEssenceTrack *etrack =
&g_array_index (demux->essence_tracks, GstMXFDemuxEssenceTrack, i);
etrack->position = -1;
}
earliest->current_essence_track->position = position;
} }
beach: beach: