static void _new_local_candidate (FsStream *stream, FsCandidate *candidate) { struct SimpleTestStream *st = g_object_get_data (G_OBJECT (stream), "SimpleTestStream"); gboolean ret; GError *error = NULL; struct SimpleTestStream *other_st; GList *candidates = NULL; TEST_LOCK (); if (st->target == NULL) { TEST_UNLOCK (); return; } other_st = find_pointback_stream (st->target, st->dat); if (other_st->stream == NULL || (candidate->component_id == FS_COMPONENT_RTCP && no_rtcp)) { TEST_UNLOCK (); return; } st->got_candidates = TRUE; GST_DEBUG ("%d:%d: Setting remote candidate for component %d", other_st->dat->id, other_st->target->id, candidate->component_id); if (other_st->stream == NULL) { TEST_UNLOCK (); return; } candidates = g_list_prepend (NULL, candidate); ret = fs_stream_add_remote_candidates (other_st->stream, candidates, &error); if (ret == FALSE && error && error->domain == FS_ERROR && error->code == FS_ERROR_NOT_IMPLEMENTED) { g_clear_error (&error); ret = fs_stream_force_remote_candidates (other_st->stream, candidates, &error); } g_list_free (candidates); if (error) ts_fail ("Error while adding candidate: (%s:%d) %s", g_quark_to_string (error->domain), error->code, error->message); ts_fail_unless (ret == TRUE, "No detailed error from add_remote_candidate"); TEST_UNLOCK (); }
static TestSession* add_audio_session (GstElement *pipeline, FsConference *conf, guint id, FsParticipant *part, guint localport, const gchar *remoteip, guint remoteport) { TestSession *ses = g_slice_new0 (TestSession); GError *error = NULL; GstPad *pad = NULL, *pad2 = NULL; GstElement *src = NULL; GList *cands = NULL; GList *codecs = NULL; GParameter param = {0}; gboolean res; ses->session = fs_conference_new_session (conf, FS_MEDIA_TYPE_AUDIO, &error); print_error (error); g_assert (ses->session); g_object_get (ses->session, "sink-pad", &pad, NULL); if (g_getenv ("AUDIOSRC")) src = gst_parse_bin_from_description (g_getenv ("AUDIOSRC"), TRUE, &error); else src = gst_parse_bin_from_description (DEFAULT_AUDIOSRC, TRUE, &error); print_error (error); g_assert (src); g_assert (gst_bin_add (GST_BIN (pipeline), src)); pad2 = gst_element_get_static_pad (src, "src"); g_assert (pad2); g_assert (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (pad2, pad))); gst_object_unref (pad2); gst_object_unref (pad); ses->stream = fs_session_new_stream (ses->session, part, FS_DIRECTION_BOTH, &error); print_error (error); g_assert (ses->stream); cands = g_list_prepend (NULL, fs_candidate_new ("", FS_COMPONENT_RTP, FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, NULL, localport)); param.name = "preferred-local-candidates"; g_value_init (¶m.value, FS_TYPE_CANDIDATE_LIST); g_value_take_boxed (¶m.value, cands); res = fs_stream_set_transmitter (ses->stream, "rawudp", ¶m, 1, &error); print_error (error); g_assert (ses->stream); g_value_unset (¶m.value); g_signal_connect (ses->stream, "src-pad-added", G_CALLBACK (src_pad_added_cb), pipeline); cands = g_list_prepend (NULL, fs_candidate_new ("", FS_COMPONENT_RTP, FS_CANDIDATE_TYPE_HOST, FS_NETWORK_PROTOCOL_UDP, remoteip, remoteport)); res = fs_stream_add_remote_candidates (ses->stream, cands, &error); print_error (error); g_assert (res); fs_candidate_list_destroy (cands); codecs = g_list_prepend (NULL, fs_codec_new (FS_CODEC_ID_ANY, "PCMA", FS_MEDIA_TYPE_AUDIO, 0)); codecs = g_list_prepend (codecs, fs_codec_new (FS_CODEC_ID_ANY, "PCMU", FS_MEDIA_TYPE_AUDIO, 0)); res = fs_session_set_codec_preferences (ses->session, codecs, &error); print_error (error); fs_codec_list_destroy (codecs); g_object_get (ses->session, "codecs-without-config", &codecs, NULL); res = fs_stream_set_remote_codecs (ses->stream, codecs, &error); print_error (error); g_assert (res); return ses; }
static gboolean bus_watch (GstBus *bus, GstMessage *message, gpointer user_data) { struct SimpleMsnConference *dat = user_data; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ELEMENT: { const GstStructure *s = gst_message_get_structure (message); ts_fail_if (s==NULL, "NULL structure in element message"); if (gst_structure_has_name (s, "farstream-error")) { const GValue *value; FsError errorno; const gchar *error; ts_fail_unless ( gst_implements_interface_check (GST_MESSAGE_SRC (message), FS_TYPE_CONFERENCE), "Received farstream-error from non-farstream element"); ts_fail_unless ( gst_structure_has_field_typed (s, "src-object", G_TYPE_OBJECT), "farstream-error structure has no src-object field"); ts_fail_unless ( gst_structure_has_field_typed (s, "error-no", FS_TYPE_ERROR), "farstream-error structure has no src-object field"); ts_fail_unless ( gst_structure_has_field_typed (s, "error-msg", G_TYPE_STRING), "farstream-error structure has no src-object field"); value = gst_structure_get_value (s, "error-no"); errorno = g_value_get_enum (value); error = gst_structure_get_string (s, "error-msg"); ts_fail ("Error on BUS (%d) %s", errorno, error); } else if (gst_structure_has_name (s, "farstream-new-local-candidate")) { FsStream *stream; FsCandidate *candidate; const GValue *value; ts_fail_unless ( gst_implements_interface_check (GST_MESSAGE_SRC (message), FS_TYPE_CONFERENCE), "Received farstream-error from non-farstream element"); ts_fail_unless ( gst_structure_has_field_typed (s, "stream", FS_TYPE_STREAM), "farstream-new-local-candidate structure has no stream field"); ts_fail_unless ( gst_structure_has_field_typed (s, "candidate", FS_TYPE_CANDIDATE), "farstream-new-local-candidate structure has no candidate field"); value = gst_structure_get_value (s, "stream"); stream = g_value_get_object (value); value = gst_structure_get_value (s, "candidate"); candidate = g_value_get_boxed (value); ts_fail_unless (stream && candidate, "new-local-candidate with NULL" " stream(%p) or candidate(%p)", stream, candidate); if (dat->target) { GError *error = NULL; GList *list = g_list_append (NULL, candidate); gboolean add_remote_candidates_res; GST_DEBUG ("Setting candidate: %s %d", candidate->ip, candidate->port); add_remote_candidates_res = fs_stream_add_remote_candidates ( dat->target->stream, list, &error); ts_fail_unless (add_remote_candidates_res, "Could not set remote candidate: %s", error ? error->message : "No GError"); ts_fail_unless (error == NULL); g_list_free (list); } } } break; case GST_MESSAGE_ERROR: { GError *error = NULL; gchar *debug = NULL; gst_message_parse_error (message, &error, &debug); ts_fail ("Got an error on the BUS (%d): %s (%s)", error->code, error->message, debug); g_error_free (error); g_free (debug); } break; case GST_MESSAGE_WARNING: { GError *error = NULL; gchar *debug = NULL; gst_message_parse_warning (message, &error, &debug); GST_DEBUG ("%d: Got a warning on the BUS: %s (%s)", error->code, error->message, debug); g_error_free (error); g_free (debug); } break; default: break; } return TRUE; }