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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const IPC::Message& message, bool* message_was_ok) { | 88 const IPC::Message& message, bool* message_was_ok) { |
89 bool handled = true; | 89 bool handled = true; |
90 IPC_BEGIN_MESSAGE_MAP_EX(MediaStreamDispatcherHost, message, *message_was_ok) | 90 IPC_BEGIN_MESSAGE_MAP_EX(MediaStreamDispatcherHost, message, *message_was_ok) |
91 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_GenerateStream, OnGenerateStream) | 91 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_GenerateStream, OnGenerateStream) |
92 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_CancelGenerateStream, | 92 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_CancelGenerateStream, |
93 OnCancelGenerateStream) | 93 OnCancelGenerateStream) |
94 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_StopStreamDevice, | 94 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_StopStreamDevice, |
95 OnStopStreamDevice) | 95 OnStopStreamDevice) |
96 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_EnumerateDevices, | 96 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_EnumerateDevices, |
97 OnEnumerateDevices) | 97 OnEnumerateDevices) |
| 98 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_CancelEnumerateDevices, |
| 99 OnCancelEnumerateDevices) |
98 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_OpenDevice, | 100 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_OpenDevice, |
99 OnOpenDevice) | 101 OnOpenDevice) |
100 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_CloseDevice, | 102 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_CloseDevice, |
101 OnCloseDevice) | 103 OnCloseDevice) |
102 IPC_MESSAGE_UNHANDLED(handled = false) | 104 IPC_MESSAGE_UNHANDLED(handled = false) |
103 IPC_END_MESSAGE_MAP_EX() | 105 IPC_END_MESSAGE_MAP_EX() |
104 return handled; | 106 return handled; |
105 } | 107 } |
106 | 108 |
107 void MediaStreamDispatcherHost::OnChannelClosing() { | 109 void MediaStreamDispatcherHost::OnChannelClosing() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 StoreRequest(render_view_id, page_request_id, label); | 187 StoreRequest(render_view_id, page_request_id, label); |
186 } | 188 } |
187 | 189 |
188 void MediaStreamDispatcherHost::OnCancelEnumerateDevices( | 190 void MediaStreamDispatcherHost::OnCancelEnumerateDevices( |
189 int render_view_id, | 191 int render_view_id, |
190 const std::string& label) { | 192 const std::string& label) { |
191 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices(" | 193 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelEnumerateDevices(" |
192 << render_view_id << ", " | 194 << render_view_id << ", " |
193 << label << ")"; | 195 << label << ")"; |
194 | 196 |
| 197 if (streams_.find(label) == streams_.end()) { |
| 198 // According to the comments in MediaStreamDispatcher::OnDevicesEnumerated, |
| 199 // OnCancelEnumerateDevices can be called several times with the same label. |
| 200 DVLOG(1) << "Enumeration request with label " << label |
| 201 << "does not exist."; |
| 202 return; |
| 203 } |
195 media_stream_manager_->CancelRequest(label); | 204 media_stream_manager_->CancelRequest(label); |
196 PopRequest(label); | 205 PopRequest(label); |
197 } | 206 } |
198 | 207 |
199 void MediaStreamDispatcherHost::OnOpenDevice( | 208 void MediaStreamDispatcherHost::OnOpenDevice( |
200 int render_view_id, | 209 int render_view_id, |
201 int page_request_id, | 210 int page_request_id, |
202 const std::string& device_id, | 211 const std::string& device_id, |
203 MediaStreamType type, | 212 MediaStreamType type, |
204 const GURL& security_origin) { | 213 const GURL& security_origin) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 MediaStreamDispatcherHost::StreamRequest | 246 MediaStreamDispatcherHost::StreamRequest |
238 MediaStreamDispatcherHost::PopRequest(const std::string& label) { | 247 MediaStreamDispatcherHost::PopRequest(const std::string& label) { |
239 StreamMap::iterator it = streams_.find(label); | 248 StreamMap::iterator it = streams_.find(label); |
240 CHECK(it != streams_.end()); | 249 CHECK(it != streams_.end()); |
241 StreamRequest request = it->second; | 250 StreamRequest request = it->second; |
242 streams_.erase(it); | 251 streams_.erase(it); |
243 return request; | 252 return request; |
244 } | 253 } |
245 | 254 |
246 } // namespace content | 255 } // namespace content |
OLD | NEW |