Chromium Code Reviews| 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/media/webrtc/webrtc_eventlog_host.h" | 7 #include "content/browser/media/webrtc/webrtc_eventlog_host.h" |
| 8 #include "content/browser/media/webrtc/webrtc_internals.h" | 8 #include "content/browser/media/webrtc/webrtc_internals.h" |
| 9 #include "content/browser/renderer_host/render_process_host_impl.h" | 9 #include "content/browser/renderer_host/render_process_host_impl.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 WebRTCEventLogHost* event_log_host) | 17 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 } | 96 } |
| 95 | 97 |
| 96 void PeerConnectionTrackerHost::OnAddStats(int lid, | 98 void PeerConnectionTrackerHost::OnAddStats(int lid, |
| 97 const base::ListValue& value) { | 99 const base::ListValue& value) { |
| 98 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value); | 100 WebRTCInternals::GetInstance()->OnAddStats(peer_pid(), lid, value); |
| 99 } | 101 } |
| 100 | 102 |
| 101 void PeerConnectionTrackerHost::OnGetUserMedia( | 103 void PeerConnectionTrackerHost::OnGetUserMedia( |
| 102 const std::string& origin, | 104 const std::string& origin, |
| 103 bool audio, | 105 bool audio, |
| 104 bool video, | 106 const VideoInfo& video_info, |
| 105 const std::string& audio_constraints, | 107 const std::string& audio_constraints, |
| 106 const std::string& video_constraints) { | 108 const std::string& video_constraints) { |
| 107 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, | 109 WebRTCInternals::GetInstance()->OnGetUserMedia(render_process_id_, |
| 108 peer_pid(), | 110 peer_pid(), |
| 109 origin, | 111 origin, |
| 110 audio, | 112 audio, |
| 111 video, | 113 video_info.video, |
| 112 audio_constraints, | 114 audio_constraints, |
| 113 video_constraints); | 115 video_constraints); |
| 116 #if defined(OS_ANDROID) | |
| 117 is_screen_capture_ = | |
|
Sergey Ulanov
2016/08/01 18:20:36
There can be multiple media streams, and as far as
braveyao
2016/08/03 00:23:47
Done.
Single flag is necessary on Android. During
Sergey Ulanov
2016/08/19 05:54:15
Then I still think this code won't work correctly,
braveyao
2016/08/23 21:18:54
Yes, this is a problem. Here is a temp solution an
braveyao
2016/08/30 23:06:14
Done.
| |
| 118 video_info.video_stream_source == kMediaStreamSourceScreen; | |
| 119 #endif | |
| 114 } | 120 } |
| 115 | 121 |
| 116 void PeerConnectionTrackerHost::OnSuspend() { | 122 void PeerConnectionTrackerHost::OnSuspend() { |
| 117 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 123 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 118 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this)); | 124 base::Bind(&PeerConnectionTrackerHost::SendOnSuspendOnUIThread, this)); |
| 119 } | 125 } |
| 120 | 126 |
| 121 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { | 127 void PeerConnectionTrackerHost::SendOnSuspendOnUIThread() { |
| 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 128 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 123 content::RenderProcessHost* host = | 129 content::RenderProcessHost* host = |
| 124 content::RenderProcessHost::FromID(render_process_id_); | 130 content::RenderProcessHost::FromID(render_process_id_); |
| 125 if (host) | 131 if (host && !is_screen_capture_) |
|
Sergey Ulanov
2016/08/01 18:20:36
See my comment above. I think you always want to s
braveyao
2016/08/03 00:23:47
see comments above.
| |
| 126 host->Send(new PeerConnectionTracker_OnSuspend()); | 132 host->Send(new PeerConnectionTracker_OnSuspend()); |
| 127 } | 133 } |
| 128 | 134 |
| 129 } // namespace content | 135 } // namespace content |
| OLD | NEW |