audio_source.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef MEDIA_BASE_AUDIO_SOURCE_H_
  11. #define MEDIA_BASE_AUDIO_SOURCE_H_
  12. #include <cstddef>
  13. #include "absl/types/optional.h"
  14. namespace cricket {
  15. // Abstract interface for providing the audio data.
  16. // TODO(deadbeef): Rename this to AudioSourceInterface, and rename
  17. // webrtc::AudioSourceInterface to AudioTrackSourceInterface.
  18. class AudioSource {
  19. public:
  20. class Sink {
  21. public:
  22. // Callback to receive data from the AudioSource.
  23. virtual void OnData(
  24. const void* audio_data,
  25. int bits_per_sample,
  26. int sample_rate,
  27. size_t number_of_channels,
  28. size_t number_of_frames,
  29. absl::optional<int64_t> absolute_capture_timestamp_ms) = 0;
  30. // Called when the AudioSource is going away.
  31. virtual void OnClose() = 0;
  32. protected:
  33. virtual ~Sink() {}
  34. };
  35. // Sets a sink to the AudioSource. There can be only one sink connected
  36. // to the source at a time.
  37. virtual void SetSink(Sink* sink) = 0;
  38. protected:
  39. virtual ~AudioSource() {}
  40. };
  41. } // namespace cricket
  42. #endif // MEDIA_BASE_AUDIO_SOURCE_H_