| 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 if (extra_data->GetAudioCapturer()) |
| 561 extra_data->GetAudioCapturer()->EnablePeerConnectionMode(); |
| 559 } | 562 } |
| 560 | 563 |
| 561 return AddStream(stream, &constraints); | 564 return AddStream(stream, &constraints); |
| 562 } | 565 } |
| 563 | 566 |
| 564 void RTCPeerConnectionHandler::removeStream( | 567 void RTCPeerConnectionHandler::removeStream( |
| 565 const blink::WebMediaStream& stream) { | 568 const blink::WebMediaStream& stream) { |
| 566 RemoveStream(stream); | 569 RemoveStream(stream); |
| 567 if (peer_connection_tracker_) | 570 if (peer_connection_tracker_) |
| 568 peer_connection_tracker_->TrackRemoveStream( | 571 peer_connection_tracker_->TrackRemoveStream( |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 webrtc::SessionDescriptionInterface* native_desc = | 801 webrtc::SessionDescriptionInterface* native_desc = |
| 799 dependency_factory_->CreateSessionDescription(type, sdp, error); | 802 dependency_factory_->CreateSessionDescription(type, sdp, error); |
| 800 | 803 |
| 801 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 804 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
| 802 << " Type: " << type << " SDP: " << sdp; | 805 << " Type: " << type << " SDP: " << sdp; |
| 803 | 806 |
| 804 return native_desc; | 807 return native_desc; |
| 805 } | 808 } |
| 806 | 809 |
| 807 } // namespace content | 810 } // namespace content |
| OLD | NEW |