OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
6 | 6 |
7 #include "content/browser/browser_main_loop.h" | 7 #include "content/browser/browser_main_loop.h" |
8 #include "content/browser/renderer_host/media/web_contents_capture_util.h" | 8 #include "content/browser/renderer_host/media/web_contents_capture_util.h" |
9 #include "content/common/media/media_stream_messages.h" | 9 #include "content/common/media/media_stream_messages.h" |
10 #include "content/common/media/media_stream_options.h" | 10 #include "content/common/media/media_stream_options.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 << render_view_id << ", " | 135 << render_view_id << ", " |
136 << page_request_id << ", [" | 136 << page_request_id << ", [" |
137 << " audio:" << components.audio_type | 137 << " audio:" << components.audio_type |
138 << " video:" << components.video_type | 138 << " video:" << components.video_type |
139 << " ], " | 139 << " ], " |
140 << security_origin.spec() << ")"; | 140 << security_origin.spec() << ")"; |
141 | 141 |
142 std::string label; | 142 std::string label; |
143 if (components.audio_type == MEDIA_TAB_AUDIO_CAPTURE || | 143 if (components.audio_type == MEDIA_TAB_AUDIO_CAPTURE || |
144 components.video_type == MEDIA_TAB_VIDEO_CAPTURE) { | 144 components.video_type == MEDIA_TAB_VIDEO_CAPTURE) { |
145 DCHECK(!components.video_device_id.empty()); | 145 // Append our tab capture device id scheme. It's OK if both device_id's |
146 | 146 // are empty since we check their validity in GenerateStreamForDevice. |
147 // Append our tab capture device id scheme. | |
148 // TODO(justinlin): This is kind of a hack, but the plumbing for audio | 147 // TODO(justinlin): This is kind of a hack, but the plumbing for audio |
149 // streams is too complicated to plumb in by type. Will revisit once it's | 148 // streams is too complicated to plumb in by type. Will revisit once it's |
150 // refactored. http://crbug.com/163100 | 149 // refactored. http://crbug.com/163100 |
151 const std::string& device_id = | 150 const std::string& device_id = |
152 WebContentsCaptureUtil::AppendWebContentsDeviceScheme( | 151 WebContentsCaptureUtil::AppendWebContentsDeviceScheme( |
153 components.video_device_id); | 152 components.video_device_id.empty() ? |
| 153 components.video_device_id : components.audio_device_id); |
154 | 154 |
155 // TODO(justinlin): Cleanup/get rid of GenerateStreamForDevice and merge | 155 // TODO(justinlin): Cleanup/get rid of GenerateStreamForDevice and merge |
156 // with the regular GenerateStream. | 156 // with the regular GenerateStream. |
157 label = GetManager()->GenerateStreamForDevice( | 157 label = GetManager()->GenerateStreamForDevice( |
158 this, render_process_id_, render_view_id, | 158 this, render_process_id_, render_view_id, |
159 components, device_id, security_origin); | 159 components, device_id, security_origin); |
160 } else { | 160 } else { |
161 label = GetManager()->GenerateStream(this, render_process_id_, | 161 label = GetManager()->GenerateStream(this, render_process_id_, |
162 render_view_id, | 162 render_view_id, |
163 components, security_origin); | 163 components, security_origin); |
164 } | 164 } |
165 DCHECK(!label.empty()); | 165 if (label.empty()) |
| 166 return; |
| 167 |
166 streams_[label] = StreamRequest(render_view_id, page_request_id); | 168 streams_[label] = StreamRequest(render_view_id, page_request_id); |
167 } | 169 } |
168 | 170 |
169 void MediaStreamDispatcherHost::OnCancelGenerateStream(int render_view_id, | 171 void MediaStreamDispatcherHost::OnCancelGenerateStream(int render_view_id, |
170 int page_request_id) { | 172 int page_request_id) { |
171 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelGenerateStream(" | 173 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelGenerateStream(" |
172 << render_view_id << ", " | 174 << render_view_id << ", " |
173 << page_request_id << ")"; | 175 << page_request_id << ")"; |
174 | 176 |
175 for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) { | 177 for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); ++it) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 device_id, type, security_origin); | 227 device_id, type, security_origin); |
226 DCHECK(!label.empty()); | 228 DCHECK(!label.empty()); |
227 streams_[label] = StreamRequest(render_view_id, page_request_id); | 229 streams_[label] = StreamRequest(render_view_id, page_request_id); |
228 } | 230 } |
229 | 231 |
230 MediaStreamManager* MediaStreamDispatcherHost::GetManager() { | 232 MediaStreamManager* MediaStreamDispatcherHost::GetManager() { |
231 return BrowserMainLoop::GetMediaStreamManager(); | 233 return BrowserMainLoop::GetMediaStreamManager(); |
232 } | 234 } |
233 | 235 |
234 } // namespace content | 236 } // namespace content |
OLD | NEW |