| 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 |
| 11 | #ifndef MEDIA_BASE_AUDIO_SOURCE_H_ |
| 12 | #define MEDIA_BASE_AUDIO_SOURCE_H_ |
| 13 |
| 14 | #include <cstddef> |
| 15 |
| 16 | #include "absl/types/optional.h" |
| 17 |
| 18 | namespace cricket { |
| 19 |
| 20 | // Abstract interface for providing the audio data. |
| 21 | // TODO(deadbeef): Rename this to AudioSourceInterface, and rename |
| 22 | // webrtc::AudioSourceInterface to AudioTrackSourceInterface. |
| 23 | class AudioSource { |
| 24 | public: |
| 25 | class Sink { |
| 26 | public: |
| 27 | // Callback to receive data from the AudioSource. |
| 28 | virtual void OnData( |
| 29 | const void* audio_data, |
| 30 | int bits_per_sample, |
| 31 | int sample_rate, |
| 32 | size_t number_of_channels, |
| 33 | size_t number_of_frames, |
| 34 | absl::optional<int64_t> absolute_capture_timestamp_ms) = 0; |
| 35 |
| 36 | // Called when the AudioSource is going away. |
| 37 | virtual void OnClose() = 0; |
| 38 |
| 39 | // Returns the number of channels encoded by the sink. This can be less than |
| 40 | // the number_of_channels if down-mixing occur. A value of -1 means an |
| 41 | // unknown number. |
| 42 | virtual int NumPreferredChannels() const = 0; |
| 43 |
| 44 | protected: |
| 45 | virtual ~Sink() {} |
| 46 | }; |
| 47 |
| 48 | // Sets a sink to the AudioSource. There can be only one sink connected |
| 49 | // to the source at a time. |
| 50 | virtual void SetSink(Sink* sink) = 0; |
| 51 |
| 52 | protected: |
| 53 | virtual ~AudioSource() {} |
| 54 | }; |
| 55 |
| 56 | } // namespace cricket |
| 57 |
| 58 | #endif // MEDIA_BASE_AUDIO_SOURCE_H_ |
| 59 |