| Crates.io | hang-c |
| lib.rs | hang-c |
| version | 0.7.0 |
| created_at | 2025-11-29 20:54:35.149928+00 |
| updated_at | 2025-11-29 20:54:35.149928+00 |
| description | Media over QUIC, C Interface |
| homepage | |
| repository | https://github.com/kixelated/moq |
| max_upload_size | |
| id | 1957486 |
| size | 92,812 |
C bindings for the hang Media over QUIC library.
cargo build --release
This will:
libhang.dylib on macOS, libhang.so on Linux, hang.dll on Windows)target/include/hang.htarget/hang.pcThe library is built as a cdylib by default. To build as a static library, edit Cargo.toml and change:
crate-type = ["cdylib"]
to:
crate-type = ["staticlib"]
add_subdirectory(path/to/hang-c)
target_link_libraries(your_target PRIVATE hang::hang)
find_package(hang REQUIRED)
target_link_libraries(your_target PRIVATE hang::hang)
BUILD_RUST_LIB (default: ON) - Build the Rust library using cargoRUST_LIB_DIR - Directory containing pre-built library (when BUILD_RUST_LIB=OFF)RUST_HEADER_DIR - Directory containing header files (when BUILD_RUST_LIB=OFF)After installation, you can use pkg-config:
pkg-config --cflags hang
pkg-config --libs hang
In your build system:
CFLAGS += $(shell pkg-config --cflags hang)
LDFLAGS += $(shell pkg-config --libs hang)
The library exposes the following C functions (see hang.h for full details):
hang_start_from_cvoid hang_start_from_c(const char *c_server_url, const char *c_path, const char *_c_profile);
Start the MoQ client and connect to a server.
Safety: The caller must ensure that c_server_url and c_path are valid null-terminated C strings.
hang_stop_from_cvoid hang_stop_from_c(void);
Stop the MoQ client.
hang_write_video_packet_from_cvoid hang_write_video_packet_from_c(const uint8_t *data, uintptr_t size, int32_t keyframe, uint64_t dts);
Write a video packet to the stream.
Safety: The caller must ensure that data points to a valid buffer of at least size bytes.
#include <hang.h>
int main() {
// Start the client
hang_start_from_c("https://localhost:4443", "mybroadcast", NULL);
// Send video packets
uint8_t packet_data[1024] = {/* ... */};
hang_write_video_packet_from_c(packet_data, sizeof(packet_data), 1, 0);
// Stop the client
hang_stop_from_c();
return 0;
}
cd rs/hang-c
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --install .
This will install:
/usr/local/include/hang.h/usr/local/lib/libhang.{dylib,so,dll}/usr/local/lib/cmake/hang//usr/local/lib/pkgconfig/hang.pc (if installed manually)# Build the library
cargo build --release
# Copy header
sudo cp target/include/hang.h /usr/local/include/
# Copy library
sudo cp target/release/libhang.{dylib,so,dll} /usr/local/lib/
# Copy and configure pkg-config file
sed 's|@PREFIX@|/usr/local|g; s|@VERSION@|0.6.1|g' hang.pc.in > hang.pc
sudo cp hang.pc /usr/local/lib/pkgconfig/
CC = gcc
CFLAGS = -I../../target/include
LDFLAGS = -L../../target/release -lhang
myapp: myapp.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
hang_dep = dependency('hang')
executable('myapp', 'myapp.c', dependencies: hang_dep)
hang_write_video_packet_from_c