]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: Improved logging. Refactored ogl_consumer creation.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 17 May 2011 23:12:32 +0000 (23:12 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 17 May 2011 23:12:32 +0000 (23:12 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@769 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

13 files changed:
core/channel.cpp
core/video_format.cpp
modules/bluefish/consumer/bluefish_consumer.cpp
modules/decklink/consumer/decklink_consumer.cpp
modules/decklink/decklink.cpp
modules/flash/producer/flash_producer.cpp
modules/oal/consumer/oal_consumer.cpp
modules/ogl/consumer/ogl_consumer.cpp
modules/ogl/consumer/ogl_consumer.h
modules/ogl/ogl.cpp
shell/caspar.config
shell/main.cpp
shell/server.cpp

index c65fd69bd8ce326c293a0eff71c05c0e8b62962e..3c64f5b70bd503e0254f817452944a40b7e3f1d4 100644 (file)
@@ -63,7 +63,9 @@ public:
                , producer_(new frame_producer_device(format_desc_))    \r
                , mixer_connection_(mixer_->connect([=](const safe_ptr<const read_frame>& frame){consumer_->send(frame);}))\r
                , producer_connection_(producer_->connect([=](const std::map<int, safe_ptr<basic_frame>>& frames){mixer_->send(frames);}))\r
-       {}\r
+       {\r
+               CASPAR_LOG(info) << print() << " Successfully Initialized.";\r
+       }\r
                \r
        std::wstring print() const\r
        {\r
index d695d589342af6fe6688ce53520c89d6fee0f13b..bad1125f520b4ad3569ecab33466d1947c32061b 100644 (file)
@@ -48,8 +48,8 @@ namespace caspar { namespace core {
        \r
 const video_format_desc format_descs[video_format::count] =  \r
 {                                                                         \r
-       DEFINE_VIDEOFORMATDESC(video_format::pal                ,720,  576,  video_mode::upper,                 25,             1,              TEXT("pal")             ), \r
-       DEFINE_VIDEOFORMATDESC(video_format::ntsc               ,720,  486,  video_mode::lower,                 30000,  1001,   TEXT("ntsc")    ), \r
+       DEFINE_VIDEOFORMATDESC(video_format::pal                ,720,  576,  video_mode::upper,                 25,             1,              TEXT("PAL")             ), \r
+       DEFINE_VIDEOFORMATDESC(video_format::ntsc               ,720,  486,  video_mode::lower,                 30000,  1001,   TEXT("NTSC")    ), \r
        DEFINE_VIDEOFORMATDESC(video_format::x576p2500  ,720,  576,  video_mode::progressive,   25,             1,              TEXT("576p2500")),\r
        DEFINE_VIDEOFORMATDESC(video_format::x720p2500  ,1280, 720,  video_mode::progressive,   25,             1,              TEXT("720p2500")), \r
        DEFINE_VIDEOFORMATDESC(video_format::x720p5000  ,1280, 720,  video_mode::progressive,   50,             1,              TEXT("720p5000")), \r
index 5bdef668d6655fabd004c17c39427caadea26ce5..d28ee3bb67f080896c37a8971ea675d7c3287074 100644 (file)
@@ -229,7 +229,7 @@ public:
 \r
                active_ = executor_.begin_invoke([]{});\r
                                \r
-               CASPAR_LOG(info) << print() << TEXT(" Successfully initialized for ") << format_desc_ << TEXT(".");\r
+               CASPAR_LOG(info) << print() << L" Successfully Initialized.";\r
        }\r
 \r
        ~bluefish_consumer()\r
@@ -348,7 +348,7 @@ public:
        \r
        std::wstring print() const\r
        {\r
-               return model_name_ + L" [" + boost::lexical_cast<std::wstring>(device_index_) + L"]";\r
+               return model_name_ + L" [" + boost::lexical_cast<std::wstring>(device_index_) + L"|" +  format_desc_.name + L"]";\r
        }\r
 };\r
 \r
@@ -408,7 +408,7 @@ std::vector<std::wstring> get_bluefish_device_list()
 \r
                for(int n = 1; BLUE_PASS(blue->device_attach(n, FALSE)); ++n)\r
                {                               \r
-                       devices.push_back(L"[" + boost::lexical_cast<std::wstring>(n) + L"] " + get_card_desc(blue->has_video_cardtype()));\r
+                       devices.push_back(std::wstring(get_card_desc(blue->has_video_cardtype())) + L" [" + boost::lexical_cast<std::wstring>(n) + L"]");\r
                        blue->device_detach();          \r
                }\r
        }\r
index 694dad52a42fe89d65187463bf617f882b5137ff..72d950cd41768e06579f52f3d4d8ebcfc920b560 100644 (file)
@@ -201,7 +201,7 @@ public:
                        start_playback();\r
                \r
                CASPAR_LOG(info) << print() << L" Buffer depth: " << buffer_size_;              \r
-               CASPAR_LOG(info) << print() << L" Successfully initialized for " << format_desc_.name;  \r
+               CASPAR_LOG(info) << print() << L" Successfully Initialized.";   \r
        }\r
 \r
        ~decklink_consumer()\r
@@ -396,7 +396,7 @@ public:
        \r
        std::wstring print() const\r
        {\r
-               return model_name_ + L" [" + boost::lexical_cast<std::wstring>(config_.device_index) + L"]";\r
+               return model_name_ + L" [" + boost::lexical_cast<std::wstring>(config_.device_index) + L"|" +  format_desc_.name + L"]";\r
        }\r
 };\r
 \r
index cfcb4c8507cdb826d1266eeda9b1bcf3ba26834a..ae7ce18aed0880d4f8175d5671824eca2cf4fc34 100644 (file)
@@ -80,7 +80,7 @@ std::vector<std::wstring> get_decklink_device_list()
                        {\r
                                BSTR model_name = L"Unknown";\r
                                decklink->GetModelName(&model_name);\r
-                               devices.push_back(L"[" + boost::lexical_cast<std::wstring>(n) + L"] " + model_name);    \r
+                               devices.push_back(std::wstring(model_name) + L" [" + boost::lexical_cast<std::wstring>(n) + L"]");      \r
                        }\r
                }\r
        }\r
