]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-9962: [mod_spandsp] Avaya IP Office IB FAX call T38 v0 failed #resolve
authorAnthony Minessale <anthm@freeswitch.org>
Mon, 30 Jan 2017 16:53:39 +0000 (10:53 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Mon, 30 Jan 2017 16:53:39 +0000 (10:53 -0600)
src/switch_core_media.c

index 82c397b31c4357593ed52ed8d738a0e8509c9c15..bb13376654d272bef63039d90ea9b56305e1393e 100644 (file)
@@ -211,6 +211,8 @@ typedef struct switch_rtp_engine_s {
        switch_frame_buffer_t *write_fb;
 } switch_rtp_engine_t;
 
+#define MAX_REJ_STREAMS 10
+
 struct switch_media_handle_s {
        switch_core_session_t *session;
        switch_channel_t *channel;
@@ -227,6 +229,9 @@ struct switch_media_handle_s {
        int payload_space;
        char *origin;
 
+       sdp_media_e rejected_streams[MAX_REJ_STREAMS];
+       int rej_idx;
+
        switch_mutex_t *mutex;
        switch_mutex_t *sdp_mutex;
        switch_mutex_t *control_mutex;
@@ -4244,11 +4249,29 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
                sendonly = 2;                   /* global sendonly always wins */
        }
 
+       memset(smh->rejected_streams, 0, sizeof(smh->rejected_streams));
+       smh->rej_idx = 0;
+
        for (m = sdp->sdp_media; m; m = m->m_next) {
                sdp_connection_t *connection;
                switch_core_session_t *other_session;
 
-               if (!m->m_port) {
+               if (!m->m_port && smh->rej_idx < MAX_REJ_STREAMS - 1) {
+
+                       switch(m->m_type) {
+                       case sdp_media_audio:
+                               smh->rejected_streams[smh->rej_idx++] = sdp_media_audio;
+                               break;
+                       case sdp_media_video:
+                               smh->rejected_streams[smh->rej_idx++] = sdp_media_video;
+                               break;
+                       case sdp_media_image:
+                               smh->rejected_streams[smh->rej_idx++] = sdp_media_image;
+                               break;
+                       default:
+                               break;
+                       }
+
                        continue;
                }
 
@@ -10808,6 +10831,18 @@ SWITCH_DECLARE(void) switch_core_media_absorb_sdp(switch_core_session_t *session
        }
 }
 
+static switch_bool_t stream_rejected(switch_media_handle_t *smh, sdp_media_e st)
+{
+       int x;
+
+       for (x = 0; x < smh->rej_idx; x++) {
+               if (smh->rejected_streams[x] == st) {
+                       return SWITCH_TRUE;
+               }
+       }
+
+       return SWITCH_FALSE;
+}
 
 //?
 SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t *session, switch_t38_options_t *t38_options, int insist)
@@ -10915,7 +10950,11 @@ SWITCH_DECLARE(void) switch_core_media_set_udptl_image_sdp(switch_core_session_t
                jbig_off = "a=T38FaxTranscodingJBIG:0\r\n";
 
        }
-       
+
+       if (stream_rejected(smh, sdp_media_audio)) {
+               switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+                                               "m=audio 0 RTP/AVP 0\r\n");
+       }
 
        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
                                        "m=image %d udptl t38\r\n"