OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // MediaStreamManager is used to open media capture devices (video supported | 5 // MediaStreamManager is used to open media capture devices (video supported |
6 // now). Call flow: | 6 // now). Call flow: |
7 // 1. GenerateStream is called when a render process wants to use a capture | 7 // 1. GenerateStream is called when a render process wants to use a capture |
8 // device. | 8 // device. |
9 // 2. MediaStreamManager will ask MediaStreamDeviceSettings for permission to | 9 // 2. MediaStreamManager will ask MediaStreamDeviceSettings for permission to |
10 // use devices and for which device to use. | 10 // use devices and for which device to use. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 virtual void DevicesAccepted(const std::string& label, | 82 virtual void DevicesAccepted(const std::string& label, |
83 const StreamDeviceInfoArray& devices); | 83 const StreamDeviceInfoArray& devices); |
84 virtual void SettingsError(const std::string& label); | 84 virtual void SettingsError(const std::string& label); |
85 | 85 |
86 // Used by unit test to make sure fake devices are used instead of a real | 86 // Used by unit test to make sure fake devices are used instead of a real |
87 // devices, which is needed for server based testing. | 87 // devices, which is needed for server based testing. |
88 void UseFakeDevice(); | 88 void UseFakeDevice(); |
89 | 89 |
90 private: | 90 private: |
91 // Contains all data needed to keep track of requests. | 91 // Contains all data needed to keep track of requests. |
92 struct DeviceRequest { | 92 struct DeviceRequest; |
93 DeviceRequest(); | |
94 DeviceRequest(MediaStreamRequester* requester, | |
95 const StreamOptions& request_options); | |
96 ~DeviceRequest(); | |
97 enum RequestState { | |
98 kNotRequested = 0, | |
99 kRequested, | |
100 kOpening, | |
101 kDone, | |
102 kError | |
103 }; | |
104 | |
105 MediaStreamRequester* requester; | |
106 StreamOptions options; | |
107 std::vector<RequestState> state; | |
108 StreamDeviceInfoArray audio_devices; | |
109 StreamDeviceInfoArray video_devices; | |
110 }; | |
111 | 93 |
112 // Helpers. | 94 // Helpers. |
113 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; | 95 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; |
114 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); | 96 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); |
115 | 97 |
116 scoped_ptr<MediaStreamDeviceSettings> device_settings_; | 98 scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
117 scoped_ptr<VideoCaptureManager> video_capture_manager_; | 99 scoped_ptr<VideoCaptureManager> video_capture_manager_; |
118 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; | 100 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; |
119 | 101 |
120 // Keeps track of device types currently being enumerated to not enumerate | 102 // Keeps track of device types currently being enumerated to not enumerate |
121 // when not necessary. | 103 // when not necessary. |
122 std::vector<bool> enumeration_in_progress_; | 104 std::vector<bool> enumeration_in_progress_; |
123 | 105 |
124 // All non-closed request. | 106 // All non-closed request. |
125 typedef std::map<std::string, DeviceRequest> DeviceRequests; | 107 typedef std::map<std::string, DeviceRequest> DeviceRequests; |
126 DeviceRequests requests_; | 108 DeviceRequests requests_; |
127 | 109 |
128 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 110 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
129 }; | 111 }; |
130 | 112 |
131 } // namespace media_stream | 113 } // namespace media_stream |
132 | 114 |
133 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 115 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |