Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: webrtc/video_engine/vie_channel.cc

Issue 1226143013: Merge methods for configuring NACK/FEC/hybrid. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Remove distinction between send and receive NACK. Allow disabling receive-side. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/video_engine/vie_channel.cc
diff --git a/webrtc/video_engine/vie_channel.cc b/webrtc/video_engine/vie_channel.cc
index f4d28eb6458dab36070f03deec793e3f509e3580..442471a338dfc5e9045ab4035f2c17dd5ef3006b 100644
--- a/webrtc/video_engine/vie_channel.cc
+++ b/webrtc/video_engine/vie_channel.cc
@@ -647,27 +647,6 @@ int32_t ViEChannel::WaitForKeyFrame(bool wait) {
return 0;
}
-int32_t ViEChannel::SetSignalPacketLossStatus(bool enable,
- bool only_key_frames) {
- if (enable) {
- if (only_key_frames) {
- vcm_->SetVideoProtection(kProtectionKeyOnLoss, false);
- if (vcm_->SetVideoProtection(kProtectionKeyOnKeyLoss, true) != VCM_OK) {
- return -1;
- }
- } else {
- vcm_->SetVideoProtection(kProtectionKeyOnKeyLoss, false);
- if (vcm_->SetVideoProtection(kProtectionKeyOnLoss, true) != VCM_OK) {
- return -1;
- }
- }
- } else {
- vcm_->SetVideoProtection(kProtectionKeyOnLoss, false);
- vcm_->SetVideoProtection(kProtectionKeyOnKeyLoss, false);
- }
- return 0;
-}
-
void ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) {
CriticalSectionScoped cs(rtp_rtcp_cs_.get());
for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin();
@@ -679,28 +658,53 @@ void ViEChannel::SetRTCPMode(const RTCPMethod rtcp_mode) {
rtp_rtcp_->SetRTCPStatus(rtcp_mode);
}
-int32_t ViEChannel::SetNACKStatus(const bool enable) {
- // Update the decoding VCM.
- if (vcm_->SetVideoProtection(kProtectionNack, enable) != VCM_OK) {
- return -1;
+void ViEChannel::SetProtectionMode(bool enable_nack,
+ bool enable_fec,
+ int payload_type_red,
+ int payload_type_fec) {
+ // Validate payload types.
+ if (enable_fec) {
+ DCHECK_GE(payload_type_red, 0);
+ DCHECK_GE(payload_type_fec, 0);
+ DCHECK_LE(payload_type_red, 127);
+ DCHECK_LE(payload_type_fec, 127);
+ } else {
+ DCHECK_EQ(payload_type_red, -1);
+ DCHECK_EQ(payload_type_fec, -1);
+ // Set to valid uint8_ts to be castable later without signed overflows.
+ payload_type_red = 0;
+ payload_type_fec = 0;
}
- if (enable) {
- // Disable possible FEC.
- SetFECStatus(false, 0, 0);
+
+ VCMVideoProtection protection_method;
+ if (enable_nack) {
+ protection_method = enable_fec ? kProtectionNackFEC : kProtectionNack;
+ } else {
+ protection_method = kProtectionNone;
}
- // Update the decoding VCM.
- if (vcm_->SetVideoProtection(kProtectionNack, enable) != VCM_OK) {
- return -1;
+
+ vcm_->SetVideoProtection(protection_method, true);
+
+ // Set NACK.
+ ProcessNACKRequest(enable_nack);
+
+ // Set FEC.
+ rtp_rtcp_->SetGenericFECStatus(enable_fec,
+ static_cast<uint8_t>(payload_type_red),
+ static_cast<uint8_t>(payload_type_fec));
+ CriticalSectionScoped cs(rtp_rtcp_cs_.get());
+ for (RtpRtcp* rtp_rtcp : simulcast_rtp_rtcp_) {
+ rtp_rtcp->SetGenericFECStatus(enable_fec,
+ static_cast<uint8_t>(payload_type_red),
+ static_cast<uint8_t>(payload_type_fec));
}
- return ProcessNACKRequest(enable);
}
-int32_t ViEChannel::ProcessNACKRequest(const bool enable) {
+void ViEChannel::ProcessNACKRequest(const bool enable) {
if (enable) {
// Turn on NACK.
- if (rtp_rtcp_->RTCP() == kRtcpOff) {
- return -1;
- }
+ if (rtp_rtcp_->RTCP() == kRtcpOff)
+ return;
vie_receiver_.SetNackStatus(true, max_nack_reordering_threshold_);
rtp_rtcp_->SetStorePacketsStatus(true, nack_history_size_sender_);
vcm_->RegisterPacketRequestCallback(this);
@@ -734,18 +738,6 @@ int32_t ViEChannel::ProcessNACKRequest(const bool enable) {
// will freeze, and will only recover with a complete key frame.
vcm_->SetDecodeErrorMode(kWithErrors);
}
- return 0;
-}
-
-int32_t ViEChannel::SetFECStatus(const bool enable,
- const unsigned char payload_typeRED,
- const unsigned char payload_typeFEC) {
- // Disable possible NACK.
- if (enable) {
- SetNACKStatus(false);
- }
-
- return ProcessFECRequest(enable, payload_typeRED, payload_typeFEC);
}
bool ViEChannel::IsSendingFecEnabled() {
@@ -765,40 +757,6 @@ bool ViEChannel::IsSendingFecEnabled() {
return false;
}
-int32_t ViEChannel::ProcessFECRequest(
- const bool enable,
- const unsigned char payload_typeRED,
- const unsigned char payload_typeFEC) {
- if (rtp_rtcp_->SetGenericFECStatus(enable, payload_typeRED,
- payload_typeFEC) != 0) {
- return -1;
- }
- CriticalSectionScoped cs(rtp_rtcp_cs_.get());
- for (std::list<RtpRtcp*>::iterator it = simulcast_rtp_rtcp_.begin();
- it != simulcast_rtp_rtcp_.end();
- it++) {
- RtpRtcp* rtp_rtcp = *it;
- rtp_rtcp->SetGenericFECStatus(enable, payload_typeRED, payload_typeFEC);
- }
- return 0;
-}
-
-int32_t ViEChannel::SetHybridNACKFECStatus(
- const bool enable,
- const unsigned char payload_typeRED,
- const unsigned char payload_typeFEC) {
- if (vcm_->SetVideoProtection(kProtectionNackFEC, enable) != VCM_OK) {
- return -1;
- }
-
- int32_t ret_val = 0;
- ret_val = ProcessNACKRequest(enable);
- if (ret_val < 0) {
- return ret_val;
- }
- return ProcessFECRequest(enable, payload_typeRED, payload_typeFEC);
-}
-
int ViEChannel::SetSenderBufferingMode(int target_delay_ms) {
if ((target_delay_ms < 0) || (target_delay_ms > kMaxTargetDelayMs)) {
LOG(LS_ERROR) << "Invalid send buffer value.";

Powered by Google App Engine
This is Rietveld 408576698