From 8515b1564b2156d8614f0c7ba6915018802abebd Mon Sep 17 00:00:00 2001 From: Thomas Uhle Date: Sun, 17 Jan 2021 17:55:48 +0100 Subject: [PATCH] Fix regression introduced by commit b2f7d2acf216399f8cf563b5672ae15b78c21ded (pulled in by #481) It was fixed years ago by commit 0026639e7c2f9c3e10536ee86d0508e699e0cd70 (PR #129). --- src/call.cpp | 49 ++++++++++--------------------------------------- 1 file changed, 10 insertions(+), 39 deletions(-) diff --git a/src/call.cpp b/src/call.cpp index c15b2f1d..3b3d2148 100644 --- a/src/call.cpp +++ b/src/call.cpp @@ -2683,42 +2683,11 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf dest += snprintf(dest, left, "%s", media_ip); break; case E_Message_Media_Port: - { + case E_Message_Auto_Media_Port: { int port = media_port + comp->offset; -#ifdef PCAPPLAY - char *begin = dest; - while (begin > msg_buffer) { - if (*begin == '\n') { - break; - } - begin--; + if (comp->type == E_Message_Auto_Media_Port) { + port += (4 * (number - 1)) % 10000; } - if (begin == msg_buffer) { - ERROR("Can not find beginning of a line for the media port!\n"); - } - if (strstr(begin, "audio")) { - if (media_ip_is_ipv6) { - (_RCAST(struct sockaddr_in6 *, &(play_args_a.from)))->sin6_port = port; - } else { - (_RCAST(struct sockaddr_in *, &(play_args_a.from)))->sin_port = port; - } - } else if (strstr(begin, "video")) { - if (media_ip_is_ipv6) { - (_RCAST(struct sockaddr_in6 *, &(play_args_v.from)))->sin6_port = port; - } else { - (_RCAST(struct sockaddr_in *, &(play_args_v.from)))->sin_port = port; - } - } else { - // This check will not do, as we use the media_port in other places too. - //ERROR("media_port keyword with no audio or video on the current line (%s)", begin); - } -#endif - dest += sprintf(dest, "%u", port); - break; - } - case E_Message_Auto_Media_Port: - { - int port = port = media_port + (4 * (number - 1)) % 10000 + comp->offset; #ifdef PCAPPLAY char *begin = dest; while (begin > msg_buffer) { @@ -2741,13 +2710,15 @@ char* call::createSendingMessage(SendingMessage *src, int P_index, char *msg_buf // This check will not do, as we use the media_port in other places too. //ERROR("media_port keyword with no audio or video on the current line (%s)", begin); } - if (media_ip_is_ipv6) { - (_RCAST(struct sockaddr_in6 *, &(play_args->from)))->sin6_port = htons(port); - } else { - (_RCAST(struct sockaddr_in *, &(play_args->from)))->sin_port = htons(port); + if (play_args != NULL) { + if (media_ip_is_ipv6) { + (_RCAST(struct sockaddr_in6 *, &(play_args->from)))->sin6_port = htons(port); + } else { + (_RCAST(struct sockaddr_in *, &(play_args->from)))->sin_port = htons(port); + } } #endif - dest += sprintf(dest, "%u", port); + dest += snprintf(dest, left, "%u", port); break; } #ifdef RTP_STREAM