Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1090)

Side by Side Diff: content/renderer/media/external_media_stream_audio_source.cc

Issue 1647773002: MediaStream audio sourcing: Bypass audio processing for non-WebRTC cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOT FOR REVIEW -- This will be broken-up across multiple CLs. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/renderer/media/external_media_stream_audio_source.h"
6
7 namespace content {
8
9 ExternalMediaStreamAudioSource::ExternalMediaStreamAudioSource(
10 const scoped_refptr<media::AudioCapturerSource>& source,
11 int sample_rate,
12 media::ChannelLayout channel_layout,
13 int frames_per_buffer,
14 bool is_remote)
15 : MediaStreamAudioSource(!is_remote),
16 source_(source),
17 is_started_(false) {
18 DVLOG(1) << "ExternalMediaStreamAudioSource::ExternalMediaStreamAudioSource()" ;
19 DCHECK(source_.get());
20 MediaStreamAudioSource::SetFormat(media::AudioParameters(
21 media::AudioParameters::AUDIO_PCM_LOW_LATENCY,
22 channel_layout,
23 sample_rate,
24 16, // Legacy parameter (data is always in 32-bit float format).
25 frames_per_buffer));
26 }
27
28 ExternalMediaStreamAudioSource::~ExternalMediaStreamAudioSource() {
29 DVLOG(1) << "ExternalMediaStreamAudioSource::~ExternalMediaStreamAudioSource() ";
30 // Superclass will call StopSource() just in case.
31 }
32
33 void ExternalMediaStreamAudioSource::DoStopSource() {
34 DCHECK(thread_checker_.CalledOnValidThread());
35 if (is_stopped_)
36 return;
37 if (is_started_) {
38 source_->Stop();
39 VLOG(1) << "Stopped externally-provided "
40 << (is_local_source() ? "local" : "remote")
41 << " source with audio parameters={"
42 << GetAudioParameters().AsHumanReadableString() << "}.";
43 }
44 is_stopped_ = true;
45 }
46
47 bool ExternalMediaStreamAudioSource::EnsureSourceIsStarted() {
48 DCHECK(thread_checker_.CalledOnValidThread());
49 if (is_stopped_)
50 return false;
51 if (is_started_)
52 return true;
53 VLOG(1) << "Starting externally-provided "
54 << (is_local_source() ? "local" : "remote")
55 << " source with audio parameters={"
56 << GetAudioParameters().AsHumanReadableString() << "}.";
57 source_->Initialize(GetAudioParameters(), this, -1);
58 source_->Start();
59 is_started_ = true;
60 return true;
61 }
62
63 void ExternalMediaStreamAudioSource::Capture(const media::AudioBus* audio_bus,
64 int audio_delay_milliseconds,
65 double volume,
66 bool key_pressed) {
67 DCHECK(audio_bus);
68 // TODO(miu): Plumbing is needed to determine the actual capture timestamp
69 // of the audio, instead of just snapshotting TimeTicks::Now(), for proper
70 // audio/video sync. http://crbug.com/335335
71 MediaStreamAudioSource::DeliverDataToTracks(
72 *audio_bus,
73 base::TimeTicks::Now() -
74 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds));
75 }
76
77 void ExternalMediaStreamAudioSource::OnCaptureError(const std::string& why) {
78 // As of this writing, this method doesn't get called for anything useful,
79 // and all other implementors just log the message, but don't disconnect sinks
80 // or take any other action. So, just log the error.
81 LOG(ERROR) << why;
82 }
83
84 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/external_media_stream_audio_source.h ('k') | content/renderer/media/local_media_stream_audio_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698