audio_sink.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  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. #ifndef API_CALL_AUDIO_SINK_H_
  11. #define API_CALL_AUDIO_SINK_H_
  12. #if defined(WEBRTC_POSIX) && !defined(__STDC_FORMAT_MACROS)
  13. // Avoid conflict with format_macros.h.
  14. #define __STDC_FORMAT_MACROS
  15. #endif
  16. #include <inttypes.h>
  17. #include <stddef.h>
  18. namespace webrtc {
  19. // Represents a simple push audio sink.
  20. class AudioSinkInterface {
  21. public:
  22. virtual ~AudioSinkInterface() {}
  23. struct Data {
  24. Data(const int16_t* data,
  25. size_t samples_per_channel,
  26. int sample_rate,
  27. size_t channels,
  28. uint32_t timestamp)
  29. : data(data),
  30. samples_per_channel(samples_per_channel),
  31. sample_rate(sample_rate),
  32. channels(channels),
  33. timestamp(timestamp) {}
  34. const int16_t* data; // The actual 16bit audio data.
  35. size_t samples_per_channel; // Number of frames in the buffer.
  36. int sample_rate; // Sample rate in Hz.
  37. size_t channels; // Number of channels in the audio data.
  38. uint32_t timestamp; // The RTP timestamp of the first sample.
  39. };
  40. virtual void OnData(const Data& audio) = 0;
  41. };
  42. } // namespace webrtc
  43. #endif // API_CALL_AUDIO_SINK_H_