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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller.cc

Issue 529733002: Move UMA Media.VideoTrackAdapter.FramesReceived to VideoCaptureController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Shermans comments. Created 6 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/renderer_host/media/video_capture_controller.h" 5 #include "content/browser/renderer_host/media/video_capture_controller.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 private: 172 private:
173 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format, 173 scoped_refptr<Buffer> DoReserveOutputBuffer(media::VideoFrame::Format format,
174 const gfx::Size& dimensions); 174 const gfx::Size& dimensions);
175 175
176 // The controller to which we post events. 176 // The controller to which we post events.
177 const base::WeakPtr<VideoCaptureController> controller_; 177 const base::WeakPtr<VideoCaptureController> controller_;
178 178
179 // The pool of shared-memory buffers used for capturing. 179 // The pool of shared-memory buffers used for capturing.
180 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_; 180 const scoped_refptr<VideoCaptureBufferPool> buffer_pool_;
181
182 bool first_frame_;
183 }; 181 };
184 182
185 VideoCaptureController::VideoCaptureController(int max_buffers) 183 VideoCaptureController::VideoCaptureController(int max_buffers)
186 : buffer_pool_(new VideoCaptureBufferPool(max_buffers)), 184 : buffer_pool_(new VideoCaptureBufferPool(max_buffers)),
187 state_(VIDEO_CAPTURE_STATE_STARTED), 185 state_(VIDEO_CAPTURE_STATE_STARTED),
186 frame_received_(false),
188 weak_ptr_factory_(this) { 187 weak_ptr_factory_(this) {
189 } 188 }
190 189
191 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient( 190 VideoCaptureController::VideoCaptureDeviceClient::VideoCaptureDeviceClient(
192 const base::WeakPtr<VideoCaptureController>& controller, 191 const base::WeakPtr<VideoCaptureController>& controller,
193 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool) 192 const scoped_refptr<VideoCaptureBufferPool>& buffer_pool)
194 : controller_(controller), buffer_pool_(buffer_pool), first_frame_(true) {} 193 : controller_(controller), buffer_pool_(buffer_pool) {}
195 194
196 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {} 195 VideoCaptureController::VideoCaptureDeviceClient::~VideoCaptureDeviceClient() {}
197 196
198 base::WeakPtr<VideoCaptureController> VideoCaptureController::GetWeakPtr() { 197 base::WeakPtr<VideoCaptureController> VideoCaptureController::GetWeakPtr() {
199 return weak_ptr_factory_.GetWeakPtr(); 198 return weak_ptr_factory_.GetWeakPtr();
200 } 199 }
201 200
202 scoped_ptr<media::VideoCaptureDevice::Client> 201 scoped_ptr<media::VideoCaptureDevice::Client>
203 VideoCaptureController::NewDeviceClient() { 202 VideoCaptureController::NewDeviceClient() {
204 scoped_ptr<media::VideoCaptureDevice::Client> result( 203 scoped_ptr<media::VideoCaptureDevice::Client> result(
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 BrowserThread::PostTask( 470 BrowserThread::PostTask(
472 BrowserThread::IO, 471 BrowserThread::IO,
473 FROM_HERE, 472 FROM_HERE,
474 base::Bind( 473 base::Bind(
475 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread, 474 &VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread,
476 controller_, 475 controller_,
477 buffer, 476 buffer,
478 format, 477 format,
479 frame, 478 frame,
480 timestamp)); 479 timestamp));
481
482 if (first_frame_) {
483 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width",
484 frame_format.frame_size.width());
485 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Height",
486 frame_format.frame_size.height());
487 UMA_HISTOGRAM_ASPECT_RATIO("Media.VideoCapture.AspectRatio",
488 frame_format.frame_size.width(),
489 frame_format.frame_size.height());
490 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate",
491 frame_format.frame_rate);
492 UMA_HISTOGRAM_ENUMERATION("Media.VideoCapture.PixelFormat",
493 frame_format.pixel_format,
494 media::PIXEL_FORMAT_MAX);
495 first_frame_ = false;
496 }
497 } 480 }
498 481
499 void 482 void
500 VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame( 483 VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedVideoFrame(
501 const scoped_refptr<Buffer>& buffer, 484 const scoped_refptr<Buffer>& buffer,
502 const VideoCaptureFormat& buffer_format, 485 const VideoCaptureFormat& buffer_format,
503 const scoped_refptr<media::VideoFrame>& frame, 486 const scoped_refptr<media::VideoFrame>& frame,
504 base::TimeTicks timestamp) { 487 base::TimeTicks timestamp) {
505 BrowserThread::PostTask( 488 BrowserThread::PostTask(
506 BrowserThread::IO, 489 BrowserThread::IO,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 base::Bind(&VideoCaptureController::DoBufferDestroyedOnIOThread, 544 base::Bind(&VideoCaptureController::DoBufferDestroyedOnIOThread,
562 controller_, buffer_id_to_drop)); 545 controller_, buffer_id_to_drop));
563 } 546 }
564 547
565 return output_buffer; 548 return output_buffer;
566 } 549 }
567 550
568 VideoCaptureController::~VideoCaptureController() { 551 VideoCaptureController::~VideoCaptureController() {
569 STLDeleteContainerPointers(controller_clients_.begin(), 552 STLDeleteContainerPointers(controller_clients_.begin(),
570 controller_clients_.end()); 553 controller_clients_.end());
554 UMA_HISTOGRAM_BOOLEAN("Media.VideoCapture.FramesReceived", frame_received_);
571 } 555 }
572 556
573 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( 557 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread(
574 const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer, 558 const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer,
575 const media::VideoCaptureFormat& buffer_format, 559 const media::VideoCaptureFormat& buffer_format,
576 const scoped_refptr<media::VideoFrame>& frame, 560 const scoped_refptr<media::VideoFrame>& frame,
577 base::TimeTicks timestamp) { 561 base::TimeTicks timestamp) {
578 DCHECK_CURRENTLY_ON(BrowserThread::IO); 562 DCHECK_CURRENTLY_ON(BrowserThread::IO);
579 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId); 563 DCHECK_NE(buffer->id(), VideoCaptureBufferPool::kInvalidId);
580 564
(...skipping 28 matching lines...) Expand all
609 } 593 }
610 594
611 bool inserted = 595 bool inserted =
612 client->active_buffers.insert(std::make_pair(buffer->id(), frame)) 596 client->active_buffers.insert(std::make_pair(buffer->id(), frame))
613 .second; 597 .second;
614 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer->id(); 598 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer->id();
615 count++; 599 count++;
616 } 600 }
617 } 601 }
618 602
603 if (!frame_received_) {
604 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width",
605 buffer_format.frame_size.width());
606 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Height",
607 buffer_format.frame_size.height());
608 UMA_HISTOGRAM_ASPECT_RATIO("Media.VideoCapture.AspectRatio",
609 buffer_format.frame_size.width(),
610 buffer_format.frame_size.height());
611 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.FrameRate",
612 buffer_format.frame_rate);
613 UMA_HISTOGRAM_ENUMERATION("Media.VideoCapture.PixelFormat",
614 buffer_format.pixel_format,
615 media::PIXEL_FORMAT_MAX);
616 frame_received_ = true;
617 }
618
619 buffer_pool_->HoldForConsumers(buffer->id(), count); 619 buffer_pool_->HoldForConsumers(buffer->id(), count);
620 } 620 }
621 621
622 void VideoCaptureController::DoErrorOnIOThread() { 622 void VideoCaptureController::DoErrorOnIOThread() {
623 DCHECK_CURRENTLY_ON(BrowserThread::IO); 623 DCHECK_CURRENTLY_ON(BrowserThread::IO);
624 state_ = VIDEO_CAPTURE_STATE_ERROR; 624 state_ = VIDEO_CAPTURE_STATE_ERROR;
625 625
626 for (ControllerClients::iterator client_it = controller_clients_.begin(); 626 for (ControllerClients::iterator client_it = controller_clients_.begin();
627 client_it != controller_clients_.end(); ++client_it) { 627 client_it != controller_clients_.end(); ++client_it) {
628 ControllerClient* client = *client_it; 628 ControllerClient* client = *client_it;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 } 677 }
678 return NULL; 678 return NULL;
679 } 679 }
680 680
681 int VideoCaptureController::GetClientCount() { 681 int VideoCaptureController::GetClientCount() {
682 DCHECK_CURRENTLY_ON(BrowserThread::IO); 682 DCHECK_CURRENTLY_ON(BrowserThread::IO);
683 return controller_clients_.size(); 683 return controller_clients_.size();
684 } 684 }
685 685
686 } // namespace content 686 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_controller.h ('k') | content/renderer/media/video_track_adapter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698