Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: talk/session/media/channelmanager.h

Issue 1346153002: Remove use of DeviceManager from ChannelManager. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
128 BaseSession* session, const std::string& content_name, 126 BaseSession* session, const std::string& content_name,
129 bool rtcp, DataChannelType data_channel_type); 127 bool rtcp, 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
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; 179 sigslot::repeater0<> SignalDevicesChange;
209 sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange; 180 sigslot::signal2<VideoCapturer*, CaptureState> SignalVideoCaptureStateChange;
210 181
211 // Returns the current selected device. Note: Subtly different from 182 // Returns the current selected device. Note: Subtly different from
212 // GetCaptureDevice(). See member video_device_ for more details. 183 // GetCaptureDevice(). See member video_device_ for more details.
213 // This API is mainly a hook used by unittests. 184 // This API is mainly a hook used by unittests.
214 const std::string& video_device_name() const { return video_device_name_; } 185 const std::string& video_device_name() const { return video_device_name_; }
215 186
216 187
217 protected: 188 protected:
218 // Adds non-transient parameters which can only be changed through the 189 // Adds non-transient parameters which can only be changed through the
219 // options store. 190 // options store.
220 bool SetAudioOptions(const std::string& wave_in_device, 191 bool SetAudioOptions(const std::string& wave_in_device,
221 const std::string& wave_out_device, 192 const std::string& wave_out_device,
222 const AudioOptions& options, 193 const AudioOptions& options,
223 int delay_offset); 194 int delay_offset);
224 int audio_delay_offset() const { return audio_delay_offset_; } 195 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 196
229 private: 197 private:
230 typedef std::vector<VoiceChannel*> VoiceChannels; 198 typedef std::vector<VoiceChannel*> VoiceChannels;
231 typedef std::vector<VideoChannel*> VideoChannels; 199 typedef std::vector<VideoChannel*> VideoChannels;
232 typedef std::vector<DataChannel*> DataChannels; 200 typedef std::vector<DataChannel*> DataChannels;
233 201
234 void Construct(MediaEngineInterface* me, 202 void Construct(MediaEngineInterface* me,
235 DataEngineInterface* dme, 203 DataEngineInterface* dme,
236 DeviceManagerInterface* dm,
237 CaptureManager* cm, 204 CaptureManager* cm,
238 rtc::Thread* worker_thread); 205 rtc::Thread* worker_thread);
239 bool InitMediaEngine_w(); 206 bool InitMediaEngine_w();
240 void DestructorDeletes_w(); 207 void DestructorDeletes_w();
241 void Terminate_w(); 208 void Terminate_w();
242 VoiceChannel* CreateVoiceChannel_w( 209 VoiceChannel* CreateVoiceChannel_w(
243 webrtc::MediaControllerInterface* media_controller, 210 webrtc::MediaControllerInterface* media_controller,
244 BaseSession* session, 211 BaseSession* session,
245 const std::string& content_name, 212 const std::string& content_name,
246 bool rtcp, 213 bool rtcp,
247 const AudioOptions& options); 214 const AudioOptions& options);
248 void DestroyVoiceChannel_w(VoiceChannel* voice_channel); 215 void DestroyVoiceChannel_w(VoiceChannel* voice_channel);
249 VideoChannel* CreateVideoChannel_w( 216 VideoChannel* CreateVideoChannel_w(
250 webrtc::MediaControllerInterface* media_controller, 217 webrtc::MediaControllerInterface* media_controller,
251 BaseSession* session, 218 BaseSession* session,
252 const std::string& content_name, 219 const std::string& content_name,
253 bool rtcp, 220 bool rtcp,
254 const VideoOptions& options); 221 const VideoOptions& options);
255 void DestroyVideoChannel_w(VideoChannel* video_channel); 222 void DestroyVideoChannel_w(VideoChannel* video_channel);
256 DataChannel* CreateDataChannel_w( 223 DataChannel* CreateDataChannel_w(
257 BaseSession* session, const std::string& content_name, 224 BaseSession* session, const std::string& content_name,
258 bool rtcp, DataChannelType data_channel_type); 225 bool rtcp, DataChannelType data_channel_type);
259 void DestroyDataChannel_w(DataChannel* data_channel); 226 void DestroyDataChannel_w(DataChannel* data_channel);
260 bool SetAudioOptions_w(const AudioOptions& options, int delay_offset, 227 bool SetAudioOptions_w(const AudioOptions& options, int delay_offset,
261 const Device* in_dev, const Device* out_dev); 228 const Device* in_dev, const Device* out_dev);
262 bool SetCaptureDevice_w(const Device* cam_device);
263 void OnVideoCaptureStateChange(VideoCapturer* capturer, 229 void OnVideoCaptureStateChange(VideoCapturer* capturer,
264 CaptureState result); 230 CaptureState result);
265 void GetSupportedFormats_w( 231 void GetSupportedFormats_w(
266 VideoCapturer* capturer, 232 VideoCapturer* capturer,
267 std::vector<cricket::VideoFormat>* out_formats) const; 233 std::vector<cricket::VideoFormat>* out_formats) const;
268 bool IsScreencastRunning_w() const; 234 bool IsScreencastRunning_w() const;
269 virtual void OnMessage(rtc::Message *message); 235 virtual void OnMessage(rtc::Message *message);
270 236
271 rtc::scoped_ptr<MediaEngineInterface> media_engine_; 237 rtc::scoped_ptr<MediaEngineInterface> media_engine_;
272 rtc::scoped_ptr<DataEngineInterface> data_media_engine_; 238 rtc::scoped_ptr<DataEngineInterface> data_media_engine_;
273 rtc::scoped_ptr<DeviceManagerInterface> device_manager_;
274 rtc::scoped_ptr<CaptureManager> capture_manager_; 239 rtc::scoped_ptr<CaptureManager> capture_manager_;
275 bool initialized_; 240 bool initialized_;
276 rtc::Thread* main_thread_; 241 rtc::Thread* main_thread_;
277 rtc::Thread* worker_thread_; 242 rtc::Thread* worker_thread_;
278 243
279 VoiceChannels voice_channels_; 244 VoiceChannels voice_channels_;
280 VideoChannels video_channels_; 245 VideoChannels video_channels_;
281 DataChannels data_channels_; 246 DataChannels data_channels_;
282 247
283 std::string audio_in_device_; 248 std::string audio_in_device_;
284 std::string audio_out_device_; 249 std::string audio_out_device_;
285 AudioOptions audio_options_; 250 AudioOptions audio_options_;
286 int audio_delay_offset_; 251 int audio_delay_offset_;
287 int audio_output_volume_; 252 int audio_output_volume_;
288 std::string camera_device_;
289 VideoEncoderConfig default_video_encoder_config_; 253 VideoEncoderConfig default_video_encoder_config_;
290 VideoRenderer* local_renderer_; 254 VideoRenderer* local_renderer_;
291 bool enable_rtx_; 255 bool enable_rtx_;
292 256
293 bool capturing_; 257 bool capturing_;
294 258
295 // String containing currently set device. Note that this string is subtly 259 // String containing currently set device. Note that this string is subtly
296 // different from camera_device_. E.g. camera_device_ will list unplugged 260 // different from camera_device_. E.g. camera_device_ will list unplugged
297 // but selected devices while this sting will be empty or contain current 261 // but selected devices while this sting will be empty or contain current
298 // selected device. 262 // selected device.
299 // TODO(hellner): refactor the code such that there is no need to keep two 263 // TODO(hellner): refactor the code such that there is no need to keep two
300 // strings for video devices that have subtle differences in behavior. 264 // strings for video devices that have subtle differences in behavior.
301 std::string video_device_name_; 265 std::string video_device_name_;
302 }; 266 };
303 267
304 } // namespace cricket 268 } // namespace cricket
305 269
306 #endif // TALK_SESSION_MEDIA_CHANNELMANAGER_H_ 270 #endif // TALK_SESSION_MEDIA_CHANNELMANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698