Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ptz-controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ static obs_hotkey_id lookup_obs_hotkey_id(QString hotkey_name)
obs_enum_hotkeys(
[](void *data, obs_hotkey_id id, obs_hotkey_t *key) {
data_t &d = *static_cast<data_t *>(data);
if (get<0>(d) == obs_hotkey_get_name(key)) {
*get<1>(d) = id;
if (std::get<0>(d) == obs_hotkey_get_name(key)) {
*std::get<1>(d) = id;
return false;
}
return true;
Expand Down
32 changes: 16 additions & 16 deletions src/ptz-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
blog(LOG_ERROR, "PTZ proc_handler called without PTZDevice pointer"); \
return; \
} \
if (QThread::currentThread() != ptz->thread()) { \
blog(LOG_WARNING, "PTZDevice proc_handler '%s'->%s() call from non-GUI thread; ignored", QT_TO_UTF8(ptz->objectName()), #_method); \
return; \
} \
ptz->_method(cd); \
}

Expand Down Expand Up @@ -172,39 +168,43 @@ void PTZDevice::move(calldata_t *cd)
double p = 0, t = 0, z = 0, f = 0;

if (calldata_get_float(cd, "pan", &p) + calldata_get_float(cd, "tilt", &t))
pantilt(p, t);
QMetaObject::invokeMethod(this, "pantilt", Q_ARG(double, p), Q_ARG(double, t));

if (calldata_get_float(cd, "zoom", &z))
zoom(z);
QMetaObject::invokeMethod(this, "zoom", Q_ARG(double, z));

if (calldata_get_float(cd, "focus", &f))
focus(f);
QMetaObject::invokeMethod(this, "focus", Q_ARG(double, f));
}

void PTZDevice::move_abs(calldata_t *cd)
{
double p = 0, t = 0, z = 0, f = 0;

if (calldata_get_float(cd, "pan", &p) + calldata_get_float(cd, "tilt", &t))
pantilt_abs(p, t);
QMetaObject::invokeMethod(this, "pantilt_abs", Q_ARG(double, p), Q_ARG(double, t));

if (calldata_get_float(cd, "zoom", &z))
zoom_abs(z);
QMetaObject::invokeMethod(this, "zoom_abs", Q_ARG(double, z));

if (calldata_get_float(cd, "focus", &f))
focus_abs(f);
QMetaObject::invokeMethod(this, "focus_abs", Q_ARG(double, f));
}

void PTZDevice::move_rel(calldata_t *cd)
{
double p = 0, t = 0;

if (calldata_get_float(cd, "pan", &p) + calldata_get_float(cd, "tilt", &t))
pantilt_rel(p, t);
QMetaObject::invokeMethod(this, "pantilt_rel", Q_ARG(double, p), Q_ARG(double, t));
}

void PTZDevice::get(calldata_t *cd) const
{
if (QThread::currentThread() != thread()) {
ptz_log(LOG_ERROR, "PTZDevice::get(calldata) called from non-GUI thread; ignored");
return;
}
QString arg = calldata_string(cd, "property");
if (arg == "power_on")
calldata_set_bool(cd, "power_on", obs_data_get_bool(settings, "power_on"));
Expand All @@ -217,31 +217,31 @@ void PTZDevice::set(calldata_t *cd)
{
bool enable;
if (calldata_get_bool(cd, "focus_af_enabled", &enable))
set_autofocus(enable);
QMetaObject::invokeMethod(this, "set_autofocus", Q_ARG(bool, enable));
bool trigger;
if (calldata_get_bool(cd, "focus_onetouch_trigger", &trigger) && trigger)
focus_onetouch();
QMetaObject::invokeMethod(this, &PTZDevice::focus_onetouch);
}

void PTZDevice::preset_save(calldata_t *cd)
{
long long id;
if (calldata_get_int(cd, "preset_id", &id))
memory_set(id);
QMetaObject::invokeMethod(this, "memory_set", Q_ARG(int, id));
}

void PTZDevice::preset_recall(calldata_t *cd)
{
long long id;
if (calldata_get_int(cd, "preset_id", &id))
memory_recall(id);
QMetaObject::invokeMethod(this, "memory_recall", Q_ARG(int, id));
}

void PTZDevice::preset_clear(calldata_t *cd)
{
long long id;
if (calldata_get_int(cd, "preset_id", &id))
memory_reset(id);
QMetaObject::invokeMethod(this, "memory_reset", Q_ARG(int, id));
}

void PTZDevice::getDefaults(OBSData config) const
Expand Down
9 changes: 4 additions & 5 deletions src/ptz-device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class PTZDevice : public QObject {
* zoom: range[0.0, 1.0], 0.0 == wide angle, 1.0 == telephoto
* focus: range[0.0, 1.0], 0.0 == far focus, 1.0 == near focus
*/
protected:
protected slots:
void stop();
void pantilt(double pan, double tilt);
virtual void pantilt_rel(double pan, double tilt)
Expand Down Expand Up @@ -142,10 +142,9 @@ class PTZDevice : public QObject {
virtual void memory_recall(int i) { Q_UNUSED(i); }
virtual void memory_reset(int i) { Q_UNUSED(i); }

protected slots:
void stop(calldata_t *) { stop(); }
void pantilt_home(calldata_t *) { pantilt_home(); }
void pantilt_set_home(calldata_t *) { pantilt_set_home(); };
void stop(calldata_t *) { QMetaObject::invokeMethod(this, "stop"); }
void pantilt_home(calldata_t *) { QMetaObject::invokeMethod(this, "pantilt_home"); }
void pantilt_set_home(calldata_t *) { QMetaObject::invokeMethod(this, "pantilt_set_home"); }
void move(calldata_t *cd);
void move_abs(calldata_t *cd);
void move_rel(calldata_t *cd);
Expand Down
8 changes: 8 additions & 0 deletions src/ptz-visca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,10 @@ void PTZVisca::receive(const QByteArray &msg)

void PTZVisca::get(calldata_t *cd) const
{
if (QThread::currentThread() != thread()) {
ptz_log(LOG_ERROR, "PTZVisca::get(calldata) called from non-GUI thread; ignored");
return;
}
QString arg = calldata_string(cd, "property");
if (arg == "wb_mode")
calldata_set_int(cd, "wb_mode", obs_data_get_int(settings, "wb_mode"));
Expand All @@ -789,6 +793,10 @@ void PTZVisca::get(calldata_t *cd) const

void PTZVisca::set(calldata_t *cd)
{
if (QThread::currentThread() != thread()) {
ptz_log(LOG_ERROR, "PTZVisca::set(calldata) called from non-GUI thread; ignored");
return;
}
Comment on lines +796 to +799
bool power_on;
if (calldata_get_bool(cd, "power_on", &power_on))
send(VISCA_CAM_Power, {power_on});
Expand Down
8 changes: 4 additions & 4 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ PTZJoyButtonMapper::PTZJoyButtonMapper(QWidget *parent, size_t _button) : QPushB
data_t &d = *static_cast<data_t *>(data);
if (obs_hotkey_get_registerer_type(key) != OBS_HOTKEY_REGISTERER_FRONTEND)
return true; /* todo: extra logic needed for other hotkey registerers */
auto a = get<0>(d)->addAction(obs_hotkey_get_description(key));
auto a = std::get<0>(d)->addAction(obs_hotkey_get_description(key));
a->setData(obs_hotkey_get_name(key));
connect(a, &QAction::triggered, get<1>(d), &PTZJoyButtonMapper::on_menuAction);
connect(a, &QAction::triggered, std::get<1>(d), &PTZJoyButtonMapper::on_menuAction);
return true;
},
&data);
Expand Down Expand Up @@ -282,8 +282,8 @@ void PTZJoyButtonMapper::on_hotkeyChanged(size_t _button, QString hotkey_name)
obs_enum_hotkeys(
[](void *data, obs_hotkey_id, obs_hotkey_t *key) {
data_t &d = *static_cast<data_t *>(data);
if (get<0>(d) == obs_hotkey_get_name(key)) {
get<1>(d)->setText(obs_hotkey_get_description(key));
if (std::get<0>(d) == obs_hotkey_get_name(key)) {
std::get<1>(d)->setText(obs_hotkey_get_description(key));
return false;
}
return true;
Expand Down
Loading