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

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

Issue 1064963002: VideoCapture: add support for GpuMemoryBuffer allocation and lifetime mgmt in VideoCaptureBufferPool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
13 #include "base/metrics/sparse_histogram.h" 13 #include "base/metrics/sparse_histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "content/browser/renderer_host/media/media_stream_manager.h" 15 #include "content/browser/renderer_host/media/media_stream_manager.h"
16 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h" 16 #include "content/browser/renderer_host/media/video_capture_buffer_pool.h"
17 #include "content/browser/renderer_host/media/video_capture_device_client.h" 17 #include "content/browser/renderer_host/media/video_capture_device_client.h"
18 #include "content/browser/renderer_host/media/video_capture_manager.h" 18 #include "content/browser/renderer_host/media/video_capture_manager.h"
19 #include "content/common/gpu/client/gl_helper.h" 19 #include "content/common/gpu/client/gl_helper.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "gpu/command_buffer/common/mailbox_holder.h" 22 #include "gpu/command_buffer/common/mailbox_holder.h"
23 #include "media/base/video_frame.h" 23 #include "media/base/video_frame.h"
24 24
25 #if !defined(OS_ANDROID) 25 #if !defined(OS_ANDROID)
26 #include "content/browser/compositor/image_transport_factory.h" 26 #include "content/browser/compositor/image_transport_factory.h"
27 #endif 27 #endif
28 28
29 #if defined(ENABLE_WEBRTC) && (defined(OS_LINUX) || defined(OS_MACOSX))
30 #include "content/browser/renderer_host/media/video_capture_texture_wrapper.h"
31 #endif
32
33 using media::VideoCaptureFormat; 29 using media::VideoCaptureFormat;
34 using media::VideoFrame; 30 using media::VideoFrame;
35 31
36 namespace content { 32 namespace content {
37 33
38 namespace { 34 namespace {
39 35
40 static const int kInfiniteRatio = 99999; 36 static const int kInfiniteRatio = 99999;
41 37
42 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ 38 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 base::WeakPtr<VideoCaptureController> 133 base::WeakPtr<VideoCaptureController>
138 VideoCaptureController::GetWeakPtrForIOThread() { 134 VideoCaptureController::GetWeakPtrForIOThread() {
139 return weak_ptr_factory_.GetWeakPtr(); 135 return weak_ptr_factory_.GetWeakPtr();
140 } 136 }
141 137
142 scoped_ptr<media::VideoCaptureDevice::Client> 138 scoped_ptr<media::VideoCaptureDevice::Client>
143 VideoCaptureController::NewDeviceClient( 139 VideoCaptureController::NewDeviceClient(
144 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner, 140 const scoped_refptr<base::SingleThreadTaskRunner>& capture_task_runner,
145 const media::VideoCaptureFormat& format) { 141 const media::VideoCaptureFormat& format) {
146 DCHECK_CURRENTLY_ON(BrowserThread::IO); 142 DCHECK_CURRENTLY_ON(BrowserThread::IO);
147 #if defined(ENABLE_WEBRTC) && (defined(OS_LINUX) || defined(OS_MACOSX))
148 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
149 switches::kEnableWebRtcCaptureToTexture)) {
150 return make_scoped_ptr(new VideoCaptureTextureWrapper(
151 this->GetWeakPtrForIOThread(), buffer_pool_, capture_task_runner,
152 format));
153 DVLOG(1) << "TextureWrapper, format " << format.ToString();
154 }
155 #endif
156 return make_scoped_ptr( 143 return make_scoped_ptr(
157 new VideoCaptureDeviceClient(this->GetWeakPtrForIOThread(), 144 new VideoCaptureDeviceClient(this->GetWeakPtrForIOThread(), buffer_pool_,
158 buffer_pool_)); 145 capture_task_runner, format));
159 } 146 }
160 147
161 void VideoCaptureController::AddClient( 148 void VideoCaptureController::AddClient(
162 VideoCaptureControllerID id, 149 VideoCaptureControllerID id,
163 VideoCaptureControllerEventHandler* event_handler, 150 VideoCaptureControllerEventHandler* event_handler,
164 base::ProcessHandle render_process, 151 base::ProcessHandle render_process,
165 media::VideoCaptureSessionId session_id, 152 media::VideoCaptureSessionId session_id,
166 const media::VideoCaptureParams& params) { 153 const media::VideoCaptureParams& params) {
167 DCHECK_CURRENTLY_ON(BrowserThread::IO); 154 DCHECK_CURRENTLY_ON(BrowserThread::IO);
168 DVLOG(1) << "VideoCaptureController::AddClient, id " << id 155 DVLOG(1) << "VideoCaptureController::AddClient, id " << id
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 DCHECK_CURRENTLY_ON(BrowserThread::IO); 416 DCHECK_CURRENTLY_ON(BrowserThread::IO);
430 int active_client_count = 0; 417 int active_client_count = 0;
431 for (ControllerClient* client : controller_clients_) { 418 for (ControllerClient* client : controller_clients_) {
432 if (!client->paused) 419 if (!client->paused)
433 ++active_client_count; 420 ++active_client_count;
434 } 421 }
435 return active_client_count; 422 return active_client_count;
436 } 423 }
437 424
438 } // namespace content 425 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698