1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
use std::marker::PhantomData; use super::{Sink, Source}; use ffi::*; use libc::c_void; use {format, option, ChannelLayout}; pub struct Context<'a> { ptr: *mut AVFilterContext, _marker: PhantomData<&'a ()>, } impl<'a> Context<'a> { pub unsafe fn wrap(ptr: *mut AVFilterContext) -> Self { Context { ptr, _marker: PhantomData, } } pub unsafe fn as_ptr(&self) -> *const AVFilterContext { self.ptr as *const _ } pub unsafe fn as_mut_ptr(&mut self) -> *mut AVFilterContext { self.ptr } } impl<'a> Context<'a> { pub fn source(&'a mut self) -> Source<'a> { unsafe { Source::wrap(self) } } pub fn sink(&'a mut self) -> Sink<'a> { unsafe { Sink::wrap(self) } } pub fn set_pixel_format(&mut self, value: format::Pixel) { let _ = option::Settable::set::<AVPixelFormat>(self, "pix_fmts", &value.into()); } pub fn set_sample_format(&mut self, value: format::Sample) { let _ = option::Settable::set::<AVSampleFormat>(self, "sample_fmts", &value.into()); } pub fn set_sample_rate(&mut self, value: u32) { let _ = option::Settable::set(self, "sample_rates", &i64::from(value)); } pub fn set_channel_layout(&mut self, value: ChannelLayout) { let _ = option::Settable::set(self, "channel_layouts", &value.bits()); } } unsafe impl<'a> option::Target for Context<'a> { fn as_ptr(&self) -> *const c_void { self.ptr as *const _ } fn as_mut_ptr(&mut self) -> *mut c_void { self.ptr as *mut _ } } impl<'a> option::Settable for Context<'a> {}