]> git.sesse.net Git - casparcg/blobdiff - shell/server.cpp
2.1.0: Reverted utf8. To complicated to fully fix for now.
[casparcg] / shell / server.cpp
index 18a08461af183bbe50a6c4c0dedea6dbdd9485e3..f1419cc91b1fbe5a8011cd65381918fd987ba6dc 100644 (file)
@@ -1,23 +1,25 @@
 /*\r
-* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
 *\r
-*  This file is part of CasparCG.\r
+* This file is part of CasparCG (www.casparcg.com).\r
 *\r
-*    CasparCG is free software: you can redistribute it and/or modify\r
-*    it under the terms of the GNU General Public License as published by\r
-*    the Free Software Foundation, either version 3 of the License, or\r
-*    (at your option) any later version.\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
 *\r
-*    CasparCG is distributed in the hope that it will be useful,\r
-*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-*    GNU General Public License for more details.\r
-\r
-*    You should have received a copy of the GNU General Public License\r
-*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
 *\r
+* Author: Robert Nagy, ronag89@gmail.com\r
 */\r
 \r
+\r
 #include "server.h"\r
 \r
 #include <common/env.h>\r
@@ -62,23 +64,39 @@ using namespace protocol;
 \r
 struct server::implementation : boost::noncopyable\r
 {\r
-       ogl_device                                                                      ogl_;\r
+       safe_ptr<ogl_device>                                            ogl_;\r
        std::vector<safe_ptr<IO::AsyncEventServer>> async_servers_;     \r
        std::vector<safe_ptr<video_channel>>            channels_;\r
 \r
-       implementation()                                                                                                \r
+       implementation()                \r
+               : ogl_(ogl_device::create())\r
        {                       \r
                ffmpeg::init();\r
-               bluefish::init();\r
-               decklink::init();\r
-               flash::init();\r
-               oal::init();\r
-               ogl::init();\r
-               //init_silverlight();\r
-               image::init();\r
+               CASPAR_LOG(info) << L"Initialized ffmpeg module.";\r
+                                                         \r
+               bluefish::init();         \r
+               CASPAR_LOG(info) << L"Initialized bluefish module.";\r
+                                                         \r
+               decklink::init();         \r
+               CASPAR_LOG(info) << L"Initialized decklink module.";\r
+                                                                                                                 \r
+               oal::init();              \r
+               CASPAR_LOG(info) << L"Initialized oal module.";\r
+                                                         \r
+               ogl::init();              \r
+               CASPAR_LOG(info) << L"Initialized ogl module.";\r
+\r
+               image::init();            \r
+               CASPAR_LOG(info) << L"Initialized image module.";\r
+\r
+               flash::init();            \r
+               CASPAR_LOG(info) << L"Initialized flash module.";\r
 \r
                setup_channels(env::properties());\r
+               CASPAR_LOG(info) << L"Initialized channels.";\r
+\r
                setup_controllers(env::properties());\r
+               CASPAR_LOG(info) << L"Initialized controllers.";\r
        }\r
 \r
        ~implementation()\r
@@ -89,34 +107,33 @@ struct server::implementation : boost::noncopyable
                channels_.clear();\r
        }\r
                                \r
