Skip to content

Commit

Permalink
Beginning finalizing.
Browse files Browse the repository at this point in the history
  • Loading branch information
quadrupleslap committed Jun 25, 2017
1 parent ffa7a91 commit e5b67f6
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 56 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,25 @@ Its API is as simple as it gets!

```rust
struct Display; /// A screen.
struct Frame; /// Just a byte array.
struct Frame; /// Just a BGRA byte array.
struct Capturer; /// A recording instance.

impl Capturer {
/// Begin recording.
pub fn new(display: Display) -> io::Result<Capturer>;

/// Try to get a frame!
/// Returns WouldBlock if it would block.
pub fn frame<'a>(&'a mut self) -> io::Result<Frame<'a>>;

pub fn width(&self) -> usize;
pub fn height(&self) -> usize;
pub fn format(&self) -> PixelFormat; // Almost always ARGB8888.
}

impl Display {
/// The primary screen.
pub fn primary() -> io::Result<Display>;

/// All the screens.
pub fn all() -> io::Result<Vec<Display>>;

Expand Down
10 changes: 0 additions & 10 deletions src/common/dxgi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use dxgi;
use std::{io, ops};
use std::io::ErrorKind::{WouldBlock, TimedOut, NotFound};
use PixelFormat;

pub struct Capturer {
inner: dxgi::Capturer,
Expand All @@ -25,10 +24,6 @@ impl Capturer {
self.height
}

pub fn format(&self) -> PixelFormat {
PixelFormat::Argb8888
}

pub fn frame<'a>(&'a mut self) -> io::Result<Frame<'a>> {
const MILLISECONDS_PER_FRAME: u32 = 0;
match self.inner.frame(MILLISECONDS_PER_FRAME) {
Expand All @@ -53,11 +48,6 @@ impl<'a> ops::Deref for Frame<'a> {
pub struct Display(dxgi::Display);

impl Display {
#[deprecated(note="renamed to `Display::primary`")]
pub fn main() -> io::Result<Display> {
Display::primary()
}

pub fn primary() -> io::Result<Display> {
match dxgi::Displays::new()?.next() {
Some(inner) => Ok(Display(inner)),
Expand Down
12 changes: 0 additions & 12 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,3 @@ cfg_block!(cfg(dxgi) {
pub use self::dxgi::*;
});

pub enum PixelFormat {
/// Packed Little Endian ARGB8888
Argb8888,
/// Packed Little Endian ARGB2101010
Argb2101010,
/// 2-plane "video" range YCbCr 4:2:0
YCbCr420Video,
/// 2-plane "full" range YCbCr 4:2:0
YCbCr420Full,
/// Other formats.
Other
}
17 changes: 0 additions & 17 deletions src/common/quartz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use quartz;
use std::{io, ops, mem};
use std::marker::PhantomData;
use std::sync::{Arc, Mutex, TryLockError};
use PixelFormat;

pub struct Capturer {
inner: quartz::Capturer,
Expand Down Expand Up @@ -38,17 +37,6 @@ impl Capturer {
self.inner.height()
}

pub fn format(&self) -> PixelFormat {
use quartz::PixelFormat::*;
match self.inner.format() {
Argb8888 => PixelFormat::Argb8888,
Argb2101010 => PixelFormat::Argb2101010,
YCbCr420Video => PixelFormat::YCbCr420Video,
YCbCr420Full => PixelFormat::YCbCr420Full,
_ => PixelFormat::Other
}
}

pub fn frame<'a>(&'a mut self) -> io::Result<Frame<'a>> {
match self.frame.try_lock() {
Ok(mut handle) => {
Expand Down Expand Up @@ -88,11 +76,6 @@ impl<'a> ops::Deref for Frame<'a> {
pub struct Display(quartz::Display);

impl Display {
#[deprecated(note="renamed to `Display::primary`")]
pub fn main() -> io::Result<Display> {
Display::primary()
}

pub fn primary() -> io::Result<Display> {
Ok(Display(quartz::Display::primary()))
}
Expand Down
10 changes: 0 additions & 10 deletions src/common/x11.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use x11;
use std::{io, ops};
use std::rc::Rc;
use PixelFormat;

pub struct Capturer(x11::Capturer);

Expand All @@ -18,10 +17,6 @@ impl Capturer {
self.0.display().height() as usize
}

pub fn format(&self) -> PixelFormat {
PixelFormat::Argb8888
}

pub fn frame<'a>(&'a mut self) -> io::Result<Frame<'a>> {
Ok(Frame(self.0.frame()))
}
Expand All @@ -39,11 +34,6 @@ impl<'a> ops::Deref for Frame<'a> {
pub struct Display(x11::Display);

impl Display {
#[deprecated(note="renamed to `Display::primary`")]
pub fn main() -> io::Result<Display> {
Display::primary()
}

pub fn primary() -> io::Result<Display> {
let server = Rc::new(match x11::Server::default() {
Ok(server) => server,
Expand Down
6 changes: 1 addition & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,4 @@ cfg_block!(cfg(dxgi) {
});

mod common;
pub use common::{
Capturer,
Display,
PixelFormat
};
pub use common::{Capturer, Display};

0 comments on commit e5b67f6

Please sign in to comment.