diff --git a/GstToolkit.cpp b/GstToolkit.cpp index 8598228..e8f3382 100644 --- a/GstToolkit.cpp +++ b/GstToolkit.cpp @@ -1,27 +1,44 @@ #include #include +#include +using namespace std; #include #include "GstToolkit.h" +string GstToolkit::date_time_string() +{ + std::time_t t = std::time(0); // get time now + std::tm* now = std::localtime(&t); -string GstToolkit::to_string(guint64 t) { + ostringstream oss; + oss << std::to_string(now->tm_year + 1900); + oss << std::to_string(now->tm_mon + 1); + oss << setw(2) << setfill('0') << std::to_string(now->tm_mday ); + oss << setw(2) << setfill('0') << std::to_string(now->tm_hour ); + oss << setw(2) << setfill('0') << std::to_string(now->tm_min ); + oss << setw(2) << setfill('0') << std::to_string(now->tm_sec ); + return oss.str(); +} + +string GstToolkit::time_to_string(guint64 t) +{ if (t == GST_CLOCK_TIME_NONE) return "00:00:00.00"; guint ms = GST_TIME_AS_MSECONDS(t); guint s = ms / 1000; - std::ostringstream oss; + ostringstream oss; if (s / 3600) - oss << std::setw(2) << std::setfill('0') << s / 3600 << ':'; + oss << setw(2) << setfill('0') << s / 3600 << ':'; if ((s % 3600) / 60) - oss << std::setw(2) << std::setfill('0') << (s % 3600) / 60 << ':'; - oss << std::setw(2) << std::setfill('0') << (s % 3600) % 60 << '.'; - oss << std::setw(2) << std::setfill('0') << (ms % 1000) / 10; + oss << setw(2) << setfill('0') << (s % 3600) / 60 << ':'; + oss << setw(2) << setfill('0') << (s % 3600) % 60 << '.'; + oss << setw(2) << setfill('0') << (ms % 1000) / 10; return oss.str(); } @@ -88,7 +105,7 @@ string GstToolkit::gst_version() { std::ostringstream oss; oss << GST_VERSION_MAJOR << '.' << GST_VERSION_MINOR << '.'; - oss << std::setw(2) << std::setfill('0') << GST_VERSION_MICRO ; + oss << std::setw(2) << setfill('0') << GST_VERSION_MICRO ; if (GST_VERSION_NANO > 0) oss << ( (GST_VERSION_NANO < 2 ) ? " - (CVS)" : " - (Prerelease)"); diff --git a/GstToolkit.h b/GstToolkit.h index 10df2cb..fa48509 100644 --- a/GstToolkit.h +++ b/GstToolkit.h @@ -3,20 +3,19 @@ #include #include -using namespace std; namespace GstToolkit { - string to_string(guint64 t); + std::string date_time_string(); + std::string time_to_string(guint64 t); - list all_plugins(); - list all_plugin_features(string pluginname); + std::string gst_version(); + std::list all_plugins(); + std::list all_plugin_features(std::string pluginname); - bool enable_feature (string name, bool enable); - - string gst_version(); + bool enable_feature (std::string name, bool enable); } diff --git a/ImGuiToolkit.cpp b/ImGuiToolkit.cpp index 587c56a..47afdc8 100644 --- a/ImGuiToolkit.cpp +++ b/ImGuiToolkit.cpp @@ -1,6 +1,5 @@ #include -#include #ifdef _WIN32 # include @@ -21,19 +20,8 @@ #include "ImGuiToolkit.h" #include "GstToolkit.h" -static unsigned int textureicons = 0; -static std::map fontmap; - -std::string ImGuiToolkit::DateTime(){ - std::time_t t = std::time(0); // get time now - std::tm* now = std::localtime(&t); - std::string datetime = std::to_string(now->tm_year + 1900) + - std::to_string(now->tm_mon + 1) + std::to_string(now->tm_mday) + - std::to_string(now->tm_hour) + std::to_string(now->tm_min) + - std::to_string(now->tm_sec); - - return datetime; -} +unsigned int textureicons = 0; +std::map fontmap; void ImGuiToolkit::OpenWebpage( const char* url ) @@ -248,13 +236,13 @@ bool ImGuiToolkit::TimelineSlider(const char* label, guint64 *time, guint64 dura // render text : duration and current time char overlay_buf[24]; ImVec2 overlay_size = ImVec2(0.f, 0.f); - ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::to_string(duration).c_str()); + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(duration).c_str()); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); overlay_size += ImVec2(3.f, 3.f); if (overlay_size.x > 0.0f) ImGui::RenderTextClipped( bbox.GetBR() - overlay_size, bbox.Max, overlay_buf, NULL, &overlay_size); - ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::to_string(*time).c_str()); + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(*time).c_str()); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); overlay_size = ImVec2(3.f, -3.f - overlay_size.y); if (overlay_size.x > 0.0f) @@ -452,13 +440,13 @@ bool ImGuiToolkit::TimelineSliderEdit(const char* label, guint64 *time, guint64 // render text : duration and current time char overlay_buf[24]; ImVec2 overlay_size = ImVec2(0.f, 0.f); - ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::to_string(duration).c_str()); + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(duration).c_str()); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); overlay_size += ImVec2(3.f, 3.f); if (overlay_size.x > 0.0f) ImGui::RenderTextClipped( bbox.GetBR() - overlay_size, bbox.Max, overlay_buf, NULL, &overlay_size); - ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::to_string(*time).c_str()); + ImFormatString(overlay_buf, IM_ARRAYSIZE(overlay_buf), "%s", GstToolkit::time_to_string(*time).c_str()); overlay_size = ImGui::CalcTextSize(overlay_buf, NULL); overlay_size = ImVec2(3.f, -3.f - overlay_size.y); if (overlay_size.x > 0.0f) diff --git a/ImGuiToolkit.h b/ImGuiToolkit.h index dc207f8..40c8d83 100644 --- a/ImGuiToolkit.h +++ b/ImGuiToolkit.h @@ -37,7 +37,6 @@ namespace ImGuiToolkit } accent_color; void SetAccentColor(accent_color color); - std::string DateTime(); void OpenWebpage( const char* url ); }