obs分析 笔记
widget_2 groupBox_15 groupBox_16 groupBox_10 groupBox_14 groupBox_13 groupBox_11 groupBoxMultiview GetComboData(QComboBox *combo) FindEncoder UpdateAutomaticReplayBufferCheckboxes() on_actionAddScene_triggered() void OBSBasic::on_sources_customContextMenuRequested(const QPoint &pos) Audio monitoring device main()->static int run_program()->OBSApp::OBSInit()->StartupOBS() ->obs_startup() ->obs_inti() -> obs的初始化在obs_init中。 Qmenu中的数据来源obs->source_types; obs_register_source宏 obs_register_source_s(); bool obs_module_load(void)//加载模块 //已被注释 { obs_register_source(&image_source_info); obs_register_source(&color_source_info); obs_register_source(&slideshow_info); return true; } bool obs_module_load(void) { da_init(active_log_contexts); da_init(cached_log_contexts); //av_log_set_callback(ffmpeg_log_callback); // obs_register_source(&ffmpeg_source);//媒体源 obs_register_output(&ffmpeg_output); obs_register_output(&ffmpeg_muxer); obs_register_output(&replay_buffer); obs_register_encoder(&aac_encoder_info); obs_register_encoder(&opus_encoder_info); #ifndef __APPLE__ if (nvenc_supported()) { blog(LOG_INFO, "NVENC supported"); obs_register_encoder(&nvenc_encoder_info); } #endif return true; } static bool obs_init(const char *locale, const char *module_config_path, profiler_name_store_t *store) { obs = bzalloc(sizeof(struct obs_core)); pthread_mutex_init_value(&obs->audio.monitoring_mutex); obs->name_store_owned = !store; obs->name_store = store ? store : profiler_name_store_create(); if (!obs->name_store) { blog(LOG_ERROR, "Couldn't create profiler name store"); return false; } log_system_info(); if (!obs_init_data()) return false; if (!obs_init_handlers()) return false; if (!obs_init_hotkeys()) return false; if (module_config_path) obs->module_config_path = bstrdup(module_config_path); obs->locale = bstrdup(locale); obs_register_source(&scene_info);//注册场景 // obs_register_source(&group_info); add_default_module_paths(); return true; } bool obs_module_load(void) { obs_register_source(&mask_filter); obs_register_source(&crop_filter); obs_register_source(&gain_filter); obs_register_source(&color_filter); obs_register_source(&scale_filter); obs_register_source(&scroll_filter); obs_register_source(&gpu_delay_filter); obs_register_source(&color_key_filter); obs_register_source(&color_grade_filter); obs_register_source(&sharpness_filter); obs_register_source(&chroma_key_filter); obs_register_source(&async_delay_filter); #if SPEEXDSP_ENABLED obs_register_source(&noise_suppress_filter); #endif obs_register_source(&noise_gate_filter); obs_register_source(&compressor_filter); return true; } static int obs_lua_register_source(lua_State *script) bool obs_module_load(void) { obs_register_source(&cut_transition); obs_register_source(&fade_transition); obs_register_source(&swipe_transition); obs_register_source(&slide_transition); obs_register_source(&stinger_transition); obs_register_source(&fade_to_color_transition); obs_register_source(&luma_wipe_transition); return true; } bool obs_module_load(void) { struct obs_source_info vst_filter = {}; vst_filter.id = "vst_filter"; vst_filter.type = OBS_SOURCE_TYPE_FILTER; vst_filter.output_flags = OBS_SOURCE_AUDIO; vst_filter.get_name = vst_name; vst_filter.create = vst_create; vst_filter.destroy = vst_destroy; vst_filter.update = vst_update; vst_filter.filter_audio = vst_filter_audio; vst_filter.get_properties = vst_properties; vst_filter.save = vst_save; obs_register_source(&vst_filter); return true; } static DWORD WINAPI init_hooks(LPVOID param) { char *config_path = param; if (USE_HOOK_ADDRESS_CACHE && cached_versions_match() && load_cached_graphics_offsets(IS32BIT, config_path)) { load_cached_graphics_offsets(!IS32BIT, config_path); //obs_register_source(&game_capture_info);//游戏捕获 } else if (load_graphics_offsets(IS32BIT, config_path)) { load_graphics_offsets(!IS32BIT, config_path); } bfree(config_path); return 0; } bool obs_module_load(void) { struct win_version_info ver; bool win8_or_above = false; char *config_dir; config_dir = obs_module_config_path(NULL); if (config_dir) { os_mkdirs(config_dir); bfree(config_dir); } get_win_ver(&ver); win8_or_above = ver.major > 6 || (ver.major == 6 && ver.minor >= 2); obs_enter_graphics(); if (win8_or_above && gs_get_device_type() == GS_DEVICE_DIRECT3D_11) obs_register_source(&duplicator_capture_info); else obs_register_source(&monitor_capture_info); obs_leave_graphics(); //obs_register_source(&window_capture_info); char *config_path = obs_module_config_path(NULL); init_hooks_thread = CreateThread(NULL, 0, init_hooks, config_path, 0, NULL); obs_register_source(&game_capture_info); return true; } bool obs_module_load(void) { obs_source_info si = {}; si.id = "text_gdiplus"; si.type = OBS_SOURCE_TYPE_INPUT; si.output_flags = OBS_SOURCE_VIDEO; si.get_properties = get_properties; si.get_name = [] (void*) { return obs_module_text("TextGDIPlus"); }; si.create = [] (obs_data_t *settings, obs_source_t *source) { return (void*)new TextSource(source, settings); }; si.destroy = [] (void *data) { delete reinterpret_cast<TextSource*>(data); }; si.get_width = [] (void *data) { return reinterpret_cast<TextSource*>(data)->cx; }; si.get_height = [] (void *data) { return reinterpret_cast<TextSource*>(data)->cy; }; si.get_defaults = [] (obs_data_t *settings) { obs_data_t *font_obj = obs_data_create(); obs_data_set_default_string(font_obj, "face", "Arial"); obs_data_set_default_int(font_obj, "size", 36); obs_data_set_default_obj(settings, S_FONT, font_obj); obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_OPACITY, 100); obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); obs_data_set_default_int(settings, S_BKOPACITY, 0); obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true); obs_data_set_default_int(settings, S_EXTENTS_CX, 100); obs_data_set_default_int(settings, S_EXTENTS_CY, 100); obs_data_release(font_obj); }; si.update = [] (void *data, obs_data_t *settings) { reinterpret_cast<TextSource*>(data)->Update(settings); }; si.video_tick = [] (void *data, float seconds) { reinterpret_cast<TextSource*>(data)->Tick(seconds); }; si.video_render = [] (void *data, gs_effect_t *effect) { reinterpret_cast<TextSource*>(data)->Render(effect); }; //obs_register_source(&si); const GdiplusStartupInput gdip_input; GdiplusStartup(&gdip_token, &gdip_input, nullptr); return true; } void RegisterWASAPIOutput() { obs_source_info info = {}; info.id = "wasapi_output_capture"; info.type = OBS_SOURCE_TYPE_INPUT; info.output_flags = OBS_SOURCE_AUDIO | OBS_SOURCE_DO_NOT_DUPLICATE | OBS_SOURCE_DO_NOT_SELF_MONITOR; info.get_name = GetWASAPIOutputName; info.create = CreateWASAPIOutput; info.destroy = DestroyWASAPISource; info.update = UpdateWASAPISource; info.get_defaults = GetWASAPIDefaultsOutput; info.get_properties = GetWASAPIPropertiesOutput; //obs_register_source(&info); } bool obs_module_load() { char *config_dir = obs_module_config_path(NULL); if (config_dir) { os_mkdirs(config_dir); bfree(config_dir); } //obs_register_source(&freetype2_source_info);//不推荐使用->文本 freetyep2 return true; } #include<qdialog.h> QDialog d; d.setWindowTitle("hit me"); d.exec(); QAction *action = popup.addAction( QTStr("Basic.Main.PreviewConextMenu.Enable"), this, SLOT(TogglePreview())); action->setCheckable(true); action->setChecked( obs_display_enabled(ui->preview->GetDisplay())); if (IsPreviewProgramMode()) action->setEnabled(false); 在window-basic-main.cpp void OBSBasic::CreateSourcePopupMenu(int idx, bool preview)//有关前面板preview显示菜单的函数 bool OBSApp::OBSInit() mainWindow = new OBSBasic(); mainWindow->setWindowTitle("OBS视频录制软件");//在此直接修改主窗口名 actionAddScene void OBSBasic::on_actionAddScene_triggered()// AutoUpdateThread --> update InitHotkeys()//初始化热键 bool OBSApp::InitGlobalConfigDefaults()//设置默认配置 config_set_default_bool(globalConfig, "General", "EnableAutoUpdates", false);//设置自动更新失能 ui->actionCheckForUpdates->setEnabled(false);//设置设置失效