Line data Source code
1 : /*
2 : * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 : *
4 : * Use of this source code is governed by a BSD-style license
5 : * that can be found in the LICENSE file in the root of the source
6 : * tree. An additional intellectual property rights grant can be found
7 : * in the file PATENTS. All contributing project authors may
8 : * be found in the AUTHORS file in the root of the source tree.
9 : */
10 :
11 : #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_
12 : #define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_
13 :
14 : #include "webrtc/modules/video_capture/device_info_impl.h"
15 : #include "webrtc/modules/video_capture/video_capture_impl.h"
16 : #ifdef WEBRTC_LINUX
17 : #include <memory>
18 :
19 : #include "webrtc/base/platform_thread.h"
20 : #include "webrtc/system_wrappers/include/atomic32.h"
21 : #include <sys/inotify.h>
22 : #endif
23 :
24 : namespace webrtc
25 : {
26 : namespace videocapturemodule
27 : {
28 : class DeviceInfoLinux: public DeviceInfoImpl
29 : {
30 : public:
31 : DeviceInfoLinux();
32 : virtual ~DeviceInfoLinux();
33 : virtual uint32_t NumberOfDevices();
34 : virtual int32_t GetDeviceName(
35 : uint32_t deviceNumber,
36 : char* deviceNameUTF8,
37 : uint32_t deviceNameLength,
38 : char* deviceUniqueIdUTF8,
39 : uint32_t deviceUniqueIdUTF8Length,
40 : char* productUniqueIdUTF8=0,
41 : uint32_t productUniqueIdUTF8Length=0,
42 : pid_t* pid=0);
43 : /*
44 : * Fills the membervariable _captureCapabilities with capabilites for the given device name.
45 : */
46 : virtual int32_t CreateCapabilityMap (const char* deviceUniqueIdUTF8);
47 0 : virtual int32_t DisplayCaptureSettingsDialogBox(
48 : const char* /*deviceUniqueIdUTF8*/,
49 : const char* /*dialogTitleUTF8*/,
50 : void* /*parentWindow*/,
51 : uint32_t /*positionX*/,
52 0 : uint32_t /*positionY*/) { return -1;}
53 : int32_t FillCapabilities(int fd);
54 : int32_t Init();
55 : private:
56 :
57 : bool IsDeviceNameMatches(const char* name, const char* deviceUniqueIdUTF8);
58 :
59 : #ifdef WEBRTC_LINUX
60 : void HandleEvent(inotify_event* event, int fd);
61 : int EventCheck(int fd);
62 : int HandleEvents(int fd);
63 : int ProcessInotifyEvents();
64 : std::unique_ptr<rtc::PlatformThread> _inotifyEventThread;
65 : static bool InotifyEventThread(void*);
66 : bool InotifyProcess();
67 : int _fd_v4l, _fd_snd, _fd_dev, _wd_v4l, _wd_snd, _wd_dev; /* accessed on InotifyEventThread thread */
68 : Atomic32 _isShutdown;
69 : #endif
70 : };
71 : } // namespace videocapturemodule
72 : } // namespace webrtc
73 : #endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_LINUX_DEVICE_INFO_LINUX_H_
|