index 7f36c9965a5dc06dceca9ff4ab9fa0b76dabdbad..b7b98877f8f5cc9ca87af0e946f0ab93ade5e7a8 100644 (file)
@@ -156,7 +156,7 @@ public:
                        CASPAR_LOG(warning) << print() << " Flash function call failed. Param: " << param << ".";\r
                graph_->add_tag("param");\r
 \r
-               if(abs(ax_->GetFPS() - format_desc_.fps) > 0.001 && abs(ax_->GetFPS()/2.0 - format_desc_.fps) > 0.001)\r
+               if(abs(ax_->GetFPS() - format_desc_.fps) > 0.01 && abs(ax_->GetFPS()/2.0 - format_desc_.fps) > 0.01)\r
                        CASPAR_LOG(warning) << print() << " Invalid frame-rate: " << ax_->GetFPS() << L". Should be either " << format_desc_.fps << L" or " << format_desc_.fps*2.0 << L".";\r
        }\r
        \r
index 99d0df4efee1a8f5341044fe42264d386f1e1e28..65f9668e25ccf3ddb66f449cd3fd4e03d996fcc4 100644 (file)
@@ -103,7 +103,7 @@ public:
 \r
        std::wstring print() const\r
        {\r
-               return L"oal[default]";\r
+               return L"oal[" + format_desc_.name + L"]";\r
        }\r
 };\r
 \r
