Skip to content

Commit c43f5ef

Browse files
committed
One last rename.
1 parent 5f5a59a commit c43f5ef

File tree

5 files changed

+35
-31
lines changed

5 files changed

+35
-31
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rs/libmoq/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
[package]
22
name = "libmoq"
33
description = "Media over QUIC, C bindings"
4-
authors = ["Luke Curley <[email protected]>", "Brian Medley <[email protected]>"]
4+
authors = [
5+
"Luke Curley <[email protected]>",
6+
"Brian Medley <[email protected]>",
7+
]
58
repository = "https://github.com/moq-dev/moq"
69
license = "MIT OR Apache-2.0"
710

8-
version = "0.1.2"
11+
version = "0.2.0"
912
edition = "2021"
1013

1114
keywords = ["quic", "http3", "webtransport", "media", "live"]

rs/libmoq/src/api.rs

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -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

rs/libmoq/src/consume.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl Consume {
167167
Ok(())
168168
}
169169

170-
pub fn video_track(
170+
pub fn video_ordered(
171171
&mut self,
172172
catalog: Id,
173173
index: usize,
@@ -198,7 +198,7 @@ impl Consume {
198198
Ok(id)
199199
}
200200

201-
pub fn audio_track(
201+
pub fn audio_ordered(
202202
&mut self,
203203
catalog: Id,
204204
index: usize,
@@ -255,12 +255,12 @@ impl Consume {
255255
Ok(())
256256
}
257257

258-
pub fn audio_track_close(&mut self, track: Id) -> Result<(), Error> {
258+
pub fn audio_close(&mut self, track: Id) -> Result<(), Error> {
259259
self.audio_task.remove(track).ok_or(Error::NotFound)?;
260260
Ok(())
261261
}
262262

263-
pub fn video_track_close(&mut self, track: Id) -> Result<(), Error> {
263+
pub fn video_close(&mut self, track: Id) -> Result<(), Error> {
264264
self.video_task.remove(track).ok_or(Error::NotFound)?;
265265
Ok(())
266266
}

rs/libmoq/src/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl Publish {
2929
Ok(())
3030
}
3131

32-
pub fn media_init(&mut self, broadcast: Id, format: &str, mut init: &[u8]) -> Result<Id, Error> {
32+
pub fn media_ordered(&mut self, broadcast: Id, format: &str, mut init: &[u8]) -> Result<Id, Error> {
3333
let broadcast = self.broadcasts.get(broadcast).ok_or(Error::NotFound)?;
3434
let mut decoder = hang::import::Decoder::new(broadcast.clone(), format)
3535
.ok_or_else(|| Error::UnknownFormat(format.to_string()))?;

0 commit comments

Comments
 (0)