video_track.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2012 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_VIDEO_TRACK_H_
  11. #define PC_VIDEO_TRACK_H_
  12. #include <string>
  13. #include "api/media_stream_interface.h"
  14. #include "api/scoped_refptr.h"
  15. #include "api/video/video_frame.h"
  16. #include "api/video/video_sink_interface.h"
  17. #include "api/video/video_source_interface.h"
  18. #include "media/base/video_source_base.h"
  19. #include "pc/media_stream_track.h"
  20. #include "rtc_base/thread.h"
  21. #include "rtc_base/thread_annotations.h"
  22. #include "rtc_base/thread_checker.h"
  23. namespace webrtc {
  24. class VideoTrack : public MediaStreamTrack<VideoTrackInterface>,
  25. public rtc::VideoSourceBase,
  26. public ObserverInterface {
  27. public:
  28. static rtc::scoped_refptr<VideoTrack> Create(
  29. const std::string& label,
  30. VideoTrackSourceInterface* source,
  31. rtc::Thread* worker_thread);
  32. void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
  33. const rtc::VideoSinkWants& wants) override;
  34. void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override;
  35. VideoTrackSourceInterface* GetSource() const override {
  36. return video_source_.get();
  37. }
  38. ContentHint content_hint() const override;
  39. void set_content_hint(ContentHint hint) override;
  40. bool set_enabled(bool enable) override;
  41. std::string kind() const override;
  42. protected:
  43. VideoTrack(const std::string& id,
  44. VideoTrackSourceInterface* video_source,
  45. rtc::Thread* worker_thread);
  46. ~VideoTrack();
  47. private:
  48. // Implements ObserverInterface. Observes |video_source_| state.
  49. void OnChanged() override;
  50. rtc::Thread* const worker_thread_;
  51. rtc::ThreadChecker signaling_thread_checker_;
  52. rtc::scoped_refptr<VideoTrackSourceInterface> video_source_;
  53. ContentHint content_hint_ RTC_GUARDED_BY(signaling_thread_checker_);
  54. };
  55. } // namespace webrtc
  56. #endif // PC_VIDEO_TRACK_H_