index 52e139e66cdc0ee89c4b232ffd64ee340b33411d..f5cfa783794819b80930ddcbd6dd6d1d3df9c53e 100644 (file)
@@ -44,7 +44,7 @@
 \r
 namespace caspar {\r
 \r
-struct ogl_consumer::implementation : boost::noncopyable\r
+struct ogl_consumer : boost::noncopyable\r
 {              \r
        boost::unique_future<void> active_;\r
                \r
@@ -72,26 +72,18 @@ struct ogl_consumer::implementation : boost::noncopyable
 \r
        executor executor_;\r
 public:\r
-       implementation(unsigned int screen_index, stretch stretch, bool windowed\r
+       ogl_consumer(unsigned int screen_index, stretch stretch, bool windowed, const core::video_format_desc& format_desc\r
                : stretch_(stretch)\r
                , windowed_(windowed)\r
                , texture_(0)\r
                , screen_index_(screen_index)\r
+               , format_desc_(format_desc_)\r
                , graph_(diagnostics::create_graph(narrow(print())))\r
                , executor_(print())\r
        {               \r
                executor_.set_capacity(3);\r
                graph_->add_guide("frame-time", 0.5);\r
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
-       }\r
-\r
-       ~implementation()\r
-       {\r
-               CASPAR_LOG(info) << print() << L" Shutting down.";      \r
-       }\r
-\r
-       void initialize(const core::video_format_desc& format_desc)\r
-       {\r
                if(!GLEE_VERSION_2_1)\r
                        BOOST_THROW_EXCEPTION(not_supported() << msg_info("Missing OpenGL 2.1 support."));\r
                \r
@@ -177,9 +169,9 @@ public:
                        glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, format_desc_.size, 0, GL_STREAM_DRAW_ARB);\r
                        glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0);\r
                });\r
-               CASPAR_LOG(info) << print() << " Sucessfully initialized.";\r
+               CASPAR_LOG(info) << print() << " Sucessfully Initialized.";\r
        }\r
-\r
+       \r
        void calculate_aspect()\r
        {\r
                if(windowed_)\r
@@ -290,32 +282,51 @@ public:
        }\r
 \r
        std::wstring print() const\r
-       {\r
-               return L"ogl[" + boost::lexical_cast<std::wstring>(screen_index_) + L"]";\r
+       {       \r
+               return  L"ogl[" + boost::lexical_cast<std::wstring>(screen_index_) + L"|" + format_desc_.name + L"]";\r
        }\r
 \r
        size_t buffer_depth() const{return 2;}\r
 };\r
 \r
