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