Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture rtp host and port from sdp #428

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -959,6 +957,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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it might be slightly better to always call extract_rtp_remote_addr (at line 2820 or so) instead of guarding it with #ifdef RTP_STREAM, and store the host/port off as member variables on the call object, then just use those (in the same way we use the pre-stored peer_tag when handling E_Message_Peer_Tag_Param). That would guarantee that the host/port would be retrieved consistently whether you used built-in RTP streaming or this method.

// 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