提交 b5f1bbdd 编写于 作者: J jp9000

rtmp-services: Add format_version to services.json

The entire services file had to be restructured, but this allows us to
be able to change the format of the json file safely (if ever needed).
上级 d3eaeda2
......@@ -7,6 +7,9 @@ set(rtmp-services_SOURCES
rtmp-custom.c
rtmp-services-main.c)
set(rtmp-services_HEADERS
rtmp-format-ver.h)
set(RTMP_SERVICES_URL
"https://obsproject.com/obs2_update/rtmp-services"
CACHE STRING "Default services package URL")
......@@ -20,6 +23,7 @@ set(rtmp-services_config_HEADERS
add_library(rtmp-services MODULE
${rtmp-services_SOURCES}
${rtmp-services_HEADERS}
${rtmp-services_config_HEADERS})
target_link_libraries(rtmp-services
libobs
......
......@@ -2,6 +2,8 @@
#include <obs-module.h>
#include <jansson.h>
#include "rtmp-format-ver.h"
struct rtmp_common {
char *service;
char *server;
......@@ -129,6 +131,8 @@ static json_t *open_json_file(const char *file)
char *file_data = os_quick_read_utf8_file(file);
json_error_t error;
json_t *root;
json_t *list;
int format_ver;
if (!file_data)
return NULL;
......@@ -143,7 +147,28 @@ static json_t *open_json_file(const char *file)
return NULL;
}
return root;
format_ver = get_int_val(root, "format_version");
if (format_ver != RTMP_SERVICES_FORMAT_VERSION) {
blog(LOG_WARNING, "rtmp-common.c: [open_json_file] "
"Wrong format version (%d), expected %d",
format_ver, RTMP_SERVICES_FORMAT_VERSION);
json_decref(root);
return NULL;
}
list = json_object_get(root, "services");
if (list)
json_incref(list);
json_decref(root);
if (!list) {
blog(LOG_WARNING, "rtmp-common.c: [open_json_file] "
"No services list");
return NULL;
}
return list;
}
static void build_service_list(obs_property_t *list, json_t *root,
......
#pragma once
#define RTMP_SERVICES_FORMAT_VERSION 1
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册