Publish and subscribe over wss://livekit.uni-wh.de:7800 and refuse cleartext ws://. Conference room is uwh-telhai. Includes the uncommitted encoded H.264 publish path, Rally hairpin, and KMS wall overlay.
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
"""ctypes: push pre-encoded AUs into LiveKit VideoSource (pass-through)."""
|
|
from __future__ import annotations
|
|
|
|
import ctypes
|
|
|
|
_CODEC = {"h264": 0, "h265": 1, "vp8": 2, "vp9": 3, "av1": 4}
|
|
|
|
|
|
def capture_encoded(
|
|
video_source,
|
|
payload: bytes,
|
|
width: int,
|
|
height: int,
|
|
keyframe: bool,
|
|
timestamp_us: int = 0,
|
|
codec: str = "h264",
|
|
) -> int:
|
|
from livekit.rtc._ffi_client import FfiClient
|
|
|
|
if not payload:
|
|
return -1
|
|
lib = FfiClient.instance._ffi_lib
|
|
fn = lib.livekit_ffi_capture_encoded
|
|
fn.argtypes = [
|
|
ctypes.c_uint64,
|
|
ctypes.c_void_p,
|
|
ctypes.c_size_t,
|
|
ctypes.c_int32,
|
|
ctypes.c_int32,
|
|
ctypes.c_int32,
|
|
ctypes.c_int64,
|
|
ctypes.c_int32,
|
|
]
|
|
fn.restype = ctypes.c_int32
|
|
handle = int(video_source._ffi_handle.handle)
|
|
buf = (ctypes.c_uint8 * len(payload)).from_buffer_copy(payload)
|
|
return int(
|
|
fn(
|
|
handle,
|
|
ctypes.cast(buf, ctypes.c_void_p),
|
|
len(payload),
|
|
int(width),
|
|
int(height),
|
|
1 if keyframe else 0,
|
|
int(timestamp_us),
|
|
int(_CODEC.get(codec, 0)),
|
|
)
|
|
)
|