diff --git a/ImGuiVisitor.cpp b/ImGuiVisitor.cpp index fb58b0c..390d2c8 100644 --- a/ImGuiVisitor.cpp +++ b/ImGuiVisitor.cpp @@ -712,6 +712,7 @@ void ImGuiVisitor::visit (PatternSource& s) for (uint p = 0; p < Pattern::pattern_types.size(); ++p){ if (ImGui::Selectable( Pattern::pattern_types[p].c_str() )) { s.setPattern(p, s.pattern()->resolution()); + info.reset(); std::ostringstream oss; oss << s.name() << ": Pattern " << Pattern::pattern_types[p]; Action::manager().store(oss.str()); @@ -751,6 +752,7 @@ void ImGuiVisitor::visit (DeviceSource& s) std::string namedev = Device::manager().name(d); if (ImGui::Selectable( namedev.c_str() )) { s.setDevice(namedev); + info.reset(); std::ostringstream oss; oss << s.name() << " Device " << namedev; Action::manager().store(oss.str()); @@ -789,8 +791,8 @@ void ImGuiVisitor::visit (NetworkSource& s) if ( ImGui::Button( ICON_FA_REPLY " Reconnect", ImVec2(IMGUI_RIGHT_ALIGN, 0)) ) { - // TODO : reload ? s.setConnection(s.connection()); + info.reset(); } } @@ -800,7 +802,7 @@ void ImGuiVisitor::visit (MultiFileSource& s) ImGuiToolkit::Icon(s.icon().x, s.icon().y); ImGui::SameLine(0, 10); ImGui::Text("Images sequence"); - static int64_t id = s.id(); + static int64_t id = 0; // information text ImGui::PushTextWrapPos(ImGui::GetCursorPos().x + ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN); @@ -857,4 +859,6 @@ void ImGuiVisitor::visit (MultiFileSource& s) ImGui::SameLine(); ImGui::Text("Folder"); + if (id != s.id()) + id = s.id(); } diff --git a/InfoVisitor.cpp b/InfoVisitor.cpp index d2e3299..75be121 100644 --- a/InfoVisitor.cpp +++ b/InfoVisitor.cpp @@ -37,12 +37,10 @@ #include "SystemToolkit.h" -InfoVisitor::InfoVisitor(bool brief) : brief_(brief), current_id_(0) +InfoVisitor::InfoVisitor() : brief_(true), current_id_(0) { - } - void InfoVisitor::visit(Node &n) { } @@ -64,9 +62,13 @@ void InfoVisitor::visit(Primitive &n) } - void InfoVisitor::visit(MediaPlayer &mp) { + if (current_id_ == mp.id()) + return; + + Log::Info("Getting string info MediaPlayer %ld", current_id_); + std::ostringstream oss; if (brief_) { oss << SystemToolkit::filename(mp.filename()) << std::endl; @@ -82,7 +84,9 @@ void InfoVisitor::visit(MediaPlayer &mp) if (!mp.isImage()) oss << ", " << std::fixed << std::setprecision(1) << mp.frameRate() << " fps"; } + information_ = oss.str(); + current_id_ = mp.id(); } void InfoVisitor::visit(Stream &n) @@ -180,8 +184,7 @@ void InfoVisitor::visit (PatternSource& s) oss << ", RGB"; } else { - std::string desc = s.stream()->description(); - oss << desc.substr(0, desc.find_first_of('!')) << std::endl; + oss << Pattern::pattern_types[s.pattern()->type()] << std::endl; oss << s.pattern()->width() << " x " << s.pattern()->height(); oss << ", RGB"; } @@ -256,11 +259,11 @@ void InfoVisitor::visit (MultiFileSource& s) oss << s.sequence().min << " - " << s.sequence().max << "]"; } else { - oss << SystemToolkit::path_filename(s.sequence().location) ; - oss << " " << s.sequence().max - s.sequence().min + 1 << " images ["; + oss << s.sequence().location << " ["; oss << s.sequence().min << " - " << s.sequence().max << "]" << std::endl; oss << s.sequence().width << " x " << s.sequence().height << ", "; - oss << s.sequence().codec; + oss << s.sequence().codec << " ("; + oss << s.sequence().max - s.sequence().min + 1 << " images)"; } information_ = oss.str(); diff --git a/InfoVisitor.h b/InfoVisitor.h index 2db7616..4458073 100644 --- a/InfoVisitor.h +++ b/InfoVisitor.h @@ -10,8 +10,11 @@ class InfoVisitor : public Visitor uint64_t current_id_; public: - InfoVisitor(bool brief = true); - inline std::string str() const { return information_; } + InfoVisitor(); + inline void setBriefStringMode () { brief_ = true; current_id_ = 0; } + inline void setExtendedStringMode () { brief_ = false; current_id_ = 0; } + inline void reset () { current_id_ = 0; } + inline std::string str () const { return information_; } // Elements of Scene void visit (Scene& n) override; diff --git a/MediaPlayer.cpp b/MediaPlayer.cpp index a3019a6..61602f5 100644 --- a/MediaPlayer.cpp +++ b/MediaPlayer.cpp @@ -1242,16 +1242,16 @@ void MediaPlayer::TimeCounter::tic () { // how long since last time GstClockTime t = gst_util_get_timestamp (); - GstClockTime dt = t - last_time; + GstClockTime dt = t - last_time -1; // one more frame since last time nbFrames++; // calculate instantaneous framerate - // Exponential moving averate with previous framerate to filter jitter (50/50) + // Exponential moving averate with previous framerate to filter jitter (70/30) // The divition of frame/time is done on long integer GstClockTime, counting in microsecond // NB: factor 100 to get 0.01 precision - fps = 0.5 * fps + 0.005 * static_cast( ( 100 * GST_SECOND * nbFrames ) / dt ); + fps = 0.7 * fps + 0.003 * static_cast( ( 100 * GST_SECOND * nbFrames ) / dt ); // reset counter every second if ( dt >= GST_SECOND) diff --git a/MediaPlayer.h b/MediaPlayer.h index 0e4a742..3efd921 100644 --- a/MediaPlayer.h +++ b/MediaPlayer.h @@ -299,7 +299,7 @@ private: GstClockTime last_time; GstClockTime tic_time; - int nbFrames; + long nbFrames; gdouble fps; public: TimeCounter(); diff --git a/PatternSource.cpp b/PatternSource.cpp index d7c7ff6..cd7f762 100644 --- a/PatternSource.cpp +++ b/PatternSource.cpp @@ -126,6 +126,7 @@ void Pattern::open( uint pattern, glm::ivec2 res ) // all patterns before 'SMPTE test pattern' are single frames (not animated) single_frame_ = type_ < 14; + Log::Info("Stream %d SingleFrame", single_frame_); // (private) open stream Stream::open(gstreamer_pattern, res.x, res.y); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 87614c6..353a377 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -1963,15 +1963,17 @@ void ToolBox::Render() /// SOURCE CONTROLLER /// SourceController::SourceController() : _min_width(0.f), _h_space(0.f), _v_space(0.f), _buttons_height(0.f), - _timeline_height(0.f), _scrollbar(0.f), _mediaplayer_height(0.f), + _timeline_height(0.f), _scrollbar(0.f), _mediaplayer_height(0.f), _buttons_width(0.f), active_label_(LABEL_AUTO_MEDIA_PLAYER), active_selection_(-1), media_playing_mode_(false), slider_pressed_(false) { + info_.setExtendedStringMode(); } void SourceController::resetActiveSelection() { + info_.reset(); active_selection_ = -1; active_label_ = LABEL_AUTO_MEDIA_PLAYER; } @@ -2008,7 +2010,6 @@ void SourceController::Render() source_window_pos = ImGui::GetWindowPos(); source_window_size = ImGui::GetWindowSize(); - // menu (no title bar) if (ImGui::BeginMenuBar()) { @@ -2037,6 +2038,7 @@ void SourceController::Render() { active_selection_ = i; active_label_ = label; + info_.reset(); } } @@ -2045,9 +2047,9 @@ void SourceController::Render() active_selection_ = Mixer::manager().session()->numPlayGroups(); active_label_ = std::string("Selection #") + std::to_string(active_selection_); Mixer::manager().session()->addPlayGroup( ids(playable_only(Mixer::selection().getCopy())) ); + info_.reset(); } - ImGui::EndMenu(); } @@ -2100,10 +2102,8 @@ void SourceController::RenderSelection(size_t i) { ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0.f, _v_space)); - for (auto source = selection_.begin(); source != selection_.end(); ++source) { - ImVec2 framesize(1.5f * _timeline_height * (*source)->frame()->aspectRatio(), 1.5f * _timeline_height); ImVec2 image_top = ImGui::GetCursorPos(); @@ -2235,8 +2235,9 @@ bool SourceController::SourceButton(Source *s, ImVec2 framesize) ImGui::PushID(s->id()); ImGui::InvisibleButton("##sourcebutton", framesize); - if (ImGui::IsItemClicked()) + if (ImGui::IsItemClicked()) { ret = true; + } if (ImGui::IsItemHovered()){ ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->AddRect(frame_top, frame_top + framesize - ImVec2(1.f, 0.f), ImGui::GetColorU32(ImGuiCol_Text), 0, 0, 3.f); @@ -2305,9 +2306,8 @@ void SourceController::RenderSelectedSources() framesize.x -= _h_space; ImVec2 image_top = ImGui::GetCursorPos(); - if (SourceButton(*source, framesize)){ - Mixer::selection().set(*source); - } + if (SourceButton(*source, framesize)) + UserInterface::manager().showSourceEditor(*source); // Play icon lower left corner ImGuiToolkit::PushFont(framesize.x > 350.f ? ImGuiToolkit::FONT_LARGE : ImGuiToolkit::FONT_MONO); @@ -2407,14 +2407,20 @@ void SourceController::RenderSingleSource(Source *s) ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space)); ImGui::Text(ICON_FA_INFO_CIRCLE); if (ImGui::IsItemHovered()){ - static InfoVisitor info(false); - s->accept(info); + // fill info string + s->accept(info_); float tooltip_height = 2.f * ImGui::GetTextLineHeightWithSpacing(); ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY); ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space)); - ImGui::Text("%s", info.str().c_str()); + ImGui::Text("%s", info_.str().c_str()); + + StreamSource *sts = dynamic_cast(s); + if (sts) { + ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.5f * tooltip_height)); + ImGui::Text("%.1f Hz", sts->stream()->updateFrameRate()); + } } /// @@ -2465,14 +2471,16 @@ void SourceController::RenderMediaPlayer(MediaPlayer *mp) ImGui::SetCursorScreenPos(top + ImVec2(framesize.x - ImGui::GetTextLineHeightWithSpacing(), _v_space)); ImGui::Text(ICON_FA_INFO_CIRCLE); if (ImGui::IsItemHovered()){ - static InfoVisitor info(false); - mp->accept(info); + mp->accept(info_); float tooltip_height = 3.f * ImGui::GetTextLineHeightWithSpacing(); ImDrawList* draw_list = ImGui::GetWindowDrawList(); draw_list->AddRectFilled(top, top + ImVec2(framesize.x, tooltip_height), IMGUI_COLOR_OVERLAY); ImGui::SetCursorScreenPos(top + ImVec2(_h_space, _v_space)); - ImGui::Text("%s", info.str().c_str()); + ImGui::Text("%s", info_.str().c_str()); + + ImGui::SetCursorScreenPos(top + ImVec2( framesize.x - 1.5f * _buttons_height, 0.666f * tooltip_height)); + ImGui::Text("%.1f Hz", mp->updateFrameRate()); } /// diff --git a/UserInterfaceManager.h b/UserInterfaceManager.h index 712ddf2..72df4e4 100644 --- a/UserInterfaceManager.h +++ b/UserInterfaceManager.h @@ -11,6 +11,7 @@ #define NAV_TRANS 67 #include "SourceList.h" +#include "InfoVisitor.h" struct ImVec2; class MediaPlayer; @@ -116,6 +117,7 @@ class SourceController std::string active_label_; int active_selection_; + InfoVisitor info_; SourceList selection_; void DrawButtonBar(ImVec2 bottom, float width);