Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separated unicapture #128

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 3 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ include_directories(${LS2_INCLUDE_DIRS})
pkg_check_modules(PMLOG REQUIRED PmLogLib)
include_directories(${PMLOG_INCLUDE_DIRS})

add_subdirectory(unicapture)

find_package(Git)
add_custom_target(version
Expand All @@ -48,8 +49,6 @@ add_executable(hyperion-webos
src/main.c
src/settings.c
src/service.c
src/unicapture.c
src/converter.c
src/log.c
src/utils.c
src/hyperion_client.c
Expand All @@ -63,36 +62,6 @@ set_target_properties(hyperion-webos PROPERTIES
# LINK_FLAGS "-Wl,-rpath,'$ORIGIN:$ORIGIN/lib' -Wl,-z,origin"
)
target_include_directories(hyperion-webos PRIVATE ${CMAKE_BINARY_DIR})
target_link_libraries(hyperion-webos fbs flatccrt pthread dl yuv rt ${GTHREAD2_LDFLAGS} ${PBNJSON_LDFLAGS} ${LS2_LDFLAGS} ${GLIB2_LDFLAGS} ${PMLOG_LDFLAGS})
add_dependencies(hyperion-webos version gm_backend dile_vt_backend halgal_backend vtcapture_backend)
target_link_libraries(hyperion-webos fbs flatccrt pthread dl unicapture rt ${GTHREAD2_LDFLAGS} ${PBNJSON_LDFLAGS} ${LS2_LDFLAGS} ${GLIB2_LDFLAGS} ${PMLOG_LDFLAGS})
add_dependencies(hyperion-webos version)
set_property(TARGET hyperion-webos PROPERTY ENABLE_EXPORTS 1)

# "Unified" v2 Backends
add_library(gm_backend SHARED
src/backends/libgm.c
)
target_include_directories(gm_backend PRIVATE src src/backends)
target_link_libraries(gm_backend gm)

add_library(dile_vt_backend SHARED
src/backends/libdile_vt.c
)
target_include_directories(dile_vt_backend PRIVATE src src/backends)
target_link_libraries(dile_vt_backend dile_vt)

# libdile_vt.so seems to be missing DT_NEEDED for libPmLogLib.so.3 - let's just
# add it over to our library. For some reason adding PmLogLib loaded via
# pkgconfig to target_link_libraries doesn't work...
set_target_properties(dile_vt_backend PROPERTIES LINK_FLAGS "-lPmLogLib")

add_library(halgal_backend SHARED
src/backends/libhalgal.c
)
target_include_directories(halgal_backend PRIVATE src src/backends)
target_link_libraries(halgal_backend halgal)

add_library(vtcapture_backend SHARED
src/backends/libvtcapture.cpp
)
target_include_directories(vtcapture_backend PRIVATE src src/backends)
target_link_libraries(vtcapture_backend vtcapture)
39 changes: 39 additions & 0 deletions unicapture/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
add_library(unicapture STATIC
unicapture.c
converter.c
)
set(UNICAPTURE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/../src")
target_include_directories(unicapture PUBLIC ${UNICAPTURE_INCLUDE_DIRS})
target_link_libraries(unicapture PUBLIC yuv)

# "Unified" v2 Backends
add_library(gm_backend SHARED
backends/libgm.c
)
target_include_directories(gm_backend PRIVATE ${UNICAPTURE_INCLUDE_DIRS} backends)
target_link_libraries(gm_backend gm)

add_library(dile_vt_backend SHARED
backends/libdile_vt.c
)
target_include_directories(dile_vt_backend PRIVATE ${UNICAPTURE_INCLUDE_DIRS} backends)
target_link_libraries(dile_vt_backend dile_vt)

# libdile_vt.so seems to be missing DT_NEEDED for libPmLogLib.so.3 - let's just
# add it over to our library. For some reason adding PmLogLib loaded via
# pkgconfig to target_link_libraries doesn't work...
set_target_properties(dile_vt_backend PROPERTIES LINK_FLAGS "-lPmLogLib")

add_library(halgal_backend SHARED
backends/libhalgal.c
)
target_include_directories(halgal_backend PRIVATE ${UNICAPTURE_INCLUDE_DIRS} backends)
target_link_libraries(halgal_backend halgal)

add_library(vtcapture_backend SHARED
backends/libvtcapture.cpp
)
target_include_directories(vtcapture_backend PRIVATE ${UNICAPTURE_INCLUDE_DIRS} backends)
target_link_libraries(vtcapture_backend vtcapture)

add_dependencies(unicapture gm_backend dile_vt_backend halgal_backend vtcapture_backend)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 6 additions & 4 deletions src/unicapture.c → unicapture/unicapture.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,12 @@ void* unicapture_run(void* data)
// Convert frame to suitable video formats
if (ui_frame.pixel_format != PIXFMT_INVALID) {
converter_run(&ui_converter, &ui_frame, &ui_frame_converted,
target_format == PIXFMT_RGB ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
(target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
}

if (video_frame.pixel_format != PIXFMT_INVALID) {
converter_run(&video_converter, &video_frame, &video_frame_converted,
target_format == PIXFMT_RGB ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
(target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) ? PIXFMT_ARGB : PIXFMT_YUV420_SEMI_PLANAR);
}

uint64_t frame_converted = getticks_us();
Expand All @@ -204,7 +204,7 @@ void* unicapture_run(void* data)
const int width = video_frame_converted.width;
const int height = video_frame_converted.height;

if (target_format == PIXFMT_RGB) {
if (target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB) {
blended_frame.planes[0].buffer = realloc(blended_frame.planes[0].buffer, width * height * 4);
blended_frame.planes[0].stride = width * 4;
blended_frame.pixel_format = PIXFMT_ARGB;
Expand Down Expand Up @@ -266,6 +266,8 @@ void* unicapture_run(void* data)
FILE* fd = fopen(filename, "wb");
if (target_format == PIXFMT_RGB)
fwrite(final_frame.planes[0].buffer, 3 * final_frame.width * final_frame.height, 1, fd);
if (target_format == PIXFMT_ARGB)
fwrite(final_frame.planes[0].buffer, 4 * final_frame.width * final_frame.height, 1, fd);
if (target_format == PIXFMT_YUV420_SEMI_PLANAR) {
fwrite(final_frame.planes[0].buffer, final_frame.width * final_frame.height, 1, fd);
fwrite(final_frame.planes[1].buffer, final_frame.width * final_frame.height / 2, 1, fd);
Expand All @@ -274,7 +276,7 @@ void* unicapture_run(void* data)
INFO("Buffer dumped to: %s", filename);
}

if (this->callback != NULL && target_format == PIXFMT_RGB) {
if (this->callback != NULL && (target_format == PIXFMT_RGB || target_format == PIXFMT_ARGB)) {
this->callback(this->callback_data, final_frame.width, final_frame.height, final_frame.planes[0].buffer);
}

Expand Down
File renamed without changes.