tests: more rtpbin checks

This commit is contained in:
Wim Taymans 2009-05-22 15:37:29 +02:00 committed by Tim-Philipp Müller
parent 901b7f3b69
commit 02b34602c4

View file

@ -27,58 +27,73 @@ GST_START_TEST (test_cleanup_send)
GstElement *rtpbin; GstElement *rtpbin;
GstPad *rtp_sink, *rtp_src, *rtcp_src; GstPad *rtp_sink, *rtp_src, *rtcp_src;
GObject *session; GObject *session;
gint count = 2;
rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin"); rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
/* request session 0 */ while (count--) {
rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0"); /* request session 0 */
fail_unless (rtp_sink != NULL); rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2); fail_unless (rtp_sink != NULL);
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 2);
/* this static pad should be created automatically now */ /* request again */
rtp_src = gst_element_get_static_pad (rtpbin, "send_rtp_src_0"); rtp_sink = gst_element_get_request_pad (rtpbin, "send_rtp_sink_0");
fail_unless (rtp_src != NULL); fail_unless (rtp_sink != NULL);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 2); ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 3);
gst_object_unref (rtp_sink);
/* we should be able to get an internal session 0 now */ /* this static pad should be created automatically now */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); rtp_src = gst_element_get_static_pad (rtpbin, "send_rtp_src_0");
fail_unless (session != NULL); fail_unless (rtp_src != NULL);
g_object_unref (session); ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 2);
/* get the send RTCP pad too */ /* we should be able to get an internal session 0 now */
rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0"); g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (rtcp_src != NULL); fail_unless (session != NULL);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 2); g_object_unref (session);
gst_element_release_request_pad (rtpbin, rtp_sink); /* get the send RTCP pad too */
/* we should only have our refs to the pads now */ rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0");
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1); fail_unless (rtcp_src != NULL);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1); ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 2);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 2);
/* the other pad should be gone now */ /* second time */
fail_unless (gst_element_get_static_pad (rtpbin, "send_rtp_src_0") == NULL); rtcp_src = gst_element_get_request_pad (rtpbin, "send_rtcp_src_0");
fail_unless (rtcp_src != NULL);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtcp_src", 3);
gst_object_unref (rtcp_src);
/* internal session should still be there */ gst_element_release_request_pad (rtpbin, rtp_sink);
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); /* we should only have our refs to the pads now */
fail_unless (session != NULL); ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
g_object_unref (session); ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 2);
/* release the RTCP pad */ /* the other pad should be gone now */
gst_element_release_request_pad (rtpbin, rtcp_src); fail_unless (gst_element_get_static_pad (rtpbin, "send_rtp_src_0") == NULL);
/* we should only have our refs to the pads now */
ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 1);
/* the session should be gone now */ /* internal session should still be there */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session); g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (session == NULL); fail_unless (session != NULL);
g_object_unref (session);
/* unref the request pad and the static pad */ /* release the RTCP pad */
gst_object_unref (rtp_sink); gst_element_release_request_pad (rtpbin, rtcp_src);
gst_object_unref (rtp_src); /* we should only have our refs to the pads now */
gst_object_unref (rtcp_src); ASSERT_OBJECT_REFCOUNT (rtp_sink, "rtp_sink", 1);
ASSERT_OBJECT_REFCOUNT (rtp_src, "rtp_src", 1);
ASSERT_OBJECT_REFCOUNT (rtcp_src, "rtp_src", 1);
/* the session should be gone now */
g_signal_emit_by_name (rtpbin, "get-internal-session", 0, &session);
fail_unless (session == NULL);
/* unref the request pad and the static pad */
gst_object_unref (rtp_sink);
gst_object_unref (rtp_src);
gst_object_unref (rtcp_src);
}
gst_object_unref (rtpbin); gst_object_unref (rtpbin);
} }