pidgin.vv.yahoo.voice: c14691eb: Move SDP media string generation to its ...
maiku at pidgin.im
maiku at pidgin.im
Mon Aug 31 00:15:40 EDT 2009
-----------------------------------------------------------------
Revision: c14691eb12207b312c36cf3ba3c8309eca509c30
Ancestor: 9d6cc5a4aa44d370386bf1578e7db9c313e461ff
Author: maiku at pidgin.im
Date: 2009-08-31T00:58:48
Branch: im.pidgin.pidgin.vv.yahoo.voice
URL: http://d.pidgin.im/viewmtn/revision/info/c14691eb12207b312c36cf3ba3c8309eca509c30
Modified files:
libpurple/protocols/yahoo/yahoo_sip.c
ChangeLog:
Move SDP media string generation to its own function.
-------------- next part --------------
============================================================
--- libpurple/protocols/yahoo/yahoo_sip.c 77f91fbb73db99d8ba58ce996d98e0aa93e2dea6
+++ libpurple/protocols/yahoo/yahoo_sip.c 6d45343bcdedf6a22cdeab898b7a6bcdcfcae5a5
@@ -205,18 +205,25 @@ yahoo_sdp_parse_media(PurpleMedia *media
return TRUE;
}
-static void
-yahoo_sip_send_response(PurpleMedia *media, nua_handle_t *nh)
+static gchar *
+yahoo_stream_to_sdp(PurpleMedia *media, const gchar *session_id,
+ const gchar *name)
{
- const gchar *name = purple_url_decode(
- nua_handle_remote(nh)->a_display);
GList *codecs, *candidates;
gchar **codec_strs, **codec_strs2, **candidate_strs,
*codec_str, *codec_str2, *candidate_str, *sdp_str;
+ const gchar *type;
guint port = 0;
guint i = 0;
- codecs = purple_media_get_codecs(media, "yahoo-voice");
+ g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
+ g_return_val_if_fail(session_id, NULL);
+ g_return_val_if_fail(name, NULL);
+
+ type = purple_media_get_session_type(media, session_id) &
+ PURPLE_MEDIA_AUDIO ? "audio" : "video";
+
+ codecs = purple_media_get_codecs(media, session_id);
codec_strs = g_new0(gchar*, g_list_length(codecs) + 1);
codec_strs2 = g_new0(gchar*, g_list_length(codecs) + 1);
@@ -239,7 +246,7 @@ yahoo_sip_send_response(PurpleMedia *med
purple_debug_info("yahoo", "local codecs:\n%s", codec_str);
candidates = purple_media_get_local_candidates(media,
- "yahoo-voice", name);
+ session_id, name);
candidate_strs = g_new0(gchar*, g_list_length(candidates) + 1);
if (candidates->data)
@@ -270,21 +277,44 @@ yahoo_sip_send_response(PurpleMedia *med
g_strfreev(candidate_strs);
purple_debug_info("yahoo", "local candidates:\n%s", candidate_str);
- sdp_str = g_strdup_printf("m=audio %d RTP/AVP %s\r"
- "\n%s%sa=sendrecv\r\n", port, codec_str2,
+ sdp_str = g_strdup_printf("m=%s %d RTP/AVP %s\r"
+ "\n%s%sa=sendrecv\r\n", type, port, codec_str2,
codec_str, candidate_str);
g_free(codec_str);
g_free(codec_str2);
g_free(candidate_str);
- nua_respond(nh, 200, "OK",
- SOATAG_USER_SDP_STR(sdp_str),
- /* This is essentially all common codecs */
- SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
- TAG_END());
- g_free(sdp_str);
+ return sdp_str;
}
+static gchar *
+yahoo_sdp_generate_media(PurpleMedia *media, const gchar *name)
+{
+ GList *ids;
+ gchar **media_strs, *ret;
+ guint i = 0;
+
+ g_return_val_if_fail(PURPLE_IS_MEDIA(media), NULL);
+ g_return_val_if_fail(name, NULL);
+
+ ids = purple_media_get_session_ids(media);
+ media_strs = g_new0(gchar*, g_list_length(ids));
+
+ for (; ids; ids = g_list_delete_link(ids, ids)) {
+ media_strs[i] = yahoo_stream_to_sdp(media, ids->data, name);
+ if (!media_strs[i]) {
+ g_list_free(ids);
+ g_strfreev(media_strs);
+ return NULL;
+ }
+ ++i;
+ }
+ g_list_free(ids);
+ ret = g_strjoinv(NULL, media_strs);
+ g_strfreev(media_strs);
+ return ret;
+}
+
static void
yahoo_sip_ready(PurpleMedia *media, nua_handle_t *nh)
{
@@ -296,7 +326,22 @@ yahoo_sip_ready(PurpleMedia *media, nua_
if (purple_media_is_initiator(media, NULL, NULL)) {
/* send initiate */
} else {
- yahoo_sip_send_response(media, nh);
+ const gchar *name = purple_url_decode(
+ nua_handle_remote(nh)->a_display);
+ gchar *sdp_str = yahoo_sdp_generate_media(media, name);
+
+ if (!sdp_str) {
+ purple_debug_error("yahoo", "Error generating"
+ "SDP media string\n");
+ return;
+ }
+
+ nua_respond(nh, 200, "OK",
+ SOATAG_USER_SDP_STR(sdp_str),
+ /* This is essentially all common codecs */
+ SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
+ TAG_END());
+ g_free(sdp_str);
}
g_signal_handlers_disconnect_by_func(G_OBJECT(media),
More information about the Commits
mailing list