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 "content/browser/renderer_host/media/media_stream_provider.h" | 31 #include "content/browser/renderer_host/media/media_stream_provider.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 int render_view_id, const StreamOptions& options, | 64 int render_view_id, const StreamOptions& options, |
62 const std::string& security_origin, std::string* label); | 65 const std::string& security_origin, std::string* label); |
63 | 66 |
64 // Cancels all non-finished GenerateStream request, i.e. request for which | 67 // Cancels all non-finished GenerateStream request, i.e. request for which |
65 // StreamGenerated hasn't been called. | 68 // StreamGenerated hasn't been called. |
66 void CancelRequests(MediaStreamRequester* requester); | 69 void CancelRequests(MediaStreamRequester* requester); |
67 | 70 |
68 // Closes generated stream. | 71 // Closes generated stream. |
69 void StopGeneratedStream(const std::string& label); | 72 void StopGeneratedStream(const std::string& label); |
70 | 73 |
74 // Gets a list of devices of |type|. | |
75 // The request is identified using |label|, which is pointing to a | |
76 // std::string. | |
77 void EnumerateDevices(MediaStreamRequester* requester, | |
scherkus (not reviewing)
2011/12/06 19:25:04
I think I understand why GenerateStream() returns
wjia(left Chromium)
2012/01/24 00:59:46
This is internal implementation in browser process
| |
78 int render_process_id, | |
79 int render_view_id, | |
80 MediaStreamType type, | |
81 const std::string& security_origin, | |
82 std::string* label); | |
83 | |
84 // Open a device identified by |device_id|. | |
85 // The request is identified using |label|, which is pointing to a | |
86 // std::string. | |
87 void OpenDevice(MediaStreamRequester* requester, | |
88 int render_process_id, | |
89 int render_view_id, | |
90 const std::string& device_id, | |
91 MediaStreamType type, | |
92 const std::string& security_origin, | |
93 std::string* label); | |
94 | |
71 // Implements MediaStreamProviderListener. | 95 // Implements MediaStreamProviderListener. |
72 virtual void Opened(MediaStreamType stream_type, | 96 virtual void Opened(MediaStreamType stream_type, |
73 int capture_session_id) OVERRIDE; | 97 int capture_session_id) OVERRIDE; |
74 virtual void Closed(MediaStreamType stream_type, | 98 virtual void Closed(MediaStreamType stream_type, |
75 int capture_session_id) OVERRIDE; | 99 int capture_session_id) OVERRIDE; |
76 virtual void DevicesEnumerated(MediaStreamType stream_type, | 100 virtual void DevicesEnumerated(MediaStreamType stream_type, |
77 const StreamDeviceInfoArray& devices) OVERRIDE; | 101 const StreamDeviceInfoArray& devices) OVERRIDE; |
78 virtual void Error(MediaStreamType stream_type, | 102 virtual void Error(MediaStreamType stream_type, |
79 int capture_session_id, | 103 int capture_session_id, |
80 MediaStreamProviderError error) OVERRIDE; | 104 MediaStreamProviderError error) OVERRIDE; |
81 | 105 |
82 // Implements SettingsRequester. | 106 // Implements SettingsRequester. |
83 virtual void GetDevices(const std::string& label, | |
84 MediaStreamType stream_type) OVERRIDE; | |
85 virtual void DevicesAccepted(const std::string& label, | 107 virtual void DevicesAccepted(const std::string& label, |
86 const StreamDeviceInfoArray& devices) OVERRIDE; | 108 const StreamDeviceInfoArray& devices) OVERRIDE; |
87 virtual void SettingsError(const std::string& label) OVERRIDE; | 109 virtual void SettingsError(const std::string& label) OVERRIDE; |
88 | 110 |
89 // Used by unit test to make sure fake devices are used instead of a real | 111 // Used by unit test to make sure fake devices are used instead of a real |
90 // devices, which is needed for server based testing. | 112 // devices, which is needed for server based testing. |
91 void UseFakeDevice(); | 113 void UseFakeDevice(); |
92 | 114 |
93 private: | 115 private: |
94 // Contains all data needed to keep track of requests. | 116 // Contains all data needed to keep track of requests. |
95 struct DeviceRequest; | 117 struct DeviceRequest; |
96 | 118 |
97 // Helpers. | 119 // Helpers. |
98 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; | 120 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; |
99 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); | 121 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); |
122 void StartEnumeration(DeviceRequest* new_request, | |
123 int render_process_id, | |
124 int render_view_id, | |
125 const std::string& security_origin, | |
126 std::string* label); | |
100 | 127 |
101 scoped_ptr<MediaStreamDeviceSettings> device_settings_; | 128 scoped_ptr<MediaStreamDeviceSettings> device_settings_; |
102 scoped_ptr<VideoCaptureManager> video_capture_manager_; | 129 scoped_ptr<VideoCaptureManager> video_capture_manager_; |
103 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; | 130 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; |
104 | 131 |
105 // Keeps track of device types currently being enumerated to not enumerate | 132 // Keeps track of device types currently being enumerated to not enumerate |
106 // when not necessary. | 133 // when not necessary. |
107 std::vector<bool> enumeration_in_progress_; | 134 std::vector<bool> enumeration_in_progress_; |
108 | 135 |
109 // All non-closed request. | 136 // All non-closed request. |
110 typedef std::map<std::string, DeviceRequest> DeviceRequests; | 137 typedef std::map<std::string, DeviceRequest> DeviceRequests; |
111 DeviceRequests requests_; | 138 DeviceRequests requests_; |
112 | 139 |
113 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); | 140 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); |
114 }; | 141 }; |
115 | 142 |
116 } // namespace media_stream | 143 } // namespace media_stream |
117 | 144 |
118 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ | 145 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ |
OLD | NEW |