mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-29 18:48:44 +00:00
tests: x264enc: fix leak in unit test
The static pad templates weren't static so their contents were leaked. valgrind was not happy. Also rename confusing define.
This commit is contained in:
parent
7e63943361
commit
908c36eceb
1 changed files with 15 additions and 17 deletions
|
@ -35,36 +35,35 @@ static GstPad *mysrcpad, *mysinkpad;
|
||||||
"height = (int) 288, " \
|
"height = (int) 288, " \
|
||||||
"framerate = (fraction) 25/1"
|
"framerate = (fraction) 25/1"
|
||||||
|
|
||||||
#define MPEG_CAPS_STRING "video/x-h264, " \
|
#define H264_CAPS_STRING "video/x-h264, " \
|
||||||
"width = (int) 384, " \
|
"width = (int) 384, " \
|
||||||
"height = (int) 288, " \
|
"height = (int) 288, " \
|
||||||
"framerate = (fraction) 25/1"
|
"framerate = (fraction) 25/1"
|
||||||
|
|
||||||
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
|
GST_PAD_SRC,
|
||||||
|
GST_PAD_ALWAYS,
|
||||||
|
GST_STATIC_CAPS (VIDEO_CAPS_STRING));
|
||||||
|
|
||||||
static GstElement *
|
static GstElement *
|
||||||
setup_x264enc (const gchar * profile, const gchar * stream_format,
|
setup_x264enc (const gchar * profile, const gchar * stream_format,
|
||||||
const gchar * input_format)
|
const gchar * input_format)
|
||||||
{
|
{
|
||||||
GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
GstPadTemplate *sink_tmpl;
|
||||||
GST_PAD_SINK,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (MPEG_CAPS_STRING));
|
|
||||||
|
|
||||||
GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
||||||
GST_PAD_SRC,
|
|
||||||
GST_PAD_ALWAYS,
|
|
||||||
GST_STATIC_CAPS (VIDEO_CAPS_STRING));
|
|
||||||
GstElement *x264enc;
|
GstElement *x264enc;
|
||||||
gchar *caps_str;
|
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
|
|
||||||
GST_DEBUG ("setup_x264enc");
|
GST_DEBUG ("setup_x264enc");
|
||||||
|
|
||||||
caps_str = g_strdup_printf ("%s, profile = (string) %s, "
|
caps = gst_caps_from_string (H264_CAPS_STRING);
|
||||||
"stream-format = (string) %s", MPEG_CAPS_STRING, profile, stream_format);
|
gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile,
|
||||||
sinktemplate.static_caps.string = caps_str;
|
"stream-format", G_TYPE_STRING, stream_format, NULL);
|
||||||
|
sink_tmpl = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, caps);
|
||||||
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
x264enc = gst_check_setup_element ("x264enc");
|
x264enc = gst_check_setup_element ("x264enc");
|
||||||
mysrcpad = gst_check_setup_src_pad (x264enc, &srctemplate);
|
mysrcpad = gst_check_setup_src_pad (x264enc, &srctemplate);
|
||||||
mysinkpad = gst_check_setup_sink_pad (x264enc, &sinktemplate);
|
mysinkpad = gst_check_setup_sink_pad_from_template (x264enc, sink_tmpl);
|
||||||
gst_pad_set_active (mysrcpad, TRUE);
|
gst_pad_set_active (mysrcpad, TRUE);
|
||||||
gst_pad_set_active (mysinkpad, TRUE);
|
gst_pad_set_active (mysinkpad, TRUE);
|
||||||
|
|
||||||
|
@ -72,8 +71,7 @@ setup_x264enc (const gchar * profile, const gchar * stream_format,
|
||||||
gst_caps_set_simple (caps, "format", G_TYPE_STRING, input_format, NULL);
|
gst_caps_set_simple (caps, "format", G_TYPE_STRING, input_format, NULL);
|
||||||
gst_check_setup_events (mysrcpad, x264enc, caps, GST_FORMAT_TIME);
|
gst_check_setup_events (mysrcpad, x264enc, caps, GST_FORMAT_TIME);
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
gst_object_unref (sink_tmpl);
|
||||||
g_free (caps_str);
|
|
||||||
|
|
||||||
return x264enc;
|
return x264enc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue