summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikita Kostovsky <nikita@kostovsky.me>2025-11-14 22:20:20 +0100
committerNikita Kostovsky <nikita@kostovsky.me>2025-11-14 22:20:20 +0100
commitac27fb455c76aee4f9e9f65747483006909b14ab (patch)
tree3819750b1475674296f1f02b7f237552afd6f386 /src
parentff20080b6f6cdc8b7f8003a6673bf149c515cdda (diff)
cleanup
Diffstat (limited to 'src')
-rw-r--r--src/camera/icamera.h2
-rw-r--r--src/camera/veye_i2c.h3
-rw-r--r--src/camera/veyeimx287m.cpp83
-rw-r--r--src/camera/veyeimx287m.h5
-rw-r--r--src/main.cpp357
-rw-r--r--src/protocols/httpserver.cpp2
-rw-r--r--src/protocols/httpserver.h4
-rw-r--r--src/protocols/iprotocol.cpp2
-rw-r--r--src/protocols/iprotocol.h8
-rw-r--r--src/protocols/protocolbase.cpp3
-rw-r--r--src/protocols/protocolbase.h10
11 files changed, 20 insertions, 459 deletions
diff --git a/src/camera/icamera.h b/src/camera/icamera.h
index 391ce55..bd08786 100644
--- a/src/camera/icamera.h
+++ b/src/camera/icamera.h
@@ -54,8 +54,6 @@ public:
virtual bool set_gain(const float value) = 0;
virtual std::optional<float> get_gain() = 0;
- virtual bool setLaserLevel(int value) = 0;
-
public:
std::function<void(std::shared_ptr<Pixels>)> newPixelsCallback;
std::function<void(Image &)> newImageCallback;
diff --git a/src/camera/veye_i2c.h b/src/camera/veye_i2c.h
index 24ef10b..48ad507 100644
--- a/src/camera/veye_i2c.h
+++ b/src/camera/veye_i2c.h
@@ -9,7 +9,8 @@ namespace imx287m {
class i2c
{
public:
- i2c(const std::string &name = "/dev/i2c-2", const int address = 0x3b);
+ explicit i2c(const std::string &name = "/dev/i2c-2",
+ const int address = 0x3b);
~i2c();
public:
diff --git a/src/camera/veyeimx287m.cpp b/src/camera/veyeimx287m.cpp
index a03aa83..7b6302c 100644
--- a/src/camera/veyeimx287m.cpp
+++ b/src/camera/veyeimx287m.cpp
@@ -238,6 +238,8 @@ VeyeIMX287m::~VeyeIMX287m()
std::vector<std::shared_ptr<ICamera> > VeyeIMX287m::search()
{
+ // FIXME: use saved params, get rid of hardcode
+
// return only one camera for now
const auto cam = std::make_shared<VeyeIMX287m>();
@@ -257,18 +259,13 @@ std::vector<std::shared_ptr<ICamera> > VeyeIMX287m::search()
if (!cam->set_gain(0.1))
return {};
- if (!cam->setLaserLevel(1))
- return {};
-
return {cam};
}
bool VeyeIMX287m::startStream()
{
- // int buffer_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- const auto radxa_buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- // auto ret = ioctl(m_cam_fd, VIDIOC_STREAMON, &buffer_type);
- auto ret = ioctl(m_cam_fd, VIDIOC_STREAMON, &radxa_buf_type);
+ constexpr auto radxa_buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
+ const auto ret = ioctl(m_cam_fd, VIDIOC_STREAMON, &radxa_buf_type);
if (ret != 0) {
std::cerr << "ioctl(VIDIOC_STREAMON) failed: " << errno << " ("
@@ -276,14 +273,12 @@ bool VeyeIMX287m::startStream()
return false;
}
- std::cout << "stream started" << std::endl;
-
- // m_streamThread = std::jthread{&VeyeIMX287m::dequeueFrameLoop, this};
-
for (auto &t : m_calcThreads) {
t = std::jthread{&VeyeIMX287m::calcFrameLoop, this};
}
+ std::cout << __func__ << " - OK" << std::endl;
+
return true;
}
@@ -292,9 +287,6 @@ bool VeyeIMX287m::init()
if (!openCam())
return false;
- // if (!selectCam())
- // return false;
-
if (!initCam())
return false;
@@ -395,16 +387,6 @@ std::optional<float> VeyeIMX287m::get_gain()
return *value * 10;
}
-bool VeyeIMX287m::setLaserLevel(int value)
-{
- std::cout << __func__ << ": " << value << std::endl << std::flush;
-
- // return setCamParam(V4L2_CID_FLASH_TIMEOUT, value);
-
- // FIXME: tmp workaround for imx287llr
- return true;
-}
-
bool VeyeIMX287m::openCam()
{
m_cam_fd = open(videoDevice, O_RDWR);
@@ -420,23 +402,6 @@ bool VeyeIMX287m::openCam()
return true;
}
-bool VeyeIMX287m::selectCam(int camIdx)
-{
- int input = camIdx;
- int ret = ioctl(m_cam_fd, VIDIOC_S_INPUT, &input);
-
- if (ret < 0) {
- fprintf(stderr,
- "cannot select cam: idx - %d, error - '%s'\n",
- camIdx,
- strerror(errno));
-
- return false;
- }
-
- return true;
-}
-
bool VeyeIMX287m::initCam()
{
int ret{-1};
@@ -516,11 +481,13 @@ bool VeyeIMX287m::initCam()
struct v4l2_requestbuffers rb;
memset(&rb, 0, sizeof rb);
rb.count = BUFFER_COUNT;
+
if constexpr (radxa_zero_3et) {
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
} else {
rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
}
+
rb.memory = V4L2_MEMORY_MMAP;
ret = ioctl(m_cam_fd, VIDIOC_REQBUFS, &rb);
@@ -545,10 +512,6 @@ bool VeyeIMX287m::initCam()
buffers.resize(rb.count);
- // memset(&buffer, 0, sizeof(buffer));
- // buffer.type = request.type;
- // buffer.memory = V4L2_MEMORY_MMAP;
-
std::cout << "query buffers" << std::endl;
for (uint32_t i = 0; i < rb.count; i++) {
@@ -570,9 +533,9 @@ bool VeyeIMX287m::initCam()
ret = ioctl(m_cam_fd, VIDIOC_QUERYBUF, &buf);
if (ret < 0) {
- // std::cout << "ioctl(VIDIOC_QUERYBUF) failed: " << errno << " " << std::endl;
std::cerr << "ioctl(VIDIOC_QUERYBUF) failed: " << errno << " ("
<< strerror(errno) << ")" << std::endl;
+
return false;
}
@@ -591,18 +554,14 @@ bool VeyeIMX287m::initCam()
MAP_SHARED,
m_cam_fd,
offset);
+
if (buffers[i].mem[0] == MAP_FAILED) {
std::cerr << "mmap() failed: " << errno << " (" << strerror(errno)
<< ")" << std::endl;
std::cerr << "length: " << length << std::endl;
std::cerr << "offset: " << offset << std::endl;
- return false;
- // m_videoBuffers[i] = (uint8_t *)
- // mmap(NULL, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, m_cam_fd, buf.m.offset);
- // if (m_videoBuffers[i] == MAP_FAILED) {
- // DBG("mmap() failed %d(%s)", errno, strerror(errno));
- // return false;
+ return false;
}
m_videoBuffers[i] = (uint8_t *) buffers[i].mem[0];
@@ -615,10 +574,8 @@ bool VeyeIMX287m::initCam()
i,
buffers[i].mem[0]);
- // buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- // buf.memory = V4L2_MEMORY_MMAP;
- // buf.index = i;
ret = ioctl(m_cam_fd, VIDIOC_QBUF, &buf);
+
if (ret != 0) {
std::cerr << "ioctl(VIDIOC_QBUF) failed: " << errno << " ("
<< strerror(errno) << ")" << std::endl;
@@ -631,18 +588,7 @@ bool VeyeIMX287m::initCam()
fflush(stdout);
fflush(stderr);
- // std::cout << "test return false" << std::endl;
- // return false;
-
- // int buffer_type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- // ret = ioctl(m_cam_fd, VIDIOC_STREAMON, &buffer_type);
- // if (ret != 0)
- // {
- // DBG("ioctl(VIDIOC_STREAMON) failed %d(%s)", errno, strerror(errno));
- // return false;
- // }
-
- DBG("cam init done.");
+ std::cout << "imx287 cam initialized" << std::endl;
return true;
}
@@ -693,8 +639,6 @@ void VeyeIMX287m::calcFrameLoop(std::stop_token stopToken)
}
}
-// Image &VeyeIMX287m::dequeueImageBuffer()
-// bool VeyeIMX287m::dequeueImageBuffer(Image &image)
bool VeyeIMX287m::dequeueImageBuffer(size_t &imageIndex)
// TODO: get Image from video_buffer_ptr
{
@@ -754,7 +698,6 @@ bool VeyeIMX287m::dequeueImageBuffer(size_t &imageIndex)
buf.index = requestIdx++ % BUFFER_COUNT;
{
- // m_bufferMutexes[buffer.index].lock();
{
std::lock_guard<std::mutex> lock(m_camMtx);
QElapsedTimer t;
diff --git a/src/camera/veyeimx287m.h b/src/camera/veyeimx287m.h
index d8c42ae..9b96afe 100644
--- a/src/camera/veyeimx287m.h
+++ b/src/camera/veyeimx287m.h
@@ -54,8 +54,6 @@ public:
bool set_gain(const float value) override;
std::optional<float> get_gain() override;
- bool setLaserLevel(int value) override;
-
public:
/*!
* \brief processedCounter - count of images processed in current second.
@@ -65,7 +63,6 @@ public:
private:
bool openCam();
- bool selectCam(int camIdx = 0);
bool initCam();
bool initI2C();
@@ -91,7 +88,7 @@ private:
* to m_videoBuffers[i] which is being copied to m_images[i]. In theory, it
* should not overlap if BUFFER_COUNT > theads count
*/
- std::array<uint8_t *, BUFFER_COUNT> m_videoBuffers;
+ std::array<uint8_t *, BUFFER_COUNT> m_videoBuffers{0};
struct buffer
{
diff --git a/src/main.cpp b/src/main.cpp
index e5d6c5b..99ad57b 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -80,10 +80,6 @@ auto printPixels = [](const auto &pixels) {
std::cout << std::endl;
};
-bool initLaser();
-
-bool initCam();
-
int main(int argc, char *argv[])
{
auto sigHandler = [](int s) {
@@ -231,77 +227,6 @@ int main(int argc, char *argv[])
qHttpServer.route("/v1/sensor/image", httpGetImage);
qHttpServer.route("/v1/sensor/image2", httpGetImage);
- qHttpServer.route("/v1/pixels", [&]() -> QHttpServerResponse {
- // std::cout << "http: pixels" << std::endl;
- // return QHttpServerResponse::StatusCode::ServiceUnavailable;
-
- auto cam = dynamic_cast<VeyeIMX287m *>(camera.get());
-
- if (!cam) {
- qDebug() << "NO CAM";
- return QHttpServerResponse::StatusCode::ServiceUnavailable;
- }
-
- Image img;
- // yeaah
- // ::img = &img;
- if (!cam->getImage(img)) {
- qDebug() << "cannot get image";
- return QHttpServerResponse::StatusCode::ServiceUnavailable;
- }
-
- ::pixels = std::move(img.pixels());
- ++cam->processedCounter;
-
- // qt json does not allow to limit double precision
- const auto lines = pixelsToLines(::pixels);
-
- const auto nan2zero = [](const auto &value) {
- return qIsNaN(value) ? 0 : value;
- };
- rapidjson::Document jd;
- jd.SetObject();
- auto &al = jd.GetAllocator();
-
- rapidjson::Value rjPixels{rapidjson::kArrayType};
-
- for (size_t i = 0; i < img_width; ++i) {
- rjPixels.PushBack(nan2zero(::pixels.pixels[i]), al);
- }
-
- rapidjson::Value rjLines{rapidjson::kArrayType};
-
- for (const auto &l : lines) {
- rapidjson::Value rjLineP1{rapidjson::kArrayType};
- rjLineP1.PushBack(nan2zero(l.p1().x()), al)
- .PushBack(nan2zero(l.p1().y()), al);
- rapidjson::Value rjLineP2{rapidjson::kArrayType};
- rjLineP2.PushBack(nan2zero(l.p2().x()), al)
- .PushBack(nan2zero(l.p2().y()), al);
- rapidjson::Value rjLinePoints{rapidjson::kArrayType};
- rjLinePoints.PushBack(rjLineP1, al).PushBack(rjLineP2, al);
-
- rjLines.PushBack(rjLinePoints, al);
- }
-
- // jd.AddMember("encoderPosition", qint64{encoder.position()});
- // FIXME: get prom pixels struct
- jd.AddMember("measurementCounter", img.counters.measurementCounter, al);
- jd.AddMember("timestampUs", img.counters.timestampUs, al);
- jd.AddMember("pixels", rjPixels.Move(), al);
- jd.AddMember("lines", rjLines.Move(), al);
-
- rapidjson::StringBuffer buffer;
- rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
- writer.SetMaxDecimalPlaces(2);
- jd.Accept(writer);
- QString res{(const char *) buffer.GetString()};
- // qDebug() << "size:" << res.size();
- // qDebug().noquote() << "ret pix";
-
- return QHttpServerResponse{res};
- });
-
qHttpServer.route("/v1/profile", [&]() -> QHttpServerResponse {
// std::cout << "http: profile" << std::endl;
return QHttpServerResponse::StatusCode::ServiceUnavailable;
@@ -368,72 +293,6 @@ int main(int argc, char *argv[])
return QHttpServerResponse::StatusCode::Ok;
});
- qHttpServer.route(
- "/v1/sensor/params",
- [&](const QHttpServerRequest &request) -> QHttpServerResponse {
- // std::cout << "http: params" << std::endl;
- switch (request.method()) {
- case QHttpServerRequest::Method::Get: {
- std::lock_guard<std::mutex> lg(pgm_image_mtx);
- QJsonObject json;
-
- return QHttpServerResponse(QJsonDocument(json).toJson());
- }
-
- case QHttpServerRequest::Method::Post: {
- // qDebug() << "request body:" << request.body();
-
- auto json = QJsonDocument::fromJson(request.body()).object();
-
- if (json.contains(exposureTimeKey)) {
- const int32_t value{json[exposureTimeKey].toInt()};
-
- if (value == 0)
- return QHttpServerResponse::StatusCode::
- RequestRangeNotSatisfiable;
-
- // qDebug() << "set new exposure time:" << value;
-
- // requested_params.exposureTime = value;
- if (!camera->set_exposureTime(
- std::chrono::microseconds(value))) {
- qDebug() << "cannot set exp";
- return QHttpServerResponse::StatusCode::
- RequestRangeNotSatisfiable;
- }
- }
-
- if (json.contains(gainKey)) {
- const auto value = json[gainKey].toDouble();
-
- if (value == 0)
- return QHttpServerResponse::StatusCode::
- RequestRangeNotSatisfiable;
-
- if (!camera->set_gain(value))
- return QHttpServerResponse::StatusCode::
- RequestRangeNotSatisfiable;
- }
-
- if (json.contains(laserLevelKey)) {
- const int32_t value{json[laserLevelKey].toInt()};
-
- if (!camera->setLaserLevel(value))
- return QHttpServerResponse::StatusCode::
- RequestRangeNotSatisfiable;
-
- requested_params.laserLevel = value;
- }
-
- return QHttpServerResponse(request.body());
- }
- default: {
- return QHttpServerResponse(
- QByteArray("unsupported http method"));
- }
- }
- });
-
qDebug() << "listen: " << qHttpServer.listen(QHostAddress::Any, 8081);
////////////////////////////////////////////////////////////////////////////
@@ -445,219 +304,3 @@ int main(int argc, char *argv[])
return result;
}
-
-bool initLaser()
-{
- const QLatin1String pwmChip{"pwmchip2"};
- const uint16_t pwmChannel{1};
- const QLatin1String pwmSystemRoot{"/sys/class/pwm"};
- const QString pwmChipRoot{pwmSystemRoot + "/" + pwmChip};
-
- const QString pwmExportFile{pwmChipRoot + "/export"};
-
- QFile f{pwmExportFile};
-
- if (!f.open(QFile::WriteOnly)) {
- qWarning() << "cannot open" << f.fileName() << "for writing";
- qWarning() << "error:" << f.errorString();
-
- return false;
- }
-
- QTextStream s{&f};
- s << pwmChannel;
-
- const QString pwm{QLatin1String("pwm%1").arg(QString::number(pwmChannel))};
- const QString pwmRoot{pwmChipRoot + "/" + pwm};
-
- const QString periodFilename{pwmRoot + "/period"};
- f.close();
- f.setFileName(periodFilename);
-
- if (!f.open(QFile::WriteOnly)) {
- qWarning() << "cannot open" << f.fileName() << "for writing";
- qWarning() << "error:" << f.errorString();
-
- return false;
- }
-
- const unsigned periodHz{50'000};
-
- s << periodHz;
-
- const QString dutyCycleFilename{pwmRoot + "/duty_cycle"};
- f.close();
- f.setFileName(dutyCycleFilename);
-
- if (!f.open(QFile::WriteOnly)) {
- qWarning() << "cannot open" << f.fileName() << "for writing";
- qWarning() << "error:" << f.errorString();
-
- return false;
- }
-
- const unsigned dutyCycle{3'000};
-
- s << dutyCycle;
-
- const QString enableFilename{pwmRoot + "/enable"};
- f.close();
- f.setFileName(enableFilename);
-
- if (!f.open(QFile::WriteOnly)) {
- qWarning() << "cannot open" << f.fileName() << "for writing";
- qWarning() << "error:" << f.errorString();
-
- return false;
- }
-
- const int enable{1};
-
- s << enable;
-
- return true;
-}
-
-bool initCam()
-{
- const v4l2_memory memtype = V4L2_MEMORY_MMAP;
- v4l2_buf_type type = (enum v4l2_buf_type) - 1;
- const char *devname{"/dev/video0"};
- int fd{open(devname, O_RDWR)};
-
- if (fd < 0) {
- printf("Error opening device %s: %s (%d).\n",
- devname,
- strerror(errno),
- errno);
- fflush(stdout);
- return false;
- }
-
- std::cout << devname << ": opened" << std::endl;
-
- v4l2_capability cap;
- memset(&cap, 0, sizeof cap);
- const auto ret = ioctl(fd, VIDIOC_QUERYCAP, &cap);
- if (ret < 0) {
- printf("cannot query cap for %s: %s (%d).\n",
- devname,
- strerror(errno),
- errno);
- fflush(stdout);
- return false;
- }
-
- std::cout << devname << ": got caps" << std::endl;
-
- const auto caps = cap.capabilities & V4L2_CAP_DEVICE_CAPS
- ? cap.device_caps
- : cap.capabilities;
- const bool has_video = caps
- & (V4L2_CAP_VIDEO_CAPTURE_MPLANE
- | V4L2_CAP_VIDEO_CAPTURE
- | V4L2_CAP_VIDEO_OUTPUT_MPLANE
- | V4L2_CAP_VIDEO_OUTPUT);
- const bool has_meta = caps & (V4L2_CAP_META_CAPTURE | V4L2_CAP_META_OUTPUT);
- const bool has_capture = caps
- & (V4L2_CAP_VIDEO_CAPTURE_MPLANE
- | V4L2_CAP_VIDEO_CAPTURE
- | V4L2_CAP_META_CAPTURE);
- const bool has_output = caps
- & (V4L2_CAP_VIDEO_OUTPUT_MPLANE
- | V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_META_OUTPUT);
- const bool has_mplane = caps
- & (V4L2_CAP_VIDEO_CAPTURE_MPLANE
- | V4L2_CAP_VIDEO_OUTPUT_MPLANE);
-
- printf("Device `%s' on `%s' (driver '%s') supports%s%s%s%s %s mplanes.\n",
- cap.card,
- cap.bus_info,
- cap.driver,
- has_video ? " video," : "",
- has_meta ? " meta-data," : "",
- has_capture ? " capture," : "",
- has_output ? " output," : "",
- has_mplane ? "with" : "without");
-
- const auto buf_type = [caps, devname]() -> int {
- if (caps & V4L2_CAP_VIDEO_CAPTURE_MPLANE) {
- std::cout << devname
- << ": buf_type: V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE"
- << std::endl;
- return V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
- } else if (caps & V4L2_CAP_VIDEO_OUTPUT_MPLANE) {
- std::cout << devname
- << ": buf_type: V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE"
- << std::endl;
- return V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
- } else if (caps & V4L2_CAP_VIDEO_CAPTURE) {
- std::cout << devname << ": buf_type: V4L2_BUF_TYPE_VIDEO_CAPTURE"
- << std::endl;
- return V4L2_BUF_TYPE_VIDEO_CAPTURE;
- } else if (caps & V4L2_CAP_VIDEO_OUTPUT) {
- std::cout << devname << ": buf_type: V4L2_BUF_TYPE_VIDEO_OUTPUT"
- << std::endl;
- return V4L2_BUF_TYPE_VIDEO_OUTPUT;
- } else if (caps & V4L2_CAP_META_CAPTURE) {
- std::cout << devname << ": buf_type: V4L2_BUF_TYPE_META_CAPTURE"
- << std::endl;
- return V4L2_BUF_TYPE_META_CAPTURE;
- } else if (caps & V4L2_CAP_META_OUTPUT) {
- std::cout << devname << ": buf_type: V4L2_BUF_TYPE_META_OUTPUT"
- << std::endl;
- return V4L2_BUF_TYPE_META_OUTPUT;
- } else {
- printf("Device supports neither capture nor output.\n");
- return -EINVAL;
- }
- }();
-
- if (buf_type < 0) {
- return false;
- }
-
- if (false) {
- v4l2_format fmt;
- memset(&fmt, 0, sizeof fmt);
- fmt.type = buf_type;
-
- if (ioctl(fd, VIDIOC_G_FMT, &fmt) < 0) {
- printf("Unable to get format: %s (%d).\n", strerror(errno), errno);
-
- return false;
- }
-
- const auto width = fmt.fmt.pix_mp.width;
- const auto height = fmt.fmt.pix_mp.height;
- const auto num_planes = fmt.fmt.pix_mp.num_planes;
- struct v4l2_plane_pix_format plane_fmt[VIDEO_MAX_PLANES] = {0};
-
- printf("Video format: (%08x) %ux%u field %d, %u planes: \n",
- fmt.fmt.pix_mp.pixelformat,
- fmt.fmt.pix_mp.width,
- fmt.fmt.pix_mp.height,
- fmt.fmt.pix_mp.field,
- fmt.fmt.pix_mp.num_planes);
-
- for (int i = 0; i < fmt.fmt.pix_mp.num_planes; i++) {
- plane_fmt[i].bytesperline = fmt.fmt.pix_mp.plane_fmt[i].bytesperline;
- plane_fmt[i].sizeimage = fmt.fmt.pix_mp.plane_fmt[i].bytesperline
- ? fmt.fmt.pix_mp.plane_fmt[i].sizeimage
- : 0;
-
- printf(" * Stride %u, buffer size %u\n",
- fmt.fmt.pix_mp.plane_fmt[i].bytesperline,
- fmt.fmt.pix_mp.plane_fmt[i].sizeimage);
- }
- }
-
- unsigned int padding = 0;
- unsigned int nbufs = 8;
-
- // if ()
-
- close(fd);
-
- return true;
-}
diff --git a/src/protocols/httpserver.cpp b/src/protocols/httpserver.cpp
index 41226aa..8819490 100644
--- a/src/protocols/httpserver.cpp
+++ b/src/protocols/httpserver.cpp
@@ -26,7 +26,7 @@ HttpServer::HttpServer(ICamera *camera,
// QObject *parent,
const QHostAddress &address,
const uint16_t port)
- : ProtocolBase{camera}
+ : IProtocol{camera}
, INIT_FIELD(address)
, INIT_FIELD(port)
, m_server{std::make_shared<QHttpServer>()}
diff --git a/src/protocols/httpserver.h b/src/protocols/httpserver.h
index 86b6ad6..64f7987 100644
--- a/src/protocols/httpserver.h
+++ b/src/protocols/httpserver.h
@@ -11,10 +11,8 @@
class ICamera;
class QHttpServer;
-class HttpServer : public ProtocolBase
+class HttpServer : public IProtocol
{
- // Q_OBJECT
-
private:
struct Stats
{
diff --git a/src/protocols/iprotocol.cpp b/src/protocols/iprotocol.cpp
index f85d990..d021fb7 100644
--- a/src/protocols/iprotocol.cpp
+++ b/src/protocols/iprotocol.cpp
@@ -1,5 +1,5 @@
#include "iprotocol.h"
-ProtocolBase::ProtocolBase(ICamera *camera)
+IProtocol::IProtocol(ICamera *camera)
: m_camera{camera}
{}
diff --git a/src/protocols/iprotocol.h b/src/protocols/iprotocol.h
index 3827550..1643036 100644
--- a/src/protocols/iprotocol.h
+++ b/src/protocols/iprotocol.h
@@ -5,14 +5,8 @@ class ICamera;
class IProtocol
{
public:
+ explicit IProtocol(ICamera *camera);
virtual ~IProtocol() = default;
-};
-
-class ProtocolBase : public IProtocol
-{
-public:
- explicit ProtocolBase(ICamera *camera);
- ~ProtocolBase() override = default;
protected:
ICamera *m_camera{nullptr};
diff --git a/src/protocols/protocolbase.cpp b/src/protocols/protocolbase.cpp
deleted file mode 100644
index 9116d25..0000000
--- a/src/protocols/protocolbase.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#include "protocolbase.h"
-
-ProtocolBase::ProtocolBase() {}
diff --git a/src/protocols/protocolbase.h b/src/protocols/protocolbase.h
deleted file mode 100644
index fb41dca..0000000
--- a/src/protocols/protocolbase.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef PROTOCOLBASE_H
-#define PROTOCOLBASE_H
-
-class ProtocolBase
-{
-public:
- ProtocolBase();
-};
-
-#endif // PROTOCOLBASE_H