Skip to content

Commit

Permalink
Add the VideoToolbox framework
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jan 12, 2025
1 parent 2591c57 commit d6014ff
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 13 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- `OpenDirectory` / `objc2-open-directory`.
- `ScreenSaver` / `objc2-screen-saver`.
- `SystemConfiguration` / `objc2-system-configuration`.
- `VideoToolbox` / `objc2-video-toolbox`.
* Added `#[must_use]` attributes where the C headers have them.
* Added automatic conversion of `Bool` in external function argument and
return types (similar to what's done on methods).
Expand Down
1 change: 1 addition & 0 deletions crates/objc2/src/topics/about_generated/list_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
| `UIKit` | [![`objc2-ui-kit`](https://badgen.net/crates/v/objc2-ui-kit)](https://crates.io/crates/objc2-ui-kit) | [![docs.rs](https://docs.rs/objc2-ui-kit/badge.svg)](https://docs.rs/objc2-ui-kit/) |
| `UniformTypeIdentifiers` | [![`objc2-uniform-type-identifiers`](https://badgen.net/crates/v/objc2-uniform-type-identifiers)](https://crates.io/crates/objc2-uniform-type-identifiers) | [![docs.rs](https://docs.rs/objc2-uniform-type-identifiers/badge.svg)](https://docs.rs/objc2-uniform-type-identifiers/) |
| `UserNotifications` | [![`objc2-user-notifications`](https://badgen.net/crates/v/objc2-user-notifications)](https://crates.io/crates/objc2-user-notifications) | [![docs.rs](https://docs.rs/objc2-user-notifications/badge.svg)](https://docs.rs/objc2-user-notifications/) |
| `VideoToolbox` | [![`objc2-video-toolbox`](https://badgen.net/crates/v/objc2-video-toolbox)](https://crates.io/crates/objc2-video-toolbox) | [![docs.rs](https://docs.rs/objc2-video-toolbox/badge.svg)](https://docs.rs/objc2-video-toolbox/) |
| `Virtualization` | [![`objc2-virtualization`](https://badgen.net/crates/v/objc2-virtualization)](https://crates.io/crates/objc2-virtualization) | [![docs.rs](https://docs.rs/objc2-virtualization/badge.svg)](https://docs.rs/objc2-virtualization/) |
| `Vision` | [![`objc2-vision`](https://badgen.net/crates/v/objc2-vision)](https://crates.io/crates/objc2-vision) | [![docs.rs](https://docs.rs/objc2-vision/badge.svg)](https://docs.rs/objc2-vision/) |
| `WebKit` | [![`objc2-web-kit`](https://badgen.net/crates/v/objc2-web-kit)](https://crates.io/crates/objc2-web-kit) | [![docs.rs](https://docs.rs/objc2-web-kit/badge.svg)](https://docs.rs/objc2-web-kit/) |
3 changes: 3 additions & 0 deletions crates/test-frameworks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ test-frameworks = [
"objc2-uniform-type-identifiers/all",
"dep:objc2-user-notifications",
"objc2-user-notifications/all",
"dep:objc2-video-toolbox",
"objc2-video-toolbox/all",
"dep:objc2-virtualization",
"objc2-virtualization/all",
"dep:objc2-vision",
Expand Down Expand Up @@ -296,6 +298,7 @@ objc2-multipeer-connectivity = { path = "../../framework-crates/objc2-multipeer-
objc2-photos = { path = "../../framework-crates/objc2-photos", optional = true }
objc2-quartz-core = { path = "../../framework-crates/objc2-quartz-core", optional = true }
objc2-system-configuration = { path = "../../framework-crates/objc2-system-configuration", optional = true }
objc2-video-toolbox = { path = "../../framework-crates/objc2-video-toolbox", optional = true }
objc2-vision = { path = "../../framework-crates/objc2-vision", optional = true }

[target.'cfg(any(target_os = "ios", target_os = "tvos", target_os = "visionos"))'.dependencies]
Expand Down
172 changes: 172 additions & 0 deletions framework-crates/objc2-video-toolbox/Cargo.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions framework-crates/objc2-video-toolbox/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions framework-crates/objc2-video-toolbox/src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#[cfg(feature = "objc2")]
use objc2::encode::{Encode, Encoding, RefEncode};

/// Directives for the decompression session and the video decoder, passed into
/// decodeFlags parameter of VTDecompressionSessionDecodeFrame.
///
///
/// With the kVTDecodeFrame_EnableAsynchronousDecompression bit clear, the video decoder
/// is compelled to emit every frame before it returns. With the bit set, the decoder may
/// process frames asynchronously, but it is not compelled to do so.
///
/// A hint to the decompression session and video decoder that a CVImageBuffer should not
/// be emitted for this frame. NULL will be returned instead.
///
/// A hint to the video decoder that it would be OK to use a low-power mode that can not decode faster than 1x realtime.
///
/// With the kVTDecodeFrame_EnableTemporalProcessing bit clear, the video decoder should emit
/// every frame once that frame's decoding is done -- frames may not be delayed indefinitely. With
/// the bit set, it is legal for the decoder to delay frames indefinitely -- at least
/// until VTDecompressionSessionFinishDelayedFrames or VTDecompressionSessionInvalidate is called.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtdecodeframeflags?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTDecodeFrameFlags(pub u32);
bitflags::bitflags! {
impl VTDecodeFrameFlags: u32 {
#[doc(alias = "kVTDecodeFrame_EnableAsynchronousDecompression")]
const Frame_EnableAsynchronousDecompression = 1<<0;
#[doc(alias = "kVTDecodeFrame_DoNotOutputFrame")]
const Frame_DoNotOutputFrame = 1<<1;
#[doc(alias = "kVTDecodeFrame_1xRealTimePlayback")]
const Frame_1xRealTimePlayback = 1<<2;
#[doc(alias = "kVTDecodeFrame_EnableTemporalProcessing")]
const Frame_EnableTemporalProcessing = 1<<3;
}
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTDecodeFrameFlags {
const ENCODING: Encoding = u32::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTDecodeFrameFlags {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
1 change: 1 addition & 0 deletions framework-crates/objc2-video-toolbox/src/generated

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions framework-crates/objc2-video-toolbox/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! # Bindings to the `VideoToolbox` framework
//!
//! See [Apple's docs][apple-doc] and [the general docs on framework crates][framework-crates] for more information.
//!
//! [apple-doc]: https://developer.apple.com/documentation/videotoolbox/
//! [framework-crates]: https://docs.rs/objc2/latest/objc2/topics/about_generated/index.html
#![no_std]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// Update in Cargo.toml as well.
#![doc(html_root_url = "https://docs.rs/objc2-video-toolbox/0.2.2")]

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(feature = "std")]
extern crate std;

#[cfg(feature = "VTErrors")]
mod errors;
mod generated;
#[cfg(feature = "VTErrors")]
pub use self::errors::VTDecodeFrameFlags;
#[allow(unused_imports, unreachable_pub)]
pub use self::generated::*;

// MacTypes.h
#[allow(dead_code)]
pub(crate) type Boolean = u8;
#[allow(dead_code)]
pub(crate) type OSStatus = i32;
12 changes: 12 additions & 0 deletions framework-crates/objc2-video-toolbox/translation-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
framework = "VideoToolbox"
crate = "objc2-video-toolbox"
required-crates = ["objc2-core-foundation"]
custom-lib-rs = true
macos = "10.8"
maccatalyst = "13.0"
ios = "6.0"
tvos = "10.2"
visionos = "1.0"

# Wrongly renamed (Swift's renaming algorithm is insufficient)
enum.VTDecodeFrameFlags.skipped = true

0 comments on commit d6014ff

Please sign in to comment.