OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" | 4 #include "content/browser/renderer_host/media/peer_connection_tracker_host.h" |
5 | 5 |
6 #include "base/power_monitor/power_monitor.h" | 6 #include "base/power_monitor/power_monitor.h" |
7 #include "content/browser/renderer_host/render_process_host_impl.h" | 7 #include "content/browser/renderer_host/render_process_host_impl.h" |
8 #include "content/browser/webrtc/webrtc_eventlog_host.h" | 8 #include "content/browser/webrtc/webrtc_eventlog_host.h" |
9 #include "content/browser/webrtc/webrtc_internals.h" | 9 #include "content/browser/webrtc/webrtc_internals.h" |
| 10 #include "content/common/media/media_stream_options.h" |
10 #include "content/common/media/peer_connection_tracker_messages.h" | 11 #include "content/common/media/peer_connection_tracker_messages.h" |
11 | 12 |
12 namespace content { | 13 namespace content { |
13 | 14 |
14 PeerConnectionTrackerHost::PeerConnectionTrackerHost( | 15 PeerConnectionTrackerHost::PeerConnectionTrackerHost( |
15 int render_process_id, | 16 int render_process_id, |
16 const base::WeakPtr<WebRTCEventLogHost>& event_log_host) | 17 const base::WeakPtr<WebRTCEventLogHost>& event_log_host) |
17 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), | 18 : BrowserMessageFilter(PeerConnectionTrackerMsgStart), |
18 render_process_id_(render_process_id), | 19 render_process_id_(render_process_id), |
| 20 is_screen_capture_(false), |
19 event_log_host_(event_log_host) { | 21 event_log_host_(event_log_host) { |
20 DCHECK(event_log_host); | 22 DCHECK(event_log_host); |
21 } | 23 } |
22 | 24 |
23 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { | 25 bool PeerConnectionTrackerHost::OnMessageReceived(const IPC::Message& message) { |
24 bool handled = true; | 26 bool handled = true; |
25 | 27 |
26 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) | 28 IPC_BEGIN_MESSAGE_MAP(PeerConnectionTrackerHost, message) |
27 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, | 29 IPC_MESSAGE_HANDLER(PeerConnectionTrackerHost_AddPeerConnection, |
28 OnAddPeerConnection) | 30 OnAddPeerConnection) |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 98 } |
97 | 99 |
98 void PeerConnectionTrackerHost::OnAddStats(int lid, | 100 void PeerConnectionTrackerHost::OnAddStats(int lid, |
99 const base::ListValue& value) { | 101 const base::ListValue& value) { |
100 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value); | 102 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value); |
101 } | 103 } |
102 | 104 |
103 void PeerConnectionTrackerHost::OnGetUserMedia( | 105 void PeerConnectionTrackerHost::OnGetUserMedia( |
104 const std::string& origin, | 106 const std::string& origin, |
105 bool audio, | 107 bool audio, |
106 bool video, | 108 const VideoInfo& video_info, |
107 const std::string& audio_constraints, | 109 const std::string& audio_constraints, |
108 const std::string& video_constraints) { | 110 const std::string& video_constraints) { |
| 111 base::AutoLock lock(lock_); |
109 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, | 112 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, |
110 peer_pid(), | 113 peer_pid(), |
111 origin, | 114 origin, |
112 audio, | 115 audio, |
113 video, | 116 video_info.video, |
114 audio_constraints, | 117 audio_constraints, |
115 video_constraints); | 118 video_constraints); |
| 119 #if defined(OS_ANDROID) |
| 120 is_screen_capture_ = |
| 121 video_info.video_stream_source == kMediaStreamSourceScreen; |
| 122 #endif |
116 } | 123 } |
117 | 124 |
118 void PeerConnectionTrackerHost::OnSuspend() { | 125 void PeerConnectionTrackerHost::OnSuspend() { |
119 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 126 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
120 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this)); | 127 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this)); |
121 } | 128 } |
122 | 129 |
123 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { | 130 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { |
| 131 base::AutoLock lock(lock_); |
124 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
125 content::RenderProcessHost* host = | 133 content::RenderProcessHost* host = |
126 content::RenderProcessHost::FromID(render_process_id_); | 134 content::RenderProcessHost::FromID(render_process_id_); |
127 if (host) | 135 if (host && !is_screen_capture_) |
128 host->Send(new PeerConnectionTracker_OnSuspend()); | 136 host->Send(new PeerConnectionTracker_OnSuspend()); |
129 } | 137 } |
130 | 138 |
131 } // namespace content | 139 } // namespace content |
OLD | NEW |