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 1c39ecbc786c8646b1d92a2262857839cf8348bf..fb753b8d8120b94b7736db7b6a91ec427f3ce88c 100644 |
| --- a/media/cast/sender/video_sender.cc |
| +++ b/media/cast/sender/video_sender.cc |
| @@ -41,6 +41,12 @@ const int kConstantTimeMs = 75; |
| // available to handle the occasional more-complex frames). |
| const int kTargetUtilizationPercentage = 75; |
| +// This is the minimum duration between two key frame requests. Too many Key |
| +// frames will reduce the dependency among frames, but reduce the picture |
| +// quality as well. |
| +const base::TimeDelta kMinKeyFrameRequestDuration = |
|
miu
2016/02/26 23:36:07
Static initializer foo: In Chromium code, we can o
xjz
2016/02/27 05:53:32
Done.
|
| + base::TimeDelta::FromMilliseconds(500); |
| + |
| // Extract capture begin/end timestamps from |video_frame|'s metadata and log |
| // it. |
| void LogVideoCaptureTimestamps(CastEnvironment* cast_environment, |
| @@ -134,11 +140,11 @@ VideoSender::VideoSender( |
| transport_config.aes_iv_mask = video_config.aes_iv_mask; |
| transport_sender->InitializeVideo( |
| - transport_config, |
| - base::Bind(&VideoSender::OnReceivedCastFeedback, |
| - weak_factory_.GetWeakPtr()), |
| + transport_config, base::Bind(&VideoSender::OnReceivedCastFeedback, |
| + weak_factory_.GetWeakPtr()), |
| base::Bind(&VideoSender::OnMeasuredRoundTripTime, |
| - weak_factory_.GetWeakPtr())); |
| + weak_factory_.GetWeakPtr()), |
| + base::Bind(&VideoSender::OnReceivedPli, weak_factory_.GetWeakPtr())); |
| } |
| VideoSender::~VideoSender() { |
| @@ -154,6 +160,16 @@ void VideoSender::InsertRawVideoFrame( |
| return; |
| } |
| + // Request a key frame when receive the PLI and it has been passed more than |
| + // |kMinKeyFrameRequestDuration| frome encoding last key frame. |
| + if (picture_lost_at_receiver_) { |
|
miu
2016/02/26 23:36:07
The client may call InsertRawVideoFrame() several
xjz
2016/02/27 05:53:32
Done.
|
| + base::TimeDelta duration; |
| + if (last_encoded_key_frame_ != base::TimeTicks()) |
| + duration = reference_time - last_encoded_key_frame_; |
| + if (duration > kMinKeyFrameRequestDuration) |
| + video_encoder_->GenerateKeyFrame(); |
| + } |
| + |
| const RtpTimeTicks rtp_timestamp = |
| RtpTimeTicks::FromTimeDelta(video_frame->timestamp(), kVideoFrequency); |
| LogVideoCaptureTimestamps(cast_environment_.get(), *video_frame, |
| @@ -306,6 +322,9 @@ void VideoSender::OnEncodedVideoFrame( |
| frames_in_encoder_--; |
| DCHECK_GE(frames_in_encoder_, 0); |
| + if (encoded_frame->dependency == EncodedFrame::KEY) |
| + last_encoded_key_frame_ = encoded_frame->reference_time; |
| + |
| duration_in_encoder_ = |
| last_enqueued_frame_reference_time_ - encoded_frame->reference_time; |