Commit 8f67c453 authored by Willem Mulder's avatar Willem Mulder

Merge branch 'complete-documentation' into 'develop'

Complete documentation

See merge request !4
parents 2425db36 035d035a
Pipeline #26446 passed with stage
in 15 seconds
......@@ -45,6 +45,8 @@ compile_commands.json
CTestTestfile.cmake
_deps
# Doxygen
/html
# JetBrains
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
......@@ -114,4 +116,4 @@ fabric.properties
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
\ No newline at end of file
.idea/caches/build_file_checksums.ser
doxygen:
image: alpine
script:
- apk update && apk add doxygen
- doxygen
artifacts:
paths:
- html
......@@ -416,25 +416,25 @@ LOOKUP_CACHE_SIZE = 0
# normally produced when WARNINGS is set to YES.
# The default value is: NO.
EXTRACT_ALL = NO
EXTRACT_ALL = YES
# If the EXTRACT_PRIVATE tag is set to YES, all private members of a class will
# be included in the documentation.
# The default value is: NO.
EXTRACT_PRIVATE = NO
EXTRACT_PRIVATE = YES
# If the EXTRACT_PACKAGE tag is set to YES, all members with package or internal
# scope will be included in the documentation.
# The default value is: NO.
EXTRACT_PACKAGE = NO
EXTRACT_PACKAGE = YES
# If the EXTRACT_STATIC tag is set to YES, all static members of a file will be
# included in the documentation.
# The default value is: NO.
EXTRACT_STATIC = NO
EXTRACT_STATIC = YES
# If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
# locally in source files will be included in the documentation. If set to NO,
......@@ -743,7 +743,7 @@ WARN_NO_PARAMDOC = NO
# a warning is encountered.
# The default value is: NO.
WARN_AS_ERROR = NO
WARN_AS_ERROR = YES
# The WARN_FORMAT tag determines the format of the warning messages that doxygen
# can produce. The string should contain the $file, $line, and $text tags, which
......
# Jinglepings-server
Ping! Ping! Jingleping!
Ping! Ping! Jingleping! Make the pings go fast!
Make the pings go fast!
This a simple C++ implementation of a Jinglepings server.
Flow of packets is:
```
(ICMPv6 packet)
Socket
JingleController
JingleBuffer(s)
Gstreamer Pipeline
(RTMP server)
```
Configuration is done in `CMakeLists.txt`.
#include "JingleController.h"
//! Constructor for Jingleping Controller.
//! Initialises a blacklist from a blacklist file if it exists.
//! \param blacklistFile file to store/retrive blacklist from.
JingleController::JingleController(std::filesystem::path &blacklistFile) : blacklistFile(blacklistFile) {
// Get blacklist from disk if possible
if (std::filesystem::exists(blacklistFile)) {
......@@ -51,7 +54,7 @@ void JingleController::drawPixel(uint64_t sourceAddr, int y, int x, uint8_t a, u
//! Draw a pixel on the Jingle board
//! puts a pixel on the main board with the specified values, and on a source
//! specific board to keep track of submitted images from each IP address.
//! \param upper 64 bits of the IPV6 source address
//! \param sourceAddr upper 64 bits of the IPV6 source address
//! \param y
//! \param x
//! \param value
......@@ -101,7 +104,6 @@ void JingleController::removeFromBlacklist(uint64_t sourceAddr) {
}
//! Save the blacklist to file.
//! \param sourceAddr upper 64 bits of the IPV6 source address
void JingleController::saveBlackList() {
std::ofstream bout(blacklistFile);
blacklistLock.lock_shared();
......@@ -118,16 +120,23 @@ std::unordered_set<uint64_t> JingleController::getBlacklist() {
return blacklist;
}
//! Get the main buffer.
//! \return the main buffer
cv::Mat JingleController::getMainBuffer() {
return mainBuffer.getBuffer();
}
//! Convert a 64-bit subnet ID to a hex string.
//! \return hexadecimal representation of the subnet ID.
static inline std::string idToHex(uint64_t id) {
char label[17];
std::snprintf(label, sizeof label, "%016lx", id);
return std::string(label);
}
//! Get a single matrix containing the main buffer,
//! and all source frames with an annotation.
//! \return matrix with all buffer contents.
cv::Mat JingleController::getBuffers() {
int width = mainBuffer.getBuffer().cols;
int height = mainBuffer.getBuffer().rows;
......
......@@ -7,6 +7,7 @@
#include <shared_mutex>
#include "../draw/JingleBuffer.h"
//! \brief Controller allowing concurrent handling of incoming pings.
class JingleController {
public:
JingleController(std::filesystem::path &blacklistFile);
......
......@@ -41,7 +41,7 @@ void JingleBuffer::setPixel(int y, int x, const cv::Vec4b &value) {
}
//! Returns reference to internal OpenCV buffer
//! \return
//! \return internal OpenCV buffer
cv::Mat JingleBuffer::getBuffer() const {
return buffer;
}
......@@ -3,6 +3,7 @@
#include <opencv2/opencv.hpp>
//! \brief Image buffer where pings are stored.
class JingleBuffer {
public:
......
......@@ -13,6 +13,8 @@ const std::string gstreamer_pipe = "appsrc is-live=true ! videoconvert ! " \
"x264enc tune=zerolatency key-int-max=250 speed-preset=veryfast quantizer=0 qp-min=0 qp-max=0 byte-stream=true threads=4 ! " \
"flvmux streamable=true ! rtmpsink location=" + std::string(JINGLE_RTMP_URL);
//! Create the overview image for management.
//! \param controller controller to create image for.
void overViewCreator(JingleController &controller) {
using namespace std::chrono_literals;
......@@ -29,6 +31,8 @@ void overViewCreator(JingleController &controller) {
}
}
//! Create the video stream.
//! \param controller controller to create stream for.
int mainCreator(JingleController &controller) {
using namespace std::chrono_literals;
......
#include <iostream>
#include <cstdio>
#include <cstring>
#include <linux/if_ether.h>
......@@ -13,6 +12,8 @@
#include "Socket.h"
//! Constructor for socket.
//! \param interface_name network interface name to listen on.
Socket::Socket(std::string interface_name) {
// Create socket
sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_IPV6));
......@@ -37,6 +38,9 @@ Socket::Socket(std::string interface_name) {
}
}
//! Run the socket for a single controller.
//! This retrieves pixels from the socket and passes them to the given controller.
//! \param controller controller to send pixels to.
void Socket::run(JingleController &controller) {
// Initialize buffers
struct mmsghdr msgs[msg_count];
......@@ -57,6 +61,9 @@ void Socket::run(JingleController &controller) {
}
}
//! Retrieve pixels (in the form of ICMPv6 messages) and send them to the controller.
//! \param msgs buffer to store messages in.
//! \param controller controller to send pixel information to.
void Socket::receivePixels(mmsghdr *msgs, JingleController &controller) {
auto res = recvmmsg(sockfd, msgs, msg_count, 0, &timeout);
if (res == -1) {
......@@ -90,6 +97,9 @@ void Socket::receivePixels(mmsghdr *msgs, JingleController &controller) {
}
}
//! Get the interface number corresponding to an interface name.
//! \param interface_name interface name.
//! \return interface number.
int Socket::getInterfaceNumber(std::string &interface_name) {
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
......
......@@ -9,12 +9,14 @@
#include "../controller/JingleController.h"
//! \brief Exceptions that occur during socket interaction.
class SocketException : public std::runtime_error {
public:
SocketException(std::string const &msg) :
std::runtime_error(msg) {}
};
//! \brief Socket for receiving pings.
class Socket {
private:
// Buffer and timing parameters
......
#include <thread>
#include "Tui.h"
//! Constructor for TUI of JingleController.
//! \param controller controller to control from the terminal.
Tui::Tui(JingleController &controller) : controller(controller) {}
//! Run the TUI.
void Tui::run() {
using namespace std::chrono_literals;
......@@ -29,6 +32,8 @@ void Tui::run() {
}
}
//! Execute a command.
//! \param cmd command to execute.
void Tui::runCommand(std::string &cmd) {
if (cmd == "help") {
std::cerr << "Commands are: " << std::endl
......@@ -46,24 +51,29 @@ void Tui::runCommand(std::string &cmd) {
}
}
//! Get a hex prefix from the user and return it as int.
//! \return prefix as number.
static uint64_t getPrefix() {
uint64_t prefix;
std::cin >> std::hex >> prefix;
return prefix;
}
//! Execute the 'add' command.
void Tui::cmdAdd() {
auto prefix = getPrefix();
controller.addToBlacklist(prefix);
std::cerr << "Added to blacklist:" << std::hex << std::setfill('0') << std::setw(16) << prefix << std::endl;
}
//! Execute the 'del' command.
void Tui::cmdDel() {
auto prefix = getPrefix();
controller.removeFromBlacklist(prefix);
std::cerr << "Removed from blacklist:" << std::hex << std::setfill('0') << std::setw(16) << prefix << std::endl;
}
//! Execute the 'list' command.
void Tui::cmdList() {
for (const auto prefix: controller.getBlacklist()) {
std::cerr << std::hex << std::setfill('0') << std::setw(16) << prefix << std::endl;
......
......@@ -3,12 +3,14 @@
#include "../controller/JingleController.h"
//! \brief TUI errors.
class TuiException : public std::runtime_error {
public:
TuiException(std::string const &msg) :
std::runtime_error(msg) {}
};
//! \brief TUI that allows manual controller control.
class Tui {
private:
JingleController &controller;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment