diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e63921e..33013b97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,6 +114,8 @@ target_sources(tomato PUBLIC ./chat_gui/send_image_popup.cpp ./chat_gui/settings_window.hpp ./chat_gui/settings_window.cpp + ./chat_gui/voip_video_display.hpp + ./chat_gui/voip_video_display.cpp ./chat_gui/voip_chat_tab.hpp ./chat_gui/voip_chat_tab.cpp diff --git a/src/chat_gui/voip_video_display.cpp b/src/chat_gui/voip_video_display.cpp new file mode 100644 index 00000000..c8ffddab --- /dev/null +++ b/src/chat_gui/voip_video_display.cpp @@ -0,0 +1,51 @@ +#include "./voip_video_display.hpp" + +#include + +#include + +VoIPVideoDisplay::VoIPVideoDisplay( + ObjectStore2& os, + ContactStore4I& cs, + StreamManager& sm, + TextureUploaderI& tu +) : _os(os), _cs(cs), _sm(sm), _tu(tu) { +} + +VoIPVideoDisplay::~VoIPVideoDisplay(void) { +} + +float VoIPVideoDisplay::render(float delta_time) { + // go over all contacts with os comp + + { // destory unrendered + std::vector to_destory; + _cs.registry() + .view() + .each([this, &to_destory](Contact4 c, Contact::Components::VoIPVideoTexture& comp) { + if (comp.frames_since_render >= _frames_till_destory) { + // TODO: video sink + + _tu.destroy(comp.texture); + to_destory.push_back(c); + return; + } + }); + _cs.registry().erase(to_destory.cbegin(), to_destory.cend()); + } + + // create/update rendered + _cs.registry() + .view() + .each([this](Contact4 c, Contact::Components::VoIPVideoTexture& comp) { + // TODO: magic + if (comp.texture == 0) { + + //comp.texture = _tu.upload(nullptr, w, h, format, TextureUploaderI::LINEAR, TextureUploaderI::STREAMING); + } + }); + + // render popout windows + + return 1.f; +} diff --git a/src/chat_gui/voip_video_display.hpp b/src/chat_gui/voip_video_display.hpp new file mode 100644 index 00000000..634fa768 --- /dev/null +++ b/src/chat_gui/voip_video_display.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include +#include +#include "../frame_streams/stream_manager.hpp" +#include "../texture_uploader.hpp" + +namespace Contact::Components { + struct VoIPVideoTexture { + uint64_t texture {0}; + // w,h,format + size_t frames_since_render {0}; + }; +} // Contact::Components + +// creates/updates/destroys contact voip video sink textures that where rendered +// also connects/disconnects to voip stream source +// renders standalone(pop-out) video windows +class VoIPVideoDisplay final { + ObjectStore2& _os; + ContactStore4I& _cs; + StreamManager& _sm; + TextureUploaderI& _tu; + + const size_t _frames_till_destory {2}; + + public: + VoIPVideoDisplay( + ObjectStore2& os, + ContactStore4I& cs, + StreamManager& sm, + TextureUploaderI& tu + ); + ~VoIPVideoDisplay(void); + + public: + // call every frame + float render(float delta_time); +};