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