-ogl_consumer::ogl_consumer(ogl_consumer&& other) : impl_(std::move(other.impl_)){}\r
-ogl_consumer::ogl_consumer(unsigned int screen_index, stretch stretch, bool windowed) : impl_(new implementation(screen_index, stretch, windowed)){}\r
-void ogl_consumer::send(const safe_ptr<const core::read_frame>& frame){impl_->send(frame);}\r
-size_t ogl_consumer::buffer_depth() const{return impl_->buffer_depth();}\r
-void ogl_consumer::initialize(const core::video_format_desc& format_desc)\r
+\r
+struct ogl_consumer_proxy : public core::frame_consumer\r
 {\r
-       // TODO: Ugly\r
-       if(impl_->executor_.is_running())\r
-               impl_.reset(new implementation(impl_->screen_index_, impl_->stretch_, impl_->windowed_));\r
-       impl_->initialize(format_desc);\r
-}\r
-std::wstring ogl_consumer::print() const {return impl_->print();}\r
+       size_t screen_index_;\r
+       caspar::stretch stretch_;\r
+       bool windowed_;\r
+\r
+       std::unique_ptr<ogl_consumer> consumer_;\r
+\r
+public:\r
+\r
+       ogl_consumer_proxy(size_t screen_index, stretch stretch, bool windowed)\r
+               : screen_index_(screen_index)\r
+               , stretch_(stretch)\r
+               , windowed_(windowed){}\r
+       \r
+       virtual void initialize(const core::video_format_desc& format_desc)\r
+       {\r
+               consumer_.reset(new ogl_consumer(screen_index_, stretch_, windowed_, format_desc));\r
+       }\r
+       \r
+       virtual void send(const safe_ptr<const core::read_frame>& frame)\r
+       {\r
+               consumer_->send(frame);\r
+       }\r
+       \r
+       virtual std::wstring print() const\r
+       {\r
+               return consumer_->print();\r
+       }\r
+};     \r
 \r
 safe_ptr<core::frame_consumer> create_ogl_consumer(const std::vector<std::wstring>& params)\r
 {\r
        if(params.size() < 1 || params[0] != L"OGL")\r
                return core::frame_consumer::empty();\r
        \r
-       unsigned int screen_index = 0;\r
+       size_t screen_index = 0;\r
        stretch stretch = stretch::fill;\r
        bool windowed = true;\r
        \r
@@ -325,7 +336,22 @@ safe_ptr<core::frame_consumer> create_ogl_consumer(const std::vector<std::wstrin
        if(params.size() > 2) \r
                windowed = lexical_cast_or_default<bool>(params[3], windowed);\r
 \r
-       return make_safe<ogl_consumer>(screen_index, stretch, windowed);\r
+       return make_safe<ogl_consumer_proxy>(screen_index, stretch, windowed);\r
+}\r
+\r
+safe_ptr<core::frame_consumer> create_ogl_consumer(const boost::property_tree::ptree& ptree) \r
+{\r
+       size_t screen_index = ptree.get("device", 0);\r
+       bool windowed =ptree.get("windowed", true);\r
+       \r
+       stretch stretch = stretch::fill;\r
+       auto key_str = ptree.get("stretch", "default");\r
+       if(key_str == "uniform")\r
+               stretch = stretch::uniform;\r
+       else if(key_str == "uniform_to_fill")\r
+               stretch = stretch::uniform_to_fill;\r
+\r
+       return make_safe<ogl_consumer_proxy>(screen_index, stretch, windowed);\r
 }\r
 \r
 }
\ No newline at end of file
index dc29ebee5eeb7309e4e6f45854bb4ad7ea267b9a..94cbcb2541b1ee11a3df61abccdcc9470fb9eba9 100644 (file)
@@ -23,6 +23,7 @@
 #include <core/video_format.h>\r
 \r
 #include <vector>\r
+#include <boost/property_tree/ptree.hpp>\r
 \r
 namespace caspar {\r
        \r
@@ -34,21 +35,7 @@ enum stretch
        uniform_to_fill\r
 };\r
 \r
-class ogl_consumer : public core::frame_consumer\r
-{\r
-public:        \r
-       explicit ogl_consumer(unsigned int screen_index = 0, stretch stretch = stretch::fill, bool windowed = false);\r
-       ogl_consumer(ogl_consumer&& other);\r
-       \r
-       virtual void initialize(const core::video_format_desc& format_desc);\r
-       virtual void send(const safe_ptr<const core::read_frame>&);\r
-       virtual size_t buffer_depth() const;\r
-       virtual std::wstring print() const;\r
-private:\r
-       struct implementation;\r
-       std::shared_ptr<implementation> impl_;\r
-};\r
-\r
 safe_ptr<core::frame_consumer> create_ogl_consumer(const std::vector<std::wstring>& params);\r
+safe_ptr<core::frame_consumer> create_ogl_consumer(const boost::property_tree::ptree& ptree);\r
 \r
 }
\ No newline at end of file
index 1fe37a0c25572e0da1729608d223f2f76d775429..b387512e7b8dc86a60f39e869683f895eefdecb2 100644 (file)
@@ -28,7 +28,7 @@ namespace caspar
 \r
 void init_ogl()\r
 {\r
-       core::register_consumer_factory(create_ogl_consumer);\r
+       core::register_consumer_factory([](const std::vector<std::wstring>& params){return create_ogl_consumer(params);});\r
 }\r
 \r
 }
