From 2d72008361f59d6f39a38d9e95ea454a189a18a1 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 10 Oct 2023 10:22:44 +0200 Subject: [PATCH] tsmux: Fix default new_stream_func `tsmux_stream_new` is missing the `user_data` parameter and shouldn't be cast to `TsMuxNewStreamFunc`. Prefer not casting at all to make sure we don't miss such an issue. Part-of: --- .../gst-plugins-bad/gst/mpegtsmux/gstatscmux.c | 11 +++++------ .../gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c | 9 ++++++++- .../gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstatscmux.c b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstatscmux.c index 33124be92e..7c40b9e2d6 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/gstatscmux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/gstatscmux.c @@ -61,7 +61,7 @@ static GstStaticPadTemplate gst_atsc_mux_sink_factory = static void gst_atsc_mux_stream_get_es_descrs (TsMuxStream * stream, - GstMpegtsPMTStream * pmt_stream, GstBaseTsMux * mpegtsmux) + GstMpegtsPMTStream * pmt_stream, gpointer user_data) { GstMpegtsDescriptor *descriptor; @@ -291,8 +291,8 @@ gst_atsc_mux_stream_get_es_descrs (TsMuxStream * stream, } static TsMuxStream * -gst_atsc_mux_create_new_stream (guint16 new_pid, - TsMuxStreamType stream_type, guint stream_number, GstBaseTsMux * mpegtsmux) +gst_atsc_mux_create_new_stream (guint16 new_pid, TsMuxStreamType stream_type, + guint stream_number, gpointer user_data) { TsMuxStream *ret = tsmux_stream_new (new_pid, stream_type, stream_number); @@ -307,7 +307,7 @@ gst_atsc_mux_create_new_stream (guint16 new_pid, tsmux_stream_set_get_es_descriptors_func (ret, (TsMuxStreamGetESDescriptorsFunc) gst_atsc_mux_stream_get_es_descrs, - mpegtsmux); + user_data); return ret; } @@ -335,8 +335,7 @@ gst_atsc_mux_create_ts_mux (GstBaseTsMux * mpegtsmux) section = gst_mpegts_section_from_atsc_rrt (rrt); tsmux_add_mpegts_si_section (ret, section); - tsmux_set_new_stream_func (ret, - (TsMuxNewStreamFunc) gst_atsc_mux_create_new_stream, mpegtsmux); + tsmux_set_new_stream_func (ret, gst_atsc_mux_create_new_stream, mpegtsmux); return ret; } diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c index 678f2afbf3..0a3f7e7540 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.c @@ -116,6 +116,13 @@ tsmux_section_free (TsMuxSection * section) g_free (section); } +static TsMuxStream * +tsmux_new_stream_default (guint16 pid, guint stream_type, guint stream_number, + gpointer user_data) +{ + return tsmux_stream_new (pid, stream_type, stream_number); +} + /** * tsmux_new: * @@ -150,7 +157,7 @@ tsmux_new (void) mux->si_sections = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) tsmux_section_free); - mux->new_stream_func = (TsMuxNewStreamFunc) tsmux_stream_new; + mux->new_stream_func = tsmux_new_stream_default; mux->new_stream_data = NULL; mux->first_pcr_ts = G_MININT64; diff --git a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.h b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.h index da90f51380..8e59dd9cbe 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.h +++ b/subprojects/gst-plugins-bad/gst/mpegtsmux/tsmux/tsmux.h @@ -84,7 +84,7 @@ typedef struct TsMux TsMux; typedef gboolean (*TsMuxWriteFunc) (GstBuffer * buf, void *user_data, gint64 new_pcr); typedef void (*TsMuxAllocFunc) (GstBuffer ** buf, void *user_data); -typedef TsMuxStream * (*TsMuxNewStreamFunc) (guint16 new_pid, guint stream_type, guint stream_number, void *user_data); +typedef TsMuxStream * (*TsMuxNewStreamFunc) (guint16 new_pid, guint stream_type, guint stream_number, gpointer user_data); struct TsMuxSection { TsMuxPacketInfo pi;