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

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

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