Skip to content
Open
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: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@ default = []

ffmpeg = []

[[test]]
name = "reftest"
path = "tests/reftest.rs"
harness = false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

`rust-media` is a media player framework for Rust, similar in spirit to `libvlc` or GStreamer. It's designed for use in Servo but is intended to be widely useful for all sorts of projects. Possible use cases are background music and FMVs for video games, as well as media player applications.

`rust-media` is currently pinned to the same version of Rust that Servo uses. This means that, until the language is stable, you may have to forward-port it somewhat.
The `master` branch of `rust-media` is currently pinned to the same version of Rust that Servo uses. The `nightly` branch is intended to track the current Rust nightly; however, like many Rust projects, it may be out of date.

The library is currently in very early stages; contributions are welcome!

Expand Down Expand Up @@ -57,4 +57,4 @@ This will probably fail with an error about `#[derive(Copy)]` in `libc`. You wil

* Play a YouTube video:

$ youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ --exec "target/release/example {} video/mp4"
$ youtube-dl https://www.youtube.com/watch?v=dQw4w9WgXcQ --exec "target/release/example {} video/mp4"
19 changes: 13 additions & 6 deletions container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ pub trait ContainerReader {

pub trait Track<'x> {
fn track_type(self: Box<Self>) -> TrackType<'x>;
fn is_video(&self) -> bool;
fn is_audio(&self) -> bool;
fn is_video(&self) -> bool { false }
fn is_audio(&self) -> bool { false }

/// Returns the number of clusters in this track, if possible. Returns `None` if this container
/// has no table of contents (so the number of clusters is unknown).
fn cluster_count(&self) -> Option<c_int>;
fn cluster_count(&self) -> Option<c_int> { None }

fn number(&self) -> c_long;
fn codec(&self) -> Option<Vec<u8>>;
fn number(&self) -> c_long { 0 }
fn codec(&self) -> Option<Vec<u8>> { None }
fn cluster<'a>(&'a self, cluster_index: i32) -> Result<Box<Cluster + 'a>,()>;
}

Expand All @@ -81,8 +81,15 @@ pub trait VideoTrack<'a> : Track<'a> {
/// Returns the height of this track in pixels.
fn height(&self) -> u16;

/// Returns the number of times this track should be played.
///
/// `0` indicates infinite loop.
fn num_iterations(&self) -> u32 { 1 }

/// Returns the frame rate of this track in Hertz.
fn frame_rate(&self) -> c_double;
///
/// Since this isn't constant for all codecs, this is largely a debugging tool.
fn frame_rate(&self) -> c_double { 0.0 }

/// Returns a the pixel format of this track. This is usually derived from the codec. If the
/// pixel format is indexed, ignore the associated palette; each frame can have its own
Expand Down
Loading