Esempio n. 1
0
        std::shared_ptr<profile> config::resolve(std::shared_ptr<device_interface> dev)
        {
            util::config config;

            //if the user requested all streams
            if (_enable_all_streams)
            {
                for (size_t i = 0; i < dev->get_sensors_count(); ++i)
                {
                    auto&& sub = dev->get_sensor(i);
                    auto profiles = sub.get_stream_profiles(PROFILE_TAG_SUPERSET);
                    config.enable_streams(profiles);
                }
                return std::make_shared<profile>(dev, config, _device_request.record_output);
            }

            //If the user did not request anything, give it the default, on playback all recorded streams are marked as default.
            if (_stream_requests.empty())
            {
                auto default_profiles = get_default_configuration(dev);
                config.enable_streams(default_profiles);
                return std::make_shared<profile>(dev, config, _device_request.record_output);
            }

            //Enabled requested streams
            for (auto&& req : _stream_requests)
            {
                auto r = req.second;
                config.enable_stream(r.stream, r.index, r.width, r.height, r.format, r.fps);
            }
            return std::make_shared<profile>(dev, config, _device_request.record_output);
        }
Esempio n. 2
0
void UIElement::set_configuration(ui_element_config::ptr config)
{
	DWORD *dataptr = (DWORD *)config->get_data();
	if(dataptr && config->get_data_size() > 4 && dataptr[0] == ('A' << 24 | 'L' << 16 | 'S' << 8 | 'O'))
		m_config = config; //right signature
	else
		m_config = get_default_configuration();
	dataptr = (DWORD *)m_config->get_data();
	memcpy(&m_Setting, &dataptr[1], sizeof(m_Setting));
	m_Setting.Ready();
	BYTE *datatmp = (BYTE *)m_config->get_data();
	DWORD scriptlen = *((DWORD *)&datatmp[sizeof(m_Setting) + 4]);
	m_Script.add_string((const char *)datatmp[sizeof(m_Setting) + 8], scriptlen);
}
Esempio n. 3
0
    std::shared_ptr<pipeline_profile> pipeline_config::resolve(std::shared_ptr<pipeline> pipe)
    {
        std::lock_guard<std::mutex> lock(_mtx);
        _resolved_profile.reset();
        auto requested_device = resolve_device_requests(pipe);

        std::vector<stream_profile> resolved_profiles;

        //if the user requested all streams, or if the requested device is from file and the user did not request any stream
        if (_enable_all_streams || (!_device_request.filename.empty() && _stream_requests.empty()))
        {
            if (!requested_device)
            {
                requested_device = get_first_or_default_device(pipe);
            }

            util::config config;
            config.enable_all(util::best_quality);
            _resolved_profile = std::make_shared<pipeline_profile>(requested_device, config, _device_request.record_output);
            return _resolved_profile;
        }
        else
        {
            util::config config;

            //If the user did not request anything, give it the default
            if (_stream_requests.empty())
            {
                if (!requested_device)
                {
                    requested_device = get_first_or_default_device(pipe);
                }

                auto default_profiles = get_default_configuration(requested_device);
                for (auto prof : default_profiles)
                {
                    auto p = dynamic_cast<video_stream_profile*>(prof.get());
                    if (!p)
                    {
                        LOG_ERROR("prof is not video_stream_profile");
                        throw std::logic_error("Failed to resolve request. internal error");
                    }
                    config.enable_stream(p->get_stream_type(), p->get_stream_index(), p->get_width(), p->get_height(), p->get_format(), p->get_framerate());
                }

                _resolved_profile = std::make_shared<pipeline_profile>(requested_device, config, _device_request.record_output);
                return _resolved_profile;
            }
            else
            {
                //User enabled some stream, enable only them   
                for(auto&& req : _stream_requests)
                {
                    auto r = req.second;
                    config.enable_stream(r.stream, r.stream_index, r.width, r.height, r.format, r.fps);
                }

                auto devs = pipe->get_context()->query_devices();
                if (devs.empty())
                {
                    auto dev = get_first_or_default_device(pipe);
                    _resolved_profile = std::make_shared<pipeline_profile>(dev, config, _device_request.record_output);
                    return _resolved_profile;
                }
                else
                {
                    for (auto dev_info : devs)
                    {
                        try
                        {
                            auto dev = dev_info->create_device();
                            _resolved_profile = std::make_shared<pipeline_profile>(dev, config, _device_request.record_output);
                            return _resolved_profile;
                        }
                        catch (...) {}
                    }
                }

                throw std::runtime_error("Failed to resolve request. No device found that satisfies all requirements");
            }
        }

        assert(0); //Unreachable code
    }