Skip to content

Commit

Permalink
Fix audio/video only streams with Firefox (#1514)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcague authored Jan 3, 2020
1 parent 3eaa691 commit 08dde5d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
12 changes: 12 additions & 0 deletions erizo/src/erizo/SdpInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ namespace erizo {
case RECVONLY:
sdp << "a=recvonly" << endl;
break;
case INACTIVE:
sdp << "a=inactive" << endl;
break;
}

ELOG_DEBUG("Writing Extmap for AUDIO %lu", extMapVector.size());
Expand Down Expand Up @@ -368,6 +371,9 @@ namespace erizo {
case RECVONLY:
sdp << "a=recvonly" << endl;
break;
case INACTIVE:
sdp << "a=inactive" << endl;
break;
}
for (uint8_t i = 0; i < bundleTags.size(); i++) {
if (bundleTags[i].mediaType == VIDEO_TYPE) {
Expand Down Expand Up @@ -544,6 +550,9 @@ namespace erizo {
case SENDRECV:
this->videoDirection = SENDRECV;
break;
case INACTIVE:
this->videoDirection = INACTIVE;
break;
default:
this->videoDirection = SENDRECV;
break;
Expand All @@ -558,6 +567,9 @@ namespace erizo {
case SENDRECV:
this->audioDirection = SENDRECV;
break;
case INACTIVE:
this->audioDirection = INACTIVE;
break;
default:
this->audioDirection = SENDRECV;
break;
Expand Down
2 changes: 1 addition & 1 deletion erizo/src/erizo/SdpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ enum MediaType {
* Stream directions
*/
enum StreamDirection {
SENDRECV, SENDONLY, RECVONLY
SENDRECV, SENDONLY, RECVONLY, INACTIVE
};
/**
* Simulcast rid direction
Expand Down
23 changes: 19 additions & 4 deletions erizo/src/erizo/WebRtcConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,19 @@ std::shared_ptr<SdpInfo> WebRtcConnection::getLocalSdpInfoSync() {
bool sending_audio = local_sdp_->audio_ssrc_map.size() > 0;
bool sending_video = local_sdp_->video_ssrc_map.size() > 0;

bool receiving_audio = remote_sdp_->audio_ssrc_map.size() > 0;
bool receiving_video = remote_sdp_->video_ssrc_map.size() > 0;
int audio_sources = 0;
for (auto iterator = remote_sdp_->audio_ssrc_map.begin(), itr_end = remote_sdp_->audio_ssrc_map.end();
iterator != itr_end; ++iterator) {
audio_sources++;
}
int video_sources = 0;
for (auto iterator = remote_sdp_->video_ssrc_map.begin(), itr_end = remote_sdp_->video_ssrc_map.end();
iterator != itr_end; ++iterator) {
video_sources += iterator->second.size();
}

bool receiving_audio = audio_sources > 0;
bool receiving_video = video_sources > 0;

audio_enabled_ = sending_audio || receiving_audio;
video_enabled_ = sending_video || receiving_video;
Expand All @@ -364,16 +375,20 @@ std::shared_ptr<SdpInfo> WebRtcConnection::getLocalSdpInfoSync() {
local_sdp_->audioDirection = erizo::RECVONLY;
} else if (sending_audio && !receiving_audio) {
local_sdp_->audioDirection = erizo::SENDONLY;
} else {
} else if (sending_audio && receiving_audio) {
local_sdp_->audioDirection = erizo::SENDRECV;
} else {
local_sdp_->audioDirection = erizo::INACTIVE;
}

if (!sending_video && receiving_video) {
local_sdp_->videoDirection = erizo::RECVONLY;
} else if (sending_video && !receiving_video) {
local_sdp_->videoDirection = erizo::SENDONLY;
} else {
} else if (sending_video && receiving_video) {
local_sdp_->videoDirection = erizo::SENDRECV;
} else {
local_sdp_->videoDirection = erizo::INACTIVE;
}

auto local_sdp_copy = std::make_shared<SdpInfo>(*local_sdp_.get());
Expand Down
7 changes: 7 additions & 0 deletions erizoAPI/ConnectionDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ NAN_METHOD(ConnectionDescription::setVideoDirection) {
sdp->videoDirection = erizo::SENDRECV;
} else if (direction == "recvonly") {
sdp->videoDirection = erizo::RECVONLY;
} else if (direction == "inactive") {
sdp->videoDirection = erizo::INACTIVE;
}
}

Expand All @@ -350,6 +352,8 @@ NAN_METHOD(ConnectionDescription::setAudioDirection) {
sdp->audioDirection = erizo::SENDRECV;
} else if (direction == "recvonly") {
sdp->audioDirection = erizo::RECVONLY;
} else if (direction == "inactive") {
sdp->audioDirection = erizo::INACTIVE;
}
}

Expand All @@ -370,6 +374,9 @@ NAN_METHOD(ConnectionDescription::getDirection) {
case erizo::SENDRECV:
value = "sendrecv";
break;
case erizo::INACTIVE:
value = "inactive";
break;
case erizo::RECVONLY:
default:
value = "recvonly";
Expand Down

0 comments on commit 08dde5d

Please sign in to comment.