|
|
@ -73,7 +73,6 @@ void OBSManager::Initialize(Gdk::Rectangle rect) |
|
|
|
mScreenWidth = rect.get_width(); |
|
|
|
mScreenHeight = rect.get_height(); |
|
|
|
|
|
|
|
mSources = list<OBSSource>(); |
|
|
|
auto settings = new SettingsManager(); |
|
|
|
LoadSettings(settings); |
|
|
|
|
|
|
@ -122,10 +121,12 @@ void OBSManager::StartPreview(XID wid, Display *wdisplay) |
|
|
|
if (mDisplay == nullptr) |
|
|
|
throw runtime_error("Failed to create display"); |
|
|
|
|
|
|
|
obs_display_resize(mDisplay, PreviewWidth, PreviewHeight); |
|
|
|
//obs_display_resize(mDisplay, PreviewWidth, PreviewHeight);
|
|
|
|
obs_display_add_draw_callback(mDisplay, OBSRender, nullptr); |
|
|
|
|
|
|
|
OBSScene scene = obs_scene_create("scene1"); |
|
|
|
auto sources = new list<OBSSource>(); |
|
|
|
|
|
|
|
OBSScene scene = obs_scene_create("Main"); |
|
|
|
if (scene == NULL) |
|
|
|
throw runtime_error("Couldn't create scene\n"); |
|
|
|
|
|
|
@ -133,7 +134,7 @@ void OBSManager::StartPreview(XID wid, Display *wdisplay) |
|
|
|
{ |
|
|
|
auto source = CreateScreenSource(); |
|
|
|
obs_scene_add(scene, source); |
|
|
|
mSources.push_back(source); |
|
|
|
sources->push_back(source); |
|
|
|
} |
|
|
|
|
|
|
|
if (mWebcamEnabled) |
|
|
@ -144,27 +145,29 @@ void OBSManager::StartPreview(XID wid, Display *wdisplay) |
|
|
|
auto source = CreateWebcamSource(); |
|
|
|
auto item = obs_scene_add(scene, source); |
|
|
|
obs_sceneitem_set_scale(item, &scale); |
|
|
|
mSources.push_back(source); |
|
|
|
sources->push_back(source); |
|
|
|
} |
|
|
|
|
|
|
|
if (mAudioEnabled) |
|
|
|
{ |
|
|
|
auto source = CreateAudioSource(); |
|
|
|
obs_scene_add(scene, source); |
|
|
|
mSources.push_back(source); |
|
|
|
sources->push_back(source); |
|
|
|
} |
|
|
|
|
|
|
|
obs_set_output_source(0, obs_scene_get_source(scene)); |
|
|
|
obs_scene_release(scene); |
|
|
|
|
|
|
|
for (auto source : *sources) |
|
|
|
{ |
|
|
|
obs_source_release(source); |
|
|
|
} |
|
|
|
|
|
|
|
sigStartPreview.emit(); |
|
|
|
} |
|
|
|
|
|
|
|
void OBSManager::StopPreview() |
|
|
|
{ |
|
|
|
for (auto source : mSources) |
|
|
|
{ |
|
|
|
obs_source_remove(source); |
|
|
|
} |
|
|
|
|
|
|
|
if (mDisplay != nullptr) |
|
|
|
obs_display_destroy(mDisplay); |
|
|
|
|
|
|
@ -207,6 +210,10 @@ void OBSManager::StartRecording() |
|
|
|
obsStartRecording.Connect(obs_output_get_signal_handler(mOutput), "start", OBSStartRecording, this); |
|
|
|
obsStopRecording.Connect(obs_output_get_signal_handler(mOutput), "stop", OBSStopRecording, this); |
|
|
|
|
|
|
|
obs_encoder_release(venc); |
|
|
|
obs_encoder_release(aenc); |
|
|
|
obs_output_release(mOutput); |
|
|
|
|
|
|
|
isRecording = true; |
|
|
|
} |
|
|
|
|
|
|
@ -225,14 +232,16 @@ bool OBSManager::IsRecording() |
|
|
|
|
|
|
|
void OBSManager::Cleanup() |
|
|
|
{ |
|
|
|
if (!isInitialized) |
|
|
|
return; |
|
|
|
|
|
|
|
StopRecording(); |
|
|
|
StopPreview(); |
|
|
|
|
|
|
|
obs_shutdown(); |
|
|
|
isInitialized = false; |
|
|
|
if (isInitialized) |
|
|
|
{ |
|
|
|
StopRecording(); |
|
|
|
StopPreview(); |
|
|
|
|
|
|
|
if (obs_initialized()) |
|
|
|
obs_shutdown(); |
|
|
|
|
|
|
|
isInitialized = false; |
|
|
|
} |
|
|
|
|
|
|
|
sigCleanup.emit(); |
|
|
|
} |
|
|
|