| 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/common/media/media_stream_messages.h" | 8 #include "content/common/media/media_stream_messages.h" |
| 9 #include "content/common/media/media_stream_options.h" | 9 #include "content/common/media/media_stream_options.h" |
| 10 #include "googleurl/src/gurl.h" | 10 #include "googleurl/src/gurl.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 OnOpenDevice) | 135 OnOpenDevice) |
| 136 IPC_MESSAGE_UNHANDLED(handled = false) | 136 IPC_MESSAGE_UNHANDLED(handled = false) |
| 137 IPC_END_MESSAGE_MAP_EX() | 137 IPC_END_MESSAGE_MAP_EX() |
| 138 return handled; | 138 return handled; |
| 139 } | 139 } |
| 140 | 140 |
| 141 void MediaStreamDispatcherHost::OnChannelClosing() { | 141 void MediaStreamDispatcherHost::OnChannelClosing() { |
| 142 BrowserMessageFilter::OnChannelClosing(); | 142 BrowserMessageFilter::OnChannelClosing(); |
| 143 DVLOG(1) << "MediaStreamDispatcherHost::OnChannelClosing"; | 143 DVLOG(1) << "MediaStreamDispatcherHost::OnChannelClosing"; |
| 144 | 144 |
| 145 // Since the IPC channel is gone, cancel pending requests and close all | 145 // Since the IPC channel is gone, close all requesting/requested streams. |
| 146 // requested VideoCaptureDevices. | |
| 147 GetManager()->CancelRequests(this); | |
| 148 for (StreamMap::iterator it = streams_.begin(); | 146 for (StreamMap::iterator it = streams_.begin(); |
| 149 it != streams_.end(); | 147 it != streams_.end(); |
| 150 it++) { | 148 ++it) { |
| 151 std::string label = it->first; | 149 std::string label = it->first; |
| 152 GetManager()->StopGeneratedStream(label); | 150 GetManager()->StopGeneratedStream(label); |
| 153 } | 151 } |
| 152 // Clear the map after we have stopped all the streams. |
| 153 streams_.clear(); |
| 154 } | 154 } |
| 155 | 155 |
| 156 MediaStreamDispatcherHost::~MediaStreamDispatcherHost() {} | 156 MediaStreamDispatcherHost::~MediaStreamDispatcherHost() { |
| 157 DCHECK(streams_.empty()); |
| 158 } |
| 157 | 159 |
| 158 void MediaStreamDispatcherHost::OnGenerateStream( | 160 void MediaStreamDispatcherHost::OnGenerateStream( |
| 159 int render_view_id, | 161 int render_view_id, |
| 160 int page_request_id, | 162 int page_request_id, |
| 161 const media_stream::StreamOptions& components, | 163 const media_stream::StreamOptions& components, |
| 162 const GURL& security_origin) { | 164 const GURL& security_origin) { |
| 163 DVLOG(1) << "MediaStreamDispatcherHost::OnGenerateStream(" | 165 DVLOG(1) << "MediaStreamDispatcherHost::OnGenerateStream(" |
| 164 << render_view_id << ", " | 166 << render_view_id << ", " |
| 165 << page_request_id << ", [ " | 167 << page_request_id << ", [ " |
| 166 << (components.audio ? "audio " : "") | 168 << (components.audio ? "audio " : "") |
| 167 << (components.video ? "video " : "") | 169 << (components.video ? "video " : "") |
| 168 << "], " | 170 << "], " |
| 169 << security_origin.spec() << ")"; | 171 << security_origin.spec() << ")"; |
| 170 | 172 |
| 171 std::string label; | 173 std::string label; |
| 172 GetManager()->GenerateStream(this, render_process_id_, render_view_id, | 174 GetManager()->GenerateStream(this, render_process_id_, render_view_id, |
| 173 components, security_origin, &label); | 175 components, security_origin, &label); |
| 174 DCHECK(!label.empty()); | 176 DCHECK(!label.empty()); |
| 175 streams_[label] = StreamRequest(render_view_id, page_request_id); | 177 streams_[label] = StreamRequest(render_view_id, page_request_id); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void MediaStreamDispatcherHost::OnCancelGenerateStream(int render_view_id, | 180 void MediaStreamDispatcherHost::OnCancelGenerateStream(int render_view_id, |
| 179 int page_request_id) { | 181 int page_request_id) { |
| 180 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelGenerateStream(" | 182 DVLOG(1) << "MediaStreamDispatcherHost::OnCancelGenerateStream(" |
| 181 << render_view_id << ", " | 183 << render_view_id << ", " |
| 182 << page_request_id << ")"; | 184 << page_request_id << ")"; |
| 183 | 185 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 device_id, type, security_origin, &label); | 237 device_id, type, security_origin, &label); |
| 236 DCHECK(!label.empty()); | 238 DCHECK(!label.empty()); |
| 237 streams_[label] = StreamRequest(render_view_id, page_request_id); | 239 streams_[label] = StreamRequest(render_view_id, page_request_id); |
| 238 } | 240 } |
| 239 | 241 |
| 240 MediaStreamManager* MediaStreamDispatcherHost::GetManager() { | 242 MediaStreamManager* MediaStreamDispatcherHost::GetManager() { |
| 241 return BrowserMainLoop::GetMediaStreamManager(); | 243 return BrowserMainLoop::GetMediaStreamManager(); |
| 242 } | 244 } |
| 243 | 245 |
| 244 } // namespace media_stream | 246 } // namespace media_stream |
| OLD | NEW |