| 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/renderer/media/peer_connection_tracker.h" | 4 #include "content/renderer/media/peer_connection_tracker.h" |
| 5 | 5 |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "content/common/media/peer_connection_tracker_messages.h" | 9 #include "content/common/media/peer_connection_tracker_messages.h" |
| 10 #include "content/renderer/media/rtc_media_constraints.h" | 10 #include "content/renderer/media/rtc_media_constraints.h" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats) | 297 IPC_MESSAGE_HANDLER(PeerConnectionTracker_GetAllStats, OnGetAllStats) |
| 298 IPC_MESSAGE_HANDLER(PeerConnectionTracker_OnSuspend, OnSuspend) | 298 IPC_MESSAGE_HANDLER(PeerConnectionTracker_OnSuspend, OnSuspend) |
| 299 IPC_MESSAGE_UNHANDLED(handled = false) | 299 IPC_MESSAGE_UNHANDLED(handled = false) |
| 300 IPC_END_MESSAGE_MAP() | 300 IPC_END_MESSAGE_MAP() |
| 301 return handled; | 301 return handled; |
| 302 } | 302 } |
| 303 | 303 |
| 304 void PeerConnectionTracker::OnGetAllStats() { | 304 void PeerConnectionTracker::OnGetAllStats() { |
| 305 DCHECK(main_thread_.CalledOnValidThread()); | 305 DCHECK(main_thread_.CalledOnValidThread()); |
| 306 | 306 |
| 307 const std::string empty_track_id; |
| 307 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); | 308 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); |
| 308 it != peer_connection_id_map_.end(); ++it) { | 309 it != peer_connection_id_map_.end(); ++it) { |
| 309 rtc::scoped_refptr<InternalStatsObserver> observer( | 310 rtc::scoped_refptr<InternalStatsObserver> observer( |
| 310 new rtc::RefCountedObject<InternalStatsObserver>(it->second)); | 311 new rtc::RefCountedObject<InternalStatsObserver>(it->second)); |
| 311 | 312 |
| 313 // The last type parameter is ignored when the track id is empty. |
| 312 it->first->GetStats( | 314 it->first->GetStats( |
| 313 observer, | 315 observer, |
| 314 NULL, | 316 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug, |
| 315 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug); | 317 empty_track_id, blink::WebMediaStreamSource::TypeAudio); |
| 316 } | 318 } |
| 317 } | 319 } |
| 318 | 320 |
| 319 void PeerConnectionTracker::OnSuspend() { | 321 void PeerConnectionTracker::OnSuspend() { |
| 320 DCHECK(main_thread_.CalledOnValidThread()); | 322 DCHECK(main_thread_.CalledOnValidThread()); |
| 321 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); | 323 for (PeerConnectionIdMap::iterator it = peer_connection_id_map_.begin(); |
| 322 it != peer_connection_id_map_.end(); ++it) { | 324 it != peer_connection_id_map_.end(); ++it) { |
| 323 it->first->CloseClientPeerConnection(); | 325 it->first->CloseClientPeerConnection(); |
| 324 } | 326 } |
| 325 } | 327 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 RTCPeerConnectionHandler* pc_handler, | 383 RTCPeerConnectionHandler* pc_handler, |
| 382 const RTCMediaConstraints& constraints) { | 384 const RTCMediaConstraints& constraints) { |
| 383 DCHECK(main_thread_.CalledOnValidThread()); | 385 DCHECK(main_thread_.CalledOnValidThread()); |
| 384 SendPeerConnectionUpdate( | 386 SendPeerConnectionUpdate( |
| 385 pc_handler, "createAnswer", | 387 pc_handler, "createAnswer", |
| 386 "constraints: {" + SerializeMediaConstraints(constraints) + "}"); | 388 "constraints: {" + SerializeMediaConstraints(constraints) + "}"); |
| 387 } | 389 } |
| 388 | 390 |
| 389 void PeerConnectionTracker::TrackSetSessionDescription( | 391 void PeerConnectionTracker::TrackSetSessionDescription( |
| 390 RTCPeerConnectionHandler* pc_handler, | 392 RTCPeerConnectionHandler* pc_handler, |
| 391 const blink::WebRTCSessionDescription& desc, | 393 const std::string& sdp, const std::string& type, Source source) { |
| 392 Source source) { | |
| 393 DCHECK(main_thread_.CalledOnValidThread()); | 394 DCHECK(main_thread_.CalledOnValidThread()); |
| 394 string sdp = base::UTF16ToUTF8(desc.sdp()); | |
| 395 string type = base::UTF16ToUTF8(desc.type()); | |
| 396 | |
| 397 string value = "type: " + type + ", sdp: " + sdp; | 395 string value = "type: " + type + ", sdp: " + sdp; |
| 398 SendPeerConnectionUpdate( | 396 SendPeerConnectionUpdate( |
| 399 pc_handler, | 397 pc_handler, |
| 400 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", | 398 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", |
| 401 value); | 399 value); |
| 402 } | 400 } |
| 403 | 401 |
| 404 void PeerConnectionTracker::TrackUpdateIce( | 402 void PeerConnectionTracker::TrackUpdateIce( |
| 405 RTCPeerConnectionHandler* pc_handler, | 403 RTCPeerConnectionHandler* pc_handler, |
| 406 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 404 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 DCHECK(main_thread_.CalledOnValidThread()); | 573 DCHECK(main_thread_.CalledOnValidThread()); |
| 576 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 574 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
| 577 return; | 575 return; |
| 578 | 576 |
| 579 RenderThreadImpl::current()->Send( | 577 RenderThreadImpl::current()->Send( |
| 580 new PeerConnectionTrackerHost_UpdatePeerConnection( | 578 new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 581 peer_connection_id_map_[pc_handler], type, value)); | 579 peer_connection_id_map_[pc_handler], type, value)); |
| 582 } | 580 } |
| 583 | 581 |
| 584 } // namespace content | 582 } // namespace content |
| OLD | NEW |