cpw.maiku.media_refactor: 15be1094: Handle part of accepting a stream in the...
maiku at pidgin.im
maiku at pidgin.im
Mon Oct 26 22:45:48 EDT 2009
-----------------------------------------------------------------
Revision: 15be10945e42ad1044265eccacb6159587b0a4f4
Ancestor: 602088ab48304bdc10cd602297a92fc9fea2ed22
Author: maiku at pidgin.im
Date: 2009-10-27T00:13:39
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/15be10945e42ad1044265eccacb6159587b0a4f4
Modified files:
libpurple/media/backend-fs2.c libpurple/media/media.c
ChangeLog:
Handle part of accepting a stream in the Fs2 media backend.
-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c 06a800e5fb13f41e6d315cfbb13f4982fe564a79
+++ libpurple/media/backend-fs2.c 147100f6359026a98e213963ab3104100a2d7e74
@@ -625,6 +625,33 @@ _get_stream(PurpleMediaBackendFs2 *self,
return NULL;
}
+static GList *
+_get_streams(PurpleMediaBackendFs2 *self,
+ const gchar *sess_id, const gchar *name)
+{
+ PurpleMediaBackendFs2Private *priv;
+ GList *streams, *ret = NULL;
+
+ g_return_val_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self), NULL);
+
+ priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+ streams = priv->streams;
+
+ for (; streams; streams = g_list_next(streams)) {
+ PurpleMediaBackendFs2Stream *stream = streams->data;
+
+ if (sess_id != NULL && strcmp(stream->session->id, sess_id))
+ continue;
+ else if (name != NULL && strcmp(stream->participant, name))
+ continue;
+ else
+ ret = g_list_prepend(ret, stream);
+ }
+
+ ret = g_list_reverse(ret);
+ return ret;
+}
+
static PurpleMediaBackendFs2Session *
_get_session_from_fs_stream(PurpleMediaBackendFs2 *self, FsStream *stream)
{
@@ -964,6 +991,33 @@ _stream_info_cb(PurpleMedia *media, Purp
gchar *sid, gchar *name, gboolean local,
PurpleMediaBackendFs2 *self)
{
+ if (type == PURPLE_MEDIA_INFO_ACCEPT) {
+ GList *streams = _get_streams(self, sid, name);
+
+ for (; streams; streams =
+ g_list_delete_link(streams, streams)) {
+ PurpleMediaBackendFs2Stream *stream = streams->data;
+ GError *err = NULL;
+
+ g_object_set(G_OBJECT(stream->stream), "direction",
+ _session_type_to_fs_stream_direction(
+ stream->session->type), NULL);
+
+ if (stream->remote_candidates == NULL)
+ continue;
+
+ fs_stream_set_remote_candidates(stream->stream,
+ stream->remote_candidates, &err);
+
+ if (err == NULL)
+ continue;
+
+ purple_debug_error("backend-fs2", "Error adding "
+ "remote candidates: %s\n",
+ err->message);
+ g_error_free(err);
+ }
+ }
}
static gboolean
============================================================
--- libpurple/media/media.c 8a87c9e7077146789fec87886bc41c25eda6dccd
+++ libpurple/media/media.c 3d914e5a558a2c89a32ee7504c35826d876debb5
@@ -509,72 +509,6 @@ purple_media_get_property (GObject *obje
}
-static FsCandidate *
-purple_media_candidate_to_fs(PurpleMediaCandidate *candidate)
-{
- FsCandidate *fscandidate;
- gchar *foundation;
- guint component_id;
- gchar *ip;
- guint port;
- gchar *base_ip;
- guint base_port;
- PurpleMediaNetworkProtocol proto;
- guint32 priority;
- PurpleMediaCandidateType type;
- gchar *username;
- gchar *password;
- guint ttl;
-
- if (candidate == NULL)
- return NULL;
-
- g_object_get(G_OBJECT(candidate),
- "foundation", &foundation,
- "component-id", &component_id,
- "ip", &ip,
- "port", &port,
- "base-ip", &base_ip,
- "base-port", &base_port,
- "protocol", &proto,
- "priority", &priority,
- "type", &type,
- "username", &username,
- "password", &password,
- "ttl", &ttl,
- NULL);
-
- fscandidate = fs_candidate_new(foundation,
- component_id, type,
- proto, ip, port);
-
- fscandidate->base_ip = base_ip;
- fscandidate->base_port = base_port;
- fscandidate->priority = priority;
- fscandidate->username = username;
- fscandidate->password = password;
- fscandidate->ttl = ttl;
-
- g_free(foundation);
- g_free(ip);
- return fscandidate;
-}
-
-static GList *
-purple_media_candidate_list_to_fs(GList *candidates)
-{
- GList *new_list = NULL;
-
- for (; candidates; candidates = g_list_next(candidates)) {
- new_list = g_list_prepend(new_list,
- purple_media_candidate_to_fs(
- candidates->data));
- }
-
- new_list = g_list_reverse(new_list);
- return new_list;
-}
-
static FsMediaType
purple_media_to_fs_media_type(PurpleMediaSessionType type)
{
@@ -974,27 +908,8 @@ purple_media_stream_info(PurpleMedia *me
for (; streams; streams =
g_list_delete_link(streams, streams)) {
PurpleMediaStream *stream = streams->data;
- g_object_set(G_OBJECT(stream->stream), "direction",
- purple_media_to_fs_stream_direction(
- stream->session->type), NULL);
- stream->accepted = TRUE;
- if (stream->remote_candidates != NULL) {
- GError *err = NULL;
- GList *candidates;
-
- candidates = purple_media_candidate_list_to_fs(
- stream->remote_candidates);
- fs_stream_set_remote_candidates(stream->stream,
- candidates, &err);
- fs_candidate_list_destroy(candidates);
-
- if (err) {
- purple_debug_error("media", "Error adding remote"
- " candidates: %s\n", err->message);
- g_error_free(err);
- }
- }
+ stream->accepted = TRUE;
}
} else if (local == TRUE && (type == PURPLE_MEDIA_INFO_MUTE ||
type == PURPLE_MEDIA_INFO_UNMUTE)) {
@@ -1444,11 +1359,8 @@ purple_media_add_remote_candidates(Purpl
stream->remote_candidates = g_list_concat(stream->remote_candidates,
purple_media_candidate_list_copy(remote_candidates));
- if (stream->accepted == TRUE) {
- purple_media_backend_add_remote_candidates(
- media->priv->backend, sess_id, participant,
- remote_candidates);
- }
+ purple_media_backend_add_remote_candidates(media->priv->backend,
+ sess_id, participant, remote_candidates);
#endif
}
More information about the Commits
mailing list