OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // ChannelManager also allows the application to discover what devices it has | 58 // ChannelManager also allows the application to discover what devices it has |
59 // using device manager. | 59 // using device manager. |
60 class ChannelManager : public rtc::MessageHandler, | 60 class ChannelManager : public rtc::MessageHandler, |
61 public sigslot::has_slots<> { | 61 public sigslot::has_slots<> { |
62 public: | 62 public: |
63 // For testing purposes. Allows the media engine and data media | 63 // For testing purposes. Allows the media engine and data media |
64 // engine and dev manager to be mocks. The ChannelManager takes | 64 // engine and dev manager to be mocks. The ChannelManager takes |
65 // ownership of these objects. | 65 // ownership of these objects. |
66 ChannelManager(MediaEngineInterface* me, | 66 ChannelManager(MediaEngineInterface* me, |
67 DataEngineInterface* dme, | 67 DataEngineInterface* dme, |
68 DeviceManagerInterface* dm, | |
69 CaptureManager* cm, | 68 CaptureManager* cm, |
70 rtc::Thread* worker); | 69 rtc::Thread* worker); |
71 // Same as above, but gives an easier default DataEngine. | 70 // Same as above, but gives an easier default DataEngine. |
72 ChannelManager(MediaEngineInterface* me, | 71 ChannelManager(MediaEngineInterface* me, |
73 DeviceManagerInterface* dm, | |
74 rtc::Thread* worker); | 72 rtc::Thread* worker); |
75 ~ChannelManager(); | 73 ~ChannelManager(); |
76 | 74 |
77 // Accessors for the worker thread, allowing it to be set after construction, | 75 // Accessors for the worker thread, allowing it to be set after construction, |
78 // but before Init. set_worker_thread will return false if called after Init. | 76 // but before Init. set_worker_thread will return false if called after Init. |
79 rtc::Thread* worker_thread() const { return worker_thread_; } | 77 rtc::Thread* worker_thread() const { return worker_thread_; } |
80 bool set_worker_thread(rtc::Thread* thread) { | 78 bool set_worker_thread(rtc::Thread* thread) { |
81 if (initialized_) return false; | 79 if (initialized_) return false; |
82 worker_thread_ = thread; | 80 worker_thread_ = thread; |
83 return true; | 81 return true; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 bool rtcp, | 126 bool rtcp, |
129 DataChannelType data_channel_type); | 127 DataChannelType data_channel_type); |
130 // Destroys a data channel created with the Create API. | 128 // Destroys a data channel created with the Create API. |
131 void DestroyDataChannel(DataChannel* data_channel); | 129 void DestroyDataChannel(DataChannel* data_channel); |
132 | 130 |
133 // Indicates whether any channels exist. | 131 // Indicates whether any channels exist. |
134 bool has_channels() const { | 132 bool has_channels() const { |
135 return (!voice_channels_.empty() || !video_channels_.empty()); | 133 return (!voice_channels_.empty() || !video_channels_.empty()); |
136 } | 134 } |
137 | 135 |
138 // Configures the audio and video devices. A null pointer can be passed to | |
139 // GetAudioOptions() for any parameter of no interest. | |
140 bool GetAudioOptions(std::string* wave_in_device, | |
141 std::string* wave_out_device, | |
142 AudioOptions* options); | |
143 bool SetAudioOptions(const std::string& wave_in_device, | |
144 const std::string& wave_out_device, | |
145 const AudioOptions& options); | |
146 bool GetOutputVolume(int* level); | 136 bool GetOutputVolume(int* level); |
147 bool SetOutputVolume(int level); | 137 bool SetOutputVolume(int level); |
148 bool IsSameCapturer(const std::string& capturer_name, | |
149 VideoCapturer* capturer); | |
150 // TODO(noahric): Nearly everything called "device" in this API is actually a | |
151 // device name, so this should really be GetCaptureDeviceName, and the | |
152 // next method should be GetCaptureDevice. | |
153 bool GetCaptureDevice(std::string* cam_device); | |
154 // Gets the current capture Device. | |
155 bool GetVideoCaptureDevice(Device* device); | |
156 // Create capturer based on what has been set in SetCaptureDevice(). | |
157 VideoCapturer* CreateVideoCapturer(); | |
158 // Create capturer from a screen. | |
159 VideoCapturer* CreateScreenCapturer(const ScreencastId& screenid); | |
160 bool SetCaptureDevice(const std::string& cam_device); | |
161 bool SetDefaultVideoEncoderConfig(const VideoEncoderConfig& config); | 138 bool SetDefaultVideoEncoderConfig(const VideoEncoderConfig& config); |
162 // RTX will be enabled/disabled in engines that support it. The supporting | 139 // RTX will be enabled/disabled in engines that support it. The supporting |
163 // engines will start offering an RTX codec. Must be called before Init(). | 140 // engines will start offering an RTX codec. Must be called before Init(). |
164 bool SetVideoRtxEnabled(bool enable); | 141 bool SetVideoRtxEnabled(bool enable); |
165 | 142 |
166 // Starts/stops the local microphone and enables polling of the input level. | 143 // Starts/stops the local microphone and enables polling of the input level. |
167 bool capturing() const { return capturing_; } | 144 bool capturing() const { return capturing_; } |
168 | 145 |
169 // Configures the logging output of the mediaengine(s). | 146 // Configures the logging output of the mediaengine(s). |
170 void SetVoiceLogging(int level, const char* filter); | 147 void SetVoiceLogging(int level, const char* filter); |
(...skipping 18 matching lines...) Expand all Loading... |
189 const VideoFormat& previous_format, | 166 const VideoFormat& previous_format, |
190 const VideoFormat& desired_format, | 167 const VideoFormat& desired_format, |
191 CaptureManager::RestartOptions options); | 168 CaptureManager::RestartOptions options); |
192 | 169 |
193 bool AddVideoRenderer(VideoCapturer* capturer, VideoRenderer* renderer); | 170 bool AddVideoRenderer(VideoCapturer* capturer, VideoRenderer* renderer); |
194 bool RemoveVideoRenderer(VideoCapturer* capturer, VideoRenderer* renderer); | 171 bool RemoveVideoRenderer(VideoCapturer* capturer, VideoRenderer* renderer); |
195 bool IsScreencastRunning() const; | 172 bool IsScreencastRunning() const; |
196 | 173 |
197 // The operations below occur on the main thread. | 174 // The operations below occur on the main thread. |
198 | 175 |
199 bool GetAudioInputDevices(std::vector<std::string>* names); | |
200 bool GetAudioOutputDevices(std::vector<std::string>* names); | |
201 bool GetVideoCaptureDevices(std::vector<std::string>* names); | |
202 void SetVideoCaptureDeviceMaxFormat(const std::string& usb_id, | |
203 const VideoFormat& max_format); | |
204 | |
205 // Starts AEC dump using existing file. | 176 // Starts AEC dump using existing file. |
206 bool StartAecDump(rtc::PlatformFile file); | 177 bool StartAecDump(rtc::PlatformFile file); |
207 | 178 |
208 sigslot::repeater0<> SignalDevicesChange; | |
209 sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange; | 179 sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange; |
210 | 180 |
211 // Returns the current selected device. Note: Subtly different from | |
212 // GetCaptureDevice(). See member video_device_ for more details. | |
213 // This API is mainly a hook used by unittests. | |
214 const std::string& video_device_name() const { return video_device_name_; } | |
215 | |
216 | |
217 protected: | 181 protected: |
218 // Adds non-transient parameters which can only be changed through the | 182 // Adds non-transient parameters which can only be changed through the |
219 // options store. | 183 // options store. |
220 bool SetAudioOptions(const std::string& wave_in_device, | 184 bool SetAudioOptions(const AudioOptions& options, int delay_offset); |
221 const std::string& wave_out_device, | |
222 const AudioOptions& options, | |
223 int delay_offset); | |
224 int audio_delay_offset() const { return audio_delay_offset_; } | 185 int audio_delay_offset() const { return audio_delay_offset_; } |
225 // This is here so that ChannelManager subclasses can set the video | |
226 // capturer factories to use. | |
227 DeviceManagerInterface* device_manager() { return device_manager_.get(); } | |
228 | 186 |
229 private: | 187 private: |
230 typedef std::vector<VoiceChannel*> VoiceChannels; | 188 typedef std::vector<VoiceChannel*> VoiceChannels; |
231 typedef std::vector<VideoChannel*> VideoChannels; | 189 typedef std::vector<VideoChannel*> VideoChannels; |
232 typedef std::vector<DataChannel*> DataChannels; | 190 typedef std::vector<DataChannel*> DataChannels; |
233 | 191 |
234 void Construct(MediaEngineInterface* me, | 192 void Construct(MediaEngineInterface* me, |
235 DataEngineInterface* dme, | 193 DataEngineInterface* dme, |
236 DeviceManagerInterface* dm, | |
237 CaptureManager* cm, | 194 CaptureManager* cm, |
238 rtc::Thread* worker_thread); | 195 rtc::Thread* worker_thread); |
239 bool InitMediaEngine_w(); | 196 bool InitMediaEngine_w(); |
240 void DestructorDeletes_w(); | 197 void DestructorDeletes_w(); |
241 void Terminate_w(); | 198 void Terminate_w(); |
242 VoiceChannel* CreateVoiceChannel_w( | 199 VoiceChannel* CreateVoiceChannel_w( |
243 webrtc::MediaControllerInterface* media_controller, | 200 webrtc::MediaControllerInterface* media_controller, |
244 TransportController* transport_controller, | 201 TransportController* transport_controller, |
245 const std::string& content_name, | 202 const std::string& content_name, |
246 bool rtcp, | 203 bool rtcp, |
247 const AudioOptions& options); | 204 const AudioOptions& options); |
248 void DestroyVoiceChannel_w(VoiceChannel* voice_channel); | 205 void DestroyVoiceChannel_w(VoiceChannel* voice_channel); |
249 VideoChannel* CreateVideoChannel_w( | 206 VideoChannel* CreateVideoChannel_w( |
250 webrtc::MediaControllerInterface* media_controller, | 207 webrtc::MediaControllerInterface* media_controller, |
251 TransportController* transport_controller, | 208 TransportController* transport_controller, |
252 const std::string& content_name, | 209 const std::string& content_name, |
253 bool rtcp, | 210 bool rtcp, |
254 const VideoOptions& options); | 211 const VideoOptions& options); |
255 void DestroyVideoChannel_w(VideoChannel* video_channel); | 212 void DestroyVideoChannel_w(VideoChannel* video_channel); |
256 DataChannel* CreateDataChannel_w(TransportController* transport_controller, | 213 DataChannel* CreateDataChannel_w(TransportController* transport_controller, |
257 const std::string& content_name, | 214 const std::string& content_name, |
258 bool rtcp, | 215 bool rtcp, |
259 DataChannelType data_channel_type); | 216 DataChannelType data_channel_type); |
260 void DestroyDataChannel_w(DataChannel* data_channel); | 217 void DestroyDataChannel_w(DataChannel* data_channel); |
261 bool SetAudioOptions_w(const AudioOptions& options, int delay_offset, | 218 bool SetAudioOptions_w(const AudioOptions& options, int delay_offset, |
262 const Device* in_dev, const Device* out_dev); | 219 const Device* in_dev, const Device* out_dev); |
263 bool SetCaptureDevice_w(const Device* cam_device); | |
264 void OnVideoCaptureStateChange(VideoCapturer* capturer, | 220 void OnVideoCaptureStateChange(VideoCapturer* capturer, |
265 CaptureState result); | 221 CaptureState result); |
266 void GetSupportedFormats_w( | 222 void GetSupportedFormats_w( |
267 VideoCapturer* capturer, | 223 VideoCapturer* capturer, |
268 std::vector<cricket::VideoFormat>* out_formats) const; | 224 std::vector<cricket::VideoFormat>* out_formats) const; |
269 bool IsScreencastRunning_w() const; | 225 bool IsScreencastRunning_w() const; |
270 virtual void OnMessage(rtc::Message *message); | 226 virtual void OnMessage(rtc::Message *message); |
271 | 227 |
272 rtc::scoped_ptr<MediaEngineInterface> media_engine_; | 228 rtc::scoped_ptr<MediaEngineInterface> media_engine_; |
273 rtc::scoped_ptr<DataEngineInterface> data_media_engine_; | 229 rtc::scoped_ptr<DataEngineInterface> data_media_engine_; |
274 rtc::scoped_ptr<DeviceManagerInterface> device_manager_; | |
275 rtc::scoped_ptr<CaptureManager> capture_manager_; | 230 rtc::scoped_ptr<CaptureManager> capture_manager_; |
276 bool initialized_; | 231 bool initialized_; |
277 rtc::Thread* main_thread_; | 232 rtc::Thread* main_thread_; |
278 rtc::Thread* worker_thread_; | 233 rtc::Thread* worker_thread_; |
279 | 234 |
280 VoiceChannels voice_channels_; | 235 VoiceChannels voice_channels_; |
281 VideoChannels video_channels_; | 236 VideoChannels video_channels_; |
282 DataChannels data_channels_; | 237 DataChannels data_channels_; |
283 | 238 |
284 std::string audio_in_device_; | |
285 std::string audio_out_device_; | |
286 AudioOptions audio_options_; | 239 AudioOptions audio_options_; |
287 int audio_delay_offset_; | 240 int audio_delay_offset_; |
288 int audio_output_volume_; | 241 int audio_output_volume_; |
289 std::string camera_device_; | |
290 VideoEncoderConfig default_video_encoder_config_; | 242 VideoEncoderConfig default_video_encoder_config_; |
291 VideoRenderer* local_renderer_; | 243 VideoRenderer* local_renderer_; |
292 bool enable_rtx_; | 244 bool enable_rtx_; |
293 | 245 |
294 bool capturing_; | 246 bool capturing_; |
295 | |
296 // String containing currently set device. Note that this string is subtly | |
297 // different from camera_device_. E.g. camera_device_ will list unplugged | |
298 // but selected devices while this sting will be empty or contain current | |
299 // selected device. | |
300 // TODO(hellner): refactor the code such that there is no need to keep two | |
301 // strings for video devices that have subtle differences in behavior. | |
302 std::string video_device_name_; | |
303 }; | 247 }; |
304 | 248 |
305 } // namespace cricket | 249 } // namespace cricket |
306 | 250 |
307 #endif // TALK_SESSION_MEDIA_CHANNELMANAGER_H_ | 251 #endif // TALK_SESSION_MEDIA_CHANNELMANAGER_H_ |
OLD | NEW |