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..1df31563063609da218aa94f4a36760dbc1b159c 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 stress level for non-key frames. Key frames are excepted |
| + // because their utilization measurements are atypical compared to the other |
| + // frames in the stream, and this can misguide the producer of the input video |
| + // frames. |
|
hubbe
2015/06/02 00:23:22
I really wish we could include key frames too.
Not
miu
2015/06/02 03:07:34
Done. I thought about this for awhile, and there
|
| + if (encoded_frame->dependency != EncodedFrame::KEY) { |
| + // Take the greater of the two utilization values and attenuate them such |
| + // that 75% utilization is reported as the maximum sustainable stress |
| + // level. 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; |
| + const double attenuated_stress_level = |
| + std::max(last_reported_deadline_utilization_, |
| + last_reported_lossy_utilization_) / kAttenuationFactor; |
| + if (attenuated_stress_level >= 0.0) { |
| + video_frame->metadata()->SetDouble( |
| + media::VideoFrameMetadata::STRESS_LEVEL, attenuated_stress_level); |
| + } |
| + } |
| SendEncodedFrame(encoder_bitrate, encoded_frame.Pass()); |
| } |