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

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

Issue 91343002: Added supported formats caching to VideoCaptureManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mad formatting corrected in certain files. Created 7 years 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 <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 base::ProcessHandle render_process, 170 base::ProcessHandle render_process,
171 media::VideoCaptureSessionId session_id, 171 media::VideoCaptureSessionId session_id,
172 const media::VideoCaptureParams& params) { 172 const media::VideoCaptureParams& params) {
173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
174 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id 174 DVLOG(1) << "VideoCaptureController::AddClient, id " << id.device_id
175 << ", " << params.requested_format.frame_size.ToString() 175 << ", " << params.requested_format.frame_size.ToString()
176 << ", " << params.requested_format.frame_rate 176 << ", " << params.requested_format.frame_rate
177 << ", " << session_id 177 << ", " << session_id
178 << ")"; 178 << ")";
179 179
180 // If this is the first client added to the controller, cache the parameters.
181 if (!controller_clients_.size())
182 video_capture_format_ = params.requested_format;
183
180 // Signal error in case device is already in error state. 184 // Signal error in case device is already in error state.
181 if (state_ == VIDEO_CAPTURE_STATE_ERROR) { 185 if (state_ == VIDEO_CAPTURE_STATE_ERROR) {
182 event_handler->OnError(id); 186 event_handler->OnError(id);
183 return; 187 return;
184 } 188 }
185 189
186 // Do nothing if this client has called AddClient before. 190 // Do nothing if this client has called AddClient before.
187 if (FindClient(id, event_handler, controller_clients_)) 191 if (FindClient(id, event_handler, controller_clients_))
188 return; 192 return;
189 193
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // If this buffer is not held by this client, or this client doesn't exist 250 // If this buffer is not held by this client, or this client doesn't exist
247 // in controller, do nothing. 251 // in controller, do nothing.
248 if (!client || !client->active_buffers.erase(buffer_id)) { 252 if (!client || !client->active_buffers.erase(buffer_id)) {
249 NOTREACHED(); 253 NOTREACHED();
250 return; 254 return;
251 } 255 }
252 256
253 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); 257 buffer_pool_->RelinquishConsumerHold(buffer_id, 1);
254 } 258 }
255 259
260 const media::VideoCaptureFormat&
261 VideoCaptureController::GetVideoCaptureFormat() const {
262 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
263 return video_capture_format_;
264 }
265
256 scoped_refptr<media::VideoCaptureDevice::Client::Buffer> 266 scoped_refptr<media::VideoCaptureDevice::Client::Buffer>
257 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer( 267 VideoCaptureController::VideoCaptureDeviceClient::ReserveOutputBuffer(
258 media::VideoFrame::Format format, 268 media::VideoFrame::Format format,
259 const gfx::Size& size) { 269 const gfx::Size& size) {
260 return DoReserveOutputBuffer(format, size, 0); 270 return DoReserveOutputBuffer(format, size, 0);
261 } 271 }
262 272
263 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame( 273 void VideoCaptureController::VideoCaptureDeviceClient::OnIncomingCapturedFrame(
264 const uint8* data, 274 const uint8* data,
265 int length, 275 int length,
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 633 }
624 return NULL; 634 return NULL;
625 } 635 }
626 636
627 int VideoCaptureController::GetClientCount() { 637 int VideoCaptureController::GetClientCount() {
628 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 638 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
629 return controller_clients_.size(); 639 return controller_clients_.size();
630 } 640 }
631 641
632 } // namespace content 642 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698