audio_track.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2011 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 PC_AUDIO_TRACK_H_
  11. #define PC_AUDIO_TRACK_H_
  12. #include <string>
  13. #include "api/media_stream_interface.h"
  14. #include "api/scoped_refptr.h"
  15. #include "pc/media_stream_track.h"
  16. #include "rtc_base/thread_checker.h"
  17. namespace webrtc {
  18. class AudioTrack : public MediaStreamTrack<AudioTrackInterface>,
  19. public ObserverInterface {
  20. protected:
  21. // Protected ctor to force use of factory method.
  22. AudioTrack(const std::string& label,
  23. const rtc::scoped_refptr<AudioSourceInterface>& source);
  24. AudioTrack() = delete;
  25. AudioTrack(const AudioTrack&) = delete;
  26. AudioTrack& operator=(const AudioTrack&) = delete;
  27. ~AudioTrack() override;
  28. public:
  29. static rtc::scoped_refptr<AudioTrack> Create(
  30. const std::string& id,
  31. const rtc::scoped_refptr<AudioSourceInterface>& source);
  32. // MediaStreamTrack implementation.
  33. std::string kind() const override;
  34. private:
  35. // AudioTrackInterface implementation.
  36. AudioSourceInterface* GetSource() const override;
  37. void AddSink(AudioTrackSinkInterface* sink) override;
  38. void RemoveSink(AudioTrackSinkInterface* sink) override;
  39. // ObserverInterface implementation.
  40. void OnChanged() override;
  41. private:
  42. const rtc::scoped_refptr<AudioSourceInterface> audio_source_;
  43. rtc::ThreadChecker thread_checker_;
  44. };
  45. } // namespace webrtc
  46. #endif // PC_AUDIO_TRACK_H_