UI: Support FTL URLs for custom streaming service

Custom streaming service URLs beginning with `ftl` are handled by the
`ftl_output` plugin.
This commit is contained in:
Hayden McAfee 2020-12-06 01:54:29 -08:00 committed by Jim
parent 46118470ab
commit 96ef45cef5
2 changed files with 20 additions and 4 deletions

View File

@ -16,6 +16,7 @@ volatile bool recording_paused = false;
volatile bool replaybuf_active = false; volatile bool replaybuf_active = false;
volatile bool virtualcam_active = false; volatile bool virtualcam_active = false;
#define FTL_PROTOCOL "ftl"
#define RTMP_PROTOCOL "rtmp" #define RTMP_PROTOCOL "rtmp"
static void OBSStreamStarting(void *data, calldata_t *params) static void OBSStreamStarting(void *data, calldata_t *params)
@ -763,7 +764,10 @@ bool SimpleOutput::SetupStreaming(obs_service_t *service)
type = "rtmp_output"; type = "rtmp_output";
const char *url = obs_service_get_url(service); const char *url = obs_service_get_url(service);
if (url != NULL && if (url != NULL &&
strncmp(url, RTMP_PROTOCOL, strlen(RTMP_PROTOCOL)) != 0) { strncmp(url, FTL_PROTOCOL, strlen(FTL_PROTOCOL)) == 0) {
type = "ftl_output";
} else if (url != NULL && strncmp(url, RTMP_PROTOCOL,
strlen(RTMP_PROTOCOL)) != 0) {
type = "ffmpeg_mpegts_muxer"; type = "ffmpeg_mpegts_muxer";
} }
} }
@ -1684,7 +1688,10 @@ bool AdvancedOutput::SetupStreaming(obs_service_t *service)
type = "rtmp_output"; type = "rtmp_output";
const char *url = obs_service_get_url(service); const char *url = obs_service_get_url(service);
if (url != NULL && if (url != NULL &&
strncmp(url, RTMP_PROTOCOL, strlen(RTMP_PROTOCOL)) != 0) { strncmp(url, FTL_PROTOCOL, strlen(FTL_PROTOCOL)) == 0) {
type = "ftl_output";
} else if (url != NULL && strncmp(url, RTMP_PROTOCOL,
strlen(RTMP_PROTOCOL)) != 0) {
type = "ffmpeg_mpegts_muxer"; type = "ffmpeg_mpegts_muxer";
} }
} }

View File

@ -45,6 +45,8 @@
#define OPT_MAX_SHUTDOWN_TIME_SEC "max_shutdown_time_sec" #define OPT_MAX_SHUTDOWN_TIME_SEC "max_shutdown_time_sec"
#define OPT_BIND_IP "bind_ip" #define OPT_BIND_IP "bind_ip"
#define FTL_URL_PROTOCOL "ftl://"
typedef struct _nalu_t { typedef struct _nalu_t {
int len; int len;
int dts_usec; int dts_usec;
@ -1020,7 +1022,7 @@ static int init_connect(struct ftl_stream *stream)
{ {
obs_service_t *service; obs_service_t *service;
obs_data_t *settings; obs_data_t *settings;
const char *bind_ip, *key; const char *bind_ip, *key, *ingest_url;
ftl_status_t status_code; ftl_status_t status_code;
info("init_connect"); info("init_connect");
@ -1046,7 +1048,14 @@ static int init_connect(struct ftl_stream *stream)
obs_output_get_video_encoder(stream->output); obs_output_get_video_encoder(stream->output);
obs_data_t *video_settings = obs_encoder_get_settings(video_encoder); obs_data_t *video_settings = obs_encoder_get_settings(video_encoder);
dstr_copy(&stream->path, obs_service_get_url(service)); ingest_url = obs_service_get_url(service);
if (strncmp(ingest_url, FTL_URL_PROTOCOL, strlen(FTL_URL_PROTOCOL)) ==
0) {
dstr_copy(&stream->path, ingest_url + strlen(FTL_URL_PROTOCOL));
} else {
dstr_copy(&stream->path, ingest_url);
}
key = obs_service_get_key(service); key = obs_service_get_key(service);
int target_bitrate = (int)obs_data_get_int(video_settings, "bitrate"); int target_bitrate = (int)obs_data_get_int(video_settings, "bitrate");