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/enumerate media capture devices (video |
6 // now). Call flow: | 6 // supported 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. |
11 // 3. MediaStreamDeviceSettings will request list(s) of available devices, the | 11 // 3. MediaStreamManager will request the corresponding media device manager(s) |
12 // requests will be relayed to the corresponding media device manager and the | 12 // to enumerate available devices. The result will be given to |
13 // result will be given to MediaStreamDeviceSettings. | 13 // MediaStreamDeviceSettings. |
14 // 4. MediaStreamDeviceSettings will, by using user settings, pick devices which | 14 // 4. MediaStreamDeviceSettings will, by using user settings, pick devices which |
15 // devices to use and let MediaStreamManager know the result. | 15 // devices to use and let MediaStreamManager know the result. |
16 // 5. MediaStreamManager will call the proper media device manager to open the | 16 // 5. MediaStreamManager will call the proper media device manager to open the |
17 // device and let the MediaStreamRequester know it has been done. | 17 // device and let the MediaStreamRequester know it has been done. |
18 | 18 |
| 19 // When enumeration and open are done in separate operations, |
| 20 // MediaStreamDeviceSettings is not involved as in steps. |
| 21 |
19 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 22 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
20 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 23 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
21 | 24 |
22 #include <map> | 25 #include <map> |
23 #include <string> | 26 #include <string> |
24 #include <vector> | 27 #include <vector> |
25 | 28 |
26 #include "base/basictypes.h" | 29 #include "base/basictypes.h" |
27 #include "base/memory/scoped_ptr.h" | 30 #include "base/memory/scoped_ptr.h" |
28 #include "base/memory/ref_counted.h" | 31 #include "base/memory/ref_counted.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 int render_view_id, const StreamOptions& options, | 67 int render_view_id, const StreamOptions& options, |
65 const std::string& security_origin, std::string* label); | 68 const std::string& security_origin, std::string* label); |
66 | 69 |
67 // Cancels all non-finished GenerateStream request, i.e. request for which | 70 // Cancels all non-finished GenerateStream request, i.e. request for which |
68 // StreamGenerated hasn't been called. | 71 // StreamGenerated hasn't been called. |
69 void CancelRequests(MediaStreamRequester* requester); | 72 void CancelRequests(MediaStreamRequester* requester); |
70 | 73 |
71 // Closes generated stream. | 74 // Closes generated stream. |
72 void StopGeneratedStream(const std::string& label); | 75 void StopGeneratedStream(const std::string& label); |
73 | 76 |
| 77 // Gets a list of devices of |type|. |
| 78 // The request is identified using |label|, which is pointing to a |
| 79 // std::string. |
| 80 void EnumerateDevices(MediaStreamRequester* requester, |
| 81 int render_process_id, |
| 82 int render_view_id, |
| 83 MediaStreamType type, |
| 84 const std::string& security_origin, |
| 85 std::string* label); |
| 86 |
| 87 // Open a device identified by |device_id|. |
| 88 // The request is identified using |label|, which is pointing to a |
| 89 // std::string. |
| 90 void OpenDevice(MediaStreamRequester* requester, |
| 91 int render_process_id, |
| 92 int render_view_id, |
| 93 const std::string& device_id, |
| 94 MediaStreamType type, |
| 95 const std::string& security_origin, |
| 96 std::string* label); |
| 97 |
74 // Implements MediaStreamProviderListener. | 98 // Implements MediaStreamProviderListener. |
75 virtual void Opened(MediaStreamType stream_type, | 99 virtual void Opened(MediaStreamType stream_type, |
76 int capture_session_id) OVERRIDE; | 100 int capture_session_id) OVERRIDE; |
77 virtual void Closed(MediaStreamType stream_type, | 101 virtual void Closed(MediaStreamType stream_type, |
78 int capture_session_id) OVERRIDE; | 102 int capture_session_id) OVERRIDE; |
79 virtual void DevicesEnumerated(MediaStreamType stream_type, | 103 virtual void DevicesEnumerated(MediaStreamType stream_type, |
80 const StreamDeviceInfoArray& devices) OVERRIDE; | 104 const StreamDeviceInfoArray& devices) OVERRIDE; |
81 virtual void Error(MediaStreamType stream_type, | 105 virtual void Error(MediaStreamType stream_type, |
82 int capture_session_id, | 106 int capture_session_id, |
83 MediaStreamProviderError error) OVERRIDE; | 107 MediaStreamProviderError error) OVERRIDE; |
84 | 108 |
85 // Implements SettingsRequester. | 109 // Implements SettingsRequester. |
86 virtual void GetDevices(const std::string& label, | |
87 MediaStreamType stream_type) OVERRIDE; | |
88 virtual void DevicesAccepted(const std::string& label, | 110 virtual void DevicesAccepted(const std::string& label, |
89 const StreamDeviceInfoArray& devices) OVERRIDE; | 111 const StreamDeviceInfoArray& devices) OVERRIDE; |
90 virtual void SettingsError(const std::string& label) OVERRIDE; | 112 virtual void SettingsError(const std::string& label) OVERRIDE; |
91 | 113 |
92 // Used by unit test to make sure fake devices are used instead of a real | 114 // Used by unit test to make sure fake devices are used instead of a real |
93 // devices, which is needed for server based testing. | 115 // devices, which is needed for server based testing. |
94 void UseFakeDevice(); | 116 void UseFakeDevice(); |
95 | 117 |
96 private: | 118 private: |
97 // Contains all data needed to keep track of requests. | 119 // Contains all data needed to keep track of requests. |
98 struct DeviceRequest; | 120 struct DeviceRequest; |
99 | 121 |
100 // Helpers. | 122 // Helpers. |
101 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; | 123 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; |
102 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); | 124 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); |
| 125 void StartEnumeration(DeviceRequest* new_request, |
| 126 int render_process_id, |
| 127 int render_view_id, |
| 128 const std::string& security_origin, |
| 129 std::string* label); |
103 | 130 |
104 scoped_ptr<MediaStreamDeviceSettings> device_settings_; | 131 scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
105 scoped_ptr<VideoCaptureManager> video_capture_manager_; | 132 scoped_ptr<VideoCaptureManager> video_capture_manager_; |
106 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; | 133 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; |
107 | 134 |
108 // Keeps track of device types currently being enumerated to not enumerate | 135 // Keeps track of device types currently being enumerated to not enumerate |
109 // when not necessary. | 136 // when not necessary. |
110 std::vector<bool> enumeration_in_progress_; | 137 std::vector<bool> enumeration_in_progress_; |
111 | 138 |
112 // All non-closed request. | 139 // All non-closed request. |
113 typedef std::map<std::string, DeviceRequest> DeviceRequests; | 140 typedef std::map<std::string, DeviceRequest> DeviceRequests; |
114 DeviceRequests requests_; | 141 DeviceRequests requests_; |
115 scoped_refptr<AudioManager> audio_manager_; | 142 scoped_refptr<AudioManager> audio_manager_; |
116 | 143 |
117 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 144 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
118 }; | 145 }; |
119 | 146 |
120 } // namespace media_stream | 147 } // namespace media_stream |
121 | 148 |
122 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 149 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |