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

Side by Side Diff: content/browser/renderer_host/media/media_stream_manager.h

Issue 8480028: support video device enumeration from renderer process. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | Annotate | Revision Log
OLDNEW
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.
11 // 3. MediaStreamDeviceSettings will request list(s) of available devices, the 11 // 3. MediaStreamDeviceSettings will request list(s) of available devices, the
mflodman_chromium_OOO 2011/11/29 02:30:56 The flow has changed somewhat and the comment need
wjia(left Chromium) 2011/11/30 00:14:23 Done.
12 // requests will be relayed to the corresponding media device manager and the 12 // requests will be relayed to the corresponding media device manager and the
13 // result will be given to MediaStreamDeviceSettings. 13 // result will be given to 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 19 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
20 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 20 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
21 21
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, 91 virtual void Opened(MediaStreamType stream_type,
73 int capture_session_id) OVERRIDE; 92 int capture_session_id) OVERRIDE;
74 virtual void Closed(MediaStreamType stream_type, 93 virtual void Closed(MediaStreamType stream_type,
75 int capture_session_id) OVERRIDE; 94 int capture_session_id) OVERRIDE;
76 virtual void DevicesEnumerated(MediaStreamType stream_type, 95 virtual void DevicesEnumerated(MediaStreamType stream_type,
77 const StreamDeviceInfoArray& devices) OVERRIDE; 96 const StreamDeviceInfoArray& devices) OVERRIDE;
78 virtual void Error(MediaStreamType stream_type, 97 virtual void Error(MediaStreamType stream_type,
79 int capture_session_id, 98 int capture_session_id,
80 MediaStreamProviderError error) OVERRIDE; 99 MediaStreamProviderError error) OVERRIDE;
81 100
82 // Implements SettingsRequester. 101 // Implements SettingsRequester.
83 virtual void GetDevices(const std::string& label,
84 MediaStreamType stream_type) OVERRIDE;
85 virtual void DevicesAccepted(const std::string& label, 102 virtual void DevicesAccepted(const std::string& label,
86 const StreamDeviceInfoArray& devices) OVERRIDE; 103 const StreamDeviceInfoArray& devices) OVERRIDE;
87 virtual void SettingsError(const std::string& label) OVERRIDE; 104 virtual void SettingsError(const std::string& label) OVERRIDE;
88 105
89 // Used by unit test to make sure fake devices are used instead of a real 106 // Used by unit test to make sure fake devices are used instead of a real
90 // devices, which is needed for server based testing. 107 // devices, which is needed for server based testing.
91 void UseFakeDevice(); 108 void UseFakeDevice();
92 109
93 private: 110 private:
94 // Contains all data needed to keep track of requests. 111 // Contains all data needed to keep track of requests.
95 struct DeviceRequest; 112 struct DeviceRequest;
96 113
97 // Helpers. 114 // Helpers.
98 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const; 115 bool RequestDone(const MediaStreamManager::DeviceRequest& request) const;
99 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type); 116 MediaStreamProvider* GetDeviceManager(MediaStreamType stream_type);
117 void StartEnumeration(DeviceRequest* new_request,
118 int render_process_id,
119 int render_view_id,
120 const std::string& security_origin,
121 std::string* label);
100 122
101 scoped_ptr<MediaStreamDeviceSettings> device_settings_; 123 scoped_ptr<MediaStreamDeviceSettings> device_settings_;
102 scoped_ptr<VideoCaptureManager> video_capture_manager_; 124 scoped_ptr<VideoCaptureManager> video_capture_manager_;
103 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_; 125 scoped_ptr<AudioInputDeviceManager> audio_input_device_manager_;
104 126
105 // Keeps track of device types currently being enumerated to not enumerate 127 // Keeps track of device types currently being enumerated to not enumerate
106 // when not necessary. 128 // when not necessary.
107 std::vector<bool> enumeration_in_progress_; 129 std::vector<bool> enumeration_in_progress_;
108 130
109 // All non-closed request. 131 // All non-closed request.
110 typedef std::map<std::string, DeviceRequest> DeviceRequests; 132 typedef std::map<std::string, DeviceRequest> DeviceRequests;
111 DeviceRequests requests_; 133 DeviceRequests requests_;
112 134
113 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager); 135 DISALLOW_COPY_AND_ASSIGN(MediaStreamManager);
114 }; 136 };
115 137
116 } // namespace media_stream 138 } // namespace media_stream
117 139
118 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_ 140 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_MEDIA_STREAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698