]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Display flash version in main window.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Mon, 28 Feb 2011 18:11:28 +0000 (18:11 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Mon, 28 Feb 2011 18:11:28 +0000 (18:11 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@497 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/producer/flash/flash_producer.cpp
core/producer/flash/flash_producer.h
shell/main.cpp

index 9488376e59a7862a1d002a24c310addf5c197da5..4231d647063869c9356acf8c3ef716ed52855003 100644 (file)
@@ -39,6 +39,7 @@
 #include <boost/filesystem.hpp>\r
 \r
 #include <functional>\r
+#include <boost/thread.hpp>\r
 \r
 namespace caspar { namespace core { namespace flash {\r
                \r
@@ -72,7 +73,7 @@ class flash_renderer
 \r
        safe_ptr<diagnostics::graph> graph_;\r
        timer perf_timer_;\r
-\r
+       \r
        std::wstring print()\r
        {\r
                return parent_printer_();\r
@@ -115,7 +116,7 @@ public:
                                                                                \r
                if(FAILED(spFlash->put_ScaleMode(2)))  //Exact fit. Scale without respect to the aspect ratio.\r
                        BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + "Failed to Set Scale Mode"));\r
-                                                                                                               \r
+                                               \r
                ax_->SetFormat(format_desc_);\r
                \r
                BITMAPINFO info;\r
@@ -164,7 +165,7 @@ public:
        {\r
                return ax_->GetFPS();   \r
        }\r
-\r
+       \r
 private:\r
 \r
        safe_ptr<draw_frame> render_simple_frame(bool underflow)\r
@@ -327,4 +328,53 @@ std::wstring flash_producer::find_template(const std::wstring& template_name)
        return L"";\r
 }\r
 \r
+std::wstring g_version = L"Unknown";\r
+void setup_version()\r
+{\r
+       CComObject<caspar::flash::FlashAxContainer>* ax_ = nullptr;     \r
+       {\r
+               CComPtr<IShockwaveFlash> spFlash;\r
+               try\r
+               {\r
+                       ::CoInitialize(nullptr);\r
+                       if(FAILED(CComObject<caspar::flash::FlashAxContainer>::CreateInstance(&ax_)))\r
+                               BOOST_THROW_EXCEPTION(caspar_exception());\r
+               \r
+                       if(FAILED(ax_->CreateAxControl()))\r
+                               BOOST_THROW_EXCEPTION(caspar_exception());\r
+               \r
+                       if(FAILED(ax_->QueryControl(&spFlash)))\r
+                               BOOST_THROW_EXCEPTION(caspar_exception());\r
+               }\r
+               catch(...){}\r
+       \r
+               if(!spFlash)\r
+                       return;\r
+\r
+               long ver;\r
+               if(SUCCEEDED(spFlash->FlashVersion(&ver)))\r
+               {\r
+                       auto min = boost::lexical_cast<std::wstring>((ver >> 0) & 0xFF);\r
+                       auto may = boost::lexical_cast<std::wstring>((ver >> 16) & 0xFF);\r
+                       g_version = may + L"." + min;\r
+               }\r
+       }\r
+\r
+       if(ax_)\r
+       {\r
+               ax_->DestroyAxControl();\r
+               ax_->Release();\r
+       }\r
+       \r
+       ::CoUninitialize();\r
+}\r
+\r
+std::wstring flash_producer::version()\r
+{              \r
+       boost::once_flag flag = BOOST_ONCE_INIT;\r
+       boost::call_once(setup_version, flag);\r
+\r
+       return g_version;\r
+}\r
+\r
 }}}
\ No newline at end of file
index f43bc437d8a9906d3321f2319d1e568693956634..2ac95ede3045eeb1b4fb342fa52ae51a4e69164c 100644 (file)
@@ -40,6 +40,8 @@ public:
        \r
        static std::wstring find_template(const std::wstring& templateName);\r
 \r
+       static std::wstring version();\r
+\r
 private:       \r
        struct implementation;\r
        std::shared_ptr<implementation> impl_;\r
index 5118e59f23e24f81504356f60efe6c0099de54e3..047bc895033adec2486f0676748bbf988fc5d3a7 100644 (file)
@@ -33,6 +33,8 @@
 \r
 #include "bootstrapper.h"\r
 \r
+#include <core/producer/flash/flash_producer.h>\r
+\r
 #include <common/exception/win32_exception.h>\r
 #include <common/exception/exceptions.h>\r
 #include <common/log/log.h>\r
@@ -94,7 +96,7 @@ void setup_console_window()
        SetConsoleWindowInfo(hOut, TRUE, &DisplayArea);\r
                \r
        std::wstringstream str;\r
-       str << "CasparCG Server " << env::version();\r
+       str << "CasparCG Server " << env::version() << L"      Flash " << flash::flash_producer::version();\r
        SetConsoleTitle(str.str().c_str());\r
 \r
        std::wcout << L"Copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\n" << std::endl;\r