Chromium Code Reviews| Index: media/cast/sender/video_sender.cc |
| diff --git a/media/cast/sender/video_sender.cc b/media/cast/sender/video_sender.cc |
| index 383d802360b7541f5cee61ce21328acd46a8a37f..814afdee5f2c9e2f9c56b5434417e5e0d71cf2fc 100644 |
| --- a/media/cast/sender/video_sender.cc |
| +++ b/media/cast/sender/video_sender.cc |
| @@ -208,6 +208,7 @@ void VideoSender::InsertRawVideoFrame( |
| reference_time, |
| base::Bind(&VideoSender::OnEncodedVideoFrame, |
| weak_factory_.GetWeakPtr(), |
| + video_frame, |
| bitrate))) { |
| frames_in_encoder_++; |
| duration_in_encoder_ += duration_added_by_next_frame; |
| @@ -241,6 +242,7 @@ void VideoSender::OnAck(uint32 frame_id) { |
| } |
| void VideoSender::OnEncodedVideoFrame( |
| + const scoped_refptr<media::VideoFrame>& video_frame, |
| int encoder_bitrate, |
| scoped_ptr<SenderEncodedFrame> encoded_frame) { |
| DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| @@ -253,8 +255,25 @@ void VideoSender::OnEncodedVideoFrame( |
| last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; |
| last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; |
| - // TODO(miu): Plumb-in a utilization feedback signal back to the producer of |
| - // the video frames. http://crbug.com/156767 |
| + |
| + // Report the resource utilization for processing this frame. Take the |
| + // greater of the two utilization values and attenuate them such that 75% |
| + // utilization is reported as the maximum sustainable amount. This provides |
| + // "wiggle room," ensuring there will be sufficient CPU and bandwidth |
| + // available to handle the occasional more-complex frames. |
| + static const double kAttenuationFactor = 0.75; |
|
hubbe
2015/06/04 22:08:53
Move to top of file?
miu
2015/06/06 00:29:22
Done.
|
| + const double attenuated_utilization = |
| + std::max(last_reported_deadline_utilization_, |
| + last_reported_lossy_utilization_) / kAttenuationFactor; |
| + if (attenuated_utilization >= 0.0) { |
| + // Key frames are artificially capped to 1.0 because their actual |
| + // utilization is atypical compared to the other frames in the stream, and |
| + // this can misguide the producer of the input video frames. |
| + video_frame->metadata()->SetDouble( |
| + media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| + encoded_frame->dependency == EncodedFrame::KEY ? |
| + std::min(1.0, attenuated_utilization) : attenuated_utilization); |
| + } |
| SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); |
| } |