diff --git a/src/modules/video_capture/main/interface/video_capture.h b/src/modules/video_capture/main/interface/video_capture.h index 6af3651964..e2f2f230ec 100644 --- a/src/modules/video_capture/main/interface/video_capture.h +++ b/src/modules/video_capture/main/interface/video_capture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -61,7 +61,7 @@ class VideoCaptureModule: public RefCountedModule { // Returns the deviceCapabilityNumber on success. virtual WebRtc_Word32 GetBestMatchedCapability( const WebRtc_UWord8*deviceUniqueIdUTF8, - const VideoCaptureCapability requested, + const VideoCaptureCapability& requested, VideoCaptureCapability& resulting) = 0; // Display OS /capture device specific settings dialog diff --git a/src/modules/video_capture/main/source/Linux/device_info_linux.cc b/src/modules/video_capture/main/source/Linux/device_info_linux.cc index 2d14c54a5d..842e51f103 100644 --- a/src/modules/video_capture/main/source/Linux/device_info_linux.cc +++ b/src/modules/video_capture/main/source/Linux/device_info_linux.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -10,7 +10,6 @@ #include "device_info_linux.h" -#include #include #include #include @@ -68,15 +67,11 @@ WebRtc_UWord32 DeviceInfoLinux::NumberOfDevices() /* detect /dev/video [0-63]VideoCaptureModule entries */ for (int n = 0; n < 64; n++) { - struct stat s; sprintf(device, "/dev/video%d", n); - if (stat(device, &s) == 0) //check validity of path + if ((fd = open(device, O_RDONLY)) != -1) { - if ((fd = open(device, O_RDONLY)) != -1) - { - close(fd); - count++; - } + close(fd); + count++; } } @@ -101,20 +96,16 @@ WebRtc_Word32 DeviceInfoLinux::GetDeviceName( bool found = false; for (int n = 0; n < 64; n++) { - struct stat s; sprintf(device, "/dev/video%d", n); - if (stat(device, &s) == 0) // Check validity of path + if ((fd = open(device, O_RDONLY)) != -1) { - if ((fd = open(device, O_RDONLY)) != -1) - { - if (count == deviceNumber) { - // Found the device - found = true; - break; - } else { - close(fd); - count++; - } + if (count == deviceNumber) { + // Found the device + found = true; + break; + } else { + close(fd); + count++; } } } @@ -187,41 +178,38 @@ WebRtc_Word32 DeviceInfoLinux::CreateCapabilityMap( "CreateCapabilityMap called for device %s", deviceUniqueIdUTF8); /* detect /dev/video [0-63] entries */ - for (int n = 0; n < 64; n++) + for (int n = 0; n < 64; ++n) { - struct stat s; sprintf(device, "/dev/video%d", n); - if (stat(device, &s) == 0) //check validity of path + fd = open(device, O_RDONLY); + if (fd == -1) + continue; + + // query device capabilities + struct v4l2_capability cap; + if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) { - if ((fd = open(device, O_RDONLY)) > 0) + if (cap.bus_info[0] != 0) { - // query device capabilities - struct v4l2_capability cap; - if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) + if (strncmp((const char*) cap.bus_info, + (const char*) deviceUniqueIdUTF8, + strlen((const char*) deviceUniqueIdUTF8)) == 0) //match with device id { - if (cap.bus_info[0] != 0) - { - if (strncmp((const char*) cap.bus_info, - (const char*) deviceUniqueIdUTF8, - strlen((const char*) deviceUniqueIdUTF8)) == 0) //match with device id - { - found = true; - break; // fd matches with device unique id supplied - } - } - else //match for device name - { - if (IsDeviceNameMatches((const char*) cap.card, - (const char*) deviceUniqueIdUTF8)) - { - found = true; - break; - } - } + found = true; + break; // fd matches with device unique id supplied + } + } + else //match for device name + { + if (IsDeviceNameMatches((const char*) cap.card, + (const char*) deviceUniqueIdUTF8)) + { + found = true; + break; } - close(fd); // close since this is not the matching device } } + close(fd); // close since this is not the matching device } if (!found) diff --git a/src/modules/video_capture/main/source/Linux/video_capture_linux.cc b/src/modules/video_capture/main/source/Linux/video_capture_linux.cc index 6f4ef98eae..da8fe3ea15 100644 --- a/src/modules/video_capture/main/source/Linux/video_capture_linux.cc +++ b/src/modules/video_capture/main/source/Linux/video_capture_linux.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -50,7 +50,8 @@ VideoCaptureModuleV4L2::VideoCaptureModuleV4L2(const WebRtc_Word32 id) : VideoCaptureImpl(id), _captureThread(NULL), _captureCritSect(CriticalSectionWrapper::CreateCriticalSection()), _deviceId(-1), _currentWidth(-1), _currentHeight(-1), - _currentFrameRate(-1), _captureStarted(false), _captureVideoType(kVideoI420) + _currentFrameRate(-1), _captureStarted(false), + _captureVideoType(kVideoI420), pool(NULL) { } @@ -71,30 +72,26 @@ WebRtc_Word32 VideoCaptureModuleV4L2::Init(const WebRtc_UWord8* deviceUniqueIdUT int n; for (n = 0; n < 64; n++) { - struct stat s; sprintf(device, "/dev/video%d", n); - if (stat(device, &s) == 0) //check validity of path + if ((fd = open(device, O_RDONLY)) != -1) { - if ((fd = open(device, O_RDONLY)) > 0) + // query device capabilities + struct v4l2_capability cap; + if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) { - // query device capabilities - struct v4l2_capability cap; - if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) + if (cap.bus_info[0] != 0) { - if (cap.bus_info[0] != 0) + if (strncmp((const char*) cap.bus_info, + (const char*) deviceUniqueIdUTF8, + strlen((const char*) deviceUniqueIdUTF8)) == 0) //match with device id { - if (strncmp((const char*) cap.bus_info, - (const char*) deviceUniqueIdUTF8, - strlen((const char*) deviceUniqueIdUTF8)) == 0) //match with device id - { - close(fd); - found = true; - break; // fd matches with device unique id supplied - } + close(fd); + found = true; + break; // fd matches with device unique id supplied } } - close(fd); // close since this is not the matching device } + close(fd); // close since this is not the matching device } } if (!found) diff --git a/src/modules/video_capture/main/source/device_info_impl.cc b/src/modules/video_capture/main/source/device_info_impl.cc index 16aba10aa3..10312e9620 100644 --- a/src/modules/video_capture/main/source/device_info_impl.cc +++ b/src/modules/video_capture/main/source/device_info_impl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -149,7 +149,7 @@ WebRtc_Word32 DeviceInfoImpl::GetCapability(const WebRtc_UWord8* deviceUniqueIdU WebRtc_Word32 DeviceInfoImpl::GetBestMatchedCapability( const WebRtc_UWord8*deviceUniqueIdUTF8, - const VideoCaptureCapability requested, + const VideoCaptureCapability& requested, VideoCaptureCapability& resulting) { diff --git a/src/modules/video_capture/main/source/device_info_impl.h b/src/modules/video_capture/main/source/device_info_impl.h index c682ee83db..34ef65d4c4 100644 --- a/src/modules/video_capture/main/source/device_info_impl.h +++ b/src/modules/video_capture/main/source/device_info_impl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -32,7 +32,7 @@ public: VideoCaptureCapability& capability); virtual WebRtc_Word32 GetBestMatchedCapability(const WebRtc_UWord8*deviceUniqueIdUTF8, - const VideoCaptureCapability requested, + const VideoCaptureCapability& requested, VideoCaptureCapability& resulting); virtual WebRtc_Word32 GetOrientation(const WebRtc_UWord8* deviceUniqueIdUTF8, VideoCaptureRotation& orientation); diff --git a/src/modules/video_capture/main/source/video_capture_impl.cc b/src/modules/video_capture/main/source/video_capture_impl.cc index 349153ddaf..1d19fc7fae 100644 --- a/src/modules/video_capture/main/source/video_capture_impl.cc +++ b/src/modules/video_capture/main/source/video_capture_impl.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. + * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source @@ -136,7 +136,9 @@ VideoCaptureImpl::VideoCaptureImpl(const WebRtc_Word32 id) _lastProcessTime(TickTime::Now()), _lastFrameRateCallbackTime(TickTime::Now()), _frameRateCallBack(false), _noPictureAlarmCallBack(false), _captureAlarm(Cleared), _setCaptureDelay(0), - _dataCallBack(NULL), _captureCallBack(NULL), _startImageFrameIntervall(0), + _dataCallBack(NULL), _captureCallBack(NULL), + _startImage(), _startImageFrameIntervall(0), + _lastSentStartImageTime(TickTime::Now()), _lastProcessFrameCount(TickTime::Now()), _rotateFrame(kRotateNone), last_capture_time_(TickTime::MillisecondTimestamp())