Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Feb 16, 2025
1 parent 6a476f8 commit cb0b232
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/control_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void ControlServer::onMessageReceived(std::shared_ptr<ControlSession> session, c
}


void ControlServer::onNewSession(shared_ptr<ControlSession> session)
void ControlServer::onNewSession(std::shared_ptr<ControlSession> session)
{
std::lock_guard<std::recursive_mutex> mlock(session_mutex_);
session->start();
Expand Down
16 changes: 16 additions & 0 deletions server/streamreader/stream_control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace streamreader
{


/// Stream control base class
/// Controls a stream via "command" (play, pause, next, ...)
/// Provides status information (playback status, position, metadata, ...)
class StreamControl
{
public:
Expand All @@ -50,21 +53,30 @@ class StreamControl
using OnResponse = std::function<void(const jsonrpcpp::Response& response)>;
using OnLog = std::function<void(std::string message)>;

/// c'tor
explicit StreamControl(const boost::asio::any_io_executor& executor);
/// d'tor
virtual ~StreamControl() = default;

/// Start the stream control, calls abstract "doStart"
void start(const std::string& stream_id, const ServerSettings& server_setttings, const OnNotification& notification_handler,
const OnRequest& request_handler, const OnLog& log_handler);

/// Issue a command to the stream, calls abstract "doCommand"
void command(const jsonrpcpp::Request& request, const OnResponse& response_handler);

protected:
/// abstract "command" interface: send a json request to the plugin
virtual void doCommand(const jsonrpcpp::Request& request) = 0;
/// abstract "start" interface: starts and initializes the plugin
virtual void doStart(const std::string& stream_id, const ServerSettings& server_setttings) = 0;

/// a @p json message has been received from the plugin
void onReceive(const std::string& json);
/// a @p message log request has been received from the plugin
void onLog(std::string message);

/// asio executor
boost::asio::any_io_executor executor_;

private:
Expand All @@ -76,10 +88,14 @@ class StreamControl
};


/// Script based stream control
/// Executes a script (e.g. Python) and communicates via stdout/stdin with the script
class ScriptStreamControl : public StreamControl
{
public:
/// c'tor
ScriptStreamControl(const boost::asio::any_io_executor& executor, const std::filesystem::path& plugin_dir, std::string script, std::string params);
/// d'tor
virtual ~ScriptStreamControl() = default;

private:
Expand Down

0 comments on commit cb0b232

Please sign in to comment.