Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_AUDIOSOURCE_H_ |
| 12 | #define MEDIA_BASE_AUDIOSOURCE_H_ |
Taylor Brandstetter | 1a018dc | 2016-03-08 12:37:39 -0800 | [diff] [blame] | 13 | |
| 14 | #include <cstddef> |
| 15 | |
| 16 | namespace cricket { |
| 17 | |
| 18 | // Abstract interface for providing the audio data. |
| 19 | // TODO(deadbeef): Rename this to AudioSourceInterface, and rename |
| 20 | // webrtc::AudioSourceInterface to AudioTrackSourceInterface. |
| 21 | class AudioSource { |
| 22 | public: |
| 23 | class Sink { |
| 24 | public: |
| 25 | // Callback to receive data from the AudioSource. |
| 26 | virtual void OnData(const void* audio_data, |
| 27 | int bits_per_sample, |
| 28 | int sample_rate, |
| 29 | size_t number_of_channels, |
| 30 | size_t number_of_frames) = 0; |
| 31 | |
| 32 | // Called when the AudioSource is going away. |
| 33 | virtual void OnClose() = 0; |
| 34 | |
| 35 | protected: |
| 36 | virtual ~Sink() {} |
| 37 | }; |
| 38 | |
| 39 | // Sets a sink to the AudioSource. There can be only one sink connected |
| 40 | // to the source at a time. |
| 41 | virtual void SetSink(Sink* sink) = 0; |
| 42 | |
| 43 | protected: |
| 44 | virtual ~AudioSource() {} |
| 45 | }; |
| 46 | |
| 47 | } // namespace cricket |
| 48 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 49 | #endif // MEDIA_BASE_AUDIOSOURCE_H_ |