Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 2749703005: RTCRtpSender with track behind RuntimeEnabled flag (Closed)
Patch Set: Fix win-specific compile error. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/rtc_peer_connection_handler.h" 5 #include "content/renderer/media/rtc_peer_connection_handler.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 12 matching lines...) Expand all
23 #include "content/public/common/content_switches.h" 23 #include "content/public/common/content_switches.h"
24 #include "content/renderer/media/media_stream_constraints_util.h" 24 #include "content/renderer/media/media_stream_constraints_util.h"
25 #include "content/renderer/media/media_stream_track.h" 25 #include "content/renderer/media/media_stream_track.h"
26 #include "content/renderer/media/peer_connection_tracker.h" 26 #include "content/renderer/media/peer_connection_tracker.h"
27 #include "content/renderer/media/remote_media_stream_impl.h" 27 #include "content/renderer/media/remote_media_stream_impl.h"
28 #include "content/renderer/media/rtc_certificate.h" 28 #include "content/renderer/media/rtc_certificate.h"
29 #include "content/renderer/media/rtc_data_channel_handler.h" 29 #include "content/renderer/media/rtc_data_channel_handler.h"
30 #include "content/renderer/media/rtc_dtmf_sender_handler.h" 30 #include "content/renderer/media/rtc_dtmf_sender_handler.h"
31 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" 31 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
32 #include "content/renderer/media/webrtc/rtc_rtp_receiver.h" 32 #include "content/renderer/media/webrtc/rtc_rtp_receiver.h"
33 #include "content/renderer/media/webrtc/rtc_rtp_sender.h"
33 #include "content/renderer/media/webrtc/rtc_stats.h" 34 #include "content/renderer/media/webrtc/rtc_stats.h"
34 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" 35 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h"
35 #include "content/renderer/media/webrtc_audio_device_impl.h" 36 #include "content/renderer/media/webrtc_audio_device_impl.h"
36 #include "content/renderer/media/webrtc_uma_histograms.h" 37 #include "content/renderer/media/webrtc_uma_histograms.h"
37 #include "content/renderer/render_thread_impl.h" 38 #include "content/renderer/render_thread_impl.h"
38 #include "media/base/media_switches.h" 39 #include "media/base/media_switches.h"
39 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" 40 #include "third_party/WebKit/public/platform/WebMediaConstraints.h"
40 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" 41 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h"
41 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" 42 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h"
42 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" 43 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h"
43 #include "third_party/WebKit/public/platform/WebRTCError.h" 44 #include "third_party/WebKit/public/platform/WebRTCError.h"
44 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" 45 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h"
45 #include "third_party/WebKit/public/platform/WebRTCLegacyStats.h" 46 #include "third_party/WebKit/public/platform/WebRTCLegacyStats.h"
46 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" 47 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h"
48 #include "third_party/WebKit/public/platform/WebRTCRtpSender.h"
47 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" 49 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h"
48 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" 50 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h"
49 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" 51 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h"
50 #include "third_party/WebKit/public/platform/WebURL.h" 52 #include "third_party/WebKit/public/platform/WebURL.h"
51 #include "third_party/webrtc/pc/mediasession.h" 53 #include "third_party/webrtc/pc/mediasession.h"
52 54
53 using webrtc::DataChannelInterface; 55 using webrtc::DataChannelInterface;
54 using webrtc::IceCandidateInterface; 56 using webrtc::IceCandidateInterface;
55 using webrtc::MediaStreamInterface; 57 using webrtc::MediaStreamInterface;
56 using webrtc::PeerConnectionInterface; 58 using webrtc::PeerConnectionInterface;
(...skipping 1587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 1646
1645 void RTCPeerConnectionHandler::GetStats( 1647 void RTCPeerConnectionHandler::GetStats(
1646 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) { 1648 std::unique_ptr<blink::WebRTCStatsReportCallback> callback) {
1647 DCHECK(thread_checker_.CalledOnValidThread()); 1649 DCHECK(thread_checker_.CalledOnValidThread());
1648 signaling_thread()->PostTask(FROM_HERE, 1650 signaling_thread()->PostTask(FROM_HERE,
1649 base::Bind(&GetRTCStatsOnSignalingThread, 1651 base::Bind(&GetRTCStatsOnSignalingThread,
1650 base::ThreadTaskRunnerHandle::Get(), native_peer_connection_, 1652 base::ThreadTaskRunnerHandle::Get(), native_peer_connection_,
1651 base::Passed(&callback))); 1653 base::Passed(&callback)));
1652 } 1654 }
1653 1655
1656 blink::WebVector<std::unique_ptr<blink::WebRTCRtpSender>>
1657 RTCPeerConnectionHandler::GetSenders() {
1658 DCHECK(thread_checker_.CalledOnValidThread());
1659 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::getSenders");
1660 std::vector<rtc::scoped_refptr<webrtc::RtpSenderInterface>> webrtc_senders =
1661 native_peer_connection_->GetSenders();
1662 blink::WebVector<std::unique_ptr<blink::WebRTCRtpSender>> web_senders(
1663 webrtc_senders.size());
1664 for (size_t i = 0; i < web_senders.size(); ++i) {
1665 rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> webrtc_track =
1666 webrtc_senders[i]->track();
1667 std::unique_ptr<blink::WebMediaStreamTrack> web_track;
1668
1669 if (webrtc_track) {
1670 std::string track_id = webrtc_track->id();
1671 bool is_audio_track = (webrtc_track->kind() ==
1672 webrtc::MediaStreamTrackInterface::kAudioKind);
1673 for (const auto& stream_adapter : local_streams_) {
1674 blink::WebVector<blink::WebMediaStreamTrack> tracks;
1675 if (is_audio_track)
1676 stream_adapter->web_stream().AudioTracks(tracks);
1677 else
1678 stream_adapter->web_stream().VideoTracks(tracks);
1679 for (const blink::WebMediaStreamTrack& track : tracks) {
1680 if (track.Id() == track_id.c_str()) {
1681 web_track.reset(new blink::WebMediaStreamTrack(track));
1682 break;
1683 }
1684 }
1685 if (web_track)
1686 break;
1687 }
1688 DCHECK(web_track);
1689 }
1690
1691 web_senders[i].reset(
1692 new RTCRtpSender(webrtc_senders[i].get(), std::move(web_track)));
Guido Urdaneta 2017/05/02 12:31:48 nit: favor base::MakeUnique over new.
hbos_chromium 2017/05/03 09:54:23 Done.
1693 }
1694 return web_senders;
1695 }
1696
1654 blink::WebVector<std::unique_ptr<blink::WebRTCRtpReceiver>> 1697 blink::WebVector<std::unique_ptr<blink::WebRTCRtpReceiver>>
1655 RTCPeerConnectionHandler::GetReceivers() { 1698 RTCPeerConnectionHandler::GetReceivers() {
1656 DCHECK(thread_checker_.CalledOnValidThread()); 1699 DCHECK(thread_checker_.CalledOnValidThread());
1657 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::getReceivers"); 1700 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::getReceivers");
1658 1701
1659 std::vector<rtc::scoped_refptr<webrtc::RtpReceiverInterface>> 1702 std::vector<rtc::scoped_refptr<webrtc::RtpReceiverInterface>>
1660 webrtc_receivers = native_peer_connection_->GetReceivers(); 1703 webrtc_receivers = native_peer_connection_->GetReceivers();
1661 std::vector<std::unique_ptr<blink::WebRTCRtpReceiver>> web_receivers; 1704 std::vector<std::unique_ptr<blink::WebRTCRtpReceiver>> web_receivers;
1662 for (size_t i = 0; i < webrtc_receivers.size(); ++i) { 1705 for (size_t i = 0; i < webrtc_receivers.size(); ++i) {
1663 rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> webrtc_track = 1706 rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> webrtc_track =
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 } 2120 }
2078 2121
2079 void RTCPeerConnectionHandler::ResetUMAStats() { 2122 void RTCPeerConnectionHandler::ResetUMAStats() {
2080 DCHECK(thread_checker_.CalledOnValidThread()); 2123 DCHECK(thread_checker_.CalledOnValidThread());
2081 num_local_candidates_ipv6_ = 0; 2124 num_local_candidates_ipv6_ = 0;
2082 num_local_candidates_ipv4_ = 0; 2125 num_local_candidates_ipv4_ = 0;
2083 ice_connection_checking_start_ = base::TimeTicks(); 2126 ice_connection_checking_start_ = base::TimeTicks();
2084 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); 2127 memset(ice_state_seen_, 0, sizeof(ice_state_seen_));
2085 } 2128 }
2086 } // namespace content 2129 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698