]> git.sesse.net Git - casparcg/blobdiff - shell/server.cpp
2.0.2: Fixed CINF command.
[casparcg] / shell / server.cpp
index 68b77ab235265064c6969f272fa85b5e474f00c2..18a08461af183bbe50a6c4c0dedea6dbdd9485e3 100644 (file)
@@ -1,10 +1,33 @@
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+*  This file is part of CasparCG.\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
+*\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
+*/\r
+\r
 #include "server.h"\r
 \r
 #include <common/env.h>\r
 #include <common/exception/exceptions.h>\r
 #include <common/utility/string.h>\r
 \r
-#include <core/channel.h>\r
+#include <core/mixer/gpu/ogl_device.h>\r
+#include <core/video_channel.h>\r
+#include <core/producer/stage.h>\r
+#include <core/consumer/output.h>\r
 \r
 #include <modules/bluefish/bluefish.h>\r
 #include <modules/decklink/decklink.h>\r
@@ -28,7 +51,6 @@
 \r
 #include <boost/algorithm/string.hpp>\r
 #include <boost/lexical_cast.hpp>\r
-#include <boost/filesystem.hpp>\r
 #include <boost/foreach.hpp>\r
 #include <boost/property_tree/ptree.hpp>\r
 #include <boost/property_tree/xml_parser.hpp>\r
@@ -40,26 +62,29 @@ using namespace protocol;
 \r
 struct server::implementation : boost::noncopyable\r
 {\r
+       ogl_device                                                                      ogl_;\r
        std::vector<safe_ptr<IO::AsyncEventServer>> async_servers_;     \r
-       std::vector<safe_ptr<channel>> channels_;\r
+       std::vector<safe_ptr<video_channel>>            channels_;\r
 \r
        implementation()                                                                                                \r
        {                       \r
-               init_ffmpeg();\r
-               init_bluefish();\r
-               init_decklink();\r
-               init_flash();\r
-               init_oal();\r
-               init_ogl();\r
-               init_silverlight();\r
-               init_image();\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
 \r
                setup_channels(env::properties());\r
                setup_controllers(env::properties());\r
        }\r
 \r
        ~implementation()\r
-       {                               \r
+       {               \r
+               ffmpeg::uninit();\r
+\r
                async_servers_.clear();\r
                channels_.clear();\r
        }\r
@@ -69,43 +94,30 @@ struct server::implementation : boost::noncopyable
                using boost::property_tree::ptree;\r
                BOOST_FOREACH(auto& xml_channel, pt.get_child("configuration.channels"))\r
                {               \r
-                       auto format_desc = video_format_desc::get(widen(xml_channel.second.get("videomode", "PAL")));           \r
+                       auto format_desc = video_format_desc::get(widen(xml_channel.second.get("video-mode", "PAL")));          \r
                        if(format_desc.format == video_format::invalid)\r
-                               BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid videomode."));\r
+                               BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Invalid video-mode."));\r
                        \r
-                       channels_.push_back(channel(channels_.size(), format_desc));\r
+                       channels_.push_back(video_channel(channels_.size(), format_desc, ogl_));\r
                        \r
                        int index = 0;\r
                        BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child("consumers"))\r
                        {\r
                                try\r
                                {\r
-                                       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
+                                       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()->consumer()->add(index++, bluefish_consumer(xml_consumer.second.get("device", 0), \r
-                                                                                                                                                                       xml_consumer.second.get("embedded-audio", true)));                                      \r
-                                       else if(name == "decklink")\r
-                                               channels_.back()->consumer()->add(index++, decklink_consumer(xml_consumer.second.get("device", 0), \r
-                                                                                                                                                                       xml_consumer.second.get("embedded-audio", true), \r
-                                                                                                                                                                       xml_consumer.second.get("internal-key", false)));\r
-                                       else if(name == "audio")\r
-                                               channels_.back()->consumer()->add(index++, oal_consumer());                     \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
+                                               CASPAR_LOG(warning) << "Invalid consumer: " << widen(name);     \r
                                }\r
                                catch(...)\r
                                {\r
@@ -133,7 +145,7 @@ struct server::implementation : boost::noncopyable
                                        async_servers_.push_back(asyncbootstrapper);\r
                                }\r
                                else\r
-                                       BOOST_THROW_EXCEPTION(invalid_bootstrapper() << arg_name_info(name) << msg_info("Invalid controller."));\r
+                                       CASPAR_LOG(warning) << "Invalid controller: " << widen(name);   \r
                        }\r
                        catch(...)\r
                        {\r
@@ -151,13 +163,13 @@ struct server::implementation : boost::noncopyable
                else if(name == "CLOCK")\r
                        return make_safe<CLK::CLKProtocolStrategy>(channels_);\r
                \r
-               BOOST_THROW_EXCEPTION(invalid_bootstrapper() << 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(name) << msg_info("Invalid protocol"));\r
        }\r
 };\r
 \r
 server::server() : impl_(new implementation()){}\r
 \r
-const std::vector<safe_ptr<channel>> server::get_channels() const\r
+const std::vector<safe_ptr<video_channel>> server::get_channels() const\r
 {\r
        return impl_->channels_;\r
 }\r