blob: 50ce7a109a6e429ccba2a577b521b892b23a8280 [file] [log] [blame]
Tommif888bb52015-12-12 01:37:01 +01001/*
2 * Copyright (c) 2015 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 WEBRTC_AUDIO_AUDIO_SINK_H_
12#define WEBRTC_AUDIO_AUDIO_SINK_H_
13
14#if defined(WEBRTC_POSIX) && !defined(__STDC_FORMAT_MACROS)
15// Avoid conflict with format_macros.h.
16#define __STDC_FORMAT_MACROS
17#endif
18
19#include <inttypes.h>
20#include <stddef.h>
21
deadbeefe591f932016-01-12 16:44:59 -080022#include "webrtc/base/refcount.h"
23
Tommif888bb52015-12-12 01:37:01 +010024namespace webrtc {
25
26// Represents a simple push audio sink.
deadbeefe591f932016-01-12 16:44:59 -080027class AudioSinkInterface : public rtc::RefCountInterface {
Tommif888bb52015-12-12 01:37:01 +010028 public:
29 virtual ~AudioSinkInterface() {}
30
31 struct Data {
32 Data(int16_t* data,
33 size_t samples_per_channel,
34 int sample_rate,
Peter Kasting69558702016-01-12 16:26:35 -080035 size_t channels,
Tommif888bb52015-12-12 01:37:01 +010036 uint32_t timestamp)
37 : data(data),
38 samples_per_channel(samples_per_channel),
39 sample_rate(sample_rate),
40 channels(channels),
41 timestamp(timestamp) {}
42
43 int16_t* data; // The actual 16bit audio data.
44 size_t samples_per_channel; // Number of frames in the buffer.
45 int sample_rate; // Sample rate in Hz.
Peter Kasting69558702016-01-12 16:26:35 -080046 size_t channels; // Number of channels in the audio data.
Tommif888bb52015-12-12 01:37:01 +010047 uint32_t timestamp; // The RTP timestamp of the first sample.
48 };
49
50 virtual void OnData(const Data& audio) = 0;
51};
52
53} // namespace webrtc
54
55#endif // WEBRTC_AUDIO_AUDIO_SINK_H_