2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
4 * This file is part of CasparCG (www.casparcg.com).
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
19 * Author: Helge Norberg, helge.norberg@svt.se
22 #include "../../StdAfx.h"
24 #include "scene_cg_proxy.h"
26 #include <core/producer/frame_producer.h>
28 #include <boost/property_tree/ptree.hpp>
29 #include <boost/property_tree/xml_parser.hpp>
34 namespace caspar { namespace core { namespace scene {
36 struct scene_cg_proxy::impl
38 spl::shared_ptr<frame_producer> producer_;
40 impl(spl::shared_ptr<frame_producer> producer)
41 : producer_(std::move(producer))
46 scene_cg_proxy::scene_cg_proxy(spl::shared_ptr<frame_producer> producer)
47 : impl_(new impl(std::move(producer)))
51 void scene_cg_proxy::add(
53 const std::wstring& template_name,
55 const std::wstring& start_from_label,
56 const std::wstring& data)
64 void scene_cg_proxy::remove(int layer)
66 impl_->producer_->call({ L"remove()" });
69 void scene_cg_proxy::play(int layer)
71 impl_->producer_->call({ L"play()", L"intro" });
74 void scene_cg_proxy::stop(int layer, unsigned int mix_out_duration)
76 impl_->producer_->call({ L"play()", L"outro" });
79 void scene_cg_proxy::next(int layer)
81 impl_->producer_->call({ L"next()" });
84 void scene_cg_proxy::update(int layer, const std::wstring& data)
89 std::wstringstream stream(data);
90 boost::property_tree::wptree root;
91 boost::property_tree::read_xml(
94 boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments);
96 std::vector<std::wstring> parameters;
98 for (auto value : root.get_child(L"templateData"))
100 auto id = value.second.get<std::wstring>(L"<xmlattr>.id");
101 auto val = value.second.get<std::wstring>(L"data.<xmlattr>.value");
103 parameters.push_back(std::move(id));
104 parameters.push_back(std::move(val));
107 impl_->producer_->call(parameters);
110 std::wstring scene_cg_proxy::invoke(int layer, const std::wstring& label)
112 if (boost::ends_with(label, L")"))
113 return impl_->producer_->call({ L"play()", label.substr(0, label.find(L"(")) }).get();
115 return impl_->producer_->call({ L"play()", label }).get();
118 std::wstring scene_cg_proxy::description(int layer)
120 return L"<scene producer />";
123 std::wstring scene_cg_proxy::template_host_info()
125 return L"<scene producer />";