Files
cuframes-composer/src/CMakeLists.txt
T
gx 75271436f7 Phase 11b: MQTT-overlays конфигурируются через JSON (вместо --temp-topic)
User: "оверлеев которые выводят какую-то инфу из MQTT может быть
бесконечно много. Надо делать настраиваемым через json/yaml конфиг".

Заменили захардкоженный TempMqttOverlay на generic MqttOverlay:

  - cpp/mqtt_overlay.hpp/.cpp: класс MqttOverlayItem (один topic + один
    text overlay) + MqttOverlayManager (контейнер). Загрузка из JSON.
  - cpp/mqtt_overlay_c_api.cpp: extern "C" обёртка для grid_record.c.
  - docker/mqtt_overlays.json: default config с temp_outside примером.
  - grid_record.c: --mqtt-overlays=PATH (заменил --temp-topic).
  - src/CMakeLists.txt: temp_overlay* удалены, mqtt_overlay* добавлены.

JSON schema:
  {
    "overlays": [
      {
        "id": "temp_outside",
        "topic": "zigbee2mqtt/Температура на улице",
        "json_field": "temperature",      // пусто = raw payload string
        "format": "%+.1f°C",                // printf
        "anchor": "right-bottom",           // right-top, left-bottom, ...
        "margin_x": 32, "margin_y": 24,
        "pixel_size": 32,
        "color": [255, 255, 255], "alpha": 230,
        "font_path": "/fonts/DejaVuSans-Bold.ttf"
      }
    ]
  }

MqttBrokerCfg делятся между всеми overlays (one connect_async per item
но shared credentials). Добавление новых overlays = редактирование JSON +
restart cfc-grid (hot-reload через ZMQ — Phase 12).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 10:07:05 +01:00

119 lines
4.4 KiB
CMake
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Основная библиотека композитора — `libcuframes_composer.so`. Содержит:
# - source.c подписка к cuframes публишеру + state machine
# - nvenc_loader.c dlopen libnvidia-encode.so + загрузка API таблицы
# - nvenc.c обвязка вокруг NVENC SDK (init/encode/teardown)
# - composer.c Phase 2: multi-source grid композитор
# - cugrid/cugrid.cu Phase 2: CUDA kernels (resize, fill) для NV12 grid'а
#
# Дальше по фазам:
# Phase 3: overlay.c, png_decode.c, text_render.c, rtsp_publisher.c, rtp_h264.c
# Phase 4: control_zmq.c
# Phase 5: health_mqtt.c
set(COMPOSER_SOURCES_C
source.c
nvenc_loader.c
nvenc.c
overlay.c
control.c
health.c
writer.c
audio.c
frigate_mqtt.c
)
# Phase 11b — C++ ООП-модель Cell/Layout/Decoration/Composer + ABI shim.
# Заменяет composer.c и layouts.c из Phase 10/11. Старые callers (control.c,
# frigate_mqtt.c, examples/grid_record.c) продолжают использовать те же
# cfc_composer_* и cfc_layout_* функции — они теперь обёртки над C++ ядром.
set(COMPOSER_SOURCES_CPP
cpp/label_decoration.cpp
cpp/border_decoration.cpp
cpp/camera_cell.cpp
cpp/widget_cell.cpp
cpp/blank_cell.cpp
cpp/source_pool.cpp
cpp/layout.cpp
cpp/template_loader.cpp
cpp/composer.cpp
cpp/composer_c_api.cpp
cpp/layouts_c_api.cpp
cpp/mqtt_overlay.cpp
cpp/mqtt_overlay_c_api.cpp
)
set(COMPOSER_SOURCES_CU
cugrid/cugrid.cu
)
add_library(cuframes_composer SHARED
${COMPOSER_SOURCES_C} ${COMPOSER_SOURCES_CPP} ${COMPOSER_SOURCES_CU})
add_library(cuframes_composer_static STATIC
${COMPOSER_SOURCES_C} ${COMPOSER_SOURCES_CPP} ${COMPOSER_SOURCES_CU})
foreach(target cuframes_composer cuframes_composer_static)
target_include_directories(${target}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${NVCODEC_HEADERS_DIR}
)
target_compile_features(${target} PRIVATE c_std_11 cxx_std_17)
# C-only флаги (для CUDA свои дефолты, -Wpedantic не подходит для .cu).
target_compile_options(${target} PRIVATE
$<$<COMPILE_LANGUAGE:C>:-Wall>
$<$<COMPILE_LANGUAGE:C>:-Wextra>
$<$<COMPILE_LANGUAGE:C>:-Wpedantic>
$<$<COMPILE_LANGUAGE:CXX>:-Wall>
$<$<COMPILE_LANGUAGE:CXX>:-Wextra>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:Debug>>:-O0>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:Debug>>:-g3>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:Release>>:-O2>
$<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:Release>>:-g>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Release>>:-O2>
$<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:Release>>:-g>
)
target_link_libraries(${target}
PUBLIC
cuframes_static # из third_party/cuframes
CUDA::cudart
CUDA::cuda_driver
Threads::Threads
${LIBDL_LIBRARY} # для dlopen libnvidia-encode.so
PNG::PNG # для PNG overlay'ев (Phase 3b)
Freetype::Freetype # для text overlay'ев (Phase 3c)
${LIBZMQ_LIBRARY} # для control plane (Phase 4a)
${LIBJSONC_LIBRARY} # для control plane JSON (Phase 4a)
${LIBMOSQUITTO_LIBRARY} # для MQTT health (Phase 4b)
PkgConfig::LIBAV # для mpegts writer (Phase 7)
rt
)
target_include_directories(${target} PRIVATE
${LIBZMQ_INCLUDE_DIR}
${LIBJSONC_INCLUDE_DIR}
${LIBMOSQUITTO_INCLUDE_DIR}
)
# CUDA properties.
set_target_properties(${target} PROPERTIES
CUDA_SEPARABLE_COMPILATION OFF
)
endforeach()
set_target_properties(cuframes_composer PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION 0
)
# Install rules
include(GNUInstallDirs)
install(TARGETS cuframes_composer cuframes_composer_static
EXPORT cuframesComposerTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/cuframes_composer
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)