Skip to main content

moq_decode_audio

Function moq_decode_audio 

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

Subscribe to an audio track and decode it into PCM.

The catalog index identifies which audio rendition to subscribe to, matching the existing moq_consume_audio selection model. TODO: a future API will pick the right rendition automatically (ABR).

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

on_frame is called with a positive frame ID per 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_audio_cancel.

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

A packet the codec cannot decode is logged and skipped rather than ending the subscription, so a single bad frame costs that frame and not the stream.

ยงSafety

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