|
@@ -16,8 +16,8 @@ struct rtmp_common {
|
|
|
char *key;
|
|
|
|
|
|
char *output;
|
|
|
- int max_cx;
|
|
|
- int max_cy;
|
|
|
+ struct obs_service_resolution *supported_resolutions;
|
|
|
+ size_t supported_resolutions_count;
|
|
|
int max_fps;
|
|
|
|
|
|
bool supports_additional_audio_track;
|
|
@@ -77,8 +77,34 @@ static void update_recommendations(struct rtmp_common *service, json_t *rec)
|
|
|
if (out)
|
|
|
service->output = bstrdup(out);
|
|
|
|
|
|
- service->max_cx = get_int_val(rec, "max width");
|
|
|
- service->max_cy = get_int_val(rec, "max height");
|
|
|
+ json_t *sr = json_object_get(rec, "supported resolutions");
|
|
|
+ if (sr && json_is_array(sr)) {
|
|
|
+ DARRAY(struct obs_service_resolution) res_list;
|
|
|
+ json_t *res_obj;
|
|
|
+ size_t index;
|
|
|
+
|
|
|
+ da_init(res_list);
|
|
|
+
|
|
|
+ json_array_foreach (sr, index, res_obj) {
|
|
|
+ if (!json_is_string(res_obj))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ const char *res_str = json_string_value(res_obj);
|
|
|
+ struct obs_service_resolution res;
|
|
|
+ if (sscanf(res_str, "%dx%d", &res.cx, &res.cy) != 2)
|
|
|
+ continue;
|
|
|
+ if (res.cx <= 0 || res.cy <= 0)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ da_push_back(res_list, &res);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (res_list.num) {
|
|
|
+ service->supported_resolutions = res_list.array;
|
|
|
+ service->supported_resolutions_count = res_list.num;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
service->max_fps = get_int_val(rec, "max fps");
|
|
|
}
|
|
|
|
|
@@ -90,14 +116,15 @@ static void rtmp_common_update(void *data, obs_data_t *settings)
|
|
|
bfree(service->server);
|
|
|
bfree(service->output);
|
|
|
bfree(service->key);
|
|
|
+ bfree(service->supported_resolutions);
|
|
|
|
|
|
service->service = bstrdup(obs_data_get_string(settings, "service"));
|
|
|
service->server = bstrdup(obs_data_get_string(settings, "server"));
|
|
|
service->key = bstrdup(obs_data_get_string(settings, "key"));
|
|
|
service->supports_additional_audio_track = false;
|
|
|
service->output = NULL;
|
|
|
- service->max_cx = 0;
|
|
|
- service->max_cy = 0;
|
|
|
+ service->supported_resolutions = NULL;
|
|
|
+ service->supported_resolutions_count = 0;
|
|
|
service->max_fps = 0;
|
|
|
|
|
|
json_t *root = open_services_file();
|
|
@@ -131,6 +158,7 @@ static void rtmp_common_destroy(void *data)
|
|
|
{
|
|
|
struct rtmp_common *service = data;
|
|
|
|
|
|
+ bfree(service->supported_resolutions);
|
|
|
bfree(service->service);
|
|
|
bfree(service->server);
|
|
|
bfree(service->output);
|
|
@@ -679,15 +707,19 @@ static bool supports_multitrack(void *data)
|
|
|
return service->supports_additional_audio_track;
|
|
|
}
|
|
|
|
|
|
-static void rtmp_common_get_max_res_fps(void *data, int *cx, int *cy, int *fps)
|
|
|
+static void rtmp_common_get_supported_resolutions(
|
|
|
+ void *data, struct obs_service_resolution **resolutions, size_t *count)
|
|
|
+{
|
|
|
+ struct rtmp_common *service = data;
|
|
|
+ *count = service->supported_resolutions_count;
|
|
|
+ *resolutions = bmemdup(service->supported_resolutions,
|
|
|
+ *count * sizeof(struct obs_service_resolution));
|
|
|
+}
|
|
|
+
|
|
|
+static void rtmp_common_get_max_fps(void *data, int *fps)
|
|
|
{
|
|
|
struct rtmp_common *service = data;
|
|
|
- if (cx)
|
|
|
- *cx = service->max_cx;
|
|
|
- if (cy)
|
|
|
- *cy = service->max_cy;
|
|
|
- if (fps)
|
|
|
- *fps = service->max_fps;
|
|
|
+ *fps = service->max_fps;
|
|
|
}
|
|
|
|
|
|
static void rtmp_common_get_max_bitrate(void *data, int *video_bitrate,
|
|
@@ -737,6 +769,7 @@ struct obs_service_info rtmp_common_service = {
|
|
|
.get_key = rtmp_common_key,
|
|
|
.apply_encoder_settings = rtmp_common_apply_settings,
|
|
|
.get_output_type = rtmp_common_get_output_type,
|
|
|
- .get_max_res_fps = rtmp_common_get_max_res_fps,
|
|
|
+ .get_supported_resolutions = rtmp_common_get_supported_resolutions,
|
|
|
+ .get_max_fps = rtmp_common_get_max_fps,
|
|
|
.get_max_bitrate = rtmp_common_get_max_bitrate,
|
|
|
};
|