diff --git a/src/debug_video_tap.cpp b/src/debug_video_tap.cpp index 85b0a71a..87ba861e 100644 --- a/src/debug_video_tap.cpp +++ b/src/debug_video_tap.cpp @@ -10,6 +10,8 @@ #include "./frame_streams/sdl/video.hpp" #include "./frame_streams/frame_stream2.hpp" +#include "./frame_streams/locked_frame_stream.hpp" +#include "./frame_streams/sdl/video_push_converter.hpp" #include #include @@ -27,40 +29,6 @@ namespace Message { uint64_t getTimeMS(void); } -// threadsafe queue frame stream -// protected by a simple mutex lock -template -struct LockedFrameStream2 : public FrameStream2I { - std::mutex _lock; - - std::deque _frames; - - ~LockedFrameStream2(void) {} - - int32_t size(void) { return -1; } - - std::optional pop(void) { - std::lock_guard lg{_lock}; - - if (_frames.empty()) { - return std::nullopt; - } - - FrameType new_frame = std::move(_frames.front()); - _frames.pop_front(); - - return std::move(new_frame); - } - - bool push(const FrameType& value) { - std::lock_guard lg{_lock}; - - _frames.push_back(value); - - return true; - } -}; - struct DebugVideoTapSink : public FrameStream2SinkI { TextureUploaderI& _tu; @@ -80,7 +48,7 @@ struct DebugVideoTapSink : public FrameStream2SinkI { float _v_interval_avg {0.f}; // s } view; - std::shared_ptr> stream; + std::shared_ptr>> stream; }; std::vector _writers; @@ -91,7 +59,7 @@ struct DebugVideoTapSink : public FrameStream2SinkI { std::shared_ptr> subscribe(void) override { _writers.emplace_back(Writer{ Writer::View{_id_counter++}, - std::make_shared>() + std::make_shared>>(SDL_PIXELFORMAT_RGBA32) }); return _writers.back().stream; @@ -127,7 +95,7 @@ struct DebugVideoTestSource : public FrameStream2SourceI { _thread = std::thread([this](void) { while (!_stop) { if (!_readers.empty()) { - auto* surf = SDL_CreateSurface(960, 720, SDL_PIXELFORMAT_ARGB32); + auto* surf = SDL_CreateSurface(960, 720, SDL_PIXELFORMAT_RGBA32); // color static auto start_time = Message::getTimeMS(); diff --git a/src/frame_streams/sdl/sdl_video_frame_stream2.hpp b/src/frame_streams/sdl/sdl_video_frame_stream2.hpp index 5c92795b..b94c7c6e 100644 --- a/src/frame_streams/sdl/sdl_video_frame_stream2.hpp +++ b/src/frame_streams/sdl/sdl_video_frame_stream2.hpp @@ -7,6 +7,11 @@ #include #include +// tips: you can force a SDL vido driver by setting an env: +// SDL_CAMERA_DRIVER=v4l2 +// SDL_CAMERA_DRIVER=pipewire +// etc. + // while a stream is subscribed, have the camera device open // and aquire and push frames from a thread struct SDLVideo2InputDevice : public FrameStream2MultiSource {