static bool use_auth_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings) { bool use_auth = obs_data_get_bool(settings, "use_auth"); p = obs_properties_get(ppts, "username"); obs_property_set_visible(p, use_auth); p = obs_properties_get(ppts, "password"); obs_property_set_visible(p, use_auth); return true; }
static bool is_local_file_modified(obs_properties_t *props, obs_property_t *prop, obs_data_t *settings) { UNUSED_PARAMETER(prop); bool enabled = obs_data_get_bool(settings, "is_local_file"); obs_property_t *url = obs_properties_get(props, "url"); obs_property_t *local_file = obs_properties_get(props, "local_file"); obs_property_set_visible(url, !enabled); obs_property_set_visible(local_file, enabled); return true; }
void AutoConfigStreamPage::LoadServices(bool showAll) { obs_properties_t *props = obs_get_service_properties("rtmp_common"); OBSData settings = obs_data_create(); obs_data_release(settings); obs_data_set_bool(settings, "show_all", showAll); obs_property_t *prop = obs_properties_get(props, "show_all"); obs_property_modified(prop, settings); ui->service->blockSignals(true); ui->service->clear(); QStringList names; obs_property_t *services = obs_properties_get(props, "service"); size_t services_count = obs_property_list_item_count(services); for (size_t i = 0; i < services_count; i++) { const char *name = obs_property_list_item_string(services, i); names.push_back(name); } if (showAll) names.sort(); for (QString &name : names) ui->service->addItem(name); if (!showAll) { ui->service->addItem( QTStr("Basic.AutoConfig.StreamPage.Service.ShowAll"), QVariant((int)ListOpt::ShowAll)); } ui->service->insertItem(0, QTStr("Basic.AutoConfig.StreamPage.Service.Custom"), QVariant((int)ListOpt::Custom)); if (!lastService.isEmpty()) { int idx = ui->service->findText(lastService); if (idx != -1) ui->service->setCurrentIndex(idx); } obs_properties_destroy(props); ui->service->blockSignals(false); }
static bool is_advanced_modified(obs_properties_t *props, obs_property_t *prop, obs_data_t *settings) { UNUSED_PARAMETER(prop); bool enabled = obs_data_get_bool(settings, "advanced"); obs_property_t *abuf = obs_properties_get(props, "audio_buffer_size"); obs_property_t *vbuf = obs_properties_get(props, "video_buffer_size"); obs_property_t *frame_drop = obs_properties_get(props, "frame_drop"); obs_property_set_visible(abuf, enabled); obs_property_set_visible(vbuf, enabled); obs_property_set_visible(frame_drop, enabled); return true; }
static bool sampling_modified(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { const char *sampling = obs_data_get_string(settings, S_SAMPLING); bool has_undistort; if (astrcmpi(sampling, S_SAMPLING_POINT) == 0) { has_undistort = false; } else if (astrcmpi(sampling, S_SAMPLING_BILINEAR) == 0) { has_undistort = false; } else if (astrcmpi(sampling, S_SAMPLING_LANCZOS) == 0) { has_undistort = true; } else { /* S_SAMPLING_BICUBIC */ has_undistort = true; } obs_property_set_visible(obs_properties_get(props, S_UNDISTORT), has_undistort); UNUSED_PARAMETER(p); return true; }
/** * The x server was changed */ static bool xshm_server_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { UNUSED_PARAMETER(p); bool advanced = obs_data_get_bool(settings, "advanced"); int_fast32_t old_screen = obs_data_get_int(settings, "screen"); const char *server = obs_data_get_string(settings, "server"); obs_property_t *screens = obs_properties_get(props, "screen"); /* we want a real NULL here in case there is no string here */ server = (advanced && *server) ? server : NULL; obs_property_list_clear(screens); Display *dpy = XOpenDisplay(server); if (!dpy) { obs_property_set_enabled(screens, false); return true; } struct dstr screen_info; dstr_init(&screen_info); bool xinerama = xinerama_is_active(dpy); int_fast32_t count = (xinerama) ? xinerama_screen_count(dpy) : XScreenCount(dpy); for (int_fast32_t i = 0; i < count; ++i) { int_fast32_t x, y, w, h; x = y = w = h = 0; if (xinerama) xinerama_screen_geo(dpy, i, &x, &y, &w, &h); else x11_screen_geo(dpy, i, &w, &h); dstr_printf(&screen_info, "Screen %"PRIuFAST32" (%"PRIuFAST32 "x%"PRIuFAST32" @ %"PRIuFAST32 ",%"PRIuFAST32")", i, w, h, x, y); obs_property_list_add_int(screens, screen_info.array, i); } /* handle missing screen */ if (old_screen + 1 > count) { dstr_printf(&screen_info, "Screen %"PRIuFAST32" (not found)", old_screen); size_t index = obs_property_list_add_int(screens, screen_info.array, old_screen); obs_property_list_item_disable(screens, index, true); } dstr_free(&screen_info); XCloseDisplay(dpy); obs_property_set_enabled(screens, true); return true; }
std::vector<T> obs_properties_get_list(obs_properties_t* props, const char* name, GetFuncT GetFunc) { obs_property_t* prop = obs_properties_get(props, name); if (prop) { if (obs_property_get_type(prop) == OBS_PROPERTY_LIST) { if (obs_property_list_format(prop) == formatId) { int count = obs_property_list_item_count(prop); std::vector<T> r; r.reserve(count); for (int i = 0; i < count; ++i) { r.push_back(std::make_pair(obs_property_list_item_name(prop, i), GetFunc(prop, i))); } return std::move(r); } } } return std::vector<T>(); }
/* * Format selected callback */ static bool format_selected(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { UNUSED_PARAMETER(p); int dev = v4l2_open(obs_data_get_string(settings, "device_id"), O_RDWR | O_NONBLOCK); if (dev == -1) return false; int input = (int) obs_data_get_int(settings, "input"); uint32_t caps = 0; if (v4l2_get_input_caps(dev, input, &caps) < 0) return false; caps &= V4L2_IN_CAP_STD | V4L2_IN_CAP_DV_TIMINGS; obs_property_t *resolution = obs_properties_get(props, "resolution"); obs_property_t *framerate = obs_properties_get(props, "framerate"); obs_property_t *standard = obs_properties_get(props, "standard"); obs_property_t *dv_timing = obs_properties_get(props, "dv_timing"); obs_property_set_visible(resolution, (!caps) ? true : false); obs_property_set_visible(framerate, (!caps) ? true : false); obs_property_set_visible(standard, (caps & V4L2_IN_CAP_STD) ? true : false); obs_property_set_visible(dv_timing, (caps & V4L2_IN_CAP_DV_TIMINGS) ? true : false); if (!caps) { v4l2_resolution_list(dev, obs_data_get_int( settings, "pixelformat"), resolution); } if (caps & V4L2_IN_CAP_STD) v4l2_standard_list(dev, standard); if (caps & V4L2_IN_CAP_DV_TIMINGS) v4l2_dv_timing_list(dev, dv_timing); v4l2_close(dev); if (!caps) obs_property_modified(resolution, settings); if (caps & V4L2_IN_CAP_STD) obs_property_modified(standard, settings); if (caps & V4L2_IN_CAP_DV_TIMINGS) obs_property_modified(dv_timing, settings); return true; }
static bool use_bufsize_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings) { bool use_bufsize = obs_data_get_bool(settings, "use_bufsize"); p = obs_properties_get(ppts, "buffer_size"); obs_property_set_visible(p, use_bufsize); return true; }
static bool use_cbr_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings) { bool cbr = obs_data_get_bool(settings, "cbr"); p = obs_properties_get(ppts, "crf"); obs_property_set_visible(p, !cbr); return true; }
static bool is_local_file_modified(obs_properties_t *props, obs_property_t *prop, obs_data_t *settings) { UNUSED_PARAMETER(prop); bool enabled = obs_data_get_bool(settings, "is_local_file"); obs_property_t *input = obs_properties_get(props, "input"); obs_property_t *input_format =obs_properties_get(props, "input_format"); obs_property_t *local_file = obs_properties_get(props, "local_file"); obs_property_t *looping = obs_properties_get(props, "looping"); obs_property_set_visible(input, !enabled); obs_property_set_visible(input_format, !enabled); obs_property_set_visible(local_file, enabled); obs_property_set_visible(looping, enabled); return true; }
static bool Get(T* val, obs_properties_t* props, const char* index) { obs_property_t* prop = obs_properties_get(props, index); if (prop == 0) return false; else { *val = GetFunc(props, index); return true; } }
static bool key_type_changed(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { const char *type = obs_data_get_string(settings, SETTING_COLOR_TYPE); bool custom = strcmp(type, "custom") == 0; obs_property_set_visible(obs_properties_get(props, SETTING_KEY_COLOR), custom); UNUSED_PARAMETER(p); return true; }
static bool rate_control_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *settings) { const char *rate_control = obs_data_get_string(settings, "rate_control"); bool bVisible = astrcmpi(rate_control, "VCM") == 0 || astrcmpi(rate_control, "VBR") == 0; p = obs_properties_get(ppts, "max_bitrate"); obs_property_set_visible(p, bVisible); bVisible = astrcmpi(rate_control, "CQP") == 0 || astrcmpi(rate_control, "LA_ICQ") == 0 || astrcmpi(rate_control, "ICQ") == 0; p = obs_properties_get(ppts, "bitrate"); obs_property_set_visible(p, !bVisible); bVisible = astrcmpi(rate_control, "AVBR") == 0; p = obs_properties_get(ppts, "accuracy"); obs_property_set_visible(p, bVisible); p = obs_properties_get(ppts, "convergence"); obs_property_set_visible(p, bVisible); bVisible = astrcmpi(rate_control, "CQP") == 0; p = obs_properties_get(ppts, "qpi"); obs_property_set_visible(p, bVisible); p = obs_properties_get(ppts, "qpb"); obs_property_set_visible(p, bVisible); p = obs_properties_get(ppts, "qpp"); obs_property_set_visible(p, bVisible); bVisible = astrcmpi(rate_control, "ICQ") == 0 || astrcmpi(rate_control, "LA_ICQ") == 0; p = obs_properties_get(ppts, "icq_quality"); obs_property_set_visible(p, bVisible); bVisible = astrcmpi(rate_control, "LA_ICQ") == 0 || astrcmpi(rate_control, "LA") == 0; p = obs_properties_get(ppts, "la_depth"); obs_property_set_visible(p, bVisible); return true; }
static bool transition_point_type_modified(obs_properties_t *ppts, obs_property_t *p, obs_data_t *s) { int64_t type = obs_data_get_int(s, "tp_type"); p = obs_properties_get(ppts, "transition_point"); if (type == TIMING_TIME) obs_property_set_description(p, obs_module_text("TransitionPoint")); else obs_property_set_description(p, obs_module_text("TransitionPointFrame")); return true; }
/** * Toggle visibility of advanced settings */ static bool xshm_toggle_advanced(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { UNUSED_PARAMETER(p); const bool visible = obs_data_get_bool(settings, "advanced"); obs_property_t *server = obs_properties_get(props, "server"); obs_property_set_visible(server, visible); /* trigger server changed callback so the screen list is refreshed */ obs_property_modified(server, settings); return true; }
void AutoConfigStreamPage::UpdateServerList() { QString serviceName = ui->service->currentText(); bool showMore = ui->service->currentData().toInt() == (int)ListOpt::ShowAll; if (showMore) { LoadServices(true); ui->service->showPopup(); return; } else { lastService = serviceName; } obs_properties_t *props = obs_get_service_properties("rtmp_common"); obs_property_t *services = obs_properties_get(props, "service"); OBSData settings = obs_data_create(); obs_data_release(settings); obs_data_set_string(settings, "service", QT_TO_UTF8(serviceName)); obs_property_modified(services, settings); obs_property_t *servers = obs_properties_get(props, "server"); ui->server->clear(); size_t servers_count = obs_property_list_item_count(servers); for (size_t i = 0; i < servers_count; i++) { const char *name = obs_property_list_item_name(servers, i); const char *server = obs_property_list_item_string(servers, i); ui->server->addItem(name, server); } obs_properties_destroy(props); }
/* * Input selected callback */ static bool input_selected(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { UNUSED_PARAMETER(p); int dev = v4l2_open(obs_data_get_string(settings, "device_id"), O_RDWR | O_NONBLOCK); if (dev == -1) return false; obs_property_t *prop = obs_properties_get(props, "pixelformat"); v4l2_format_list(dev, prop); v4l2_close(dev); obs_property_modified(prop, settings); return true; }
/* * Device selected callback */ static bool device_selected(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { int dev = v4l2_open(obs_data_get_string(settings, "device_id"), O_RDWR | O_NONBLOCK); v4l2_props_set_enabled(props, p, (dev == -1) ? false : true); if (dev == -1) return false; obs_property_t *prop = obs_properties_get(props, "input"); v4l2_input_list(dev, prop); v4l2_close(dev); obs_property_modified(prop, settings); return true; }
/* * Resolution selected callback */ static bool resolution_selected(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { UNUSED_PARAMETER(p); int width, height; int dev = v4l2_open(obs_data_get_string(settings, "device_id"), O_RDWR | O_NONBLOCK); if (dev == -1) return false; obs_property_t *prop = obs_properties_get(props, "framerate"); v4l2_unpack_tuple(&width, &height, obs_data_get_int(settings, "resolution")); v4l2_framerate_list(dev, obs_data_get_int(settings, "pixelformat"), width, height, prop); v4l2_close(dev); obs_property_modified(prop, settings); return true; }
static bool relative_clicked(obs_properties_t *props, obs_property_t *p, obs_data_t *settings) { bool relative = obs_data_get_bool(settings, "relative"); obs_property_set_description(obs_properties_get(props, "left"), relative ? obs_module_text("Crop.Left") : "X"); obs_property_set_description(obs_properties_get(props, "top"), relative ? obs_module_text("Crop.Top") : "Y"); obs_property_set_visible(obs_properties_get(props, "right"), relative); obs_property_set_visible(obs_properties_get(props, "bottom"), relative); obs_property_set_visible(obs_properties_get(props, "cx"), !relative); obs_property_set_visible(obs_properties_get(props, "cy"), !relative); UNUSED_PARAMETER(p); return true; }
static bool decklink_device_changed(obs_properties_t *props, obs_property_t *list, obs_data_t *settings) { const char *name = obs_data_get_string(settings, DEVICE_NAME); const char *hash = obs_data_get_string(settings, DEVICE_HASH); const char *mode = obs_data_get_string(settings, MODE_NAME); long long modeId = obs_data_get_int(settings, MODE_ID); size_t itemCount = obs_property_list_item_count(list); bool itemFound = false; for (size_t i = 0; i < itemCount; i++) { const char *curHash = obs_property_list_item_string(list, i); if (strcmp(hash, curHash) == 0) { itemFound = true; break; } } if (!itemFound) { obs_property_list_insert_string(list, 0, name, hash); obs_property_list_item_disable(list, 0, true); } obs_property_t *modeList = obs_properties_get(props, MODE_ID); obs_property_t *channelList = obs_properties_get(props, CHANNEL_FORMAT); obs_property_list_clear(modeList); obs_property_list_clear(channelList); obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_NONE, SPEAKERS_UNKNOWN); obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_2_0CH, SPEAKERS_STEREO); ComPtr<DeckLinkDevice> device; device.Set(deviceEnum->FindByHash(hash)); if (!device) { obs_property_list_add_int(modeList, mode, modeId); obs_property_list_item_disable(modeList, 0, true); } else { const std::vector<DeckLinkDeviceMode*> &modes = device->GetModes(); for (DeckLinkDeviceMode *mode : modes) { obs_property_list_add_int(modeList, mode->GetName().c_str(), mode->GetId()); } if (device->GetMaxChannel() >= 8) { obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_5_1CH, SPEAKERS_5POINT1); obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_5_1CH_BACK, SPEAKERS_5POINT1_SURROUND); obs_property_list_add_int(channelList, TEXT_CHANNEL_FORMAT_7_1CH, SPEAKERS_7POINT1); } } return true; }
static void set_visible(obs_properties_t *ppts, const char *name, bool visible) { obs_property_t *p = obs_properties_get(ppts, name); obs_property_set_visible(p, visible); }
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")); }