Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions docs/generated/comments.json
Original file line number Diff line number Diff line change
Expand Up @@ -2824,6 +2824,97 @@
"lead": "",
"type": "class",
"examples": []
},
{
"subheads": [],
"description": "Get basic OBS video information",
"return": [
"{int} `baseWidth` Base (canvas) width",
"{int} `baseHeight` Base (canvas) height",
"{int} `outputWidth` Output width",
"{int} `outputHeight` Output height",
"{String} `scaleType` Scaling method used if output size differs from base size",
"{double} `fps` Frames rendered per second",
"{String} `videoFormat` Video color format",
"{String} `colorSpace` Color space for YUV",
"{String} `colorRange` Color range (full or partial)"
],
"api": "requests",
"name": "GetVideoInfo",
"category": "general",
"since": "4.6.0",
"returns": [
{
"type": "int",
"name": "baseWidth",
"description": "Base (canvas) width"
},
{
"type": "int",
"name": "baseHeight",
"description": "Base (canvas) height"
},
{
"type": "int",
"name": "outputWidth",
"description": "Output width"
},
{
"type": "int",
"name": "outputHeight",
"description": "Output height"
},
{
"type": "String",
"name": "scaleType",
"description": "Scaling method used if output size differs from base size"
},
{
"type": "double",
"name": "fps",
"description": "Frames rendered per second"
},
{
"type": "String",
"name": "videoFormat",
"description": "Video color format"
},
{
"type": "String",
"name": "colorSpace",
"description": "Color space for YUV"
},
{
"type": "String",
"name": "colorRange",
"description": "Color range (full or partial)"
}
],
"names": [
{
"name": "",
"description": "GetVideoInfo"
}
],
"categories": [
{
"name": "",
"description": "general"
}
],
"sinces": [
{
"name": "",
"description": "4.6.0"
}
],
"heading": {
"level": 2,
"text": "GetVideoInfo"
},
"lead": "",
"type": "class",
"examples": []
}
],
"profiles": [
Expand Down
29 changes: 29 additions & 0 deletions docs/generated/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ auth_response = base64_encode(auth_response_hash)
+ [SetFilenameFormatting](#setfilenameformatting)
+ [GetFilenameFormatting](#getfilenameformatting)
+ [GetStats](#getstats)
+ [GetVideoInfo](#getvideoinfo)
* [Profiles](#profiles-1)
+ [SetCurrentProfile](#setcurrentprofile)
+ [GetCurrentProfile](#getcurrentprofile)
Expand Down Expand Up @@ -1181,6 +1182,34 @@ _No specified parameters._
| `stats` | _OBSStats_ | OBS stats |


---

### GetVideoInfo


- Added in v4.6.0

Get basic OBS video information

**Request Fields:**

_No specified parameters._

**Response Items:**

| Name | Type | Description |
| ---- | :---: | ------------|
| `baseWidth` | _int_ | Base (canvas) width |
| `baseHeight` | _int_ | Base (canvas) height |
| `outputWidth` | _int_ | Output width |
| `outputHeight` | _int_ | Output height |
| `scaleType` | _String_ | Scaling method used if output size differs from base size |
| `fps` | _double_ | Frames rendered per second |
| `videoFormat` | _String_ | Video color format |
| `colorSpace` | _String_ | Color space for YUV |
| `colorRange` | _String_ | Color range (full or partial) |


---

## Profiles
Expand Down
1 change: 1 addition & 0 deletions src/WSRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ QHash<QString, HandlerResponse(*)(WSRequestHandler*)> WSRequestHandler::messageM

{ "GetStats", WSRequestHandler::HandleGetStats },
{ "SetHeartbeat", WSRequestHandler::HandleSetHeartbeat },
{ "GetVideoInfo", WSRequestHandler::HandleGetVideoInfo },

{ "SetFilenameFormatting", WSRequestHandler::HandleSetFilenameFormatting },
{ "GetFilenameFormatting", WSRequestHandler::HandleGetFilenameFormatting },
Expand Down
1 change: 1 addition & 0 deletions src/WSRequestHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class WSRequestHandler : public QObject {

static HandlerResponse HandleGetStats(WSRequestHandler* req);
static HandlerResponse HandleSetHeartbeat(WSRequestHandler* req);
static HandlerResponse HandleGetVideoInfo(WSRequestHandler* req);

static HandlerResponse HandleSetFilenameFormatting(WSRequestHandler* req);
static HandlerResponse HandleGetFilenameFormatting(WSRequestHandler* req);
Expand Down
82 changes: 82 additions & 0 deletions src/WSRequestHandler_General.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,54 @@

#include "WSRequestHandler.h"

#define CASE(x) case x: return #x;
const char *describe_output_format(int format) {
switch (format) {
default:
CASE(VIDEO_FORMAT_NONE)
CASE(VIDEO_FORMAT_I420)
CASE(VIDEO_FORMAT_NV12)
CASE(VIDEO_FORMAT_YVYU)
CASE(VIDEO_FORMAT_YUY2)
CASE(VIDEO_FORMAT_UYVY)
CASE(VIDEO_FORMAT_RGBA)
CASE(VIDEO_FORMAT_BGRA)
CASE(VIDEO_FORMAT_BGRX)
CASE(VIDEO_FORMAT_Y800)
CASE(VIDEO_FORMAT_I444)
}
}

const char *describe_color_space(int cs) {
switch (cs) {
default:
CASE(VIDEO_CS_DEFAULT)
CASE(VIDEO_CS_601)
CASE(VIDEO_CS_709)
}
}

const char *describe_color_range(int range) {
switch (range) {
default:
CASE(VIDEO_RANGE_DEFAULT)
CASE(VIDEO_RANGE_PARTIAL)
CASE(VIDEO_RANGE_FULL)
}
}

const char *describe_scale_type(int scale) {
switch (scale) {
default:
CASE(VIDEO_SCALE_DEFAULT)
CASE(VIDEO_SCALE_POINT)
CASE(VIDEO_SCALE_FAST_BILINEAR)
CASE(VIDEO_SCALE_BILINEAR)
CASE(VIDEO_SCALE_BICUBIC)
}
}
#undef CASE

/**
* Returns the latest version of the plugin and the API.
*
Expand Down Expand Up @@ -181,3 +229,37 @@ HandlerResponse WSRequestHandler::HandleGetStats(WSRequestHandler* req) {
obs_data_set_obj(response, "stats", stats);
return req->SendOKResponse(response);
}

/**
* Get basic OBS video information
*
* @return {int} `baseWidth` Base (canvas) width
* @return {int} `baseHeight` Base (canvas) height
* @return {int} `outputWidth` Output width
* @return {int} `outputHeight` Output height
* @return {String} `scaleType` Scaling method used if output size differs from base size
* @return {double} `fps` Frames rendered per second
* @return {String} `videoFormat` Video color format
* @return {String} `colorSpace` Color space for YUV
* @return {String} `colorRange` Color range (full or partial)
*
Comment thread
Palakis marked this conversation as resolved.
* @api requests
* @name GetVideoInfo
* @category general
* @since 4.6.0
*/
HandlerResponse WSRequestHandler::HandleGetVideoInfo(WSRequestHandler* req) {
obs_video_info ovi;
obs_get_video_info(&ovi);
OBSDataAutoRelease response = obs_data_create();
obs_data_set_int(response, "baseWidth", ovi.base_width);
obs_data_set_int(response, "baseHeight", ovi.base_height);
obs_data_set_int(response, "outputWidth", ovi.output_width);
obs_data_set_int(response, "outputHeight", ovi.output_height);
obs_data_set_double(response, "fps", (double)ovi.fps_num / ovi.fps_den);
obs_data_set_string(response, "videoFormat", describe_output_format(ovi.output_format));
obs_data_set_string(response, "colorSpace", describe_color_space(ovi.colorspace));
obs_data_set_string(response, "colorRange", describe_color_range(ovi.range));
obs_data_set_string(response, "scaleType", describe_scale_type(ovi.scale_type));
return req->SendOKResponse(response);
Comment thread
Palakis marked this conversation as resolved.
}