\r
#include "color_producer.h"\r
\r
-#include "../frame_producer.h"\r
-#include "../../frame/draw_frame.h"\r
-#include "../../frame/frame_factory.h"\r
-#include "../../frame/pixel_format.h"\r
-#include "../../mixer/write_frame.h"\r
+#include <core/producer/frame_producer.h>\r
+#include <core/frame/frame.h>\r
+#include <core/frame/draw_frame.h>\r
+#include <core/frame/frame_factory.h>\r
+#include <core/frame/pixel_format.h>\r
+#include <core/monitor/monitor.h>\r
\r
-#include <common/exception/exceptions.h>\r
+#include <common/except.h>\r
+#include <common/array.h>\r
\r
#include <boost/algorithm/string.hpp>\r
\r
\r
namespace caspar { namespace core {\r
\r
-class color_producer : public frame_producer\r
+class color_producer : public frame_producer_impl\r
{\r
- safe_ptr<draw_frame> frame_;\r
- const std::wstring color_str_;\r
+ monitor::basic_subject event_subject_;\r
+\r
+ draw_frame frame_;\r
+ const std::wstring color_str_;\r
\r
public:\r
- explicit color_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& color) \r
+ explicit color_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& color) \r
: color_str_(color)\r
, frame_(create_color_frame(this, frame_factory, color))\r
- {}\r
+ {\r
+ CASPAR_LOG(info) << print() << L" Initialized";\r
+ }\r
\r
// frame_producer\r
\r
- virtual safe_ptr<draw_frame> receive(int) override\r
+ draw_frame receive_impl() override\r
{\r
- return frame_;\r
- } \r
+ event_subject_ << monitor::event("color") % color_str_;\r
\r
- virtual safe_ptr<draw_frame> last_frame() const override\r
- {\r
- return frame_; \r
+ return frame_;\r
} \r
-\r
- virtual std::wstring print() const override\r
+ \r
+ std::wstring print() const override\r
{\r
return L"color[" + color_str_ + L"]";\r
}\r
\r
+ std::wstring name() const override\r
+ {\r
+ return L"color";\r
+ }\r
+ \r
boost::property_tree::wptree info() const override\r
{\r
boost::property_tree::wptree info;\r
- info.add(L"type", L"color-producer");\r
+ info.add(L"type", L"color");\r
info.add(L"color", color_str_);\r
return info;\r
}\r
+\r
+ void subscribe(const monitor::observable::observer_ptr& o) override \r
+ {\r
+ return event_subject_.subscribe(o);\r
+ }\r
+\r
+ void unsubscribe(const monitor::observable::observer_ptr& o) override \r
+ {\r
+ return event_subject_.unsubscribe(o);\r
+ }\r
};\r
\r
std::wstring get_hex_color(const std::wstring& str)\r
return str;\r
}\r
\r
-safe_ptr<frame_producer> create_color_producer(const safe_ptr<frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
+spl::shared_ptr<frame_producer> create_color_producer(const spl::shared_ptr<frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
{\r
if(params.size() < 0)\r
return core::frame_producer::empty();\r
if(color2.length() != 9 || color2[0] != '#')\r
return core::frame_producer::empty();\r
\r
- return create_producer_print_proxy(\r
- make_safe<color_producer>(frame_factory, color2));\r
+ return spl::make_shared<color_producer>(frame_factory, color2);\r
}\r
-safe_ptr<write_frame> create_color_frame(void* tag, const safe_ptr<frame_factory>& frame_factory, const std::wstring& color)\r
+\r
+draw_frame create_color_frame(void* tag, const spl::shared_ptr<frame_factory>& frame_factory, const std::wstring& color)\r
{\r
auto color2 = get_hex_color(color);\r
if(color2.length() != 9 || color2[0] != '#')\r
BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(color2) << msg_info("Invalid color."));\r
\r
- core::pixel_format_desc desc;\r
- desc.pix_fmt = pixel_format::bgra;\r
+ core::pixel_format_desc desc(pixel_format::bgra);\r
desc.planes.push_back(core::pixel_format_desc::plane(1, 1, 4));\r
auto frame = frame_factory->create_frame(tag, desc);\r
\r
// Read color from hex-string and write to frame pixel.\r
\r
- auto& value = *reinterpret_cast<uint32_t*>(frame->image_data().begin());\r
+ auto& value = *reinterpret_cast<uint32_t*>(frame.image_data(0).begin());\r
std::wstringstream str(color2.substr(1));\r
if(!(str >> std::hex >> value) || !str.eof())\r
BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("color") << arg_value_info(color2) << msg_info("Invalid color."));\r
-\r
- frame->commit();\r
- \r
- return frame;\r
+ \r
+ return core::draw_frame(std::move(frame));\r
}\r
\r
}}
\ No newline at end of file