From 5e4ed49a2dbac66696972762e89be01bb8916ffe Mon Sep 17 00:00:00 2001 From: tytan652 Date: Thu, 19 Jan 2023 15:52:25 +0100 Subject: [PATCH] obs-outputs,obs-ffmpeg: Use connect infos in outputs --- plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c | 6 ++-- plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c | 38 +++++++++++++++---------- plugins/obs-ffmpeg/obs-ffmpeg-mux.c | 3 +- plugins/obs-ffmpeg/obs-ffmpeg-output.h | 3 +- plugins/obs-outputs/ftl-stream.c | 14 ++++++--- plugins/obs-outputs/rtmp-stream.c | 16 ++++++++--- 6 files changed, 53 insertions(+), 27 deletions(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c b/plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c index d8546bf26..50da30a7a 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-hls-mux.c @@ -126,8 +126,10 @@ bool ffmpeg_hls_mux_start(void *data) service = obs_output_get_service(stream->output); if (!service) return false; - path_str = obs_service_get_url(service); - stream_key = obs_service_get_key(service); + path_str = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_SERVER_URL); + stream_key = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_STREAM_KEY); dstr_copy(&stream->stream_key, stream_key); dstr_copy(&path, path_str); dstr_replace(&path, "{stream_key}", stream_key); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c index f4145c936..a59f04cca 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c @@ -349,24 +349,26 @@ static inline int connect_mpegts_url(struct ffmpeg_output *stream, bool is_rist) if (!is_rist) { SRTContext *context = (SRTContext *)uc->priv_data; context->streamid = NULL; - if (stream->ff_data.config.key != NULL) { - if (strlen(stream->ff_data.config.key)) - context->streamid = - av_strdup(stream->ff_data.config.key); + if (stream->ff_data.config.stream_id != NULL) { + if (strlen(stream->ff_data.config.stream_id)) + context->streamid = av_strdup( + stream->ff_data.config.stream_id); } context->passphrase = NULL; - if (stream->ff_data.config.password != NULL) { - if (strlen(stream->ff_data.config.password)) - context->passphrase = av_strdup( - stream->ff_data.config.password); + if (stream->ff_data.config.encrypt_passphrase != NULL) { + if (strlen(stream->ff_data.config.encrypt_passphrase)) + context->passphrase = + av_strdup(stream->ff_data.config + .encrypt_passphrase); } } else { RISTContext *context = (RISTContext *)uc->priv_data; context->secret = NULL; - if (stream->ff_data.config.key != NULL) { - if (strlen(stream->ff_data.config.key)) + if (stream->ff_data.config.encrypt_passphrase != NULL) { + if (strlen(stream->ff_data.config.encrypt_passphrase)) context->secret = - bstrdup(stream->ff_data.config.key); + bstrdup(stream->ff_data.config + .encrypt_passphrase); } context->username = NULL; if (stream->ff_data.config.username != NULL) { @@ -879,10 +881,16 @@ static bool set_config(struct ffmpeg_output *stream) service = obs_output_get_service(stream->output); if (!service) return false; - config.url = obs_service_get_url(service); - config.username = obs_service_get_username(service); - config.password = obs_service_get_password(service); - config.key = obs_service_get_key(service); + config.url = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_SERVER_URL); + config.username = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_USERNAME); + config.password = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_PASSWORD); + config.stream_id = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_STREAM_ID); + config.encrypt_passphrase = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_ENCRYPT_PASSPHRASE); config.format_name = "mpegts"; config.format_mime_type = "video/M2PT"; diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c index c202d8345..b821ada05 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c @@ -419,7 +419,8 @@ static inline bool ffmpeg_mux_start_internal(struct ffmpeg_muxer *stream, service = obs_output_get_service(stream->output); if (!service) return false; - path = obs_service_get_url(service); + path = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_SERVER_URL); stream->split_file = false; } else { diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-output.h b/plugins/obs-ffmpeg/obs-ffmpeg-output.h index 682eee30a..9bcf472f7 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-output.h +++ b/plugins/obs-ffmpeg/obs-ffmpeg-output.h @@ -39,7 +39,8 @@ struct ffmpeg_cfg { int frame_size; // audio frame size const char *username; const char *password; - const char *key; + const char *stream_id; + const char *encrypt_passphrase; }; struct ffmpeg_audio_info { diff --git a/plugins/obs-outputs/ftl-stream.c b/plugins/obs-outputs/ftl-stream.c index ef305420f..3d19b7563 100644 --- a/plugins/obs-outputs/ftl-stream.c +++ b/plugins/obs-outputs/ftl-stream.c @@ -1049,7 +1049,8 @@ static int init_connect(struct ftl_stream *stream) obs_output_get_video_encoder(stream->output); obs_data_t *video_settings = obs_encoder_get_settings(video_encoder); - ingest_url = obs_service_get_url(service); + ingest_url = obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_SERVER_URL); if (strncmp(ingest_url, FTL_URL_PROTOCOL, strlen(FTL_URL_PROTOCOL)) == 0) { dstr_copy(&stream->path, ingest_url + strlen(FTL_URL_PROTOCOL)); @@ -1057,7 +1058,8 @@ static int init_connect(struct ftl_stream *stream) dstr_copy(&stream->path, ingest_url); } - key = obs_service_get_key(service); + key = obs_service_get_connect_info(service, + OBS_SERVICE_CONNECT_INFO_STREAM_KEY); int target_bitrate = (int)obs_data_get_int(video_settings, "bitrate"); int peak_bitrate = (int)((float)target_bitrate * 1.1f); @@ -1093,8 +1095,12 @@ static int init_connect(struct ftl_stream *stream) } } - dstr_copy(&stream->username, obs_service_get_username(service)); - dstr_copy(&stream->password, obs_service_get_password(service)); + dstr_copy(&stream->username, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_USERNAME)); + dstr_copy(&stream->password, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_PASSWORD)); dstr_depad(&stream->path); stream->drop_threshold_usec = diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 6058d4f7f..0312101b7 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -1134,10 +1134,18 @@ static bool init_connect(struct rtmp_stream *stream) stream->got_first_video = false; settings = obs_output_get_settings(stream->output); - dstr_copy(&stream->path, obs_service_get_url(service)); - dstr_copy(&stream->key, obs_service_get_key(service)); - dstr_copy(&stream->username, obs_service_get_username(service)); - dstr_copy(&stream->password, obs_service_get_password(service)); + dstr_copy(&stream->path, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_SERVER_URL)); + dstr_copy(&stream->key, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_STREAM_KEY)); + dstr_copy(&stream->username, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_USERNAME)); + dstr_copy(&stream->password, + obs_service_get_connect_info( + service, OBS_SERVICE_CONNECT_INFO_PASSWORD)); dstr_depad(&stream->path); dstr_depad(&stream->key); drop_b = (int64_t)obs_data_get_int(settings, OPT_DROP_THRESHOLD);