Browse Source

obs-outputs,obs-ffmpeg: Use connect infos in outputs

tytan652 2 years ago
parent
commit
5e4ed49a2d

+ 4 - 2
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);

+ 23 - 15
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";
 

+ 2 - 1
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 {
 

+ 2 - 1
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 {

+ 10 - 4
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 =

+ 12 - 4
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);