Final changes before the release.

Removed code to elevate privileges in Windows, now you must explicitly
run the manager as administrator.
Allow setting a device ID in the config file.
Changed wording from 'Device Path' to 'Device ID' (and similar ones),
this breaks previous devices configurations.
Return standard error codes in the manager.
Added plugin install path hint in Windows registry.
This commit is contained in:
Gonzalo Exequiel Pedone 2021-06-21 18:25:48 -03:00
parent c0d241d0b4
commit b0f83b8462
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
16 changed files with 244 additions and 242 deletions

View file

@ -18,6 +18,7 @@
*/
#include <algorithm>
#include <cerrno>
#include <chrono>
#include <cmath>
#include <codecvt>
@ -387,7 +388,7 @@ int AkVCam::CmdParser::parse(int argc, char **argv)
<< "'"
<< std::endl;
return -1;
return -EINVAL;
}
std::string value;
@ -421,7 +422,7 @@ int AkVCam::CmdParser::parse(int argc, char **argv)
} else {
std::cout << "Unknown command '" << arg << "'" << std::endl;
return -1;
return -EINVAL;
}
} else {
arguments.push_back(arg);
@ -451,14 +452,17 @@ int AkVCam::CmdParser::parse(int argc, char **argv)
this->d->drawTable(table, columns, true);
}
return -1;
return -EBUSY;
}
if (this->d->m_ipcBridge.needsRoot(command->command)
|| (command->command == "hack"
&& arguments.size() >= 2
&& this->d->m_ipcBridge.hackNeedsRoot(arguments[1])))
return this->d->m_ipcBridge.sudo(argc, argv);
&& this->d->m_ipcBridge.hackNeedsRoot(arguments[1]))) {
std::cerr << "You must run this command with administrator privileges." << std::endl;
return -EPERM;
}
return command->func(flags, arguments);
}
@ -878,7 +882,7 @@ int AkVCam::CmdParserPrivate::addDevice(const StringMap &flags,
if (args.size() < 2) {
std::cerr << "Device description not provided." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = this->flagValue(flags, "add-device", "-i");
@ -887,7 +891,7 @@ int AkVCam::CmdParserPrivate::addDevice(const StringMap &flags,
if (deviceId.empty()) {
std::cerr << "Failed to create device." << std::endl;
return -1;
return -EIO;
}
if (this->m_parseable)
@ -906,7 +910,7 @@ int AkVCam::CmdParserPrivate::removeDevice(const StringMap &flags,
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -916,7 +920,7 @@ int AkVCam::CmdParserPrivate::removeDevice(const StringMap &flags,
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
this->m_ipcBridge.removeDevice(args[1]);
@ -945,7 +949,7 @@ int AkVCam::CmdParserPrivate::showDeviceDescription(const StringMap &flags,
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -955,7 +959,7 @@ int AkVCam::CmdParserPrivate::showDeviceDescription(const StringMap &flags,
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
std::cout << this->m_ipcBridge.description(args[1]) << std::endl;
@ -971,7 +975,7 @@ int AkVCam::CmdParserPrivate::setDeviceDescription(const AkVCam::StringMap &flag
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -981,7 +985,7 @@ int AkVCam::CmdParserPrivate::setDeviceDescription(const AkVCam::StringMap &flag
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
this->m_ipcBridge.setDescription(deviceId, args[2]);
@ -1038,7 +1042,7 @@ int AkVCam::CmdParserPrivate::showFormats(const StringMap &flags,
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1048,7 +1052,7 @@ int AkVCam::CmdParserPrivate::showFormats(const StringMap &flags,
if (it == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
if (this->m_parseable) {
@ -1093,7 +1097,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (args.size() < 6) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1103,7 +1107,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
auto format = VideoFormat::fourccFromString(args[2]);
@ -1111,7 +1115,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (!format) {
std::cerr << "Invalid pixel format." << std::endl;
return -1;
return -EINVAL;
}
auto formats =
@ -1121,7 +1125,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (fit == formats.end()) {
std::cerr << "Format not supported." << std::endl;
return -1;
return -EINVAL;
}
char *p = nullptr;
@ -1130,7 +1134,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (*p) {
std::cerr << "Width must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
p = nullptr;
@ -1139,7 +1143,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (*p) {
std::cerr << "Height must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
Fraction fps(args[5]);
@ -1147,7 +1151,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (fps.num() < 1 || fps.den() < 1) {
std::cerr << "Invalid frame rate." << std::endl;
return -1;
return -EINVAL;
}
auto indexStr = this->flagValue(flags, "add-format", "-i");
@ -1160,7 +1164,7 @@ int AkVCam::CmdParserPrivate::addFormat(const StringMap &flags,
if (*p) {
std::cerr << "Index must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
}
@ -1178,7 +1182,7 @@ int AkVCam::CmdParserPrivate::removeFormat(const StringMap &flags,
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1188,7 +1192,7 @@ int AkVCam::CmdParserPrivate::removeFormat(const StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
char *p = nullptr;
@ -1197,7 +1201,7 @@ int AkVCam::CmdParserPrivate::removeFormat(const StringMap &flags,
if (*p) {
std::cerr << "Index must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
auto formats = this->m_ipcBridge.formats(deviceId);
@ -1205,7 +1209,7 @@ int AkVCam::CmdParserPrivate::removeFormat(const StringMap &flags,
if (index >= formats.size()) {
std::cerr << "Index is out of range." << std::endl;
return -1;
return -ERANGE;
}
this->m_ipcBridge.removeFormat(deviceId, int(index));
@ -1221,7 +1225,7 @@ int AkVCam::CmdParserPrivate::removeFormats(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1231,7 +1235,7 @@ int AkVCam::CmdParserPrivate::removeFormats(const AkVCam::StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
this->m_ipcBridge.setFormats(deviceId, {});
@ -1257,7 +1261,7 @@ int AkVCam::CmdParserPrivate::loadSettings(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Settings file not provided." << std::endl;
return -1;
return -EINVAL;
}
Settings settings;
@ -1265,7 +1269,7 @@ int AkVCam::CmdParserPrivate::loadSettings(const AkVCam::StringMap &flags,
if (!settings.load(args[1])) {
std::cerr << "Settings file not valid." << std::endl;
return -1;
return -EIO;
}
this->loadGenerals(settings);
@ -1287,7 +1291,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (args.size() < 5) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1297,7 +1301,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
auto format = VideoFormat::fourccFromString(args[2]);
@ -1305,7 +1309,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (!format) {
std::cerr << "Invalid pixel format." << std::endl;
return -1;
return -EINVAL;
}
auto formats =
@ -1315,7 +1319,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (fit == formats.end()) {
std::cerr << "Format not supported." << std::endl;
return -1;
return -EINVAL;
}
char *p = nullptr;
@ -1324,7 +1328,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (*p) {
std::cerr << "Width must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
p = nullptr;
@ -1333,7 +1337,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (*p) {
std::cerr << "Height must be an unsigned integer." << std::endl;
return -1;
return -EINVAL;
}
auto fpsStr = this->flagValue(flags, "stream", "-f");
@ -1347,7 +1351,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (!Fraction::isFraction(fpsStr)) {
std::cerr << "The framerate must be a number or a fraction." << std::endl;
return -1;
return -EINVAL;
}
fps = Fraction(fpsStr).value();
@ -1356,7 +1360,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (fps <= 0 || std::isinf(fps)) {
std::cerr << "The framerate is out of range." << std::endl;
return -1;
return -ERANGE;
}
}
@ -1365,7 +1369,7 @@ int AkVCam::CmdParserPrivate::stream(const AkVCam::StringMap &flags,
if (!this->m_ipcBridge.deviceStart(deviceId, fmt)) {
std::cerr << "Can't start stream." << std::endl;
return -1;
return -EIO;
}
static bool exit = false;
@ -1497,7 +1501,7 @@ int AkVCam::CmdParserPrivate::showControls(const StringMap &flags,
if (args.size() < 2) {
std::cerr << "Device not provided." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1507,7 +1511,7 @@ int AkVCam::CmdParserPrivate::showControls(const StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
if (this->m_parseable) {
@ -1551,7 +1555,7 @@ int AkVCam::CmdParserPrivate::readControl(const StringMap &flags,
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1561,7 +1565,7 @@ int AkVCam::CmdParserPrivate::readControl(const StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
for (auto &control: this->m_ipcBridge.controls(deviceId))
@ -1611,7 +1615,7 @@ int AkVCam::CmdParserPrivate::readControl(const StringMap &flags,
std::cerr << "'" << args[2] << "' control not available." << std::endl;
return -1;
return -ENOSYS;
}
int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
@ -1622,7 +1626,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
if (args.size() < 3) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto deviceId = args[1];
@ -1632,7 +1636,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
if (dit == devices.end()) {
std::cerr << "'" << deviceId << "' doesn't exists." << std::endl;
return -1;
return -ENODEV;
}
std::map<std::string, int> controls;
@ -1644,7 +1648,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " is not in the form KEY=VALUE."
<< std::endl;
return -1;
return -EINVAL;
}
auto pair = splitOnce(args[i], "=");
@ -1655,7 +1659,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " is emty."
<< std::endl;
return -1;
return -EINVAL;
}
auto key = trimmed(pair.first);
@ -1675,7 +1679,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " must be an integer."
<< std::endl;
return -1;
return -EINVAL;
}
controls[key] = val;
@ -1702,7 +1706,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " must be a boolean."
<< std::endl;
return -1;
return -EINVAL;
}
break;
@ -1723,7 +1727,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " is not valid."
<< std::endl;
return -1;
return -EINVAL;
}
controls[key] = int(it - control.menu.begin());
@ -1734,7 +1738,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< " is out of range."
<< std::endl;
return -1;
return -ERANGE;
}
controls[key] = int(val);
@ -1760,7 +1764,7 @@ int AkVCam::CmdParserPrivate::writeControls(const StringMap &flags,
<< "."
<< std::endl;
return -1;
return -ENOSYS;
}
}
@ -1788,7 +1792,7 @@ int AkVCam::CmdParserPrivate::setPicture(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
this->m_ipcBridge.setPicture(args[1]);
@ -1820,7 +1824,7 @@ int AkVCam::CmdParserPrivate::setLogLevel(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto levelStr = args[1];
@ -2103,7 +2107,7 @@ int AkVCam::CmdParserPrivate::hackInfo(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto hack = args[1];
@ -2113,7 +2117,7 @@ int AkVCam::CmdParserPrivate::hackInfo(const AkVCam::StringMap &flags,
if (dit == hacks.end()) {
std::cerr << "Unknown hack: " << hack << "." << std::endl;
return -1;
return -ENOSYS;
}
if (this->containsFlag(flags, "hack-info", "-c"))
@ -2135,7 +2139,7 @@ int AkVCam::CmdParserPrivate::hack(const AkVCam::StringMap &flags,
if (args.size() < 2) {
std::cerr << "Not enough arguments." << std::endl;
return -1;
return -EINVAL;
}
auto hack = args[1];
@ -2145,7 +2149,7 @@ int AkVCam::CmdParserPrivate::hack(const AkVCam::StringMap &flags,
if (dit == hacks.end()) {
std::cerr << "Unknown hack: " << hack << "." << std::endl;
return -1;
return -ENOSYS;
}
bool accepted = this->m_parseable | this->m_ipcBridge.hackIsSafe(hack);
@ -2176,7 +2180,7 @@ int AkVCam::CmdParserPrivate::hack(const AkVCam::StringMap &flags,
if (!accepted) {
std::cerr << "Hack not applied." << std::endl;
return -1;
return -EIO;
}
StringVector hargs;
@ -2346,7 +2350,8 @@ void AkVCam::CmdParserPrivate::createDevice(Settings &settings,
return;
}
auto deviceId = this->m_ipcBridge.addDevice(description);
auto deviceId = settings.value("id");
deviceId = this->m_ipcBridge.addDevice(description, deviceId);
auto supportedFormats =
this->m_ipcBridge.supportedPixelFormats(IpcBridge::StreamTypeOutput);

View file

@ -176,7 +176,6 @@ namespace AkVCam
bool isBusyFor(const std::string &operation) const;
bool needsRoot(const std::string &operation) const;
int sudo(int argc, char **argv) const;
/* Hacks */

View file

@ -289,14 +289,14 @@ std::string AkVCam::Preferences::addDevice(const std::string &description,
const std::string &deviceId)
{
AkLogFunction();
std::string path;
std::string id;
if (deviceId.empty())
path = createDevicePath();
id = createDeviceId();
else if (!idDeviceIdTaken(deviceId))
path = deviceId;
id = deviceId;
if (path.empty())
if (id.empty())
return {};
int cameraIndex = readInt("cameras");
@ -307,11 +307,11 @@ std::string AkVCam::Preferences::addDevice(const std::string &description,
description);
write("cameras."
+ std::to_string(cameraIndex)
+ ".path",
path);
+ ".id",
id);
sync();
return path;
return id;
}
std::string AkVCam::Preferences::addCamera(const std::string &description,
@ -320,16 +320,16 @@ std::string AkVCam::Preferences::addCamera(const std::string &description,
return addCamera("", description, formats);
}
std::string AkVCam::Preferences::addCamera(const std::string &path,
std::string AkVCam::Preferences::addCamera(const std::string &deviceId,
const std::string &description,
const std::vector<VideoFormat> &formats)
{
AkLogFunction();
if (!path.empty() && cameraExists(path))
if (!deviceId.empty() && cameraExists(deviceId))
return {};
auto path_ = path.empty()? createDevicePath(): path;
auto id = deviceId.empty()? createDeviceId(): deviceId;
int cameraIndex = readInt("cameras");
write("cameras", cameraIndex + 1);
write("cameras."
@ -338,8 +338,8 @@ std::string AkVCam::Preferences::addCamera(const std::string &path,
description);
write("cameras."
+ std::to_string(cameraIndex)
+ ".path",
path_);
+ ".id",
id);
write("cameras."
+ std::to_string(cameraIndex)
+ ".formats",
@ -360,14 +360,14 @@ std::string AkVCam::Preferences::addCamera(const std::string &path,
sync();
return path_;
return id;
}
void AkVCam::Preferences::removeCamera(const std::string &path)
void AkVCam::Preferences::removeCamera(const std::string &deviceId)
{
AkLogFunction();
AkLogInfo() << "Device: " << path << std::endl;
int cameraIndex = cameraFromPath(path);
AkLogInfo() << "Device: " << deviceId << std::endl;
int cameraIndex = cameraFromId(deviceId);
if (cameraIndex < 0)
return;
@ -402,58 +402,58 @@ bool AkVCam::Preferences::idDeviceIdTaken(const std::string &deviceId)
{
AkLogFunction();
// List device paths in use.
std::vector<std::string> cameraPaths;
// List device IDs in use.
std::vector<std::string> cameraIds;
for (size_t i = 0; i < camerasCount(); i++)
cameraPaths.push_back(cameraPath(i));
cameraIds.push_back(cameraId(i));
return std::find(cameraPaths.begin(),
cameraPaths.end(),
deviceId) != cameraPaths.end();
return std::find(cameraIds.begin(),
cameraIds.end(),
deviceId) != cameraIds.end();
}
std::string AkVCam::Preferences::createDevicePath()
std::string AkVCam::Preferences::createDeviceId()
{
AkLogFunction();
// List device paths in use.
std::vector<std::string> cameraPaths;
// List device IDs in use.
std::vector<std::string> cameraIds;
for (size_t i = 0; i < camerasCount(); i++)
cameraPaths.push_back(cameraPath(i));
cameraIds.push_back(cameraId(i));
const int maxId = 64;
for (int i = 0; i < maxId; i++) {
/* There are no rules for device paths in Mac. Just append an
/* There are no rules for device IDs in Mac. Just append an
* incremental index to a common prefix.
*/
auto path = CMIO_PLUGIN_DEVICE_PREFIX + std::to_string(i);
auto id = CMIO_PLUGIN_DEVICE_PREFIX + std::to_string(i);
// Check if the path is being used, if not return it.
if (std::find(cameraPaths.begin(),
cameraPaths.end(),
path) == cameraPaths.end())
return path;
// Check if the ID is being used, if not return it.
if (std::find(cameraIds.begin(),
cameraIds.end(),
id) == cameraIds.end())
return id;
}
return {};
}
int AkVCam::Preferences::cameraFromPath(const std::string &path)
int AkVCam::Preferences::cameraFromId(const std::string &deviceId)
{
for (size_t i = 0; i < camerasCount(); i++)
if (cameraPath(i) == path)
if (cameraId(i) == deviceId)
return int(i);
return -1;
}
bool AkVCam::Preferences::cameraExists(const std::string &path)
bool AkVCam::Preferences::cameraExists(const std::string &deviceId)
{
for (size_t i = 0; i < camerasCount(); i++)
if (cameraPath(i) == path)
if (cameraId(i) == deviceId)
return true;
return false;
@ -480,11 +480,11 @@ void AkVCam::Preferences::cameraSetDescription(size_t cameraIndex,
sync();
}
std::string AkVCam::Preferences::cameraPath(size_t cameraIndex)
std::string AkVCam::Preferences::cameraId(size_t cameraIndex)
{
return readString("cameras."
+ std::to_string(cameraIndex)
+ ".path");
+ ".id");
}
size_t AkVCam::Preferences::formatsCount(size_t cameraIndex)

View file

@ -55,19 +55,19 @@ namespace AkVCam
const std::string &deviceId);
std::string addCamera(const std::string &description,
const std::vector<VideoFormat> &formats);
std::string addCamera(const std::string &path,
std::string addCamera(const std::string &deviceId,
const std::string &description,
const std::vector<VideoFormat> &formats);
void removeCamera(const std::string &path);
void removeCamera(const std::string &deviceId);
size_t camerasCount();
bool idDeviceIdTaken(const std::string &deviceId);
std::string createDevicePath();
int cameraFromPath(const std::string &path);
bool cameraExists(const std::string &path);
std::string createDeviceId();
int cameraFromId(const std::string &deviceId);
bool cameraExists(const std::string &deviceId);
std::string cameraDescription(size_t cameraIndex);
void cameraSetDescription(size_t cameraIndex,
const std::string &description);
std::string cameraPath(size_t cameraIndex);
std::string cameraId(size_t cameraIndex);
size_t formatsCount(size_t cameraIndex);
VideoFormat cameraFormat(size_t cameraIndex, size_t formatIndex);
std::vector<VideoFormat> cameraFormats(size_t cameraIndex);

View file

@ -340,7 +340,7 @@ std::vector<std::string> AkVCam::IpcBridge::devices() const
AkLogInfo() << "Devices:" << std::endl;
for (size_t i = 0; i < nCameras; i++) {
auto deviceId = Preferences::cameraPath(i);
auto deviceId = Preferences::cameraId(i);
devices.push_back(deviceId);
AkLogInfo() << " " << deviceId << std::endl;
}
@ -351,7 +351,7 @@ std::vector<std::string> AkVCam::IpcBridge::devices() const
std::string AkVCam::IpcBridge::description(const std::string &deviceId) const
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -363,7 +363,7 @@ void AkVCam::IpcBridge::setDescription(const std::string &deviceId,
const std::string &description)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraSetDescription(size_t(cameraIndex), description);
@ -392,7 +392,7 @@ AkVCam::PixelFormat AkVCam::IpcBridge::defaultPixelFormat(StreamType type) const
std::vector<AkVCam::VideoFormat> AkVCam::IpcBridge::formats(const std::string &deviceId) const
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -403,7 +403,7 @@ std::vector<AkVCam::VideoFormat> AkVCam::IpcBridge::formats(const std::string &d
void AkVCam::IpcBridge::setFormats(const std::string &deviceId,
const std::vector<VideoFormat> &formats)
{
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraSetFormats(size_t(cameraIndex), formats);
@ -442,7 +442,7 @@ std::string AkVCam::IpcBridge::broadcaster(const std::string &deviceId) const
std::vector<AkVCam::DeviceControl> AkVCam::IpcBridge::controls(const std::string &deviceId)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -462,7 +462,7 @@ void AkVCam::IpcBridge::setControls(const std::string &deviceId,
const std::map<std::string, int> &controls)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return;
@ -602,7 +602,7 @@ void AkVCam::IpcBridge::addFormat(const std::string &deviceId,
int index)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraAddFormat(size_t(cameraIndex),
@ -613,7 +613,7 @@ void AkVCam::IpcBridge::addFormat(const std::string &deviceId,
void AkVCam::IpcBridge::removeFormat(const std::string &deviceId, int index)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraRemoveFormat(size_t(cameraIndex),
@ -840,15 +840,6 @@ bool AkVCam::IpcBridge::needsRoot(const std::string &operation) const
return it != operations.end() && !this->d->isRoot();
}
int AkVCam::IpcBridge::sudo(int argc, char **argv) const
{
UNUSED(argc);
UNUSED(argv);
std::cerr << "You must run this command with administrator privileges." << std::endl;
return -1;
}
std::vector<std::string> AkVCam::IpcBridge::hacks() const
{
std::vector<std::string> hacks;
@ -977,7 +968,7 @@ void AkVCam::IpcBridgePrivate::updateDevices(xpc_connection_t port, bool propaga
auto devices = xpc_array_create(nullptr, 0);
for (size_t i = 0; i < Preferences::camerasCount(); i++) {
auto path = Preferences::cameraPath(i);
auto path = Preferences::cameraId(i);
auto pathObj = xpc_string_create(path.c_str());
xpc_array_append_value(devices, pathObj);
AkLogDebug() << "Device " << i << ": " << path << std::endl;
@ -1009,7 +1000,7 @@ void AkVCam::IpcBridgePrivate::deviceUpdate(xpc_connection_t client,
auto nCameras = Preferences::camerasCount();
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraPath(i));
devices.push_back(Preferences::cameraId(i));
for (auto bridge: this->m_bridges)
AKVCAM_EMIT(bridge, DevicesChanged, devices)
@ -1085,7 +1076,7 @@ void AkVCam::IpcBridgePrivate::controlsUpdated(xpc_connection_t client,
std::string deviceId =
xpc_dictionary_get_string(event, "device");
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return;

View file

@ -387,7 +387,7 @@ bool AkVCam::PluginInterface::createDevice(const std::string &deviceId,
device->connectRemoveListener(this, &PluginInterface::removeListener);
this->m_devices.push_back(device);
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
auto hflip = Preferences::cameraControlValue(cameraIndex, "hflip");
auto vflip = Preferences::cameraControlValue(cameraIndex, "vflip");
auto scaling = Preferences::cameraControlValue(cameraIndex, "scaling");
@ -493,7 +493,7 @@ void AkVCam::PluginInterfacePrivate::updateDevices()
{
for (auto &device: this->self->m_devices) {
device->setBroadcasting(this->m_ipcBridge.broadcaster(device->deviceId()));
auto cameraIndex = Preferences::cameraFromPath(device->deviceId());
auto cameraIndex = Preferences::cameraFromId(device->deviceId());
auto hflip = Preferences::cameraControlValue(cameraIndex, "hflip");
auto vflip = Preferences::cameraControlValue(cameraIndex, "vflip");
auto scaling = Preferences::cameraControlValue(cameraIndex, "scaling");

View file

@ -503,7 +503,7 @@ void AkVCam::ServicePrivate::devicesUpdate(AkVCam::Message *message)
DeviceConfigs configs;
for (size_t i = 0; i < Preferences::camerasCount(); i++) {
auto device = Preferences::cameraPath(i);
auto device = Preferences::cameraId(i);
if (this->m_deviceConfigs.count(device) > 0)
configs[device] = this->m_deviceConfigs[device];

View file

@ -227,14 +227,14 @@ std::string AkVCam::Preferences::addDevice(const std::string &description,
const std::string &deviceId)
{
AkLogFunction();
std::string path;
std::string id;
if (deviceId.empty())
path = createDevicePath();
id = createDeviceId();
else if (!idDeviceIdTaken(deviceId))
path = deviceId;
id = deviceId;
if (path.empty())
if (id.empty())
return {};
bool ok = true;
@ -243,9 +243,9 @@ std::string AkVCam::Preferences::addDevice(const std::string &description,
ok &= write("Cameras\\" + std::to_string(cameraIndex) + "\\description",
description,
true);
ok &= write("Cameras\\" + std::to_string(cameraIndex) + "\\path", path, true);
ok &= write("Cameras\\" + std::to_string(cameraIndex) + "\\id", id, true);
return ok? path: std::string();
return ok? id: std::string();
}
std::string AkVCam::Preferences::addCamera(const std::string &description,
@ -254,18 +254,18 @@ std::string AkVCam::Preferences::addCamera(const std::string &description,
return addCamera("", description, formats);
}
std::string AkVCam::Preferences::addCamera(const std::string &path,
std::string AkVCam::Preferences::addCamera(const std::string &deviceId,
const std::string &description,
const std::vector<VideoFormat> &formats)
{
AkLogFunction();
if (!path.empty() && cameraExists(path))
if (!deviceId.empty() && cameraExists(deviceId))
return {};
auto path_ = path.empty()? createDevicePath(): path;
auto id = deviceId.empty()? createDeviceId(): deviceId;
if (path.empty())
if (id.empty())
return {};
bool ok = true;
@ -278,8 +278,8 @@ std::string AkVCam::Preferences::addCamera(const std::string &path,
true);
ok &= write("Cameras\\"
+ std::to_string(cameraIndex)
+ "\\path",
path_,
+ "\\id",
id,
true);
ok &= write("Cameras\\"
+ std::to_string(cameraIndex)
@ -302,14 +302,14 @@ std::string AkVCam::Preferences::addCamera(const std::string &path,
true);
}
return ok? path_: std::string();
return ok? id: std::string();
}
bool AkVCam::Preferences::removeCamera(const std::string &path)
bool AkVCam::Preferences::removeCamera(const std::string &deviceId)
{
AkLogFunction();
AkLogInfo() << "Device: " << path << std::endl;
int cameraIndex = cameraFromPath(path);
AkLogInfo() << "Device: " << deviceId << std::endl;
int cameraIndex = cameraFromId(deviceId);
if (cameraIndex < 0)
return false;
@ -346,48 +346,48 @@ bool AkVCam::Preferences::idDeviceIdTaken(const std::string &deviceId)
{
AkLogFunction();
// List device paths in use.
std::vector<std::string> cameraPaths;
// List device IDs in use.
std::vector<std::string> cameraIds;
for (size_t i = 0; i < camerasCount(); i++)
cameraPaths.push_back(cameraPath(i));
cameraIds.push_back(cameraId(i));
// List device CLSIDs in use.
auto cameraClsids = listAllCameras();
auto clsid = createClsidFromStr(deviceId);
auto pit = std::find(cameraPaths.begin(), cameraPaths.end(), deviceId);
auto pit = std::find(cameraIds.begin(), cameraIds.end(), deviceId);
auto cit = std::find(cameraClsids.begin(), cameraClsids.end(), clsid);
return pit != cameraPaths.end() || cit != cameraClsids.end();
return pit != cameraIds.end() || cit != cameraClsids.end();
}
std::string AkVCam::Preferences::createDevicePath()
std::string AkVCam::Preferences::createDeviceId()
{
AkLogFunction();
// List device paths in use.
std::vector<std::string> cameraPaths;
// List device IDs in use.
std::vector<std::string> cameraIds;
for (size_t i = 0; i < camerasCount(); i++)
cameraPaths.push_back(cameraPath(i));
cameraIds.push_back(cameraId(i));
// List device CLSIDs in use.
auto cameraClsids = listAllCameras();
const int maxId = 64;
for (int i = 0; i < maxId; i++) {
/* There are no rules for device paths in Windows. Just append an
/* There are no rules for device IDs in Windows. Just append an
* incremental index to a common prefix.
*/
auto path = DSHOW_PLUGIN_DEVICE_PREFIX + std::to_string(i);
auto clsid = createClsidFromStr(path);
auto pit = std::find(cameraPaths.begin(), cameraPaths.end(), path);
auto id = DSHOW_PLUGIN_DEVICE_PREFIX + std::to_string(i);
auto clsid = createClsidFromStr(id);
auto pit = std::find(cameraIds.begin(), cameraIds.end(), id);
auto cit = std::find(cameraClsids.begin(), cameraClsids.end(), clsid);
// Check if the path is being used, if not return it.
if (pit == cameraPaths.end() && cit == cameraClsids.end())
return path;
// Check if the ID is being used, if not return it.
if (pit == cameraIds.end() && cit == cameraClsids.end())
return id;
}
return {};
@ -399,7 +399,7 @@ int AkVCam::Preferences::cameraFromCLSID(const CLSID &clsid)
AkLogDebug() << "CLSID: " << stringFromIid(clsid) << std::endl;
for (size_t i = 0; i < camerasCount(); i++) {
auto cameraClsid = createClsidFromStr(cameraPath(i));
auto cameraClsid = createClsidFromStr(cameraId(i));
if (IsEqualCLSID(cameraClsid, clsid))
return int(i);
@ -408,19 +408,19 @@ int AkVCam::Preferences::cameraFromCLSID(const CLSID &clsid)
return -1;
}
int AkVCam::Preferences::cameraFromPath(const std::string &path)
int AkVCam::Preferences::cameraFromId(const std::string &deviceId)
{
for (size_t i = 0; i < camerasCount(); i++)
if (cameraPath(i) == path)
if (cameraId(i) == deviceId)
return int(i);
return -1;
}
bool AkVCam::Preferences::cameraExists(const std::string &path)
bool AkVCam::Preferences::cameraExists(const std::string &deviceId)
{
for (DWORD i = 0; i < camerasCount(); i++)
if (cameraPath(i) == path)
if (cameraId(i) == deviceId)
return true;
return false;
@ -449,11 +449,11 @@ bool AkVCam::Preferences::cameraSetDescription(size_t cameraIndex,
true);
}
std::string AkVCam::Preferences::cameraPath(size_t cameraIndex)
std::string AkVCam::Preferences::cameraId(size_t cameraIndex)
{
return readString("Cameras\\"
+ std::to_string(cameraIndex + 1)
+ "\\path",
+ "\\id",
{},
true);
}

View file

@ -59,20 +59,20 @@ namespace AkVCam
const std::string &deviceId);
std::string addCamera(const std::string &description,
const std::vector<VideoFormat> &formats);
std::string addCamera(const std::string &path,
std::string addCamera(const std::string &deviceId,
const std::string &description,
const std::vector<VideoFormat> &formats);
bool removeCamera(const std::string &path);
bool removeCamera(const std::string &deviceId);
size_t camerasCount();
bool idDeviceIdTaken(const std::string &deviceId);
std::string createDevicePath();
std::string createDeviceId();
int cameraFromCLSID(const CLSID &clsid);
int cameraFromPath(const std::string &path);
bool cameraExists(const std::string &path);
int cameraFromId(const std::string &deviceId);
bool cameraExists(const std::string &deviceId);
std::string cameraDescription(size_t cameraIndex);
bool cameraSetDescription(size_t cameraIndex,
const std::string &description);
std::string cameraPath(size_t cameraIndex);
std::string cameraId(size_t cameraIndex);
size_t formatsCount(size_t cameraIndex);
VideoFormat cameraFormat(size_t cameraIndex, size_t formatIndex);
std::vector<VideoFormat> cameraFormats(size_t cameraIndex);

View file

@ -122,7 +122,7 @@ namespace AkVCam
void listenerRemove (Message *message);
bool isRoot() const;
int sudo(const std::vector<std::string> &parameters,
int exec(const std::vector<std::string> &parameters,
const std::string &directory={},
bool show=false);
std::string assistant() const;
@ -313,7 +313,7 @@ std::vector<std::string> AkVCam::IpcBridge::devices() const
AkLogInfo() << "Devices:" << std::endl;
for (size_t i = 0; i < nCameras; i++) {
auto deviceId = Preferences::cameraPath(i);
auto deviceId = Preferences::cameraId(i);
devices.push_back(deviceId);
AkLogInfo() << " " << deviceId << std::endl;
}
@ -324,7 +324,7 @@ std::vector<std::string> AkVCam::IpcBridge::devices() const
std::string AkVCam::IpcBridge::description(const std::string &deviceId) const
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -336,7 +336,7 @@ void AkVCam::IpcBridge::setDescription(const std::string &deviceId,
const std::string &description)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraSetDescription(size_t(cameraIndex), description);
@ -368,7 +368,7 @@ AkVCam::PixelFormat AkVCam::IpcBridge::defaultPixelFormat(StreamType type) const
std::vector<AkVCam::VideoFormat> AkVCam::IpcBridge::formats(const std::string &deviceId) const
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -380,7 +380,7 @@ void AkVCam::IpcBridge::setFormats(const std::string &deviceId,
const std::vector<VideoFormat> &formats)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraSetFormats(size_t(cameraIndex), formats);
@ -415,7 +415,7 @@ std::string AkVCam::IpcBridge::broadcaster(const std::string &deviceId) const
std::vector<AkVCam::DeviceControl> AkVCam::IpcBridge::controls(const std::string &deviceId)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return {};
@ -435,7 +435,7 @@ void AkVCam::IpcBridge::setControls(const std::string &deviceId,
const std::map<std::string, int> &controls)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return;
@ -588,7 +588,7 @@ void AkVCam::IpcBridge::addFormat(const std::string &deviceId,
int index)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraAddFormat(size_t(cameraIndex),
@ -599,7 +599,7 @@ void AkVCam::IpcBridge::addFormat(const std::string &deviceId,
void AkVCam::IpcBridge::removeFormat(const std::string &deviceId, int index)
{
AkLogFunction();
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex >= 0)
Preferences::cameraRemoveFormat(size_t(cameraIndex),
@ -643,7 +643,7 @@ void AkVCam::IpcBridge::updateDevices()
auto altManager = this->d->alternativeManager();
if (!altManager.empty())
this->d->sudo({altManager, "update"});
this->d->exec({altManager, "update"});
DeleteFileA(lockFileName.c_str());
}
@ -857,17 +857,6 @@ bool AkVCam::IpcBridge::needsRoot(const std::string &operation) const
return it != operations.end() && !this->d->isRoot();
}
int AkVCam::IpcBridge::sudo(int argc, char **argv) const
{
AkLogFunction();
std::vector<std::string> arguments;
for (int i = 0; i < argc; i++)
arguments.push_back(argv[i]);
return this->d->sudo(arguments);
}
std::vector<std::string> AkVCam::IpcBridge::hacks() const
{
std::vector<std::string> hacks;
@ -978,16 +967,16 @@ void AkVCam::IpcBridgePrivate::updateDeviceSharedProperties()
AkLogFunction();
for (size_t i = 0; i < Preferences::camerasCount(); i++) {
auto path = Preferences::cameraPath(i);
auto deviceId = Preferences::cameraId(i);
Message message;
message.messageId = AKVCAM_ASSISTANT_MSG_DEVICE_BROADCASTING;
message.dataSize = sizeof(MsgBroadcasting);
auto data = messageData<MsgBroadcasting>(&message);
memcpy(data->device,
path.c_str(),
(std::min<size_t>)(path.size(), MAX_STRING));
deviceId.c_str(),
(std::min<size_t>)(deviceId.size(), MAX_STRING));
this->m_mainServer.sendMessage(&message);
this->updateDeviceSharedProperties(path,
this->updateDeviceSharedProperties(deviceId,
std::string(data->broadcaster));
}
}
@ -1120,7 +1109,7 @@ void AkVCam::IpcBridgePrivate::deviceUpdate(Message *message)
auto nCameras = Preferences::camerasCount();
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraPath(i));
devices.push_back(Preferences::cameraId(i));
AKVCAM_EMIT(this->self, DevicesChanged, devices)
}
@ -1174,7 +1163,7 @@ void AkVCam::IpcBridgePrivate::controlsUpdated(Message *message)
AkLogFunction();
auto data = messageData<MsgControlsUpdated>(message);
std::string deviceId(data->device);
auto cameraIndex = Preferences::cameraFromPath(deviceId);
auto cameraIndex = Preferences::cameraFromId(deviceId);
if (cameraIndex < 0)
return;
@ -1237,7 +1226,7 @@ bool AkVCam::IpcBridgePrivate::isRoot() const
return elevationInfo.TokenIsElevated;
}
int AkVCam::IpcBridgePrivate::sudo(const std::vector<std::string> &parameters,
int AkVCam::IpcBridgePrivate::exec(const std::vector<std::string> &parameters,
const std::string &directory,
bool show)
{
@ -1276,7 +1265,7 @@ int AkVCam::IpcBridgePrivate::sudo(const std::vector<std::string> &parameters,
execInfo.cbSize = sizeof(SHELLEXECUTEINFO);
execInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
execInfo.hwnd = nullptr;
execInfo.lpVerb = "runas";
execInfo.lpVerb = "";
execInfo.lpFile = command.data();
execInfo.lpParameters = params.data();
execInfo.lpDirectory = directory.data();
@ -1454,30 +1443,41 @@ int AkVCam::IpcBridgePrivate::setServiceUp(const std::vector<std::string> &args)
if (assistant.empty())
return -1;
auto result = this->sudo({assistant, "--install"});
auto result = this->exec({assistant, "--install"});
if (result < 0)
return result;
}
// Start the service.
bool result = false;
auto manager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (manager) {
auto service = OpenService(manager,
TEXT(DSHOW_PLUGIN_ASSISTANT_NAME),
SERVICE_START);
if (!this->isServiceRunning()) {
bool result = false;
auto manager = OpenSCManager(nullptr, nullptr, SC_MANAGER_CONNECT);
if (service) {
result = StartService(service, 0, nullptr);
CloseServiceHandle(service);
if (manager) {
auto service = OpenService(manager,
TEXT(DSHOW_PLUGIN_ASSISTANT_NAME),
SERVICE_START);
if (service) {
result = StartService(service, 0, nullptr);
CloseServiceHandle(service);
}
CloseServiceHandle(manager);
}
CloseServiceHandle(manager);
if (!result)
return -1;
}
return result? 0: -1;
auto pluginPath = locatePluginPath();
bool ok = Preferences::write("installPath",
realPath(pluginPath + "\\.."),
true);
return ok? 0: -1;
}
int AkVCam::IpcBridgePrivate::setServiceDown(const std::vector<std::string> &args)
@ -1526,7 +1526,7 @@ int AkVCam::IpcBridgePrivate::setServiceDown(const std::vector<std::string> &arg
// Unistall the service.
return this->sudo({servicePath, "--uninstall"});
return this->exec({servicePath, "--uninstall"});
}
AkVCam::Hack::Hack()

View file

@ -160,7 +160,7 @@ std::string AkVCam::BaseFilter::deviceId()
if (cameraIndex < 0)
return {};
return Preferences::cameraPath(size_t(cameraIndex));
return Preferences::cameraId(size_t(cameraIndex));
}
std::string AkVCam::BaseFilter::broadcaster()
@ -363,12 +363,12 @@ void AkVCam::BaseFilter::stateChanged(FILTER_STATE state)
if (cameraIndex < 0)
return;
auto path = Preferences::cameraPath(size_t(cameraIndex));
auto deviceId = Preferences::cameraId(size_t(cameraIndex));
if (state == State_Running)
this->d->m_ipcBridge.addListener(path);
this->d->m_ipcBridge.addListener(deviceId);
else
this->d->m_ipcBridge.removeListener(path);
this->d->m_ipcBridge.removeListener(deviceId);
}
AkVCam::BaseFilterPrivate::BaseFilterPrivate(AkVCam::BaseFilter *self,
@ -417,9 +417,9 @@ IEnumPins *AkVCam::BaseFilterPrivate::pinsForDevice(const std::string &deviceId)
if (cameraIndex < 0)
return nullptr;
auto path = Preferences::cameraPath(size_t(cameraIndex));
auto id = Preferences::cameraId(size_t(cameraIndex));
if (path.empty() || path != deviceId)
if (id.empty() || id != deviceId)
return nullptr;
IEnumPins *pins = nullptr;
@ -437,20 +437,20 @@ void AkVCam::BaseFilterPrivate::updatePins()
if (cameraIndex < 0)
return;
auto path = Preferences::cameraPath(size_t(cameraIndex));
auto deviceId = Preferences::cameraId(size_t(cameraIndex));
auto broadcaster = this->m_ipcBridge.broadcaster(path);
AkVCamDevicePinCall(path,
auto broadcaster = this->m_ipcBridge.broadcaster(deviceId);
AkVCamDevicePinCall(deviceId,
this,
setBroadcasting,
broadcaster)
auto controlsList = this->m_ipcBridge.controls(path);
auto controlsList = this->m_ipcBridge.controls(deviceId);
std::map<std::string, int> controls;
for (auto &control: controlsList)
controls[control.id] = control.value;
AkVCamDevicePinCall(path, this, setControls, controls)
AkVCamDevicePinCall(deviceId, this, setControls, controls)
}
void AkVCam::BaseFilterPrivate::serverStateChanged(void *userData,

View file

@ -112,7 +112,7 @@ AkVCam::Pin::Pin(BaseFilter *baseFilter,
this->d->m_mediaTypes = new AkVCam::EnumMediaTypes(formats);
this->d->m_mediaTypes->AddRef();
auto cameraIndex = Preferences::cameraFromPath(baseFilter->deviceId());
auto cameraIndex = Preferences::cameraFromId(baseFilter->deviceId());
this->d->m_broadcaster = baseFilter->broadcaster();
this->d->m_controls["hflip"] =
Preferences::cameraControlValue(cameraIndex, "hflip");

View file

@ -103,15 +103,15 @@ STDAPI DllRegisterServer()
for (size_t i = 0; i < AkVCam::Preferences::camerasCount(); i++) {
auto description = AkVCam::Preferences::cameraDescription(i);
auto path = AkVCam::Preferences::cameraPath(i);
auto clsid = AkVCam::createClsidFromStr(path);
auto deviceId = AkVCam::Preferences::cameraId(i);
auto clsid = AkVCam::createClsidFromStr(deviceId);
AkLogInfo() << "Creating Camera" << std::endl;
AkLogInfo() << "\tDescription: " << description << std::endl;
AkLogInfo() << "\tPath: " << path << std::endl;
AkLogInfo() << "\tID: " << deviceId << std::endl;
AkLogInfo() << "\tCLSID: " << AkVCam::stringFromIid(clsid) << std::endl;
ok &= pluginInterface()->createDevice(path, description);
ok &= pluginInterface()->createDevice(deviceId, description);
}
return ok? S_OK: E_UNEXPECTED;

View file

@ -259,7 +259,7 @@ unregisterFilter_failed:
AkLogInfo() << "Result: " << stringFromResult(result) << std::endl;
}
bool AkVCam::PluginInterface::setDevicePath(const std::string &deviceId) const
bool AkVCam::PluginInterface::setDeviceId(const std::string &deviceId) const
{
AkLogFunction();
@ -279,7 +279,7 @@ bool AkVCam::PluginInterface::setDevicePath(const std::string &deviceId) const
bool ok = false;
if (result != ERROR_SUCCESS)
goto setDevicePath_failed;
goto setDeviceId_failed;
result = RegSetValueExA(hKey,
"DevicePath",
@ -289,11 +289,11 @@ bool AkVCam::PluginInterface::setDevicePath(const std::string &deviceId) const
DWORD(deviceId.size() + 1));
if (result != ERROR_SUCCESS)
goto setDevicePath_failed;
goto setDeviceId_failed;
ok = true;
setDevicePath_failed:
setDeviceId_failed:
if (hKey)
RegCloseKey(hKey);
@ -313,7 +313,7 @@ bool AkVCam::PluginInterface::createDevice(const std::string &deviceId,
if (!this->registerFilter(deviceId, description))
goto createDevice_failed;
if (!this->setDevicePath(deviceId))
if (!this->setDeviceId(deviceId))
goto createDevice_failed;
return true;

View file

@ -44,7 +44,7 @@ namespace AkVCam
const std::string &description) const;
void unregisterFilter(const std::string &deviceId) const;
void unregisterFilter(const CLSID &clsid) const;
bool setDevicePath(const std::string &deviceId) const;
bool setDeviceId(const std::string &deviceId) const;
bool createDevice(const std::string &deviceId,
const std::string &description);
void destroyDevice(const std::string &deviceId);

View file

@ -45,6 +45,13 @@ Function InstallPlugin
ExecShellWait "" "sc" "start AkVCamAssistant" SW_HIDE
${Next}
${If} ${RunningX64}
SetRegView 64
${EndIf}
WriteRegStr HKLM "SOFTWARE\Webcamoid\VirtualCamera" "installPath" "$INSTDIR"
SetRegView default
FunctionEnd
Function un.InstallPlugin