| 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 id = base::UTF16ToUTF8(base::StringPiece16(stream.id())); | 93 std::string id = stream.id().utf8(); |
| 94 std::string result = "id: " + id; | 94 std::string result = "id: " + id; |
| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 | 544 |
| 545 void PeerConnectionTracker::TrackAddIceCandidate( | 545 void PeerConnectionTracker::TrackAddIceCandidate( |
| 546 RTCPeerConnectionHandler* pc_handler, | 546 RTCPeerConnectionHandler* pc_handler, |
| 547 const blink::WebRTCICECandidate& candidate, | 547 const blink::WebRTCICECandidate& candidate, |
| 548 Source source, | 548 Source source, |
| 549 bool succeeded) { | 549 bool succeeded) { |
| 550 DCHECK(main_thread_.CalledOnValidThread()); | 550 DCHECK(main_thread_.CalledOnValidThread()); |
| 551 int id = GetLocalIDForHandler(pc_handler); | 551 int id = GetLocalIDForHandler(pc_handler); |
| 552 if (id == -1) | 552 if (id == -1) |
| 553 return; | 553 return; |
| 554 std::string value = | 554 std::string value = "sdpMid: " + candidate.sdpMid().utf8() + ", " + |
| 555 "sdpMid: " + base::UTF16ToUTF8(base::StringPiece16(candidate.sdpMid())) + | 555 "sdpMLineIndex: " + |
| 556 ", " + "sdpMLineIndex: " + base::UintToString(candidate.sdpMLineIndex()) + | 556 base::UintToString(candidate.sdpMLineIndex()) + ", " + |
| 557 ", " + "candidate: " + | 557 "candidate: " + candidate.candidate().utf8(); |
| 558 base::UTF16ToUTF8(base::StringPiece16(candidate.candidate())); | |
| 559 | 558 |
| 560 // OnIceCandidate always succeeds as it's a callback from the browser. | 559 // OnIceCandidate always succeeds as it's a callback from the browser. |
| 561 DCHECK(source != SOURCE_LOCAL || succeeded); | 560 DCHECK(source != SOURCE_LOCAL || succeeded); |
| 562 | 561 |
| 563 const char* event = | 562 const char* event = |
| 564 (source == SOURCE_LOCAL) ? "onIceCandidate" | 563 (source == SOURCE_LOCAL) ? "onIceCandidate" |
| 565 : (succeeded ? "addIceCandidate" | 564 : (succeeded ? "addIceCandidate" |
| 566 : "addIceCandidateFailed"); | 565 : "addIceCandidateFailed"); |
| 567 | 566 |
| 568 SendPeerConnectionUpdate(id, event, value); | 567 SendPeerConnectionUpdate(id, event, value); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 SendPeerConnectionUpdate(id, "onRenegotiationNeeded", std::string()); | 693 SendPeerConnectionUpdate(id, "onRenegotiationNeeded", std::string()); |
| 695 } | 694 } |
| 696 | 695 |
| 697 void PeerConnectionTracker::TrackCreateDTMFSender( | 696 void PeerConnectionTracker::TrackCreateDTMFSender( |
| 698 RTCPeerConnectionHandler* pc_handler, | 697 RTCPeerConnectionHandler* pc_handler, |
| 699 const blink::WebMediaStreamTrack& track) { | 698 const blink::WebMediaStreamTrack& track) { |
| 700 DCHECK(main_thread_.CalledOnValidThread()); | 699 DCHECK(main_thread_.CalledOnValidThread()); |
| 701 int id = GetLocalIDForHandler(pc_handler); | 700 int id = GetLocalIDForHandler(pc_handler); |
| 702 if (id == -1) | 701 if (id == -1) |
| 703 return; | 702 return; |
| 704 SendPeerConnectionUpdate(id, "createDTMFSender", | 703 SendPeerConnectionUpdate(id, "createDTMFSender", track.id().utf8()); |
| 705 base::UTF16ToUTF8(base::StringPiece16(track.id()))); | |
| 706 } | 704 } |
| 707 | 705 |
| 708 void PeerConnectionTracker::TrackGetUserMedia( | 706 void PeerConnectionTracker::TrackGetUserMedia( |
| 709 const blink::WebUserMediaRequest& user_media_request) { | 707 const blink::WebUserMediaRequest& user_media_request) { |
| 710 DCHECK(main_thread_.CalledOnValidThread()); | 708 DCHECK(main_thread_.CalledOnValidThread()); |
| 711 | 709 |
| 712 SendTarget()->Send(new PeerConnectionTrackerHost_GetUserMedia( | 710 SendTarget()->Send(new PeerConnectionTrackerHost_GetUserMedia( |
| 713 user_media_request.getSecurityOrigin().toString().utf8(), | 711 user_media_request.getSecurityOrigin().toString().utf8(), |
| 714 user_media_request.audio(), user_media_request.video(), | 712 user_media_request.audio(), user_media_request.video(), |
| 715 SerializeMediaConstraints(user_media_request.audioConstraints()), | 713 SerializeMediaConstraints(user_media_request.audioConstraints()), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 740 DCHECK(main_thread_.CalledOnValidThread()); | 738 DCHECK(main_thread_.CalledOnValidThread()); |
| 741 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( | 739 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 742 local_id, std::string(callback_type), value)); | 740 local_id, std::string(callback_type), value)); |
| 743 } | 741 } |
| 744 | 742 |
| 745 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { | 743 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { |
| 746 send_target_for_test_ = target; | 744 send_target_for_test_ = target; |
| 747 } | 745 } |
| 748 | 746 |
| 749 } // namespace content | 747 } // namespace content |
| OLD | NEW |