Fix #210: Conference call ends with error message (II)
authorJakub Adam <jakub.adam@ktknet.cz>
Wed, 26 Mar 2014 14:09:38 +0000 (26 15:09 +0100)
committerJakub Adam <jakub.adam@ktknet.cz>
Wed, 26 Mar 2014 15:26:11 +0000 (26 16:26 +0100)
Looks like we don't have a reliable way to recognize which ICE dialect
to use to communicate with conferencing server (perhaps it's hard-coded
in Lync/OCS client corresponding to the server release?). Lacking a
better option let's just retry the call with the other ICE version when
the first attempt fails.

src/core/sipe-media.c

index 5b2cbb5..4f4d5fc 100644 (file)
@@ -1153,22 +1153,23 @@ reinvite_on_candidate_pair_cb(struct sipe_core_public *sipe_public)
 }
 
 static gboolean
-maybe_retry_call_with_ice_v6(struct sipe_core_private *sipe_private,
-                            struct transaction *trans)
+maybe_retry_call_with_ice_version(struct sipe_core_private *sipe_private,
+                                 SipeIceVersion ice_version,
+                                 struct transaction *trans)
 {
        struct sipe_media_call_private *call_private = sipe_private->media_call;
 
-       if (call_private->ice_version == SIPE_ICE_RFC_5245 &&
+       if (call_private->ice_version != ice_version &&
            sip_transaction_cseq(trans) == 1) {
                gchar *with = g_strdup(call_private->with);
                struct sipe_backend_media *backend_private = call_private->public.backend_private;
                gboolean with_video = sipe_backend_media_get_stream_by_id(backend_private, "video") != NULL;
 
                sipe_media_hangup(call_private);
-               SIPE_DEBUG_INFO_NOFORMAT("Retrying call witn ICEv6.");
-               // We might be calling to OC 2007 instance, retry with ICEv6
-               sipe_media_initiate_call(sipe_private, with,
-                                         SIPE_ICE_DRAFT_6, with_video);
+               SIPE_DEBUG_INFO("Retrying call with ICEv%d.",
+                               ice_version == SIPE_ICE_DRAFT_6 ? 6 : 19);
+               sipe_media_initiate_call(sipe_private, with, ice_version,
+                                        with_video);
 
                g_free(with);
                return TRUE;
@@ -1222,7 +1223,7 @@ process_invite_call_response(struct sipe_core_private *sipe_private,
                        case 415:
                                // OCS/Lync really sends response string with 'Mutipart' typo.
                                if (sipe_strequal(msg->responsestr, "Mutipart mime in content type not supported by Archiving CDR service") &&
-                                   maybe_retry_call_with_ice_v6(sipe_private, trans)) {
+                                   maybe_retry_call_with_ice_version(sipe_private, SIPE_ICE_DRAFT_6, trans)) {
                                        return TRUE;
                                }
                                title = _("Unsupported media type");
@@ -1238,6 +1239,7 @@ process_invite_call_response(struct sipe_core_private *sipe_private,
                                 * 488 Encryption Levels not compatible
                                 */
                                const gchar *ms_diag = sipmsg_find_header(msg, "ms-client-diagnostics");
+                               SipeIceVersion retry_ice_version = SIPE_ICE_DRAFT_6;
 
                                if (sipe_strequal(msg->responsestr, "Encryption Levels not compatible") ||
                                    (ms_diag && g_str_has_prefix(ms_diag, "52017;"))) {
@@ -1246,7 +1248,15 @@ process_invite_call_response(struct sipe_core_private *sipe_private,
                                        break;
                                }
 
-                               if (maybe_retry_call_with_ice_v6(sipe_private, trans)) {
+                               /* Check if this is failed conference using
+                                * ICEv6 with reason "Error parsing SDP" and
+                                * retry using ICEv19. */
+                               ms_diag = sipmsg_find_header(msg, "ms-diagnostics");
+                               if (ms_diag && g_str_has_prefix(ms_diag, "7008;")) {
+                                       retry_ice_version = SIPE_ICE_RFC_5245;
+                               }
+
+                               if (maybe_retry_call_with_ice_version(sipe_private, retry_ice_version, trans)) {
                                        return TRUE;
                                }
                                // Break intentionally omitted