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/webrtc_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
| 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" |
| 11 #include "base/location.h" |
9 #include "base/logging.h" | 12 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
11 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
13 #include "build/build_config.h" | 16 #include "build/build_config.h" |
14 #include "content/renderer/media/audio_device_factory.h" | 17 #include "content/renderer/media/audio_device_factory.h" |
15 #include "content/renderer/media/media_stream_audio_track.h" | 18 #include "content/renderer/media/media_stream_audio_track.h" |
16 #include "content/renderer/media/media_stream_dispatcher.h" | 19 #include "content/renderer/media/webrtc/peer_connection_remote_audio_source.h" |
17 #include "content/renderer/media/media_stream_track.h" | |
18 #include "content/renderer/media/webrtc_audio_device_impl.h" | |
19 #include "content/renderer/media/webrtc_logging.h" | 20 #include "content/renderer/media/webrtc_logging.h" |
20 #include "content/renderer/render_frame_impl.h" | |
21 #include "media/audio/sample_rates.h" | 21 #include "media/audio/sample_rates.h" |
22 #include "media/base/audio_capturer_source.h" | 22 #include "media/base/audio_capturer_source.h" |
23 #include "media/base/audio_parameters.h" | 23 #include "media/base/audio_parameters.h" |
24 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 24 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
25 #include "third_party/webrtc/api/mediastreaminterface.h" | 25 #include "third_party/webrtc/api/mediastreaminterface.h" |
26 #include "third_party/webrtc/media/base/audiorenderer.h" | 26 #include "third_party/webrtc/media/base/audiorenderer.h" |
27 | 27 |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "media/audio/win/core_audio_util_win.h" | 30 #include "media/audio/win/core_audio_util_win.h" |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 } | 588 } |
589 | 589 |
590 void WebRtcAudioRenderer::OnPlayStateChanged( | 590 void WebRtcAudioRenderer::OnPlayStateChanged( |
591 const blink::WebMediaStream& media_stream, | 591 const blink::WebMediaStream& media_stream, |
592 PlayingState* state) { | 592 PlayingState* state) { |
593 DCHECK(thread_checker_.CalledOnValidThread()); | 593 DCHECK(thread_checker_.CalledOnValidThread()); |
594 blink::WebVector<blink::WebMediaStreamTrack> web_tracks; | 594 blink::WebVector<blink::WebMediaStreamTrack> web_tracks; |
595 media_stream.audioTracks(web_tracks); | 595 media_stream.audioTracks(web_tracks); |
596 | 596 |
597 for (const blink::WebMediaStreamTrack& web_track : web_tracks) { | 597 for (const blink::WebMediaStreamTrack& web_track : web_tracks) { |
598 MediaStreamAudioTrack* track = MediaStreamAudioTrack::From(web_track); | |
599 // WebRtcAudioRenderer can only render audio tracks received from a remote | 598 // WebRtcAudioRenderer can only render audio tracks received from a remote |
600 // peer. Since the actual MediaStream is mutable from JavaScript, we need | 599 // peer. Since the actual MediaStream is mutable from JavaScript, we need |
601 // to make sure |web_track| is actually a remote track. | 600 // to make sure |web_track| is actually a remote track. |
602 if (track->is_local_track()) | 601 PeerConnectionRemoteAudioTrack* const remote_track = |
| 602 PeerConnectionRemoteAudioTrack::From( |
| 603 MediaStreamAudioTrack::From(web_track)); |
| 604 if (!remote_track) |
603 continue; | 605 continue; |
604 webrtc::AudioSourceInterface* source = | 606 webrtc::AudioSourceInterface* source = |
605 track->GetAudioAdapter()->GetSource(); | 607 remote_track->track_interface()->GetSource(); |
606 DCHECK(source); | 608 DCHECK(source); |
607 if (!state->playing()) { | 609 if (!state->playing()) { |
608 if (RemovePlayingState(source, state)) | 610 if (RemovePlayingState(source, state)) |
609 EnterPauseState(); | 611 EnterPauseState(); |
610 } else if (AddPlayingState(source, state)) { | 612 } else if (AddPlayingState(source, state)) { |
611 EnterPlayState(); | 613 EnterPlayState(); |
612 } | 614 } |
613 UpdateSourceVolume(source); | 615 UpdateSourceVolume(source); |
614 } | 616 } |
615 } | 617 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 base::Bind(&WebRtcAudioRenderer::SourceCallback, | 678 base::Bind(&WebRtcAudioRenderer::SourceCallback, |
677 base::Unretained(this)))); | 679 base::Unretained(this)))); |
678 } | 680 } |
679 sink_params_ = new_sink_params; | 681 sink_params_ = new_sink_params; |
680 } | 682 } |
681 | 683 |
682 sink_->Initialize(new_sink_params, this); | 684 sink_->Initialize(new_sink_params, this); |
683 } | 685 } |
684 | 686 |
685 } // namespace content | 687 } // namespace content |
OLD | NEW |