OLD | NEW |
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 #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/resource_context.h" |
7 #include "content/common/media/media_stream_messages.h" | 8 #include "content/common/media/media_stream_messages.h" |
8 #include "content/common/media/media_stream_options.h" | 9 #include "content/common/media/media_stream_options.h" |
9 | 10 |
10 namespace media_stream { | 11 namespace media_stream { |
11 | 12 |
12 MediaStreamDispatcherHost::MediaStreamDispatcherHost(int render_process_id) | 13 MediaStreamDispatcherHost::MediaStreamDispatcherHost( |
13 : render_process_id_(render_process_id) { | 14 const content::ResourceContext* resource_context, int render_process_id) |
| 15 : resource_context_(resource_context), |
| 16 render_process_id_(render_process_id) { |
14 } | 17 } |
15 | 18 |
16 MediaStreamDispatcherHost::~MediaStreamDispatcherHost() { | 19 MediaStreamDispatcherHost::~MediaStreamDispatcherHost() { |
17 } | 20 } |
18 | 21 |
19 MediaStreamManager* MediaStreamDispatcherHost::manager() { | 22 MediaStreamManager* MediaStreamDispatcherHost::manager() { |
20 return MediaStreamManager::Get(); | 23 return resource_context_->media_stream_manager(); |
21 } | 24 } |
22 | 25 |
23 bool MediaStreamDispatcherHost::OnMessageReceived( | 26 bool MediaStreamDispatcherHost::OnMessageReceived( |
24 const IPC::Message& message, bool* message_was_ok) { | 27 const IPC::Message& message, bool* message_was_ok) { |
25 bool handled = true; | 28 bool handled = true; |
26 IPC_BEGIN_MESSAGE_MAP_EX(MediaStreamDispatcherHost, message, *message_was_ok) | 29 IPC_BEGIN_MESSAGE_MAP_EX(MediaStreamDispatcherHost, message, *message_was_ok) |
27 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_GenerateStream, OnGenerateStream) | 30 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_GenerateStream, OnGenerateStream) |
28 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_StopGeneratedStream, | 31 IPC_MESSAGE_HANDLER(MediaStreamHostMsg_StopGeneratedStream, |
29 OnStopGeneratedStream) | 32 OnStopGeneratedStream) |
30 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
31 IPC_END_MESSAGE_MAP_EX() | 34 IPC_END_MESSAGE_MAP_EX() |
32 return handled; | 35 return handled; |
33 } | 36 } |
34 | 37 |
35 void MediaStreamDispatcherHost::OnChannelClosing() { | 38 void MediaStreamDispatcherHost::OnChannelClosing() { |
36 BrowserMessageFilter::OnChannelClosing(); | 39 BrowserMessageFilter::OnChannelClosing(); |
37 VLOG(1) << "MediaStreamDispatcherHost::OnChannelClosing"; | 40 VLOG(1) << "MediaStreamDispatcherHost::OnChannelClosing"; |
38 | 41 |
| 42 // TODO(mflodman) Remove this temporary solution when shut-down issue is |
| 43 // resolved, i.e. uncomment the code below. |
39 // Since the IPC channel is gone, close all requested VideCaptureDevices and | 44 // Since the IPC channel is gone, close all requested VideCaptureDevices and |
40 // cancel pending requests. | 45 // cancel pending requests. |
41 manager()->CancelRequests(this); | 46 // manager()->CancelRequests(this); |
42 for (StreamMap::iterator it = streams_.begin(); it != streams_.end(); it++) { | 47 // for (StreamMap::iterator it = streams_.begin(); |
43 std::string label = it->first; | 48 // it != streams_.end(); |
44 manager()->StopGeneratedStream(label); | 49 // it++) { |
45 } | 50 // std::string label = it->first; |
| 51 // manager()->StopGeneratedStream(label); |
| 52 // } |
46 } | 53 } |
47 | 54 |
48 void MediaStreamDispatcherHost::OnGenerateStream( | 55 void MediaStreamDispatcherHost::OnGenerateStream( |
49 int render_view_id, | 56 int render_view_id, |
50 int page_request_id, | 57 int page_request_id, |
51 const media_stream::StreamOptions& components, | 58 const media_stream::StreamOptions& components, |
52 const std::string& security_origin) { | 59 const std::string& security_origin) { |
53 VLOG(1) << "MediaStreamDispatcherHost::OnGenerateStream(" | 60 VLOG(1) << "MediaStreamDispatcherHost::OnGenerateStream(" |
54 << render_view_id << ", " | 61 << render_view_id << ", " |
55 << page_request_id << ", [ " | 62 << page_request_id << ", [ " |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 142 |
136 StreamMap::iterator it = streams_.find(label); | 143 StreamMap::iterator it = streams_.find(label); |
137 DCHECK(it != streams_.end()); | 144 DCHECK(it != streams_.end()); |
138 StreamRequest request = it->second; | 145 StreamRequest request = it->second; |
139 Send(new MediaStreamHostMsg_VideoDeviceFailed(request.render_view_id, | 146 Send(new MediaStreamHostMsg_VideoDeviceFailed(request.render_view_id, |
140 label, | 147 label, |
141 index)); | 148 index)); |
142 } | 149 } |
143 | 150 |
144 } // namespace media_stream | 151 } // namespace media_stream |
OLD | NEW |