OLD | NEW |
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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/metrics/sparse_histogram.h" | 18 #include "base/metrics/sparse_histogram.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/thread_task_runner_handle.h" | 21 #include "base/thread_task_runner_handle.h" |
22 #include "base/trace_event/trace_event.h" | 22 #include "base/trace_event/trace_event.h" |
23 #include "content/public/common/content_features.h" | 23 #include "content/public/common/content_features.h" |
24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
25 #include "content/renderer/media/media_stream_audio_track.h" | |
26 #include "content/renderer/media/media_stream_constraints_util.h" | 25 #include "content/renderer/media/media_stream_constraints_util.h" |
27 #include "content/renderer/media/media_stream_track.h" | 26 #include "content/renderer/media/media_stream_track.h" |
28 #include "content/renderer/media/peer_connection_tracker.h" | 27 #include "content/renderer/media/peer_connection_tracker.h" |
29 #include "content/renderer/media/remote_media_stream_impl.h" | 28 #include "content/renderer/media/remote_media_stream_impl.h" |
30 #include "content/renderer/media/rtc_certificate.h" | 29 #include "content/renderer/media/rtc_certificate.h" |
31 #include "content/renderer/media/rtc_data_channel_handler.h" | 30 #include "content/renderer/media/rtc_data_channel_handler.h" |
32 #include "content/renderer/media/rtc_dtmf_sender_handler.h" | 31 #include "content/renderer/media/rtc_dtmf_sender_handler.h" |
33 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" | 32 #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
34 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" | 33 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" |
35 #include "content/renderer/media/webrtc_audio_capturer.h" | |
36 #include "content/renderer/media/webrtc_audio_device_impl.h" | 34 #include "content/renderer/media/webrtc_audio_device_impl.h" |
37 #include "content/renderer/media/webrtc_uma_histograms.h" | 35 #include "content/renderer/media/webrtc_uma_histograms.h" |
38 #include "content/renderer/render_thread_impl.h" | 36 #include "content/renderer/render_thread_impl.h" |
39 #include "media/base/media_switches.h" | 37 #include "media/base/media_switches.h" |
40 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 38 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
41 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" | 39 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" |
42 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" | 40 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" |
43 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" | 41 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" |
44 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" | 42 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" |
45 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" | 43 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" |
(...skipping 1432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1478 | 1476 |
1479 ++num_data_channels_created_; | 1477 ++num_data_channels_created_; |
1480 | 1478 |
1481 return new RtcDataChannelHandler(base::ThreadTaskRunnerHandle::Get(), | 1479 return new RtcDataChannelHandler(base::ThreadTaskRunnerHandle::Get(), |
1482 webrtc_channel); | 1480 webrtc_channel); |
1483 } | 1481 } |
1484 | 1482 |
1485 blink::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender( | 1483 blink::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender( |
1486 const blink::WebMediaStreamTrack& track) { | 1484 const blink::WebMediaStreamTrack& track) { |
1487 DCHECK(thread_checker_.CalledOnValidThread()); | 1485 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1486 DCHECK(!track.isNull()); |
1488 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createDTMFSender"); | 1487 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::createDTMFSender"); |
1489 DVLOG(1) << "createDTMFSender."; | 1488 DVLOG(1) << "createDTMFSender."; |
1490 | 1489 |
1491 MediaStreamAudioTrack* native_track = MediaStreamAudioTrack::From(track); | 1490 // Find the WebRtc track referenced by the blink track's ID. |
1492 if (!native_track || !native_track->is_local_track() || | 1491 webrtc::AudioTrackInterface* webrtc_track = nullptr; |
1493 track.source().getType() != blink::WebMediaStreamSource::TypeAudio) { | 1492 for (const WebRtcMediaStreamAdapter* s : local_streams_) { |
1494 DLOG(ERROR) << "The DTMF sender requires a local audio track."; | 1493 webrtc_track = s->webrtc_media_stream()->FindAudioTrack(track.id().utf8()); |
| 1494 if (webrtc_track) |
| 1495 break; |
| 1496 } |
| 1497 if (!webrtc_track) { |
| 1498 DLOG(ERROR) << "Audio track with ID '" << track.id().utf8() |
| 1499 << "' has no known WebRtc sink."; |
1495 return nullptr; | 1500 return nullptr; |
1496 } | 1501 } |
1497 | 1502 |
1498 scoped_refptr<webrtc::AudioTrackInterface> audio_track = | |
1499 native_track->GetAudioAdapter(); | |
1500 rtc::scoped_refptr<webrtc::DtmfSenderInterface> sender( | 1503 rtc::scoped_refptr<webrtc::DtmfSenderInterface> sender( |
1501 native_peer_connection_->CreateDtmfSender(audio_track.get())); | 1504 native_peer_connection_->CreateDtmfSender(webrtc_track)); |
1502 if (!sender) { | 1505 if (!sender) { |
1503 DLOG(ERROR) << "Could not create native DTMF sender."; | 1506 DLOG(ERROR) << "Could not create native DTMF sender."; |
1504 return nullptr; | 1507 return nullptr; |
1505 } | 1508 } |
1506 if (peer_connection_tracker_) | 1509 if (peer_connection_tracker_) |
1507 peer_connection_tracker_->TrackCreateDTMFSender(this, track); | 1510 peer_connection_tracker_->TrackCreateDTMFSender(this, track); |
1508 | 1511 |
1509 return new RtcDtmfSenderHandler(sender); | 1512 return new RtcDtmfSenderHandler(sender); |
1510 } | 1513 } |
1511 | 1514 |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 } | 1798 } |
1796 | 1799 |
1797 void RTCPeerConnectionHandler::ResetUMAStats() { | 1800 void RTCPeerConnectionHandler::ResetUMAStats() { |
1798 DCHECK(thread_checker_.CalledOnValidThread()); | 1801 DCHECK(thread_checker_.CalledOnValidThread()); |
1799 num_local_candidates_ipv6_ = 0; | 1802 num_local_candidates_ipv6_ = 0; |
1800 num_local_candidates_ipv4_ = 0; | 1803 num_local_candidates_ipv4_ = 0; |
1801 ice_connection_checking_start_ = base::TimeTicks(); | 1804 ice_connection_checking_start_ = base::TimeTicks(); |
1802 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | 1805 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
1803 } | 1806 } |
1804 } // namespace content | 1807 } // namespace content |
OLD | NEW |