mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
mpegtsmux: mpegtsmux_collected(): calculate PCR for programs
This commit is contained in:
parent
b67ed24676
commit
5b0b69a858
2 changed files with 23 additions and 15 deletions
|
@ -610,18 +610,6 @@ mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux)
|
||||||
|
|
||||||
best = mpegtsmux_choose_best_stream (mux);
|
best = mpegtsmux_choose_best_stream (mux);
|
||||||
|
|
||||||
if (mux->pcr_stream == NULL) {
|
|
||||||
if (best) {
|
|
||||||
/* Take the first data stream for the PCR */
|
|
||||||
GST_DEBUG_OBJECT (COLLECT_DATA_PAD (best), "Use stream as PCR");
|
|
||||||
mux->pcr_stream = best->stream;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the chosen PCR stream */
|
|
||||||
g_return_val_if_fail (mux->pcr_stream != NULL, GST_FLOW_ERROR);
|
|
||||||
tsmux_program_set_pcr_stream (mux->program, mux->pcr_stream);
|
|
||||||
|
|
||||||
if (!mpegtsdemux_prepare_srcpad (mux)) {
|
if (!mpegtsdemux_prepare_srcpad (mux)) {
|
||||||
GST_DEBUG_OBJECT (mux, "Failed to send new segment");
|
GST_DEBUG_OBJECT (mux, "Failed to send new segment");
|
||||||
goto new_seg_fail;
|
goto new_seg_fail;
|
||||||
|
@ -633,9 +621,29 @@ mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (best != NULL) {
|
if (best != NULL) {
|
||||||
|
TsMuxProgram *prog = best->prog;
|
||||||
GstBuffer *buf = best->queued_buf;
|
GstBuffer *buf = best->queued_buf;
|
||||||
gint64 pts = -1;
|
gint64 pts = -1;
|
||||||
|
|
||||||
|
if (prog == NULL) {
|
||||||
|
GST_ELEMENT_ERROR (mux, STREAM, MUX, ("Stream is not associated with "
|
||||||
|
"any program"), (NULL));
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (G_UNLIKELY (prog->pcr_stream == NULL)) {
|
||||||
|
if (best) {
|
||||||
|
MpegTsPadData *ts_data = (MpegTsPadData *) best;
|
||||||
|
/* Take the first data stream for the PCR */
|
||||||
|
GST_DEBUG_OBJECT (COLLECT_DATA_PAD (best),
|
||||||
|
"Use stream (pid=%d) from pad as PCR for program (prog_id = %d)",
|
||||||
|
ts_data->pid, ts_data->prog_id);
|
||||||
|
|
||||||
|
/* Set the chosen PCR stream */
|
||||||
|
tsmux_program_set_pcr_stream (prog, best->stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (COLLECT_DATA_PAD (best),
|
GST_DEBUG_OBJECT (COLLECT_DATA_PAD (best),
|
||||||
|
@ -657,8 +665,9 @@ mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux)
|
||||||
goto write_fail;
|
goto write_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mux->pcr_stream == best->stream) {
|
if (prog->pcr_stream == best->stream) {
|
||||||
mux->last_ts = best->last_ts;
|
/* FIXME: is this correct? */
|
||||||
|
mux->last_ts = best->last_ts; // how?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: Drain all remaining streams */
|
/* FIXME: Drain all remaining streams */
|
||||||
|
|
|
@ -113,7 +113,6 @@ struct MpegTsMux {
|
||||||
GstStructure *prog_map;
|
GstStructure *prog_map;
|
||||||
|
|
||||||
gboolean first;
|
gboolean first;
|
||||||
TsMuxStream *pcr_stream;
|
|
||||||
GstFlowReturn last_flow_ret;
|
GstFlowReturn last_flow_ret;
|
||||||
GstAdapter *adapter;
|
GstAdapter *adapter;
|
||||||
gint64 previous_pcr;
|
gint64 previous_pcr;
|
||||||
|
|
Loading…
Reference in a new issue