Merge methods for configuring NACK/FEC/hybrid.
BUG=webrtc:1695 R=stefan@webrtc.org Review URL: https://codereview.webrtc.org/1226143013 Cr-Commit-Position: refs/heads/master@{#9580}
This commit is contained in:
@ -41,8 +41,6 @@ enum { kDefaultStartBitrateKbps = 300 };
|
||||
enum VCMVideoProtection {
|
||||
kProtectionNone,
|
||||
kProtectionNack, // Both send-side and receive-side
|
||||
kProtectionNackSender, // Send-side only
|
||||
kProtectionNackReceiver, // Receive-side only
|
||||
kProtectionFEC,
|
||||
kProtectionNackFEC,
|
||||
kProtectionKeyOnLoss,
|
||||
|
||||
@ -519,7 +519,6 @@ VCMFecMethod::UpdateParameters(const VCMProtectionParameters* parameters)
|
||||
return true;
|
||||
}
|
||||
VCMLossProtectionLogic::VCMLossProtectionLogic(int64_t nowMs):
|
||||
_selectedMethod(NULL),
|
||||
_currentParameters(),
|
||||
_rtt(0),
|
||||
_lossPr(0.0f),
|
||||
@ -548,25 +547,21 @@ VCMLossProtectionLogic::~VCMLossProtectionLogic()
|
||||
|
||||
void VCMLossProtectionLogic::SetMethod(
|
||||
enum VCMProtectionMethodEnum newMethodType) {
|
||||
if (_selectedMethod != nullptr) {
|
||||
if (_selectedMethod->Type() == newMethodType)
|
||||
return;
|
||||
// Remove old method.
|
||||
delete _selectedMethod;
|
||||
}
|
||||
if (_selectedMethod && _selectedMethod->Type() == newMethodType)
|
||||
return;
|
||||
|
||||
switch(newMethodType) {
|
||||
case kNack:
|
||||
_selectedMethod = new VCMNackMethod();
|
||||
_selectedMethod.reset(new VCMNackMethod());
|
||||
break;
|
||||
case kFec:
|
||||
_selectedMethod = new VCMFecMethod();
|
||||
_selectedMethod.reset(new VCMFecMethod());
|
||||
break;
|
||||
case kNackFec:
|
||||
_selectedMethod = new VCMNackFecMethod(kLowRttNackMs, -1);
|
||||
_selectedMethod.reset(new VCMNackFecMethod(kLowRttNackMs, -1));
|
||||
break;
|
||||
case kNone:
|
||||
_selectedMethod = nullptr;
|
||||
_selectedMethod.reset();
|
||||
break;
|
||||
}
|
||||
UpdateMethod();
|
||||
@ -726,10 +721,8 @@ void VCMLossProtectionLogic::UpdateNumLayers(int numLayers) {
|
||||
bool
|
||||
VCMLossProtectionLogic::UpdateMethod()
|
||||
{
|
||||
if (_selectedMethod == NULL)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!_selectedMethod)
|
||||
return false;
|
||||
_currentParameters.rtt = _rtt;
|
||||
_currentParameters.lossPr = _lossPr;
|
||||
_currentParameters.bitRate = _bitRate;
|
||||
@ -748,11 +741,11 @@ VCMLossProtectionLogic::UpdateMethod()
|
||||
VCMProtectionMethod*
|
||||
VCMLossProtectionLogic::SelectedMethod() const
|
||||
{
|
||||
return _selectedMethod;
|
||||
return _selectedMethod.get();
|
||||
}
|
||||
|
||||
VCMProtectionMethodEnum VCMLossProtectionLogic::SelectedType() const {
|
||||
return _selectedMethod == nullptr ? kNone : _selectedMethod->Type();
|
||||
return _selectedMethod ? _selectedMethod->Type() : kNone;
|
||||
}
|
||||
|
||||
void
|
||||
@ -773,11 +766,8 @@ VCMLossProtectionLogic::Reset(int64_t nowMs)
|
||||
Release();
|
||||
}
|
||||
|
||||
void
|
||||
VCMLossProtectionLogic::Release()
|
||||
{
|
||||
delete _selectedMethod;
|
||||
_selectedMethod = NULL;
|
||||
void VCMLossProtectionLogic::Release() {
|
||||
_selectedMethod.reset();
|
||||
}
|
||||
|
||||
} // namespace media_optimization
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "webrtc/base/exp_filter.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/video_coding/main/source/internal_defines.h"
|
||||
#include "webrtc/modules/video_coding/main/source/qm_select.h"
|
||||
#include "webrtc/system_wrappers/interface/trace.h"
|
||||
@ -335,7 +336,7 @@ private:
|
||||
// Sets the available loss protection methods.
|
||||
void UpdateMaxLossHistory(uint8_t lossPr255, int64_t now);
|
||||
uint8_t MaxFilteredLossPr(int64_t nowMs) const;
|
||||
VCMProtectionMethod* _selectedMethod;
|
||||
rtc::scoped_ptr<VCMProtectionMethod> _selectedMethod;
|
||||
VCMProtectionParameters _currentParameters;
|
||||
int64_t _rtt;
|
||||
float _lossPr;
|
||||
|
||||
@ -317,13 +317,8 @@ uint32_t MediaOptimization::SetTargetRates(
|
||||
return target_bit_rate_;
|
||||
}
|
||||
|
||||
void MediaOptimization::EnableProtectionMethod(bool enable,
|
||||
VCMProtectionMethodEnum method) {
|
||||
void MediaOptimization::SetProtectionMethod(VCMProtectionMethodEnum method) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
if (!enable && loss_prot_logic_->SelectedType() != method)
|
||||
return;
|
||||
if (!enable)
|
||||
method = kNone;
|
||||
loss_prot_logic_->SetMethod(method);
|
||||
}
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ class MediaOptimization {
|
||||
VCMProtectionCallback* protection_callback,
|
||||
VCMQMSettingsCallback* qmsettings_callback);
|
||||
|
||||
void EnableProtectionMethod(bool enable, VCMProtectionMethodEnum method);
|
||||
void SetProtectionMethod(VCMProtectionMethodEnum method);
|
||||
void EnableQM(bool enable);
|
||||
void EnableFrameDropper(bool enable);
|
||||
|
||||
|
||||
@ -168,7 +168,9 @@ class VideoCodingModuleImpl : public VideoCodingModule {
|
||||
|
||||
int32_t SetVideoProtection(VCMVideoProtection videoProtection,
|
||||
bool enable) override {
|
||||
sender_->SetVideoProtection(enable, videoProtection);
|
||||
// TODO(pbos): Remove enable from receive-side protection modes as well.
|
||||
if (enable)
|
||||
sender_->SetVideoProtection(videoProtection);
|
||||
return receiver_->SetVideoProtection(videoProtection, enable);
|
||||
}
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ class VideoSender {
|
||||
int32_t RegisterTransportCallback(VCMPacketizationCallback* transport);
|
||||
int32_t RegisterSendStatisticsCallback(VCMSendStatisticsCallback* sendStats);
|
||||
int32_t RegisterProtectionCallback(VCMProtectionCallback* protection);
|
||||
void SetVideoProtection(bool enable, VCMVideoProtection videoProtection);
|
||||
void SetVideoProtection(VCMVideoProtection videoProtection);
|
||||
|
||||
int32_t AddVideoFrame(const VideoFrame& videoFrame,
|
||||
const VideoContentMetrics* _contentMetrics,
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/modules/video_coding/codecs/interface/video_codec_interface.h"
|
||||
@ -187,15 +188,9 @@ int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection,
|
||||
// By default, do not decode with errors.
|
||||
_receiver.SetDecodeErrorMode(kNoErrors);
|
||||
switch (videoProtection) {
|
||||
case kProtectionNack:
|
||||
case kProtectionNackReceiver: {
|
||||
CriticalSectionScoped cs(_receiveCritSect);
|
||||
if (enable) {
|
||||
// Enable NACK and always wait for retransmits.
|
||||
_receiver.SetNackMode(kNack, -1, -1);
|
||||
} else {
|
||||
_receiver.SetNackMode(kNoNack, -1, -1);
|
||||
}
|
||||
case kProtectionNack: {
|
||||
DCHECK(enable);
|
||||
_receiver.SetNackMode(kNack, -1, -1);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -226,25 +221,17 @@ int32_t VideoReceiver::SetVideoProtection(VCMVideoProtection videoProtection,
|
||||
|
||||
case kProtectionNackFEC: {
|
||||
CriticalSectionScoped cs(_receiveCritSect);
|
||||
if (enable) {
|
||||
// Enable hybrid NACK/FEC. Always wait for retransmissions
|
||||
// and don't add extra delay when RTT is above
|
||||
// kLowRttNackMs.
|
||||
_receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs, -1);
|
||||
_receiver.SetDecodeErrorMode(kNoErrors);
|
||||
_receiver.SetDecodeErrorMode(kNoErrors);
|
||||
} else {
|
||||
_receiver.SetNackMode(kNoNack, -1, -1);
|
||||
}
|
||||
DCHECK(enable);
|
||||
_receiver.SetNackMode(kNack, media_optimization::kLowRttNackMs, -1);
|
||||
_receiver.SetDecodeErrorMode(kNoErrors);
|
||||
break;
|
||||
}
|
||||
case kProtectionNackSender:
|
||||
case kProtectionFEC:
|
||||
// Ignore encoder modes.
|
||||
return VCM_OK;
|
||||
case kProtectionNone:
|
||||
// TODO(pbos): Implement like sender and remove enable parameter. Ignored
|
||||
// for now.
|
||||
// No receiver-side protection.
|
||||
DCHECK(enable);
|
||||
_receiver.SetNackMode(kNoNack, -1, -1);
|
||||
_receiver.SetDecodeErrorMode(kWithErrors);
|
||||
break;
|
||||
}
|
||||
return VCM_OK;
|
||||
|
||||
@ -296,24 +296,21 @@ int32_t VideoSender::RegisterProtectionCallback(
|
||||
}
|
||||
|
||||
// Enable or disable a video protection method.
|
||||
void VideoSender::SetVideoProtection(bool enable,
|
||||
VCMVideoProtection videoProtection) {
|
||||
void VideoSender::SetVideoProtection(VCMVideoProtection videoProtection) {
|
||||
CriticalSectionScoped cs(_sendCritSect);
|
||||
switch (videoProtection) {
|
||||
case kProtectionNone:
|
||||
_mediaOpt.EnableProtectionMethod(enable, media_optimization::kNone);
|
||||
_mediaOpt.SetProtectionMethod(media_optimization::kNone);
|
||||
break;
|
||||
case kProtectionNack:
|
||||
case kProtectionNackSender:
|
||||
_mediaOpt.EnableProtectionMethod(enable, media_optimization::kNack);
|
||||
_mediaOpt.SetProtectionMethod(media_optimization::kNack);
|
||||
break;
|
||||
case kProtectionNackFEC:
|
||||
_mediaOpt.EnableProtectionMethod(enable, media_optimization::kNackFec);
|
||||
_mediaOpt.SetProtectionMethod(media_optimization::kNackFec);
|
||||
break;
|
||||
case kProtectionFEC:
|
||||
_mediaOpt.EnableProtectionMethod(enable, media_optimization::kFec);
|
||||
_mediaOpt.SetProtectionMethod(media_optimization::kFec);
|
||||
break;
|
||||
case kProtectionNackReceiver:
|
||||
case kProtectionKeyOnLoss:
|
||||
case kProtectionKeyOnKeyLoss:
|
||||
// Ignore receiver modes.
|
||||
|
||||
Reference in New Issue
Block a user