Skip to content

Commit 50e0e02

Browse files
committed
capture rtp host and port from sdp
1 parent b9fd107 commit 50e0e02

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/call.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ unsigned int call::wake()
162162
return wake;
163163
}
164164

165-
#if defined(PCAPPLAY) || defined(RTP_STREAM) || defined(GTEST)
166165
static std::string find_in_sdp(std::string const &pattern, std::string const &msg)
167166
{
168167
std::string::size_type begin, end;
@@ -180,7 +179,6 @@ static std::string find_in_sdp(std::string const &pattern, std::string const &ms
180179

181180
return msg.substr(begin, end - begin);
182181
}
183-
#endif
184182

185183
#ifdef PCAPPLAY
186184
void call::get_remote_media_addr(std::string const &msg)
@@ -959,6 +957,19 @@ char * call::get_last_header(const char * name)
959957
ERROR("call::get_last_header: Header to parse bigger than %d (%zu)", MAX_HEADER_LEN, strlen(name));
960958
}
961959

960+
if(strcmp(name, "media_ip")==0) {
961+
// get media ip from sdp
962+
static std::string host;
963+
host = find_in_sdp(media_ip_is_ipv6 ? "c=IN IP6 " : "c=IN IP4 ", last_recv_msg);
964+
return const_cast<char*>(host.c_str());
965+
}
966+
if(strcmp(name, "media_port")==0) {
967+
// get media port from sdp
968+
static std::string port;
969+
port = find_in_sdp("m=audio ", last_recv_msg);
970+
return const_cast<char*>(port.c_str());
971+
}
972+
962973
if (name[len - 1] == ':') {
963974
return get_header(last_recv_msg, name, false);
964975
} else {

0 commit comments

Comments
 (0)