diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index b0c4962a41184ee4224954c90ac6ac5b4563d991..51d0d514ae18cf1a87f3dd401a4fec3056cc58a8 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -23,13 +23,12 @@ MainWindow.Volume="Volume:" Settings="Settings" -Settings.StreamRestart="All streaming/recording must be stopped in order for these changes to take effect" +Settings.ProgramRestart="The program must be restarted for these settings to take effect." Settings.ConfirmTitle="Confirm Changes" Settings.Confirm="You have unsaved changes. Save changes?" Settings.General="General" Settings.General.Language="Language:" -Settings.General.LanguageChanged="The program must be restarted in order to change the language" Settings.Outputs="Outputs" diff --git a/libobs/obs.c b/libobs/obs.c index 425cf671f2ef63d9953ee739450709b0fde97017..e9a6bf043c5fe01f2877c48008d79a8d9f463ab2 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -343,7 +343,7 @@ bool obs_get_video_info(struct obs_video_info *ovi) struct obs_video *video = &obs->video; const struct video_info *info; - if (!video->graphics) + if (!obs || !video->graphics) return false; info = video_output_getinfo(video->video); @@ -365,7 +365,7 @@ bool obs_get_audio_info(struct audio_info *ai) struct obs_audio *audio = &obs->audio; const struct audio_info *info; - if (!audio->audio) + if (!obs || !audio->audio) return false; info = audio_output_getinfo(audio->audio); diff --git a/libobs/util/util.hpp b/libobs/util/util.hpp index a993c4b1065ab02155a957a8312b089a329ee99d..406abbf6397a31ebe26a3cfde47b3153fd7dc203 100644 --- a/libobs/util/util.hpp +++ b/libobs/util/util.hpp @@ -89,7 +89,7 @@ public: config = NULL; } - inline operator config_t() {return config;} + inline operator config_t() const {return config;} }; class TextLookup { @@ -114,9 +114,9 @@ public: return *this; } - inline operator lookup_t() {return lookup;} + inline operator lookup_t() const {return lookup;} - inline const char *GetString(const char *lookupVal) + inline const char *GetString(const char *lookupVal) const { const char *out; if (!text_lookup_getstr(lookup, lookupVal, &out)) diff --git a/obs/obs-app.cpp b/obs/obs-app.cpp index 670afca9494f6b1f3483bba126736b6995b31724..60cbaa416b87d5bec198b9a1f8ed5f36819dad10 100644 --- a/obs/obs-app.cpp +++ b/obs/obs-app.cpp @@ -183,61 +183,107 @@ bool OBSApp::InitLocale() return true; } +bool OBSApp::InitOBSBasic() +{ + OBSBasic *obsBasic = new OBSBasic(); + obsBasic->Show(); + + mainWindow = obsBasic; + return obsBasic->Init(); +} + bool OBSApp::OnInit() { base_set_log_handler(do_log); if (!wxApp::OnInit()) return false; + wxInitAllImageHandlers(); + if (!MakeUserDirs()) return false; if (!InitGlobalConfig()) return false; if (!InitLocale()) return false; - if (!obs_startup()) + if (!InitOBSBasic()) return false; - wxInitAllImageHandlers(); - - OBSBasic *mainWindow = new OBSBasic(); - - wxSize size = mainWindow->GetPreviewPanel()->GetClientSize(); - - mainWindow->Show(); + return true; +} - /* this is a test */ - struct obs_video_info ovi; - ovi.graphics_module = "libobs-opengl"; - ovi.fps_num = 30000; - ovi.fps_den = 1001; - ovi.window_width = size.x; - ovi.window_height = size.y; - ovi.base_width = 1920; - ovi.base_height = 1080; - ovi.output_width = 1280; - ovi.output_height = 720; - ovi.output_format = VIDEO_FORMAT_RGBA; - ovi.adapter = 0; - ovi.window = WxToGSWindow(mainWindow->GetPreviewPanel()); +int OBSApp::OnExit() +{ + return wxApp::OnExit(); +} - if (!obs_reset_video(&ovi)) - return false; +void OBSApp::GetFPSCommon(uint32_t &num, uint32_t &den) const +{ + const char *val = config_get_string(globalConfig, "Video", "FPSCommon"); + + if (strcmp(val, "10") == 0) { + num = 30; + den = 1; + } else if (strcmp(val, "20") == 0) { + num = 20; + den = 1; + } else if (strcmp(val, "29.97") == 0) { + num = 30000; + den = 1001; + } else if (strcmp(val, "48") == 0) { + num = 48; + den = 1; + } else if (strcmp(val, "59.94") == 0) { + num = 60000; + den = 1001; + } else if (strcmp(val, "60") == 0) { + num = 60; + den = 1; + } else { + num = 30; + den = 1; + } +} - //required to make opengl display stuff on osx(?) - mainWindow->SendSizeEvent(); +void OBSApp::GetFPSInteger(uint32_t &num, uint32_t &den) const +{ + num = (uint32_t)config_get_uint(globalConfig, "Video", "FPSInt"); + den = 1; +} - return true; +void OBSApp::GetFPSFraction(uint32_t &num, uint32_t &den) const +{ + num = (uint32_t)config_get_uint(globalConfig, "Video", "FPSNum"); + den = (uint32_t)config_get_uint(globalConfig, "Video", "FPSDen"); } -int OBSApp::OnExit() +void OBSApp::GetFPSNanoseconds(uint32_t &num, uint32_t &den) const { - obs_shutdown(); + num = 1000000000; + den = (uint32_t)config_get_uint(globalConfig, "Video", "FPSNS"); +} - return wxApp::OnExit(); +void OBSApp::GetConfigFPS(uint32_t &num, uint32_t &den) const +{ + const char *type = config_get_string(globalConfig, "Video", "FPSType"); + + if (astrcmpi(type, "Integer") == 0) + GetFPSInteger(num, den); + else if (astrcmpi(type, "Fraction") == 0) + GetFPSFraction(num, den); + else if (astrcmpi(type, "Nanoseconds") == 0) + GetFPSNanoseconds(num, den); + else + GetFPSCommon(num, den); } -void OBSApp::CleanUp() +const char *OBSApp::GetRenderModule() const { - wxApp::CleanUp(); + const char *renderer = config_get_string(globalConfig, "Video", + "Renderer"); + + if (astrcmpi(renderer, "Direct3D 11") == 0) + return "libobs-d3d11"; + else + return "libobs-opengl"; } diff --git a/obs/obs-app.hpp b/obs/obs-app.hpp index 9b0c60ed51266221453958f84c7e14722ecf460e..1d6fd1bd54a896cfaaf9d79da3e7beb70f34f66c 100644 --- a/obs/obs-app.hpp +++ b/obs/obs-app.hpp @@ -18,6 +18,7 @@ #pragma once #include +#include #include @@ -29,23 +30,34 @@ public: class OBSApp : public OBSAppBase { ConfigFile globalConfig; TextLookup textLookup; + wxWindow *mainWindow; bool InitGlobalConfig(); bool InitGlobalConfigDefaults(); bool InitConfigDefaults(); bool InitLocale(); + bool InitOBSBasic(); + + void GetFPSCommon(uint32_t &num, uint32_t &den) const; + void GetFPSInteger(uint32_t &num, uint32_t &den) const; + void GetFPSFraction(uint32_t &num, uint32_t &den) const; + void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const; public: virtual bool OnInit(); virtual int OnExit(); - virtual void CleanUp(); - inline config_t GlobalConfig() {return globalConfig;} + inline wxWindow *GetMainWindow() const {return mainWindow;} + + inline config_t GlobalConfig() const {return globalConfig;} - inline const char *GetString(const char *lookupVal) + inline const char *GetString(const char *lookupVal) const { return textLookup.GetString(lookupVal); } + + void GetConfigFPS(uint32_t &num, uint32_t &den) const; + const char *GetRenderModule() const; }; wxDECLARE_APP(OBSApp); diff --git a/obs/settings-basic-general.cpp b/obs/settings-basic-general.cpp index 8a70618ad5179a2456c2973322a244fbb1c87a5e..21cb5cce4e5b7a0fb875a6503256647cf99746a8 100644 --- a/obs/settings-basic-general.cpp +++ b/obs/settings-basic-general.cpp @@ -103,7 +103,7 @@ void BasicGenData::LanguageChanged(wxCommandEvent &event) { SetChanged(); window->generalChangedText->SetLabel( - WXStr("Settings.General.LanguageChanged")); + WXStr("Settings.General.ProgramRestart")); window->generalChangedText->Show(); } diff --git a/obs/settings-basic-video.cpp b/obs/settings-basic-video.cpp index 562e545f31ef9df056a30649651fa0a5a171f8e8..88a1448c75fd90e7b79f160711dfc901befe6116 100644 --- a/obs/settings-basic-video.cpp +++ b/obs/settings-basic-video.cpp @@ -40,8 +40,10 @@ class BasicVideoData : public BasicSettingsData { void LoadFPSNanoseconds(); void ResetScaleList(uint32_t cx, uint32_t cy); - void BaseResListChanged(wxCommandEvent &event); - void OutputResListChanged(wxCommandEvent &event); + void RendererChanged(wxCommandEvent &event); + void BaseResChanged(wxCommandEvent &event); + void OutputResChanged(wxCommandEvent &event); + void FPSChanged(wxCommandEvent &event); void SaveOther(); void SaveFPSData(); @@ -280,6 +282,11 @@ void BasicVideoData::ResetScaleList(uint32_t cx, uint32_t cy) } } +#define ADD_CONNECT(control, event, func) \ + connections.Add(window->control, event, \ + wxCommandEventHandler(BasicVideoData::func), \ + NULL, this) + BasicVideoData::BasicVideoData(OBSBasicSettings *window) : BasicSettingsData(window) { @@ -288,19 +295,37 @@ BasicVideoData::BasicVideoData(OBSBasicSettings *window) LoadOther(); /* load connectors after loading data to prevent them from triggering */ - connections.Add(window->baseResList, wxEVT_TEXT, - wxCommandEventHandler( - BasicVideoData::BaseResListChanged), - NULL, this); - connections.Add(window->outputResList, wxEVT_TEXT, - wxCommandEventHandler( - BasicVideoData::OutputResListChanged), - NULL, this); + ADD_CONNECT(baseResList, wxEVT_TEXT, BaseResChanged); + ADD_CONNECT(outputResList, wxEVT_TEXT, OutputResChanged); + ADD_CONNECT(rendererList, wxEVT_COMBOBOX, RendererChanged); + ADD_CONNECT(fpsCommonList, wxEVT_COMBOBOX, FPSChanged); + ADD_CONNECT(fpsIntegerScroller, wxEVT_SPINCTRL, FPSChanged); + ADD_CONNECT(fpsNumeratorScroller, wxEVT_SPINCTRL, FPSChanged); + ADD_CONNECT(fpsDenominatorScroller, wxEVT_SPINCTRL, FPSChanged); + ADD_CONNECT(fpsNanosecondsScroller, wxEVT_SPINCTRL, FPSChanged); + ADD_CONNECT(fpsIntegerScroller, wxEVT_TEXT, FPSChanged); + ADD_CONNECT(fpsNumeratorScroller, wxEVT_TEXT, FPSChanged); + ADD_CONNECT(fpsDenominatorScroller, wxEVT_TEXT, FPSChanged); + ADD_CONNECT(fpsNanosecondsScroller, wxEVT_TEXT, FPSChanged); + ADD_CONNECT(fpsTypeList, wxEVT_CHOICEBOOK_PAGE_CHANGED, + FPSChanged); window->videoChangedText->Hide(); } -void BasicVideoData::BaseResListChanged(wxCommandEvent &event) +void BasicVideoData::RendererChanged(wxCommandEvent &event) +{ + SetChanged(); + window->videoChangedText->SetLabel(WXStr("Settings.ProgramRestart")); + window->videoChangedText->Show(); +} + +void BasicVideoData::FPSChanged(wxCommandEvent &event) +{ + SetChanged(); +} + +void BasicVideoData::BaseResChanged(wxCommandEvent &event) { uint32_t cx, cy; if (!ConvertTextRes(window->baseResList, cx, cy)) { @@ -311,13 +336,11 @@ void BasicVideoData::BaseResListChanged(wxCommandEvent &event) } SetChanged(); - window->videoChangedText->SetLabel(WXStr("Settings.StreamRestart")); - window->videoChangedText->Show(); ResetScaleList(cx, cy); } -void BasicVideoData::OutputResListChanged(wxCommandEvent &event) +void BasicVideoData::OutputResChanged(wxCommandEvent &event) { uint32_t cx, cy; if (!ConvertTextRes(window->outputResList, cx, cy)) { @@ -328,8 +351,6 @@ void BasicVideoData::OutputResListChanged(wxCommandEvent &event) } SetChanged(); - window->videoChangedText->SetLabel(WXStr("Settings.StreamRestart")); - window->videoChangedText->Show(); } void BasicVideoData::SaveOther() @@ -412,6 +433,8 @@ void BasicVideoData::Apply() config_save(GetGlobalConfig()); + /* TODO: If resolutiosn/fps were chaned, reset video */ + SetSaved(); } diff --git a/obs/window-main-basic.cpp b/obs/window-main-basic.cpp index b2eae9b9027ae7e03802a3d514e86c8400c4931c..424f0c2060958152b2c659fde2b66a05529f543b 100644 --- a/obs/window-main-basic.cpp +++ b/obs/window-main-basic.cpp @@ -18,9 +18,55 @@ #include #include "obs-app.hpp" +#include "wx-wrappers.hpp" #include "window-settings-basic.hpp" #include "window-main-basic.hpp" +bool OBSBasic::Init() +{ + if (!obs_startup()) + return false; + if (!InitGraphics()) + return false; + + return true; +} + +OBSBasic::~OBSBasic() +{ + obs_shutdown(); +} + +bool OBSBasic::InitGraphics() +{ + wxSize size = previewPanel->GetClientSize(); + + struct obs_video_info ovi; + wxGetApp().GetConfigFPS(ovi.fps_num, ovi.fps_den); + ovi.graphics_module = wxGetApp().GetRenderModule(); + ovi.window_width = size.x; + ovi.window_height = size.y; + ovi.base_width = (uint32_t)config_get_uint(GetGlobalConfig(), + "Video", "BaseCX"); + ovi.base_height = (uint32_t)config_get_uint(GetGlobalConfig(), + "Video", "BaseCY"); + ovi.output_width = (uint32_t)config_get_uint(GetGlobalConfig(), + "Video", "OutputCX"); + ovi.output_height = (uint32_t)config_get_uint(GetGlobalConfig(), + "Video", "OutputCY"); + ovi.output_format = VIDEO_FORMAT_RGBA; + ovi.adapter = 0; + ovi.window = WxToGSWindow(previewPanel); + + if (!obs_reset_video(&ovi)) + return false; + + //required to make opengl display stuff on osx(?) + SendSizeEvent(); + + return true; +} + void OBSBasic::OnClose(wxCloseEvent &event) { wxGetApp().ExitMainLoop(); diff --git a/obs/window-main-basic.hpp b/obs/window-main-basic.hpp index 8175750bf98c414e25217289f1fed2168d2bc7ea..0e49d44b9715a045128e525dfca98d92f39a2b9d 100644 --- a/obs/window-main-basic.hpp +++ b/obs/window-main-basic.hpp @@ -19,7 +19,16 @@ #include "forms/OBSWindows.h" +#include + +#include +using namespace std; + class OBSBasic : public OBSBasicBase { + vector scenes; + + bool InitGraphics(); + void NewProject(); void SaveProject(); void LoadProject(); @@ -49,6 +58,9 @@ protected: public: inline OBSBasic() : OBSBasicBase(NULL) {} + virtual ~OBSBasic(); + + bool Init(); inline wxPanel *GetPreviewPanel() {return previewPanel;} inline wxSizer *GetPreviewContainer() {return previewContainer;}