@@ -61,10 +61,10 @@ pub struct moq_frame {
6161 pub payload : * const u8 ,
6262 pub payload_size : usize ,
6363
64- // The presentation timestamp of the frame in microseconds
64+ /// The presentation timestamp of the frame in microseconds
6565 pub timestamp_us : u64 ,
6666
67- /// Whether the frame is a keyframe (meaningless for audio)
67+ /// Whether the frame is a keyframe, aka the start of a new group.
6868 pub keyframe : bool ,
6969}
7070
@@ -293,17 +293,18 @@ pub extern "C" fn moq_publish_close(broadcast: i32) -> i32 {
293293 } )
294294}
295295
296- /// Create a new track for a broadcast.
296+ /// Create a new media track for a broadcast
297297///
298- /// The encoding of `init` depends on the `format` string.
298+ /// All frames in [moq_publish_media_frame] must be written in decode order.
299+ /// The `format` controls the encoding, both of `init` and frame payloads.
299300///
300301/// Returns a non-zero handle to the track on success, or a negative code on failure.
301302///
302303/// # Safety
303304/// - The caller must ensure that format is a valid pointer to format_len bytes of data.
304305/// - The caller must ensure that init is a valid pointer to init_size bytes of data.
305306#[ no_mangle]
306- pub unsafe extern "C" fn moq_publish_media_init (
307+ pub unsafe extern "C" fn moq_publish_media_ordered (
307308 broadcast : i32 ,
308309 format : * const c_char ,
309310 format_len : usize ,
@@ -315,7 +316,7 @@ pub unsafe extern "C" fn moq_publish_media_init(
315316 let format = unsafe { ffi:: parse_str ( format, format_len) ? } ;
316317 let init = unsafe { ffi:: parse_slice ( init, init_size) ? } ;
317318
318- state. publish . media_init ( broadcast, format, init)
319+ state. publish . media_ordered ( broadcast, format, init)
319320 } )
320321}
321322
@@ -425,77 +426,77 @@ pub unsafe extern "C" fn moq_consume_audio_config(catalog: i32, index: i32, dst:
425426 } )
426427}
427428
428- /// Consume a video track from a broadcast.
429+ /// Consume a video track from a broadcast, delivering frames in order .
429430///
430- /// - `max_buffer_ms ` controls the maximum amount of buffering allowed before skipping a GoP.
431+ /// - `max_latency_ms ` controls the maximum amount of buffering allowed before skipping a GoP.
431432/// - `on_frame` is called with a frame ID when a new frame is available.
432433///
433434/// Returns a non-zero handle to the track on success, or a negative code on failure.
434435///
435436/// # Safety
436437/// - The caller must ensure that `on_frame` is valid until [moq_consume_video_track_close] is called.
437438#[ no_mangle]
438- pub unsafe extern "C" fn moq_consume_video_track (
439+ pub unsafe extern "C" fn moq_consume_video_ordered (
439440 broadcast : i32 ,
440441 index : i32 ,
441- max_buffer_ms : u64 ,
442+ max_latency_ms : u64 ,
442443 on_frame : Option < extern "C" fn ( user_data : * mut c_void , frame : i32 ) > ,
443444 user_data : * mut c_void ,
444445) -> i32 {
445446 State :: enter ( move |state| {
446447 let broadcast = ffi:: parse_id ( broadcast) ?;
447448 let index = index as usize ;
448- let max_buffer = std:: time:: Duration :: from_millis ( max_buffer_ms ) ;
449+ let max_latency = std:: time:: Duration :: from_millis ( max_latency_ms ) ;
449450 let on_frame = ffi:: OnStatus :: new ( user_data, on_frame) ;
450- state. consume . video_track ( broadcast, index, max_buffer , on_frame)
451+ state. consume . video_ordered ( broadcast, index, max_latency , on_frame)
451452 } )
452453}
453454
454455/// Close a video track consumer and clean up its resources.
455456///
456457/// Returns a zero on success, or a negative code on failure.
457458#[ no_mangle]
458- pub extern "C" fn moq_consume_video_track_close ( track : i32 ) -> i32 {
459+ pub extern "C" fn moq_consume_video_close ( track : i32 ) -> i32 {
459460 State :: enter ( move |state| {
460461 let track = ffi:: parse_id ( track) ?;
461- state. consume . video_track_close ( track)
462+ state. consume . video_close ( track)
462463 } )
463464}
464465
465- /// Consume an audio track from a broadcast.
466+ /// Consume an audio track from a broadcast, emitting the frames in order .
466467///
467468/// The callback is called with a frame ID when a new frame is available.
468- /// The latency_ms parameter controls how much buffering to apply .
469+ /// The `max_latency_ms` parameter controls how long to wait before skipping frames .
469470///
470471/// Returns a non-zero handle to the track on success, or a negative code on failure.
471472///
472473/// # Safety
473- /// - The caller must ensure that `on_frame` is valid until [moq_consume_audio_track_close ] is called.
474+ /// - The caller must ensure that `on_frame` is valid until [moq_consume_audio_close ] is called.
474475#[ no_mangle]
475- pub unsafe extern "C" fn moq_consume_audio_track (
476+ pub unsafe extern "C" fn moq_consume_audio_ordered (
476477 broadcast : i32 ,
477478 index : i32 ,
478- latency_ms : u64 ,
479+ max_latency_ms : u64 ,
479480 on_frame : Option < extern "C" fn ( user_data : * mut c_void , frame : i32 ) > ,
480481 user_data : * mut c_void ,
481482) -> i32 {
482483 State :: enter ( move |state| {
483484 let broadcast = ffi:: parse_id ( broadcast) ?;
484485 let index = index as usize ;
485- let latency = std:: time:: Duration :: from_millis ( latency_ms ) ;
486+ let max_latency = std:: time:: Duration :: from_millis ( max_latency_ms ) ;
486487 let on_frame = ffi:: OnStatus :: new ( user_data, on_frame) ;
487- state. consume . audio_track ( broadcast, index, latency , on_frame)
488+ state. consume . audio_ordered ( broadcast, index, max_latency , on_frame)
488489 } )
489490}
490491
491492/// Close an audio track consumer and clean up its resources.
492493///
493494/// Returns a zero on success, or a negative code on failure.
494495#[ no_mangle]
495- pub extern "C" fn moq_consume_audio_track_close ( track : i32 ) -> i32 {
496+ pub extern "C" fn moq_consume_audio_close ( track : i32 ) -> i32 {
496497 State :: enter ( move |state| {
497498 let track = ffi:: parse_id ( track) ?;
498- state. consume . audio_track_close ( track)
499+ state. consume . audio_close ( track)
499500 } )
500501}
501502
0 commit comments