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

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

Issue 1721273002: MediaStream audio object graph untangling and clean-ups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed mcasas's 1st round comments, plus REBASE. 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>
10 #include <string> 11 #include <string>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
14 #include "base/files/file.h" 15 #include "base/files/file.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
19 #include "base/threading/thread_checker.h" 20 #include "base/threading/thread_checker.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 int32_t PlayoutDelay(uint16_t* delay_ms) const override; 300 int32_t PlayoutDelay(uint16_t* delay_ms) const override;
300 int32_t RecordingDelay(uint16_t* delay_ms) const override; 301 int32_t RecordingDelay(uint16_t* delay_ms) const override;
301 int32_t RecordingSampleRate(uint32_t* sample_rate) const override; 302 int32_t RecordingSampleRate(uint32_t* sample_rate) const override;
302 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override; 303 int32_t PlayoutSampleRate(uint32_t* sample_rate) const override;
303 304
304 public: 305 public:
305 // Sets the |renderer_|, returns false if |renderer_| already exists. 306 // Sets the |renderer_|, returns false if |renderer_| already exists.
306 // Called on the main renderer thread. 307 // Called on the main renderer thread.
307 bool SetAudioRenderer(WebRtcAudioRenderer* renderer); 308 bool SetAudioRenderer(WebRtcAudioRenderer* renderer);
308 309
309 // Adds/Removes the capturer to the ADM. 310 // Adds/Removes the |capturer| to the ADM. Does NOT take ownership.
311 // Capturers must remain valid until RemoveAudioCapturer() is called.
o1ka 2016/02/29 14:28:04 How will we prevent bugs cause by violation of thi
miu 2016/03/01 09:43:55 The risk of that is non-existent here because the
o1ka 2016/03/01 14:18:59 Thanks a lot for the detailed reply - it answers e
310 // TODO(xians): Remove these two methods once the ADM does not need to pass 312 // TODO(xians): Remove these two methods once the ADM does not need to pass
311 // hardware information up to WebRtc. 313 // hardware information up to WebRtc.
312 void AddAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); 314 void AddAudioCapturer(WebRtcAudioCapturer* capturer);
313 void RemoveAudioCapturer(const scoped_refptr<WebRtcAudioCapturer>& capturer); 315 void RemoveAudioCapturer(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;
318 316
319 // Gets paired device information of the capture device for the audio 317 // Gets paired device information of the capture device for the audio
320 // renderer. This is used to pass on a session id, sample rate and buffer 318 // renderer. This is used to pass on a session id, sample rate and buffer
321 // size to a webrtc audio renderer (either local or remote), so that audio 319 // size to a webrtc audio renderer (either local or remote), so that audio
322 // will be rendered to a matching output device. 320 // will be rendered to a matching output device.
323 // Returns true if the capture device has a paired output device, otherwise 321 // Returns true if the capture device has a paired output device, otherwise
324 // false. Note that if there are more than one open capture device the 322 // false. Note that if there are more than one open capture device the
325 // function will not be able to pick an appropriate device and return false. 323 // function will not be able to pick an appropriate device and return false.
326 bool GetAuthorizedDeviceInfoForAudioRenderer( 324 bool GetAuthorizedDeviceInfoForAudioRenderer(
327 int* session_id, int* output_sample_rate, int* output_buffer_size); 325 int* session_id, int* output_sample_rate, int* output_buffer_size);
328 326
329 const scoped_refptr<WebRtcAudioRenderer>& renderer() const { 327 const scoped_refptr<WebRtcAudioRenderer>& renderer() const {
330 return renderer_; 328 return renderer_;
331 } 329 }
332 330
333 private: 331 private:
334 typedef std::list<scoped_refptr<WebRtcAudioCapturer> > CapturerList; 332 typedef std::list<WebRtcAudioCapturer*> CapturerList;
335 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList; 333 typedef std::list<WebRtcPlayoutDataSource::Sink*> PlayoutDataSinkList;
336 class RenderBuffer; 334 class RenderBuffer;
337 335
338 // Make destructor private to ensure that we can only be deleted by Release(). 336 // Make destructor private to ensure that we can only be deleted by Release().
339 ~WebRtcAudioDeviceImpl() override; 337 ~WebRtcAudioDeviceImpl() override;
340 338
341 // WebRtcAudioRendererSource implementation. 339 // WebRtcAudioRendererSource implementation.
342 340
343 // Called on the AudioOutputDevice worker thread. 341 // Called on the AudioOutputDevice worker thread.
344 void RenderData(media::AudioBus* audio_bus, 342 void RenderData(media::AudioBus* audio_bus,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 // Buffer used for temporary storage during render callback. 403 // Buffer used for temporary storage during render callback.
406 // It is only accessed by the audio render thread. 404 // It is only accessed by the audio render thread.
407 std::vector<int16_t> render_buffer_; 405 std::vector<int16_t> render_buffer_;
408 406
409 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl); 407 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioDeviceImpl);
410 }; 408 };
411 409
412 } // namespace content 410 } // namespace content
413 411
414 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_ 412 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_DEVICE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698