Skip to content

Commit

Permalink
[WIP] ptz: Add HTTP backend
Browse files Browse the repository at this point in the history
  • Loading branch information
norihiro committed Jul 11, 2024
1 parent e8a834f commit 41e1ce8
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ set(PLUGIN_SOURCES
src/helper.cpp
src/ptz-backend.cpp
src/obsptz-backend.cpp
src/ptz-http-backend.cpp
src/dummy-backend.cpp
)

Expand Down
7 changes: 7 additions & 0 deletions src/face-tracker-ptz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#ifdef WITH_PTZ_TCP
#include "libvisca-thread.hpp"
#endif
#include "ptz-http-backend.hpp"
#include "dummy-backend.hpp"

#define PTZ_MAX_X 0x18
Expand Down Expand Up @@ -137,6 +138,11 @@ static const struct ptz_backend_type_s backends[] =
.list_settings = list_viscaip,
},
#endif // WITH_PTZ_TCP
{
.backend_name = "http",
.make_device = make_device_template<ptz_http_backend>,
.list_settings = NULL,
},
{
.backend_name = "dummy",
.make_device = make_device_template<dummy_backend>,
Expand Down Expand Up @@ -433,6 +439,7 @@ static obs_properties_t *ftptz_properties(void *data)
#ifdef WITH_PTZ_TCP
obs_property_list_add_string(p, obs_module_text("VISCA over TCP"), "visca-over-tcp");
#endif // WITH_PTZ_TCP
obs_property_list_add_string(p, obs_module_text("HTTP"), "http");
obs_property_set_modified_callback(p, ptz_type_modified);
obs_properties_add_int(pp, "ptz-obsptz-device_id", obs_module_text("Device ID"), 0, 99, 1);
obs_properties_add_text(pp, "ptz-viscaip-address", obs_module_text("IP address"), OBS_TEXT_DEFAULT);
Expand Down
51 changes: 51 additions & 0 deletions src/ptz-http-backend.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <obs-module.h>
#include "plugin-macros.generated.h"
#include "ptz-http-backend.hpp"

ptz_http_backend::ptz_http_backend()
{
// TODO: Implement

pthread_t thread;
pthread_create(&thread, NULL, ptz_http_backend::thread_main, (void*)this);
pthread_detach(thread);
}

ptz_http_backend::~ptz_http_backend()
{
// TODO: Implement
}

void *ptz_http_backend::thread_main(void *data)
{
auto *visca = (ptz_http_backend*)data;
visca->add_ref();
visca->thread_loop();
visca->release();
return NULL;
}

void ptz_http_backend::thread_loop()
{
// TODO: Implement
}

void ptz_http_backend::set_config(struct obs_data *data)
{
// TODO: Implement
}

void ptz_http_backend::set_pantilt_speed(int pan, int tilt)
{
pan_next = pan;
tilt_next = tilt;

// TODO: Implement
}

void ptz_http_backend::set_zoom_speed(int zoom)
{
zoom_next = zoom;

// TODO: Implement
}
31 changes: 31 additions & 0 deletions src/ptz-http-backend.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once

#include <atomic>
#include <mutex>
#include "ptz-backend.hpp"

class ptz_http_backend : public ptz_backend
{
std::mutex mutex;
struct obs_data *data;
std::atomic<bool> data_changed;
std::atomic<bool> preset_changed;
std::atomic<int> pan_next, tilt_next, zoom_next;

static void *thread_main(void *);
void thread_loop();

public:
ptz_http_backend();
~ptz_http_backend() override;

void set_config(struct obs_data *data) override;

void set_pantilt_speed(int pan, int tilt) override;
void set_zoom_speed(int zoom) override;
void recall_preset(int) override { }
int get_zoom() override {
// TODO: Implement if available
return 0;
}
};

0 comments on commit 41e1ce8

Please sign in to comment.