| 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/audio_parameters.h" | 21 #include "media/audio/audio_parameters.h" |
| 22 #include "media/audio/sample_rates.h" | 22 #include "media/audio/sample_rates.h" |
| 23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 23 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
| 24 #include "third_party/webrtc/api/mediastreaminterface.h" | 24 #include "third_party/webrtc/api/mediastreaminterface.h" |
| 25 #include "third_party/webrtc/media/base/audiorenderer.h" | 25 #include "third_party/webrtc/media/base/audiorenderer.h" |
| 26 | 26 |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 #include "base/win/windows_version.h" | 28 #include "base/win/windows_version.h" |
| 29 #include "media/audio/win/core_audio_util_win.h" | 29 #include "media/audio/win/core_audio_util_win.h" |
| 30 #endif | 30 #endif |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 } | 594 } |
| 595 | 595 |
| 596 void WebRtcAudioRenderer::OnPlayStateChanged( | 596 void WebRtcAudioRenderer::OnPlayStateChanged( |
| 597 const blink::WebMediaStream& media_stream, | 597 const blink::WebMediaStream& media_stream, |
| 598 PlayingState* state) { | 598 PlayingState* state) { |
| 599 DCHECK(thread_checker_.CalledOnValidThread()); | 599 DCHECK(thread_checker_.CalledOnValidThread()); |
| 600 blink::WebVector<blink::WebMediaStreamTrack> web_tracks; | 600 blink::WebVector<blink::WebMediaStreamTrack> web_tracks; |
| 601 media_stream.audioTracks(web_tracks); | 601 media_stream.audioTracks(web_tracks); |
| 602 | 602 |
| 603 for (const blink::WebMediaStreamTrack& web_track : web_tracks) { | 603 for (const blink::WebMediaStreamTrack& web_track : web_tracks) { |
| 604 MediaStreamAudioTrack* track = MediaStreamAudioTrack::From(web_track); | |
| 605 // WebRtcAudioRenderer can only render audio tracks received from a remote | 604 // WebRtcAudioRenderer can only render audio tracks received from a remote |
| 606 // peer. Since the actual MediaStream is mutable from JavaScript, we need | 605 // peer. Since the actual MediaStream is mutable from JavaScript, we need |
| 607 // to make sure |web_track| is actually a remote track. | 606 // to make sure |web_track| is actually a remote track. |
| 608 if (track->is_local_track()) | 607 PeerConnectionRemoteAudioTrack* const remote_track = |
| 608 PeerConnectionRemoteAudioTrack::From( |
| 609 MediaStreamAudioTrack::From(web_track)); |
| 610 if (!remote_track) |
| 609 continue; | 611 continue; |
| 610 webrtc::AudioSourceInterface* source = | 612 webrtc::AudioSourceInterface* source = |
| 611 track->GetAudioAdapter()->GetSource(); | 613 remote_track->track_interface()->GetSource(); |
| 612 DCHECK(source); | 614 DCHECK(source); |
| 613 if (!state->playing()) { | 615 if (!state->playing()) { |
| 614 if (RemovePlayingState(source, state)) | 616 if (RemovePlayingState(source, state)) |
| 615 EnterPauseState(); | 617 EnterPauseState(); |
| 616 } else if (AddPlayingState(source, state)) { | 618 } else if (AddPlayingState(source, state)) { |
| 617 EnterPlayState(); | 619 EnterPlayState(); |
| 618 } | 620 } |
| 619 UpdateSourceVolume(source); | 621 UpdateSourceVolume(source); |
| 620 } | 622 } |
| 621 } | 623 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 base::Bind(&WebRtcAudioRenderer::SourceCallback, | 682 base::Bind(&WebRtcAudioRenderer::SourceCallback, |
| 681 base::Unretained(this)))); | 683 base::Unretained(this)))); |
| 682 } | 684 } |
| 683 sink_params_ = new_sink_params; | 685 sink_params_ = new_sink_params; |
| 684 } | 686 } |
| 685 | 687 |
| 686 sink_->Initialize(new_sink_params, this); | 688 sink_->Initialize(new_sink_params, this); |
| 687 } | 689 } |
| 688 | 690 |
| 689 } // namespace content | 691 } // namespace content |
| OLD | NEW |