| 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 | 4 |
| 5 #include "content/renderer/media/peer_connection_tracker.h" | 5 #include "content/renderer/media/peer_connection_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return "null"; | 78 return "null"; |
| 79 | 79 |
| 80 std::ostringstream result; | 80 std::ostringstream result; |
| 81 result << ", voiceActivityDetection: " | 81 result << ", voiceActivityDetection: " |
| 82 << SerializeBoolean(options.voiceActivityDetection()); | 82 << SerializeBoolean(options.voiceActivityDetection()); |
| 83 return result.str(); | 83 return result.str(); |
| 84 } | 84 } |
| 85 | 85 |
| 86 static std::string SerializeMediaStreamComponent( | 86 static std::string SerializeMediaStreamComponent( |
| 87 const blink::WebMediaStreamTrack& component) { | 87 const blink::WebMediaStreamTrack& component) { |
| 88 return base::UTF16ToUTF8(base::StringPiece16(component.source().id())); | 88 return component.source().id().utf8(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 static std::string SerializeMediaDescriptor( | 91 static std::string SerializeMediaDescriptor( |
| 92 const blink::WebMediaStream& stream) { | 92 const blink::WebMediaStream& stream) { |
| 93 std::string label = base::UTF16ToUTF8(base::StringPiece16(stream.id())); | 93 std::string label = stream.id().utf8(); |
| 94 std::string result = "label: " + label; | 94 std::string result = "label: " + label; |
| 95 blink::WebVector<blink::WebMediaStreamTrack> tracks; | 95 blink::WebVector<blink::WebMediaStreamTrack> tracks; |
| 96 stream.audioTracks(tracks); | 96 stream.audioTracks(tracks); |
| 97 if (!tracks.isEmpty()) { | 97 if (!tracks.isEmpty()) { |
| 98 result += ", audio: ["; | 98 result += ", audio: ["; |
| 99 for (size_t i = 0; i < tracks.size(); ++i) { | 99 for (size_t i = 0; i < tracks.size(); ++i) { |
| 100 result += SerializeMediaStreamComponent(tracks[i]); | 100 result += SerializeMediaStreamComponent(tracks[i]); |
| 101 if (i != tracks.size() - 1) | 101 if (i != tracks.size() - 1) |
| 102 result += ", "; | 102 result += ", "; |
| 103 } | 103 } |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 547 |
| 548 void PeerConnectionTracker::TrackAddIceCandidate( | 548 void PeerConnectionTracker::TrackAddIceCandidate( |
| 549 RTCPeerConnectionHandler* pc_handler, | 549 RTCPeerConnectionHandler* pc_handler, |
| 550 const blink::WebRTCICECandidate& candidate, | 550 const blink::WebRTCICECandidate& candidate, |
| 551 Source source, | 551 Source source, |
| 552 bool succeeded) { | 552 bool succeeded) { |
| 553 DCHECK(main_thread_.CalledOnValidThread()); | 553 DCHECK(main_thread_.CalledOnValidThread()); |
| 554 int id = GetLocalIDForHandler(pc_handler); | 554 int id = GetLocalIDForHandler(pc_handler); |
| 555 if (id == -1) | 555 if (id == -1) |
| 556 return; | 556 return; |
| 557 std::string value = | 557 std::string value = "sdpMid: " + candidate.sdpMid().utf8() + ", " + |
| 558 "sdpMid: " + base::UTF16ToUTF8(base::StringPiece16(candidate.sdpMid())) + | 558 "sdpMLineIndex: " + |
| 559 ", " + "sdpMLineIndex: " + base::UintToString(candidate.sdpMLineIndex()) + | 559 base::UintToString(candidate.sdpMLineIndex()) + ", " + |
| 560 ", " + "candidate: " + | 560 "candidate: " + candidate.candidate().utf8(); |
| 561 base::UTF16ToUTF8(base::StringPiece16(candidate.candidate())); | |
| 562 | 561 |
| 563 // OnIceCandidate always succeeds as it's a callback from the browser. | 562 // OnIceCandidate always succeeds as it's a callback from the browser. |
| 564 DCHECK(source != SOURCE_LOCAL || succeeded); | 563 DCHECK(source != SOURCE_LOCAL || succeeded); |
| 565 | 564 |
| 566 const char* event = | 565 const char* event = |
| 567 (source == SOURCE_LOCAL) ? "onIceCandidate" | 566 (source == SOURCE_LOCAL) ? "onIceCandidate" |
| 568 : (succeeded ? "addIceCandidate" | 567 : (succeeded ? "addIceCandidate" |
| 569 : "addIceCandidateFailed"); | 568 : "addIceCandidateFailed"); |
| 570 | 569 |
| 571 SendPeerConnectionUpdate(id, event, value); | 570 SendPeerConnectionUpdate(id, event, value); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 SendPeerConnectionUpdate(id, "onRenegotiationNeeded", std::string()); | 696 SendPeerConnectionUpdate(id, "onRenegotiationNeeded", std::string()); |
| 698 } | 697 } |
| 699 | 698 |
| 700 void PeerConnectionTracker::TrackCreateDTMFSender( | 699 void PeerConnectionTracker::TrackCreateDTMFSender( |
| 701 RTCPeerConnectionHandler* pc_handler, | 700 RTCPeerConnectionHandler* pc_handler, |
| 702 const blink::WebMediaStreamTrack& track) { | 701 const blink::WebMediaStreamTrack& track) { |
| 703 DCHECK(main_thread_.CalledOnValidThread()); | 702 DCHECK(main_thread_.CalledOnValidThread()); |
| 704 int id = GetLocalIDForHandler(pc_handler); | 703 int id = GetLocalIDForHandler(pc_handler); |
| 705 if (id == -1) | 704 if (id == -1) |
| 706 return; | 705 return; |
| 707 SendPeerConnectionUpdate(id, "createDTMFSender", | 706 SendPeerConnectionUpdate(id, "createDTMFSender", track.id().utf8()); |
| 708 base::UTF16ToUTF8(base::StringPiece16(track.id()))); | |
| 709 } | 707 } |
| 710 | 708 |
| 711 void PeerConnectionTracker::TrackGetUserMedia( | 709 void PeerConnectionTracker::TrackGetUserMedia( |
| 712 const blink::WebUserMediaRequest& user_media_request) { | 710 const blink::WebUserMediaRequest& user_media_request) { |
| 713 DCHECK(main_thread_.CalledOnValidThread()); | 711 DCHECK(main_thread_.CalledOnValidThread()); |
| 714 | 712 |
| 715 SendTarget()->Send(new PeerConnectionTrackerHost_GetUserMedia( | 713 SendTarget()->Send(new PeerConnectionTrackerHost_GetUserMedia( |
| 716 user_media_request.getSecurityOrigin().toString().utf8(), | 714 user_media_request.getSecurityOrigin().toString().utf8(), |
| 717 user_media_request.audio(), user_media_request.video(), | 715 user_media_request.audio(), user_media_request.video(), |
| 718 SerializeMediaConstraints(user_media_request.audioConstraints()), | 716 SerializeMediaConstraints(user_media_request.audioConstraints()), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 743 DCHECK(main_thread_.CalledOnValidThread()); | 741 DCHECK(main_thread_.CalledOnValidThread()); |
| 744 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( | 742 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 745 local_id, std::string(callback_type), value)); | 743 local_id, std::string(callback_type), value)); |
| 746 } | 744 } |
| 747 | 745 |
| 748 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { | 746 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { |
| 749 send_target_for_test_ = target; | 747 send_target_for_test_ = target; |
| 750 } | 748 } |
| 751 | 749 |
| 752 } // namespace content | 750 } // namespace content |
| OLD | NEW |