A simple program that accepts RTMP streams and then restreams them directly to other services. I use it to record at a higher rate but stream to target services at the rate they want. It's also useful for streaming to multiple sites.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
distributary/server.hpp

39 lines
717 B

#pragma once
#include "fsm.hpp"
#include "config.hpp"
#include <chrono>
using namespace nlohmann;
using namespace std::chrono_literals;
#define BUF_MAX 1024 * 10
enum class ServerState {
START, READING, STOP, ERROR
};
enum class ServerEvent {
GO
};
class Server : DeadSimpleFSM<ServerState, ServerEvent> {
Config &config;
FILE *handle = nullptr;
char buffer[BUF_MAX];
char *res = nullptr;
std::chrono::milliseconds wait_time = 200ms;
int fail_count = 0;
public:
Server(Config &config) : config(config) {};
bool stopped();
void event(ServerEvent ev);
// states
void START(ServerEvent ev);
void READING(ServerEvent ev);
void STOP(ServerEvent ev);
void ERROR(ServerEvent ev);
};