Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: media/cast/sender/video_sender.cc

Issue 1709863002: Add Cast PLI support on sender side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d45fef18a23918f35bdfe5901380254c3397d7bc 100644
--- a/media/cast/sender/video_sender.cc
+++ b/media/cast/sender/video_sender.cc
@@ -41,6 +41,10 @@ const int kConstantTimeMs = 75;
// available to handle the occasional more-complex frames).
const int kTargetUtilizationPercentage = 75;
+// This is the minimum duration in milliseconds that the sender will respond to
miu 2016/02/29 23:00:45 Hmm...This comment and var name still aren't quite
xjz 2016/03/01 01:14:27 Renamed to |kMinKeyFrameRequestOnPliIntervalMs|.
+// multiple Pli messages.
+const int kMinPliResponseIntervalMs = 500;
+
// Extract capture begin/end timestamps from |video_frame|'s metadata and log
// it.
void LogVideoCaptureTimestamps(CastEnvironment* cast_environment,
@@ -134,11 +138,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() {
@@ -192,6 +196,18 @@ void VideoSender::InsertRawVideoFrame(
return;
}
+ // Request a key frame when received a Pli message, and it has been passed
+ // more than |kMinPliResponseIntervalMs| milliseconds from the last key frame
+ // request sent to encoder.
+ if (picture_lost_at_receiver_) {
+ if (last_time_attempted_to_resolve_pli_.is_null() ||
+ ((reference_time - last_time_attempted_to_resolve_pli_)
+ .InMilliseconds() > kMinPliResponseIntervalMs)) {
miu 2016/02/29 23:00:45 BTW--Thinking about this a bit more: Is 500 ms eno
xjz 2016/03/01 01:14:27 I agree. Frequent key frames also reduce the video
+ video_encoder_->GenerateKeyFrame();
+ last_time_attempted_to_resolve_pli_ = reference_time;
+ }
+ }
+
// Two video frames are needed to compute the exact media duration added by
// the next frame. If there are no frames in the encoder, compute a guess
// based on the configured |max_frame_rate_|. Any error introduced by this

Powered by Google App Engine
This is Rietveld 408576698