blob: c70a2ee01dea576cb87cbf9400995f8f33b5ea47 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 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
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +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
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000014#include "modules/video_capture/main/interface/video_capture.h"
15#include "system_wrappers/interface/map_wrapper.h"
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +000016#include "system_wrappers/interface/scoped_ptr.h"
niklase@google.com470e71d2011-07-07 08:21:25 +000017#include "typedefs.h"
mflodman@webrtc.orga4863db2011-12-22 08:51:52 +000018#include "video_engine/include/vie_capture.h"
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000019#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.com470e71d2011-07-07 08:21:25 +000022
23namespace webrtc {
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000024
niklase@google.com470e71d2011-07-07 08:21:25 +000025class CriticalSectionWrapper;
26class ProcessThread;
27class RWLockWrapper;
28class ViECapturer;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000029class ViEExternalCapture;
niklase@google.com470e71d2011-07-07 08:21:25 +000030class ViEFilePlayer;
31class VoiceEngine;
32
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000033class ViEInputManager : private ViEManagerBase {
34 friend class ViEInputManagerScoped;
35 public:
36 explicit ViEInputManager(int engine_id);
37 ~ViEInputManager();
niklase@google.com470e71d2011-07-07 08:21:25 +000038
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +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.
45 int GetDeviceName(WebRtc_UWord32 device_number,
46 WebRtc_UWord8* device_nameUTF8,
47 WebRtc_UWord32 device_name_length,
48 WebRtc_UWord8* device_unique_idUTF8,
49 WebRtc_UWord32 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.
52 int NumberOfCaptureCapabilities(const WebRtc_UWord8* 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.
55 int GetCaptureCapability(const WebRtc_UWord8* device_unique_idUTF8,
56 const WebRtc_UWord32 device_capability_number,
57 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.
60 int DisplayCaptureSettingsDialogBox(const WebRtc_UWord8* device_unique_idUTF8,
61 const WebRtc_UWord8* dialog_titleUTF8,
62 void* parent_window,
63 WebRtc_UWord32 positionX,
64 WebRtc_UWord32 positionY);
65 int GetOrientation(const WebRtc_UWord8* device_unique_idUTF8,
66 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.
71 int CreateCaptureDevice(const WebRtc_UWord8* device_unique_idUTF8,
72 const WebRtc_UWord32 device_unique_idUTF8Length,
73 int& capture_id);
74 int CreateCaptureDevice(VideoCaptureModule& capture_module,
75 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 int CreateFilePlayer(const WebRtc_Word8* file_nameUTF8, const bool loop,
81 const FileFormats file_format,
82 VoiceEngine* voe_ptr,
83 int& file_id);
84 int DestroyFilePlayer(int file_id);
niklase@google.com470e71d2011-07-07 08:21:25 +000085
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000086 private:
87 // Gets and allocates a free capture device id. Assumed protected by caller.
88 bool GetFreeCaptureId(int& freecapture_id);
niklase@google.com470e71d2011-07-07 08:21:25 +000089
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +000090 // 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.
94 bool GetFreeFileId(int& free_file_id);
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
109 // Gets the the entire map with GetViECaptures.
110 void GetViECaptures(MapWrapper& vie_capture_map);
111
112 // Gets the ViEFilePlayer for this file_id.
113 ViEFilePlayer* ViEFilePlayerPtr(int file_id) const;
114
115 int engine_id_;
mflodman@webrtc.orgd32c4472011-12-22 14:17:53 +0000116 scoped_ptr<CriticalSectionWrapper> map_cs_;
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000117 MapWrapper vie_frame_provider_map_;
118
119 // Capture devices.
120 VideoCaptureModule::DeviceInfo* capture_device_info_;
121 int free_capture_device_id_[kViEMaxCaptureDevices];
122
123 // File Players.
124 int free_file_id_[kViEMaxFilePlayers];
125
126 ProcessThread* module_process_thread_;
niklase@google.com470e71d2011-07-07 08:21:25 +0000127};
128
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000129// Provides protected access to ViEInputManater.
130class ViEInputManagerScoped: private ViEManagerScopedBase {
131 public:
132 explicit ViEInputManagerScoped(const ViEInputManager& vie_input_manager);
niklase@google.com470e71d2011-07-07 08:21:25 +0000133
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000134 ViECapturer* Capture(int capture_id) const;
135 ViEFilePlayer* FilePlayer(int file_id) const;
136 ViEFrameProviderBase* FrameProvider(int provider_id) const;
137 ViEFrameProviderBase* FrameProvider(const ViEFrameCallback*
138 capture_observer) const;
niklase@google.com470e71d2011-07-07 08:21:25 +0000139};
mflodman@webrtc.orge8be22c2011-12-15 10:19:29 +0000140
141} // namespace webrtc
142
143#endif // WEBRTC_VIDEO_ENGINE_VIE_INPUT_MANAGER_H_