OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBRTC_AUDIO_SINK_ADAPTER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/public/renderer/media_stream_audio_sink.h" | 12 #include "content/public/renderer/media_stream_audio_sink.h" |
13 #include "media/audio/audio_parameters.h" | 13 #include "media/audio/audio_parameters.h" |
| 14 #include "media/base/audio_push_fifo.h" |
14 | 15 |
15 namespace webrtc { | 16 namespace webrtc { |
16 class AudioTrackSinkInterface; | 17 class AudioTrackSinkInterface; |
17 } // namespace webrtc | 18 } // namespace webrtc |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 // Adapter to the webrtc::AudioTrackSinkInterface of the audio track. | 22 // Adapter to the webrtc::AudioTrackSinkInterface of the audio track. |
22 // This class is used in between the MediaStreamAudioSink and | 23 // This class is used in between the MediaStreamAudioSink and |
23 // webrtc::AudioTrackSinkInterface. It gets data callback via the | 24 // webrtc::AudioTrackSinkInterface. It gets data callback via the |
24 // MediaStreamAudioSink::OnData() interface and pass the data to | 25 // MediaStreamAudioSink::OnData() interface, re-chunks the data into the |
| 26 // required 10ms chunks if needed, and passes the data to WebRTC via the |
25 // webrtc::AudioTrackSinkInterface. | 27 // webrtc::AudioTrackSinkInterface. |
26 class WebRtcAudioSinkAdapter : public MediaStreamAudioSink { | 28 class WebRtcAudioSinkAdapter : public MediaStreamAudioSink { |
27 public: | 29 public: |
28 explicit WebRtcAudioSinkAdapter( | 30 explicit WebRtcAudioSinkAdapter( |
29 webrtc::AudioTrackSinkInterface* sink); | 31 webrtc::AudioTrackSinkInterface* sink); |
30 ~WebRtcAudioSinkAdapter() override; | 32 ~WebRtcAudioSinkAdapter() override; |
31 | 33 |
32 bool IsEqual(const webrtc::AudioTrackSinkInterface* other) const; | 34 bool IsEqual(const webrtc::AudioTrackSinkInterface* other) const; |
33 | 35 |
34 private: | 36 private: |
35 // MediaStreamAudioSink implementation. | 37 // MediaStreamAudioSink implementation. |
36 void OnData(const media::AudioBus& audio_bus, | 38 void OnData(const media::AudioBus& audio_bus, |
37 base::TimeTicks estimated_capture_time) override; | 39 base::TimeTicks estimated_capture_time) override; |
38 void OnSetFormat(const media::AudioParameters& params) override; | 40 void OnSetFormat(const media::AudioParameters& params) override; |
39 | 41 |
| 42 // Called by AudioPushFifo zero or more times during the call to OnData(). |
| 43 // Delivers audio data with the required 10ms buffer size to |sink_|. |
| 44 void DeliverRebufferedAudio(const media::AudioBus& audio_bus, |
| 45 int frame_delay); |
| 46 |
40 webrtc::AudioTrackSinkInterface* const sink_; | 47 webrtc::AudioTrackSinkInterface* const sink_; |
41 | 48 media::AudioPushFifo fifo_; |
42 media::AudioParameters params_; | 49 media::AudioParameters params_; |
43 scoped_ptr<int16_t[]> interleaved_data_; | 50 scoped_ptr<int16_t[]> interleaved_data_; |
44 | 51 |
45 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioSinkAdapter); | 52 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioSinkAdapter); |
46 }; | 53 }; |
47 | 54 |
48 } // namespace content | 55 } // namespace content |
49 | 56 |
50 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ | 57 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_AUDIO_SINK_ADAPTER_H_ |
OLD | NEW |