tsmux: Slightly reflow collected buffer handler for clarity.

This commit is contained in:
Jan Schmidt 2012-10-22 12:36:28 +11:00
parent 43938bbf54
commit 119c27c9b9

View file

@ -1039,6 +1039,11 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
{ {
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
MpegTsPadData *best = (MpegTsPadData *) data; MpegTsPadData *best = (MpegTsPadData *) data;
TsMuxProgram *prog;
gint64 pts = -1;
guint64 dts = -1;
gboolean delta = TRUE;
StreamData *stream_data;
GST_DEBUG_OBJECT (mux, "Pads collected"); GST_DEBUG_OBJECT (mux, "Pads collected");
@ -1052,13 +1057,17 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
mux->first = FALSE; mux->first = FALSE;
} }
if (best != NULL) { if (G_UNLIKELY (best == NULL)) {
TsMuxProgram *prog = best->prog; /* EOS */
gint64 pts = -1; /* drain some possibly cached data */
guint64 dts = -1; new_packet_m2ts (mux, NULL, -1);
gboolean delta = TRUE; mpegtsmux_push_packets (mux, TRUE);
StreamData *stream_data; gst_pad_push_event (mux->srcpad, gst_event_new_eos ());
return GST_FLOW_OK;
}
prog = best->prog;
if (prog == NULL) if (prog == NULL)
goto no_program; goto no_program;
@ -1155,8 +1164,8 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
if (prog->pcr_stream == best->stream) { if (prog->pcr_stream == best->stream) {
/* prefer DTS if present for PCR as it should be monotone */ /* prefer DTS if present for PCR as it should be monotone */
mux->last_ts = mux->last_ts =
GST_CLOCK_TIME_IS_VALID (best->last_dts) ? best-> GST_CLOCK_TIME_IS_VALID (best->last_dts) ? best->last_dts : best->
last_dts : best->last_pts; last_pts;
} }
mux->is_delta = delta; mux->is_delta = delta;
@ -1172,13 +1181,6 @@ mpegtsmux_collected_buffer (GstCollectPads * pads, GstCollectData * data,
} }
/* flush packet cache */ /* flush packet cache */
mpegtsmux_push_packets (mux, FALSE); mpegtsmux_push_packets (mux, FALSE);
} else {
/* EOS */
/* drain some possibly cached data */
new_packet_m2ts (mux, NULL, -1);
mpegtsmux_push_packets (mux, TRUE);
gst_pad_push_event (mux->srcpad, gst_event_new_eos ());
}
return ret; return ret;