Skip to content
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
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ set(CMAKE_CXX_EXTENSIONS OFF)
option(OPENMOQ_BUILD_TESTS "Build OpenMOQ publisher tests" ON)
option(OPENMOQ_ENABLE_PICOQUIC "Enable picoquic transport integration when picoquic is available" ON)
option(OPENMOQ_RUN_PICOQUIC_SMOKE_TESTS "Build and run picoquic loopback smoke tests" OFF)
option(OPENMOQ_ENABLE_SRT "Enable libsrt ingest support when libsrt is available" ON)

set(OPENMOQ_HAS_SRT OFF)
if(OPENMOQ_ENABLE_SRT)
find_path(OPENMOQ_SRT_INCLUDE_DIR NAMES srt/srt.h)
find_library(OPENMOQ_SRT_LIBRARY NAMES srt)
if(OPENMOQ_SRT_INCLUDE_DIR AND OPENMOQ_SRT_LIBRARY)
set(OPENMOQ_HAS_SRT ON)
else()
message(STATUS "libsrt not found; building without SRT ingest runtime")
endif()
endif()

set(_OPENMOQ_THIRDPARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/third_party")
if(NOT EXISTS "${_OPENMOQ_THIRDPARTY_ROOT}")
Expand Down Expand Up @@ -134,6 +146,8 @@ add_library(openmoq_publisher_lib
src/cli_options.cpp
src/cmaf_segmenter.cpp
src/cmsf_packager.cpp
src/live_srt_ingest.cpp
src/live_srt_config.cpp
src/moq_draft.cpp
src/mp4_box.cpp
src/publisher_api.cpp
Expand Down Expand Up @@ -169,6 +183,12 @@ if(OPENMOQ_HAS_PICOQUIC)
endif()
endif()

if(OPENMOQ_HAS_SRT)
target_compile_definitions(openmoq_publisher_lib PRIVATE OPENMOQ_HAS_SRT=1)
target_include_directories(openmoq_publisher_lib PRIVATE ${OPENMOQ_SRT_INCLUDE_DIR})
target_link_libraries(openmoq_publisher_lib PRIVATE ${OPENMOQ_SRT_LIBRARY})
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(openmoq_publisher_lib PRIVATE -Wall -Wextra -Wpedantic)
elseif(MSVC)
Expand Down Expand Up @@ -198,6 +218,12 @@ if(OPENMOQ_BUILD_TESTS)
target_link_libraries(openmoq-publisher-cli-tests PRIVATE openmoq_publisher_lib)
add_test(NAME openmoq-publisher-cli-tests COMMAND openmoq-publisher-cli-tests)

add_executable(openmoq-publisher-live-srt-config-tests
tests/live_srt_config_test.cpp
)
target_link_libraries(openmoq-publisher-live-srt-config-tests PRIVATE openmoq_publisher_lib)
add_test(NAME openmoq-publisher-live-srt-config-tests COMMAND openmoq-publisher-live-srt-config-tests)

add_executable(openmoq-publisher-transport-tests
tests/moqt_session_test.cpp
)
Expand Down
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,91 @@ OPENMOQ_PICOQUIC_TRACE=1 ./build/openmoq-publisher \
--paced
```

Live ingest examples (choose one path, not both):

1. SRT ingest path (`--live-source srt`)

Create an SRT config file (example: `/tmp/srt_callers.json`):

```json
{
"srt_callers": [
{
"id": "cam1",
"srt": {
"mode": "caller",
"host": "127.0.0.1",
"port": 9000,
"latency_ms": 120
},
"mpegts": {
"auto_detect_program": true,
"program_number": null,
"video_pid": null,
"audio_pid": null
},
"cmaf": {
"fragment_on_keyframe": true,
"empty_moov": true,
"default_base_moof": true,
"separate_moof_per_track": true,
"target_fragment_duration_ms": 1000
}
}
]
}
```

Start the publisher (SRT receiver + MoQ publisher):

```bash
./build/openmoq-publisher \
--live-source srt \
--srt-config /tmp/srt_callers.json \
--endpoint 127.0.0.1:4443 \
--transport raw \
--namespace live \
--draft 16 \
--timeout 120 \
--forward 0
```

Feed MPEG-TS over SRT from ffmpeg:

```bash
ffmpeg -hide_banner -stream_loop -1 -re \
-i /home/ubuntu/bbb_sunflower_1080p_30fps_normal.mp4 \
-filter_complex "[0:v]drawtext=fontcolor=white:fontsize=36:box=1:boxcolor=black@0.45:boxborderw=8:x=w-tw-20:y=20:text='%{localtime\\:%Y-%m-%d %T}\\:%{eif\\:mod(t*1000\\,1000)\\:d\\:3}'[vclock]" \
-map "[vclock]" -map 0:a:0 \
-c:v libx265 -preset veryfast -r 30 -g 60 -keyint_min 60 -bf 0 \
-x265-params "keyint=60:min-keyint=60:scenecut=0:open-gop=0:repeat-headers=1" \
-c:a aac -b:a 160k -ar 48000 -ac 2 \
-f mpegts "srt://0.0.0.0:9000?mode=listener&pkt_size=1316"
```

2. stdin fragmented-MP4 path (`--live-source stdin`)

```bash
ffmpeg -i /home/ubuntu/bbb_sunflower_1080p_30fps_normal.mp4 \
-map 0:v:0 -map 0:a:0 \
-map_metadata -1 \
-sn -dn \
-c:v libx264 -preset medium -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -bf 0 \
-c:a aac -b:a 160k -ar 48000 -ac 2 \
-movflags +frag_keyframe+empty_moov+default_base_moof+separate_moof \
-f mp4 - | ./build/openmoq-publisher \
--live-source stdin \
--input - \
--endpoint 127.0.0.1:4443 \
--transport raw \
--namespace live \
--draft 16 \
--timeout 120 \
--forward 0
```

`--live-source both` is intentionally not supported.

On Windows, replace `./build/openmoq-publisher` with `build\Release\openmoq-publisher.exe` or the matching build configuration path.

## Documentation
Expand Down
Loading
Loading