General: code and docs cleanup

This commit is contained in:
Palakis
2017-09-25 16:48:46 +02:00
parent 6aef437f58
commit 3981abc5ca
5 changed files with 71 additions and 76 deletions

View File

@ -115,8 +115,6 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
if (!owner->_srv)
return;
// TODO : implement SourceOrderChanged and RepopulateSources
if (event == OBS_FRONTEND_EVENT_SCENE_CHANGED) {
owner->OnSceneChange();
}
@ -669,25 +667,25 @@ void WSEvents::StreamStatus() {
obs_output_release(stream_output);
}
/************************************************************************************************************
* Heatbeat is emitted every 2 seconds, when enabled with request: SetHeartbeat *
* *
* @return {boolean} `pulse` Toggles between every JSON meassage as an "I am alive" indicator. *
* @return {string (optional)} `current-profile` Current active profile. *
* @return {string (optional)} `current-scene` Current active scene. *
* @return {boolean (optional)} `streaming` Current streaming state. *
* @return {int (optional)} `total-stream-time` Total time (in seconds) since the stream started. *
* @return {int (optional)} `total-stream-bytes` Total bytes sent since the stream started. *
* @return {int (optional)} `total-stream-frames` Total frames streamed since the stream started. *
* @return {boolean (optional)} `recording` Current recording state. *
* @return {int (optional)} `total-record-time` Total time (in seconds) since recording started. *
* @return {int (optional)} `total-record-bytes` Total bytes recorded since the recording started. *
* @return {int (optional)} `total-record-frames` Total frames recorded since the recording started. *
* *
* @api events *
* @name Heartbeat *
* @category general *
************************************************************************ September 2017 *** by RainbowEK ***/
/**
* Emitted every 2 seconds after enabling it by calling SetHeartbeat.
*
* @return {boolean} `pulse` Toggles between every JSON meassage as an "I am alive" indicator.
* @return {string (optional)} `current-profile` Current active profile.
* @return {string (optional)} `current-scene` Current active scene.
* @return {boolean (optional)} `streaming` Current streaming state.
* @return {int (optional)} `total-stream-time` Total time (in seconds) since the stream started.
* @return {int (optional)} `total-stream-bytes` Total bytes sent since the stream started.
* @return {int (optional)} `total-stream-frames` Total frames streamed since the stream started.
* @return {boolean (optional)} `recording` Current recording state.
* @return {int (optional)} `total-record-time` Total time (in seconds) since recording started.
* @return {int (optional)} `total-record-bytes` Total bytes recorded since the recording started.
* @return {int (optional)} `total-record-frames` Total frames recorded since the recording started.
*
* @api events
* @name Heartbeat
* @category general
*/
void WSEvents::Heartbeat() {
if (!Heartbeat_active) return;
@ -709,20 +707,20 @@ void WSEvents::Heartbeat() {
obs_data_set_string(data, "current-scene", name);
obs_data_set_bool(data, "streaming", streaming_active);
if (streaming_active) {
uint64_t totalStreamTime = (os_gettime_ns() - _stream_starttime) / 1000000000;
obs_data_set_int(data, "total-stream-time", totalStreamTime);
obs_data_set_int(data, "total-stream-bytes", (uint64_t)obs_output_get_total_bytes(stream_output));
obs_data_set_int(data, "total-stream-frames", obs_output_get_total_frames(stream_output));
}
if (streaming_active) {
uint64_t totalStreamTime = (os_gettime_ns() - _stream_starttime) / 1000000000;
obs_data_set_int(data, "total-stream-time", totalStreamTime);
obs_data_set_int(data, "total-stream-bytes", (uint64_t)obs_output_get_total_bytes(stream_output));
obs_data_set_int(data, "total-stream-frames", obs_output_get_total_frames(stream_output));
}
obs_data_set_bool(data, "recording", recording_active);
if (recording_active) {
uint64_t totalRecordTime = (os_gettime_ns() - _rec_starttime) / 1000000000;
if (recording_active) {
uint64_t totalRecordTime = (os_gettime_ns() - _rec_starttime) / 1000000000;
obs_data_set_int(data, "total-record-time", totalRecordTime);
obs_data_set_int(data, "total-record-bytes", (uint64_t)obs_output_get_total_bytes(record_output));
obs_data_set_int(data, "total-record-frames", obs_output_get_total_frames(record_output));
}
obs_data_set_int(data, "total-record-bytes", (uint64_t)obs_output_get_total_bytes(record_output));
obs_data_set_int(data, "total-record-frames", obs_output_get_total_frames(record_output));
}
broadcastUpdate("Heartbeat", data);
obs_data_release(data);

View File

@ -31,16 +31,16 @@ class WSEvents : public QObject {
~WSEvents();
static void FrontendEventHandler(
enum obs_frontend_event event, void* private_data);
static WSEvents* Instance;
void connectTransitionSignals(obs_source_t* transition);
void connectSceneSignals(obs_source_t* scene);
static WSEvents* Instance;
uint64_t GetStreamingTime();
const char* GetStreamingTimecode();
uint64_t GetRecordingTime();
const char* GetRecordingTimecode();
bool Heartbeat_active;
bool Heartbeat_active;
private slots:
void deferredInitOperations();

View File

@ -300,45 +300,42 @@ void WSRequestHandler::HandleAuthenticate(WSRequestHandler* req) {
}
}
/************************************************************************************************************
* Heatbeat update message is emitted every 2 seconds, when enabled with this request. *
* When the Heartbeat is enabled it always sends a `pulse` to indicate that the host obs is alive. *
* Read comment from 'void WSEvents::Heartbeat()' for the total picture. *
* *
* @param {boolean} `enable` Starts/Stops emitting heartbeat messages *
* *
* @api requests *
* @name HandleSetHeartbeat *
* @category general *
************************************************************************ September 2017 *** by RainbowEK ***/
/**
* Enable/disable sending of the Heartbeat event
*
* @param {boolean} `enable` Starts/Stops emitting heartbeat messages
*
* @api requests
* @name HandleSetHeartbeat
* @category general
*/
void WSRequestHandler::HandleSetHeartbeat(WSRequestHandler* req) {
if (!req->hasField("enable")) {
req->SendErrorResponse("Heartbeat <enable> parameter missing");
return;
}
if (!req->hasField("enable")) {
req->SendErrorResponse("Heartbeat <enable> parameter missing");
return;
}
WSEvents::Instance->Heartbeat_active =
obs_data_get_bool(req->data, "enable");
obs_data_t* response = obs_data_create();
bool keyValue = obs_data_get_bool(req->data, "enable");
if (keyValue) WSEvents::Instance->Heartbeat_active = true;
else WSEvents::Instance->Heartbeat_active = false;
obs_data_set_bool(response, "enable", keyValue);
obs_data_set_bool(response, "enable",
WSEvents::Instance->Heartbeat_active);
req->SendOKResponse(response);
obs_data_release(response);
}
/**
* Switch to the specified scene.
*
* @param {String} `scene-name` Name of the scene to switch to.
*
* @api requests
* @name SetCurrentScene
* @category scenes
* @since 0.3
*/
* Switch to the specified scene.
*
* @param {String} `scene-name` Name of the scene to switch to.
*
* @api requests
* @name SetCurrentScene
* @category scenes
* @since 0.3
*/
void WSRequestHandler::HandleSetCurrentScene(WSRequestHandler* req) {
if (!req->hasField("scene-name")) {
req->SendErrorResponse("missing request parameters");