Skip to content

Commit 1f70df4

Browse files
- Added option to change priority
- Update Readme.md - Cleanup
1 parent 8455a87 commit 1f70df4

16 files changed

+299
-129
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
[submodule "external/obs-studio"]
2-
path = external/obs-studio
3-
url = https://github.com/obsproject/obs-studio
41
[submodule "external/flatbuffers"]
52
path = external/flatbuffers
63
url = https://github.com/google/flatbuffers

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools"
3+
}

CMakeLists.txt

Lines changed: 98 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,89 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(hyperion-obs)
3-
include(GNUInstallDirs)
3+
4+
# Macro to get path of first sub dir of a dir, used for MAC OSX lib/header searching
5+
MACRO(FIRSTSUBDIR result curdir)
6+
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
7+
SET(dirlist "")
8+
FOREACH(child ${children})
9+
IF(IS_DIRECTORY ${curdir}/${child})
10+
LIST(APPEND dirlist "${curdir}/${child}")
11+
BREAK()
12+
ENDIF()
13+
ENDFOREACH()
14+
SET(${result} ${dirlist})
15+
ENDMACRO()
416

517
set(CMAKE_CXX_STANDARD 11)
6-
set(CMAKE_PREFIX_PATH "${QTDIR}")
718
set(CMAKE_AUTOMOC ON)
819
set(CMAKE_AUTOUIC ON)
920

10-
set(LIBOBS_INCLUDE_DIR "external/obs-studio/libobs")
11-
include(cmake/FindLibObs.cmake)
21+
if(UNIX)
22+
include(GNUInstallDirs)
23+
endif()
24+
25+
# Add project specific cmake modules (find, etc)
26+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
27+
28+
# enable C++11; MSVC doesn't have c++11 feature switch
29+
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
30+
include(CheckCXXCompilerFlag)
31+
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
32+
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
33+
34+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
35+
if (CMAKE_COMPILER_IS_GNUCXX)
36+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")
37+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-psabi")
38+
endif()
39+
if(COMPILER_SUPPORTS_CXX11)
40+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
41+
elseif(COMPILER_SUPPORTS_CXX0X)
42+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
43+
else()
44+
message(STATUS "No support for C++11 detected. Compilation will most likely fail on your compiler")
45+
endif()
46+
endif()
47+
48+
# MSVC options
49+
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
50+
if (NOT DEFINED ENV{Qt5_BASE_DIR})
51+
FIRSTSUBDIR(SUBDIRQT "C:/Qt")
52+
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "${SUBDIRQT}/msvc2019_64")
53+
else()
54+
message(STATUS "Qt5_BASE_DIR: $ENV{Qt5_BASE_DIR}")
55+
message(STATUS "Add Qt5_BASE_DIR: $ENV{Qt5_BASE_DIR} to CMAKE_PREFIX_PATH")
56+
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "$ENV{Qt5_BASE_DIR}")
57+
endif()
58+
59+
if (NOT DEFINED ENV{Qt5_DIR})
60+
if (NOT DEFINED ENV{Qt5_BASE_DIR})
61+
SET (qt_module_path "${SUBDIRQT}/msvc2019_64/lib/cmake/Qt5")
62+
else ()
63+
SET (qt_module_path "$ENV{Qt5_BASE_DIR}/lib/cmake/Qt5")
64+
endif()
65+
else()
66+
SET (qt_module_path "$ENV{Qt5_DIR}")
67+
endif()
68+
69+
message(STATUS "Add ${qt_module_path} to CMAKE_MODULE_PATH")
70+
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${qt_module_path}")
71+
endif()
1272

13-
find_package(LibObs REQUIRED)
73+
set(OBS_SOURCE "" CACHE STRING "Where is the source code of OBS-Studio located")
74+
set(OBS_BUILD "" CACHE STRING "Where is the build directory of OBS-Studio located")
75+
76+
set(LIBOBS_INCLUDE_DIR "${OBS_SOURCE}/libobs")
77+
set(OBS_FRONTEND_INCLUDE_DIR "${OBS_SOURCE}/UI/obs-frontend-api")
78+
79+
if (WIN32)
80+
set(LibObs_DIR "${OBS_BUILD}/libobs")
81+
set(LIBOBS_LIB "${OBS_BUILD}/libobs/$<CONFIGURATION>/obs.lib")
82+
set(OBS_FRONTEND_LIB "${OBS_BUILD}/UI/obs-frontend-api/$<CONFIGURATION>/obs-frontend-api.lib")
83+
set(PTHREAD_LIB "${OBS_BUILD}/deps/w32-pthreads/$<CONFIGURATION>/w32-pthreads.lib")
84+
endif()
85+
86+
find_package(Libobs REQUIRED)
1487
find_package(Qt5 COMPONENTS Core Widgets Network REQUIRED)
1588

