Remove MediaOptimization::Reset.
It is called right after construction, so move the needed implementation into the MediaOptimization constructor instead. Bug: webrtc:9711 Change-Id: Ibca35670bf45a85538c34c8ead58ba855acc6b96 Reviewed-on: https://webrtc-review.googlesource.com/97325 Commit-Queue: Rasmus Brandt <brandtr@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24540}
This commit is contained in:
parent
4e5af96606
commit
3613fef7a2
@ -25,22 +25,13 @@ MediaOptimization::MediaOptimization(Clock* clock)
|
||||
: clock_(clock),
|
||||
max_bit_rate_(0),
|
||||
max_frame_rate_(0),
|
||||
frame_dropper_(new FrameDropper),
|
||||
frame_dropper_(),
|
||||
incoming_frame_rate_(0) {
|
||||
memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
|
||||
frame_dropper_.SetRates(0, 0);
|
||||
}
|
||||
|
||||
MediaOptimization::~MediaOptimization(void) {}
|
||||
|
||||
void MediaOptimization::Reset() {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
memset(incoming_frame_times_, -1, sizeof(incoming_frame_times_));
|
||||
incoming_frame_rate_ = 0.0;
|
||||
frame_dropper_->Reset();
|
||||
frame_dropper_->SetRates(0, 0);
|
||||
max_bit_rate_ = 0;
|
||||
max_frame_rate_ = 0;
|
||||
}
|
||||
MediaOptimization::~MediaOptimization() = default;
|
||||
|
||||
void MediaOptimization::SetEncodingData(int32_t max_bit_rate,
|
||||
uint32_t target_bitrate,
|
||||
@ -50,8 +41,8 @@ void MediaOptimization::SetEncodingData(int32_t max_bit_rate,
|
||||
max_bit_rate_ = max_bit_rate;
|
||||
max_frame_rate_ = static_cast<float>(max_frame_rate);
|
||||
float target_bitrate_kbps = static_cast<float>(target_bitrate) / 1000.0f;
|
||||
frame_dropper_->Reset();
|
||||
frame_dropper_->SetRates(target_bitrate_kbps, max_frame_rate_);
|
||||
frame_dropper_.Reset();
|
||||
frame_dropper_.SetRates(target_bitrate_kbps, max_frame_rate_);
|
||||
}
|
||||
|
||||
uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) {
|
||||
@ -71,7 +62,7 @@ uint32_t MediaOptimization::SetTargetRates(uint32_t target_bitrate) {
|
||||
framerate = max_frame_rate_;
|
||||
}
|
||||
|
||||
frame_dropper_->SetRates(target_video_bitrate_kbps, framerate);
|
||||
frame_dropper_.SetRates(target_video_bitrate_kbps, framerate);
|
||||
|
||||
return video_target_bitrate;
|
||||
}
|
||||
@ -95,21 +86,21 @@ void MediaOptimization::UpdateWithEncodedData(
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (encoded_length > 0) {
|
||||
const bool delta_frame = encoded_image_frametype != kVideoFrameKey;
|
||||
frame_dropper_->Fill(encoded_length, delta_frame);
|
||||
frame_dropper_.Fill(encoded_length, delta_frame);
|
||||
}
|
||||
}
|
||||
|
||||
void MediaOptimization::EnableFrameDropper(bool enable) {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
frame_dropper_->Enable(enable);
|
||||
frame_dropper_.Enable(enable);
|
||||
}
|
||||
|
||||
bool MediaOptimization::DropFrame() {
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
UpdateIncomingFrameRate();
|
||||
// Leak appropriate number of bytes.
|
||||
frame_dropper_->Leak((uint32_t)(InputFrameRateInternal() + 0.5f));
|
||||
return frame_dropper_->DropFrame();
|
||||
frame_dropper_.Leak(static_cast<uint32_t>(InputFrameRateInternal() + 0.5f));
|
||||
return frame_dropper_.DropFrame();
|
||||
}
|
||||
|
||||
void MediaOptimization::UpdateIncomingFrameRate() {
|
||||
|
||||
@ -16,12 +16,12 @@
|
||||
#include "modules/include/module_common_types.h"
|
||||
#include "modules/video_coding/include/video_coding.h"
|
||||
#include "modules/video_coding/media_opt_util.h"
|
||||
#include "modules/video_coding/utility/frame_dropper.h"
|
||||
#include "rtc_base/criticalsection.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class Clock;
|
||||
class FrameDropper;
|
||||
|
||||
namespace media_optimization {
|
||||
|
||||
@ -30,10 +30,6 @@ class MediaOptimization {
|
||||
explicit MediaOptimization(Clock* clock);
|
||||
~MediaOptimization();
|
||||
|
||||
// TODO(andresp): Can Reset and SetEncodingData be done at construction time
|
||||
// only?
|
||||
void Reset();
|
||||
|
||||
// Informs media optimization of initial encoding state.
|
||||
// TODO(perkj): Deprecate SetEncodingData once its not used for stats in
|
||||
// VideoStreamEncoder.
|
||||
@ -71,7 +67,7 @@ class MediaOptimization {
|
||||
Clock* const clock_ RTC_GUARDED_BY(crit_sect_);
|
||||
int32_t max_bit_rate_ RTC_GUARDED_BY(crit_sect_);
|
||||
float max_frame_rate_ RTC_GUARDED_BY(crit_sect_);
|
||||
std::unique_ptr<FrameDropper> frame_dropper_ RTC_GUARDED_BY(crit_sect_);
|
||||
FrameDropper frame_dropper_ RTC_GUARDED_BY(crit_sect_);
|
||||
float incoming_frame_rate_ RTC_GUARDED_BY(crit_sect_);
|
||||
int64_t incoming_frame_times_[kFrameCountHistorySize] RTC_GUARDED_BY(
|
||||
crit_sect_);
|
||||
|
||||
@ -45,7 +45,6 @@ VideoSender::VideoSender(Clock* clock,
|
||||
encoder_params_({VideoBitrateAllocation(), 0, 0, 0}),
|
||||
encoder_has_internal_source_(false),
|
||||
next_frame_types_(1, kVideoFrameDelta) {
|
||||
_mediaOpt.Reset();
|
||||
// Allow VideoSender to be created on one thread but used on another, post
|
||||
// construction. This is currently how this class is being used by at least
|
||||
// one external project (diffractor).
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user