mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-24 23:31:36 +08:00
UI: Add eRTMP Multitrack Video Output
This commit is contained in:
+98
-52
@@ -1615,6 +1615,13 @@ bool OBSBasic::InitBasicConfigDefaults()
|
||||
|
||||
config_set_default_bool(basicConfig, "Stream1", "IgnoreRecommended",
|
||||
false);
|
||||
config_set_default_bool(basicConfig, "Stream1", "EnableMultitrackVideo",
|
||||
true);
|
||||
config_set_default_bool(basicConfig, "Stream1",
|
||||
"MultitrackVideoMaximumAggregateBitrateAuto",
|
||||
true);
|
||||
config_set_default_bool(basicConfig, "Stream1",
|
||||
"MultitrackVideoMaximumVideoTracksAuto", true);
|
||||
|
||||
config_set_default_string(basicConfig, "SimpleOutput", "FilePath",
|
||||
GetDefaultVideoSavePath().c_str());
|
||||
@@ -1953,7 +1960,8 @@ void OBSBasic::ResetOutputs()
|
||||
const char *mode = config_get_string(basicConfig, "Output", "Mode");
|
||||
bool advOut = astrcmpi(mode, "Advanced") == 0;
|
||||
|
||||
if (!outputHandler || !outputHandler->Active()) {
|
||||
if ((!outputHandler || !outputHandler->Active()) &&
|
||||
startStreamingFuture.future.isFinished()) {
|
||||
outputHandler.reset();
|
||||
outputHandler.reset(advOut ? CreateAdvancedOutputHandler(this)
|
||||
: CreateSimpleOutputHandler(this));
|
||||
@@ -5097,6 +5105,22 @@ void OBSBasic::ClearSceneData()
|
||||
|
||||
void OBSBasic::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if (!startStreamingFuture.future.isFinished() &&
|
||||
!startStreamingFuture.future.isCanceled()) {
|
||||
startStreamingFuture.future.onCanceled(
|
||||
this, [basic = QPointer{this}] {
|
||||
if (basic)
|
||||
basic->close();
|
||||
});
|
||||
startStreamingFuture.cancelAll();
|
||||
event->ignore();
|
||||
return;
|
||||
} else if (startStreamingFuture.future.isCanceled() &&
|
||||
!startStreamingFuture.future.isFinished()) {
|
||||
event->ignore();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Do not close window if inside of a temporary event loop because we
|
||||
* could be inside of an Auth::LoadUI call. Keep trying once per
|
||||
* second until we've exit any known sub-loops. */
|
||||
@@ -7016,68 +7040,88 @@ void OBSBasic::StartStreaming()
|
||||
}
|
||||
}
|
||||
|
||||
if (!outputHandler->SetupStreaming(service)) {
|
||||
DisplayStreamStartError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (api)
|
||||
api->on_event(OBS_FRONTEND_EVENT_STREAMING_STARTING);
|
||||
|
||||
SaveProject();
|
||||
auto setStreamText = [&](const QString &text) {
|
||||
ui->streamButton->setText(text);
|
||||
if (sysTrayStream)
|
||||
sysTrayStream->setText(text);
|
||||
};
|
||||
|
||||
ui->streamButton->setEnabled(false);
|
||||
ui->streamButton->setChecked(false);
|
||||
ui->streamButton->setText(QTStr("Basic.Main.Connecting"));
|
||||
ui->broadcastButton->setChecked(false);
|
||||
|
||||
if (sysTrayStream) {
|
||||
if (sysTrayStream)
|
||||
sysTrayStream->setEnabled(false);
|
||||
sysTrayStream->setText(ui->streamButton->text());
|
||||
}
|
||||
|
||||
if (!outputHandler->StartStreaming(service)) {
|
||||
DisplayStreamStartError();
|
||||
return;
|
||||
}
|
||||
setStreamText(QTStr("Basic.Main.PreparingStream"));
|
||||
|
||||
if (!autoStartBroadcast) {
|
||||
ui->broadcastButton->setText(
|
||||
QTStr("Basic.Main.StartBroadcast"));
|
||||
ui->broadcastButton->setProperty("broadcastState", "ready");
|
||||
ui->broadcastButton->style()->unpolish(ui->broadcastButton);
|
||||
ui->broadcastButton->style()->polish(ui->broadcastButton);
|
||||
// well, we need to disable button while stream is not active
|
||||
ui->broadcastButton->setEnabled(false);
|
||||
} else {
|
||||
if (!autoStopBroadcast) {
|
||||
ui->broadcastButton->setText(
|
||||
QTStr("Basic.Main.StopBroadcast"));
|
||||
} else {
|
||||
ui->broadcastButton->setText(
|
||||
QTStr("Basic.Main.AutoStopEnabled"));
|
||||
ui->broadcastButton->setEnabled(false);
|
||||
}
|
||||
ui->broadcastButton->setProperty("broadcastState", "active");
|
||||
ui->broadcastButton->style()->unpolish(ui->broadcastButton);
|
||||
ui->broadcastButton->style()->polish(ui->broadcastButton);
|
||||
broadcastActive = true;
|
||||
}
|
||||
auto holder = outputHandler->SetupStreaming(service);
|
||||
auto future = holder.future.then(
|
||||
this, [&, setStreamText](bool setupStreamingResult) {
|
||||
if (!setupStreamingResult) {
|
||||
DisplayStreamStartError();
|
||||
return;
|
||||
}
|
||||
|
||||
bool recordWhenStreaming = config_get_bool(
|
||||
GetGlobalConfig(), "BasicWindow", "RecordWhenStreaming");
|
||||
if (recordWhenStreaming)
|
||||
StartRecording();
|
||||
if (api)
|
||||
api->on_event(
|
||||
OBS_FRONTEND_EVENT_STREAMING_STARTING);
|
||||
|
||||
bool replayBufferWhileStreaming = config_get_bool(
|
||||
GetGlobalConfig(), "BasicWindow", "ReplayBufferWhileStreaming");
|
||||
if (replayBufferWhileStreaming)
|
||||
StartReplayBuffer();
|
||||
SaveProject();
|
||||
|
||||
setStreamText(QTStr("Basic.Main.Connecting"));
|
||||
|
||||
if (!outputHandler->StartStreaming(service)) {
|
||||
DisplayStreamStartError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!autoStartBroadcast) {
|
||||
ui->broadcastButton->setText(
|
||||
QTStr("Basic.Main.StartBroadcast"));
|
||||
ui->broadcastButton->setProperty(
|
||||
"broadcastState", "ready");
|
||||
ui->broadcastButton->style()->unpolish(
|
||||
ui->broadcastButton);
|
||||
ui->broadcastButton->style()->polish(
|
||||
ui->broadcastButton);
|
||||
// well, we need to disable button while stream is not active
|
||||
ui->broadcastButton->setEnabled(false);
|
||||
} else {
|
||||
if (!autoStopBroadcast) {
|
||||
ui->broadcastButton->setText(QTStr(
|
||||
"Basic.Main.StopBroadcast"));
|
||||
} else {
|
||||
ui->broadcastButton->setText(QTStr(
|
||||
"Basic.Main.AutoStopEnabled"));
|
||||
ui->broadcastButton->setEnabled(false);
|
||||
}
|
||||
ui->broadcastButton->setProperty(
|
||||
"broadcastState", "active");
|
||||
ui->broadcastButton->style()->unpolish(
|
||||
ui->broadcastButton);
|
||||
ui->broadcastButton->style()->polish(
|
||||
ui->broadcastButton);
|
||||
broadcastActive = true;
|
||||
}
|
||||
|
||||
bool recordWhenStreaming = config_get_bool(
|
||||
GetGlobalConfig(), "BasicWindow",
|
||||
"RecordWhenStreaming");
|
||||
if (recordWhenStreaming)
|
||||
StartRecording();
|
||||
|
||||
bool replayBufferWhileStreaming = config_get_bool(
|
||||
GetGlobalConfig(), "BasicWindow",
|
||||
"ReplayBufferWhileStreaming");
|
||||
if (replayBufferWhileStreaming)
|
||||
StartReplayBuffer();
|
||||
|
||||
#ifdef YOUTUBE_ENABLED
|
||||
if (!autoStartBroadcast)
|
||||
OBSBasic::ShowYouTubeAutoStartWarning();
|
||||
if (!autoStartBroadcast)
|
||||
OBSBasic::ShowYouTubeAutoStartWarning();
|
||||
#endif
|
||||
});
|
||||
startStreamingFuture = {holder.cancelAll, future};
|
||||
}
|
||||
|
||||
void OBSBasic::BroadcastButtonClicked()
|
||||
@@ -7447,10 +7491,12 @@ void OBSBasic::StreamDelayStopping(int sec)
|
||||
|
||||
void OBSBasic::StreamingStart()
|
||||
{
|
||||
OBSOutputAutoRelease output = obs_frontend_get_streaming_output();
|
||||
|
||||
ui->streamButton->setText(QTStr("Basic.Main.StopStreaming"));
|
||||
ui->streamButton->setEnabled(true);
|
||||
ui->streamButton->setChecked(true);
|
||||
ui->statusbar->StreamStarted(outputHandler->streamOutput);
|
||||
ui->statusbar->StreamStarted(output);
|
||||
|
||||
if (sysTrayStream) {
|
||||
sysTrayStream->setText(ui->streamButton->text());
|
||||
|
||||
Reference in New Issue
Block a user