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> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
17 #include "content/renderer/media/media_stream_dependency_factory.h" | 17 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 18 #include "content/renderer/media/media_stream_source_extra_data.h" |
18 #include "content/renderer/media/peer_connection_tracker.h" | 19 #include "content/renderer/media/peer_connection_tracker.h" |
19 #include "content/renderer/media/remote_media_stream_impl.h" | 20 #include "content/renderer/media/remote_media_stream_impl.h" |
20 #include "content/renderer/media/rtc_data_channel_handler.h" | 21 #include "content/renderer/media/rtc_data_channel_handler.h" |
21 #include "content/renderer/media/rtc_dtmf_sender_handler.h" | 22 #include "content/renderer/media/rtc_dtmf_sender_handler.h" |
22 #include "content/renderer/media/rtc_media_constraints.h" | 23 #include "content/renderer/media/rtc_media_constraints.h" |
23 #include "content/renderer/media/webrtc_audio_capturer.h" | 24 #include "content/renderer/media/webrtc_audio_capturer.h" |
24 #include "content/renderer/media/webrtc_audio_device_impl.h" | 25 #include "content/renderer/media/webrtc_audio_device_impl.h" |
25 #include "content/renderer/render_thread_impl.h" | 26 #include "content/renderer/render_thread_impl.h" |
26 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 27 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
27 // TODO(hta): Move the following include to WebRTCStatsRequest.h file. | 28 // TODO(hta): Move the following include to WebRTCStatsRequest.h file. |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 bool RTCPeerConnectionHandler::addStream( | 543 bool RTCPeerConnectionHandler::addStream( |
543 const blink::WebMediaStream& stream, | 544 const blink::WebMediaStream& stream, |
544 const blink::WebMediaConstraints& options) { | 545 const blink::WebMediaConstraints& options) { |
545 RTCMediaConstraints constraints(options); | 546 RTCMediaConstraints constraints(options); |
546 | 547 |
547 if (peer_connection_tracker_) | 548 if (peer_connection_tracker_) |
548 peer_connection_tracker_->TrackAddStream( | 549 peer_connection_tracker_->TrackAddStream( |
549 this, stream, PeerConnectionTracker::SOURCE_LOCAL); | 550 this, stream, PeerConnectionTracker::SOURCE_LOCAL); |
550 | 551 |
551 // A media stream is connected to a peer connection, enable the | 552 // A media stream is connected to a peer connection, enable the |
552 // peer connection mode for the capturer. | 553 // peer connection mode for the sources. |
553 WebRtcAudioDeviceImpl* audio_device = | 554 blink::WebVector<blink::WebMediaStreamTrack> audio_tracks; |
554 dependency_factory_->GetWebRtcAudioDevice(); | 555 stream.audioTracks(audio_tracks); |
555 if (audio_device) { | 556 for (size_t i = 0; i < audio_tracks.size(); ++i) { |
556 WebRtcAudioCapturer* capturer = audio_device->GetDefaultCapturer(); | 557 const blink::WebMediaStreamSource& source = audio_tracks[i].source(); |
557 if (capturer) | 558 MediaStreamSourceExtraData* extra_data = |
558 capturer->EnablePeerConnectionMode(); | 559 static_cast<MediaStreamSourceExtraData*>(source.extraData()); |
| 560 // |extra_data| is NULL if the track is a remote audio track. |
| 561 if (extra_data && extra_data->GetAudioCapturer()) |
| 562 extra_data->GetAudioCapturer()->EnablePeerConnectionMode(); |
559 } | 563 } |
560 | 564 |
561 return AddStream(stream, &constraints); | 565 return AddStream(stream, &constraints); |
562 } | 566 } |
563 | 567 |
564 void RTCPeerConnectionHandler::removeStream( | 568 void RTCPeerConnectionHandler::removeStream( |
565 const blink::WebMediaStream& stream) { | 569 const blink::WebMediaStream& stream) { |
566 RemoveStream(stream); | 570 RemoveStream(stream); |
567 if (peer_connection_tracker_) | 571 if (peer_connection_tracker_) |
568 peer_connection_tracker_->TrackRemoveStream( | 572 peer_connection_tracker_->TrackRemoveStream( |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 webrtc::SessionDescriptionInterface* native_desc = | 802 webrtc::SessionDescriptionInterface* native_desc = |
799 dependency_factory_->CreateSessionDescription(type, sdp, error); | 803 dependency_factory_->CreateSessionDescription(type, sdp, error); |
800 | 804 |
801 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 805 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
802 << " Type: " << type << " SDP: " << sdp; | 806 << " Type: " << type << " SDP: " << sdp; |
803 | 807 |
804 return native_desc; | 808 return native_desc; |
805 } | 809 } |
806 | 810 |
807 } // namespace content | 811 } // namespace content |
OLD | NEW |