Merge branch 'bugfix/openprojector-build-error' into 4.x-current

This commit is contained in:
Stéphane Lepin 2020-03-12 17:51:57 +01:00
commit 4e19e41460
4 changed files with 43 additions and 11 deletions

View File

@ -14,6 +14,6 @@ apt-get install -y \
qtbase5-dev
# Dirty hack
wget -O /usr/include/obs/obs-frontend-api.h https://raw.githubusercontent.com/obsproject/obs-studio/master/UI/obs-frontend-api/obs-frontend-api.h
wget -O /usr/include/obs/obs-frontend-api.h https://raw.githubusercontent.com/obsproject/obs-studio/24.0.3/UI/obs-frontend-api/obs-frontend-api.h
ldconfig

View File

@ -798,8 +798,6 @@ void getPauseRecordingFunctions(RecordingPausedFunction* recPausedFuncPtr, Pause
if (pauseRecFuncPtr) {
*pauseRecFuncPtr = (PauseRecordingFunction)os_dlsym(frontendApi, "obs_frontend_recording_pause");
}
os_dlclose(frontendApi);
}
bool Utils::RecordingPauseSupported()
@ -835,6 +833,34 @@ void Utils::PauseRecording(bool pause)
pauseRecording(pause);
}
bool Utils::OpenProjectorSupported()
{
void* frontendApi = os_dlopen("obs-frontend-api");
if (!frontendApi) {
return false;
}
void* openProjectorFunc = os_dlsym(frontendApi, "obs_frontend_open_projector");
return (openProjectorFunc != nullptr);
}
void Utils::OpenProjector(const char* type, int monitor, const char* geometry, const char* name)
{
typedef void(*OpenProjectorFunc)(const char*, int monitor, const char* geometry, const char* name);
void* frontendApi = os_dlopen("obs-frontend-api");
if (!frontendApi) {
return;
}
OpenProjectorFunc openProjectorFunc = (OpenProjectorFunc)os_dlsym(frontendApi, "obs_frontend_open_projector");
if (!openProjectorFunc) {
return;
}
openProjectorFunc(type, monitor, geometry, name);
}
QString Utils::nsToTimestamp(uint64_t ns)
{
uint64_t ms = ns / 1000000ULL;

View File

@ -86,5 +86,8 @@ namespace Utils {
bool RecordingPaused();
void PauseRecording(bool pause);
bool OpenProjectorSupported();
void OpenProjector(const char* type, int monitor, const char* geometry, const char* name);
QString nsToTimestamp(uint64_t ns);
};

View File

@ -331,17 +331,20 @@ RpcResponse WSRequestHandler::GetVideoInfo(const RpcRequest& request) {
* @since unreleased
*/
RpcResponse WSRequestHandler::OpenProjector(const RpcRequest& request) {
#if LIBOBS_API_VER >= 0x18000004
const char *type = obs_data_get_string(request.parameters(), "type");
if (!Utils::OpenProjectorSupported()) {
return request.failed("Projector opening requires OBS 24.0.4 or newer.");
}
const char* type = obs_data_get_string(request.parameters(), "type");
int monitor = -1;
if (request.hasField("monitor")) {
monitor = obs_data_get_int(request.parameters(), "monitor");
}
const char *geometry = obs_data_get_string(request.parameters(), "geometry");
const char *name = obs_data_get_string(request.parameters(), "name");
obs_frontend_open_projector(type, monitor, geometry, name);
const char* geometry = obs_data_get_string(request.parameters(), "geometry");
const char* name = obs_data_get_string(request.parameters(), "name");
Utils::OpenProjector(type, monitor, geometry, name);
return request.success();
#else
return request.failed("Projector opening requires libobs v24.0.4 or newer.");
#endif
}