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