spl::shared_ptr<core::frame_producer> create_route_producer(const core::frame_producer_dependencies& dependencies, const std::vector<std::wstring>& params) { static boost::wregex expr(L"route://(?<CHANNEL>\\d+)(-(?<LAYER>\\d+))?", boost::regex::icase); boost::wsmatch what; if (params.empty() || !boost::regex_match(params.at(0), what, expr)) { return core::frame_producer::empty(); } auto channel = std::stoi(what["CHANNEL"].str()); auto layer = what["LAYER"].matched ? std::stoi(what["LAYER"].str()) : -1; auto mode = core::route_mode::foreground; if (layer >= 0) { if (contains_param(L"BACKGROUND", params)) mode = core::route_mode::background; else if (contains_param(L"NEXT", params)) mode = core::route_mode::next; } auto channel_it = boost::find_if(dependencies.channels, [=](spl::shared_ptr<core::video_channel> ch) { return ch->index() == channel; }); if (channel_it == dependencies.channels.end()) { CASPAR_THROW_EXCEPTION(user_error() << msg_info(L"No channel with id " + std::to_wstring(channel))); } auto buffer = get_param(L"BUFFER", params, 0); return spl::make_shared<route_producer>((*channel_it)->route(layer, mode), buffer); }
impl(frame_geometry::geometry_type type, std::vector<coord> data) : type_(type) { if (type == geometry_type::quad && data.size() != 4) CASPAR_THROW_EXCEPTION(invalid_argument() << msg_info("The number of coordinates needs to be 4")); data_ = std::move(data); }
newtek_ivga_consumer() { if (!airsend::is_available()) { CASPAR_THROW_EXCEPTION(not_supported() << msg_info(airsend::dll_name() + L" not available")); } graph_->set_text(print()); graph_->set_color("frame-time", diagnostics::color(0.5f, 1.0f, 0.2f)); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f)); diagnostics::register_graph(graph_); }
void add_file_sink(const std::wstring& file) { using file_sink_type = boost::log::sinks::synchronous_sink<boost::log::sinks::text_file_backend>; try { if (!boost::filesystem::is_directory(boost::filesystem::path(file).parent_path())) { CASPAR_THROW_EXCEPTION(directory_not_found()); } auto file_sink = boost::make_shared<file_sink_type>( boost::log::keywords::file_name = file + L"_%Y-%m-%d.log", boost::log::keywords::time_based_rotation = boost::log::sinks::file::rotation_at_time_point(0, 0, 0), boost::log::keywords::auto_flush = true, boost::log::keywords::open_mode = std::ios::app); file_sink->set_formatter(boost::bind(&my_formatter<boost::log::formatting_ostream>, true, _1, _2)); boost::log::core::get()->add_sink(file_sink); } catch (...) { std::wcerr << L"Failed to Setup File Logging Sink" << std::endl << std::endl; } }
boost::filesystem::path get_relative(const boost::filesystem::path& file, const boost::filesystem::path& relative_to) { auto result = file.filename(); auto current_path = file; if (boost::filesystem::equivalent(current_path, relative_to)) return L""; while (true) { current_path = current_path.parent_path(); if (boost::filesystem::equivalent(current_path, relative_to)) break; if (current_path.empty()) CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("File " + file.string() + " not relative to folder " + relative_to.string())); result = current_path.filename() / result; } return result; }
void SMFL_GLCheckError(const std::string&, const std::string& file, unsigned int line) { // Get the last error GLenum LastErrorCode = GL_NO_ERROR; for(GLenum ErrorCode = glGetError(); ErrorCode != GL_NO_ERROR; ErrorCode = glGetError()) { CASPAR_LOG(error) << "OpenGL Error: " << ErrorCode << L" " << glewGetErrorString(ErrorCode); LastErrorCode = ErrorCode; } if (LastErrorCode != GL_NO_ERROR) { // Decode the error code switch (LastErrorCode) { case GL_INVALID_ENUM : CASPAR_THROW_EXCEPTION(ogl_invalid_enum() << msg_info("an unacceptable value has been specified for an enumerated argument") << error_info("GL_INVALID_ENUM") << line_info(line) << source_info(file)); case GL_INVALID_VALUE : CASPAR_THROW_EXCEPTION(ogl_invalid_value() << msg_info("a numeric argument is out of range") << error_info("GL_INVALID_VALUE") << line_info(line) << source_info(file)); case GL_INVALID_OPERATION : CASPAR_THROW_EXCEPTION(ogl_invalid_operation() << msg_info("the specified operation is not allowed in the current state") << error_info("GL_INVALID_OPERATION") << line_info(line) << source_info(file)); case GL_STACK_OVERFLOW : CASPAR_THROW_EXCEPTION(ogl_stack_overflow() << msg_info("this command would cause a stack overflow") << error_info("GL_STACK_OVERFLOW") << line_info(line) << source_info(file)); case GL_STACK_UNDERFLOW : CASPAR_THROW_EXCEPTION(ogl_stack_underflow() << msg_info("this command would cause a stack underflow") << error_info("GL_STACK_UNDERFLOW") << line_info(line) << source_info(file)); case GL_OUT_OF_MEMORY : CASPAR_THROW_EXCEPTION(ogl_out_of_memory() << msg_info("there is not enough memory left to execute the command") << error_info("GL_OUT_OF_MEMORY") << line_info(line) << source_info(file)); case GL_INVALID_FRAMEBUFFER_OPERATION_EXT : CASPAR_THROW_EXCEPTION(ogl_stack_underflow() << msg_info("the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"") << error_info("GL_INVALID_FRAMEBUFFER_OPERATION_EXT") << line_info(line) << source_info(file)); } } }
std::map<std::string, std::string> read_flv_meta_info(const std::string& filename) { std::map<std::string, std::string> values; if(boost::filesystem::path(filename).extension().string() != ".flv") return values; try { if(!boost::filesystem::exists(filename)) CASPAR_THROW_EXCEPTION(caspar_exception()); std::fstream fileStream = std::fstream(filename, std::fstream::in); std::vector<char> bytes2(256); fileStream.read(bytes2.data(), bytes2.size()); auto ptr = bytes2.data(); ptr += 27; if(std::string(ptr, ptr+10) == "onMetaData") { ptr += 16; for(int n = 0; n < 16; ++n) { char name_size = *ptr++; if(name_size == 0) break; auto name = std::string(ptr, ptr + name_size); ptr += name_size; char data_type = *ptr++; switch(data_type) { case 0: // double { static_assert(sizeof(double) == 8, ""); std::reverse(ptr, ptr+8); values[name] = boost::lexical_cast<std::string>(*(double*)(ptr)); ptr += 9; break; } case 1: // bool { values[name] = boost::lexical_cast<std::string>(*ptr != 0); ptr += 2; break; } } } } } catch(...) { CASPAR_LOG_CURRENT_EXCEPTION(); } return values; }