-       void setup_channels(const boost::property_tree::ptree& pt)\r
+       void setup_channels(const boost::property_tree::wptree& pt)\r
        {   \r
-               using boost::property_tree::ptree;\r
-               BOOST_FOREACH(auto& xml_channel, pt.get_child("configuration.channels"))\r
+               using boost::property_tree::wptree;\r
+               BOOST_FOREACH(auto& xml_channel, pt.get_child(L"configuration.channels"))\r
                {               \r
-                       auto format_desc = video_format_desc::get(widen(xml_channel.second.get("video-mode", "PAL")));          \r
+                       auto format_desc = video_format_desc::get(widen(xml_channel.second.get(L"video-mode", L"PAL")));                \r
                        if(format_desc.format == video_format::invalid)\r
                                BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid video-mode."));\r
                        \r
-                       channels_.push_back(video_channel(channels_.size(), format_desc, ogl_));\r
+                       channels_.push_back(make_safe<video_channel>(channels_.size()+1, format_desc, ogl_));\r
                        \r
-                       int index = 0;\r
-                       BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child("consumers"))\r
+                       BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child(L"consumers"))\r
                        {\r
                                try\r
                                {\r
-                                       const std::string name = xml_consumer.first;\r
-                                       if(name == "screen")\r
-                                               channels_.back()->output()->add(index++, ogl::create_consumer(xml_consumer.second));                                    \r
-                                       else if(name == "bluefish")                                     \r
-                                               channels_.back()->output()->add(index++, bluefish::create_consumer(xml_consumer.second));                                       \r
-                                       else if(name == "decklink")                                     \r
-                                               channels_.back()->output()->add(index++, decklink::create_consumer(xml_consumer.second));                               \r
-                                       //else if(name == "file")                                       \r
-                                       //      channels_.back()->output()->add(index++, create_ffmpeg_consumer(xml_consumer.second));                                          \r
-                                       else if(name == "system-audio")\r
-                                               channels_.back()->output()->add(index++, oal::create_consumer());               \r
-                                       else if(name != "<xmlcomment>")\r
+                                       auto name = xml_consumer.first;\r
+                                       if(name == L"screen")\r
+                                               channels_.back()->output()->add(ogl::create_consumer(xml_consumer.second));                                     \r
+                                       else if(name == L"bluefish")                                    \r
+                                               channels_.back()->output()->add(bluefish::create_consumer(xml_consumer.second));                                        \r
+                                       else if(name == L"decklink")                                    \r
+                                               channels_.back()->output()->add(decklink::create_consumer(xml_consumer.second));                                \r
+                                       else if(name == L"file")                                        \r
+                                               channels_.back()->output()->add(ffmpeg::create_consumer(xml_consumer.second));                                          \r
+                                       else if(name == L"system-audio")\r
+                                               channels_.back()->output()->add(oal::create_consumer());                \r
+                                       else if(name != L"<xmlcomment>")\r
                                                CASPAR_LOG(warning) << "Invalid consumer: " << widen(name);     \r
                                }\r
                                catch(...)\r
@@ -127,19 +144,19 @@ struct server::implementation : boost::noncopyable
                }\r
        }\r
                \r
-       void setup_controllers(const boost::property_tree::ptree& pt)\r
+       void setup_controllers(const boost::property_tree::wptree& pt)\r
        {               \r
-               using boost::property_tree::ptree;\r
-               BOOST_FOREACH(auto& xml_controller, pt.get_child("configuration.controllers"))\r
+               using boost::property_tree::wptree;\r
+               BOOST_FOREACH(auto& xml_controller, pt.get_child(L"configuration.controllers"))\r
                {\r
                        try\r
                        {\r
-                               std::string name = xml_controller.first;\r
-                               std::string protocol = xml_controller.second.get<std::string>("protocol");      \r
+                               auto name = xml_controller.first;\r
+                               auto protocol = xml_controller.second.get<std::wstring>(L"protocol");   \r
 \r
-                               if(name == "tcp")\r
+                               if(name == L"tcp")\r
                                {                                       \r
-                                       unsigned int port = xml_controller.second.get("port", 5250);\r
+                                       unsigned int port = xml_controller.second.get(L"port", 5250);\r
                                        auto asyncbootstrapper = make_safe<IO::AsyncEventServer>(create_protocol(protocol), port);\r
                                        asyncbootstrapper->Start();\r
                                        async_servers_.push_back(asyncbootstrapper);\r
@@ -154,16 +171,16 @@ struct server::implementation : boost::noncopyable
                }\r
        }\r
 \r
-       safe_ptr<IO::IProtocolStrategy> create_protocol(const std::string& name) const\r
+       safe_ptr<IO::IProtocolStrategy> create_protocol(const std::wstring& name) const\r
        {\r
-               if(name == "AMCP")\r
+               if(boost::iequals(name, L"AMCP"))\r
                        return make_safe<amcp::AMCPProtocolStrategy>(channels_);\r
-               else if(name == "CII")\r
+               else if(boost::iequals(name, L"CII"))\r
                        return make_safe<cii::CIIProtocolStrategy>(channels_);\r
-               else if(name == "CLOCK")\r
+               else if(boost::iequals(name, L"CLOCK"))\r
                        return make_safe<CLK::CLKProtocolStrategy>(channels_);\r
                \r
-               BOOST_THROW_EXCEPTION(caspar_exception() << arg_name_info("name") << arg_value_info(name) << msg_info("Invalid protocol"));\r
+               BOOST_THROW_EXCEPTION(caspar_exception() << arg_name_info("name") << arg_value_info(narrow(name)) << msg_info("Invalid protocol"));\r
        }\r
 };\r
 \r