\ No newline at end of file
index c6de7991f2f4cd2b93803b383760d07c5f8a577d..d57491835698090d76b050dfcba89ad2b998fad3 100644 (file)
@@ -5,14 +5,14 @@
     <log-path>L:\\Casparcg\\_log\\</log-path>\r
     <data-path>L:\\Casparcg\\_data\\</data-path>\r
     <template-path>L:\\Casparcg\\_templates\\</template-path>\r
-    <template-host>cg.fth.1920x1080i59.94</template-host>\r
+    <template-host>1080 59i.fth</template-host>\r
   </paths>\r
   <diagnostics>\r
     <graphs>true</graphs>\r
   </diagnostics>\r
   <channels>\r
     <channel>\r
-      <videomode>1080i5000</videomode>\r
+      <videomode>NTSC</videomode>\r
       <consumers>\r
         <decklink>\r
           <device>1</device>\r
index 70584c1d068730790dca70d36bf9c3d767575b04..9923160a9c5ad705aaa73f9129f991cf54e02588 100644 (file)
@@ -101,15 +101,13 @@ void print_info()
        CASPAR_LOG(info) << L"Flash-Template-Host " << caspar::get_cg_version();\r
        CASPAR_LOG(info) << L"FreeImage " << caspar::get_image_version();\r
        \r
-       std::wstring decklink_devices;\r
+       CASPAR_LOG(info) << L"Decklink " << caspar::get_decklink_version();\r
        BOOST_FOREACH(auto& device, caspar::get_decklink_device_list())\r
-               decklink_devices += L"\t" + device;\r
-       CASPAR_LOG(info) << L"Decklink " << caspar::get_decklink_version() << (decklink_devices.empty() ? L"" : L"\n\tDevices:\n" + decklink_devices);\r
-       \r
-       std::wstring bluefish_devices;\r
+               CASPAR_LOG(info) << device;\r
+               \r
+       CASPAR_LOG(info) << L"Bluefish " << caspar::get_bluefish_version();\r
        BOOST_FOREACH(auto& device, caspar::get_bluefish_device_list())\r
-               bluefish_devices += L"\t" + device;\r
-       CASPAR_LOG(info) << L"Bluefish " << caspar::get_bluefish_version() << (bluefish_devices.empty() ? L"" : L"\n\tDevices:\n" + bluefish_devices);\r
+               CASPAR_LOG(info) << device;\r
 \r
        CASPAR_LOG(info) << L"FFMPEG-avcodec "  << caspar::get_avcodec_version();\r
        CASPAR_LOG(info) << L"FFMPEG-swscale "  << caspar::get_avformat_version();\r
index 5e3528bfdc137427da000acce2cdcabf49ae4149..956a9bcde677ebe78719233af4f682dc7fde1eb4 100644 (file)
@@ -100,23 +100,9 @@ struct server::implementation : boost::noncopyable
                        {\r
                                try\r
                                {\r
-                                       std::string name = xml_consumer.first;\r
+                                       const std::string name = xml_consumer.first;\r
                                        if(name == "ogl")\r
-                                       {                       \r
-                                               int device = xml_consumer.second.get("device", 0);\r
-                       \r
-                                               stretch stretch = stretch::fill;\r
-                                               std::string stretchStr = xml_consumer.second.get("stretch", "");\r
-                                               if(stretchStr == "none")\r
-                                                       stretch = stretch::none;\r
-                                               else if(stretchStr == "uniform")\r
-                                                       stretch = stretch::uniform;\r
-                                               else if(stretchStr == "uniformtofill")\r
-                                                       stretch = stretch::uniform_to_fill;\r
-\r
-                                               bool windowed = xml_consumer.second.get("windowed", false);\r
-                                               channels_.back()->consumer()->add(index++, ogl_consumer(device, stretch, windowed));\r
-                                       }\r
+                                               channels_.back()->consumer()->add(index++, create_ogl_consumer(xml_consumer.second));                                   \r
                                        else if(name == "bluefish")                                     \r
                                                channels_.back()->consumer()->add(index++, create_bluefish_consumer(xml_consumer.second));                                      \r
                                        else if(name == "decklink")                                     \r