mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-10-21 13:34:56 -04:00
UI: Select streaming output based on the protocol
This commit is contained in:
1 parent
213eb613d3
commit
ea2858705c
3 files changed
+123
-27
No files matched your search
@@ -88,6 +88,7 @@ public:
|
||||
#define SUBTITLE_TESTING TEST_STR("Subtitle.Testing")
|
||||
#define SUBTITLE_COMPLETE TEST_STR("Subtitle.Complete")
|
||||
#define TEST_BW TEST_STR("TestingBandwidth")
|
||||
#define TEST_BW_NO_OUTPUT TEST_STR("TestingBandwidth.NoOutput")
|
||||
#define TEST_BW_CONNECTING TEST_STR("TestingBandwidth.Connecting")
|
||||
#define TEST_BW_CONNECT_FAIL TEST_STR("TestingBandwidth.ConnectFailed")
|
||||
#define TEST_BW_SERVER TEST_STR("TestingBandwidth.Server")
|
||||
@@ -155,6 +156,23 @@ static inline void string_depad_key(string &key)
|
||||
|
||||
const char *FindAudioEncoderFromCodec(const char *type);
|
||||
|
||||
static inline bool can_use_output(const char *prot, const char *output,
|
||||
const char *prot_test1,
|
||||
const char *prot_test2 = nullptr)
|
||||
{
|
||||
return (strcmp(prot, prot_test1) == 0 ||
|
||||
(prot_test2 && strcmp(prot, prot_test2) == 0)) &&
|
||||
(obs_get_output_flags(output) & OBS_OUTPUT_SERVICE) != 0;
|
||||
}
|
||||
|
||||
static bool return_first_id(void *data, const char *id)
|
||||
{
|
||||
const char **output = (const char **)data;
|
||||
|
||||
*output = id;
|
||||
return false;
|
||||
}
|
||||
|
||||
void AutoConfigTestPage::TestBandwidthThread()
|
||||
{
|
||||
bool connected = false;
|
||||
@@ -268,9 +286,37 @@ void AutoConfigTestPage::TestBandwidthThread()
|
||||
/* -----------------------------------*/
|
||||
/* create output */
|
||||
|
||||
const char *output_type = obs_service_get_output_type(service);
|
||||
if (!output_type)
|
||||
output_type = "rtmp_output";
|
||||
/* Check if the service has a preferred output type */
|
||||
const char *output_type =
|
||||
obs_service_get_preferred_output_type(service);
|
||||
if (!output_type ||
|
||||
(obs_get_output_flags(output_type) & OBS_OUTPUT_SERVICE) == 0) {
|
||||
/* Otherwise, prefer first-party output types */
|
||||
const char *protocol = obs_service_get_protocol(service);
|
||||
|
||||
if (can_use_output(protocol, "rtmp_output", "RTMP", "RTMPS")) {
|
||||
output_type = "rtmp_output";
|
||||
} else if (can_use_output(protocol, "ffmpeg_hls_muxer",
|
||||
"HLS")) {
|
||||
output_type = "ffmpeg_hls_muxer";
|
||||
} else if (can_use_output(protocol, "ffmpeg_mpegts_muxer",
|
||||
"SRT", "RIST")) {
|
||||
output_type = "ffmpeg_mpegts_muxer";
|
||||
}
|
||||
|
||||
/* If third-party protocol, use the first enumerated type */
|
||||
if (!output_type)
|
||||
obs_enum_output_types_with_protocol(
|
||||
protocol, &output_type, return_first_id);
|
||||
|
||||
/* If none, fail */
|
||||
if (!output_type) {
|
||||
QMetaObject::invokeMethod(
|
||||
this, "Failure",
|
||||
Q_ARG(QString, QTStr(TEST_BW_NO_OUTPUT)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
OBSOutputAutoRelease output =
|
||||
obs_output_create(output_type, "test_stream", nullptr, nullptr);
|
||||
|
||||
Reference in new issue
Block a user