avmux: fix element leak

Fixes #2473

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4384>
This commit is contained in:
Tim-Philipp Müller 2023-04-10 18:06:17 +01:00
parent c723d9a1e0
commit a40c38eddf

View file

@ -103,7 +103,8 @@ static void gst_ffmpegmux_init (GstFFMpegMux * ffmpegmux,
GstFFMpegMuxClass * g_class); GstFFMpegMuxClass * g_class);
static void gst_ffmpegmux_finalize (GObject * object); static void gst_ffmpegmux_finalize (GObject * object);
static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps); static gboolean gst_ffmpegmux_setcaps (GstPad * pad, GstObject * parent,
GstCaps * caps);
static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element, static GstPad *gst_ffmpegmux_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * name, const GstCaps * caps); GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads, static GstFlowReturn gst_ffmpegmux_collected (GstCollectPads * pads,
@ -460,19 +461,10 @@ gst_ffmpegmux_request_new_pad (GstElement * element,
return pad; return pad;
} }
/**
* gst_ffmpegmux_setcaps
* @pad: #GstPad
* @caps: New caps.
*
* Set caps to pad.
*
* Returns: #TRUE on success.
*/
static gboolean static gboolean
gst_ffmpegmux_setcaps (GstPad * pad, GstCaps * caps) gst_ffmpegmux_setcaps (GstPad * pad, GstObject * parent, GstCaps * caps)
{ {
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) (gst_pad_get_parent (pad)); GstFFMpegMux *ffmpegmux = (GstFFMpegMux *) parent;
GstFFMpegMuxPad *collect_pad; GstFFMpegMuxPad *collect_pad;
AVStream *st; AVStream *st;
AVCodecContext tmp; AVCodecContext tmp;
@ -526,7 +518,7 @@ gst_ffmpegmux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
case GST_EVENT_CAPS:{ case GST_EVENT_CAPS:{
GstCaps *caps; GstCaps *caps;
gst_event_parse_caps (event, &caps); gst_event_parse_caps (event, &caps);
if (!(res = gst_ffmpegmux_setcaps (pad, caps))) if (!(res = gst_ffmpegmux_setcaps (pad, parent, caps)))
goto beach; goto beach;
break; break;
} }