bool directx_camera_server::open_and_find_parameters(const int which, unsigned width, unsigned height) { auto graphbuilderRet = start_com_and_graphbuilder(); if (!graphbuilderRet) { return false; } std::size_t i = 0; auto pMoniker = find_first_capture_device_where([&i, which](IMoniker &) { if (i == which) { return true; } ++i; return false; }); if (!pMoniker) { fprintf(stderr, "directx_camera_server::open_and_find_parameters(): " "Could not get the device requested - not enough " "cameras?\n"); return false; } #ifdef DEBUG std::cout << "directx_camera_server::open_and_find_parameters(): Accepted!" << std::endl; #endif return open_moniker_and_finish_setup(pMoniker, FilterOperation{}, width, height); }
bool directx_camera_server::open_and_find_parameters( std::string const &pathPrefix, FilterOperation const &sourceConfig, unsigned width, unsigned height) { auto graphbuilderRet = start_com_and_graphbuilder(); if (!graphbuilderRet) { return false; } auto pMoniker = find_first_capture_device_where([&pathPrefix](IMoniker &mon) { auto props = PropertyBagHelper{mon}; if (!props) { return false; } auto path = getDevicePath(props); if (path.length() < pathPrefix.length()) { return false; } return (path.substr(0, pathPrefix.length()) == pathPrefix); }); if (!pMoniker) { fprintf(stderr, "directx_camera_server::open_and_find_parameters(): " "Could not get the device requested - not enough " "cameras?\n"); return false; } #ifdef DEBUG std::cout << "directx_camera_server::open_and_find_parameters(): Accepted!" << std::endl; #endif return open_moniker_and_finish_setup(pMoniker, sourceConfig, width, height); }