*\r
* Author: Robert Nagy, ronag89@gmail.com\r
*/\r
-\r
+#include "stdafx.h"\r
\r
#include "server.h"\r
\r
+#include <accelerator/accelerator.h>\r
+\r
#include <common/env.h>\r
-#include <common/exception/exceptions.h>\r
-#include <common/utility/string.h>\r
+#include <common/except.h>\r
+#include <common/utf.h>\r
\r
-#include <core/mixer/gpu/ogl_device.h>\r
#include <core/video_channel.h>\r
+#include <core/video_format.h>\r
#include <core/producer/stage.h>\r
#include <core/consumer/output.h>\r
\r
#include <modules/ffmpeg/ffmpeg.h>\r
#include <modules/flash/flash.h>\r
#include <modules/oal/oal.h>\r
-#include <modules/ogl/ogl.h>\r
-#include <modules/silverlight/silverlight.h>\r
+#include <modules/screen/screen.h>\r
#include <modules/image/image.h>\r
\r
#include <modules/oal/consumer/oal_consumer.h>\r
#include <modules/bluefish/consumer/bluefish_consumer.h>\r
#include <modules/decklink/consumer/decklink_consumer.h>\r
-#include <modules/ogl/consumer/ogl_consumer.h>\r
+#include <modules/screen/consumer/screen_consumer.h>\r
#include <modules/ffmpeg/consumer/ffmpeg_consumer.h>\r
\r
#include <protocol/amcp/AMCPProtocolStrategy.h>\r
using namespace core;\r
using namespace protocol;\r
\r
-struct server::implementation : boost::noncopyable\r
+struct server::impl : boost::noncopyable\r
{\r
- safe_ptr<ogl_device> ogl_;\r
- std::vector<safe_ptr<IO::AsyncEventServer>> async_servers_; \r
- std::vector<safe_ptr<video_channel>> channels_;\r
+ monitor::basic_subject event_subject_;\r
+ accelerator::accelerator accelerator_;\r
+ std::vector<spl::shared_ptr<IO::AsyncEventServer>> async_servers_; \r
+ std::vector<spl::shared_ptr<video_channel>> channels_;\r
+\r
+ impl() \r
+ : accelerator_(env::properties().get(L"configuration.accelerator", L"auto"))\r
+ { \r
\r
- implementation() \r
- : ogl_(ogl_device::create())\r
- { \r
ffmpeg::init();\r
CASPAR_LOG(info) << L"Initialized ffmpeg module.";\r
\r
oal::init(); \r
CASPAR_LOG(info) << L"Initialized oal module.";\r
\r
- ogl::init(); \r
+ screen::init(); \r
CASPAR_LOG(info) << L"Initialized ogl module.";\r
\r
image::init(); \r
CASPAR_LOG(info) << L"Initialized controllers.";\r
}\r
\r
- ~implementation()\r
+ ~impl()\r
{ \r
- ffmpeg::uninit();\r
-\r
async_servers_.clear();\r
channels_.clear();\r
+\r
+ Sleep(500); // HACK: Wait for asynchronous destruction of producers and consumers.\r
+\r
+ image::uninit();\r
+ ffmpeg::uninit();\r
}\r
\r
void setup_channels(const boost::property_tree::wptree& pt)\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(xml_channel.second.get(L"video-mode", L"PAL")); \r
+ auto format_desc = video_format_desc(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(make_safe<video_channel>(channels_.size()+1, format_desc, ogl_));\r
+ auto channel = spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), format_desc, accelerator_.create_image_mixer());\r
\r
BOOST_FOREACH(auto& xml_consumer, xml_channel.second.get_child(L"consumers"))\r
{\r
{\r
auto name = xml_consumer.first;\r
if(name == L"screen")\r
- channels_.back()->output()->add(ogl::create_consumer(xml_consumer.second)); \r
+ channel->output().add(caspar::screen::create_consumer(xml_consumer.second)); \r
else if(name == L"bluefish") \r
- channels_.back()->output()->add(bluefish::create_consumer(xml_consumer.second)); \r
+ channel->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
+ channel->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
+ channel->output().add(ffmpeg::create_consumer(xml_consumer.second)); \r
else if(name == L"system-audio")\r
- channels_.back()->output()->add(oal::create_consumer()); \r
+ channel->output().add(oal::create_consumer()); \r
else if(name != L"<xmlcomment>")\r
CASPAR_LOG(warning) << "Invalid consumer: " << name; \r
}\r
{\r
CASPAR_LOG_CURRENT_EXCEPTION();\r
}\r
- } \r
+ } \r
+\r
+ channel->subscribe(monitor::observable::observer_ptr(event_subject_));\r
+ channels_.push_back(channel);\r
}\r
+\r
+ // Dummy diagnostics channel\r
+ if(env::properties().get(L"configuration.channel-grid", false))\r
+ channels_.push_back(spl::make_shared<video_channel>(static_cast<int>(channels_.size()+1), core::video_format_desc(core::video_format::x576p2500), accelerator_.create_image_mixer()));\r
}\r
\r
void setup_controllers(const boost::property_tree::wptree& pt)\r
if(name == L"tcp")\r
{ \r
unsigned int port = xml_controller.second.get(L"port", 5250);\r
- auto asyncbootstrapper = make_safe<IO::AsyncEventServer>(create_protocol(protocol), port);\r
+ auto asyncbootstrapper = spl::make_shared<IO::AsyncEventServer>(create_protocol(protocol), port);\r
asyncbootstrapper->Start();\r
async_servers_.push_back(asyncbootstrapper);\r
}\r
}\r
}\r
\r
- safe_ptr<IO::IProtocolStrategy> create_protocol(const std::wstring& name) const\r
+ spl::shared_ptr<IO::IProtocolStrategy> create_protocol(const std::wstring& name) const\r
{\r
if(boost::iequals(name, L"AMCP"))\r
- return make_safe<amcp::AMCPProtocolStrategy>(channels_);\r
+ return spl::make_shared<amcp::AMCPProtocolStrategy>(channels_);\r
else if(boost::iequals(name, L"CII"))\r
- return make_safe<cii::CIIProtocolStrategy>(channels_);\r
+ return spl::make_shared<cii::CIIProtocolStrategy>(channels_);\r
else if(boost::iequals(name, L"CLOCK"))\r
- return make_safe<CLK::CLKProtocolStrategy>(channels_);\r
+ return spl::make_shared<CLK::CLKProtocolStrategy>(channels_);\r
\r
- BOOST_THROW_EXCEPTION(caspar_exception() << warg_name_info(L"name") << warg_value_info(name) << wmsg_info(L"Invalid protocol"));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << arg_name_info(L"name") << arg_value_info(name) << msg_info(L"Invalid protocol"));\r
}\r
};\r
\r
-server::server() : impl_(new implementation()){}\r
+server::server() : impl_(new impl()){}\r
\r
-const std::vector<safe_ptr<video_channel>> server::get_channels() const\r
+const std::vector<spl::shared_ptr<video_channel>> server::channels() const\r
{\r
return impl_->channels_;\r
}\r
+void server::subscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.subscribe(o);}\r
+void server::unsubscribe(const monitor::observable::observer_ptr& o){impl_->event_subject_.unsubscribe(o);}\r
\r
}
\ No newline at end of file