Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/carla/bridge/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use bytes::Bytes;
use moq_mux::codec::annexb;
use moq_video::encode::{Encoder, Kind};
use moq_video::frame::vulkan::{self, Device};
use moq_video::{Color, Frame, I420, Rate, Size, Surface};
use moq_video::{Color, Frame, FrameRate, I420, Size, Surface};
use parking_lot::Mutex;

use crate::protocol::{self, Event, Rendition};
Expand Down Expand Up @@ -597,7 +597,7 @@ impl Encoding {
}

fn config(rendition: &Rendition, device: Device) -> Result<moq_video::encode::Config> {
let framerate = Rate::new(rendition.framerate, 1).context("framerate")?;
let framerate = FrameRate::new(rendition.framerate, 1).context("framerate")?;
let mut config = moq_video::encode::Config::new(rendition.width, rendition.height, framerate);
config.bitrate = Some(moq_net::bandwidth::Rate::from_bps(rendition.bitrate));
config.kind = Kind::Named("nvenc".into());
Expand Down
1 change: 0 additions & 1 deletion quest/m1/api-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ Rejected in planning:
- [The origin announces](/quest/m1/api-audit/announce-owner.md) - a broadcast producer cannot announce; the origin hands out the announcement, so `Prepared` and standalone broadcasts lose methods that always fail
- [moq-net exports with a consumer](/quest/m1/api-audit/net-exports.md) - the dead and test-only moq-net, `@moq/net`, and moq-ffi items the follow-up audit found go private or away
- [Bindings read gaps and ends](/quest/m1/api-audit/decode-read-bindings.md) - moq-ffi and every wrapper surface `Gap` and `End` instead of discarding them
- [One frame rate name](/quest/m1/api-audit/frame-rate.md) - core `moq_video::Rate` becomes `FrameRate`, as the bindings name it
- [Pinned consumers adopt the CLI flag names](/quest/m1/api-audit/cli-flags-consumers.md) - pinned downstream deployments move past the flag rename and use its spellings
- [Session-only items stay private](/quest/m1/api-audit/model-private.md) - model items only the built-in sessions use are private
- [Only sessions accept a request](/quest/m1/api-audit/claim-request-type.md) - accepting an application claim's request fails to compile, and the peer-route hatches are crate-private
Expand Down
18 changes: 0 additions & 18 deletions quest/m1/api-audit/frame-rate.md

This file was deleted.

3 changes: 2 additions & 1 deletion rs/moq-boy/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ impl VideoEncoder {

// Game Boy is 160x144; force the openh264 software encoder since hardware
// encoders can reject such tiny resolutions.
let mut config = moq_video::encode::Config::new(WIDTH, HEIGHT, moq_video::Rate::new(FRAMERATE, 1).unwrap());
let mut config =
moq_video::encode::Config::new(WIDTH, HEIGHT, moq_video::FrameRate::new(FRAMERATE, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;

// Probed from a throwaway encoder, before the emulator has run a frame, so a
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-c/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4767,7 +4767,7 @@ fn video_raw_publish_rejects_invalid_config() {
#[test]
fn video_raw_decode() {
// Encode a few gray frames to Annex-B (avc3, SPS/PPS inline on the keyframe).
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
let mut encoder = moq_video::encode::Encoder::new(&config).expect("openh264 encoder");
let gray = vec![0x80u8; 320 * 240 * 4];
Expand Down
6 changes: 3 additions & 3 deletions rs/moq-c/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ pub unsafe extern "C" fn moq_encode_video(

let format = pixel_format_from_u32(raw_input.format)?;

let framerate = moq_video::Rate::new(raw_input.framerate.numerator, raw_input.framerate.denominator)
let framerate = moq_video::FrameRate::new(raw_input.framerate.numerator, raw_input.framerate.denominator)
.map_err(|err| Error::InvalidConfig(format!("invalid framerate: {err}")))?;
let mut config = moq_video::encode::Config::new(raw_input.width, raw_input.height, framerate);
config.codec = codec_from_u32(raw_output.codec)?;
Expand Down Expand Up @@ -1043,7 +1043,7 @@ mod tests {
let catalog = moq_mux::catalog::Producer::new(&mut broadcast, config).unwrap();
let consumer = broadcast.consume();
// Probed rather than hand-built, so the test track carries what a real one would.
let encode = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let encode = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
let rendition = encode.probe().await.unwrap();
let reserved = catalog
.reserve()
Expand Down Expand Up @@ -1087,7 +1087,7 @@ mod tests {
#[tokio::test]
async fn finish_ends_the_track_after_a_rate_follower_panic() {
let (producer, mut track) = track_under_test().await;
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
let encoder = moq_video::encode::Sink::open(&config).await.unwrap();
let followed = crate::ffi::Background::new(async { panic!("injected rate follower panic") });
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-cli/src/play/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ mod tests {
.create_track("video", hang::container::track_info(hang::catalog::PRIORITY.video))
.unwrap();
let mut producer = moq_mux::container::Producer::new(track, Container::Legacy(moq_mux::container::Kind::Data));
let mut config = moq_video::encode::Config::new(64, 64, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(64, 64, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config.gop = moq_video::encode::Gop::Keyframe { interval: 120 };
let mut encoder = moq_video::encode::Encoder::new(&config).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-cli/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ impl CaptureArgs {
config.height = self.height;
config.framerate = self
.fps
.map(|fps| moq_video::Rate::new(fps, 1))
.map(|fps| moq_video::FrameRate::new(fps, 1))
.transpose()
.map_err(anyhow::Error::from)?;
config.cursor = !self.no_cursor;
Expand Down
7 changes: 5 additions & 2 deletions rs/moq-ffi/src/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub struct MoqVideoFrameRate {
pub denominator: u32,
}

impl TryFrom<MoqVideoFrameRate> for moq_video::Rate {
impl TryFrom<MoqVideoFrameRate> for moq_video::FrameRate {
type Error = MoqError;

fn try_from(rate: MoqVideoFrameRate) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -1108,7 +1108,10 @@ mod finish_tests {
&output,
)
.unwrap();
assert_eq!(config.framerate, moq_video::Rate::new(numerator, denominator).unwrap());
assert_eq!(
config.framerate,
moq_video::FrameRate::new(numerator, denominator).unwrap()
);
assert_eq!(config.framerate.denominator(), 1001);
}
for (numerator, denominator) in [(0, 1), (30_000, 0), (1_000_001, 1)] {
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-transcode/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl Rendition {
}

/// The output framerate, inherited from the source.
pub fn framerate(&self) -> Option<moq_video::Rate> {
pub fn framerate(&self) -> Option<moq_video::FrameRate> {
self.0.rung.framerate
}

Expand Down Expand Up @@ -370,7 +370,7 @@ mod tests {
short_side: height,
size: moq_video::Size::new(height * 16 / 9, height),
bitrate: moq_net::bandwidth::Rate::from_bps(100_000),
framerate: Some(moq_video::Rate::new(30, 1).unwrap()),
framerate: Some(moq_video::FrameRate::new(30, 1).unwrap()),
}
}

Expand Down
16 changes: 8 additions & 8 deletions rs/moq-transcode/src/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub(crate) struct Resolved {
/// The output resolution, derived from the source aspect ratio.
pub size: moq_video::Size,
pub bitrate: moq_net::bandwidth::Rate,
pub framerate: Option<moq_video::Rate>,
pub framerate: Option<moq_video::FrameRate>,
}

impl Resolved {
Expand Down Expand Up @@ -284,7 +284,7 @@ pub(crate) fn resolve_rungs(ladder: &Ladder, source_name: &str, source: &VideoCo
let Some((source_width, source_height)) = dimensions(source) else {
return Err(Error::SourceDimensions(source_name.to_string()));
};
let framerate = source.framerate.map(moq_video::Rate::from_f64).transpose()?;
let framerate = source.framerate.map(moq_video::FrameRate::from_f64).transpose()?;

let mut resolved: Vec<Resolved> = Vec::new();
for rung in ladder.rungs() {
Expand Down Expand Up @@ -328,13 +328,13 @@ pub(crate) async fn rung_entry(
source: &VideoConfig,
encoder: &moq_video::encode::Kind,
) -> Result<VideoConfig, Error> {
let encode_rate = rung.framerate.unwrap_or(moq_video::Rate::new(30, 1).unwrap());
let encode_rate = rung.framerate.unwrap_or(moq_video::FrameRate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(rung.size.width, rung.size.height, encode_rate);
config.bitrate = Some(rung.bitrate);
config.kind = encoder.clone();

let mut entry = config.probe().await?;
entry.framerate = rung.framerate.map(moq_video::Rate::as_f64);
entry.framerate = rung.framerate.map(moq_video::FrameRate::as_f64);
// A property of the source rather than the ladder: every rung shows the same picture.
entry.optimize_for_latency = source.optimize_for_latency;
Ok(entry)
Expand Down Expand Up @@ -443,7 +443,7 @@ mod tests {
short_side: 360,
size: moq_video::Size::new(640, 360),
bitrate: moq_net::bandwidth::Rate::from_bps(600_000),
framerate: Some(moq_video::Rate::new(30, 1).unwrap()),
framerate: Some(moq_video::FrameRate::new(30, 1).unwrap()),
},
entry: source(640, 360, Some(600_000)),
}];
Expand Down Expand Up @@ -474,7 +474,7 @@ mod tests {
short_side: 360,
size: moq_video::Size::new(640, 360),
bitrate: moq_net::bandwidth::Rate::from_bps(600_000),
framerate: Some(moq_video::Rate::new(30, 1).unwrap()),
framerate: Some(moq_video::FrameRate::new(30, 1).unwrap()),
},
entry: source(640, 360, Some(600_000)),
}];
Expand Down Expand Up @@ -509,7 +509,7 @@ mod tests {
let resolved = resolve_rungs(&ladder, "video", &fractional).unwrap();
assert_eq!(
resolved[0].framerate,
Some(moq_video::Rate::new(30_000, 1_001).unwrap())
Some(moq_video::FrameRate::new(30_000, 1_001).unwrap())
);

fractional.framerate = None;
Expand Down Expand Up @@ -706,7 +706,7 @@ mod tests {
short_side: 360,
size: moq_video::Size::new(640, 360),
bitrate: moq_net::bandwidth::Rate::from_bps(600_000),
framerate: Some(moq_video::Rate::new(30, 1).unwrap()),
framerate: Some(moq_video::FrameRate::new(30, 1).unwrap()),
};
let mut source = source(1920, 1080, Some(6_000_000));
source.optimize_for_latency = Some(true);
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-transcode/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub enum Error {

/// The source catalog declared an invalid frame rate.
#[error(transparent)]
Framerate(#[from] moq_video::RateError),
Framerate(#[from] moq_video::FrameRateError),

/// Timestamp overflow converting to the moq microsecond timescale.
#[error(transparent)]
Expand Down
12 changes: 6 additions & 6 deletions rs/moq-transcode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ mod tests {
/// to decode while the group is still open.
fn write_keyframe(group: &mut moq_net::group::Producer) {
let mut encoder = moq_video::encode::Encoder::new(&{
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config
})
Expand Down Expand Up @@ -401,7 +401,7 @@ mod tests {
let track = broadcast.create_track("video", info).unwrap();

let mut encoder = moq_video::encode::Encoder::new(&{
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config
})
Expand Down Expand Up @@ -468,7 +468,7 @@ mod tests {

let task = tokio::spawn(async move {
let mut encoder = moq_video::encode::Sink::open(&{
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config
})
Expand Down Expand Up @@ -633,7 +633,7 @@ mod tests {
/// with the NVIDIA driver). Probed through the public API so the hardware
/// test skips cleanly on GPU-less CI.
fn hardware_available() -> bool {
let mut encode = moq_video::encode::Config::new(160, 120, moq_video::Rate::new(30, 1).unwrap());
let mut encode = moq_video::encode::Config::new(160, 120, moq_video::FrameRate::new(30, 1).unwrap());
encode.kind = moq_video::encode::Kind::Hardware;
if moq_video::encode::Encoder::new(&encode).is_err() {
return false;
Expand Down Expand Up @@ -1534,7 +1534,7 @@ mod tests {
// Two frames, so the output's largest moves once both are encoded.
let mut group = source._track.create_group(0u64.into()).unwrap();
let mut encoder = moq_video::encode::Encoder::new(&{
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config
})
Expand Down Expand Up @@ -1625,7 +1625,7 @@ mod tests {
let _source_fetches = source._track.dynamic();

let mut encoder = moq_video::encode::Encoder::new(&{
let mut config = moq_video::encode::Config::new(320, 240, moq_video::Rate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(320, 240, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
config
})
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-transcode/src/rung.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl Rung {
/// worker's initialization and uninitialize COM on one that never initialized
/// it. The sink owns a thread and stays on it.
async fn encode(&self, color: Option<moq_video::Color>) -> Result<moq_video::encode::Sink, Error> {
let framerate = self.info.framerate.unwrap_or(moq_video::Rate::new(30, 1).unwrap());
let framerate = self.info.framerate.unwrap_or(moq_video::FrameRate::new(30, 1).unwrap());
let mut config = moq_video::encode::Config::new(self.info.size.width, self.info.size.height, framerate);
config.bitrate = Some(self.info.bitrate);
config.kind = self.encoder.clone();
Expand Down Expand Up @@ -1111,7 +1111,7 @@ mod tests {
short_side: 120,
size: moq_video::Size::new(160, 120),
bitrate: moq_net::bandwidth::Rate::from_bps(100_000),
framerate: Some(moq_video::Rate::new(30, 1).unwrap()),
framerate: Some(moq_video::FrameRate::new(30, 1).unwrap()),
};

let active = crate::active::Producer::default();
Expand Down
5 changes: 5 additions & 0 deletions rs/moq-video/MIGRATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ How to update your code for each breaking change, newest first.

## Unreleased

### `Rate` is `FrameRate` (#6653)

`Rate` and `RateError` are `FrameRate` and `FrameRateError`, the name the bindings already use.
Rename the imports; the methods and error variants are unchanged.

### Decoded reads carry gaps and encoder ends (#6475)

`decode::Consumer::read()` returns `decode::Read` events instead of bare frames, the same shape as `moq_audio::decode::Read`: `Frame(frame)`, `Gap { timestamp, duration }` for lost media, and `End { end }` where the publisher stopped its encoder; `None` still means the track is finished.
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-video/examples/d3d11-resize-probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ mod probe {
/// inline parameter sets, which is what the MFT wants).
fn stream() -> Result<Vec<Vec<u8>>> {
let mut config =
moq_video::encode::Config::new(SOURCE.width, SOURCE.height, moq_video::Rate::new(30, 1).unwrap());
moq_video::encode::Config::new(SOURCE.width, SOURCE.height, moq_video::FrameRate::new(30, 1).unwrap());
config.kind = moq_video::encode::Kind::Software;
let mut encoder = moq_video::encode::Encoder::new(&config).context("openh264 encoder")?;

Expand Down Expand Up @@ -1145,7 +1145,7 @@ mod probe {
let mut config = moq_video::encode::Config::new(
target.width,
target.height,
moq_video::Rate::new(30, 1).unwrap(),
moq_video::FrameRate::new(30, 1).unwrap(),
);
config.kind = moq_video::encode::Kind::Named("mediafoundation".into());
let mut encoder = moq_video::encode::Encoder::new(&config)
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-video/examples/encode-presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
use std::time::{Duration, Instant};

use moq_video::encode::{Codec, Config, Encoder, Kind, Preset};
use moq_video::{Frame, I420, Rate, Size, Surface};
use moq_video::{Frame, FrameRate, I420, Size, Surface};

const PRESETS: [(Preset, &str); 3] = [
(Preset::LowLatency, "low-latency"),
Expand Down Expand Up @@ -73,7 +73,7 @@ fn main() -> anyhow::Result<()> {
.into_iter()
.filter(|(_, label)| only.is_none_or(|only| only == *label))
{
let mut config = Config::new(size.width, size.height, Rate::new(fps, 1)?);
let mut config = Config::new(size.width, size.height, FrameRate::new(fps, 1)?);
config.codec = codec;
config.kind = Kind::Named(backend.clone());
config.bitrate = Some(moq_net::bandwidth::Rate::from_bps(bitrate));
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-video/src/capture/mediafoundation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct Camera {
device: Option<ID3D11Device>,
width: u32,
height: u32,
framerate: Option<crate::Rate>,
framerate: Option<crate::FrameRate>,
device_name: String,
// Keep the DXGI manager alive for the reader's lifetime (the reader holds its
// own ref, but we own the pairing). Drops before `_com`.
Expand Down Expand Up @@ -182,7 +182,7 @@ impl Camera {
}
let framerate = unsafe { current.GetUINT64(&MF_MT_FRAME_RATE).ok() }.and_then(|packed| {
let (num, den) = unpack_2x32(packed);
crate::Rate::new(num, den).ok()
crate::FrameRate::new(num, den).ok()
});

let (device, manager) = match gpu {
Expand Down
Loading
Loading