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/fsm.hpp

28 lines
686 B

#pragma once
#include <fmt/core.h>
#ifndef FSM_DEBUG
#define FSM_STATE(C, S, E, ...) case C::S: S(E, ##__VA_ARGS__); break
#else
#define FSM_STATE(C, S, E, ...) case C::S: fmt::println(">> " #C " " #S " event={}, state={}", int(E), int(_state)); S(E, ##__VA_ARGS__); fmt::println("<< " #C " state={}", int(_state)); break
#endif
template<typename S, typename E>
class DeadSimpleFSM {
protected:
// BUG: don't put this in your class because state() won't work
S _state = S::START;
public:
template<typename... Types>
void event(E event, Types... args);
void state(S next_state) {
_state = next_state;
}
bool in_state(S state) {
return _state == state;
}
};