]> git.sesse.net Git - casparcg/blobdiff - core/server.cpp
2.0.0.2:
[casparcg] / core / server.cpp
index e0d4dcc9f1332a5aedeeacc5cfc4de87b7d124f2..3e62f131ec339ae6ca5b4abbc2208dc3f3e6d83c 100644 (file)
@@ -1,24 +1,21 @@
 #include "StdAfx.h"\r
 \r
 #include "server.h"\r
+#include "channel.h"\r
 \r
-#include "consumer/oal/oal_frame_consumer.h"\r
+#include "consumer/oal/oal_consumer.h"\r
 #ifndef DISABLE_BLUEFISH\r
-#include "consumer/bluefish/BlueFishVideoConsumer.h"\r
+#include "consumer/bluefish/bluefish_consumer.h"\r
 #endif\r
 #include "consumer/decklink/DecklinkVideoConsumer.h"\r
-#include "consumer/ogl/ogl_frame_consumer.h"\r
-\r
-#include <FreeImage.h>\r
+#include "consumer/ogl/ogl_consumer.h"\r
 \r
 #include "protocol/amcp/AMCPProtocolStrategy.h"\r
 #include "protocol/cii/CIIProtocolStrategy.h"\r
 #include "protocol/CLK/CLKProtocolStrategy.h"\r
 #include "producer/flash/FlashAxContainer.h"\r
-#include "protocol/monitor/Monitor.h"\r
 \r
 #include "../common/io/AsyncEventServer.h"\r
-#include "../common/io/SerialPort.h"\r
 #include "../common/utility/string_convert.h"\r
 \r
 #include <boost/algorithm/string.hpp>\r
 #include <boost/property_tree/ptree.hpp>\r
 #include <boost/property_tree/xml_parser.hpp>\r
 \r
