Skip to content

Commit

Permalink
fix!: remove filter::Context generic lifetime parameter
Browse files Browse the repository at this point in the history
issue #193
  • Loading branch information
Vincent Jousse committed Jul 19, 2024
1 parent 1922ed0 commit 1b49eca
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 34 deletions.
23 changes: 8 additions & 15 deletions src/filter/context/context.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
use std::marker::PhantomData;

use super::{Sink, Source};
use ffi::*;
use libc::c_void;
use {format, option, ChannelLayout};

pub struct Context<'a> {
pub struct Context {
ptr: *mut AVFilterContext,

_marker: PhantomData<&'a ()>,
}

impl<'a> Context<'a> {
impl Context {
pub unsafe fn wrap(ptr: *mut AVFilterContext) -> Self {
Context {
ptr,
_marker: PhantomData,
}
Context { ptr }
}

pub unsafe fn as_ptr(&self) -> *const AVFilterContext {
Expand All @@ -28,12 +21,12 @@ impl<'a> Context<'a> {
}
}

impl<'a> Context<'a> {
pub fn source(&'a mut self) -> Source<'a> {
impl Context {
pub fn source(&mut self) -> Source {
unsafe { Source::wrap(self) }
}

pub fn sink(&'a mut self) -> Sink<'a> {
pub fn sink(&mut self) -> Sink {
unsafe { Sink::wrap(self) }
}

Expand Down Expand Up @@ -61,7 +54,7 @@ impl<'a> Context<'a> {
}
}

unsafe impl<'a> option::Target for Context<'a> {
unsafe impl option::Target for Context {
fn as_ptr(&self) -> *const c_void {
self.ptr as *const _
}
Expand All @@ -71,4 +64,4 @@ unsafe impl<'a> option::Target for Context<'a> {
}
}

impl<'a> option::Settable for Context<'a> {}
impl option::Settable for Context {}
6 changes: 3 additions & 3 deletions src/filter/context/sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use libc::c_int;
use {Error, Frame, Rational};

pub struct Sink<'a> {
ctx: &'a mut Context<'a>,
ctx: &'a mut Context,
}

impl<'a> Sink<'a> {
pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Sink<'b> {
Sink { ctx }
pub unsafe fn wrap(ctx: &'a mut Context) -> Self {
Self { ctx }
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/filter/context/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use ffi::*;
use {Error, Frame};

pub struct Source<'a> {
ctx: &'a mut Context<'a>,
ctx: &'a mut Context,
}

impl<'a> Source<'a> {
pub unsafe fn wrap<'b>(ctx: &'b mut Context<'b>) -> Source<'b> {
Source { ctx }
pub unsafe fn wrap(ctx: &'a mut Context) -> Self {
Self { ctx }
}
}

Expand Down
15 changes: 2 additions & 13 deletions src/filter/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,7 @@ impl Graph {
}
}

pub fn add<'a, 'b>(
&'a mut self,
filter: &Filter,
name: &str,
args: &str,
) -> Result<Context<'b>, Error>
where
'a: 'b,
{
pub fn add(&mut self, filter: &Filter, name: &str, args: &str) -> Result<Context, Error> {
unsafe {
let name = CString::new(name).unwrap();
let args = CString::new(args).unwrap();
Expand All @@ -78,10 +70,7 @@ impl Graph {
}
}

pub fn get<'a, 'b>(&'b mut self, name: &str) -> Option<Context<'b>>
where
'a: 'b,
{
pub fn get(&mut self, name: &str) -> Option<Context> {
unsafe {
let name = CString::new(name).unwrap();
let ptr = avfilter_graph_get_filter(self.as_mut_ptr(), name.as_ptr());
Expand Down

0 comments on commit 1b49eca

Please sign in to comment.