Dwayne Harris
3 years ago
11 changed files with 292 additions and 35 deletions
-
4.kdev4/screen-recorder.kdev4
-
BIN.obs-manager.hpp.kate-swp
-
14Makefile
-
5main.cpp
-
80obs-manager.cpp
-
31obs-manager.hpp
-
55recording-window.cpp
-
24recording-window.hpp
-
BINscreenrecorder
-
82settings-window.cpp
-
32settings-window.hpp
@ -1,17 +1,23 @@ |
|||||
CC = g++ |
CC = g++ |
||||
CFLAGS = -g -Wall --std=c++17 |
|
||||
|
CFLAGS = -g -Wall -std=c++17 |
||||
GCFLAGS = `pkg-config --cflags --libs gtkmm-3.0` -lobs |
GCFLAGS = `pkg-config --cflags --libs gtkmm-3.0` -lobs |
||||
|
|
||||
TARGET = screenrecorder |
TARGET = screenrecorder |
||||
|
|
||||
$(TARGET): main.o recording-window.o |
|
||||
$(CC) $(CFLAGS) -o $(TARGET) main.o recording-window.o $(GCFLAGS) |
|
||||
|
$(TARGET): main.o obs-manager.o recording-window.o settings-window.o |
||||
|
$(CC) $(CFLAGS) -o $(TARGET) main.o obs-manager.o recording-window.o settings-window.o $(GCFLAGS) |
||||
|
|
||||
main.o: |
main.o: |
||||
$(CC) $(CFLAGS) -c main.cpp $(GCFLAGS) |
$(CC) $(CFLAGS) -c main.cpp $(GCFLAGS) |
||||
|
|
||||
|
obs-manager.o: obs-manager.cpp obs-manager.hpp |
||||
|
$(CC) $(CFLAGS) -c obs-manager.cpp $(GCFLAGS) |
||||
|
|
||||
recording-window.o: recording-window.cpp recording-window.hpp |
recording-window.o: recording-window.cpp recording-window.hpp |
||||
$(CC) $(CFLAGS) -c recording-window.cpp $(GCFLAGS) |
$(CC) $(CFLAGS) -c recording-window.cpp $(GCFLAGS) |
||||
|
|
||||
|
settings-window.o: settings-window.cpp settings-window.hpp |
||||
|
$(CC) $(CFLAGS) -c settings-window.cpp $(GCFLAGS) |
||||
|
|
||||
clean: |
clean: |
||||
rm $(TARGET) main.o recording-window.o |
|
||||
|
rm $(TARGET) main.o obs-manager.o recording-window.o settings-window.o |
@ -1,10 +1,13 @@ |
|||||
#include "recording-window.hpp"
|
#include "recording-window.hpp"
|
||||
|
#include "obs-manager.hpp"
|
||||
#include <gtkmm/application.h>
|
#include <gtkmm/application.h>
|
||||
|
|
||||
int main(int argc, char *argv[]) |
int main(int argc, char *argv[]) |
||||
{ |
{ |
||||
auto app = Gtk::Application::create(argc, argv, "xyz.dwayne.screenrecorder"); |
auto app = Gtk::Application::create(argc, argv, "xyz.dwayne.screenrecorder"); |
||||
RecordingWindow win; |
|
||||
|
auto obs = new OBSManager(); |
||||
|
|
||||
|
RecordingWindow win(obs); |
||||
|
|
||||
return app->run(win); |
return app->run(win); |
||||
} |
} |
@ -0,0 +1,80 @@ |
|||||
|
#include "obs-manager.hpp"
|
||||
|
#include <obs/obs.h>
|
||||
|
#include <glibmm/ustring.h>
|
||||
|
#include <stdexcept>
|
||||
|
|
||||
|
using namespace Glib; |
||||
|
|
||||
|
OBSManager::OBSManager() |
||||
|
{ |
||||
|
plugins = { |
||||
|
"obs-ffmpeg.so", |
||||
|
"linux-v4l2.so", |
||||
|
"linux-capture.so", |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
OBSManager::~OBSManager() |
||||
|
{ |
||||
|
if (display != nullptr) |
||||
|
obs_display_destroy(display); |
||||
|
} |
||||
|
|
||||
|
ustring OBSManager::GetVersion() |
||||
|
{ |
||||
|
return ustring(obs_get_version_string()); |
||||
|
} |
||||
|
|
||||
|
void OBSManager::Initialize() |
||||
|
{ |
||||
|
if (isInitialized) |
||||
|
return; |
||||
|
|
||||
|
if (!obs_startup("en-US", NULL, NULL)) |
||||
|
throw std::runtime_error("Failed to initialize OBS"); |
||||
|
|
||||
|
struct gs_init_data info = { |
||||
|
.cx = 1280, |
||||
|
.cy = 720, |
||||
|
.format = GS_BGRA, |
||||
|
.zsformat = GS_ZS_NONE, |
||||
|
}; |
||||
|
|
||||
|
display = obs_display_create(&info, 0); |
||||
|
if (display == nullptr) |
||||
|
throw std::runtime_error("Failed to create display"); |
||||
|
} |
||||
|
|
||||
|
ustring OBSManager::GetPluginDir() |
||||
|
{ |
||||
|
return pluginDir; |
||||
|
} |
||||
|
|
||||
|
void OBSManager::loadPlugin(ustring name) |
||||
|
{ |
||||
|
obs_module_t *module; |
||||
|
|
||||
|
ustring path; |
||||
|
path.append(pluginDir); |
||||
|
path.append(name); |
||||
|
|
||||
|
int res = obs_open_module(&module, path.c_str(), nullptr); |
||||
|
if (res != MODULE_SUCCESS) |
||||
|
throw std::runtime_error("Failed to open plugin"); |
||||
|
|
||||
|
obs_init_module(module); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
void OBSManager::loadPlugins() |
||||
|
{ |
||||
|
for (ustring plugin : plugins) |
||||
|
{ |
||||
|
loadPlugin(plugin); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,31 @@ |
|||||
|
#ifndef SCREEN_RECORDER_OBS_MANAGER_HPP
|
||||
|
#define SCREEN_RECORDER_OBS_MANAGER_HPP
|
||||
|
|
||||
|
#include <list>
|
||||
|
#include <glibmm/ustring.h>
|
||||
|
#include <obs/obs.h>
|
||||
|
|
||||
|
using namespace Glib; |
||||
|
|
||||
|
class OBSManager |
||||
|
{ |
||||
|
public: |
||||
|
OBSManager(); |
||||
|
virtual ~OBSManager(); |
||||
|
ustring GetVersion(); |
||||
|
void Initialize(); |
||||
|
void Cleanup(); |
||||
|
ustring GetPluginDir(); |
||||
|
|
||||
|
private: |
||||
|
ustring pluginDir = "/usr/lib/x86_64-linux-gnu/obs-plugins/"; |
||||
|
std::list<ustring> plugins; |
||||
|
|
||||
|
bool isInitialized = false; |
||||
|
obs_display_t *display = nullptr; |
||||
|
|
||||
|
void loadPlugin(ustring name); |
||||
|
void loadPlugins(); |
||||
|
}; |
||||
|
|
||||
|
#endif
|
@ -1,40 +1,57 @@ |
|||||
#include "recording-window.hpp"
|
#include "recording-window.hpp"
|
||||
|
#include "obs-manager.hpp"
|
||||
#include <iostream>
|
#include <iostream>
|
||||
#include <obs/obs.h>
|
|
||||
|
#include <string>
|
||||
|
|
||||
RecordingWindow::RecordingWindow() |
|
||||
: m_box_main(Gtk::Orientation::ORIENTATION_VERTICAL, 2), |
|
||||
m_button_start("Start Recording"), |
|
||||
m_label_version("Version: ") |
|
||||
|
using namespace std; |
||||
|
|
||||
|
RecordingWindow::RecordingWindow(OBSManager *obs) |
||||
|
: mBoxMain(Gtk::Orientation::ORIENTATION_VERTICAL, 2), |
||||
|
mButtonStart("Start Recording"), |
||||
|
mButtonSettings("Settings"), |
||||
|
mLabelVersion("Version: "), |
||||
|
mSettingsWindow(obs) |
||||
{ |
{ |
||||
set_title("New Recording"); |
set_title("New Recording"); |
||||
set_default_size(640, 480); |
|
||||
|
set_default_size(1048, 720); |
||||
set_border_width(10); |
set_border_width(10); |
||||
m_button_start.signal_clicked().connect(sigc::mem_fun(*this, &RecordingWindow::on_button_clicked)); |
|
||||
|
mButtonStart.signal_clicked().connect( |
||||
|
sigc::mem_fun(*this, &RecordingWindow::onStartClicked)); |
||||
|
mButtonSettings.signal_clicked().connect( |
||||
|
sigc::mem_fun(*this, &RecordingWindow::onSettingsClicked)); |
||||
|
|
||||
//m_box_main.set_margin(10);
|
|
||||
m_box_main.add(m_button_start); |
|
||||
m_box_main.add(m_label_version); |
|
||||
|
mBoxMain.add(mButtonStart); |
||||
|
mBoxMain.add(mButtonSettings); |
||||
|
mBoxMain.add(mLabelVersion); |
||||
|
|
||||
m_button_start.show(); |
|
||||
m_label_version.show(); |
|
||||
|
mButtonStart.show(); |
||||
|
mButtonSettings.show(); |
||||
|
mLabelVersion.show(); |
||||
|
|
||||
add(m_box_main); |
|
||||
m_box_main.show(); |
|
||||
|
add(mBoxMain); |
||||
|
mBoxMain.show(); |
||||
|
|
||||
std::string version = "OBS Version: "; |
|
||||
version.append(obs_get_version_string()); |
|
||||
|
string version; |
||||
|
version.append("OBS Version: "); |
||||
|
version.append(obs->GetVersion()); |
||||
|
|
||||
m_label_version.set_text(version); |
|
||||
|
mLabelVersion.set_text(version); |
||||
} |
} |
||||
|
|
||||
RecordingWindow::~RecordingWindow() |
RecordingWindow::~RecordingWindow() |
||||
{ |
{ |
||||
} |
} |
||||
|
|
||||
void RecordingWindow::on_button_clicked() |
|
||||
|
void RecordingWindow::onStartClicked() |
||||
{ |
{ |
||||
std::cout << "Clicked" << std::endl; |
|
||||
|
cout << "Clicked" << endl; |
||||
} |
} |
||||
|
|
||||
|
void RecordingWindow::onSettingsClicked() |
||||
|
{ |
||||
|
mSettingsWindow.set_transient_for(*this); |
||||
|
mSettingsWindow.show(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
@ -1,21 +1,23 @@ |
|||||
#ifndef SCREEN_RECORDER_RECORDING_WINDOW_H
|
|
||||
#define SCREEN_RECORDER_RECORDING_WINDOW_H
|
|
||||
|
#ifndef SCREEN_RECORDER_RECORDING_WINDOW_HPP
|
||||
|
#define SCREEN_RECORDER_RECORDING_WINDOW_HPP
|
||||
|
|
||||
#include <gtkmm/box.h>
|
|
||||
#include <gtkmm/button.h>
|
|
||||
#include <gtkmm/label.h>
|
|
||||
#include <gtkmm/window.h>
|
|
||||
|
#include <gtkmm.h>
|
||||
|
#include "obs-manager.hpp"
|
||||
|
#include "settings-window.hpp"
|
||||
|
|
||||
class RecordingWindow : public Gtk::Window |
class RecordingWindow : public Gtk::Window |
||||
{ |
{ |
||||
public: |
public: |
||||
RecordingWindow(); |
|
||||
|
RecordingWindow(OBSManager *obs); |
||||
virtual ~RecordingWindow(); |
virtual ~RecordingWindow(); |
||||
protected: |
protected: |
||||
void on_button_clicked(); |
|
||||
Gtk::Box m_box_main; |
|
||||
Gtk::Button m_button_start; |
|
||||
Gtk::Label m_label_version; |
|
||||
|
void onStartClicked(); |
||||
|
void onSettingsClicked(); |
||||
|
Gtk::Box mBoxMain; |
||||
|
Gtk::Button mButtonStart; |
||||
|
Gtk::Button mButtonSettings; |
||||
|
Gtk::Label mLabelVersion; |
||||
|
SettingsWindow mSettingsWindow; |
||||
}; |
}; |
||||
|
|
||||
#endif
|
#endif
|
@ -0,0 +1,82 @@ |
|||||
|
#include "settings-window.hpp"
|
||||
|
|
||||
|
SettingsWindow::SettingsWindow(OBSManager* obs) |
||||
|
: mBox(Gtk::Orientation::ORIENTATION_VERTICAL, 2), |
||||
|
mBoxSettings(Gtk::Orientation::ORIENTATION_VERTICAL, 2), |
||||
|
mBoxPluginDir(Gtk::Orientation::ORIENTATION_HORIZONTAL, 2), |
||||
|
mLabelPluginDir("Plugin Dir: "), |
||||
|
mBoxOutputDir(Gtk::Orientation::ORIENTATION_HORIZONTAL, 2), |
||||
|
mLabelOutputDir("Saved Files Dir: "), |
||||
|
mButtonClose("Close"), |
||||
|
mButtonSave("Save") |
||||
|
{ |
||||
|
set_title("Settings"); |
||||
|
set_default_size(640, 480); |
||||
|
set_border_width(10); |
||||
|
set_modal(true); |
||||
|
set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_DIALOG); |
||||
|
|
||||
|
signal_key_press_event().connect( |
||||
|
sigc::mem_fun(*this, &SettingsWindow::onKeyPressed)); |
||||
|
|
||||
|
mButtonClose.signal_clicked().connect( |
||||
|
sigc::mem_fun(*this, &SettingsWindow::onClosePressed)); |
||||
|
mButtonSave.signal_clicked().connect( |
||||
|
sigc::mem_fun(*this, &SettingsWindow::onSavePressed)); |
||||
|
|
||||
|
mBoxSettings.set_border_width(10); |
||||
|
|
||||
|
mEntryPluginDir.set_hexpand(true); |
||||
|
mEntryPluginDir.set_text(obs->GetPluginDir().c_str()); |
||||
|
|
||||
|
mBoxPluginDir.set_border_width(10); |
||||
|
mBoxPluginDir.add(mLabelPluginDir); |
||||
|
mBoxPluginDir.add(mEntryPluginDir); |
||||
|
|
||||
|
mEntryOutputDir.set_hexpand(true); |
||||
|
|
||||
|
mBoxOutputDir.set_border_width(10); |
||||
|
mBoxOutputDir.add(mLabelOutputDir); |
||||
|
mBoxOutputDir.add(mEntryOutputDir); |
||||
|
|
||||
|
mBoxSettings.add(mBoxPluginDir); |
||||
|
mBoxSettings.add(mBoxOutputDir); |
||||
|
|
||||
|
mFrameSettings.set_label("Settings"); |
||||
|
mFrameSettings.set_border_width(10); |
||||
|
mFrameSettings.add(mBoxSettings); |
||||
|
|
||||
|
mActionBar.pack_end(mButtonClose); |
||||
|
mActionBar.pack_end(mButtonSave); |
||||
|
|
||||
|
mBox.add(mFrameSettings); |
||||
|
mBox.add(mActionBar); |
||||
|
|
||||
|
mBox.show_all(); |
||||
|
add(mBox); |
||||
|
} |
||||
|
|
||||
|
SettingsWindow::~SettingsWindow() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
bool SettingsWindow::onKeyPressed(GdkEventKey *event) |
||||
|
{ |
||||
|
if (event->keyval == GDK_KEY_Escape) |
||||
|
{ |
||||
|
close(); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
void SettingsWindow::onClosePressed() |
||||
|
{ |
||||
|
close(); |
||||
|
} |
||||
|
|
||||
|
void SettingsWindow::onSavePressed() |
||||
|
{ |
||||
|
} |
||||
|
|
@ -0,0 +1,32 @@ |
|||||
|
#ifndef SCREEN_RECORDER_SETTINGS_WINDOW_HPP
|
||||
|
#define SCREEN_RECORDER_SETTINGS_WINDOW_HPP
|
||||
|
|
||||
|
#include <gtkmm.h>
|
||||
|
#include "obs-manager.hpp"
|
||||
|
|
||||
|
class SettingsWindow : public Gtk::Window |
||||
|
{ |
||||
|
public: |
||||
|
SettingsWindow(OBSManager *obs); |
||||
|
virtual ~SettingsWindow(); |
||||
|
private: |
||||
|
Gtk::Box mBox; |
||||
|
Gtk::Frame mFrameSettings; |
||||
|
Gtk::Box mBoxSettings; |
||||
|
Gtk::Box mBoxPluginDir; |
||||
|
Gtk::Label mLabelPluginDir; |
||||
|
Gtk::Entry mEntryPluginDir; |
||||
|
Gtk::Box mBoxOutputDir; |
||||
|
Gtk::Label mLabelOutputDir; |
||||
|
Gtk::Entry mEntryOutputDir; |
||||
|
|
||||
|
Gtk::ActionBar mActionBar; |
||||
|
Gtk::Button mButtonClose; |
||||
|
Gtk::Button mButtonSave; |
||||
|
|
||||
|
bool onKeyPressed(GdkEventKey* event); |
||||
|
void onClosePressed(); |
||||
|
void onSavePressed(); |
||||
|
}; |
||||
|
|
||||
|
#endif
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue