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 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 protected: ~Sink()40 virtual ~Sink() {} 41 }; 42 43 // Sets a sink to the AudioSource. There can be only one sink connected 44 // to the source at a time. 45 virtual void SetSink(Sink* sink) = 0; 46 47 protected: ~AudioSource()48 virtual ~AudioSource() {} 49 }; 50 51 } // namespace cricket 52 53 #endif // MEDIA_BASE_AUDIO_SOURCE_H_ 54