overlay_video.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. #include <pc/video_track_source.h>
  3. #include <media/base/video_broadcaster.h>
  4. #include "../include/cap_interface.h"
  5. class COverlayVideo:public IOverlayVideo,public rtc::VideoSourceInterface<webrtc::VideoFrame>
  6. {
  7. public:
  8. COverlayVideo();
  9. virtual void OnVideoData(const webrtc::VideoFrame& frame) override;
  10. virtual void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink,
  11. const rtc::VideoSinkWants& wants) override;
  12. virtual void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override;
  13. private:
  14. rtc::VideoBroadcaster _broadcaster;
  15. };
  16. class COverlayTrackSource :public webrtc::VideoTrackSource
  17. {
  18. public:
  19. static rtc::scoped_refptr<COverlayTrackSource> Create(std::unique_ptr<COverlayVideo> capturer) {
  20. return new rtc::RefCountedObject<COverlayTrackSource>(std::move(capturer));
  21. }
  22. protected:
  23. explicit COverlayTrackSource(std::unique_ptr<COverlayVideo> capturer)
  24. : VideoTrackSource(false),
  25. capturer_(std::move(capturer)) {}
  26. ~COverlayTrackSource()
  27. {
  28. //capturer_->Stop();
  29. }
  30. private:
  31. rtc::VideoSourceInterface<webrtc::VideoFrame>* source() override {
  32. return capturer_.get();
  33. }
  34. std::unique_ptr<COverlayVideo> capturer_;
  35. };
  36. rtc::scoped_refptr<webrtc::VideoTrackSourceInterface> OpenOverlayVideoTrack(IOverlayVideo*);
  37. IOverlayVideo* CreateOverlayVideo();