Skip to main content

moq_decode_video

Function moq_decode_video 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn moq_decode_video( catalog: u32, index: u32, output: *const moq_video_decoder_output, on_frame: moq_status_callback, user_data: *mut c_void, ) -> i32
Expand description

Subscribe to a video track and decode it into raw frames in the requested CPU pixel format and size (see moq_video_decoder_output).

The catalog index selects which video rendition to subscribe to, matching the existing moq_consume_video selection model. Only H.264 is supported; a non-H.264 rendition fails on the terminal callback.

An unknown output->format or an invalid output->width/height fails here, before subscribing: an accepted request always produces the requested layout or fails on the terminal callback instead of delivering it silently.

Returns a non-zero handle on success or a negative error code.

on_frame is called with a positive frame id per decoded frame, then exactly once more with a terminal code: 0 (closed cleanly) or a negative error. After the terminal (<= 0) callback, on_frame is never called again and user_data is never touched again, so release user_data there. The terminal callback fires even after moq_decode_video_cancel.

Starts at the newest cached group so reopening live playback skips the backlog.

ยงSafety

  • output must point to a valid moq_video_decoder_output.
  • user_data must stay valid until the terminal (<= 0) on_frame callback.