void OAuth::SaveInternal() { OBSBasic *main = OBSBasic::Get(); config_set_string(main->Config(), service(), "RefreshToken", refresh_token.c_str()); config_set_string(main->Config(), service(), "Token", token.c_str()); config_set_uint(main->Config(), service(), "ExpireTime", expire_time); config_set_int(main->Config(), service(), "ScopeVer", currentScopeVer); }
void MixerAuth::SaveInternal() { OBSBasic *main = OBSBasic::Get(); config_set_string(main->Config(), service(), "Name", name.c_str()); config_set_string(main->Config(), service(), "Id", id.c_str()); if (uiLoaded) { config_set_string(main->Config(), service(), "DockState", main->saveState().toBase64().constData()); } OAuthStreamKey::SaveInternal(); }
bool OAuth::LoadInternal() { OBSBasic *main = OBSBasic::Get(); refresh_token = get_config_str(main, service(), "RefreshToken"); token = get_config_str(main, service(), "Token"); expire_time = config_get_uint(main->Config(), service(), "ExpireTime"); currentScopeVer = (int)config_get_int(main->Config(), service(), "ScopeVer"); return implicit ? !token.empty() : !refresh_token.empty(); }
void AutoConfig::SaveSettings() { OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); if (recordingEncoder != Encoder::Stream) config_set_string(main->Config(), "SimpleOutput", "RecEncoder", GetEncoderId(recordingEncoder)); const char *quality = recordingQuality == Quality::High ? "Small" : "Stream"; config_set_string(main->Config(), "Output", "Mode", "Simple"); config_set_string(main->Config(), "SimpleOutput", "RecQuality", quality); config_set_int(main->Config(), "Video", "BaseCX", baseResolutionCX); config_set_int(main->Config(), "Video", "BaseCY", baseResolutionCY); config_set_int(main->Config(), "Video", "OutputCX", idealResolutionCX); config_set_int(main->Config(), "Video", "OutputCY", idealResolutionCY); if (fpsType != FPSType::UseCurrent) { config_set_uint(main->Config(), "Video", "FPSType", 0); config_set_string(main->Config(), "Video", "FPSCommon", std::to_string(idealFPSNum).c_str()); } main->ResetVideo(); main->ResetOutputs(); config_save_safe(main->Config(), "tmp", nullptr); }
void AutoConfig::SaveStreamSettings() { OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); /* ---------------------------------- */ /* save service */ const char *service_id = customServer ? "rtmp_custom" : "rtmp_common"; obs_service_t *oldService = main->GetService(); OBSData hotkeyData = obs_hotkeys_save_service(oldService); obs_data_release(hotkeyData); OBSData settings = obs_data_create(); obs_data_release(settings); if (!customServer) obs_data_set_string(settings, "service", serviceName.c_str()); obs_data_set_string(settings, "server", server.c_str()); obs_data_set_string(settings, "key", key.c_str()); OBSService newService = obs_service_create(service_id, "default_service", settings, hotkeyData); obs_service_release(newService); if (!newService) return; main->SetService(newService); main->SaveService(); main->auth = streamPage->auth; if (!!main->auth) main->auth->LoadUI(); /* ---------------------------------- */ /* save stream settings */ config_set_int(main->Config(), "SimpleOutput", "VBitrate", idealBitrate); config_set_string(main->Config(), "SimpleOutput", "StreamEncoder", GetEncoderId(streamingEncoder)); config_remove_value(main->Config(), "SimpleOutput", "UseAdvanced"); }
void MixerAuth::LoadUI() { if (!cef) return; if (uiLoaded) return; if (!GetChannelInfo()) return; OBSBasic::InitBrowserPanelSafeBlock(); OBSBasic *main = OBSBasic::Get(); std::string url; url += "https://mixer.com/embed/chat/"; url += id; QSize size = main->frameSize(); QPoint pos = main->pos(); chat.reset(new MixerChat()); chat->setObjectName("mixerChat"); chat->resize(300, 600); chat->setMinimumSize(200, 300); chat->setWindowTitle(QTStr("Auth.Chat")); chat->setAllowedAreas(Qt::AllDockWidgetAreas); QCefWidget *browser = cef->create_widget(nullptr, url, panel_cookies); chat->setWidget(browser); main->addDockWidget(Qt::RightDockWidgetArea, chat.data()); chatMenu.reset(main->AddDockWidget(chat.data())); /* ----------------------------------- */ chat->setFloating(true); chat->move(pos.x() + size.width() - chat->width() - 50, pos.y() + 50); if (firstLoad) { chat->setVisible(true); } else { const char *dockStateStr = config_get_string(main->Config(), service(), "DockState"); QByteArray dockState = QByteArray::fromBase64(QByteArray(dockStateStr)); main->restoreState(dockState); } uiLoaded = true; }
OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_) : source(source_) { QHBoxLayout *hlayout; signal_handler_t *handler = obs_source_get_signal_handler(source); const char *sourceName = obs_source_get_name(source); float vol = obs_source_get_volume(source); uint32_t flags = obs_source_get_flags(source); uint32_t mixers = obs_source_get_audio_mixers(source); forceMonoContainer = new QWidget(); mixerContainer = new QWidget(); balanceContainer = new QWidget(); labelL = new QLabel(); labelR = new QLabel(); nameLabel = new QLabel(); volume = new QDoubleSpinBox(); forceMono = new QCheckBox(); balance = new BalanceSlider(); #if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO monitoringType = new QComboBox(); #endif syncOffset = new QSpinBox(); mixer1 = new QCheckBox(); mixer2 = new QCheckBox(); mixer3 = new QCheckBox(); mixer4 = new QCheckBox(); mixer5 = new QCheckBox(); mixer6 = new QCheckBox(); volChangedSignal.Connect(handler, "volume", OBSSourceVolumeChanged, this); syncOffsetSignal.Connect(handler, "audio_sync", OBSSourceSyncChanged, this); flagsSignal.Connect(handler, "update_flags", OBSSourceFlagsChanged, this); mixersSignal.Connect(handler, "audio_mixers", OBSSourceMixersChanged, this); hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); forceMonoContainer->setLayout(hlayout); hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); mixerContainer->setLayout(hlayout); hlayout = new QHBoxLayout(); hlayout->setContentsMargins(0, 0, 0, 0); balanceContainer->setLayout(hlayout); balanceContainer->setMinimumWidth(100); labelL->setText("L"); labelR->setText("R"); nameLabel->setMinimumWidth(170); nameLabel->setText(QT_UTF8(sourceName)); nameLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); volume->setMinimum(MIN_DB - 0.1); volume->setMaximum(MAX_DB); volume->setSingleStep(0.1); volume->setDecimals(1); volume->setSuffix(" dB"); volume->setValue(obs_mul_to_db(vol)); if (volume->value() < MIN_DB) volume->setSpecialValueText("-inf dB"); forceMono->setChecked((flags & OBS_SOURCE_FLAG_FORCE_MONO) != 0); forceMonoContainer->layout()->addWidget(forceMono); forceMonoContainer->layout()->setAlignment(forceMono, Qt::AlignHCenter | Qt::AlignVCenter); balance->setOrientation(Qt::Horizontal); balance->setMinimum(0); balance->setMaximum(100); balance->setTickPosition(QSlider::TicksAbove); balance->setTickInterval(50); OBSBasic *main = reinterpret_cast<OBSBasic*>(App()->GetMainWindow()); const char *speakers = config_get_string(main->Config(), "Audio", "ChannelSetup"); if (strcmp(speakers, "Mono") == 0) balance->setEnabled(false); else balance->setEnabled(true); float bal = obs_source_get_balance_value(source) * 100.0f; balance->setValue((int)bal); int64_t cur_sync = obs_source_get_sync_offset(source); syncOffset->setMinimum(-950); syncOffset->setMaximum(20000); syncOffset->setValue(int(cur_sync / NSEC_PER_MSEC)); int idx; #if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO monitoringType->addItem(QTStr("Basic.AdvAudio.Monitoring.None"), (int)OBS_MONITORING_TYPE_NONE); monitoringType->addItem(QTStr("Basic.AdvAudio.Monitoring.MonitorOnly"), (int)OBS_MONITORING_TYPE_MONITOR_ONLY); monitoringType->addItem(QTStr("Basic.AdvAudio.Monitoring.Both"), (int)OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT); int mt = (int)obs_source_get_monitoring_type(source); idx = monitoringType->findData(mt); monitoringType->setCurrentIndex(idx); #endif mixer1->setText("1"); mixer1->setChecked(mixers & (1<<0)); mixer2->setText("2"); mixer2->setChecked(mixers & (1<<1)); mixer3->setText("3"); mixer3->setChecked(mixers & (1<<2)); mixer4->setText("4"); mixer4->setChecked(mixers & (1<<3)); mixer5->setText("5"); mixer5->setChecked(mixers & (1<<4)); mixer6->setText("6"); mixer6->setChecked(mixers & (1<<5)); speaker_layout sl = obs_source_get_speaker_layout(source); if (sl == SPEAKERS_STEREO) { balanceContainer->layout()->addWidget(labelL); balanceContainer->layout()->addWidget(balance); balanceContainer->layout()->addWidget(labelR); balanceContainer->setMaximumWidth(170); } mixerContainer->layout()->addWidget(mixer1); mixerContainer->layout()->addWidget(mixer2); mixerContainer->layout()->addWidget(mixer3); mixerContainer->layout()->addWidget(mixer4); mixerContainer->layout()->addWidget(mixer5); mixerContainer->layout()->addWidget(mixer6); QWidget::connect(volume, SIGNAL(valueChanged(double)), this, SLOT(volumeChanged(double))); QWidget::connect(forceMono, SIGNAL(clicked(bool)), this, SLOT(downmixMonoChanged(bool))); QWidget::connect(balance, SIGNAL(valueChanged(int)), this, SLOT(balanceChanged(int))); QWidget::connect(balance, SIGNAL(doubleClicked()), this, SLOT(ResetBalance())); QWidget::connect(syncOffset, SIGNAL(valueChanged(int)), this, SLOT(syncOffsetChanged(int))); #if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO QWidget::connect(monitoringType, SIGNAL(currentIndexChanged(int)), this, SLOT(monitoringTypeChanged(int))); #endif QWidget::connect(mixer1, SIGNAL(clicked(bool)), this, SLOT(mixer1Changed(bool))); QWidget::connect(mixer2, SIGNAL(clicked(bool)), this, SLOT(mixer2Changed(bool))); QWidget::connect(mixer3, SIGNAL(clicked(bool)), this, SLOT(mixer3Changed(bool))); QWidget::connect(mixer4, SIGNAL(clicked(bool)), this, SLOT(mixer4Changed(bool))); QWidget::connect(mixer5, SIGNAL(clicked(bool)), this, SLOT(mixer5Changed(bool))); QWidget::connect(mixer6, SIGNAL(clicked(bool)), this, SLOT(mixer6Changed(bool))); setObjectName(sourceName); }
AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent) { EnableThreadedMessageBoxes(true); calldata_t cd = {0}; calldata_set_int(&cd, "seconds", 5); proc_handler_t *ph = obs_get_proc_handler(); proc_handler_call(ph, "twitch_ingests_refresh", &cd); calldata_free(&cd); OBSBasic *main = reinterpret_cast<OBSBasic*>(parent); main->EnableOutputs(false); installEventFilter(CreateShortcutFilter()); std::string serviceType; GetServiceInfo(serviceType, serviceName, server, key); #ifdef _WIN32 setWizardStyle(QWizard::ModernStyle); #endif streamPage = new AutoConfigStreamPage(); setPage(StartPage, new AutoConfigStartPage()); setPage(VideoPage, new AutoConfigVideoPage()); setPage(StreamPage, streamPage); setPage(TestPage, new AutoConfigTestPage()); setWindowTitle(QTStr("Basic.AutoConfig")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); obs_video_info ovi; obs_get_video_info(&ovi); baseResolutionCX = ovi.base_width; baseResolutionCY = ovi.base_height; /* ----------------------------------------- */ /* check to see if Twitch's "auto" available */ OBSData twitchSettings = obs_data_create(); obs_data_release(twitchSettings); obs_data_set_string(twitchSettings, "service", "Twitch"); obs_properties_t *props = obs_get_service_properties("rtmp_common"); obs_properties_apply_settings(props, twitchSettings); obs_property_t *p = obs_properties_get(props, "server"); const char *first = obs_property_list_item_string(p, 0); twitchAuto = strcmp(first, "auto") == 0; obs_properties_destroy(props); /* ----------------------------------------- */ /* load service/servers */ customServer = serviceType == "rtmp_custom"; QComboBox *serviceList = streamPage->ui->service; if (!serviceName.empty()) { serviceList->blockSignals(true); int count = serviceList->count(); bool found = false; for (int i = 0; i < count; i++) { QString name = serviceList->itemText(i); if (name == serviceName.c_str()) { serviceList->setCurrentIndex(i); found = true; break; } } if (!found) { serviceList->insertItem(0, serviceName.c_str()); serviceList->setCurrentIndex(0); } serviceList->blockSignals(false); } streamPage->UpdateServerList(); streamPage->UpdateKeyLink(); streamPage->lastService.clear(); if (!customServer) { QComboBox *serverList = streamPage->ui->server; int idx = serverList->findData(QString(server.c_str())); if (idx == -1) idx = 0; serverList->setCurrentIndex(idx); } else { streamPage->ui->customServer->setText(server.c_str()); int idx = streamPage->ui->service->findData( QVariant((int)ListOpt::Custom)); streamPage->ui->service->setCurrentIndex(idx); } if (!key.empty()) streamPage->ui->key->setText(key.c_str()); int bitrate = config_get_int(main->Config(), "SimpleOutput", "VBitrate"); streamPage->ui->bitrate->setValue(bitrate); streamPage->ServiceChanged(); TestHardwareEncoding(); if (!hardwareEncodingAvailable) { delete streamPage->ui->preferHardware; streamPage->ui->preferHardware = nullptr; } else { /* Newer generations of NVENC have a high enough quality to * bitrate ratio that if NVENC is available, it makes sense to * just always prefer hardware encoding by default */ bool preferHardware = nvencAvailable || os_get_physical_cores() <= 4; streamPage->ui->preferHardware->setChecked(preferHardware); } setOptions(0); setButtonText(QWizard::FinishButton, QTStr("Basic.AutoConfig.ApplySettings")); setButtonText(QWizard::BackButton, QTStr("Back")); setButtonText(QWizard::NextButton, QTStr("Next")); setButtonText(QWizard::CancelButton, QTStr("Cancel")); }