mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-24 02:31:03 +00:00
mpegts: Only use timestamp-based PCR/PTS estimation when needed
When dealing with non-time based push-mode streams, we need to revert to using the offset-based PCR/PTS estimation logic of packetizer. This solves uses cases such as: pushfile:// ! tsdemux src ! queue ! tsdemux https://bugzilla.gnome.org/show_bug.cgi?id=687178
This commit is contained in:
parent
b2e65fd575
commit
651203de07
2 changed files with 12 additions and 2 deletions
|
@ -1340,6 +1340,14 @@ mpegts_base_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_SEGMENT:
|
||||
gst_event_copy_segment (event, &base->segment);
|
||||
/* Check if we need to switch PCR/PTS handling */
|
||||
if (base->segment.format == GST_FORMAT_TIME) {
|
||||
base->packetizer->calculate_offset = FALSE;
|
||||
base->packetizer->calculate_skew = TRUE;
|
||||
} else {
|
||||
base->packetizer->calculate_offset = TRUE;
|
||||
base->packetizer->calculate_skew = FALSE;
|
||||
}
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
case GST_EVENT_STREAM_START:
|
||||
|
@ -1779,13 +1787,14 @@ mpegts_base_sink_activate_mode (GstPad * pad, GstObject * parent,
|
|||
switch (mode) {
|
||||
case GST_PAD_MODE_PUSH:
|
||||
base->mode = BASE_MODE_PUSHING;
|
||||
base->packetizer->calculate_skew = TRUE;
|
||||
res = TRUE;
|
||||
break;
|
||||
case GST_PAD_MODE_PULL:
|
||||
if (active) {
|
||||
base->mode = BASE_MODE_SCANNING;
|
||||
/* When working pull-based, we always use offsets for estimation */
|
||||
base->packetizer->calculate_offset = TRUE;
|
||||
base->packetizer->calculate_skew = FALSE;
|
||||
res =
|
||||
gst_pad_start_task (pad, (GstTaskFunction) mpegts_base_loop, base,
|
||||
NULL);
|
||||
|
|
|
@ -3672,7 +3672,8 @@ mpegts_packetizer_pts_to_ts (MpegTSPacketizer2 * packetizer, GstClockTime pts,
|
|||
if (G_UNLIKELY (pts < pcrtable->first_pcr_ts))
|
||||
pts += MPEGTIME_TO_GSTTIME (PTS_DTS_MAX_VALUE);
|
||||
res = pts - pcrtable->first_pcr_ts;
|
||||
}
|
||||
} else
|
||||
GST_WARNING ("Not enough information to calculate proper timestamp");
|
||||
|
||||
GST_DEBUG ("Returning timestamp %" GST_TIME_FORMAT " for pts %"
|
||||
GST_TIME_FORMAT " pcr_pid:0x%04x", GST_TIME_ARGS (res),
|
||||
|
|
Loading…
Reference in a new issue