obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

RFC 45-6: Enable more connection info in Services API

Open tytan652 opened this issue 2 years ago • 1 comments

Description

This PR is about the RFC 45.

Depends on:

  • #5104
  • #8087
  • #8088
  • #8089
  • #8090

Replace and deprecate url, key, username and password functions to replace with only one obs_service_get_connect_info().

This allow to ask the service for various connection information like:

  • Server URL (Commonly used in various protocol)
  • Stream key (Usually used with RTMP/FTL/HLS)
  • Username (Can be use with RMTP/FTL/RIST)
  • Password (Can be use with RMTP/FTL/RIST)
  • Stream ID (Can be used for SRT)
  • Encryption passphrase (Can be used for SRT/RIST)
  • It also allow third-party protocol to use custom connection infos when third-party outputs+services will be possible.

Those info type are not bound to protocol.

Adds a function that allow the service to indicate if it has all the connection info that it needs to start streaming: obs_service_can_try_to_connect.

Motivation and Context

Part of the implementation of the RFC 45 recent changes.

How Has This Been Tested?

Only tested trying to stream SRT, might need more testing.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

tytan652 avatar Jan 19 '23 16:01 tytan652

Rebased on #8090 to be able to work on top of all RFC 45 PRs.

tytan652 avatar Jan 30 '23 12:01 tytan652

Remove prefix related changes as it was done in the RFC.

tytan652 avatar Mar 12 '23 10:03 tytan652

After off-thread discussion OBS_SERVICE_CONNECT_INFO_STREAM_KEY is now an alias of OBS_SERVICE_CONNECT_INFO_STREAM_ID (and takes the value 2).

tytan652 avatar Mar 18 '23 09:03 tytan652

A crash when using custom output was reported on Discord (https://discord.com/channels/348973006581923840/374636084883095554/1087384798894501939)

	if (!codecs || IsCustomService()) {
		const char *output;
		char **output_codecs;

		obs_enum_output_types_with_protocol(QT_TO_UTF8(protocol),
						    &output, return_first_id);

		output_codecs = strlist_split(
			obs_get_output_supported_video_codecs(output), ';',
			false);

		ret = service_supports_codec((const char **)output_codecs,
					     codec);

obs_enum_output_types_with_protocol fails to find an output, so output remains uninitialized, causing a crash in obs_get_output_supported_audio_codecs. I'm not sure what the intention is here since the code clearly wants to go this path with the IsCustomService condition. Changing it to if (!codecs && !IsCustomService()) might be more correct if we want to allow all codec compatibility for custom outputs.

The same issue exists in ServiceAndACodecCompatible too, perhaps these functions could be merged to avoid logic duplication.

notr1ch avatar Mar 20 '23 15:03 notr1ch

if we want to allow all codec compatibility for custom outputs.

We don't.

tytan652 avatar Mar 20 '23 15:03 tytan652

The main problem is why no output were found.

Edit: And this is not the place to discuss about that.

tytan652 avatar Mar 20 '23 15:03 tytan652