static void link_to_recorder (GstElement * recorder, GstElement * src, GstElement * pipe, const gchar * pad_name) { GstPad *sink; GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL); gst_bin_add (GST_BIN (pipe), agnosticbin); gst_element_link (src, agnosticbin); gst_element_sync_state_with_parent (agnosticbin); connect_sink_async (recorder, agnosticbin, pad_name); sink = gst_element_get_static_pad (recorder, pad_name); if (sink != NULL) { connect_pads_and_remove_on_unlinked (agnosticbin, recorder, pad_name); g_object_unref (sink); } }
static void test_audio_sendrecv (const gchar * audio_enc_name, GstStaticCaps expected_caps, gchar * codec) { GArray *codecs_array; gchar *codecs[] = { codec, NULL }; HandOffData *hod; GMainLoop *loop = g_main_loop_new (NULL, TRUE); GstSDPMessage *offer, *answer; GstElement *pipeline = gst_pipeline_new (NULL); GstBus *bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); GstElement *audiotestsrc_offerer = gst_element_factory_make ("audiotestsrc", NULL); GstElement *audiotestsrc_answerer = gst_element_factory_make ("audiotestsrc", NULL); GstElement *audio_enc_offerer = gst_element_factory_make (audio_enc_name, NULL); GstElement *audio_enc_answerer = gst_element_factory_make (audio_enc_name, NULL); GstElement *rtpendpoint_offerer = gst_element_factory_make ("rtpendpoint", NULL); GstElement *rtpendpoint_answerer = gst_element_factory_make ("rtpendpoint", NULL); GstElement *fakesink_offerer = gst_element_factory_make ("fakesink", NULL); GstElement *fakesink_answerer = gst_element_factory_make ("fakesink", NULL); gst_bus_add_signal_watch (bus); g_signal_connect (bus, "message", G_CALLBACK (bus_msg), pipeline); codecs_array = create_codecs_array (codecs); g_object_set (rtpendpoint_offerer, "num-audio-medias", 1, "audio-codecs", g_array_ref (codecs_array), NULL); g_object_set (rtpendpoint_answerer, "num-audio-medias", 1, "audio-codecs", g_array_ref (codecs_array), NULL); g_array_unref (codecs_array); hod = g_slice_new (HandOffData); hod->expected_caps = expected_caps; hod->loop = loop; g_object_set (G_OBJECT (fakesink_offerer), "signal-handoffs", TRUE, NULL); g_signal_connect (G_OBJECT (fakesink_offerer), "handoff", G_CALLBACK (sendrecv_offerer_fakesink_hand_off), hod); g_object_set (G_OBJECT (fakesink_answerer), "signal-handoffs", TRUE, NULL); g_signal_connect (G_OBJECT (fakesink_answerer), "handoff", G_CALLBACK (sendrecv_answerer_fakesink_hand_off), hod); /* Add elements */ gst_bin_add (GST_BIN (pipeline), rtpendpoint_offerer); connect_sink_async (rtpendpoint_offerer, audiotestsrc_offerer, audio_enc_offerer, NULL, pipeline, "sink_audio"); gst_bin_add (GST_BIN (pipeline), rtpendpoint_answerer); connect_sink_async (rtpendpoint_answerer, audiotestsrc_answerer, audio_enc_answerer, NULL, pipeline, "sink_audio"); gst_element_set_state (pipeline, GST_STATE_PLAYING); /* SDP negotiation */ mark_point (); g_signal_emit_by_name (rtpendpoint_offerer, "generate-offer", &offer); fail_unless (offer != NULL); mark_point (); g_signal_emit_by_name (rtpendpoint_answerer, "process-offer", offer, &answer); fail_unless (answer != NULL); mark_point (); g_signal_emit_by_name (rtpendpoint_offerer, "process-answer", answer); gst_sdp_message_free (offer); gst_sdp_message_free (answer); gst_bin_add (GST_BIN (pipeline), fakesink_offerer); g_object_set_data (G_OBJECT (rtpendpoint_offerer), AUDIO_SINK, fakesink_offerer); g_signal_connect (rtpendpoint_offerer, "pad-added", G_CALLBACK (connect_sink_on_srcpad_added), NULL); fail_unless (kms_element_request_srcpad (rtpendpoint_offerer, KMS_ELEMENT_PAD_TYPE_AUDIO)); gst_bin_add (GST_BIN (pipeline), fakesink_answerer); g_object_set_data (G_OBJECT (rtpendpoint_answerer), AUDIO_SINK, fakesink_answerer); g_signal_connect (rtpendpoint_answerer, "pad-added", G_CALLBACK (connect_sink_on_srcpad_added), NULL); fail_unless (kms_element_request_srcpad (rtpendpoint_answerer, KMS_ELEMENT_PAD_TYPE_AUDIO)); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "test_audio_sendrecv_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_audio_sendrecv_end"); gst_element_set_state (pipeline, GST_STATE_NULL); gst_bus_remove_signal_watch (bus); g_object_unref (bus); g_main_loop_unref (loop); g_object_unref (pipeline); g_slice_free (HandOffData, hod); }