Skip to content

Commit

Permalink
Drop frames when done. (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kixelated authored Nov 26, 2024
1 parent e8ec29e commit c6df5d5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ js-sys = "0.3.70"
tokio = { version = "1", features = ["sync", "macros"] }
bytes = "1"

derive_more = { version = "1", features = ["from", "as_ref"] }

[dependencies.web-sys]
version = "0.3.70"
features = [
Expand Down
4 changes: 2 additions & 2 deletions src/video/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use bytes::Bytes;
use tokio::sync::{mpsc, watch};
use wasm_bindgen::prelude::*;

use super::VideoColorSpaceConfig;
use crate::{EncodedFrame, Error, VideoFrame};
use super::{VideoColorSpaceConfig, VideoFrame};
use crate::{EncodedFrame, Error};

pub fn video_decoder() -> (VideoDecoder, VideoDecoded) {
let (frames_tx, frames_rx) = mpsc::unbounded_channel();
Expand Down
11 changes: 11 additions & 0 deletions src/video/frame.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use derive_more::{AsMut, AsRef, From};

#[derive(Debug, From, AsRef, AsMut)]
pub struct VideoFrame(pub web_sys::VideoFrame);

// Make sure we close the frame on drop.
impl Drop for VideoFrame {
fn drop(&mut self) {
self.0.close();
}
}
4 changes: 2 additions & 2 deletions src/video/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod color;
mod decoder;
mod encoder;
mod frame;

pub use color::*;
pub use decoder::*;

pub type VideoFrame = web_sys::VideoFrame;
pub use frame::*;

0 comments on commit c6df5d5

Please sign in to comment.