@@ -4,7 +4,7 @@ use std::ffi::CString;
44use std:: mem;
55
66use ffi:: * ;
7- use libc:: { c_int, c_void } ;
7+ use libc:: c_int;
88use util:: format;
99use { ChannelLayout , Error , Rational } ;
1010
@@ -17,21 +17,21 @@ macro_rules! check {
1717 } ;
1818}
1919
20- pub unsafe trait Target {
21- fn as_ptr ( & self ) -> * const c_void ;
22- fn as_mut_ptr ( & mut self ) -> * mut c_void ;
20+ pub unsafe trait Target < T > {
21+ fn as_ptr ( & self ) -> * const T ;
22+ fn as_mut_ptr ( & mut self ) -> * mut T ;
2323}
2424
25- pub trait Settable : Target {
26- fn set < T : ' static > ( & mut self , name : & str , value : & T ) -> Result < ( ) , Error > {
25+ pub trait Settable < T > : Target < T > {
26+ fn set < V : ' static > ( & mut self , name : & str , value : & V ) -> Result < ( ) , Error > {
2727 unsafe {
2828 let name = CString :: new ( name) . unwrap ( ) ;
2929
3030 check ! ( av_opt_set_bin(
31- self . as_mut_ptr( ) ,
31+ self . as_mut_ptr( ) as * mut _ ,
3232 name. as_ptr( ) ,
3333 value as * const _ as * const _,
34- mem:: size_of:: <T >( ) as c_int,
34+ mem:: size_of:: <V >( ) as c_int,
3535 AV_OPT_SEARCH_CHILDREN
3636 ) )
3737 }
@@ -43,7 +43,7 @@ pub trait Settable: Target {
4343 let value = CString :: new ( value) . unwrap ( ) ;
4444
4545 check ! ( av_opt_set(
46- self . as_mut_ptr( ) ,
46+ self . as_mut_ptr( ) as * mut _ ,
4747 name. as_ptr( ) ,
4848 value. as_ptr( ) ,
4949 AV_OPT_SEARCH_CHILDREN
@@ -56,7 +56,7 @@ pub trait Settable: Target {
5656 let name = CString :: new ( name) . unwrap ( ) ;
5757
5858 check ! ( av_opt_set_int(
59- self . as_mut_ptr( ) ,
59+ self . as_mut_ptr( ) as * mut _ ,
6060 name. as_ptr( ) ,
6161 value,
6262 AV_OPT_SEARCH_CHILDREN
@@ -69,20 +69,20 @@ pub trait Settable: Target {
6969 let name = CString :: new ( name) . unwrap ( ) ;
7070
7171 check ! ( av_opt_set_double(
72- self . as_mut_ptr( ) ,
72+ self . as_mut_ptr( ) as * mut _ ,
7373 name. as_ptr( ) ,
7474 value,
7575 AV_OPT_SEARCH_CHILDREN
7676 ) )
7777 }
7878 }
7979
80- fn set_rational < T : Into < Rational > > ( & mut self , name : & str , value : T ) -> Result < ( ) , Error > {
80+ fn set_rational < V : Into < Rational > > ( & mut self , name : & str , value : V ) -> Result < ( ) , Error > {
8181 unsafe {
8282 let name = CString :: new ( name) . unwrap ( ) ;
8383
8484 check ! ( av_opt_set_q(
85- self . as_mut_ptr( ) ,
85+ self . as_mut_ptr( ) as * mut _ ,
8686 name. as_ptr( ) ,
8787 value. into( ) . into( ) ,
8888 AV_OPT_SEARCH_CHILDREN
@@ -95,7 +95,7 @@ pub trait Settable: Target {
9595 let name = CString :: new ( name) . unwrap ( ) ;
9696
9797 check ! ( av_opt_set_image_size(
98- self . as_mut_ptr( ) ,
98+ self . as_mut_ptr( ) as * mut _ ,
9999 name. as_ptr( ) ,
100100 w as c_int,
101101 h as c_int,
@@ -109,7 +109,7 @@ pub trait Settable: Target {
109109 let name = CString :: new ( name) . unwrap ( ) ;
110110
111111 check ! ( av_opt_set_pixel_fmt(
112- self . as_mut_ptr( ) ,
112+ self . as_mut_ptr( ) as * mut _ ,
113113 name. as_ptr( ) ,
114114 format. into( ) ,
115115 AV_OPT_SEARCH_CHILDREN
@@ -122,7 +122,7 @@ pub trait Settable: Target {
122122 let name = CString :: new ( name) . unwrap ( ) ;
123123
124124 check ! ( av_opt_set_sample_fmt(
125- self . as_mut_ptr( ) ,
125+ self . as_mut_ptr( ) as * mut _ ,
126126 name. as_ptr( ) ,
127127 format. into( ) ,
128128 AV_OPT_SEARCH_CHILDREN
@@ -137,7 +137,7 @@ pub trait Settable: Target {
137137 #[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
138138 {
139139 check ! ( av_opt_set_channel_layout(
140- self . as_mut_ptr( ) ,
140+ self . as_mut_ptr( ) as * mut _ ,
141141 name. as_ptr( ) ,
142142 layout. bits( ) as i64 ,
143143 AV_OPT_SEARCH_CHILDREN
@@ -147,7 +147,7 @@ pub trait Settable: Target {
147147 #[ cfg( feature = "ffmpeg_7_0" ) ]
148148 {
149149 check ! ( av_opt_set_chlayout(
150- self . as_mut_ptr( ) ,
150+ self . as_mut_ptr( ) as * mut _ ,
151151 name. as_ptr( ) ,
152152 & layout. into( ) ,
153153 AV_OPT_SEARCH_CHILDREN
@@ -157,6 +157,6 @@ pub trait Settable: Target {
157157 }
158158}
159159
160- pub trait Gettable : Target { }
160+ pub trait Gettable < T > : Target < T > { }
161161
162- pub trait Iterable : Target { }
162+ pub trait Iterable < T > : Target < T > { }
0 commit comments