\r
#include <common/env.h>\r
\r
+#include <core/mixer/mixer.h>\r
+\r
#include <boost/filesystem.hpp>\r
#include <boost/format.hpp>\r
+#include <boost/algorithm/string.hpp>\r
\r
-namespace caspar {\r
+namespace caspar { namespace flash {\r
\r
struct cg_producer::implementation : boost::noncopyable\r
{\r
: flash_producer_(frame_producer)\r
{}\r
\r
- void add(int layer, const std::wstring& filename, bool play_on_load, const std::wstring& label, const std::wstring& data)\r
+ void add(int layer, std::wstring filename, bool play_on_load, const std::wstring& label, const std::wstring& data)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking add-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Add\" returntype=\"xml\"><arguments><number>%1%</number><string>%2%</string>%3%<string>%4%</string><string><![CDATA[%5%]]></string></arguments></invoke>") % layer % filename % (play_on_load?TEXT("<true/>"):TEXT("<false/>")) % label % data).str());\r
+ if(filename.size() > 0 && filename[0] == L'/')\r
+ filename = filename.substr(1, filename.size()-1);\r
+\r
+ auto str = (boost::wformat(L"<invoke name=\"Add\" returntype=\"xml\"><arguments><number>%1%</number><string>%2%</string>%3%<string>%4%</string><string><![CDATA[%5%]]></string></arguments></invoke>") % layer % filename % (play_on_load?TEXT("<true/>"):TEXT("<false/>")) % label % data).str();\r
+\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking add-command:" << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void remove(int layer)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking remove-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Delete\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"Delete\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking remove-command:" << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void play(int layer)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking play-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Play\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"Play\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking play-command: " << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void stop(int layer, unsigned int)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking stop-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Stop\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><number>0</number></arguments></invoke>") % layer).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"Stop\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><number>0</number></arguments></invoke>") % layer).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking stop-command:" << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void next(int layer)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking next-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Next\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"Next\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array></arguments></invoke>") % layer).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking next-command:" << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void update(int layer, const std::wstring& data)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() <<" Invoking update-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"SetData\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><string><![CDATA[%2%]]></string></arguments></invoke>") % layer % data).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"SetData\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><string><![CDATA[%2%]]></string></arguments></invoke>") % layer % data).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() <<" Invoking update-command:" << str;\r
+ flash_producer_->param(str);\r
}\r
\r
void invoke(int layer, const std::wstring& label)\r
{\r
- CASPAR_LOG(info) << flash_producer_->print() << " Invoking invoke-command";\r
- flash_producer_->param((boost::wformat(L"<invoke name=\"Invoke\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><string>%2%</string></arguments></invoke>") % layer % label).str());\r
+ auto str = (boost::wformat(L"<invoke name=\"Invoke\" returntype=\"xml\"><arguments><array><property id=\"0\"><number>%1%</number></property></array><string>%2%</string></arguments></invoke>") % layer % label).str();\r
+ CASPAR_LOG(info) << flash_producer_->print() << " Invoking invoke-command: " << str;\r
+ flash_producer_->param(str);\r
}\r
\r
- safe_ptr<core::basic_frame> receive()\r
+ virtual safe_ptr<core::basic_frame> receive(int hints)\r
{\r
- return core::receive(flash_producer_);\r
+ return flash_producer_->receive(hints);\r
}\r
+\r
+ virtual safe_ptr<core::basic_frame> last_frame() const\r
+ {\r
+ return flash_producer_->last_frame();\r
+ } \r
\r
std::wstring print() const\r
{\r
\r
safe_ptr<cg_producer> get_default_cg_producer(const safe_ptr<core::video_channel>& video_channel, int render_layer)\r
{ \r
- auto flash_producer = video_channel->producer()->foreground(render_layer).get();\r
+ auto flash_producer = video_channel->stage()->foreground(render_layer);\r
\r
- if(flash_producer->print().find(L"flash") == std::string::npos)\r
+ if(flash_producer->print().find(L"flash[") == std::string::npos) // UGLY hack\r
{\r
- flash_producer = create_flash_producer(video_channel->mixer(), boost::assign::list_of(env::template_host())); \r
- video_channel->producer()->load(render_layer, flash_producer, true); \r
- video_channel->producer()->play(render_layer);\r
+ flash_producer = flash::create_producer(video_channel->mixer(), boost::assign::list_of<std::wstring>()); \r
+ video_channel->stage()->load(render_layer, flash_producer); \r
+ video_channel->stage()->play(render_layer);\r
}\r
\r
return make_safe<cg_producer>(flash_producer);\r
if(!boost::filesystem::exists(filename))\r
return core::frame_producer::empty();\r
\r
- auto flash_producer = create_flash_producer(frame_factory, boost::assign::list_of(env::template_host())); \r
+ boost::algorithm::replace_all(filename, L"\\", L"/");\r
+ boost::algorithm::replace_all(filename, L"//", L"/");\r
+ boost::algorithm::replace_all(filename, L"///", L"/");\r
+ \r
+ auto flash_producer = flash::create_producer(frame_factory, boost::assign::list_of<std::wstring>()); \r
auto producer = make_safe<cg_producer>(flash_producer);\r
producer->add(0, filename, 1);\r
\r
\r
cg_producer::cg_producer(const safe_ptr<core::frame_producer>& frame_producer) : impl_(new implementation(frame_producer)){}\r
cg_producer::cg_producer(cg_producer&& other) : impl_(std::move(other.impl_)){}\r
-safe_ptr<core::basic_frame> cg_producer::receive(){return impl_->receive();}\r
+safe_ptr<core::basic_frame> cg_producer::receive(int hints){return impl_->receive(hints);}\r
+safe_ptr<core::basic_frame> cg_producer::last_frame() const{return impl_->last_frame();}\r
void cg_producer::add(int layer, const std::wstring& template_name, bool play_on_load, const std::wstring& startFromLabel, const std::wstring& data){impl_->add(layer, template_name, play_on_load, startFromLabel, data);}\r
void cg_producer::remove(int layer){impl_->remove(layer);}\r
void cg_producer::play(int layer){impl_->play(layer);}\r
void cg_producer::invoke(int layer, const std::wstring& label){impl_->invoke(layer, label);}\r
std::wstring cg_producer::print() const{return impl_->print();}\r
\r
-}
\ No newline at end of file
+}}
\ No newline at end of file