-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Initial support to negotiate SDPs in Single Peer Connection #1167
Changes from 9 commits
1440682
cba96e9
889773a
bb41069
06d2e27
179ac02
8afa5e7
2eb2b8e
07ea345
bfc713f
576f893
0f35324
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,6 @@ namespace erizo { | |
hasAudio = false; | ||
hasVideo = false; | ||
profile = SAVPF; | ||
audio_ssrc = 0; | ||
videoCodecs = 0; | ||
audioCodecs = 0; | ||
videoSdpMLine = -1; | ||
|
@@ -306,16 +305,6 @@ namespace erizo { | |
} | ||
} | ||
} | ||
|
||
if (audio_ssrc == 0) { | ||
audio_ssrc = 44444; | ||
} | ||
if (audioDirection != RECVONLY) { | ||
sdp << "a=ssrc:" << audio_ssrc << " cname:o/i14u9pJrxRKAsu" << endl << | ||
"a=ssrc:"<< audio_ssrc << " msid:"<< msidtemp << " a0"<< endl << | ||
"a=ssrc:"<< audio_ssrc << " mslabel:"<< msidtemp << endl << | ||
"a=ssrc:"<< audio_ssrc << " label:" << msidtemp << "a0" << endl; | ||
} | ||
} | ||
|
||
if (printedVideo && this->hasVideo) { | ||
|
@@ -426,9 +415,6 @@ namespace erizo { | |
} | ||
} | ||
} | ||
if (video_ssrc_list.empty()) { | ||
video_ssrc_list.push_back(55543); | ||
} | ||
|
||
if (!rids().empty()) { | ||
sdp << "a=simulcast: " << rids()[0].direction << " rid="; | ||
|
@@ -440,25 +426,6 @@ namespace erizo { | |
} | ||
sdp << '\n'; | ||
} | ||
|
||
if (videoDirection != RECVONLY) { | ||
std::for_each(video_ssrc_list.begin(), video_ssrc_list.end(), | ||
[&sdp, &msidtemp](uint32_t &video_ssrc){ | ||
sdp << "a=ssrc:" << video_ssrc << " cname:o/i14u9pJrxRKAsu" << endl << | ||
"a=ssrc:" << video_ssrc << " msid:"<< msidtemp << " v0"<< endl << | ||
"a=ssrc:" << video_ssrc << " mslabel:"<< msidtemp << endl << | ||
"a=ssrc:" << video_ssrc << " label:" << msidtemp << "v0" << endl; | ||
}); | ||
/* TODO(pedro) properly encode FID groups in sdp when supported | ||
std::for_each(video_rtx_ssrc_map.begin(), video_rtx_ssrc_map.end(), | ||
[&sdp, &msidtemp](uint32_t &video_rtx_ssrc){ | ||
sdp << "a=ssrc:" << video_rtx_ssrc << " cname:o/i14u9pJrxRKAsu" << endl << | ||
"a=ssrc:" << video_rtx_ssrc << " msid:"<< msidtemp << " v0"<< endl << | ||
"a=ssrc:" << video_rtx_ssrc << " mslabel:"<< msidtemp << endl << | ||
"a=ssrc:" << video_rtx_ssrc << " label:" << msidtemp << "v0" << endl; | ||
}); | ||
*/ | ||
} | ||
} | ||
ELOG_DEBUG("sdp local \n %s", sdp.str().c_str()); | ||
return sdp.str(); | ||
|
@@ -767,55 +734,6 @@ namespace erizo { | |
} | ||
} | ||
|
||
if (isSsrc != std::string::npos) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💯x 👍 To removing the SSRC parsing from here |
||
std::vector<std::string> parts = stringutil::splitOneOf(line, " :", 2); | ||
// FIXME add error checking | ||
if (mtype == VIDEO_TYPE) { | ||
uint32_t parsed_ssrc = strtoul(parts[1].c_str(), nullptr, 10); | ||
ELOG_DEBUG("message: maybeAdd video in isSsrc, ssrc: %u", parsed_ssrc); | ||
maybeAddSsrcToList(parsed_ssrc); | ||
} else if ((mtype == AUDIO_TYPE) && (audio_ssrc == 0)) { | ||
audio_ssrc = strtoul(parts[1].c_str(), nullptr, 10); | ||
ELOG_DEBUG("audio ssrc: %u", audio_ssrc); | ||
} | ||
} | ||
|
||
if (isSsrcGroup != std::string::npos) { | ||
if (mtype != VIDEO_TYPE) { | ||
continue; | ||
} | ||
std::vector<std::string> parts = stringutil::splitOneOf(line, " :", 10); | ||
if (parts.size() < 4) { | ||
continue; | ||
} | ||
if (parts[1] == kSimulcastGroup) { | ||
ELOG_DEBUG("Detected SIM group, size: %lu", parts.size()); | ||
std::vector<uint32_t> old_video_ssrc_list; | ||
if (video_ssrc_list.size() > 0) { | ||
old_video_ssrc_list = video_ssrc_list; | ||
video_ssrc_list.clear(); | ||
} | ||
std::for_each(parts.begin() + 2, parts.end(), [this] (std::string &part){ | ||
uint32_t parsed_ssrc = strtoul(part.c_str(), nullptr, 10); | ||
ELOG_DEBUG("maybeAddSsrc video SIM, ssrc %u", parsed_ssrc); | ||
maybeAddSsrcToList(parsed_ssrc); | ||
}); | ||
for (uint32_t ssrc : old_video_ssrc_list) { | ||
maybeAddSsrcToList(ssrc); | ||
} | ||
} else if (parts[1] == kFidGroup) { | ||
int number_of_ssrcs = parts.size() - 2; | ||
if (number_of_ssrcs != 2) { | ||
ELOG_DEBUG("FID Group with wrong number of SSRCs, ignoring"); | ||
continue; | ||
} | ||
uint32_t original_ssrc = strtoul(parts[2].c_str(), nullptr, 10); | ||
uint32_t rtx_ssrc = strtoul(parts[3].c_str(), nullptr, 10); | ||
video_rtx_ssrc_map[rtx_ssrc] = original_ssrc; | ||
ELOG_DEBUG("message: parsed FID group, original_src: %u, rtx_ssrc: %u", original_ssrc, rtx_ssrc); | ||
} | ||
} | ||
|
||
if (isRid != std::string::npos) { | ||
std::vector<std::string> parts = stringutil::splitOneOf(line, ":", 2); | ||
if (mtype == VIDEO_TYPE) { | ||
|
@@ -973,10 +891,6 @@ namespace erizo { | |
} | ||
} | ||
|
||
if (video_ssrc_list.empty()) { | ||
video_ssrc_list.push_back(0); | ||
} | ||
|
||
// go through the payload_map_ and match it with internalPayloadVector_ | ||
// generate rtpMaps and payloadVector | ||
std::vector<RtpMap> rtx_maps; | ||
|
@@ -1214,21 +1128,6 @@ namespace erizo { | |
s[len] = 0; | ||
} | ||
|
||
void SdpInfo::maybeAddSsrcToList(uint32_t ssrc) { | ||
auto find_rt = video_rtx_ssrc_map.find(ssrc); | ||
if (find_rt != video_rtx_ssrc_map.end()) { | ||
// Its a rtx ssrc | ||
return; | ||
} | ||
auto value = std::find_if(video_ssrc_list.begin(), video_ssrc_list.end(), [ssrc](uint32_t current_ssrc) { | ||
return ssrc == current_ssrc; | ||
}); | ||
if (value == video_ssrc_list.end()) { | ||
ELOG_DEBUG("message: Adding ssrc to list, ssrc: %u", ssrc); | ||
video_ssrc_list.push_back(ssrc); | ||
} | ||
} | ||
|
||
bool operator==(const Rid& lhs, const Rid& rhs) { | ||
return lhs.id == rhs.id && lhs.direction == rhs.direction; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,12 +111,14 @@ bool WebRtcConnection::createOffer(bool video_enabled, bool audioEnabled, bool b | |
|
||
if (video_enabled_) { | ||
forEachMediaStream([this] (const std::shared_ptr<MediaStream> &media_stream) { | ||
local_sdp_->video_ssrc_list.push_back(media_stream->getVideoSinkSSRC()); | ||
std::vector<uint32_t> video_ssrc_list = std::vector<uint32_t>(); | ||
video_ssrc_list.push_back(media_stream->getVideoSinkSSRC()); | ||
local_sdp_->video_ssrc_map[media_stream->getLabel()] = video_ssrc_list; | ||
}); | ||
} | ||
if (audio_enabled_) { | ||
forEachMediaStream([this] (const std::shared_ptr<MediaStream> &media_stream) { | ||
local_sdp_->audio_ssrc = media_stream->getAudioSinkSSRC(); | ||
local_sdp_->audio_ssrc_map[media_stream->getLabel()] = media_stream->getAudioSinkSSRC(); | ||
}); | ||
} | ||
|
||
|
@@ -159,10 +161,15 @@ void WebRtcConnection::addMediaStream(std::shared_ptr<MediaStream> media_stream) | |
} | ||
|
||
void WebRtcConnection::removeMediaStream(const std::string& stream_id) { | ||
ELOG_DEBUG("%s message: removing mediaStream, id: %s", toLog(), stream_id.c_str()) | ||
ELOG_DEBUG("%s message: removing mediaStream, id: %s", toLog(), stream_id.c_str()); | ||
media_streams_.erase(std::remove_if(media_streams_.begin(), media_streams_.end(), | ||
[stream_id](const std::shared_ptr<MediaStream> &stream) { | ||
return stream->getId() == stream_id; | ||
[stream_id, this](const std::shared_ptr<MediaStream> &stream) { | ||
bool isStream = stream->getId() == stream_id; | ||
if (isStream) { | ||
local_sdp_->video_ssrc_map.erase(local_sdp_->video_ssrc_map.find(stream->getLabel())); | ||
local_sdp_->audio_ssrc_map.erase(local_sdp_->audio_ssrc_map.find(stream->getLabel())); | ||
} | ||
return isStream; | ||
}), media_streams_.end()); | ||
} | ||
|
||
|
@@ -183,6 +190,18 @@ bool WebRtcConnection::setRemoteSdpInfo(std::shared_ptr<SdpInfo> sdp) { | |
|
||
std::shared_ptr<SdpInfo> WebRtcConnection::getLocalSdpInfo() { | ||
ELOG_DEBUG("%s message: getting local SDPInfo", toLog()); | ||
forEachMediaStream([this] (const std::shared_ptr<MediaStream> &media_stream) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't get why this is added here... Aren't we adding the SinkSSRCs to the local_sdp in both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree, I'll make sure we don't need this by running some test |
||
std::vector<uint32_t> video_ssrc_list = std::vector<uint32_t>(); | ||
video_ssrc_list.push_back(media_stream->getVideoSinkSSRC()); | ||
local_sdp_->video_ssrc_map[media_stream->getLabel()] = video_ssrc_list; | ||
local_sdp_->audio_ssrc_map[media_stream->getLabel()] = media_stream->getAudioSinkSSRC(); | ||
}); | ||
if (local_sdp_->audio_ssrc_map.size() + local_sdp_->video_ssrc_map.size() > 2) { | ||
if (local_sdp_->audioDirection == erizo::RECVONLY) { | ||
local_sdp_->audioDirection = erizo::SENDRECV; | ||
local_sdp_->videoDirection = erizo::SENDRECV; | ||
} | ||
} | ||
return local_sdp_; | ||
} | ||
|
||
|
@@ -203,6 +222,10 @@ bool WebRtcConnection::processRemoteSdp() { | |
forEachMediaStream([this] (const std::shared_ptr<MediaStream> &media_stream) { | ||
media_stream->setRemoteSdp(remote_sdp_); | ||
}); | ||
std::string object = this->getLocalSdp(); | ||
if (conn_event_listener_) { | ||
conn_event_listener_->notifyEvent(CONN_SDP, object); | ||
} | ||
return true; | ||
} | ||
|
||
|
@@ -212,8 +235,10 @@ bool WebRtcConnection::processRemoteSdp() { | |
local_sdp_->updateSupportedExtensionMap(extension_processor_.getSupportedExtensionMap()); | ||
|
||
forEachMediaStream([this] (const std::shared_ptr<MediaStream> &media_stream) { | ||
local_sdp_->video_ssrc_list.push_back(media_stream->getVideoSinkSSRC()); | ||
local_sdp_->audio_ssrc = media_stream->getAudioSinkSSRC(); | ||
std::vector<uint32_t> video_ssrc_list = std::vector<uint32_t>(); | ||
video_ssrc_list.push_back(media_stream->getVideoSinkSSRC()); | ||
local_sdp_->video_ssrc_map[media_stream->getLabel()] = video_ssrc_list; | ||
local_sdp_->audio_ssrc_map[media_stream->getLabel()] = media_stream->getAudioSinkSSRC(); | ||
}); | ||
|
||
if (remote_sdp_->dtlsRole == ACTPASS) { | ||
|
@@ -405,7 +430,12 @@ void WebRtcConnection::onTransportData(std::shared_ptr<DataPacket> packet, Trans | |
if (chead->isRtcp() && chead->packettype != RTCP_Sender_PT) { // Sender Report | ||
ssrc = chead->getSourceSSRC(); | ||
} | ||
forEachMediaStream([packet, transport, ssrc] (const std::shared_ptr<MediaStream> &media_stream) { | ||
int index = 0; | ||
forEachMediaStream([&index, packet, transport, ssrc] (const std::shared_ptr<MediaStream> &media_stream) { | ||
if (index == 1) { | ||
return; | ||
} | ||
index++; | ||
if (media_stream->isSourceSSRC(ssrc) || media_stream->isSinkSSRC(ssrc)) { | ||
media_stream->onTransportData(packet, transport); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I like the ssrc[label] map.