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

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.h

Issue 1780653002: Revert of MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list>
11 #include <string> 10 #include <string>
12 #include <vector> 11 #include <vector>
13 12
14 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
15 #include "base/files/file.h" 14 #include "base/files/file.h"
16 #include "base/logging.h" 15 #include "base/logging.h"
17 #include "base/macros.h" 16 #include "base/macros.h"
18 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
20 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 int32_t PlayoutDelay(uint16_t* delay_ms) const override; 299 int32_t PlayoutDelay(uint16_t* delay_ms) const override;
301 int32_t RecordingDelay(uint16_t* delay_ms) const override; 300 int32_t RecordingDelay(uint16_t* delay_ms) const override;
302 int32_t RecordingSampleRate(uint32_t* sample_rate) const override; 301 int32_t RecordingSampleRate(uint32_t* sample_rate) const override;
303 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; 302 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override;
304 303
305 public: 304 public:
306 // Sets the |renderer_|, returns false if |renderer_| already exists. 305 // Sets the |renderer_|, returns false if |renderer_| already exists.
307 // Called on the main renderer thread. 306 // Called on the main renderer thread.
308 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); 307 bool SetAudioRenderer(WebRtcAudioRenderer* renderer);
309 308
310 // Adds/Removes the |capturer| to the ADM. Does NOT take ownership. 309 // Adds/Removes the capturer to the ADM.
311 // Capturers must remain valid until RemoveAudioCapturer() is called.
312 // TODO(xians): Remove these two methods once the ADM does not need to pass 310 // TODO(xians): Remove these two methods once the ADM does not need to pass
313 // hardware information up to WebRtc. 311 // hardware information up to WebRtc.
314 void AddAudioCapturer(WebRtcAudioCapturer* capturer); 312 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer);
315 void RemoveAudioCapturer(WebRtcAudioCapturer* capturer); 313 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer);
314
315 // Gets the default capturer, which is the last capturer in |capturers_|.
316 // The method can be called by both Libjingle thread and main render thread.
317 scoped_refptr<WebRtcAudioCapturer> GetDefaultCapturer() const;
316 318
317 // Gets paired device information of the capture device for the audio 319 // Gets paired device information of the capture device for the audio
318 // renderer. This is used to pass on a session id, sample rate and buffer 320 // renderer. This is used to pass on a session id, sample rate and buffer
319 // size to a webrtc audio renderer (either local or remote), so that audio 321 // size to a webrtc audio renderer (either local or remote), so that audio
320 // will be rendered to a matching output device. 322 // will be rendered to a matching output device.
321 // Returns true if the capture device has a paired output device, otherwise 323 // Returns true if the capture device has a paired output device, otherwise
322 // false. Note that if there are more than one open capture device the 324 // false. Note that if there are more than one open capture device the
323 // function will not be able to pick an appropriate device and return false. 325 // function will not be able to pick an appropriate device and return false.
324 bool GetAuthorizedDeviceInfoForAudioRenderer( 326 bool GetAuthorizedDeviceInfoForAudioRenderer(
325 int* session_id, int* output_sample_rate, int* output_buffer_size); 327 int* session_id, int* output_sample_rate, int* output_buffer_size);
326 328
327 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { 329 const scoped_refptr<WebRtcAudioRenderer>& renderer() const {
328 return renderer_; 330 return renderer_;
329 } 331 }
330 332
331 private: 333 private:
332 typedef std::list<WebRtcAudioCapturer*> CapturerList; 334 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList;
333 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; 335 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList;
334 class RenderBuffer; 336 class RenderBuffer;
335 337
336 // Make destructor private to ensure that we can only be deleted by Release(). 338 // Make destructor private to ensure that we can only be deleted by Release().
337 ~WebRtcAudioDeviceImpl() override; 339 ~WebRtcAudioDeviceImpl() override;
338 340
339 // WebRtcAudioRendererSource implementation. 341 // WebRtcAudioRendererSource implementation.
340 342
341 // Called on the AudioOutputDevice worker thread. 343 // Called on the AudioOutputDevice worker thread.
342 void RenderData(media::AudioBus* audio_bus, 344 void RenderData(media::AudioBus* audio_bus,
(...skipping 12 matching lines...) Expand all
355 // Used to check methods that run on the main render thread. 357 // Used to check methods that run on the main render thread.
356 base::ThreadChecker main_thread_checker_; 358 base::ThreadChecker main_thread_checker_;
357 // Used to check methods that are called on libjingle's signaling thread. 359 // Used to check methods that are called on libjingle's signaling thread.
358 base::ThreadChecker signaling_thread_checker_; 360 base::ThreadChecker signaling_thread_checker_;
359 base::ThreadChecker worker_thread_checker_; 361 base::ThreadChecker worker_thread_checker_;
360 base::ThreadChecker audio_renderer_thread_checker_; 362 base::ThreadChecker audio_renderer_thread_checker_;
361 363
362 mutable int ref_count_; 364 mutable int ref_count_;
363 365
364 // List of captures which provides access to the native audio input layer 366 // List of captures which provides access to the native audio input layer
365 // in the browser process. The last capturer in this list is considered the 367 // in the browser process.
366 // "default capturer" by the methods implementing the
367 // webrtc::AudioDeviceModule interface.
368 CapturerList capturers_; 368 CapturerList capturers_;
369 369
370 // Provides access to the audio renderer in the browser process. 370 // Provides access to the audio renderer in the browser process.
371 scoped_refptr<WebRtcAudioRenderer> renderer_; 371 scoped_refptr<WebRtcAudioRenderer> renderer_;
372 372
373 // A list of raw pointer of WebRtcPlayoutDataSource::Sink objects which want 373 // A list of raw pointer of WebRtcPlayoutDataSource::Sink objects which want
374 // to get the playout data, the sink need to call RemovePlayoutSink() 374 // to get the playout data, the sink need to call RemovePlayoutSink()
375 // before it goes away. 375 // before it goes away.
376 PlayoutDataSinkList playout_sinks_; 376 PlayoutDataSinkList playout_sinks_;
377 377
(...skipping 27 matching lines...) Expand all
405 // Buffer used for temporary storage during render callback. 405 // Buffer used for temporary storage during render callback.
406 // It is only accessed by the audio render thread. 406 // It is only accessed by the audio render thread.
407 std::vector<int16_t> render_buffer_; 407 std::vector<int16_t> render_buffer_;
408 408
409 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); 409 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl);
410 }; 410 };
411 411
412 } // namespace content 412 } // namespace content
413 413
414 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 414 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_capturer_unittest.cc ('k') | content/renderer/media/webrtc_audio_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698