diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index 8e50a71d28..230772a526 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -135,7 +135,7 @@ static void gst_mpegtsmux_get_property (GObject * object, guint prop_id, static void mpegtsmux_dispose (GObject * object); static gboolean new_packet_cb (guint8 * data, guint len, void *user_data, - gint64 new_pcr, gboolean delta); + gint64 new_pcr); static void release_buffer_cb (guint8 * data, void *user_data); static gboolean mpegtsdemux_prepare_srcpad (MpegTsMux * mux); @@ -217,6 +217,7 @@ mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class) mux->m2ts_mode = FALSE; mux->first_pcr = TRUE; mux->last_ts = 0; + mux->is_delta = TRUE; mux->prog_map = NULL; } @@ -661,12 +662,12 @@ mpegtsmux_collected (GstCollectPads * pads, MpegTsMux * mux) GST_BUFFER_SIZE (buf), buf, pts, -1); best->queued_buf = NULL; + mux->is_delta = delta; while (tsmux_stream_bytes_in_buffer (best->stream) > 0) { - if (!tsmux_write_stream_packet (mux->tsmux, best->stream, delta)) { + if (!tsmux_write_stream_packet (mux->tsmux, best->stream)) { GST_DEBUG_OBJECT (mux, "Failed to write data packet"); goto write_fail; } - delta = TRUE; } if (prog->pcr_stream == best->stream) { mux->last_ts = best->last_ts; @@ -771,8 +772,7 @@ mpegtsmux_release_pad (GstElement * element, GstPad * pad) } static gboolean -new_packet_cb (guint8 * data, guint len, void *user_data, gint64 new_pcr, - gboolean delta) +new_packet_cb (guint8 * data, guint len, void *user_data, gint64 new_pcr) { /* Called when the TsMux has prepared a packet for output. Return FALSE * on error */ @@ -787,11 +787,12 @@ new_packet_cb (guint8 * data, guint len, void *user_data, gint64 new_pcr, if (mux->m2ts_mode == TRUE) { /* Enters when the m2ts-mode is set true */ buf = gst_buffer_new_and_alloc (M2TS_PACKET_LENGTH); - if (delta) { + if (mux->is_delta) { GST_LOG_OBJECT (mux, "marking as delta unit"); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT); } else { GST_DEBUG_OBJECT (mux, "marking as non-delta unit"); + mux->is_delta = TRUE; } if (G_UNLIKELY (buf == NULL)) { mux->last_flow_ret = GST_FLOW_ERROR; @@ -865,11 +866,12 @@ new_packet_cb (guint8 * data, guint len, void *user_data, gint64 new_pcr, /* In case of Normal Ts packets */ GST_LOG_OBJECT (mux, "Outputting a packet of length %d", len); buf = gst_buffer_new_and_alloc (len); - if (delta) { + if (mux->is_delta) { GST_LOG_OBJECT (mux, "marking as delta unit"); GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT); } else { GST_DEBUG_OBJECT (mux, "marking as non-delta unit"); + mux->is_delta = TRUE; } if (G_UNLIKELY (buf == NULL)) { mux->last_flow_ret = GST_FLOW_ERROR; diff --git a/gst/mpegtsmux/mpegtsmux.h b/gst/mpegtsmux/mpegtsmux.h index 23fa1b00c1..8ba2a9f81e 100644 --- a/gst/mpegtsmux/mpegtsmux.h +++ b/gst/mpegtsmux/mpegtsmux.h @@ -122,6 +122,7 @@ struct MpegTsMux { gboolean first_pcr; GstClockTime last_ts; + gboolean is_delta; }; struct MpegTsMuxClass { diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index 77f14682aa..70ad3dcd2e 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -438,13 +438,13 @@ tsmux_find_stream (TsMux * mux, guint16 pid) } static gboolean -tsmux_packet_out (TsMux * mux, gboolean delta) +tsmux_packet_out (TsMux * mux) { if (G_UNLIKELY (mux->write_func == NULL)) return TRUE; return mux->write_func (mux->packet_buf, TSMUX_PACKET_LENGTH, - mux->write_func_data, mux->new_pcr, delta); + mux->write_func_data, mux->new_pcr); } /* @@ -704,7 +704,7 @@ tsmux_write_ts_header (guint8 * buf, TsMuxPacketInfo * pi, * Returns: TRUE if the packet could be written. */ gboolean -tsmux_write_stream_packet (TsMux * mux, TsMuxStream * stream, gboolean delta) +tsmux_write_stream_packet (TsMux * mux, TsMuxStream * stream) { guint payload_len, payload_offs; TsMuxPacketInfo *pi = &stream->pi; @@ -788,7 +788,7 @@ tsmux_write_stream_packet (TsMux * mux, TsMuxStream * stream, gboolean delta) payload_len)) return FALSE; - res = tsmux_packet_out (mux, delta); + res = tsmux_packet_out (mux); /* Reset all dynamic flags */ stream->pi.flags &= TSMUX_PACKET_FLAG_PES_FULL_HEADER; @@ -859,7 +859,7 @@ tsmux_write_section (TsMux * mux, TsMuxSection * section) cur_in += payload_len; payload_remain -= payload_len; - if (G_UNLIKELY (!tsmux_packet_out (mux, TRUE))) { + if (G_UNLIKELY (!tsmux_packet_out (mux))) { mux->new_pcr = -1; return FALSE; } diff --git a/gst/mpegtsmux/tsmux/tsmux.h b/gst/mpegtsmux/tsmux/tsmux.h index b2ec4698ae..4e7e063129 100644 --- a/gst/mpegtsmux/tsmux/tsmux.h +++ b/gst/mpegtsmux/tsmux/tsmux.h @@ -95,7 +95,7 @@ G_BEGIN_DECLS typedef struct TsMuxSection TsMuxSection; typedef struct TsMux TsMux; -typedef gboolean (*TsMuxWriteFunc) (guint8 *data, guint len, void *user_data, gint64 new_pcr, gboolean delta); +typedef gboolean (*TsMuxWriteFunc) (guint8 *data, guint len, void *user_data, gint64 new_pcr); struct TsMuxSection { TsMuxPacketInfo pi; @@ -176,7 +176,7 @@ void tsmux_program_add_stream (TsMuxProgram *program, TsMuxStream *stream); void tsmux_program_set_pcr_stream (TsMuxProgram *program, TsMuxStream *stream); /* writing stuff */ -gboolean tsmux_write_stream_packet (TsMux *mux, TsMuxStream *stream, gboolean delta); +gboolean tsmux_write_stream_packet (TsMux *mux, TsMuxStream *stream); G_END_DECLS