Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
Archivo: main.c Proyecto: bkarr/libshr
modifiers_s parse_modifiers(
    int argc,
    char **argv,
    int index,
    char *pattern
)   {
    modifiers_s result = {0};
    int i;
    char *param;

    for (i = 1; i < index; i++) {
        param = argv[i];
        if (param[0] != '-') {
            printf("invalid modifier %s\n", argv[i]);
            exit(1);
        }
        if (!contains_param(PERMIT, param[1])) {
            printf("error: unrecognized modifier %s\n", argv[i]);
            exit(1);
        }
        if (!contains_param(pattern, param[1])) {
            printf("warning: invalid modifier %s will be ignored\n\n", argv[i]);
            continue;
        }
        switch (param[1]) {
        case 'b' :
            result.block = true;
            break;
        case 'h' :
            result.help = true;
            break;
        case 'v' :
            result.verbose = true;
            break;
        case 'x' :
            result.hex = true;
            break;
        default :
            printf("unrecognized modifier or parameter\n");
            exit(1);
        }
    }

    return result;
}