video_source_base.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2016 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_VIDEO_SOURCE_BASE_H_
  11. #define MEDIA_BASE_VIDEO_SOURCE_BASE_H_
  12. #include <vector>
  13. #include "api/video/video_frame.h"
  14. #include "api/video/video_sink_interface.h"
  15. #include "api/video/video_source_interface.h"
  16. #include "rtc_base/thread_checker.h"
  17. namespace rtc {
  18. // VideoSourceBase is not thread safe.
  19. class VideoSourceBase : public VideoSourceInterface<webrtc::VideoFrame> {
  20. public:
  21. VideoSourceBase();
  22. ~VideoSourceBase() override;
  23. void AddOrUpdateSink(VideoSinkInterface<webrtc::VideoFrame>* sink,
  24. const VideoSinkWants& wants) override;
  25. void RemoveSink(VideoSinkInterface<webrtc::VideoFrame>* sink) override;
  26. protected:
  27. struct SinkPair {
  28. SinkPair(VideoSinkInterface<webrtc::VideoFrame>* sink, VideoSinkWants wants)
  29. : sink(sink), wants(wants) {}
  30. VideoSinkInterface<webrtc::VideoFrame>* sink;
  31. VideoSinkWants wants;
  32. };
  33. SinkPair* FindSinkPair(const VideoSinkInterface<webrtc::VideoFrame>* sink);
  34. const std::vector<SinkPair>& sink_pairs() const { return sinks_; }
  35. private:
  36. std::vector<SinkPair> sinks_;
  37. };
  38. } // namespace rtc
  39. #endif // MEDIA_BASE_VIDEO_SOURCE_BASE_H_