| 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/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
| 8 #include "content/renderer/media/rtc_media_constraints.h" | 8 #include "content/renderer/media/rtc_media_constraints.h" |
| 9 #include "content/renderer/media/rtc_peer_connection_handler.h" | 9 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 string result = "["; | 29 string result = "["; |
| 30 for (size_t i = 0; i < servers.size(); ++i) { | 30 for (size_t i = 0; i < servers.size(); ++i) { |
| 31 result += servers[i].uri; | 31 result += servers[i].uri; |
| 32 if (i != servers.size() - 1) | 32 if (i != servers.size() - 1) |
| 33 result += ", "; | 33 result += ", "; |
| 34 } | 34 } |
| 35 result += "]"; | 35 result += "]"; |
| 36 return result; | 36 return result; |
| 37 } | 37 } |
| 38 | 38 |
| 39 static RTCMediaConstraints GetNativeMediaConstraints( |
| 40 const blink::WebMediaConstraints& constraints) { |
| 41 RTCMediaConstraints native_constraints; |
| 42 |
| 43 blink::WebVector<blink::WebMediaConstraint> mandatory; |
| 44 constraints.getMandatoryConstraints(mandatory); |
| 45 for (size_t i = 0; i < mandatory.size(); ++i) { |
| 46 native_constraints.AddMandatory( |
| 47 mandatory[i].m_name.utf8(), mandatory[i].m_value.utf8(), false); |
| 48 } |
| 49 |
| 50 blink::WebVector<blink::WebMediaConstraint> optional; |
| 51 constraints.getOptionalConstraints(optional); |
| 52 for (size_t i = 0; i < optional.size(); ++i) { |
| 53 native_constraints.AddOptional( |
| 54 optional[i].m_name.utf8(), optional[i].m_value.utf8(), false); |
| 55 } |
| 56 return native_constraints; |
| 57 } |
| 58 |
| 39 static string SerializeMediaConstraints( | 59 static string SerializeMediaConstraints( |
| 40 const RTCMediaConstraints& constraints) { | 60 const RTCMediaConstraints& constraints) { |
| 41 string result; | 61 string result; |
| 42 MediaConstraintsInterface::Constraints mandatory = constraints.GetMandatory(); | 62 MediaConstraintsInterface::Constraints mandatory = constraints.GetMandatory(); |
| 43 if (!mandatory.empty()) { | 63 if (!mandatory.empty()) { |
| 44 result += "mandatory: {"; | 64 result += "mandatory: {"; |
| 45 for (size_t i = 0; i < mandatory.size(); ++i) { | 65 for (size_t i = 0; i < mandatory.size(); ++i) { |
| 46 result += mandatory[i].key + ":" + mandatory[i].value; | 66 result += mandatory[i].key + ":" + mandatory[i].value; |
| 47 if (i != mandatory.size() - 1) | 67 if (i != mandatory.size() - 1) |
| 48 result += ", "; | 68 result += ", "; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 | 454 |
| 435 void PeerConnectionTracker::TrackCreateDTMFSender( | 455 void PeerConnectionTracker::TrackCreateDTMFSender( |
| 436 RTCPeerConnectionHandler* pc_handler, | 456 RTCPeerConnectionHandler* pc_handler, |
| 437 const blink::WebMediaStreamTrack& track) { | 457 const blink::WebMediaStreamTrack& track) { |
| 438 SendPeerConnectionUpdate(pc_handler, "createDTMFSender", | 458 SendPeerConnectionUpdate(pc_handler, "createDTMFSender", |
| 439 base::UTF16ToUTF8(track.id())); | 459 base::UTF16ToUTF8(track.id())); |
| 440 } | 460 } |
| 441 | 461 |
| 442 void PeerConnectionTracker::TrackGetUserMedia( | 462 void PeerConnectionTracker::TrackGetUserMedia( |
| 443 const blink::WebUserMediaRequest& user_media_request) { | 463 const blink::WebUserMediaRequest& user_media_request) { |
| 444 RTCMediaConstraints audio_constraints(user_media_request.audioConstraints()); | 464 RTCMediaConstraints audio_constraints( |
| 445 RTCMediaConstraints video_constraints(user_media_request.videoConstraints()); | 465 GetNativeMediaConstraints(user_media_request.audioConstraints())); |
| 466 RTCMediaConstraints video_constraints( |
| 467 GetNativeMediaConstraints(user_media_request.videoConstraints())); |
| 446 | 468 |
| 447 RenderThreadImpl::current()->Send(new PeerConnectionTrackerHost_GetUserMedia( | 469 RenderThreadImpl::current()->Send(new PeerConnectionTrackerHost_GetUserMedia( |
| 448 user_media_request.securityOrigin().toString().utf8(), | 470 user_media_request.securityOrigin().toString().utf8(), |
| 449 user_media_request.audio(), | 471 user_media_request.audio(), |
| 450 user_media_request.video(), | 472 user_media_request.video(), |
| 451 SerializeMediaConstraints(audio_constraints), | 473 SerializeMediaConstraints(audio_constraints), |
| 452 SerializeMediaConstraints(video_constraints))); | 474 SerializeMediaConstraints(video_constraints))); |
| 453 } | 475 } |
| 454 | 476 |
| 455 int PeerConnectionTracker::GetNextLocalID() { | 477 int PeerConnectionTracker::GetNextLocalID() { |
| 456 return next_lid_++; | 478 return next_lid_++; |
| 457 } | 479 } |
| 458 | 480 |
| 459 void PeerConnectionTracker::SendPeerConnectionUpdate( | 481 void PeerConnectionTracker::SendPeerConnectionUpdate( |
| 460 RTCPeerConnectionHandler* pc_handler, | 482 RTCPeerConnectionHandler* pc_handler, |
| 461 const std::string& type, | 483 const std::string& type, |
| 462 const std::string& value) { | 484 const std::string& value) { |
| 463 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 485 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
| 464 return; | 486 return; |
| 465 | 487 |
| 466 RenderThreadImpl::current()->Send( | 488 RenderThreadImpl::current()->Send( |
| 467 new PeerConnectionTrackerHost_UpdatePeerConnection( | 489 new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 468 peer_connection_id_map_[pc_handler], type, value)); | 490 peer_connection_id_map_[pc_handler], type, value)); |
| 469 } | 491 } |
| 470 | 492 |
| 471 } // namespace content | 493 } // namespace content |
| OLD | NEW |