void GpiOutputCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setGpoPort(pt.get(L"gpoport", GpiOutput::DEFAULT_PORT)); setTriggerOnNext(pt.get(L"triggeronnext", GpiOutput::DEFAULT_TRIGGER_ON_NEXT)); }
void MacroCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setMacro(QString::fromStdWString(pt.get(L"macro", TriCaster::DEFAULT_MACRO.toStdWString()))); setTriggerOnNext(pt.get(L"triggeronnext", TriCaster::DEFAULT_TRIGGER_ON_NEXT)); }
void RouteVideolayerCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setFromChannel(pt.get(L"fromchannel", Route::DEFAULT_FROM_CHANNEL)); setFromVideolayer(pt.get(L"fromvideolayer", Route::DEFAULT_FROM_VIDEOLAYER)); }
void AtemAudioGainCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setInput(QString::fromStdWString(pt.get(L"audiogaininput", Atem::DEFAULT_AUDIO_INPUT.toStdWString()))); setGain(pt.get(L"gain", Atem::DEFAULT_AUDIO_GAIN)); setTriggerOnNext(pt.get(L"triggeronnext", Atem::DEFAULT_TRIGGER_ON_NEXT)); }
void AbstractCommand::readProperties(boost::property_tree::wptree& pt) { if (pt.count(L"channel") > 0) setChannel(pt.get<int>(L"channel")); if (pt.count(L"videolayer") > 0) setVideolayer(pt.get<int>(L"videolayer")); if (pt.count(L"delay") > 0) setDelay(pt.get<int>(L"delay")); if (pt.count(L"allowgpi") > 0) setAllowGpi(pt.get<bool>(L"allowgpi")); if (pt.count(L"allowremotetriggering") > 0) setAllowRemoteTriggering(pt.get<bool>(L"allowremotetriggering")); }
void AtemAudioInputStateCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setInput(QString::fromStdWString(pt.get(L"audioinput", Atem::DEFAULT_AUDIO_INPUT.toStdWString()))); setState(QString::fromStdWString(pt.get(L"state", Atem::DEFAULT_AUDIO_INPUT_STATE.toStdWString()))); setTriggerOnNext(pt.get(L"triggeronnext", Atem::DEFAULT_TRIGGER_ON_NEXT)); }
void GridCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setGrid(pt.get(L"grid", Mixer::DEFAULT_GRID)); setTransitionDuration(pt.get(L"transitionDuration", Mixer::DEFAULT_DURATION)); setTween(QString::fromStdWString(pt.get(L"tween", Mixer::DEFAULT_TWEEN.toStdWString()))); setDefer(pt.get(L"defer", Mixer::DEFAULT_DEFER)); }
void convert(const boost::property_tree::wptree & in, boost::property_tree::ptree & out) { out.data() = utf8(in.data()); for(boost::property_tree::wptree::const_iterator i = in.begin(), end = in.end(); i != end; ++i) { out.push_back(boost::property_tree::ptree::value_type(utf8(i->first), boost::property_tree::ptree())); convert(i->second, out.back().second); } }
void OpacityCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"opacity") > 0) setOpacity(pt.get<float>(L"opacity")); if (pt.count(L"duration") > 0) setDuration(pt.get<int>(L"duration")); if (pt.count(L"tween") > 0) setTween(QString::fromStdWString(pt.get<std::wstring>(L"tween"))); if (pt.count(L"defer") > 0) setDefer(pt.get<bool>(L"defer")); }
void SolidColorCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"transition") > 0) setTransition(QString::fromStdWString(pt.get<std::wstring>(L"transition"))); if (pt.count(L"duration") > 0) setDuration(pt.get<int>(L"duration")); if (pt.count(L"tween") > 0) setTween(QString::fromStdWString(pt.get<std::wstring>(L"tween"))); if (pt.count(L"direction") > 0) setDirection(QString::fromStdWString(pt.get<std::wstring>(L"direction"))); if (pt.count(L"solidcolor") > 0) setColor(QString::fromStdWString(pt.get<std::wstring>(L"solidcolor"))); }
void ChromaCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"chromablur") > 0) setSpread(pt.get<float>(L"chromablur")); if (pt.count(L"chromakey") > 0) setKey(QString::fromStdWString(pt.get<std::wstring>(L"chromakey"))); if (pt.count(L"chromasoftness") > 0) setSpread(pt.get<float>(L"chromasoftness")); if (pt.count(L"chromaspill") > 0) setSpill(pt.get<float>(L"chromaspill")); if (pt.count(L"chromathreshold") > 0) setThreshold(pt.get<float>(L"chromathreshold")); setShowMask(false); }
void HttpPostCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setUrl(QString::fromStdWString(pt.get(L"url", Http::DEFAULT_URL.toStdWString()))); setTriggerOnNext(pt.get(L"triggeronnext", Http::DEFAULT_TRIGGER_ON_NEXT)); if (pt.count(L"httpdata") > 0) { BOOST_FOREACH(const boost::property_tree::wptree::value_type& value, pt.get_child(L"httpdata")) { this->models.push_back(KeyValueModel(QString::fromStdWString(value.second.get<std::wstring>(L"key")), QString::fromStdWString(value.second.get<std::wstring>(L"value")))); } }
void read_xml(std::istream & inp, boost::property_tree::wptree & out) { out.clear(); boost::property_tree::ptree temp; boost::property_tree::read_xml(inp, temp); cleanup(temp); convert(temp, out); }
safe_ptr<core::frame_consumer> create_ivga_consumer(const boost::property_tree::wptree& ptree) { const auto channel_layout = core::default_channel_layout_repository() .get_by_name( boost::to_upper_copy(ptree.get(L"channel-layout", L"STEREO"))); return make_safe<newtek_ivga_consumer>(channel_layout); }
void AudioCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setTransition(QString::fromStdWString(pt.get(L"transition", Mixer::DEFAULT_TRANSITION.toStdWString()))); setTransitionDuration(pt.get(L"transitionDuration", Mixer::DEFAULT_DURATION)); setTween(QString::fromStdWString(pt.get(L"tween", Mixer::DEFAULT_TWEEN.toStdWString()))); setDirection(QString::fromStdWString(pt.get(L"direction", Mixer::DEFAULT_DIRECTION.toStdWString()))); setLoop(pt.get(L"loop", Audio::DEFAULT_LOOP)); setUseAuto(pt.get(L"useauto", Audio::DEFAULT_USE_AUTO)); setTriggerOnNext(pt.get(L"triggeronnext", Audio::DEFAULT_TRIGGER_ON_NEXT)); }
void SolidColorCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setTransition(QString::fromStdWString(pt.get(L"transition", Mixer::DEFAULT_TRANSITION.toStdWString()))); setTransitionDuration(pt.get(L"transtitionDuration", Mixer::DEFAULT_DURATION)); setTween(QString::fromStdWString(pt.get(L"tween", Mixer::DEFAULT_TWEEN.toStdWString()))); setDirection(QString::fromStdWString(pt.get(L"direction", Mixer::DEFAULT_DIRECTION.toStdWString()))); setColor(QString::fromStdWString(pt.get(L"solidcolor", SolidColor::DEFAULT_COLOR.toStdWString()))); setUseAuto(pt.get(L"useauto", SolidColor::DEFAULT_USE_AUTO)); setTriggerOnNext(pt.get(L"triggeronnext", SolidColor::DEFAULT_TRIGGER_ON_NEXT)); }
void CropCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"cropleft") > 0) setCropLeft(pt.get<float>(L"cropleft")); if (pt.count(L"cropright") > 0) setCropRight(pt.get<float>(L"cropright")); if (pt.count(L"croptop") > 0) setCropTop(pt.get<float>(L"croptop")); if (pt.count(L"cropbottom") > 0) setCropBottom(pt.get<float>(L"cropbottom")); if (pt.count(L"duration") > 0) setDuration(pt.get<int>(L"duration")); if (pt.count(L"tween") > 0) setTween(QString::fromStdWString(pt.get<std::wstring>(L"tween"))); if (pt.count(L"defer") > 0) setDefer(pt.get<bool>(L"defer")); }
void LevelsCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); setMinIn(pt.get(L"minin", Mixer::DEFAULT_LEVELS_MIN_IN)); setMaxIn(pt.get(L"maxin", Mixer::DEFAULT_LEVELS_MAX_IN)); setMinOut(pt.get(L"minout", Mixer::DEFAULT_LEVELS_MIN_OUT)); setMaxOut(pt.get(L"maxout", Mixer::DEFAULT_LEVELS_MAX_OUT)); setGamma(pt.get(L"gamma", Mixer::DEFAULT_LEVELS_GAMMA)); setTransitionDuration(pt.get(L"transtitionDuration", Mixer::DEFAULT_DURATION)); setTween(QString::fromStdWString(pt.get(L"tween", Mixer::DEFAULT_TWEEN.toStdWString()))); setDefer(pt.get(L"defer", Mixer::DEFAULT_DEFER)); }
void json_write_w::write_string_data(boost::property_tree::wptree& p, std::wstring tag, std::wstring data) { p.put(tag, data); }
namespace caspar { namespace env { namespace fs = boost::filesystem; std::wstring media; std::wstring log; std::wstring ftemplate; std::wstring data; std::wstring thumbnails; boost::property_tree::wptree pt; void check_is_configured() { if(pt.empty()) BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured")); } void configure(const std::wstring& filename) { try { auto separator = boost::filesystem::path::preferred_separator; auto initialPath = fs::initial_path<fs::path>().wstring(); std::wstring path_(initialPath + boost::lexical_cast<std::wstring>(separator) + filename); const wchar_t *pstr = path_.c_str(); std::wifstream file(reinterpret_cast<const char *>(pstr)); CASPAR_LOG(info) << L"before read_xml ..." << initialPath << " " << filename << " " << pstr; boost::property_tree::read_xml("/etc/casparcg.config", pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments); CASPAR_LOG(info) << L"read_xml done..."; auto paths = pt.get_child(L"configuration.paths"); media = widen(paths.get(L"media-path", initialPath + L"/media/")); log = widen(paths.get(L"log-path", initialPath + L"/log/")); ftemplate = fs::complete(fs::path(widen(paths.get(L"template-path", initialPath + L"/template/")))).wstring(); data = widen(paths.get(L"data-path", initialPath + L"/data/")); thumbnails = widen(paths.get(L"thumbnails-path", initialPath + L"/thumbnails/")); //Make sure that all paths have a trailing backslash if(media.at(media.length()-1) != L'/') media.append(L"/"); if(log.at(log.length()-1) != L'/') log.append(L"/"); if(ftemplate.at(ftemplate.length()-1) != L'/') ftemplate.append(L"/"); if(data.at(data.length()-1) != L'/') data.append(L"/"); if(thumbnails.at(thumbnails.length()-1) != L'/') thumbnails.append(L"/"); try { for(auto it = fs::directory_iterator(initialPath); it != fs::directory_iterator(); ++it) { if(it->path().filename().wstring().find(L".fth") != std::wstring::npos) { auto from_path = *it; auto to_path = fs::path(ftemplate + L'/' + it->path().filename().wstring()); if(fs::exists(to_path)) fs::remove(to_path); fs::copy_file(from_path, to_path); } } } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to copy template-hosts from initial-path to template-path."; } } catch(...) { std::wcout << L" ### Invalid configuration file. ###"; throw; } try { auto media_path = fs::path(media); if(!fs::exists(media_path)) fs::create_directory(media_path); auto log_path = fs::path(log); if(!fs::exists(log_path)) fs::create_directory(log_path); auto template_path = fs::path(ftemplate); if(!fs::exists(template_path)) fs::create_directory(template_path); auto data_path = fs::path(data); if(!fs::exists(data_path)) fs::create_directory(data_path); auto thumbnails_path = fs::path(thumbnails); if(!fs::exists(thumbnails_path)) fs::create_directory(thumbnails_path); } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to create configured directories."; } } const std::wstring& media_folder() { check_is_configured(); return media; } const std::wstring& log_folder() { check_is_configured(); return log; } const std::wstring& template_folder() { check_is_configured(); return ftemplate; } const std::wstring& data_folder() { check_is_configured(); return data; } const std::wstring& thumbnails_folder() { check_is_configured(); return thumbnails; } #define QUOTE(str) #str #define EXPAND_AND_QUOTE(str) QUOTE(str) const std::wstring& version() { static std::wstring ver(L"2.0.7"); /*=widen( EXPAND_AND_QUOTE(2) "." EXPAND_AND_QUOTE(0) "." EXPAND_AND_QUOTE(7) "." CASPAR_REV " " CASPAR_TAG);*/ return ver; } const boost::property_tree::wptree& properties() { check_is_configured(); return pt; } }}
void check_is_configured() { if(pt.empty()) BOOST_THROW_EXCEPTION(invalid_operation() << msg_info("Enviroment properties has not been configured")); }
void RundownSaturationWidget::readProperties(boost::property_tree::wptree& pt) { if (pt.count(L"color") > 0) setColor(QString::fromStdWString(pt.get<std::wstring>(L"color"))); }
void configure(const std::wstring& filename) { try { auto separator = boost::filesystem::path::preferred_separator; auto initialPath = fs::initial_path<fs::path>().wstring(); std::wstring path_(initialPath + boost::lexical_cast<std::wstring>(separator) + filename); const wchar_t *pstr = path_.c_str(); std::wifstream file(reinterpret_cast<const char *>(pstr)); CASPAR_LOG(info) << L"before read_xml ..." << initialPath << " " << filename << " " << pstr; boost::property_tree::read_xml("/etc/casparcg.config", pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments); CASPAR_LOG(info) << L"read_xml done..."; auto paths = pt.get_child(L"configuration.paths"); media = widen(paths.get(L"media-path", initialPath + L"/media/")); log = widen(paths.get(L"log-path", initialPath + L"/log/")); ftemplate = fs::complete(fs::path(widen(paths.get(L"template-path", initialPath + L"/template/")))).wstring(); data = widen(paths.get(L"data-path", initialPath + L"/data/")); thumbnails = widen(paths.get(L"thumbnails-path", initialPath + L"/thumbnails/")); //Make sure that all paths have a trailing backslash if(media.at(media.length()-1) != L'/') media.append(L"/"); if(log.at(log.length()-1) != L'/') log.append(L"/"); if(ftemplate.at(ftemplate.length()-1) != L'/') ftemplate.append(L"/"); if(data.at(data.length()-1) != L'/') data.append(L"/"); if(thumbnails.at(thumbnails.length()-1) != L'/') thumbnails.append(L"/"); try { for(auto it = fs::directory_iterator(initialPath); it != fs::directory_iterator(); ++it) { if(it->path().filename().wstring().find(L".fth") != std::wstring::npos) { auto from_path = *it; auto to_path = fs::path(ftemplate + L'/' + it->path().filename().wstring()); if(fs::exists(to_path)) fs::remove(to_path); fs::copy_file(from_path, to_path); } } } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to copy template-hosts from initial-path to template-path."; } } catch(...) { std::wcout << L" ### Invalid configuration file. ###"; throw; } try { auto media_path = fs::path(media); if(!fs::exists(media_path)) fs::create_directory(media_path); auto log_path = fs::path(log); if(!fs::exists(log_path)) fs::create_directory(log_path); auto template_path = fs::path(ftemplate); if(!fs::exists(template_path)) fs::create_directory(template_path); auto data_path = fs::path(data); if(!fs::exists(data_path)) fs::create_directory(data_path); auto thumbnails_path = fs::path(thumbnails); if(!fs::exists(thumbnails_path)) fs::create_directory(thumbnails_path); } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); CASPAR_LOG(error) << L"Failed to create configured directories."; } }
void BlendModeCommand::readProperties(boost::property_tree::wptree& pt) { AbstractCommand::readProperties(pt); if (pt.count(L"blendmode") > 0) setBlendMode(QString::fromStdWString(pt.get<std::wstring>(L"blendmode"))); }