Add configuration for cpu overuse detection to video send stream.
BUG=2422 R=mflodman@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/7129004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5468 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -26,58 +26,8 @@
|
||||
namespace webrtc {
|
||||
namespace internal {
|
||||
|
||||
// Super simple and temporary overuse logic. This will move to the application
|
||||
// as soon as the new API allows changing send codec on the fly.
|
||||
class ResolutionAdaptor : public webrtc::CpuOveruseObserver {
|
||||
public:
|
||||
ResolutionAdaptor(ViECodec* codec, int channel, size_t width, size_t height)
|
||||
: codec_(codec),
|
||||
channel_(channel),
|
||||
max_width_(width),
|
||||
max_height_(height) {}
|
||||
|
||||
virtual ~ResolutionAdaptor() {}
|
||||
|
||||
virtual void OveruseDetected() OVERRIDE {
|
||||
VideoCodec codec;
|
||||
if (codec_->GetSendCodec(channel_, codec) != 0)
|
||||
return;
|
||||
|
||||
if (codec.width / 2 < min_width || codec.height / 2 < min_height)
|
||||
return;
|
||||
|
||||
codec.width /= 2;
|
||||
codec.height /= 2;
|
||||
codec_->SetSendCodec(channel_, codec);
|
||||
}
|
||||
|
||||
virtual void NormalUsage() OVERRIDE {
|
||||
VideoCodec codec;
|
||||
if (codec_->GetSendCodec(channel_, codec) != 0)
|
||||
return;
|
||||
|
||||
if (codec.width * 2u > max_width_ || codec.height * 2u > max_height_)
|
||||
return;
|
||||
|
||||
codec.width *= 2;
|
||||
codec.height *= 2;
|
||||
codec_->SetSendCodec(channel_, codec);
|
||||
}
|
||||
|
||||
private:
|
||||
// Temporary and arbitrary chosen minimum resolution.
|
||||
static const size_t min_width = 160;
|
||||
static const size_t min_height = 120;
|
||||
|
||||
ViECodec* codec_;
|
||||
const int channel_;
|
||||
|
||||
const size_t max_width_;
|
||||
const size_t max_height_;
|
||||
};
|
||||
|
||||
VideoSendStream::VideoSendStream(newapi::Transport* transport,
|
||||
bool overuse_detection,
|
||||
CpuOveruseObserver* overuse_observer,
|
||||
webrtc::VideoEngine* video_engine,
|
||||
const VideoSendStream::Config& config,
|
||||
int base_channel)
|
||||
@ -169,11 +119,8 @@ VideoSendStream::VideoSendStream(newapi::Transport* transport,
|
||||
if (!SetCodec(config_.codec))
|
||||
abort();
|
||||
|
||||
if (overuse_detection) {
|
||||
overuse_observer_.reset(new ResolutionAdaptor(
|
||||
codec_, channel_, config_.codec.width, config_.codec.height));
|
||||
video_engine_base_->RegisterCpuOveruseObserver(channel_,
|
||||
overuse_observer_.get());
|
||||
if (overuse_observer) {
|
||||
video_engine_base_->RegisterCpuOveruseObserver(channel_, overuse_observer);
|
||||
}
|
||||
|
||||
image_process_ = ViEImageProcess::GetInterface(video_engine);
|
||||
|
Reference in New Issue
Block a user