From f65fdcdbc1ffc5ad75acc2377112f99de162ea65 Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 13 Feb 2019 18:04:56 +0100 Subject: [PATCH 1/5] handler: Add caption handler --- src/WSRequestHandler.cpp | 1 + src/WSRequestHandler.h | 1 + src/WSRequestHandler_Streaming.cpp | 23 +++++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/WSRequestHandler.cpp b/src/WSRequestHandler.cpp index fdfc2e1e..954d475c 100644 --- a/src/WSRequestHandler.cpp +++ b/src/WSRequestHandler.cpp @@ -103,6 +103,7 @@ QHash WSRequestHandler::messageM { "SetStreamSettings", WSRequestHandler::HandleSetStreamSettings }, { "GetStreamSettings", WSRequestHandler::HandleGetStreamSettings }, { "SaveStreamSettings", WSRequestHandler::HandleSaveStreamSettings }, + { "SendCaptions", WSRequestHandler::HandleSendCaptions }, { "GetStudioModeStatus", WSRequestHandler::HandleGetStudioModeStatus }, { "GetPreviewScene", WSRequestHandler::HandleGetPreviewScene }, diff --git a/src/WSRequestHandler.h b/src/WSRequestHandler.h index 9d87366d..8099677e 100644 --- a/src/WSRequestHandler.h +++ b/src/WSRequestHandler.h @@ -128,6 +128,7 @@ class WSRequestHandler : public QObject { static HandlerResponse HandleSetStreamSettings(WSRequestHandler* req); static HandlerResponse HandleGetStreamSettings(WSRequestHandler* req); static HandlerResponse HandleSaveStreamSettings(WSRequestHandler* req); + static HandlerResponse HandleSendCaptions(WSRequestHandler * req); static HandlerResponse HandleSetTransitionDuration(WSRequestHandler* req); static HandlerResponse HandleGetTransitionDuration(WSRequestHandler* req); diff --git a/src/WSRequestHandler_Streaming.cpp b/src/WSRequestHandler_Streaming.cpp index 3a5e29f8..f6ddb01a 100644 --- a/src/WSRequestHandler_Streaming.cpp +++ b/src/WSRequestHandler_Streaming.cpp @@ -287,3 +287,26 @@ HandlerResponse WSRequestHandler::HandleSaveStreamSettings(WSRequestHandler* req obs_frontend_save_streaming_service(); return req->SendOKResponse(); } + + +/** + * Send the provided text as embedded CEA-608 caption data + * + * @api requests + * @name SendCaptions + * @category streaming + */ +HandlerResponse WSRequestHandler::HandleSendCaptions(WSRequestHandler* req) { + if (!req->hasField("text")) { + return req->SendErrorResponse("missing request parameters"); + } + + OBSOutputAutoRelease output = obs_frontend_get_streaming_output(); + if (output) { + const char* caption = obs_data_get_string(req->data, "text"); + obs_output_output_caption_text1(output, caption); + } + + return req->SendOKResponse(); +} + From 545db60b9831fe5c8ac2ad4be3e92b0c0c07291a Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 22 Mar 2019 10:27:27 +0100 Subject: [PATCH 2/5] ci: enable/build captions --- CI/install-build-obs-macos.sh | 1 + CI/install-build-obs.cmd | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CI/install-build-obs-macos.sh b/CI/install-build-obs-macos.sh index 351ce239..8ac4c6f1 100755 --- a/CI/install-build-obs-macos.sh +++ b/CI/install-build-obs-macos.sh @@ -34,6 +34,7 @@ git checkout $OBSLatestTag mkdir build && cd build echo "[obs-websocket] Building obs-studio.." cmake .. \ + -DBUILD_CAPTIONS=true \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 \ -DDISABLE_PLUGINS=true \ -DDepsPath=/tmp/obsdeps \ diff --git a/CI/install-build-obs.cmd b/CI/install-build-obs.cmd index b5292a83..61e46503 100644 --- a/CI/install-build-obs.cmd +++ b/CI/install-build-obs.cmd @@ -108,12 +108,12 @@ if defined BuildOBS ( mkdir build64 echo Running cmake for obs-studio %OBSLatestTag% 32-bit... cd ./build32 - cmake -G "Visual Studio 14 2015" -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true .. + cmake -G "Visual Studio 14 2015" -DBUILD_CAPTIONS=true -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true .. echo: echo: echo Running cmake for obs-studio %OBSLatestTag% 64-bit... cd ../build64 - cmake -G "Visual Studio 14 2015 Win64" -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true .. + cmake -G "Visual Studio 14 2015 Win64" -DBUILD_CAPTIONS=true -DDISABLE_PLUGINS=true -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true .. echo: echo: echo Building obs-studio %OBSLatestTag% 32-bit ^(Build Config: %build_config%^)... From 79493df32e194ec3aa2024d0f662283bd580a39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lepin?= Date: Tue, 16 Apr 2019 13:11:46 +0200 Subject: [PATCH 3/5] requests(streaming): fix docs on SendCaptions --- src/WSRequestHandler_Streaming.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/WSRequestHandler_Streaming.cpp b/src/WSRequestHandler_Streaming.cpp index f6ddb01a..6dad96b2 100644 --- a/src/WSRequestHandler_Streaming.cpp +++ b/src/WSRequestHandler_Streaming.cpp @@ -291,7 +291,9 @@ HandlerResponse WSRequestHandler::HandleSaveStreamSettings(WSRequestHandler* req /** * Send the provided text as embedded CEA-608 caption data - * + * + * @param {String} `text` Captions text + * * @api requests * @name SendCaptions * @category streaming From fd1c4abad7d9d7fc0dc4acaef56c9c785b19c81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20L?= Date: Tue, 16 Apr 2019 22:51:22 +0200 Subject: [PATCH 5/5] requests(streaming): conditional compilation of SendCaptions --- src/WSRequestHandler.cpp | 2 ++ src/WSRequestHandler.h | 2 ++ src/WSRequestHandler_Streaming.cpp | 13 ++++++++----- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/WSRequestHandler.cpp b/src/WSRequestHandler.cpp index 954d475c..3e396c7a 100644 --- a/src/WSRequestHandler.cpp +++ b/src/WSRequestHandler.cpp @@ -103,7 +103,9 @@ QHash WSRequestHandler::messageM { "SetStreamSettings", WSRequestHandler::HandleSetStreamSettings }, { "GetStreamSettings", WSRequestHandler::HandleGetStreamSettings }, { "SaveStreamSettings", WSRequestHandler::HandleSaveStreamSettings }, +#if BUILD_CAPTIONS { "SendCaptions", WSRequestHandler::HandleSendCaptions }, +#endif { "GetStudioModeStatus", WSRequestHandler::HandleGetStudioModeStatus }, { "GetPreviewScene", WSRequestHandler::HandleGetPreviewScene }, diff --git a/src/WSRequestHandler.h b/src/WSRequestHandler.h index 8099677e..97e562c8 100644 --- a/src/WSRequestHandler.h +++ b/src/WSRequestHandler.h @@ -128,7 +128,9 @@ class WSRequestHandler : public QObject { static HandlerResponse HandleSetStreamSettings(WSRequestHandler* req); static HandlerResponse HandleGetStreamSettings(WSRequestHandler* req); static HandlerResponse HandleSaveStreamSettings(WSRequestHandler* req); +#if BUILD_CAPTIONS static HandlerResponse HandleSendCaptions(WSRequestHandler * req); +#endif static HandlerResponse HandleSetTransitionDuration(WSRequestHandler* req); static HandlerResponse HandleGetTransitionDuration(WSRequestHandler* req); diff --git a/src/WSRequestHandler_Streaming.cpp b/src/WSRequestHandler_Streaming.cpp index 6dad96b2..f877e812 100644 --- a/src/WSRequestHandler_Streaming.cpp +++ b/src/WSRequestHandler_Streaming.cpp @@ -8,7 +8,7 @@ /** * Get current streaming and recording status. - * + * * @return {boolean} `streaming` Current streaming status. * @return {boolean} `recording` Current recording status. * @return {String (optional)} `stream-timecode` Time elapsed since streaming started (only present if currently streaming). @@ -22,7 +22,7 @@ */ HandlerResponse WSRequestHandler::HandleGetStreamingStatus(WSRequestHandler* req) { auto events = WSEvents::Current(); - + OBSDataAutoRelease data = obs_data_create(); obs_data_set_bool(data, "streaming", obs_frontend_streaming_active()); obs_data_set_bool(data, "recording", obs_frontend_recording_active()); @@ -65,7 +65,7 @@ HandlerResponse WSRequestHandler::HandleStartStopStreaming(WSRequestHandler* req * * @param {Object (optional)} `stream` Special stream configuration. Please note: these won't be saved to OBS' configuration. * @param {String (optional)} `stream.type` If specified ensures the type of stream matches the given type (usually 'rtmp_custom' or 'rtmp_common'). If the currently configured stream type does not match the given stream type, all settings must be specified in the `settings` object or an error will occur when starting the stream. - * @param {Object (optional)} `stream.metadata` Adds the given object parameters as encoded query string parameters to the 'key' of the RTMP stream. Used to pass data to the RTMP service about the streaming. May be any String, Numeric, or Boolean field. + * @param {Object (optional)} `stream.metadata` Adds the given object parameters as encoded query string parameters to the 'key' of the RTMP stream. Used to pass data to the RTMP service about the streaming. May be any String, Numeric, or Boolean field. * @param {Object (optional)} `stream.settings` Settings for the stream. * @param {String (optional)} `stream.settings.server` The publish URL. * @param {String (optional)} `stream.settings.key` The publish key of the stream. @@ -185,7 +185,7 @@ HandlerResponse WSRequestHandler::HandleStopStreaming(WSRequestHandler* req) { /** * Sets one or more attributes of the current streaming server settings. Any options not passed will remain unchanged. Returns the updated settings in response. If 'type' is different than the current streaming service type, all settings are required. Returns the full settings of the stream (the same as GetStreamSettings). - * + * * @param {String} `type` The type of streaming service configuration, usually `rtmp_custom` or `rtmp_common`. * @param {Object} `settings` The actual settings of the stream. * @param {String (optional)} `settings.server` The publish URL. @@ -290,7 +290,8 @@ HandlerResponse WSRequestHandler::HandleSaveStreamSettings(WSRequestHandler* req /** - * Send the provided text as embedded CEA-608 caption data + * Send the provided text as embedded CEA-608 caption data. + * As of OBS Studio 23.1, captions are not yet available on Linux. * * @param {String} `text` Captions text * @@ -298,6 +299,7 @@ HandlerResponse WSRequestHandler::HandleSaveStreamSettings(WSRequestHandler* req * @name SendCaptions * @category streaming */ +#if BUILD_CAPTIONS HandlerResponse WSRequestHandler::HandleSendCaptions(WSRequestHandler* req) { if (!req->hasField("text")) { return req->SendErrorResponse("missing request parameters"); @@ -311,4 +313,5 @@ HandlerResponse WSRequestHandler::HandleSendCaptions(WSRequestHandler* req) { return req->SendOKResponse(); } +#endif