Skip to content

Commit

Permalink
capture rtp host and port from sdp
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-i2x committed Oct 30, 2019
1 parent 1e6af75 commit 8f454e5
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ unsigned int call::wake()
return wake;
}

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

return msg.substr(begin, end - begin);
}
#endif

#ifdef PCAPPLAY
void call::get_remote_media_addr(std::string const &msg)
Expand Down Expand Up @@ -957,6 +955,19 @@ char * call::get_last_header(const char * name)
ERROR("call::get_last_header: Header to parse bigger than %d (%zu)", MAX_HEADER_LEN, strlen(name));
}

if(strcmp(name, "media_ip")==0) {
// get media ip from sdp
static std::string host;
host = find_in_sdp(media_ip_is_ipv6 ? "c=IN IP6 " : "c=IN IP4 ", last_recv_msg);
return const_cast<char*>(host.c_str());
}
if(strcmp(name, "media_port")==0) {
// get media port from sdp
static std::string port;
port = find_in_sdp("m=audio ", last_recv_msg);
return const_cast<char*>(port.c_str());
}

if (name[len - 1] == ':') {
return get_header(last_recv_msg, name, false);
} else {
Expand Down

0 comments on commit 8f454e5

Please sign in to comment.