qulogic/pidgin

Parents 29a0a4cdee6f
Children 9183e00db579
media: don't expect FsParticipant always has "cname" property

Because only FsRtpParticipant instances have "cname", libpurple crashed when
PurpleMedia was created with conference_type other than "fsrtpconference"[1].

We still set "cname" for Farstream's internal use if the property is present,
but libpurple now adds its custom GObject data with key "purple-name" to the
participant instance to store and retrieve the participant name in a manner
independent of the type of Farstream conference.

[1] https://developer.pidgin.im/ticket/17246
--- a/libpurple/media/backend-fs2.c Tue Sep 26 02:41:52 2017 +0000
+++ b/libpurple/media/backend-fs2.c Mon Oct 02 13:27:23 2017 +0200
@@ -1059,7 +1059,7 @@
FsParticipant *participant;
PurpleMediaBackendFs2Session *session;
PurpleMediaBackendFs2Stream *media_stream;
- gchar *name;
+ const gchar *name;
value = gst_structure_get_value(structure, "stream");
stream = g_value_get_object(value);
@@ -1073,8 +1073,7 @@
local_candidate->foundation);
g_object_get(stream, "participant", &participant, NULL);
- g_object_get(participant, "cname", &name, NULL);
- g_object_unref(participant);
+ name = g_object_get_data(G_OBJECT(participant), "purple-name");
media_stream = get_stream(self, session->id, name);
media_stream->local_candidates = g_list_append(
@@ -1085,24 +1084,25 @@
g_signal_emit_by_name(self, "new-candidate",
session->id, name, candidate);
g_object_unref(candidate);
+ g_object_unref(participant);
} else if (gst_structure_has_name(structure,
"farstream-local-candidates-prepared")) {
const GValue *value;
FsStream *stream;
FsParticipant *participant;
PurpleMediaBackendFs2Session *session;
- gchar *name;
value = gst_structure_get_value(structure, "stream");
stream = g_value_get_object(value);
session = get_session_from_fs_stream(self, stream);
g_object_get(stream, "participant", &participant, NULL);
- g_object_get(participant, "cname", &name, NULL);
- g_object_unref(participant);
g_signal_emit_by_name(self, "candidates-prepared",
- session->id, name);
+ session->id,
+ g_object_get_data(G_OBJECT(participant), "purple-name"));
+
+ g_object_unref(participant);
} else if (gst_structure_has_name(structure,
"farstream-new-active-candidate-pair")) {
const GValue *value;
@@ -1112,7 +1112,6 @@
FsParticipant *participant;
PurpleMediaBackendFs2Session *session;
PurpleMediaCandidate *lcandidate, *rcandidate;
- gchar *name;
value = gst_structure_get_value(structure, "stream");
stream = g_value_get_object(value);
@@ -1122,8 +1121,6 @@
remote_candidate = g_value_get_boxed(value);
g_object_get(stream, "participant", &participant, NULL);
- g_object_get(participant, "cname", &name, NULL);
- g_object_unref(participant);
session = get_session_from_fs_stream(self, stream);
@@ -1131,8 +1128,11 @@
rcandidate = candidate_from_fs(remote_candidate);
g_signal_emit_by_name(self, "active-candidate-pair",
- session->id, name, lcandidate, rcandidate);
-
+ session->id,
+ g_object_get_data(G_OBJECT(participant), "purple-name"),
+ lcandidate, rcandidate);
+
+ g_object_unref(participant);
g_object_unref(lcandidate);
g_object_unref(rcandidate);
} else if (gst_structure_has_name(structure,
@@ -1775,6 +1775,9 @@
return FALSE;
}
+ g_object_set_data_full(G_OBJECT(participant), "purple-name",
+ g_strdup(name), g_free);
+
if (g_object_class_find_property(G_OBJECT_GET_CLASS(participant),
"cname")) {
g_object_set(participant, "cname", name, NULL);