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

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

Issue 2626533002: Revert of Fix getUserMedia so that failure is reported for invalid audio sources. (Closed)
Patch Set: Created 3 years, 11 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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/local_media_stream_audio_source.h" 5 #include "content/renderer/media/local_media_stream_audio_source.h"
6 6
7 #include "content/common/media/media_stream_options.h" 7 #include "content/common/media/media_stream_options.h"
8 #include "content/renderer/media/audio_device_factory.h" 8 #include "content/renderer/media/audio_device_factory.h"
9 #include "content/renderer/render_frame_impl.h" 9 #include "content/renderer/render_frame_impl.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 LocalMediaStreamAudioSource::LocalMediaStreamAudioSource( 13 LocalMediaStreamAudioSource::LocalMediaStreamAudioSource(
14 int consumer_render_frame_id, 14 int consumer_render_frame_id,
15 const StreamDeviceInfo& device_info, 15 const StreamDeviceInfo& device_info)
16 const ConstraintsCallback& started_callback)
17 : MediaStreamAudioSource(true /* is_local_source */), 16 : MediaStreamAudioSource(true /* is_local_source */),
18 consumer_render_frame_id_(consumer_render_frame_id), 17 consumer_render_frame_id_(consumer_render_frame_id) {
19 started_callback_(started_callback) {
20 DVLOG(1) << "LocalMediaStreamAudioSource::LocalMediaStreamAudioSource()"; 18 DVLOG(1) << "LocalMediaStreamAudioSource::LocalMediaStreamAudioSource()";
21 MediaStreamSource::SetDeviceInfo(device_info); 19 MediaStreamSource::SetDeviceInfo(device_info);
22 20
23 // If the device buffer size was not provided, use a default. 21 // If the device buffer size was not provided, use a default.
24 int frames_per_buffer = device_info.device.input.frames_per_buffer; 22 int frames_per_buffer = device_info.device.input.frames_per_buffer;
25 if (frames_per_buffer <= 0) { 23 if (frames_per_buffer <= 0) {
26 // TODO(miu): Like in ProcessedLocalAudioSource::GetBufferSize(), we should 24 // TODO(miu): Like in ProcessedLocalAudioSource::GetBufferSize(), we should
27 // re-evaluate whether Android needs special treatment here. Or, perhaps we 25 // re-evaluate whether Android needs special treatment here. Or, perhaps we
28 // should just DCHECK_GT(device_info...frames_per_buffer, 0)? 26 // should just DCHECK_GT(device_info...frames_per_buffer, 0)?
29 // http://crbug.com/638081 27 // http://crbug.com/638081
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 77
80 source_->Stop(); 78 source_->Stop();
81 source_ = nullptr; 79 source_ = nullptr;
82 80
83 VLOG(1) << "Stopped local audio input device (session_id=" 81 VLOG(1) << "Stopped local audio input device (session_id="
84 << device_info().session_id << ") for render frame " 82 << device_info().session_id << ") for render frame "
85 << consumer_render_frame_id_ << " with audio parameters={" 83 << consumer_render_frame_id_ << " with audio parameters={"
86 << GetAudioParameters().AsHumanReadableString() << "}."; 84 << GetAudioParameters().AsHumanReadableString() << "}.";
87 } 85 }
88 86
89 void LocalMediaStreamAudioSource::OnCaptureStarted() {
90 started_callback_.Run(this, MEDIA_DEVICE_OK, "");
91 }
92
93 void LocalMediaStreamAudioSource::Capture(const media::AudioBus* audio_bus, 87 void LocalMediaStreamAudioSource::Capture(const media::AudioBus* audio_bus,
94 int audio_delay_milliseconds, 88 int audio_delay_milliseconds,
95 double volume, 89 double volume,
96 bool key_pressed) { 90 bool key_pressed) {
97 DCHECK(audio_bus); 91 DCHECK(audio_bus);
98 // TODO(miu): Plumbing is needed to determine the actual capture timestamp 92 // TODO(miu): Plumbing is needed to determine the actual capture timestamp
99 // of the audio, instead of just snapshotting TimeTicks::Now(), for proper 93 // of the audio, instead of just snapshotting TimeTicks::Now(), for proper
100 // audio/video sync. http://crbug.com/335335 94 // audio/video sync. http://crbug.com/335335
101 MediaStreamAudioSource::DeliverDataToTracks( 95 MediaStreamAudioSource::DeliverDataToTracks(
102 *audio_bus, 96 *audio_bus,
103 base::TimeTicks::Now() - 97 base::TimeTicks::Now() -
104 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds)); 98 base::TimeDelta::FromMilliseconds(audio_delay_milliseconds));
105 } 99 }
106 100
107 void LocalMediaStreamAudioSource::OnCaptureError(const std::string& why) { 101 void LocalMediaStreamAudioSource::OnCaptureError(const std::string& why) {
108 StopSourceOnError(why); 102 StopSourceOnError(why);
109 } 103 }
110 104
111 } // namespace content 105 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698