Skip to content

Commit 8f454e5

Browse files
committed
capture rtp host and port from sdp
1 parent 1e6af75 commit 8f454e5

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)
@@ -957,6 +955,19 @@ char * call::get_last_header(const char * name)
957955
ERROR("call::get_last_header: Header to parse bigger than %d (%zu)", MAX_HEADER_LEN, strlen(name));
958956
}
959957

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

0 commit comments

Comments
 (0)