niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
mflodman@webrtc.org | e06ca3c | 2012-06-29 13:20:14 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ |
| 12 | #define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
pbos@webrtc.org | 4ca7d3f | 2013-08-12 19:51:57 +0000 | [diff] [blame^] | 14 | #include <map> |
| 15 | |
andrew@webrtc.org | 94caca7 | 2012-10-30 21:58:00 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/video_capture/include/video_capture.h" |
pbos@webrtc.org | f5d4cb1 | 2013-05-17 13:44:48 +0000 | [diff] [blame] | 17 | #include "webrtc/system_wrappers/interface/scoped_ptr.h" |
| 18 | #include "webrtc/typedefs.h" |
| 19 | #include "webrtc/video_engine/include/vie_capture.h" |
| 20 | #include "webrtc/video_engine/vie_defines.h" |
| 21 | #include "webrtc/video_engine/vie_frame_provider_base.h" |
| 22 | #include "webrtc/video_engine/vie_manager_base.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 25 | |
andresp@webrtc.org | 7707d06 | 2013-05-13 10:50:50 +0000 | [diff] [blame] | 26 | class Config; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 27 | class CriticalSectionWrapper; |
| 28 | class ProcessThread; |
| 29 | class RWLockWrapper; |
| 30 | class ViECapturer; |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 31 | class ViEExternalCapture; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 32 | class VoiceEngine; |
| 33 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 34 | class ViEInputManager : private ViEManagerBase { |
| 35 | friend class ViEInputManagerScoped; |
| 36 | public: |
andresp@webrtc.org | 7707d06 | 2013-05-13 10:50:50 +0000 | [diff] [blame] | 37 | ViEInputManager(int engine_id, const Config& config); |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 38 | ~ViEInputManager(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 40 | void SetModuleProcessThread(ProcessThread* module_process_thread); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 42 | // Returns number of capture devices. |
| 43 | int NumberOfCaptureDevices(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 45 | // Gets name and id for a capture device. |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 46 | int GetDeviceName(uint32_t device_number, |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 47 | char* device_nameUTF8, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 48 | uint32_t device_name_length, |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 49 | char* device_unique_idUTF8, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 50 | uint32_t device_unique_idUTF8Length); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 51 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 52 | // Returns the number of capture capabilities for a specified device. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 53 | int NumberOfCaptureCapabilities(const char* device_unique_idUTF8); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 55 | // Gets a specific capability for a capture device. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 56 | int GetCaptureCapability(const char* device_unique_idUTF8, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 57 | const uint32_t device_capability_number, |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 58 | CaptureCapability& capability); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 59 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 60 | // Show OS specific Capture settings. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 61 | int DisplayCaptureSettingsDialogBox(const char* device_unique_idUTF8, |
| 62 | const char* dialog_titleUTF8, |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 63 | void* parent_window, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 64 | uint32_t positionX, |
| 65 | uint32_t positionY); |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 66 | int GetOrientation(const char* device_unique_idUTF8, |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 67 | RotateCapturedFrame& orientation); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 69 | // Creates a capture module for the specified capture device and assigns |
| 70 | // a capture device id for the device. |
| 71 | // Return zero on success, ViEError on failure. |
leozwang@webrtc.org | 1745e93 | 2012-03-01 16:30:40 +0000 | [diff] [blame] | 72 | int CreateCaptureDevice(const char* device_unique_idUTF8, |
pbos@webrtc.org | b238d12 | 2013-04-09 13:41:51 +0000 | [diff] [blame] | 73 | const uint32_t device_unique_idUTF8Length, |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 74 | int& capture_id); |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 75 | int CreateCaptureDevice(VideoCaptureModule* capture_module, |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 76 | int& capture_id); |
| 77 | int CreateExternalCaptureDevice(ViEExternalCapture*& external_capture, |
| 78 | int& capture_id); |
| 79 | int DestroyCaptureDevice(int capture_id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 80 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 81 | private: |
| 82 | // Gets and allocates a free capture device id. Assumed protected by caller. |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 83 | bool GetFreeCaptureId(int* freecapture_id); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 84 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 85 | // Frees a capture id assigned in GetFreeCaptureId. |
| 86 | void ReturnCaptureId(int capture_id); |
| 87 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 88 | // Gets the ViEFrameProvider for this capture observer. |
| 89 | ViEFrameProviderBase* ViEFrameProvider( |
| 90 | const ViEFrameCallback* capture_observer) const; |
| 91 | |
| 92 | // Gets the ViEFrameProvider for this capture observer. |
| 93 | ViEFrameProviderBase* ViEFrameProvider(int provider_id) const; |
| 94 | |
| 95 | // Gets the ViECapturer for the capture device id. |
| 96 | ViECapturer* ViECapturePtr(int capture_id) const; |
| 97 | |
andresp@webrtc.org | 7707d06 | 2013-05-13 10:50:50 +0000 | [diff] [blame] | 98 | const Config& config_; |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 99 | int engine_id_; |
mflodman@webrtc.org | d32c447 | 2011-12-22 14:17:53 +0000 | [diff] [blame] | 100 | scoped_ptr<CriticalSectionWrapper> map_cs_; |
pbos@webrtc.org | 927296f | 2013-03-08 13:12:29 +0000 | [diff] [blame] | 101 | scoped_ptr<CriticalSectionWrapper> device_info_cs_; |
pbos@webrtc.org | 4ca7d3f | 2013-08-12 19:51:57 +0000 | [diff] [blame^] | 102 | |
| 103 | typedef std::map<int, ViEFrameProviderBase*> FrameProviderMap; |
| 104 | FrameProviderMap vie_frame_provider_map_; |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 105 | |
| 106 | // Capture devices. |
| 107 | VideoCaptureModule::DeviceInfo* capture_device_info_; |
| 108 | int free_capture_device_id_[kViEMaxCaptureDevices]; |
| 109 | |
mflodman@webrtc.org | 8baed51 | 2012-06-21 12:11:50 +0000 | [diff] [blame] | 110 | ProcessThread* module_process_thread_; // Weak. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 113 | // Provides protected access to ViEInputManater. |
| 114 | class ViEInputManagerScoped: private ViEManagerScopedBase { |
| 115 | public: |
| 116 | explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 117 | |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 118 | ViECapturer* Capture(int capture_id) const; |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 119 | ViEFrameProviderBase* FrameProvider(int provider_id) const; |
| 120 | ViEFrameProviderBase* FrameProvider(const ViEFrameCallback* |
| 121 | capture_observer) const; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 122 | }; |
mflodman@webrtc.org | e8be22c | 2011-12-15 10:19:29 +0000 | [diff] [blame] | 123 | |
| 124 | } // namespace webrtc |
| 125 | |
mflodman@webrtc.org | e06ca3c | 2012-06-29 13:20:14 +0000 | [diff] [blame] | 126 | #endif // WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_ |