1689
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared flatbuffers library")
@@ -20,6 +93,7 @@ add_subdirectory(external/flatbuffers)
2093
export(TARGETS flatc FILE "${CMAKE_BINARY_DIR}/flatc_export.cmake")
2194
set(FLATBUFFERS_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/external/flatbuffers/include")
2295
set(FLATBUFFERS_FLATC_EXECUTABLE "$<TARGET_FILE:flatc>")
96+
2397
include_directories(
2498
${CMAKE_CURRENT_BINARY_DIR}
2599
${FLATBUFFERS_INCLUDE_DIRS}
@@ -51,17 +125,28 @@ endforeach()
51125

52126
set_source_files_properties(${Flatbuffer_GENERATED_FBS} PROPERTIES GENERATED TRUE)
53127

54-
include_directories("external/obs-studio/UI/obs-frontend-api")
55-
56128
FILE ( GLOB hyperion_obs_SOURCES "${CMAKE_SOURCE_DIR}/src/*.h" "${CMAKE_SOURCE_DIR}/src/*.cpp" )
57129

58130
add_library(${PROJECT_NAME} MODULE
59131
${hyperion_obs_SOURCES}
60132
${Flatbuffer_GENERATED_FBS}
61133
)
62-
134+
135+
include_directories(
136+
${OBS_FRONTEND_INCLUDE_DIR}
137+
${LIBOBS_INCLUDE_DIR}
138+
)
139+
140+
if(UNIX)
141+
target_link_libraries(${PROJECT_NAME} libobs)
142+
endif()
143+
144+
if (WIN32)
145+
target_link_libraries(${PROJECT_NAME} ${PTHREAD_LIB} ${LIBOBS_LIB})
146+
endif()
147+
63148
target_link_libraries(${PROJECT_NAME}
64-
libobs
149+
${OBS_FRONTEND_LIB}
65150
flatbuffers
66151
Qt5::Core
67152
Qt5::Widgets
@@ -76,5 +161,7 @@ endif()
76161

77162
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
78163

79-
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/obs-plugins)
80-
install(DIRECTORY locale/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/hyperion-obs/locale)
164+
if(UNIX)
165+
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/obs-plugins)
166+
install(DIRECTORY locale/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/obs/obs-plugins/hyperion-obs/locale)
167+
endif()

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The idea for this plugin originated from a fork of [Murat Seker][m-seker].
1111

1212
## Usage with hyperion-obs
1313

14-
- Open OBS and select the menu entry `Tools > Hyperion Output`.
14+
- Open OBS and select the menu entry `Tools > Hyperion Streaming`.
1515
- Enter the flatbuffer destination IP and select the appropriate port.
1616
- Click the `Start` button.
1717

@@ -25,13 +25,19 @@ The idea for this plugin originated from a fork of [Murat Seker][m-seker].
2525
sudo apt install qtbase5-dev libobs-dev
2626
```
2727

28+
- Get OBS Studio source code
29+
30+
```
31+
git clone --recursive https://github.com/obsproject/obs-studio.git
32+
```
33+
2834
- Build plugin
2935

3036
```
3137
git clone --recursive https://github.com/hyperion-project/hyperion-obs-plugin.git
3238
cd hyperion-obs-plugin
3339
mkdir build && cd build
34-
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
40+
cmake -DOBS_SOURCE="../../obs-studio" -DCMAKE_INSTALL_PREFIX=/usr ..
3541
make -j $(nproc)
3642
sudo make install
3743
```

external/obs-studio

Lines changed: 0 additions & 1 deletion
This file was deleted.

locale/de-DE.ini

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ UI.Title="Ausgabe an Hyperion"
33
UI.AutoStart="Starte automatisch"
44
UI.AutoStartTip="Starte den Stream mit dem OBS-Start."
55
UI.Address="Adresse"
6-
UI.AddressTip="Der Hostname oder die IP-Adresse (IPv4/IPv6) desr Hyperion-Servers."
7-
UI.PortTip="Der beim Hyperion Server konfigurierte Flatbufferport [Default:19400]."
6+
UI.AddressTip="Der Hostname oder die IP-Adresse (IPv4/IPv6) des Hyperion-Servers."
7+
UI.PortTip="Der beim Hyperion Server konfigurierte Flatbufferport [Standard:19400]."
8+
UI.Priority="Priorität"
9+
UI.PriorityTip="Mit welche Priorität der Stream beim Hyperion-Server empfangen wird [Standard:150]"
810
UI.SizeDecimation="Ausgabereduzierungsfaktor"
911
UI.SizeDecimationTip="Bildverkleinerung (Faktor) ausgehend von der ursprünglichen Größe. 1 für die unveränderte/ursprüngliche Größe."
1012
UI.StartTip="Starte Ausgabe an Hyperion"

locale/en-GB.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ UI.AutoStart="Auto start"
44
UI.AutoStartTip="Start streaming when OBS is started."
55
UI.Address="Address"
66
UI.AddressTip="The hostname or IP-address (IPv4 or IPv6) of the Hyperion server."
7-
UI.PortTip="The Flatbuffer port as configured at the Hyperion Server [default:19400]."
7+
UI.PortTip="The Flatbuffer port as configured at the Hyperion Server [Default:19400]."
8+
UI.Priority="Priority"
9+
UI.PriorityTip="With which priority the stream is received at the Hyperion server [Default:150]"
810
UI.SizeDecimation="Output Decimation"
911
UI.SizeDecimationTip="Scale the output image down by decimation factor. 1 means no decimation (keep original size)."
1012
UI.StartTip="Start streaming to Hyperion"

locale/en-US.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ UI.AutoStart="Auto start"
44
UI.AutoStartTip="Start streaming when OBS is started."
55
UI.Address="Address"
66
UI.AddressTip="The hostname or IP-address (IPv4 or IPv6) of the Hyperion server."
7-
UI.PortTip="The Flatbuffer port as configured at the Hyperion Server [default:19400]."
7+
UI.PortTip="The Flatbuffer port as configured at the Hyperion Server [Default:19400]."
8+
UI.Priority="Priority"
9+
UI.PriorityTip="With which priority the stream is received at the Hyperion server [Default:150]"
810
UI.SizeDecimation="Output Decimation"
911
UI.SizeDecimationTip="Scale the output image down by decimation factor. 1 means no decimation (keep original size)."
1012
UI.StartTip="Start streaming to Hyperion"

screenshot/hyperion-obs.png

14.8 KB
Loading

src/FlatBufferConnection.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,19 @@ void FlatBufferConnection::readData()
6969
const hyperionnet::Reply* reply = hyperionnet::GetReply(msgData);
7070
if (!parseReply(reply))
7171
{
72-
qDebug() << "Reply received with error: " << reply->error();
73-
_socket.close();
72+
struct calldata call_data;
73+
calldata_init(&call_data);
74+
calldata_set_string(&call_data, "msg", QSTRING_CSTR(QString("Reply received with error: %1").arg(reply->error()->c_str())));
75+
calldata_set_bool(&call_data, "running", true);
76+
signal_handler_t *handler = hyperion_get_signal_handler();
77+
signal_handler_signal(handler, "stop", &call_data);
78+
calldata_free(&call_data);
79+
delete this;
7480
}
7581
continue;
7682
}
7783

78-
qDebug() << "Unable to parse reply";
84+
emit logMessage("Unable to parse reply");
7985
}
8086
}
8187

@@ -128,13 +134,13 @@ void FlatBufferConnection::sendMessage(const uint8_t* buffer, uint32_t size)
128134
switch (_socket.state() )
129135
{
130136
case QAbstractSocket::UnconnectedState:
131-
emit logMessage(QString("No connection to Hyperion: %1 %2").arg(_host).arg(_port));
137+
emit logMessage(QString("No connection to Hyperion: %1:%2").arg(_host).arg(_port));
132138
break;
133139
case QAbstractSocket::ConnectedState:
134-
emit logMessage(QString("Connected to Hyperion: %1 %2").arg(_host).arg(_port));
140+
emit logMessage(QString("Connected to Hyperion: %1:%2").arg(_host).arg(_port));
135141
break;
136142
default:
137-
emit logMessage(QString("Connecting to Hyperion: %1 %2").arg(_host).arg(_port));
143+
emit logMessage(QString("Connecting to Hyperion: %1:%2").arg(_host).arg(_port));
138144
break;
139145
}
140146
_prevSocketState = _socket.state();
@@ -195,6 +201,9 @@ void FlatBufferConnection::disconnected()
195201
signal_handler_t *handler = hyperion_get_signal_handler();
196202
signal_handler_signal(handler, "stop", &call_data);
197203
calldata_free(&call_data);
204+
205+
_timer.stop();
206+
_socket.close();
198207
}
199208

200209
void FlatBufferConnection::logMessage(const QString& message)

0 commit comments

Comments
 (0)