Revert "Reland "Reland "Distinguish between send and receive codecs"""
This reverts commit 9bac68c0cc4444b852416396f0e0f31ea66a9cfe. Reason for revert: Breaks perf test on iOS. Original change's description: > Reland "Reland "Distinguish between send and receive codecs"" > > This reverts commit 00a30873c415d717af8dcdf21c2df7fd4b6d1ed2. > > Reason for revert: Flaky test in Chromium fixed. > > Original change's description: > > Revert "Reland "Distinguish between send and receive codecs"" > > > > This reverts commit 133bf2bd28596aab5c7684e0ea3da99b1fece77f. > > > > Reason for revert: Breaks Chromium import due to flaky test in Chromium. > > > > Original change's description: > > > Reland "Distinguish between send and receive codecs" > > > > > > This reverts commit e57b266a20334e47f105a0bd777190ec8c6562e8. > > > > > > Reason for revert: Fixed negotiation of send-only clients. > > > > > > Original change's description: > > > > Revert "Distinguish between send and receive codecs" > > > > > > > > This reverts commit c0f25cf762a6946666c812f7a3df3f0a7f98b38d. > > > > > > > > Reason for revert: breaks negotiation with send-only clients > > > > > > > > (webrtc_video_engine.cc:985): SetRecvParameters called with unsupported video codec: VideoCodec[96:H264] > > > > (peer_connection.cc:6043): Failed to set local video description recv parameters. (INVALID_PARAMETER) > > > > (peer_connection.cc:2591): Failed to set local offer sdp: Failed to set local video description recv parameters. > > > > > > > > Original change's description: > > > > > Distinguish between send and receive codecs > > > > > > > > > > Even though send and receive codecs may be the same, they might have > > > > > different support in HW. Distinguish between send and receive codecs > > > > > to be able to keep track of which codecs have HW support. > > > > > > > > > > Bug: chromium:1029737 > > > > > Change-Id: Id119560becadfe0aaf861c892a6485f1c2eb378d > > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165763 > > > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > > > Cr-Commit-Position: refs/heads/master@{#30284} > > > > > > > > TBR=steveanton@webrtc.org,kron@webrtc.org > > > > > > > > Change-Id: Iacb7059436b2313b52577b65f164ee363c4816aa > > > > No-Presubmit: true > > > > No-Tree-Checks: true > > > > No-Try: true > > > > Bug: chromium:1029737 > > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166420 > > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > > > Cr-Commit-Position: refs/heads/master@{#30292} > > > > > > TBR=steveanton@webrtc.org,kron@webrtc.org > > > > > > > > > Bug: chromium:1029737 > > > Change-Id: I287efcfdcd1c9a3f2c410aeec8fe26a84204d1fd > > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/166604 > > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > > Cr-Commit-Position: refs/heads/master@{#30348} > > > > TBR=steveanton@webrtc.org,kron@webrtc.org > > > > Change-Id: I9f8731309749e07ce7e651e1550ecfabddb1735f > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:1029737 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167205 > > Reviewed-by: Johannes Kron <kron@webrtc.org> > > Commit-Queue: Johannes Kron <kron@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30360} > > TBR=steveanton@webrtc.org,kron@webrtc.org > > Change-Id: I1cc2d83bd884f10685503a9c31288f96c935d6a3 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:1029737 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167206 > Reviewed-by: Johannes Kron <kron@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Johannes Kron <kron@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30367} TBR=steveanton@webrtc.org,kron@webrtc.org Change-Id: I0a9b0b58922ce7c558b3d31b64cc12086b2a6a55 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: chromium:1029737 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/167364 Commit-Queue: Johannes Kron <kron@webrtc.org> Reviewed-by: Johannes Kron <kron@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30373}
This commit is contained in:
committed by
Commit Bot
parent
b039c30157
commit
a104ceb0ce
@ -20,83 +20,6 @@
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
template <class T>
|
||||
RTCError VerifyCodecPreferences(const std::vector<RtpCodecCapability>& codecs,
|
||||
const std::vector<T>& send_codecs,
|
||||
const std::vector<T>& recv_codecs) {
|
||||
// 6. If the intersection between codecs and
|
||||
// RTCRtpSender.getCapabilities(kind).codecs or the intersection between
|
||||
// codecs and RTCRtpReceiver.getCapabilities(kind).codecs only contains RTX,
|
||||
// RED or FEC codecs or is an empty set, throw InvalidModificationError.
|
||||
// This ensures that we always have something to offer, regardless of
|
||||
// transceiver.direction.
|
||||
|
||||
if (!absl::c_any_of(codecs, [&recv_codecs](const RtpCodecCapability& codec) {
|
||||
return codec.name != cricket::kRtxCodecName &&
|
||||
codec.name != cricket::kRedCodecName &&
|
||||
codec.name != cricket::kFlexfecCodecName &&
|
||||
absl::c_any_of(recv_codecs, [&codec](const T& recv_codec) {
|
||||
return recv_codec.MatchesCapability(codec);
|
||||
});
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: Missing codec from recv "
|
||||
"codec capabilities.");
|
||||
}
|
||||
|
||||
if (!absl::c_any_of(codecs, [&send_codecs](const RtpCodecCapability& codec) {
|
||||
return codec.name != cricket::kRtxCodecName &&
|
||||
codec.name != cricket::kRedCodecName &&
|
||||
codec.name != cricket::kFlexfecCodecName &&
|
||||
absl::c_any_of(send_codecs, [&codec](const T& send_codec) {
|
||||
return send_codec.MatchesCapability(codec);
|
||||
});
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: Missing codec from send "
|
||||
"codec capabilities.");
|
||||
}
|
||||
|
||||
// 7. Let codecCapabilities be the union of
|
||||
// RTCRtpSender.getCapabilities(kind).codecs and
|
||||
// RTCRtpReceiver.getCapabilities(kind).codecs. 8.1 For each codec in
|
||||
// codecs, If codec is not in codecCapabilities, throw
|
||||
// InvalidModificationError.
|
||||
for (const auto& codec_preference : codecs) {
|
||||
bool is_recv_codec =
|
||||
absl::c_any_of(recv_codecs, [&codec_preference](const T& codec) {
|
||||
return codec.MatchesCapability(codec_preference);
|
||||
});
|
||||
|
||||
bool is_send_codec =
|
||||
absl::c_any_of(send_codecs, [&codec_preference](const T& codec) {
|
||||
return codec.MatchesCapability(codec_preference);
|
||||
});
|
||||
|
||||
if (!is_recv_codec && !is_send_codec) {
|
||||
return RTCError(
|
||||
RTCErrorType::INVALID_MODIFICATION,
|
||||
std::string("Invalid codec preferences: invalid codec with name \"") +
|
||||
codec_preference.name + "\".");
|
||||
}
|
||||
}
|
||||
|
||||
// Check we have a real codec (not just rtx, red or fec)
|
||||
if (absl::c_all_of(codecs, [](const RtpCodecCapability& codec) {
|
||||
return codec.name == cricket::kRtxCodecName ||
|
||||
codec.name == cricket::kRedCodecName ||
|
||||
codec.name == cricket::kUlpfecCodecName;
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: codec list must have a non "
|
||||
"RTX, RED or FEC entry.");
|
||||
}
|
||||
|
||||
return RTCError::OK();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
RtpTransceiver::RtpTransceiver(cricket::MediaType media_type)
|
||||
: unified_plan_(false), media_type_(media_type) {
|
||||
@ -328,26 +251,111 @@ RTCError RtpTransceiver::SetCodecPreferences(
|
||||
return absl::c_linear_search(codecs, codec);
|
||||
});
|
||||
|
||||
RTCError result;
|
||||
if (media_type_ == cricket::MEDIA_TYPE_AUDIO) {
|
||||
std::vector<cricket::AudioCodec> audio_codecs;
|
||||
|
||||
std::vector<cricket::AudioCodec> recv_codecs, send_codecs;
|
||||
channel_manager_->GetSupportedAudioReceiveCodecs(&recv_codecs);
|
||||
channel_manager_->GetSupportedAudioSendCodecs(&send_codecs);
|
||||
|
||||
result = VerifyCodecPreferences(codecs, send_codecs, recv_codecs);
|
||||
// 6. If the intersection between codecs and
|
||||
// RTCRtpSender.getCapabilities(kind).codecs or the intersection between
|
||||
// codecs and RTCRtpReceiver.getCapabilities(kind).codecs only contains RTX,
|
||||
// RED or FEC codecs or is an empty set, throw InvalidModificationError.
|
||||
// This ensures that we always have something to offer, regardless of
|
||||
// transceiver.direction.
|
||||
|
||||
if (!absl::c_any_of(
|
||||
codecs, [&recv_codecs](const RtpCodecCapability& codec) {
|
||||
return codec.name != cricket::kRtxCodecName &&
|
||||
codec.name != cricket::kRedCodecName &&
|
||||
codec.name != cricket::kFlexfecCodecName &&
|
||||
absl::c_any_of(
|
||||
recv_codecs,
|
||||
[&codec](const cricket::AudioCodec& recv_codec) {
|
||||
return recv_codec.MatchesCapability(codec);
|
||||
});
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: Missing codec from recv "
|
||||
"codec capabilities.");
|
||||
}
|
||||
|
||||
if (!absl::c_any_of(
|
||||
codecs, [&send_codecs](const RtpCodecCapability& codec) {
|
||||
return codec.name != cricket::kRtxCodecName &&
|
||||
codec.name != cricket::kRedCodecName &&
|
||||
codec.name != cricket::kFlexfecCodecName &&
|
||||
absl::c_any_of(
|
||||
send_codecs,
|
||||
[&codec](const cricket::AudioCodec& send_codec) {
|
||||
return send_codec.MatchesCapability(codec);
|
||||
});
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: Missing codec from send "
|
||||
"codec capabilities.");
|
||||
}
|
||||
|
||||
// 7. Let codecCapabilities be the union of
|
||||
// RTCRtpSender.getCapabilities(kind).codecs and
|
||||
// RTCRtpReceiver.getCapabilities(kind).codecs. 8.1 For each codec in
|
||||
// codecs, If codec is not in codecCapabilities, throw
|
||||
// InvalidModificationError.
|
||||
for (const auto& codec_preference : codecs) {
|
||||
bool is_recv_codec = absl::c_any_of(
|
||||
recv_codecs, [&codec_preference](const cricket::AudioCodec& codec) {
|
||||
return codec.MatchesCapability(codec_preference);
|
||||
});
|
||||
|
||||
bool is_send_codec = absl::c_any_of(
|
||||
send_codecs, [&codec_preference](const cricket::AudioCodec& codec) {
|
||||
return codec.MatchesCapability(codec_preference);
|
||||
});
|
||||
|
||||
if (!is_recv_codec && !is_send_codec) {
|
||||
return RTCError(
|
||||
RTCErrorType::INVALID_MODIFICATION,
|
||||
std::string(
|
||||
"Invalid codec preferences: invalid codec with name \"") +
|
||||
codec_preference.name + "\".");
|
||||
}
|
||||
}
|
||||
} else if (media_type_ == cricket::MEDIA_TYPE_VIDEO) {
|
||||
std::vector<cricket::VideoCodec> recv_codecs, send_codecs;
|
||||
channel_manager_->GetSupportedVideoReceiveCodecs(&recv_codecs);
|
||||
channel_manager_->GetSupportedVideoSendCodecs(&send_codecs);
|
||||
std::vector<cricket::VideoCodec> video_codecs;
|
||||
// Video codecs are both for the receive and send side, so the checks are
|
||||
// simpler than the audio ones.
|
||||
channel_manager_->GetSupportedVideoCodecs(&video_codecs);
|
||||
|
||||
result = VerifyCodecPreferences(codecs, send_codecs, recv_codecs);
|
||||
// Validate codecs
|
||||
for (const auto& codec_preference : codecs) {
|
||||
if (!absl::c_any_of(video_codecs, [&codec_preference](
|
||||
const cricket::VideoCodec& codec) {
|
||||
return codec.MatchesCapability(codec_preference);
|
||||
})) {
|
||||
return RTCError(
|
||||
RTCErrorType::INVALID_MODIFICATION,
|
||||
std::string(
|
||||
"Invalid codec preferences: invalid codec with name \"") +
|
||||
codec_preference.name + "\".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result.ok()) {
|
||||
codec_preferences_ = codecs;
|
||||
// Check we have a real codec (not just rtx, red or fec)
|
||||
if (absl::c_all_of(codecs, [](const RtpCodecCapability& codec) {
|
||||
return codec.name == cricket::kRtxCodecName ||
|
||||
codec.name == cricket::kRedCodecName ||
|
||||
codec.name == cricket::kUlpfecCodecName;
|
||||
})) {
|
||||
return RTCError(RTCErrorType::INVALID_MODIFICATION,
|
||||
"Invalid codec preferences: codec list must have a non "
|
||||
"RTX, RED or FEC entry.");
|
||||
}
|
||||
|
||||
return result;
|
||||
codec_preferences_ = codecs;
|
||||
|
||||
return RTCError::OK();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user