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

Side by Side Diff: media/cast/sender/video_sender.cc

Issue 2103043005: media/cast/sender: Rename deadline_utilization to encoder_utilization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
« no previous file with comments | « media/cast/sender/video_sender.h ('k') | media/cast/sender/vp8_encoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/cast/sender/video_sender.h" 5 #include "media/cast/sender/video_sender.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <cmath> 9 #include <cmath>
10 #include <cstring> 10 #include <cstring>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ? NewFixedCongestionControl( 109 ? NewFixedCongestionControl(
110 (video_config.min_bitrate + video_config.max_bitrate) / 2) 110 (video_config.min_bitrate + video_config.max_bitrate) / 2)
111 : NewAdaptiveCongestionControl(cast_environment->Clock(), 111 : NewAdaptiveCongestionControl(cast_environment->Clock(),
112 video_config.max_bitrate, 112 video_config.max_bitrate,
113 video_config.min_bitrate, 113 video_config.min_bitrate,
114 video_config.max_frame_rate)), 114 video_config.max_frame_rate)),
115 frames_in_encoder_(0), 115 frames_in_encoder_(0),
116 last_bitrate_(0), 116 last_bitrate_(0),
117 playout_delay_change_cb_(playout_delay_change_cb), 117 playout_delay_change_cb_(playout_delay_change_cb),
118 low_latency_mode_(false), 118 low_latency_mode_(false),
119 last_reported_deadline_utilization_(-1.0), 119 last_reported_encoder_utilization_(-1.0),
120 last_reported_lossy_utilization_(-1.0), 120 last_reported_lossy_utilization_(-1.0),
121 weak_factory_(this) { 121 weak_factory_(this) {
122 video_encoder_ = VideoEncoder::Create( 122 video_encoder_ = VideoEncoder::Create(
123 cast_environment_, 123 cast_environment_,
124 video_config, 124 video_config,
125 status_change_cb, 125 status_change_cb,
126 create_vea_cb, 126 create_vea_cb,
127 create_video_encode_mem_cb); 127 create_video_encode_mem_cb);
128 if (!video_encoder_) { 128 if (!video_encoder_) {
129 cast_environment_->PostTask( 129 cast_environment_->PostTask(
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 261
262 const int bitrate = congestion_control_->GetBitrate( 262 const int bitrate = congestion_control_->GetBitrate(
263 reference_time + target_playout_delay_, target_playout_delay_); 263 reference_time + target_playout_delay_, target_playout_delay_);
264 if (bitrate != last_bitrate_) { 264 if (bitrate != last_bitrate_) {
265 video_encoder_->SetBitRate(bitrate); 265 video_encoder_->SetBitRate(bitrate);
266 last_bitrate_ = bitrate; 266 last_bitrate_ = bitrate;
267 } 267 }
268 268
269 TRACE_COUNTER_ID1("cast.stream", "Video Target Bitrate", this, bitrate); 269 TRACE_COUNTER_ID1("cast.stream", "Video Target Bitrate", this, bitrate);
270 270
271 MaybeRenderPerformanceMetricsOverlay(GetTargetPlayoutDelay(), 271 MaybeRenderPerformanceMetricsOverlay(
272 low_latency_mode_, 272 GetTargetPlayoutDelay(), low_latency_mode_, bitrate,
273 bitrate, 273 frames_in_encoder_ + 1, last_reported_encoder_utilization_,
274 frames_in_encoder_ + 1, 274 last_reported_lossy_utilization_, video_frame.get());
275 last_reported_deadline_utilization_,
276 last_reported_lossy_utilization_,
277 video_frame.get());
278 275
279 if (video_encoder_->EncodeVideoFrame( 276 if (video_encoder_->EncodeVideoFrame(
280 video_frame, 277 video_frame,
281 reference_time, 278 reference_time,
282 base::Bind(&VideoSender::OnEncodedVideoFrame, 279 base::Bind(&VideoSender::OnEncodedVideoFrame,
283 weak_factory_.GetWeakPtr(), 280 weak_factory_.GetWeakPtr(),
284 video_frame, 281 video_frame,
285 bitrate))) { 282 bitrate))) {
286 TRACE_EVENT_ASYNC_BEGIN1("cast.stream", "Video Encode", video_frame.get(), 283 TRACE_EVENT_ASYNC_BEGIN1("cast.stream", "Video Encode", video_frame.get(),
287 "rtp_timestamp", rtp_timestamp.lower_32_bits()); 284 "rtp_timestamp", rtp_timestamp.lower_32_bits());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 frames_in_encoder_--; 321 frames_in_encoder_--;
325 DCHECK_GE(frames_in_encoder_, 0); 322 DCHECK_GE(frames_in_encoder_, 0);
326 323
327 // Encoding was exited with errors. 324 // Encoding was exited with errors.
328 if (!encoded_frame) 325 if (!encoded_frame)
329 return; 326 return;
330 327
331 duration_in_encoder_ = 328 duration_in_encoder_ =
332 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; 329 last_enqueued_frame_reference_time_ - encoded_frame->reference_time;
333 330
334 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; 331 last_reported_encoder_utilization_ = encoded_frame->encoder_utilization;
335 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; 332 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization;
336 333
337 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(), 334 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(),
338 "deadline_utilization", last_reported_deadline_utilization_, 335 "encoder_utilization",
339 "lossy_utilization", last_reported_lossy_utilization_); 336 last_reported_encoder_utilization_,
337 "lossy_utilization", last_reported_lossy_utilization_);
340 338
341 // Report the resource utilization for processing this frame. Take the 339 // Report the resource utilization for processing this frame. Take the
342 // greater of the two utilization values and attenuate them such that the 340 // greater of the two utilization values and attenuate them such that the
343 // target utilization is reported as the maximum sustainable amount. 341 // target utilization is reported as the maximum sustainable amount.
344 const double attenuated_utilization = 342 const double attenuated_utilization =
345 std::max(last_reported_deadline_utilization_, 343 std::max(last_reported_encoder_utilization_,
346 last_reported_lossy_utilization_) / 344 last_reported_lossy_utilization_) /
347 (kTargetUtilizationPercentage / 100.0); 345 (kTargetUtilizationPercentage / 100.0);
348 if (attenuated_utilization >= 0.0) { 346 if (attenuated_utilization >= 0.0) {
349 // Key frames are artificially capped to 1.0 because their actual 347 // Key frames are artificially capped to 1.0 because their actual
350 // utilization is atypical compared to the other frames in the stream, and 348 // utilization is atypical compared to the other frames in the stream, and
351 // this can misguide the producer of the input video frames. 349 // this can misguide the producer of the input video frames.
352 video_frame->metadata()->SetDouble( 350 video_frame->metadata()->SetDouble(
353 media::VideoFrameMetadata::RESOURCE_UTILIZATION, 351 media::VideoFrameMetadata::RESOURCE_UTILIZATION,
354 encoded_frame->dependency == EncodedFrame::KEY ? 352 encoded_frame->dependency == EncodedFrame::KEY ?
355 std::min(1.0, attenuated_utilization) : attenuated_utilization); 353 std::min(1.0, attenuated_utilization) : attenuated_utilization);
356 } 354 }
357 355
358 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); 356 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame));
359 } 357 }
360 358
361 } // namespace cast 359 } // namespace cast
362 } // namespace media 360 } // namespace media
OLDNEW
« no previous file with comments | « media/cast/sender/video_sender.h ('k') | media/cast/sender/vp8_encoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698