blob: ed8a908b09708915f31f3592a2d9917c901271d3 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
leozwang@webrtc.org1745e932012-03-01 16:30:40 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.orge06ca3c2012-06-29 13:20:14 +000011#ifndef WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
12#define WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
andrew@webrtc.org94caca72012-10-30 21:58:00 +000014#include "webrtc/modules/video_capture/include/video_capture.h"
pbos@webrtc.orgf5d4cb12013-05-17 13:44:48 +000015#include "webrtc/system_wrappers/interface/map_wrapper.h"
16#include "webrtc/system_wrappers/interface/scoped_ptr.h"
17#include "webrtc/typedefs.h"
18#include "webrtc/video_engine/include/vie_capture.h"
19#include "webrtc/video_engine/vie_defines.h"
20#include "webrtc/video_engine/vie_frame_provider_base.h"
21#include "webrtc/video_engine/vie_manager_base.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000024
andresp@webrtc.org7707d062013-05-13 10:50:50 +000025class Config;
niklase@google.com470e71d2011-07-07 08:21:25 +000026class CriticalSectionWrapper;
27class ProcessThread;
28class RWLockWrapper;
29class ViECapturer;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000030class ViEExternalCapture;
niklase@google.com470e71d2011-07-07 08:21:25 +000031class VoiceEngine;
32
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000033class ViEInputManager : private ViEManagerBase {
34 friend class ViEInputManagerScoped;
35 public:
andresp@webrtc.org7707d062013-05-13 10:50:50 +000036 ViEInputManager(int engine_id, const Config& config);
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000037 ~ViEInputManager();
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000039 void SetModuleProcessThread(ProcessThread* module_process_thread);
niklase@google.com470e71d2011-07-07 08:21:25 +000040
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000041 // Returns number of capture devices.
42 int NumberOfCaptureDevices();
niklase@google.com470e71d2011-07-07 08:21:25 +000043
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000044 // Gets name and id for a capture device.
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000045 int GetDeviceName(uint32_t device_number,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000046 char* device_nameUTF8,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000047 uint32_t device_name_length,
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000048 char* device_unique_idUTF8,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000049 uint32_t device_unique_idUTF8Length);
niklase@google.com470e71d2011-07-07 08:21:25 +000050
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000051 // Returns the number of capture capabilities for a specified device.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000052 int NumberOfCaptureCapabilities(const char* device_unique_idUTF8);
niklase@google.com470e71d2011-07-07 08:21:25 +000053
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000054 // Gets a specific capability for a capture device.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000055 int GetCaptureCapability(const char* device_unique_idUTF8,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000056 const uint32_t device_capability_number,
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000057 CaptureCapability& capability);
niklase@google.com470e71d2011-07-07 08:21:25 +000058
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000059 // Show OS specific Capture settings.
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000060 int DisplayCaptureSettingsDialogBox(const char* device_unique_idUTF8,
61 const char* dialog_titleUTF8,
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000062 void* parent_window,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000063 uint32_t positionX,
64 uint32_t positionY);
leozwang@webrtc.org1745e932012-03-01 16:30:40 +000065 int GetOrientation(const char* device_unique_idUTF8,
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000066 RotateCapturedFrame& orientation);
niklase@google.com470e71d2011-07-07 08:21:25 +000067
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000068 // 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.org1745e932012-03-01 16:30:40 +000071 int CreateCaptureDevice(const char* device_unique_idUTF8,
pbos@webrtc.orgb238d122013-04-09 13:41:51 +000072 const uint32_t device_unique_idUTF8Length,
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000073 int& capture_id);
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000074 int CreateCaptureDevice(VideoCaptureModule* capture_module,
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000075 int& capture_id);
76 int CreateExternalCaptureDevice(ViEExternalCapture*& external_capture,
77 int& capture_id);
78 int DestroyCaptureDevice(int capture_id);
niklase@google.com470e71d2011-07-07 08:21:25 +000079
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000080 private:
81 // Gets and allocates a free capture device id. Assumed protected by caller.
mflodman@webrtc.org8baed512012-06-21 12:11:50 +000082 bool GetFreeCaptureId(int* freecapture_id);
niklase@google.com470e71d2011-07-07 08:21:25 +000083
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000084 // Frees a capture id assigned in GetFreeCaptureId.
85 void ReturnCaptureId(int capture_id);
86
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000087 // Gets the ViEFrameProvider for this capture observer.
88 ViEFrameProviderBase* ViEFrameProvider(
89 const ViEFrameCallback* capture_observer) const;
90
91 // Gets the ViEFrameProvider for this capture observer.
92 ViEFrameProviderBase* ViEFrameProvider(int provider_id) const;
93
94 // Gets the ViECapturer for the capture device id.
95 ViECapturer* ViECapturePtr(int capture_id) const;
96
andresp@webrtc.org7707d062013-05-13 10:50:50 +000097 const Config& config_;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000098 int engine_id_;
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000099 scoped_ptr<CriticalSectionWrapper> map_cs_;
pbos@webrtc.org927296f2013-03-08 13:12:29 +0000100 scoped_ptr<CriticalSectionWrapper> device_info_cs_;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000101 MapWrapper vie_frame_provider_map_;
102
103 // Capture devices.
104 VideoCaptureModule::DeviceInfo* capture_device_info_;
105 int free_capture_device_id_[kViEMaxCaptureDevices];
106
mflodman@webrtc.org8baed512012-06-21 12:11:50 +0000107 ProcessThread* module_process_thread_; // Weak.
niklase@google.com470e71d2011-07-07 08:21:25 +0000108};
109
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000110// Provides protected access to ViEInputManater.
111class ViEInputManagerScoped: private ViEManagerScopedBase {
112 public:
113 explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager);
niklase@google.com470e71d2011-07-07 08:21:25 +0000114
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000115 ViECapturer* Capture(int capture_id) const;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000116 ViEFrameProviderBase* FrameProvider(int provider_id) const;
117 ViEFrameProviderBase* FrameProvider(const ViEFrameCallback*
118 capture_observer) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000119};
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000120
121} // namespace webrtc
122
mflodman@webrtc.orge06ca3c2012-06-29 13:20:14 +0000123#endif // WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_