blob: 199b614850b59038c08832e23b671e3ce21d38f3 [file] [log] [blame]
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MEDIA_BASE_AUDIOSOURCE_H_
12#define MEDIA_BASE_AUDIOSOURCE_H_
Taylor Brandstetter1a018dc2016-03-08 12:37:39 -080013
14#include <cstddef>
15
16namespace cricket {
17
18// Abstract interface for providing the audio data.
19// TODO(deadbeef): Rename this to AudioSourceInterface, and rename
20// webrtc::AudioSourceInterface to AudioTrackSourceInterface.
21class 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 Bonadei92ea95e2017-09-15 06:47:31 +020049#endif // MEDIA_BASE_AUDIOSOURCE_H_