From 1d107ee29615964292682f31ab6364c7716458b6 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Tue, 27 Oct 2015 09:04:56 +0100 Subject: [PATCH] media: refactor candidate_pair_established_cb Move the callback to sipe_media_stream structure and rename to candidate_pairs_established_cb since it's fired after both RTP and RTCP pairs become established. Also, media call argument is useless because stream already has its reference. --- src/api/sipe-backend.h | 3 +-- src/core/sipe-ft-lync.c | 5 ++--- src/purple/purple-media.c | 17 +++++++++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/api/sipe-backend.h b/src/api/sipe-backend.h index a32b1abc..0547c208 100644 --- a/src/api/sipe-backend.h +++ b/src/api/sipe-backend.h @@ -368,6 +368,7 @@ struct sipe_media_stream { struct sipe_media_call *call; gchar *id; + void (*candidate_pairs_established_cb)(struct sipe_media_stream *); void (*read_cb)(struct sipe_media_stream *); }; @@ -385,8 +386,6 @@ struct sipe_media_call { void (*call_reject_cb)(struct sipe_media_call *, gboolean local); void (*call_hold_cb) (struct sipe_media_call *, gboolean local, gboolean state); - void (*candidate_pair_established_cb)(struct sipe_media_call *, - struct sipe_media_stream *); void (*call_hangup_cb)(struct sipe_media_call *, gboolean local); void (*error_cb)(struct sipe_media_call *, gchar *message); }; diff --git a/src/core/sipe-ft-lync.c b/src/core/sipe-ft-lync.c index a191ac00..8dc76e4d 100644 --- a/src/core/sipe-ft-lync.c +++ b/src/core/sipe-ft-lync.c @@ -163,8 +163,7 @@ mime_mixed_cb(gpointer user_data, const GSList *fields, const gchar *body, } static void -candidate_pair_established_cb(SIPE_UNUSED_PARAMETER struct sipe_media_call *call, - struct sipe_media_stream *stream) +candidate_pairs_established_cb(struct sipe_media_stream *stream) { struct sipe_file_transfer_lync *ft_private; static const gchar *DOWNLOAD_FILE_REQUEST = @@ -467,7 +466,6 @@ process_incoming_invite_ft_lync(struct sipe_core_private *sipe_private, } call = ft_private->call; - call->candidate_pair_established_cb = candidate_pair_established_cb; ft_private->public.ft_init = ft_lync_incoming_init; ft_private->public.ft_cancelled = ft_lync_incoming_cancelled; @@ -478,6 +476,7 @@ process_incoming_invite_ft_lync(struct sipe_core_private *sipe_private, call->call_reject_cb = call_reject_cb; stream = sipe_core_media_get_stream_by_id(call, "data"); + stream->candidate_pairs_established_cb = candidate_pairs_established_cb; stream->read_cb = read_cb; sipe_media_stream_add_extra_attribute(stream, "recvonly", NULL); sipe_media_stream_set_data(stream, ft_private, diff --git a/src/purple/purple-media.c b/src/purple/purple-media.c index d6928531..6e58ac47 100644 --- a/src/purple/purple-media.c +++ b/src/purple/purple-media.c @@ -244,22 +244,27 @@ on_stream_info_cb(PurpleMedia *media, static void on_candidate_pair_established_cb(SIPE_UNUSED_PARAMETER PurpleMedia *media, - SIPE_UNUSED_PARAMETER const gchar *sessionid, + const gchar *sessionid, SIPE_UNUSED_PARAMETER const gchar *participant, SIPE_UNUSED_PARAMETER PurpleMediaCandidate *local_candidate, SIPE_UNUSED_PARAMETER PurpleMediaCandidate *remote_candidate, - SIPE_UNUSED_PARAMETER struct sipe_media_call *call) + struct sipe_media_call *call) { + struct sipe_media_stream *stream = + sipe_core_media_get_stream_by_id(call, sessionid); + + if (!stream) { + return; + } + #ifdef HAVE_PURPLE_NEW_TCP_ENUMS if (purple_media_candidate_get_protocol(local_candidate) != PURPLE_MEDIA_NETWORK_PROTOCOL_UDP) { purple_media_set_send_rtcp_mux(media, sessionid, participant, TRUE); } #endif - if (call->candidate_pair_established_cb) { - struct sipe_media_stream *stream = - sipe_core_media_get_stream_by_id(call, sessionid); - call->candidate_pair_established_cb(call, stream); + if (stream->candidate_pairs_established_cb) { + stream->candidate_pairs_established_cb(stream); } } -- 2.11.4.GIT