mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-03-04 06:36:08 -05:00
Add preliminary streaming code for testing
- Add some temporary streaming code using FFmpeg. FFmpeg itself is not very ideal for streaming; lack of direct control of the sockets and no framedrop handling means that FFmpeg is definitely not something you want to use without wrapper code. I'd prefer writing my own network framework in this particular case just because you give away so much control of the network interface. Wasted an entire day trying to go through FFmpeg issues. There's just no way FFmpeg should be used for real streaming (at least without being patched or submitting some sort of patch, but I'm sort of feeling "meh" on that idea) I had to end up writing multiple threads just to handle both connecting and writing, because av_interleaved_write_frame blocks every call, stalling the main encoder thread, and thus also stalling draw signals. - Add some temporary user interface for streaming settings. This is just temporary for the time being. It's in the outputs section of the basic-mode settings - Make it so that dynamic arrays do not free all their data when the size just happens to be reduced to 0. This prevents constant reallocation when an array keeps going from 1 item to 0 items. Also, it was bad to become dependent upon that functionality. You must now always explicitly call "free" on it to ensure the data is free, and that's how it should be. Implicit functionality can lead to confusion and maintainability issues.
This commit is contained in:
@@ -86,10 +86,12 @@ void OBSBasicSettings::HookWidget(QWidget *widget, const char *signal,
|
||||
|
||||
#define COMBO_CHANGED SIGNAL(currentIndexChanged(int))
|
||||
#define COMBO_CHANGED SIGNAL(currentIndexChanged(int))
|
||||
#define EDIT_CHANGED SIGNAL(textChanged(const QString &))
|
||||
#define CBEDIT_CHANGED SIGNAL(editTextChanged(const QString &))
|
||||
#define SCROLL_CHANGED SIGNAL(valueChanged(int))
|
||||
|
||||
#define GENERAL_CHANGED SLOT(GeneralChanged())
|
||||
#define OUTPUTS_CHANGED SLOT(OutputsChanged())
|
||||
#define AUDIO_RESTART SLOT(AudioChangedRestart())
|
||||
#define AUDIO_CHANGED SLOT(AudioChanged())
|
||||
#define VIDEO_RESTART SLOT(VideoChangedRestart())
|
||||
@@ -117,6 +119,10 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
|
||||
throw "Could not open locale.ini";
|
||||
|
||||
HookWidget(ui->language, COMBO_CHANGED, GENERAL_CHANGED);
|
||||
HookWidget(ui->streamVBitrate, SCROLL_CHANGED, OUTPUTS_CHANGED);
|
||||
HookWidget(ui->streamABitrate, SCROLL_CHANGED, OUTPUTS_CHANGED);
|
||||
HookWidget(ui->streamURL, EDIT_CHANGED, OUTPUTS_CHANGED);
|
||||
HookWidget(ui->streamKey, EDIT_CHANGED, OUTPUTS_CHANGED);
|
||||
HookWidget(ui->channelSetup, COMBO_CHANGED, AUDIO_RESTART);
|
||||
HookWidget(ui->sampleRate, COMBO_CHANGED, AUDIO_RESTART);
|
||||
HookWidget(ui->desktopAudioDevice1, COMBO_CHANGED, AUDIO_CHANGED);
|
||||
@@ -310,6 +316,27 @@ void OBSBasicSettings::LoadVideoSettings()
|
||||
loading = false;
|
||||
}
|
||||
|
||||
void OBSBasicSettings::LoadOutputSettings()
|
||||
{
|
||||
loading = true;
|
||||
|
||||
const char *url = config_get_string(main->Config(), "OutputTemp",
|
||||
"URL");
|
||||
const char *key = config_get_string(main->Config(), "OutputTemp",
|
||||
"Key");
|
||||
int videoBitrate = config_get_uint(main->Config(), "OutputTemp",
|
||||
"VBitrate");
|
||||
int audioBitrate = config_get_uint(main->Config(), "OutputTemp",
|
||||
"ABitrate");
|
||||
|
||||
ui->streamURL->setText(QT_UTF8(url));
|
||||
ui->streamKey->setText(QT_UTF8(key));
|
||||
ui->streamVBitrate->setValue(videoBitrate);
|
||||
ui->streamABitrate->setValue(audioBitrate);
|
||||
|
||||
loading = false;
|
||||
}
|
||||
|
||||
static inline void LoadListValue(QComboBox *widget, const char *text,
|
||||
const char *val)
|
||||
{
|
||||
@@ -409,8 +436,8 @@ void OBSBasicSettings::LoadSettings(bool changedOnly)
|
||||
{
|
||||
if (!changedOnly || generalChanged)
|
||||
LoadGeneralSettings();
|
||||
//if (!changedOnly || outputChanged)
|
||||
// LoadOutputSettings();
|
||||
if (!changedOnly || outputsChanged)
|
||||
LoadOutputSettings();
|
||||
if (!changedOnly || audioChanged)
|
||||
LoadAudioSettings();
|
||||
if (!changedOnly || videoChanged)
|
||||
@@ -464,6 +491,20 @@ void OBSBasicSettings::SaveVideoSettings()
|
||||
main->ResetVideo();
|
||||
}
|
||||
|
||||
/* TODO: Temporary! */
|
||||
void OBSBasicSettings::SaveOutputSettings()
|
||||
{
|
||||
int videoBitrate = ui->streamVBitrate->value();
|
||||
int audioBitrate = ui->streamABitrate->value();
|
||||
QString url = ui->streamURL->text();
|
||||
QString key = ui->streamKey->text();
|
||||
|
||||
config_set_uint(main->Config(), "OutputTemp", "VBitrate", videoBitrate);
|
||||
config_set_uint(main->Config(), "OutputTemp", "ABitrate", audioBitrate);
|
||||
config_set_string(main->Config(), "OutputTemp", "URL", QT_TO_UTF8(url));
|
||||
config_set_string(main->Config(), "OutputTemp", "Key", QT_TO_UTF8(key));
|
||||
}
|
||||
|
||||
static inline QString GetComboData(QComboBox *combo)
|
||||
{
|
||||
int idx = combo->currentIndex();
|
||||
@@ -517,8 +558,8 @@ void OBSBasicSettings::SaveSettings()
|
||||
{
|
||||
if (generalChanged)
|
||||
SaveGeneralSettings();
|
||||
//if (outputChanged)
|
||||
// SaveOutputSettings();
|
||||
if (outputsChanged)
|
||||
SaveOutputSettings();
|
||||
if (audioChanged)
|
||||
SaveAudioSettings();
|
||||
if (videoChanged)
|
||||
@@ -622,6 +663,12 @@ void OBSBasicSettings::GeneralChanged()
|
||||
generalChanged = true;
|
||||
}
|
||||
|
||||
void OBSBasicSettings::OutputsChanged()
|
||||
{
|
||||
if (!loading)
|
||||
outputsChanged = true;
|
||||
}
|
||||
|
||||
void OBSBasicSettings::AudioChanged()
|
||||
{
|
||||
if (!loading)
|
||||
|
||||
Reference in New Issue
Block a user