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

Side by Side Diff: content/renderer/media/gpu/rtc_video_encoder.cc

Issue 2933213003: Handle zero timestamp in RTCVideoEncoder timestamp matching & add UMA (Closed)
Patch Set: Created 3 years, 6 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 | « no previous file | tools/metrics/histograms/histograms.xml » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/media/gpu/rtc_video_encoder.h" 5 #include "content/renderer/media/gpu/rtc_video_encoder.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <deque> 9 #include <deque>
10 #include <memory> 10 #include <memory>
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 // requirements. 201 // requirements.
202 bool RequiresSizeChange(const scoped_refptr<media::VideoFrame>& frame) const; 202 bool RequiresSizeChange(const scoped_refptr<media::VideoFrame>& frame) const;
203 203
204 // Return an encoded output buffer to WebRTC. 204 // Return an encoded output buffer to WebRTC.
205 void ReturnEncodedImage(const webrtc::EncodedImage& image, 205 void ReturnEncodedImage(const webrtc::EncodedImage& image,
206 int32_t bitstream_buffer_id, 206 int32_t bitstream_buffer_id,
207 uint16_t picture_id); 207 uint16_t picture_id);
208 208
209 void SetStatus(int32_t status); 209 void SetStatus(int32_t status);
210 210
211 // Records |failed_timestamp_match_| value after a session.
212 void RecordTimestampMatchUMA() const;
213
211 // This is attached to |gpu_task_runner_|, not the thread class is constructed 214 // This is attached to |gpu_task_runner_|, not the thread class is constructed
212 // on. 215 // on.
213 base::ThreadChecker thread_checker_; 216 base::ThreadChecker thread_checker_;
214 217
215 // Factory for creating VEAs, shared memory buffers, etc. 218 // Factory for creating VEAs, shared memory buffers, etc.
216 media::GpuVideoAcceleratorFactories* gpu_factories_; 219 media::GpuVideoAcceleratorFactories* gpu_factories_;
217 220
218 // webrtc::VideoEncoder expects InitEncode() and Encode() to be synchronous. 221 // webrtc::VideoEncoder expects InitEncode() and Encode() to be synchronous.
219 // Do this by waiting on the |async_waiter_| and returning the return value in 222 // Do this by waiting on the |async_waiter_| and returning the return value in
220 // |async_retval_| when initialization completes, encoding completes, or 223 // |async_retval_| when initialization completes, encoding completes, or
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 if (IsBitrateTooHigh(bitrate)) 406 if (IsBitrateTooHigh(bitrate))
404 return; 407 return;
405 408
406 if (video_encoder_) 409 if (video_encoder_)
407 video_encoder_->RequestEncodingParametersChange(bitrate * 1000, framerate); 410 video_encoder_->RequestEncodingParametersChange(bitrate * 1000, framerate);
408 } 411 }
409 412
410 void RTCVideoEncoder::Impl::Destroy(base::WaitableEvent* async_waiter) { 413 void RTCVideoEncoder::Impl::Destroy(base::WaitableEvent* async_waiter) {
411 DVLOG(3) << "Impl::Destroy()"; 414 DVLOG(3) << "Impl::Destroy()";
412 DCHECK(thread_checker_.CalledOnValidThread()); 415 DCHECK(thread_checker_.CalledOnValidThread());
416 RecordTimestampMatchUMA();
413 if (video_encoder_) { 417 if (video_encoder_) {
414 video_encoder_.reset(); 418 video_encoder_.reset();
415 SetStatus(WEBRTC_VIDEO_CODEC_UNINITIALIZED); 419 SetStatus(WEBRTC_VIDEO_CODEC_UNINITIALIZED);
416 } 420 }
417 async_waiter->Signal(); 421 async_waiter->Signal();
418 } 422 }
419 423
420 int32_t RTCVideoEncoder::Impl::GetStatus() const { 424 int32_t RTCVideoEncoder::Impl::GetStatus() const {
421 base::AutoLock lock(status_lock_); 425 base::AutoLock lock(status_lock_);
422 return status_; 426 return status_;
423 } 427 }
424 428
425 void RTCVideoEncoder::Impl::SetStatus(int32_t status) { 429 void RTCVideoEncoder::Impl::SetStatus(int32_t status) {
426 base::AutoLock lock(status_lock_); 430 base::AutoLock lock(status_lock_);
427 status_ = status; 431 status_ = status;
428 } 432 }
429 433
434 void RTCVideoEncoder::Impl::RecordTimestampMatchUMA() const {
435 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderTimestampMatchSuccess",
436 failed_timestamp_match_ == false);
437 }
438
430 void RTCVideoEncoder::Impl::RequireBitstreamBuffers( 439 void RTCVideoEncoder::Impl::RequireBitstreamBuffers(
431 unsigned int input_count, 440 unsigned int input_count,
432 const gfx::Size& input_coded_size, 441 const gfx::Size& input_coded_size,
433 size_t output_buffer_size) { 442 size_t output_buffer_size) {
434 DVLOG(3) << "Impl::RequireBitstreamBuffers(): input_count=" << input_count 443 DVLOG(3) << "Impl::RequireBitstreamBuffers(): input_count=" << input_count
435 << ", input_coded_size=" << input_coded_size.ToString() 444 << ", input_coded_size=" << input_coded_size.ToString()
436 << ", output_buffer_size=" << output_buffer_size; 445 << ", output_buffer_size=" << output_buffer_size;
437 DCHECK(thread_checker_.CalledOnValidThread()); 446 DCHECK(thread_checker_.CalledOnValidThread());
438 447
439 if (!video_encoder_) 448 if (!video_encoder_)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 // greater than the last. 514 // greater than the last.
506 const int64_t capture_time_us = rtc::TimeMicros(); 515 const int64_t capture_time_us = rtc::TimeMicros();
507 int64_t capture_time_ms = 516 int64_t capture_time_ms =
508 capture_time_us / base::Time::kMicrosecondsPerMillisecond; 517 capture_time_us / base::Time::kMicrosecondsPerMillisecond;
509 capture_time_ms = std::max(capture_time_ms, last_capture_time_ms_ + 1); 518 capture_time_ms = std::max(capture_time_ms, last_capture_time_ms_ + 1);
510 last_capture_time_ms_ = capture_time_ms; 519 last_capture_time_ms_ = capture_time_ms;
511 520
512 // Find RTP timestamp by going through |pending_timestamps_|. Derive it from 521 // Find RTP timestamp by going through |pending_timestamps_|. Derive it from
513 // capture time otherwise. 522 // capture time otherwise.
514 base::Optional<uint32_t> rtp_timestamp; 523 base::Optional<uint32_t> rtp_timestamp;
515 if (!timestamp.is_zero() && !failed_timestamp_match_) { 524 if (!failed_timestamp_match_) {
516 // Pop timestamps until we have a match. 525 // Pop timestamps until we have a match.
517 while (!pending_timestamps_.empty()) { 526 while (!pending_timestamps_.empty()) {
518 const auto& front_timestamps = pending_timestamps_.front(); 527 const auto& front_timestamps = pending_timestamps_.front();
519 if (front_timestamps.media_timestamp_ == timestamp) { 528 if (front_timestamps.media_timestamp_ == timestamp) {
520 rtp_timestamp = front_timestamps.rtp_timestamp; 529 rtp_timestamp = front_timestamps.rtp_timestamp;
521 pending_timestamps_.pop_front(); 530 pending_timestamps_.pop_front();
522 break; 531 break;
523 } 532 }
524 pending_timestamps_.pop_front(); 533 pending_timestamps_.pop_front();
525 } 534 }
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", 954 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess",
946 init_retval == WEBRTC_VIDEO_CODEC_OK); 955 init_retval == WEBRTC_VIDEO_CODEC_OK);
947 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { 956 if (init_retval == WEBRTC_VIDEO_CODEC_OK) {
948 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", 957 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile",
949 profile, 958 profile,
950 media::VIDEO_CODEC_PROFILE_MAX + 1); 959 media::VIDEO_CODEC_PROFILE_MAX + 1);
951 } 960 }
952 } 961 }
953 962
954 } // namespace content 963 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698