audio_track.h 1.7 KB

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