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

Side by Side Diff: content/renderer/media/audio_track_recorder.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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/audio_track_recorder.h" 5 #include "content/renderer/media/audio_track_recorder.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "content/renderer/media/media_stream_audio_track.h"
13 #include "media/audio/audio_parameters.h" 14 #include "media/audio/audio_parameters.h"
14 #include "media/base/audio_bus.h" 15 #include "media/base/audio_bus.h"
15 #include "media/base/audio_converter.h" 16 #include "media/base/audio_converter.h"
16 #include "media/base/audio_fifo.h" 17 #include "media/base/audio_fifo.h"
17 #include "media/base/bind_to_current_loop.h" 18 #include "media/base/bind_to_current_loop.h"
18 #include "third_party/opus/src/include/opus.h" 19 #include "third_party/opus/src/include/opus.h"
19 20
20 // Note that this code follows the Chrome media convention of defining a "frame" 21 // Note that this code follows the Chrome media convention of defining a "frame"
21 // as "one multi-channel sample" as opposed to another common definition meaning 22 // as "one multi-channel sample" as opposed to another common definition meaning
22 // "a chunk of samples". Here this second definition of "frame" is called a 23 // "a chunk of samples". Here this second definition of "frame" is called a
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 AudioTrackRecorder::AudioTrackRecorder( 288 AudioTrackRecorder::AudioTrackRecorder(
288 const blink::WebMediaStreamTrack& track, 289 const blink::WebMediaStreamTrack& track,
289 const OnEncodedAudioCB& on_encoded_audio_cb, 290 const OnEncodedAudioCB& on_encoded_audio_cb,
290 int32_t bits_per_second) 291 int32_t bits_per_second)
291 : track_(track), 292 : track_(track),
292 encoder_(new AudioEncoder(media::BindToCurrentLoop(on_encoded_audio_cb), 293 encoder_(new AudioEncoder(media::BindToCurrentLoop(on_encoded_audio_cb),
293 bits_per_second)), 294 bits_per_second)),
294 encoder_thread_("AudioEncoderThread") { 295 encoder_thread_("AudioEncoderThread") {
295 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 296 DCHECK(main_render_thread_checker_.CalledOnValidThread());
296 DCHECK(!track_.isNull()); 297 DCHECK(!track_.isNull());
297 DCHECK(track_.extraData()); 298 DCHECK(MediaStreamAudioTrack::Get(track_));
298 299
299 // Start the |encoder_thread_|. From this point on, |encoder_| should work 300 // Start the |encoder_thread_|. From this point on, |encoder_| should work
300 // only on |encoder_thread_|, as enforced by DCHECKs. 301 // only on |encoder_thread_|, as enforced by DCHECKs.
301 DCHECK(!encoder_thread_.IsRunning()); 302 DCHECK(!encoder_thread_.IsRunning());
302 encoder_thread_.Start(); 303 encoder_thread_.Start();
303 304
304 // Connect the source provider to the track as a sink. 305 // Connect the source provider to the track as a sink.
305 MediaStreamAudioSink::AddToAudioTrack(this, track_); 306 MediaStreamAudioSink::AddToAudioTrack(this, track_);
306 } 307 }
307 308
(...skipping 21 matching lines...) Expand all
329 scoped_ptr<media::AudioBus> audio_data = 330 scoped_ptr<media::AudioBus> audio_data =
330 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames()); 331 media::AudioBus::Create(audio_bus.channels(), audio_bus.frames());
331 audio_bus.CopyTo(audio_data.get()); 332 audio_bus.CopyTo(audio_data.get());
332 333
333 encoder_thread_.task_runner()->PostTask( 334 encoder_thread_.task_runner()->PostTask(
334 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_, 335 FROM_HERE, base::Bind(&AudioEncoder::EncodeAudio, encoder_,
335 base::Passed(&audio_data), capture_time)); 336 base::Passed(&audio_data), capture_time));
336 } 337 }
337 338
338 } // namespace content 339 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/media_stream_audio_sink.cc ('k') | content/renderer/media/audio_track_recorder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698