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