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

Side by Side Diff: chrome/renderer/media/cast_receiver_audio_valve.h

Issue 1714593003: Introduce media::AudioPushFifo and a couple of use cases (and clean-ups). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win compile issue. 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 #ifndef CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_ 5 #ifndef CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_
6 #define CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_ 6 #define CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_
7 7
8 #include "base/synchronization/lock.h" 8 #include "base/synchronization/lock.h"
9 #include "media/base/audio_capturer_source.h" 9 #include "media/base/audio_capturer_source.h"
10 #include "media/base/audio_rechunker.h"
10 11
11 namespace media { 12 namespace media {
12 class AudioBus; 13 class AudioBus;
13 } 14 }
14 15
15 // Forwards calls to |cb| until Stop is called. 16 // Forwards calls to |cb| until Stop is called. If the client requested a
17 // different buffer size than that provided by the Cast Receiver, AudioRechunker
18 // is used to rectify that.
19 //
16 // Thread-safe. 20 // Thread-safe.
17 // All functions may block depending on contention. 21 // All functions may block depending on contention.
18 class CastReceiverAudioValve : 22 class CastReceiverAudioValve :
19 public media::AudioCapturerSource::CaptureCallback,
20 public base::RefCountedThreadSafe<CastReceiverAudioValve> { 23 public base::RefCountedThreadSafe<CastReceiverAudioValve> {
21 public: 24 public:
22 explicit CastReceiverAudioValve( 25 CastReceiverAudioValve(const media::AudioParameters& params,
23 media::AudioCapturerSource::CaptureCallback* cb); 26 media::AudioCapturerSource::CaptureCallback* cb);
24 27
25 // AudioCapturerSource::CaptureCallback implementation. 28 // Called on an unknown thread to provide more decoded audio data from the
26 void Capture(const media::AudioBus* audio_source, 29 // Cast Receiver.
27 int audio_delay_milliseconds, 30 void DeliverDecodedAudio(const media::AudioBus* audio_bus,
28 double volume, 31 base::TimeTicks playout_time);
29 bool key_pressed) override;
30 void OnCaptureError(const std::string& message) override;
31 32
32 // When this returns, no more calls will be forwarded to |cb|. 33 // When this returns, no more calls will be forwarded to |cb|.
33 void Stop(); 34 void Stop();
34 35
35 private: 36 private:
36 friend class base::RefCountedThreadSafe<CastReceiverAudioValve>; 37 friend class base::RefCountedThreadSafe<CastReceiverAudioValve>;
37 ~CastReceiverAudioValve() override; 38
39 ~CastReceiverAudioValve();
40
41 // Called by AudioRechunker zero or more times during the call to
42 // Capture(). Delivers audio data in the required buffer size to |cb_|.
43 void DeliverRechunkedAudio(const media::AudioBus& audio_bus,
44 base::TimeDelta timestamp);
45
38 media::AudioCapturerSource::CaptureCallback* cb_; 46 media::AudioCapturerSource::CaptureCallback* cb_;
39 base::Lock lock_; 47 base::Lock lock_;
48
49 media::AudioRechunker rechunker_;
40 }; 50 };
41 51
42 #endif // CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_ 52 #endif // CHROME_RENDERER_MEDIA_CAST_RECEIVER_AUDIO_VALVE_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/media/cast_receiver_audio_valve.cc » ('j') | chrome/renderer/media/cast_receiver_audio_valve.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698