Can compile again in Windows.

This commit is contained in:
Gonzalo Exequiel Pedone 2020-10-06 11:36:34 -03:00
parent d96eb195b6
commit 716a67221b
No known key found for this signature in database
GPG key ID: B8B09E63E9B85BAF
24 changed files with 421 additions and 546 deletions

View file

@ -75,11 +75,8 @@ namespace AkVCam
const VideoFrame &frame)
AKVCAM_SIGNAL(PictureChanged,
const std::string &picture)
AKVCAM_SIGNAL(DeviceAdded,
const std::string &deviceId)
AKVCAM_SIGNAL(DeviceRemoved,
const std::string &deviceId)
AKVCAM_SIGNAL(DevicesUpdated, void *unused)
AKVCAM_SIGNAL(DevicesChanged,
const std::vector<std::string> &devices)
AKVCAM_SIGNAL(ListenerAdded,
const std::string &deviceId,
const std::string &listener)

View file

@ -42,8 +42,6 @@ namespace AkVCam
{
struct AssistantDevice
{
std::wstring description;
std::vector<VideoFormat> formats;
std::string broadcaster;
std::vector<std::string> listeners;
};
@ -61,30 +59,22 @@ namespace AkVCam
double m_timeout {0.0};
AssistantPrivate();
~AssistantPrivate();
inline static uint64_t id();
bool startTimer();
void stopTimer();
static void timerTimeout(CFRunLoopTimerRef timer, void *info);
void loadCameras();
void releaseDevicesFromPeer(const std::string &portName);
void peerDied();
void requestPort(xpc_connection_t client, xpc_object_t event);
void addPort(xpc_connection_t client, xpc_object_t event);
void removePortByName(const std::string &portName);
void removePort(xpc_connection_t client, xpc_object_t event);
void deviceCreate(xpc_connection_t client, xpc_object_t event);
void deviceDestroyById(const std::string &deviceId);
void deviceDestroy(xpc_connection_t client, xpc_object_t event);
void deviceUpdate(xpc_connection_t client, xpc_object_t event);
void devicesUpdate(xpc_connection_t client, xpc_object_t event);
void setBroadcasting(xpc_connection_t client, xpc_object_t event);
void frameReady(xpc_connection_t client, xpc_object_t event);
void pictureUpdated(xpc_connection_t client, xpc_object_t event);
void listeners(xpc_connection_t client, xpc_object_t event);
void listener(xpc_connection_t client, xpc_object_t event);
void devices(xpc_connection_t client, xpc_object_t event);
void description(xpc_connection_t client, xpc_object_t event);
void formats(xpc_connection_t client, xpc_object_t event);
void broadcasting(xpc_connection_t client, xpc_object_t event);
void controlsUpdated(xpc_connection_t client, xpc_object_t event);
void listenerAdd(xpc_connection_t client, xpc_object_t event);
@ -137,12 +127,7 @@ AkVCam::AssistantPrivate::AssistantPrivate()
{AKVCAM_ASSISTANT_MSG_REQUEST_PORT , AKVCAM_BIND_FUNC(AssistantPrivate::requestPort) },
{AKVCAM_ASSISTANT_MSG_ADD_PORT , AKVCAM_BIND_FUNC(AssistantPrivate::addPort) },
{AKVCAM_ASSISTANT_MSG_REMOVE_PORT , AKVCAM_BIND_FUNC(AssistantPrivate::removePort) },
{AKVCAM_ASSISTANT_MSG_DEVICE_CREATE , AKVCAM_BIND_FUNC(AssistantPrivate::deviceCreate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY , AKVCAM_BIND_FUNC(AssistantPrivate::deviceDestroy) },
{AKVCAM_ASSISTANT_MSG_DEVICES , AKVCAM_BIND_FUNC(AssistantPrivate::devices) },
{AKVCAM_ASSISTANT_MSG_DEVICE_DESCRIPTION , AKVCAM_BIND_FUNC(AssistantPrivate::description) },
{AKVCAM_ASSISTANT_MSG_DEVICE_FORMATS , AKVCAM_BIND_FUNC(AssistantPrivate::formats) },
{AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE , AKVCAM_BIND_FUNC(AssistantPrivate::deviceUpdate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE , AKVCAM_BIND_FUNC(AssistantPrivate::devicesUpdate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_ADD , AKVCAM_BIND_FUNC(AssistantPrivate::listenerAdd) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_REMOVE , AKVCAM_BIND_FUNC(AssistantPrivate::listenerRemove) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENERS , AKVCAM_BIND_FUNC(AssistantPrivate::listeners) },
@ -152,24 +137,9 @@ AkVCam::AssistantPrivate::AssistantPrivate()
{AKVCAM_ASSISTANT_MSG_DEVICE_CONTROLS_UPDATED, AKVCAM_BIND_FUNC(AssistantPrivate::controlsUpdated)},
};
this->loadCameras();
this->startTimer();
}
AkVCam::AssistantPrivate::~AssistantPrivate()
{
for (auto &device: this->m_deviceConfigs) {
auto notification = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_int64(notification, "message", AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY);
xpc_dictionary_set_string(notification, "device", device.first.c_str());
for (auto &client: this->m_clients)
xpc_connection_send_message(client.second, notification);
xpc_release(notification);
}
}
uint64_t AkVCam::AssistantPrivate::id()
{
static uint64_t id = 0;
@ -229,19 +199,6 @@ void AkVCam::AssistantPrivate::timerTimeout(CFRunLoopTimerRef timer, void *info)
CFRunLoopStop(CFRunLoopGetMain());
}
void AkVCam::AssistantPrivate::loadCameras()
{
AkLogFunction();
for (size_t i = 0; i < Preferences::camerasCount(); i++) {
auto path = Preferences::cameraPath(i);
this->m_deviceConfigs[path] = {};
this->m_deviceConfigs[path].description =
Preferences::cameraDescription(i);
this->m_deviceConfigs[path].formats = Preferences::cameraFormats(i);
}
}
void AkVCam::AssistantPrivate::releaseDevicesFromPeer(const std::string &portName)
{
AkLogFunction();
@ -370,80 +327,7 @@ void AkVCam::AssistantPrivate::removePort(xpc_connection_t client,
this->removePortByName(xpc_dictionary_get_string(event, "port"));
}
void AkVCam::AssistantPrivate::deviceCreate(xpc_connection_t client,
xpc_object_t event)
{
AkLogFunction();
std::string portName = xpc_dictionary_get_string(event, "port");
AkLogInfo() << "Port Name: " << portName << std::endl;
size_t len = 0;
auto data = reinterpret_cast<const wchar_t *>(xpc_dictionary_get_data(event,
"description",
&len));
std::wstring description(data, len / sizeof(wchar_t));
auto formatsArray = xpc_dictionary_get_array(event, "formats");
std::vector<VideoFormat> formats;
for (size_t i = 0; i < xpc_array_get_count(formatsArray); i++) {
auto format = xpc_array_get_dictionary(formatsArray, i);
auto fourcc = FourCC(xpc_dictionary_get_uint64(format, "fourcc"));
auto width = int(xpc_dictionary_get_int64(format, "width"));
auto height = int(xpc_dictionary_get_int64(format, "height"));
auto frameRate = Fraction(xpc_dictionary_get_string(format, "fps"));
formats.push_back(VideoFormat {fourcc, width, height, {frameRate}});
}
auto deviceId = Preferences::addCamera(description, formats);
this->m_deviceConfigs[deviceId] = {};
this->m_deviceConfigs[deviceId].description = description;
this->m_deviceConfigs[deviceId].formats = formats;
auto notification = xpc_copy(event);
xpc_dictionary_set_string(notification, "device", deviceId.c_str());
for (auto &client: this->m_clients)
xpc_connection_send_message(client.second, notification);
xpc_release(notification);
AkLogInfo() << "Device created: " << deviceId << std::endl;
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_string(reply, "device", deviceId.c_str());
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::AssistantPrivate::deviceDestroyById(const std::string &deviceId)
{
AkLogFunction();
auto it = this->m_deviceConfigs.find(deviceId);
if (it != this->m_deviceConfigs.end()) {
this->m_deviceConfigs.erase(it);
auto notification = xpc_dictionary_create(nullptr, nullptr, 0);
xpc_dictionary_set_int64(notification, "message", AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY);
xpc_dictionary_set_string(notification, "device", deviceId.c_str());
for (auto &client: this->m_clients)
xpc_connection_send_message(client.second, notification);
xpc_release(notification);
}
}
void AkVCam::AssistantPrivate::deviceDestroy(xpc_connection_t client,
xpc_object_t event)
{
UNUSED(client);
AkLogFunction();
std::string deviceId = xpc_dictionary_get_string(event, "device");
this->deviceDestroyById(deviceId);
Preferences::removeCamera(deviceId);
}
void AkVCam::AssistantPrivate::deviceUpdate(xpc_connection_t client,
void AkVCam::AssistantPrivate::devicesUpdate(xpc_connection_t client,
xpc_object_t event)
{
UNUSED(client);
@ -582,70 +466,6 @@ void AkVCam::AssistantPrivate::listener(xpc_connection_t client,
xpc_release(reply);
}
void AkVCam::AssistantPrivate::devices(xpc_connection_t client,
xpc_object_t event)
{
AkLogFunction();
auto devices = xpc_array_create(nullptr, 0);
for (auto &device: this->m_deviceConfigs) {
auto deviceObj = xpc_string_create(device.first.c_str());
xpc_array_append_value(devices, deviceObj);
}
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_value(reply, "devices", devices);
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::AssistantPrivate::description(xpc_connection_t client,
xpc_object_t event)
{
AkLogFunction();
std::string deviceId = xpc_dictionary_get_string(event, "device");
std::wstring description;
if (this->m_deviceConfigs.count(deviceId) > 0)
description = this->m_deviceConfigs[deviceId].description;
AkLogInfo() << "Description for device "
<< deviceId
<< ": "
<< std::string(description.begin(), description.end())
<< std::endl;
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_data(reply,
"description",
description.c_str(),
description.size() * sizeof(wchar_t));
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::AssistantPrivate::formats(xpc_connection_t client,
xpc_object_t event)
{
AkLogFunction();
std::string deviceId = xpc_dictionary_get_string(event, "device");
auto formats = xpc_array_create(nullptr, 0);
if (this->m_deviceConfigs.count(deviceId) > 0)
for (auto &format: this->m_deviceConfigs[deviceId].formats) {
auto dictFormat = xpc_dictionary_create(nullptr, nullptr, 0);
xpc_dictionary_set_uint64(dictFormat, "fourcc", format.fourcc());
xpc_dictionary_set_int64(dictFormat, "width", format.width());
xpc_dictionary_set_int64(dictFormat, "height", format.height());
xpc_dictionary_set_string(dictFormat, "fps", format.minimumFrameRate().toString().c_str());
xpc_array_append_value(formats, dictFormat);
}
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_value(reply, "formats", formats);
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::AssistantPrivate::broadcasting(xpc_connection_t client,
xpc_object_t event)
{

View file

@ -36,12 +36,7 @@
#define AKVCAM_ASSISTANT_MSG_REMOVE_PORT 0x102
// Device control and information
#define AKVCAM_ASSISTANT_MSG_DEVICES 0x200
#define AKVCAM_ASSISTANT_MSG_DEVICE_CREATE 0x201
#define AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY 0x202
#define AKVCAM_ASSISTANT_MSG_DEVICE_DESCRIPTION 0x203
#define AKVCAM_ASSISTANT_MSG_DEVICE_FORMATS 0x204
#define AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE 0x205
#define AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE 0x200
// Device listeners controls
#define AKVCAM_ASSISTANT_MSG_DEVICE_LISTENERS 0x300

View file

@ -67,8 +67,6 @@ namespace AkVCam
// Message handling methods
void isAlive(xpc_connection_t client, xpc_object_t event);
void deviceCreate(xpc_connection_t client, xpc_object_t event);
void deviceDestroy(xpc_connection_t client, xpc_object_t event);
void deviceUpdate(xpc_connection_t client, xpc_object_t event);
void frameReady(xpc_connection_t client, xpc_object_t event);
void pictureUpdated(xpc_connection_t client, xpc_object_t event);
@ -276,9 +274,9 @@ void AkVCam::IpcBridge::unregisterPeer()
std::vector<std::string> AkVCam::IpcBridge::devices() const
{
AkLogFunction();
auto nCameras = Preferences::camerasCount();
std::vector<std::string> devices;
AkLogInfo() << "Devices:" << std::endl;
std::vector<std::string> devices;
auto nCameras = Preferences::camerasCount();
for (size_t i = 0; i < nCameras; i++) {
auto deviceId = Preferences::cameraPath(i);
@ -778,8 +776,6 @@ AkVCam::IpcBridgePrivate::IpcBridgePrivate(IpcBridge *self):
{AKVCAM_ASSISTANT_MSG_ISALIVE , AKVCAM_BIND_FUNC(IpcBridgePrivate::isAlive) },
{AKVCAM_ASSISTANT_MSG_FRAME_READY , AKVCAM_BIND_FUNC(IpcBridgePrivate::frameReady) },
{AKVCAM_ASSISTANT_MSG_PICTURE_UPDATED , AKVCAM_BIND_FUNC(IpcBridgePrivate::pictureUpdated) },
{AKVCAM_ASSISTANT_MSG_DEVICE_CREATE , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceCreate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceDestroy) },
{AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceUpdate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_ADD , AKVCAM_BIND_FUNC(IpcBridgePrivate::listenerAdd) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_REMOVE , AKVCAM_BIND_FUNC(IpcBridgePrivate::listenerRemove) },
@ -842,45 +838,26 @@ void AkVCam::IpcBridgePrivate::isAlive(xpc_connection_t client,
xpc_object_t event)
{
AkLogFunction();
auto reply = xpc_dictionary_create_reply(event);
xpc_dictionary_set_bool(reply, "alive", true);
xpc_connection_send_message(client, reply);
xpc_release(reply);
}
void AkVCam::IpcBridgePrivate::deviceCreate(xpc_connection_t client,
xpc_object_t event)
{
UNUSED(client);
AkLogFunction();
std::string device = xpc_dictionary_get_string(event, "device");
for (auto bridge: this->m_bridges)
AKVCAM_EMIT(bridge, DeviceAdded, device)
}
void AkVCam::IpcBridgePrivate::deviceDestroy(xpc_connection_t client,
xpc_object_t event)
{
UNUSED(client);
AkLogFunction();
std::string device = xpc_dictionary_get_string(event, "device");
for (auto bridge: this->m_bridges)
AKVCAM_EMIT(bridge, DeviceRemoved, device)
}
void AkVCam::IpcBridgePrivate::deviceUpdate(xpc_connection_t client,
xpc_object_t event)
{
UNUSED(client);
UNUSED(event);
AkLogFunction();
std::vector<std::string> devices;
auto nCameras = Preferences::camerasCount();
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraPath(i));
for (auto bridge: this->m_bridges)
AKVCAM_EMIT(bridge, DevicesUpdated, nullptr)
AKVCAM_EMIT(bridge, DevicesChanged, devices)
}
void AkVCam::IpcBridgePrivate::frameReady(xpc_connection_t client,

View file

@ -158,9 +158,7 @@ AkVCam::PluginInterface::PluginInterface():
this->d->m_reserved = 0;
this->d->m_ipcBridge.connectServerStateChanged(this, &PluginInterface::serverStateChanged);
this->d->m_ipcBridge.connectDeviceAdded(this, &PluginInterface::deviceAdded);
this->d->m_ipcBridge.connectDeviceRemoved(this, &PluginInterface::deviceRemoved);
this->d->m_ipcBridge.connectDevicesUpdated(this, &PluginInterface::devicesUpdated);
this->d->m_ipcBridge.connectDevicesChanged(this, &PluginInterface::devicesChanged);
this->d->m_ipcBridge.connectFrameReady(this, &PluginInterface::frameReady);
this->d->m_ipcBridge.connectPictureChanged(this, &PluginInterface::pictureChanged);
this->d->m_ipcBridge.connectBroadcastingChanged(this, &PluginInterface::setBroadcasting);
@ -227,11 +225,13 @@ OSStatus AkVCam::PluginInterface::InitializeWithObjectID(CMIOObjectID objectID)
{
AkLogFunction();
AkLogInfo() << objectID << std::endl;
this->m_objectID = objectID;
for (auto &deviceId: this->d->m_ipcBridge.devices())
this->deviceAdded(this, deviceId);
for (auto &deviceId: this->d->m_ipcBridge.devices()) {
auto description = this->d->m_ipcBridge.description(deviceId);
auto formats = this->d->m_ipcBridge.formats(deviceId);
this->createDevice(deviceId, description, formats);
}
return kCMIOHardwareNoError;
}
@ -240,6 +240,18 @@ OSStatus AkVCam::PluginInterface::Teardown()
{
AkLogFunction();
std::vector<std::string> oldDevices;
for (auto &device: this->m_devices) {
std::string deviceId;
device->properties().getProperty(kCMIODevicePropertyDeviceUID,
&deviceId);
oldDevices.push_back(deviceId);
}
for (auto &deviceId: oldDevices)
this->destroyDevice(deviceId);
return kCMIOHardwareNoError;
}
@ -256,43 +268,22 @@ void AkVCam::PluginInterface::serverStateChanged(void *userData,
self->d->updateDevices();
}
void AkVCam::PluginInterface::deviceAdded(void *userData,
const std::string &deviceId)
void AkVCam::PluginInterface::devicesChanged(void *userData,
const std::vector<std::string> &devices)
{
AkLogFunction();
AkLogInfo() << "Device Added: " << deviceId << std::endl;
auto self = reinterpret_cast<PluginInterface *>(userData);
auto description = self->d->m_ipcBridge.description(deviceId);
auto formats = self->d->m_ipcBridge.formats(deviceId);
self->createDevice(deviceId, description, formats);
}
void AkVCam::PluginInterface::deviceRemoved(void *userData,
const std::string &deviceId)
{
AkLogFunction();
AkLogInfo() << "Device Removed: " << deviceId << std::endl;
auto self = reinterpret_cast<PluginInterface *>(userData);
self->destroyDevice(deviceId);
}
void AkVCam::PluginInterface::devicesUpdated(void *userData, void *unused)
{
UNUSED(unused);
UNUSED(devices);
AkLogFunction();
auto self = reinterpret_cast<PluginInterface *>(userData);
std::vector<std::string> devices;
std::vector<std::string> oldDevices;
for (auto &device: self->m_devices) {
std::string deviceId;
device->properties().getProperty(kCMIODevicePropertyDeviceUID,
&deviceId);
devices.push_back(deviceId);
oldDevices.push_back(deviceId);
}
for (auto &deviceId: devices)
for (auto &deviceId: oldDevices)
self->destroyDevice(deviceId);
for (auto &deviceId: self->d->m_ipcBridge.devices()) {

View file

@ -50,11 +50,8 @@ namespace AkVCam
static void serverStateChanged(void *userData,
IpcBridge::ServerState state);
static void deviceAdded(void *userData,
const std::string &deviceId);
static void deviceRemoved(void *userData,
const std::string &deviceId);
static void devicesUpdated(void *userData, void *unused);
static void devicesChanged(void *userData,
const std::vector<std::string> &devices);
static void frameReady(void *userData,
const std::string &deviceId,
const VideoFrame &frame);

View file

@ -40,12 +40,7 @@
#define AKVCAM_ASSISTANT_MSG_REMOVE_PORT 0x102
// Device control and information
#define AKVCAM_ASSISTANT_MSG_DEVICES 0x200
#define AKVCAM_ASSISTANT_MSG_DEVICE_CREATE 0x201
#define AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY 0x202
#define AKVCAM_ASSISTANT_MSG_DEVICE_DESCRIPTION 0x203
#define AKVCAM_ASSISTANT_MSG_DEVICE_FORMATS 0x204
#define AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE 0x205
#define AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE 0x200
// Device listeners controls
#define AKVCAM_ASSISTANT_MSG_DEVICE_LISTENERS 0x300

View file

@ -261,6 +261,10 @@ void AkVCam::Preferences::deleteKey(const std::string &key)
std::string subKey;
std::string val;
splitSubKey(key, subKey, val);
if (val.empty()) {
deleteTree(HKEY_LOCAL_MACHINE, subKey.c_str(), KEY_WOW64_64KEY);
} else {
HKEY hkey = nullptr;
auto result = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
subKey.c_str(),
@ -268,15 +272,11 @@ void AkVCam::Preferences::deleteKey(const std::string &key)
KEY_ALL_ACCESS | KEY_WOW64_64KEY,
&hkey);
if (result != ERROR_SUCCESS)
return;
if (val.empty())
RegDeleteTreeA(hkey, nullptr);
else
if (result == ERROR_SUCCESS) {
RegDeleteValueA(hkey, val.c_str());
RegCloseKey(hkey);
}
}
}
void AkVCam::Preferences::move(const std::string &keyFrom,
@ -308,7 +308,7 @@ void AkVCam::Preferences::move(const std::string &keyFrom,
nullptr);
if (result == ERROR_SUCCESS) {
result = RegCopyTree(hkeyFrom, nullptr, hkeyTo);
result = copyTree(hkeyFrom, nullptr, hkeyTo, KEY_WOW64_64KEY);
if (result == ERROR_SUCCESS)
deleteKey(keyFrom);
@ -441,6 +441,18 @@ std::string AkVCam::Preferences::createDevicePath()
return {};
}
int AkVCam::Preferences::cameraFromCLSID(const CLSID &clsid)
{
for (DWORD i = 0; i < camerasCount(); i++) {
auto cameraClsid = createClsidFromStr(cameraPath(i));
if (IsEqualCLSID(cameraClsid, clsid))
return int(i);
}
return -1;
}
int AkVCam::Preferences::cameraFromPath(const std::string &path)
{
for (size_t i = 0; i < camerasCount(); i++)

View file

@ -55,6 +55,7 @@ namespace AkVCam
void removeCamera(const std::string &path);
size_t camerasCount();
std::string createDevicePath();
int cameraFromCLSID(const CLSID &clsid);
int cameraFromPath(const std::string &path);
bool cameraExists(const std::string &path);
std::wstring cameraDescription(size_t cameraIndex);

View file

@ -792,3 +792,210 @@ std::string AkVCam::stringFromMediaSample(IMediaSample *mediaSample)
return ss.str();
}
LSTATUS AkVCam::deleteTree(HKEY key, LPCSTR subkey, REGSAM samFlags)
{
HKEY mainKey = key;
LONG result = ERROR_SUCCESS;
// Open subkey
if (subkey) {
result = RegOpenKeyExA(key,
subkey,
0,
KEY_ALL_ACCESS | samFlags,
&mainKey);
if (result != ERROR_SUCCESS)
return result;
}
// list subkeys and values.
DWORD subKeys = 0;
DWORD maxSubKeyLen = 0;
DWORD values = 0;
DWORD maxValueNameLen = 0;
result = RegQueryInfoKey(mainKey,
nullptr,
nullptr,
nullptr,
&subKeys,
&maxSubKeyLen,
nullptr,
&values,
&maxValueNameLen,
nullptr,
nullptr,
nullptr);
if (result != ERROR_SUCCESS) {
RegCloseKey(mainKey);
return result;
}
// Delete subkeys
for (DWORD i = 0; i < subKeys; i++) {
auto len = maxSubKeyLen + 1;
CHAR *name = new CHAR[len];
memset(name, 0, len * sizeof(CCHAR));
DWORD nameLen = len;
result = RegEnumKeyExA(mainKey,
i,
name,
&nameLen,
nullptr,
nullptr,
nullptr,
nullptr);
if (result == ERROR_SUCCESS)
deleteTree(mainKey, name, samFlags);
delete [] name;
}
// Delete values
for (DWORD i = 0; i < values; i++) {
auto len = maxValueNameLen + 1;
TCHAR *name = new TCHAR[len];
memset(name, 0, len * sizeof(TCHAR));
DWORD nameLen = len;
result = RegEnumValue(mainKey,
i,
name,
&nameLen,
0,
nullptr,
nullptr,
nullptr);
if (result == ERROR_SUCCESS)
RegDeleteValue(mainKey, name);
delete [] name;
}
// Delete this key
if (subkey) {
result = RegDeleteKeyExA(key, subkey, samFlags, 0);
RegCloseKey(mainKey);
}
return result;
}
LSTATUS AkVCam::copyTree(HKEY src, LPCSTR subkey, HKEY dst, REGSAM samFlags)
{
HKEY hkeyFrom = src;
LONG result = ERROR_SUCCESS;
// Open source subkey
if (subkey) {
result = RegOpenKeyExA(src,
subkey,
0,
KEY_READ | samFlags,
&hkeyFrom);
if (result != ERROR_SUCCESS)
return result;
}
// list subkeys and values.
DWORD subKeys = 0;
DWORD maxSubKeyLen = 0;
DWORD values = 0;
DWORD maxValueNameLen = 0;
DWORD maxValueLen = 0;
result = RegQueryInfoKey(hkeyFrom,
nullptr,
nullptr,
nullptr,
&subKeys,
&maxSubKeyLen,
nullptr,
&values,
&maxValueNameLen,
&maxValueLen,
nullptr,
nullptr);
if (result != ERROR_SUCCESS) {
if (subkey)
RegCloseKey(hkeyFrom);
return result;
}
// Copy subkeys
for (DWORD i = 0; i < subKeys; i++) {
auto len = maxSubKeyLen + 1;
CHAR *name = new CHAR[len];
memset(name, 0, len * sizeof(CCHAR));
DWORD nameLen = len;
result = RegEnumKeyExA(hkeyFrom,
i,
name,
&nameLen,
nullptr,
nullptr,
nullptr,
nullptr);
if (result == ERROR_SUCCESS) {
HKEY subkeyTo = nullptr;
result = RegCreateKeyExA(dst,
name,
0,
nullptr,
REG_OPTION_NON_VOLATILE,
KEY_WRITE | samFlags,
nullptr,
&subkeyTo,
nullptr);
if (result == ERROR_SUCCESS) {
copyTree(hkeyFrom, name, subkeyTo, samFlags);
RegCloseKey(subkeyTo);
}
}
delete [] name;
}
// Copy values
for (DWORD i = 0; i < values; i++) {
auto len = maxValueNameLen + 1;
TCHAR *name = new TCHAR[len];
memset(name, 0, len * sizeof(TCHAR));
DWORD nameLen = len;
DWORD dataType = 0;
BYTE *data = new BYTE[maxValueLen];
DWORD dataSize = 0;
result = RegEnumValue(hkeyFrom,
i,
name,
&nameLen,
0,
&dataType,
data,
&dataSize);
if (result == ERROR_SUCCESS)
RegSetValueEx(dst,
name,
0,
dataType,
data,
dataSize);
delete [] data;
delete [] name;
}
if (subkey)
RegCloseKey(hkeyFrom);
return result;
}

View file

@ -69,6 +69,8 @@ namespace AkVCam
std::string stringFromFormatType(const GUID &formatType);
std::string stringFromMediaType(const AM_MEDIA_TYPE *mediaType);
std::string stringFromMediaSample(IMediaSample *mediaSample);
LSTATUS deleteTree(HKEY key, LPCSTR subkey, REGSAM samFlags);
LSTATUS copyTree(HKEY src, LPCSTR subkey, HKEY dst, REGSAM samFlags);
}
#endif // PLATFORM_UTILS_H

View file

@ -79,8 +79,6 @@ namespace AkVCam
void isAlive(Message *message);
void frameReady(Message *message);
void pictureUpdated(Message *message);
void deviceCreate(Message *message);
void deviceDestroy(Message *message);
void deviceUpdate(Message *message);
void listenerAdd(Message *message);
void listenerRemove (Message *message);
@ -767,8 +765,6 @@ AkVCam::IpcBridgePrivate::IpcBridgePrivate(IpcBridge *self):
{AKVCAM_ASSISTANT_MSG_ISALIVE , AKVCAM_BIND_FUNC(IpcBridgePrivate::isAlive) },
{AKVCAM_ASSISTANT_MSG_FRAME_READY , AKVCAM_BIND_FUNC(IpcBridgePrivate::frameReady) },
{AKVCAM_ASSISTANT_MSG_PICTURE_UPDATED , AKVCAM_BIND_FUNC(IpcBridgePrivate::pictureUpdated) },
{AKVCAM_ASSISTANT_MSG_DEVICE_CREATE , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceCreate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_DESTROY , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceDestroy) },
{AKVCAM_ASSISTANT_MSG_DEVICE_UPDATE , AKVCAM_BIND_FUNC(IpcBridgePrivate::deviceUpdate) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_ADD , AKVCAM_BIND_FUNC(IpcBridgePrivate::listenerAdd) },
{AKVCAM_ASSISTANT_MSG_DEVICE_LISTENER_REMOVE , AKVCAM_BIND_FUNC(IpcBridgePrivate::listenerRemove) },
@ -945,25 +941,17 @@ void AkVCam::IpcBridgePrivate::pictureUpdated(Message *message)
std::string(data->picture))
}
void AkVCam::IpcBridgePrivate::deviceCreate(Message *message)
{
AkLogFunction();
auto data = messageData<MsgDeviceAdded>(message);
AKVCAM_EMIT(this->self, DeviceAdded, std::string(data->device))
}
void AkVCam::IpcBridgePrivate::deviceDestroy(Message *message)
{
AkLogFunction();
auto data = messageData<MsgDeviceRemoved>(message);
AKVCAM_EMIT(this->self, DeviceAdded, std::string(data->device))
}
void AkVCam::IpcBridgePrivate::deviceUpdate(Message *message)
{
UNUSED(message);
AkLogFunction();
AKVCAM_EMIT(this->self, DevicesUpdated, nullptr)
std::vector<std::string> devices;
auto nCameras = Preferences::camerasCount();
for (size_t i = 0; i < nCameras; i++)
devices.push_back(Preferences::cameraPath(i));
AKVCAM_EMIT(this->self, DevicesChanged, devices)
}
void AkVCam::IpcBridgePrivate::listenerAdd(Message *message)

View file

@ -28,6 +28,7 @@
#include "specifypropertypages.h"
#include "videocontrol.h"
#include "videoprocamp.h"
#include "PlatformUtils/src/preferences.h"
#include "PlatformUtils/src/utils.h"
#include "VCamUtils/src/image/videoformat.h"
#include "VCamUtils/src/ipcbridge.h"
@ -77,19 +78,9 @@ namespace AkVCam
static void setBroadcasting(void *userData,
const std::string &deviceId,
const std::string &broadcasting);
static void setMirror(void *userData,
static void setControls(void *userData,
const std::string &deviceId,
bool horizontalMirror,
bool verticalMirror);
static void setScaling(void *userData,
const std::string &deviceId,
Scaling scaling);
static void setAspectRatio(void *userData,
const std::string &deviceId,
AspectRatio aspectRatio);
static void setSwapRgb(void *userData,
const std::string &deviceId,
bool swap);
const std::map<std::string, int> &controls);
};
}
@ -124,14 +115,14 @@ void AkVCam::BaseFilter::removePin(IPin *pin, bool changed)
AkVCam::BaseFilter *AkVCam::BaseFilter::create(const GUID &clsid)
{
AkLogFunction();
auto camera = cameraFromId(clsid);
auto camera = Preferences::cameraFromCLSID(clsid);
AkLogInfo() << "CLSID: " << stringFromClsid(clsid) << std::endl;
AkLogInfo() << "ID: " << camera << std::endl;
if (camera < 0)
return nullptr;
auto description = cameraDescription(DWORD(camera));
auto description = Preferences::cameraDescription(size_t(camera));
AkLogInfo() << "Description: "
<< std::string(description.begin(),
description.end())
@ -139,7 +130,7 @@ AkVCam::BaseFilter *AkVCam::BaseFilter::create(const GUID &clsid)
auto baseFilter = new BaseFilter(clsid,
description,
DSHOW_PLUGIN_VENDOR_L);
auto formats = cameraFormats(DWORD(camera));
auto formats = Preferences::cameraFormats(size_t(camera));
baseFilter->addPin(formats, L"Video", false);
return baseFilter;
@ -340,13 +331,17 @@ void AkVCam::BaseFilter::stateChanged(FILTER_STATE state)
{
CLSID clsid;
this->GetClassID(&clsid);
auto path = cameraPath(clsid);
std::string deviceId(path.begin(), path.end());
auto cameraIndex = Preferences::cameraFromCLSID(clsid);
if (cameraIndex < 0)
return;
auto path = Preferences::cameraPath(cameraIndex);
if (state == State_Running)
this->d->m_ipcBridge.addListener(deviceId);
this->d->m_ipcBridge.addListener(path);
else
this->d->m_ipcBridge.removeListener(deviceId);
this->d->m_ipcBridge.removeListener(path);
}
AkVCam::BaseFilterPrivate::BaseFilterPrivate(AkVCam::BaseFilter *self,
@ -370,19 +365,12 @@ AkVCam::BaseFilterPrivate::BaseFilterPrivate(AkVCam::BaseFilter *self,
&BaseFilterPrivate::frameReady);
this->m_ipcBridge.connectBroadcastingChanged(this,
&BaseFilterPrivate::setBroadcasting);
this->m_ipcBridge.connectMirrorChanged(this,
&BaseFilterPrivate::setMirror);
this->m_ipcBridge.connectScalingChanged(this,
&BaseFilterPrivate::setScaling);
this->m_ipcBridge.connectAspectRatioChanged(this,
&BaseFilterPrivate::setAspectRatio);
this->m_ipcBridge.connectSwapRgbChanged(this,
&BaseFilterPrivate::setSwapRgb);
this->m_ipcBridge.connectControlsChanged(this,
&BaseFilterPrivate::setControls);
}
AkVCam::BaseFilterPrivate::~BaseFilterPrivate()
{
this->m_ipcBridge.disconnectService();
this->m_pins->setBaseFilter(nullptr);
this->m_pins->Release();
this->m_videoProcAmp->Release();
@ -392,12 +380,16 @@ AkVCam::BaseFilterPrivate::~BaseFilterPrivate()
IEnumPins *AkVCam::BaseFilterPrivate::pinsForDevice(const std::string &deviceId)
{
AkLogFunction();
CLSID clsid;
self->GetClassID(&clsid);
auto path = cameraPath(clsid);
auto cameraIndex = Preferences::cameraFromCLSID(clsid);
if (path.empty() || std::string(path.begin(), path.end()) != deviceId)
if (cameraIndex < 0)
return nullptr;
auto path = Preferences::cameraPath(cameraIndex);
if (path.empty() || path != deviceId)
return nullptr;
IEnumPins *pins = nullptr;
@ -410,36 +402,25 @@ void AkVCam::BaseFilterPrivate::updatePins()
{
CLSID clsid;
this->self->GetClassID(&clsid);
auto path = cameraPath(clsid);
std::string deviceId(path.begin(), path.end());
auto cameraIndex = Preferences::cameraFromCLSID(clsid);
auto broadcaster = this->m_ipcBridge.broadcaster(deviceId);
AkVCamDevicePinCall(deviceId,
if (cameraIndex < 0)
return;
auto path = Preferences::cameraPath(cameraIndex);
auto broadcaster = this->m_ipcBridge.broadcaster(path);
AkVCamDevicePinCall(path,
this,
setBroadcasting,
broadcaster);
auto hmirror = this->m_ipcBridge.isHorizontalMirrored(deviceId);
auto vmirror = this->m_ipcBridge.isVerticalMirrored(deviceId);
AkVCamDevicePinCall(deviceId,
this,
setMirror,
hmirror,
vmirror);
auto scaling = this->m_ipcBridge.scalingMode(deviceId);
AkVCamDevicePinCall(deviceId,
this,
setScaling,
scaling);
auto aspect = this->m_ipcBridge.aspectRatioMode(deviceId);
AkVCamDevicePinCall(deviceId,
this,
setAspectRatio,
aspect);
auto swap = this->m_ipcBridge.swapRgb(deviceId);
AkVCamDevicePinCall(deviceId,
this,
setSwapRgb,
swap);
auto controlsList = this->m_ipcBridge.controls(path);
std::map<std::string, int> controls;
for (auto &control: controlsList)
controls[control.id] = control.value;
AkVCamDevicePinCall(path, this, setControls, controls);
}
void AkVCam::BaseFilterPrivate::serverStateChanged(void *userData,
@ -477,43 +458,11 @@ void AkVCam::BaseFilterPrivate::setBroadcasting(void *userData,
AkVCamDevicePinCall(deviceId, self, setBroadcasting, broadcaster);
}
void AkVCam::BaseFilterPrivate::setMirror(void *userData,
void AkVCam::BaseFilterPrivate::setControls(void *userData,
const std::string &deviceId,
bool horizontalMirror,
bool verticalMirror)
const std::map<std::string, int> &controls)
{
AkLogFunction();
auto self = reinterpret_cast<BaseFilterPrivate *>(userData);
AkVCamDevicePinCall(deviceId,
self,
setMirror,
horizontalMirror,
verticalMirror);
}
void AkVCam::BaseFilterPrivate::setScaling(void *userData,
const std::string &deviceId,
Scaling scaling)
{
AkLogFunction();
auto self = reinterpret_cast<BaseFilterPrivate *>(userData);
AkVCamDevicePinCall(deviceId, self, setScaling, scaling);
}
void AkVCam::BaseFilterPrivate::setAspectRatio(void *userData,
const std::string &deviceId,
AspectRatio aspectRatio)
{
AkLogFunction();
auto self = reinterpret_cast<BaseFilterPrivate *>(userData);
AkVCamDevicePinCall(deviceId, self, setAspectRatio, aspectRatio);
}
void AkVCam::BaseFilterPrivate::setSwapRgb(void *userData,
const std::string &deviceId,
bool swap)
{
AkLogFunction();
auto self = reinterpret_cast<BaseFilterPrivate *>(userData);
AkVCamDevicePinCall(deviceId, self, setSwapRgb, swap);
AkVCamDevicePinCall(deviceId, self, setControls, controls);
}

View file

@ -141,7 +141,7 @@ HRESULT AkVCam::MediaFilter::Run(REFERENCE_TIME tStart)
HRESULT AkVCam::MediaFilter::GetState(DWORD dwMilliSecsTimeout,
FILTER_STATE *State)
{
UNUSED(dwMilliSecsTimeout)
UNUSED(dwMilliSecsTimeout);
AkLogFunction();
if (!State)
@ -185,5 +185,5 @@ HRESULT AkVCam::MediaFilter::GetSyncSource(IReferenceClock **pClock)
void AkVCam::MediaFilter::stateChanged(FILTER_STATE state)
{
UNUSED(state)
UNUSED(state);
}

View file

@ -220,7 +220,7 @@ HRESULT AkVCam::MemAllocator::GetBuffer(IMediaSample **ppBuffer,
HRESULT AkVCam::MemAllocator::ReleaseBuffer(IMediaSample *pBuffer)
{
UNUSED(pBuffer)
UNUSED(pBuffer);
AkLogFunction();
this->d->m_mutex.lock();

View file

@ -95,7 +95,7 @@ HRESULT AkVCam::PersistPropertyBag::InitNew()
HRESULT AkVCam::PersistPropertyBag::Load(IPropertyBag *pPropBag,
IErrorLog *pErrorLog)
{
UNUSED(pErrorLog)
UNUSED(pErrorLog);
AkLogFunction();
if (!pPropBag)
@ -118,8 +118,8 @@ HRESULT AkVCam::PersistPropertyBag::Save(IPropertyBag *pPropBag,
BOOL fClearDirty,
BOOL fSaveAllProperties)
{
UNUSED(fClearDirty)
UNUSED(fSaveAllProperties)
UNUSED(fClearDirty);
UNUSED(fSaveAllProperties);
AkLogFunction();
if (!pPropBag)

View file

@ -66,17 +66,14 @@ namespace AkVCam
std::thread m_sendFrameThread;
std::atomic<bool> m_running;
std::mutex m_mutex;
std::mutex m_controlsMutex;
VideoFrame m_currentFrame;
VideoFrame m_testFrame;
VideoFrame m_testFrameAdapted;
std::string m_broadcaster;
bool m_horizontalFlip; // Controlled by client
bool m_verticalFlip;
bool m_horizontalMirror; // Controlled by server
bool m_verticalMirror;
Scaling m_scaling;
AspectRatio m_aspectRatio;
bool m_swapRgb;
std::map<std::string, int> m_controls;
LONG m_brightness;
LONG m_contrast;
LONG m_saturation;
@ -127,11 +124,6 @@ AkVCam::Pin::Pin(BaseFilter *baseFilter,
this->d->m_adviseCookie = 0;
this->d->m_sendFrameEvent = nullptr;
this->d->m_running = false;
this->d->m_horizontalMirror = false;
this->d->m_verticalMirror = false;
this->d->m_scaling = ScalingFast;
this->d->m_aspectRatio = AspectRatioIgnore;
this->d->m_swapRgb = false;
auto bmp = programFilesPath()
+ L"\\" DSHOW_PLUGIN_NAME_L L".plugin\\share\\TestFrame.bmp";
this->d->m_testFrame.load(std::string(bmp.begin(), bmp.end()));
@ -264,11 +256,9 @@ void AkVCam::Pin::serverStateChanged(IpcBridge::ServerState state)
if (state == IpcBridge::ServerStateGone) {
this->d->m_broadcaster.clear();
this->d->m_horizontalMirror = false;
this->d->m_verticalMirror = false;
this->d->m_scaling = ScalingFast;
this->d->m_aspectRatio = AspectRatioIgnore;
this->d->m_swapRgb = false;
this->d->m_controlsMutex.lock();
this->d->m_controls = {};
this->d->m_controlsMutex.unlock();
this->d->updateTestFrame();
this->d->m_mutex.lock();
@ -315,49 +305,19 @@ void AkVCam::Pin::setBroadcasting(const std::string &broadcaster)
this->d->m_mutex.unlock();
}
void AkVCam::Pin::setMirror(bool horizontalMirror, bool verticalMirror)
void AkVCam::Pin::setControls(const std::map<std::string, int> &controls)
{
AkLogFunction();
this->d->m_controlsMutex.lock();
if (this->d->m_controls == controls) {
this->d->m_controlsMutex.unlock();
if (this->d->m_horizontalMirror == horizontalMirror
&& this->d->m_verticalMirror == verticalMirror)
return;
}
this->d->m_horizontalMirror = horizontalMirror;
this->d->m_verticalMirror = verticalMirror;
this->d->updateTestFrame();
}
void AkVCam::Pin::setScaling(Scaling scaling)
{
AkLogFunction();
if (this->d->m_scaling == scaling)
return;
this->d->m_scaling = scaling;
this->d->updateTestFrame();
}
void AkVCam::Pin::setAspectRatio(AspectRatio aspectRatio)
{
AkLogFunction();
if (this->d->m_aspectRatio == aspectRatio)
return;
this->d->m_aspectRatio = aspectRatio;
this->d->updateTestFrame();
}
void AkVCam::Pin::setSwapRgb(bool swap)
{
AkLogFunction();
if (this->d->m_swapRgb == swap)
return;
this->d->m_swapRgb = swap;
this->d->m_controls = controls;
this->d->m_controlsMutex.unlock();
this->d->updateTestFrame();
}
@ -618,8 +578,8 @@ HRESULT AkVCam::Pin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
HRESULT AkVCam::Pin::ReceiveConnection(IPin *pConnector,
const AM_MEDIA_TYPE *pmt)
{
UNUSED(pConnector)
UNUSED(pmt)
UNUSED(pConnector);
UNUSED(pmt);
AkLogFunction();
return VFW_E_TYPE_NOT_ACCEPTED;
@ -789,8 +749,8 @@ HRESULT AkVCam::Pin::EnumMediaTypes(IEnumMediaTypes **ppEnum)
HRESULT AkVCam::Pin::QueryInternalConnections(IPin **apPin, ULONG *nPin)
{
AkLogFunction();
UNUSED(apPin)
UNUSED(nPin)
UNUSED(apPin);
UNUSED(nPin);
return E_NOTIMPL;
}
@ -983,13 +943,36 @@ AkVCam::VideoFrame AkVCam::PinPrivate::applyAdjusts(const VideoFrame &frame)
{PixelFormatRGB15, PixelFormatBGR15},
};
bool horizontalMirror = false;
bool verticalMirror = false;
Scaling scaling = ScalingFast;
AspectRatio aspectRatio = AspectRatioIgnore;
bool swapRgb = false;
this->m_controlsMutex.lock();
if (this->m_controls.count("hflip") > 0)
horizontalMirror = this->m_controls["hflip"];
if (this->m_controls.count("vflip") > 0)
verticalMirror = this->m_controls["vflip"];
if (this->m_controls.count("scaling") > 0)
scaling = Scaling(this->m_controls["scaling"]);
if (this->m_controls.count("aspect_ratio") > 0)
aspectRatio = AspectRatio(this->m_controls["aspect_ratio"]);
if (this->m_controls.count("swap_rgb") > 0)
swapRgb = this->m_controls["swap_rgb"];
this->m_controlsMutex.unlock();
bool vmirror;
if (fixFormat.count(fourcc) > 0) {
fourcc = fixFormat[fourcc];
vmirror = this->m_verticalMirror == this->m_verticalFlip;
vmirror = verticalMirror == this->m_verticalFlip;
} else {
vmirror = this->m_verticalMirror != this->m_verticalFlip;
vmirror = verticalMirror != this->m_verticalFlip;
}
VideoFrame newFrame;
@ -997,28 +980,24 @@ AkVCam::VideoFrame AkVCam::PinPrivate::applyAdjusts(const VideoFrame &frame)
if (width * height > frame.format().width() * frame.format().height()) {
newFrame =
frame
.mirror(this->m_horizontalMirror != this->m_horizontalFlip,
.mirror(horizontalMirror != this->m_horizontalFlip,
vmirror)
.swapRgb(this->m_swapRgb)
.swapRgb(swapRgb)
.adjust(this->m_hue,
this->m_saturation,
this->m_brightness,
this->m_gamma,
this->m_contrast,
!this->m_colorenable)
.scaled(width, height,
this->m_scaling,
this->m_aspectRatio)
.scaled(width, height, scaling, aspectRatio)
.convert(fourcc);
} else {
newFrame =
frame
.scaled(width, height,
this->m_scaling,
this->m_aspectRatio)
.mirror(this->m_horizontalMirror != this->m_horizontalFlip,
.scaled(width, height, scaling, aspectRatio)
.mirror(horizontalMirror != this->m_horizontalFlip,
vmirror)
.swapRgb(this->m_swapRgb)
.swapRgb(swapRgb)
.adjust(this->m_hue,
this->m_saturation,
this->m_brightness,
@ -1040,7 +1019,7 @@ void AkVCam::PinPrivate::propertyChanged(void *userData,
LONG Flags)
{
AkLogFunction();
UNUSED(Flags)
UNUSED(Flags);
auto self = reinterpret_cast<PinPrivate *>(userData);
switch (Property) {

View file

@ -50,10 +50,7 @@ namespace AkVCam
void serverStateChanged(IpcBridge::ServerState state);
void frameReady(const VideoFrame &frame);
void setBroadcasting(const std::string &broadcaster);
void setMirror(bool horizontalMirror, bool verticalMirror);
void setScaling(Scaling scaling);
void setAspectRatio(AspectRatio aspectRatio);
void setSwapRgb(bool swap);
void setControls(const std::map<std::string, int> &controls);
bool horizontalFlip() const;
void setHorizontalFlip(bool flip);
bool verticalFlip() const;

View file

@ -88,7 +88,7 @@ STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
if (!IsEqualIID(riid, IID_IUnknown)
&& !IsEqualIID(riid, IID_IClassFactory)
&& AkVCam::cameraFromId(riid) < 0)
&& AkVCam::Preferences::cameraFromCLSID(riid) < 0)
return CLASS_E_CLASSNOTAVAILABLE;
auto classFactory = new AkVCam::ClassFactory(rclsid);
@ -112,9 +112,9 @@ STDAPI DllRegisterServer()
bool ok = true;
for (DWORD i = 0; i < AkVCam::camerasCount(); i++) {
auto description = AkVCam::cameraDescription(i);
auto path = AkVCam::cameraPath(i);
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);
AkLogInfo() << "Creating Camera" << std::endl;
@ -137,7 +137,7 @@ STDAPI DllUnregisterServer()
{
AkLogFunction();
auto cameras =
AkVCam::listRegisteredCameras(pluginInterface()->pluginHinstance());
AkVCam::Preferences::listRegisteredCameras(pluginInterface()->pluginHinstance());
for (auto camera: cameras) {
AkLogInfo() << "Deleting "

View file

@ -32,8 +32,6 @@ namespace AkVCam
{
public:
HINSTANCE m_pluginHinstance {nullptr};
LONG deleteTree(HKEY hKey, LPCTSTR lpSubKey);
};
}
@ -57,7 +55,7 @@ HINSTANCE &AkVCam::PluginInterface::pluginHinstance()
return this->d->m_pluginHinstance;
}
bool AkVCam::PluginInterface::registerServer(const std::wstring &deviceId,
bool AkVCam::PluginInterface::registerServer(const std::string &deviceId,
const std::wstring &description) const
{
AkLogFunction();
@ -149,12 +147,11 @@ void AkVCam::PluginInterface::unregisterServer(const CLSID &clsid) const
auto clsidStr = stringFromClsid(clsid);
AkLogInfo() << "CLSID: " << clsidStr << std::endl;
auto subkey = L"CLSID\\" + std::wstring(clsidStr.begin(), clsidStr.end());
this->d->deleteTree(HKEY_CLASSES_ROOT, subkey.c_str());
auto subkey = "CLSID\\" + clsidStr;
deleteTree(HKEY_CLASSES_ROOT, subkey.c_str(), 0);
}
bool AkVCam::PluginInterface::registerFilter(const std::wstring &deviceId,
bool AkVCam::PluginInterface::registerFilter(const std::string &deviceId,
const std::wstring &description) const
{
AkLogFunction();
@ -264,7 +261,7 @@ unregisterFilter_failed:
AkLogInfo() << "Result: " << stringFromResult(result) << std::endl;
}
bool AkVCam::PluginInterface::setDevicePath(const std::wstring &deviceId) const
bool AkVCam::PluginInterface::setDevicePath(const std::string &deviceId) const
{
AkLogFunction();
@ -287,8 +284,8 @@ bool AkVCam::PluginInterface::setDevicePath(const std::wstring &deviceId) const
if (result != ERROR_SUCCESS)
goto setDevicePath_failed;
result = RegSetValueEx(hKey,
TEXT("DevicePath"),
result = RegSetValueExA(hKey,
"DevicePath",
0,
REG_SZ,
reinterpret_cast<const BYTE *>(deviceId.c_str()),
@ -308,7 +305,7 @@ setDevicePath_failed:
return ok;
}
bool AkVCam::PluginInterface::createDevice(const std::wstring &deviceId,
bool AkVCam::PluginInterface::createDevice(const std::string &deviceId,
const std::wstring &description)
{
AkLogFunction();
@ -353,32 +350,3 @@ void AkVCam::PluginInterface::destroyDevice(const CLSID &clsid)
this->unregisterFilter(clsid);
this->unregisterServer(clsid);
}
LONG AkVCam::PluginInterfacePrivate::deleteTree(HKEY hKey, LPCTSTR lpSubKey)
{
HKEY key = nullptr;
auto result = RegOpenKeyEx(hKey, lpSubKey, 0, MAXIMUM_ALLOWED, &key);
if (result != ERROR_SUCCESS)
return result;
TCHAR subKey[MAX_PATH];
DWORD subKeyLen = MAX_PATH;
FILETIME lastWrite;
while (RegEnumKeyEx(key,
0,
subKey,
&subKeyLen,
nullptr,
nullptr,
nullptr,
&lastWrite) == ERROR_SUCCESS) {
this->deleteTree(key, subKey);
}
RegCloseKey(key);
RegDeleteKey(hKey, lpSubKey);
return ERROR_SUCCESS;
}

View file

@ -36,18 +36,18 @@ namespace AkVCam
HINSTANCE pluginHinstance() const;
HINSTANCE &pluginHinstance();
bool registerServer(const std::wstring &deviceId,
bool registerServer(const std::string &deviceId,
const std::wstring &description) const;
void unregisterServer(const std::string &deviceId) const;
void unregisterServer(const std::wstring &deviceId) const;
void unregisterServer(const CLSID &clsid) const;
bool registerFilter(const std::wstring &deviceId,
bool registerFilter(const std::string &deviceId,
const std::wstring &description) const;
void unregisterFilter(const std::string &deviceId) const;
void unregisterFilter(const std::wstring &deviceId) const;
void unregisterFilter(const CLSID &clsid) const;
bool setDevicePath(const std::wstring &deviceId) const;
bool createDevice(const std::wstring &deviceId,
bool setDevicePath(const std::string &deviceId) const;
bool createDevice(const std::string &deviceId,
const std::wstring &description);
void destroyDevice(const std::string &deviceId);
void destroyDevice(const std::wstring &deviceId);

View file

@ -41,12 +41,12 @@ HRESULT AkVCam::PropertySet::Set(const GUID &guidPropSet,
LPVOID pPropData,
DWORD cbPropData)
{
UNUSED(guidPropSet)
UNUSED(dwPropID)
UNUSED(pInstanceData)
UNUSED(cbInstanceData)
UNUSED(pPropData)
UNUSED(cbPropData)
UNUSED(guidPropSet);
UNUSED(dwPropID);
UNUSED(pInstanceData);
UNUSED(cbInstanceData);
UNUSED(pPropData);
UNUSED(cbPropData);
AkLogFunction();
return E_NOTIMPL;
@ -60,8 +60,8 @@ HRESULT AkVCam::PropertySet::Get(const GUID &guidPropSet,
DWORD cbPropData,
DWORD *pcbReturned)
{
UNUSED(pInstanceData)
UNUSED(cbInstanceData)
UNUSED(pInstanceData);
UNUSED(cbInstanceData);
AkLogFunction();
if (!IsEqualGUID(guidPropSet, AMPROPSETID_Pin))

View file

@ -45,7 +45,7 @@ HRESULT AkVCam::PushSource::GetPushSourceFlags(ULONG *pFlags)
HRESULT AkVCam::PushSource::SetPushSourceFlags(ULONG Flags)
{
UNUSED(Flags)
UNUSED(Flags);
AkLogFunction();
return E_NOTIMPL;
@ -53,7 +53,7 @@ HRESULT AkVCam::PushSource::SetPushSourceFlags(ULONG Flags)
HRESULT AkVCam::PushSource::SetStreamOffset(REFERENCE_TIME rtOffset)
{
UNUSED(rtOffset)
UNUSED(rtOffset);
AkLogFunction();
return E_NOTIMPL;
@ -61,7 +61,7 @@ HRESULT AkVCam::PushSource::SetStreamOffset(REFERENCE_TIME rtOffset)
HRESULT AkVCam::PushSource::GetStreamOffset(REFERENCE_TIME *prtOffset)
{
UNUSED(prtOffset)
UNUSED(prtOffset);
AkLogFunction();
return E_NOTIMPL;
@ -69,7 +69,7 @@ HRESULT AkVCam::PushSource::GetStreamOffset(REFERENCE_TIME *prtOffset)
HRESULT AkVCam::PushSource::GetMaxStreamOffset(REFERENCE_TIME *prtMaxOffset)
{
UNUSED(prtMaxOffset)
UNUSED(prtMaxOffset);
AkLogFunction();
return E_NOTIMPL;
@ -77,7 +77,7 @@ HRESULT AkVCam::PushSource::GetMaxStreamOffset(REFERENCE_TIME *prtMaxOffset)
HRESULT AkVCam::PushSource::SetMaxStreamOffset(REFERENCE_TIME rtMaxOffset)
{
UNUSED(rtMaxOffset)
UNUSED(rtMaxOffset);
AkLogFunction();
return E_NOTIMPL;

View file

@ -34,7 +34,7 @@ AkVCam::QualityControl::~QualityControl()
HRESULT AkVCam::QualityControl::Notify(IBaseFilter *pSelf, Quality q)
{
UNUSED(q)
UNUSED(q);
AkLogFunction();
if (!pSelf)
@ -50,7 +50,7 @@ HRESULT AkVCam::QualityControl::Notify(IBaseFilter *pSelf, Quality q)
HRESULT AkVCam::QualityControl::SetSink(IQualityControl *piqc)
{
UNUSED(piqc)
UNUSED(piqc);
AkLogFunction();
return E_NOTIMPL;