tests: add and remove pads only once

In this test we simulate a dynamic pad by watching the caps event.
Because of renegotiation in the base payloader now, this caps is sent
multiple times but we can only deal with 1 invocation, use a variable to
only 'add and remove' the pad once.
This commit is contained in:
Wim Taymans 2014-05-09 15:08:48 +02:00
parent aec1b42c4e
commit b8165dbd60

View file

@ -214,17 +214,24 @@ static void
on_notify_caps (GstPad * pad, GParamSpec * pspec, GstElement * pay)
{
GstCaps *caps;
static gboolean have_caps = FALSE;
g_object_get (pad, "caps", &caps, NULL);
GST_DEBUG ("notify %" GST_PTR_FORMAT, caps);
if (caps) {
g_signal_emit_by_name (pay, "pad-added", pad);
g_signal_emit_by_name (pay, "no-more-pads", NULL);
if (!have_caps) {
g_signal_emit_by_name (pay, "pad-added", pad);
g_signal_emit_by_name (pay, "no-more-pads", NULL);
have_caps = TRUE;
}
gst_caps_unref (caps);
} else {
g_signal_emit_by_name (pay, "pad-removed", pad);
if (have_caps) {
g_signal_emit_by_name (pay, "pad-removed", pad);
have_caps = FALSE;
}
}
}