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

Side by Side Diff: media/video/capture/linux/video_capture_device_linux.cc

Issue 8304017: enable video capture to support sharing across multiple renderer processes (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "media/video/capture/linux/video_capture_device_linux.h" 5 #include "media/video/capture/linux/video_capture_device_linux.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <linux/videodev2.h> 9 #include <linux/videodev2.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 return device_name_; 185 return device_name_;
186 } 186 }
187 187
188 void VideoCaptureDeviceLinux::OnAllocate(int width, 188 void VideoCaptureDeviceLinux::OnAllocate(int width,
189 int height, 189 int height,
190 int frame_rate, 190 int frame_rate,
191 EventHandler* observer) { 191 EventHandler* observer) {
192 DCHECK_EQ(v4l2_thread_.message_loop(), MessageLoop::current()); 192 DCHECK_EQ(v4l2_thread_.message_loop(), MessageLoop::current());
193 193
194 observer_ = observer; 194 observer_ = observer;
195 observer_->OnDeviceState(true);
perkj_chrome 2011/10/21 14:54:00 Still think you should remove this.
wjia(left Chromium) 2011/10/21 23:54:16 We can discuss it after you confirm whether VideoC
195 196
196 if ((device_fd_ = open(device_name_.unique_id.c_str(), O_RDONLY)) < 0) { 197 if ((device_fd_ = open(device_name_.unique_id.c_str(), O_RDONLY)) < 0) {
197 SetErrorState("Failed to open V4L2 device driver."); 198 SetErrorState("Failed to open V4L2 device driver.");
198 return; 199 return;
199 } 200 }
200 201
201 // Test if this is a V4L2 device. 202 // Test if this is a V4L2 device.
202 v4l2_capability cap; 203 v4l2_capability cap;
203 if (!((ioctl(device_fd_, VIDIOC_QUERYCAP, &cap) == 0) && 204 if (!((ioctl(device_fd_, VIDIOC_QUERYCAP, &cap) == 0) &&
204 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))) { 205 (cap.capabilities & V4L2_CAP_VIDEO_CAPTURE))) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 r_buffer.memory = V4L2_MEMORY_MMAP; 436 r_buffer.memory = V4L2_MEMORY_MMAP;
436 r_buffer.count = 0; 437 r_buffer.count = 0;
437 438
438 if (ioctl(device_fd_, VIDIOC_REQBUFS, &r_buffer) < 0) { 439 if (ioctl(device_fd_, VIDIOC_REQBUFS, &r_buffer) < 0) {
439 SetErrorState("Failed to reset buf."); 440 SetErrorState("Failed to reset buf.");
440 } 441 }
441 442
442 delete [] buffer_pool_; 443 delete [] buffer_pool_;
443 buffer_pool_ = NULL; 444 buffer_pool_ = NULL;
444 buffer_pool_size_ = 0; 445 buffer_pool_size_ = 0;
446 observer_->OnDeviceState(false);
445 } 447 }
446 448
447 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) { 449 void VideoCaptureDeviceLinux::SetErrorState(const std::string& reason) {
448 DLOG(ERROR) << reason; 450 DLOG(ERROR) << reason;
449 state_ = kError; 451 state_ = kError;
450 observer_->OnError(); 452 observer_->OnError();
451 } 453 }
452 454
453 } // namespace media 455 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698