ResetVideo
2024-10-08
4
0
本想着从简单的开始,但是发现核心的渲染如D3D11和新的版本基本差不多,还不如直接用新的代码调试,所以本章节放弃。
ResetVideo总其三大部分:
- 获取基本的视频配置参数
- obs_reset_video
- 增加主窗口渲染回调
bool OBSBasic::ResetVideo()
{
struct obs_video_info ovi;
GetConfigFPS(ovi.fps_num, ovi.fps_den);
ovi.graphics_module = App()->GetRenderModule();
ovi.base_width = (uint32_t)config_get_uint(basicConfig, "Video", "BaseCX");
ovi.base_height = (uint32_t)config_get_uint(basicConfig, "Video", "BaseCY");
ovi.output_width = (uint32_t)config_get_uint(basicConfig, "Video", "OutputCX");
ovi.output_height = (uint32_t)config_get_uint(basicConfig, "Video", "OutputCY");
ovi.output_format = VIDEO_FORMAT_NV12;
ovi.adapter = 0;
ovi.gpu_conversion = true;
QTToGSWindow(ui->preview->winId(), ovi.window);//获取窗口句柄
//required to make opengl display stuff on osx(?)
ResizePreview(ovi.base_width, ovi.base_height);
QSize size = GetPixelSize(ui->preview);
ovi.window_width = size.width();
ovi.window_height = size.height();
if (!obs_reset_video(&ovi))
return false;
obs_add_draw_callback(OBSBasic::RenderMain, this);
return true;
}