Skip to content

Commit adf46a6

Browse files
committed
Support OBS 31
1 parent 92cce22 commit adf46a6

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# --- Detect if the plugin is build out of tree or not ---
22
if(CMAKE_PROJECT_NAME STREQUAL "obs-studio")
33
set(BUILD_OUT_OF_TREE OFF)
4-
if(OBS_CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0)
5-
legacy_check()
6-
endif()
74
else()
85
set(BUILD_OUT_OF_TREE ON)
96
cmake_minimum_required(VERSION 3.18)

source-record.c

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ static void start_file_output(struct source_record_filter_context *filter, obs_d
391391
obs_data_t *s = obs_data_create();
392392
char path[512];
393393
const char *format = obs_data_get_string(settings, "rec_format");
394-
char *filename = os_generate_formatted_filename(GetFormatExt(format), true,
395-
obs_data_get_string(settings, "filename_formatting"));
394+
char *filename =
395+
os_generate_formatted_filename(GetFormatExt(format), true, obs_data_get_string(settings, "filename_formatting"));
396396
snprintf(path, 512, "%s/%s", obs_data_get_string(settings, "path"), filename);
397397
bfree(filename);
398398
ensure_directory(path);
@@ -438,23 +438,39 @@ static void start_stream_output(struct source_record_filter_context *filter, obs
438438
}
439439
obs_service_apply_encoder_settings(filter->service, settings, NULL);
440440

441-
#if LIBOBS_API_VER < MAKE_SEMANTIC_VERSION(29, 0, 2)
442-
const char *type = obs_service_get_output_type(filter->service);
443-
#else
444-
const char *type = obs_service_get_preferred_output_type(filter->service);
445-
#endif
446-
if (!type) {
447-
type = "rtmp_output";
448-
#if LIBOBS_API_VER < MAKE_SEMANTIC_VERSION(29, 0, 2)
449-
const char *url = obs_service_get_url(filter->service);
450-
#else
451-
const char *url = obs_service_get_connect_info(filter->service, OBS_SERVICE_CONNECT_INFO_SERVER_URL);
452-
#endif
453-
if (url != NULL && strncmp(url, FTL_PROTOCOL, strlen(FTL_PROTOCOL)) == 0) {
454-
type = "ftl_output";
455-
} else if (url != NULL && strncmp(url, RTMP_PROTOCOL, strlen(RTMP_PROTOCOL)) != 0) {
456-
type = "ffmpeg_mpegts_muxer";
441+
const char *type = NULL;
442+
void *handle = os_dlopen("obs");
443+
if (handle) {
444+
const char *(*type_func)(obs_service_t *) =
445+
(const char *(*)(obs_service_t *))os_dlsym(handle, "obs_service_get_output_type");
446+
if (!type_func)
447+
type_func = (const char *(*)(obs_service_t *))os_dlsym(handle, "obs_service_get_preferred_output_type");
448+
if (type_func) {
449+
type = type_func(filter->service);
457450
}
451+
if (!type) {
452+
const char *url = NULL;
453+
const char *(*url_func)(obs_service_t *) =
454+
(const char *(*)(obs_service_t *))os_dlsym(handle, "obs_service_get_url");
455+
if (url_func) {
456+
url = url_func(filter->service);
457+
} else {
458+
const char *(*info_func)(obs_service_t *, uint32_t) =
459+
(const char *(*)(obs_service_t *, uint32_t))os_dlsym(handle,
460+
"obs_service_get_connect_info");
461+
if (info_func)
462+
url = info_func(filter->service, 0); // OBS_SERVICE_CONNECT_INFO_SERVER_URL
463+
}
464+
type = "rtmp_output";
465+
if (url != NULL && strncmp(url, "ftl", 3) == 0) {
466+
type = "ftl_output";
467+
} else if (url != NULL && strncmp(url, "rtmp", 4) != 0) {
468+
type = "ffmpeg_mpegts_muxer";
469+
}
470+
}
471+
os_dlclose(handle);
472+
} else {
473+
type = "rtmp_output";
458474
}
459475

460476
if (!filter->streamOutput) {
@@ -809,7 +825,8 @@ static void frontend_event(enum obs_frontend_event event, void *data)
809825
context->last_frontend_event = (int)event;
810826

811827
obs_queue_task(OBS_TASK_GRAPHICS, update_task, data, false);
812-
} else if (event == OBS_FRONTEND_EVENT_EXIT || event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP) {
828+
} else if (event == OBS_FRONTEND_EVENT_EXIT || event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_CLEANUP ||
829+
event == OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN) {
813830
context->closing = true;
814831
}
815832
}

0 commit comments

Comments
 (0)