-namespace caspar{\r
+#include "producer/frame_producer_device.h"\r
+#include "consumer/frame_consumer_device.h"\r
+#include "processor/frame_processor_device.h"\r
+\r
+namespace caspar { namespace core {\r
 \r
 struct server::implementation : boost::noncopyable\r
 {\r
        implementation()                                                                                                \r
-       {\r
-               FreeImage_Initialise(true);     \r
-                               \r
+       {                       \r
                boost::property_tree::ptree pt;\r
                boost::property_tree::read_xml(boost::filesystem::initial_path().file_string() + "\\caspar.config", pt);\r
 \r
@@ -48,9 +47,7 @@ struct server::implementation : boost::noncopyable
        }\r
 \r
        ~implementation()\r
-       {               \r
-               FreeImage_DeInitialise();\r
-               serial_ports_.clear();\r
+       {                               \r
                async_servers_.clear();\r
                channels_.clear();\r
        }\r
@@ -99,16 +96,16 @@ struct server::implementation : boost::noncopyable
                                                        stretch = ogl::stretch::uniform_to_fill;\r
 \r
                                                bool windowed = xml_consumer.second.get("windowed", false);\r
-                                               pConsumer = std::make_shared<ogl::ogl_frame_consumer>(format_desc, device, stretch, windowed);\r
+                                               pConsumer = std::make_shared<ogl::consumer>(format_desc, device, stretch, windowed);\r
                                        }\r
                                #ifndef DISABLE_BLUEFISH\r
-                                       else if(name == "bluefish")\r
-                                               pConsumer = caspar::bluefish::BlueFishVideoConsumer::Create(format_desc, xml_consumer.second.get("device", 0));\r
+                                       else if(name == "bluefish")                                     \r
+                                               pConsumer = std::make_shared<bluefish::consumer>(format_desc, xml_consumer.second.get("device", 0), xml_consumer.second.get("embedded-audio", false));                                  \r
                                #endif\r
                                        else if(name == "decklink")\r
                                                pConsumer = std::make_shared<decklink::DecklinkVideoConsumer>(format_desc, xml_consumer.second.get("internalkey", false));\r
                                        else if(name == "audio")\r
-                                               pConsumer = std::make_shared<audio::oal_frame_consumer>(format_desc);\r
+                                               pConsumer = std::make_shared<oal::consumer>(format_desc);\r
 \r
                                        if(pConsumer)                                   \r
                                                consumers.push_back(pConsumer);                                 \r
@@ -119,7 +116,10 @@ struct server::implementation : boost::noncopyable
                                }\r
                        }\r
                        \r
-                       channels_.push_back(std::make_shared<renderer::render_device>(format_desc, channels_.size() + 1, consumers));\r
+                       auto processor_device = std::make_shared<frame_processor_device>(format_desc);\r
+                       auto producer_device = std::make_shared<frame_producer_device>(processor_device);\r
+                       auto consumer_device = std::make_shared<frame_consumer_device>(processor_device, format_desc, consumers);\r
+                       channels_.push_back(std::make_shared<channel>(producer_device, processor_device, consumer_device));\r
                }\r
        }\r
                \r
@@ -137,35 +137,16 @@ struct server::implementation : boost::noncopyable
                                {                                       \r
                                        unsigned int port = xml_controller.second.get<unsigned int>("port");\r
                                        port = port != 0 ? port : 5250;\r
-                                       auto asyncserver = std::make_shared<caspar::IO::AsyncEventServer>(create_protocol(protocol), port);\r
-                                       asyncserver->SetClientDisconnectHandler(std::tr1::bind(&Monitor::ClearListener, std::tr1::placeholders::_1));\r
+                                       auto asyncserver = std::make_shared<IO::AsyncEventServer>(create_protocol(protocol), port);\r
                                        asyncserver->Start();\r
                                        async_servers_.push_back(asyncserver);\r
                                }\r
-                               else if(name == "serialcontroller")\r
-                               {\r
-                                       std::wstring portName = common::widen(xml_controller.second.get<std::string>("port-name"));                                             \r
-                                       unsigned int baudRate = xml_controller.second.get<unsigned int>("baud-rate");\r
-                                       unsigned int dataBits = xml_controller.second.get<unsigned int>("data-bits");\r
-                                       unsigned int parity = xml_controller.second.get<unsigned int>("parity");\r
-                                       unsigned int stopBits = xml_controller.second.get<unsigned int>("stop-bits");\r
-\r
-                                       baudRate =      baudRate        != 0 ? baudRate : 19200;\r
-                                       dataBits =      dataBits        != 0 ? dataBits : 8;\r
-                                       parity =        parity          != 0 ? parity   : NOPARITY;\r
-                                       stopBits =      stopBits        != 0 ? stopBits : ONESTOPBIT;\r
-                                       \r
-                                       auto serialPort = std::make_shared<IO::SerialPort>(create_protocol(protocol), baudRate, parity, dataBits, stopBits, portName, xml_controller.second.get("spy", false));\r
-                                       serialPort->Start();\r
-                                       serial_ports_.push_back(serialPort);\r
-                               }\r
                                else\r
                                        BOOST_THROW_EXCEPTION(invalid_configuration() << arg_name_info(name) << msg_info("Invalid controller"));\r
                        }\r
                        catch(...)\r
                        {\r
                                CASPAR_LOG_CURRENT_EXCEPTION();\r
-                               throw;\r
                        }\r
                }\r
        }\r
@@ -182,10 +163,9 @@ struct server::implementation : boost::noncopyable
                BOOST_THROW_EXCEPTION(invalid_configuration() << arg_name_info("name") << arg_value_info(name) << msg_info("Invalid protocol"));\r
        }\r
 \r
-       std::vector<IO::SerialPortPtr> serial_ports_;\r
        std::vector<IO::AsyncEventServerPtr> async_servers_;\r
-\r
-       std::vector<renderer::render_device_ptr> channels_;\r
+       \r
+       std::vector<channel_ptr> channels_;\r
 \r
        int logLevel_;\r
 \r
@@ -226,6 +206,8 @@ const std::wstring& server::data_folder()
        return server::implementation::data_folder_;\r
 }\r
 \r
-const std::vector<renderer::render_device_ptr>& server::get_channels() const{ return impl_->channels_; }\r
-\r
-}
\ No newline at end of file
+const std::vector<channel_ptr> server::get_channels() const\r
+{\r
+       return impl_->channels_;\r
+}\r
+}}
\ No newline at end of file