static gboolean connect_output_sink (gpointer data) { GstElement *pipeline = data; GstElement *rtpendpointreceiver = gst_bin_get_by_name (GST_BIN (pipeline), "receiver"); GstElement *outputfakesink = gst_element_factory_make ("fakesink", NULL); GMainLoop *loop = g_object_get_data (G_OBJECT (pipeline), "loop"); GstElement *agnosticbin = gst_bin_get_by_name (GST_BIN (pipeline), "agnosticbin"); GstElement *rtpendpointsender = gst_bin_get_by_name (GST_BIN (pipeline), "sender"); gst_element_link_pads (agnosticbin, NULL, rtpendpointsender, "video_sink"); g_object_unref (agnosticbin); g_object_unref (rtpendpointsender); g_object_set (G_OBJECT (outputfakesink), "signal-handoffs", TRUE, NULL); g_signal_connect (G_OBJECT (outputfakesink), "handoff", G_CALLBACK (fakesink_hand_off), loop); gst_bin_add (GST_BIN (pipeline), outputfakesink); gst_element_sync_state_with_parent (outputfakesink); kms_element_link_pads (rtpendpointreceiver, "video_src_%u", outputfakesink, "sink"); g_object_unref (rtpendpointreceiver); return FALSE; }
static void test_video_sendonly (const gchar * video_enc_name, GstStaticCaps expected_caps, const gchar * pattern_sdp_sendonly_str, const gchar * pattern_sdp_recvonly_str, gboolean play_after_negotiation) { HandOffData *hod; GMainLoop *loop = g_main_loop_new (NULL, TRUE); GstSDPMessage *pattern_sdp, *offer, *answer; GstElement *pipeline = gst_pipeline_new (NULL); GstElement *videotestsrc = gst_element_factory_make ("videotestsrc", NULL); GstElement *video_enc = gst_element_factory_make (video_enc_name, NULL); GstElement *rtpendpointsender = gst_element_factory_make ("rtpendpoint", NULL); GstElement *rtpendpointreceiver = gst_element_factory_make ("rtpendpoint", NULL); GstElement *outputfakesink = gst_element_factory_make ("fakesink", NULL); GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); gst_bus_add_watch (bus, gst_bus_async_signal_func, NULL); g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline); g_object_unref (bus); fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK); fail_unless (gst_sdp_message_parse_buffer ((const guint8 *) pattern_sdp_sendonly_str, -1, pattern_sdp) == GST_SDP_OK); g_object_set (rtpendpointsender, "pattern-sdp", pattern_sdp, NULL); fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK); fail_unless (gst_sdp_message_new (&pattern_sdp) == GST_SDP_OK); fail_unless (gst_sdp_message_parse_buffer ((const guint8 *) pattern_sdp_recvonly_str, -1, pattern_sdp) == GST_SDP_OK); g_object_set (rtpendpointreceiver, "pattern-sdp", pattern_sdp, NULL); fail_unless (gst_sdp_message_free (pattern_sdp) == GST_SDP_OK); hod = g_slice_new (HandOffData); hod->expected_caps = expected_caps; hod->loop = loop; g_object_set (G_OBJECT (outputfakesink), "signal-handoffs", TRUE, NULL); g_signal_connect (G_OBJECT (outputfakesink), "handoff", G_CALLBACK (fakesink_hand_off), hod); /* Add elements */ gst_bin_add_many (GST_BIN (pipeline), videotestsrc, video_enc, rtpendpointsender, NULL); gst_element_link (videotestsrc, video_enc); gst_element_link_pads (video_enc, NULL, rtpendpointsender, "video_sink"); gst_bin_add_many (GST_BIN (pipeline), rtpendpointreceiver, outputfakesink, NULL); kms_element_link_pads (rtpendpointreceiver, "video_src_%u", outputfakesink, "sink"); if (!play_after_negotiation) gst_element_set_state (pipeline, GST_STATE_PLAYING); /* SDP negotiation */ mark_point (); g_signal_emit_by_name (rtpendpointsender, "generate-offer", &offer); fail_unless (offer != NULL); mark_point (); g_signal_emit_by_name (rtpendpointreceiver, "process-offer", offer, &answer); fail_unless (answer != NULL); mark_point (); g_signal_emit_by_name (rtpendpointsender, "process-answer", answer); gst_sdp_message_free (offer); gst_sdp_message_free (answer); if (play_after_negotiation) gst_element_set_state (pipeline, GST_STATE_PLAYING); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_before_entering_loop"); mark_point (); g_main_loop_run (loop); mark_point (); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "test_sendonly_end"); gst_element_set_state (pipeline, GST_STATE_NULL); g_object_unref (pipeline); g_slice_free (HandOffData, hod); g_main_loop_unref (loop); }