Skip to content

Commit

Permalink
Pass obs_data_t config to PTZDevice constructor
Browse files Browse the repository at this point in the history
Instead of only passing the type, pass the whole obs_data_t structure
through to the base class constructor so that it can access any of the
configuration items it needs.

Signed-off-by: Grant Likely <[email protected]>
  • Loading branch information
glikely committed Oct 25, 2021
1 parent bd397f4 commit 2266907
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ptz-device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class PTZDevice : public QObject {
void settingsChanged(OBSData settings);

public:
PTZDevice(std::string type) : QObject(), type(type)
PTZDevice(OBSData config) : QObject()
{
type = obs_data_get_string(config, "type");
settings = obs_data_create();
obs_data_release(settings);
ptzDeviceList.add(this);
Expand Down
2 changes: 1 addition & 1 deletion ptz-pelco.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void PTZPelco::zoom_speed_set(double speed)
}

PTZPelco::PTZPelco(OBSData data)
: PTZDevice("pelco"), iface(NULL)
: PTZDevice(data), iface(NULL)
{
set_config(data);
ptz_debug("pelco device created");
Expand Down
10 changes: 5 additions & 5 deletions ptz-visca.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,8 +463,8 @@ const QMap<int, std::string> PTZVisca::viscaModels = {
/*
* PTZVisca Methods
*/
PTZVisca::PTZVisca(std::string type)
: PTZDevice(type)
PTZVisca::PTZVisca(OBSData config)
: PTZDevice(config)
{
for (int i = 0; i < 8; i++)
active_cmd[i] = false;
Expand Down Expand Up @@ -807,7 +807,7 @@ ViscaUART * ViscaUART::get_interface(QString port_name)
}

PTZViscaSerial::PTZViscaSerial(OBSData config)
: PTZVisca("visca"), iface(NULL)
: PTZVisca(config), iface(NULL)
{
set_config(config);
auto_settings_filter += {"port", "address", "baud_rate"};
Expand Down Expand Up @@ -945,7 +945,7 @@ ViscaUDPSocket * ViscaUDPSocket::get_interface(int port)
}

PTZViscaOverIP::PTZViscaOverIP(OBSData config)
: PTZVisca("visca-over-ip"), iface(NULL)
: PTZVisca(config), iface(NULL)
{
address = 1;
set_config(config);
Expand Down Expand Up @@ -1026,7 +1026,7 @@ obs_properties_t *PTZViscaOverIP::get_obs_properties()
* VISCA over TCP implementation (e.g., PTZOptics cameras
*/
PTZViscaOverTCP::PTZViscaOverTCP(OBSData config)
: PTZVisca("visca-over-tcp")
: PTZVisca(config)
{
address = 1;
set_config(config);
Expand Down
2 changes: 1 addition & 1 deletion ptz-visca.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected slots:
void receive(const QByteArray &msg);

public:
PTZVisca(std::string type);
PTZVisca(OBSData config);
obs_properties_t *get_obs_properties();

virtual void set_config(OBSData ptz_data) = 0;
Expand Down

0 comments on commit 2266907

Please sign in to comment.