@@ -4,7 +4,7 @@ use std::ffi::CString;
4
4
use std:: mem;
5
5
6
6
use ffi:: * ;
7
- use libc:: { c_int, c_void } ;
7
+ use libc:: c_int;
8
8
use util:: format;
9
9
use { ChannelLayout , Error , Rational } ;
10
10
@@ -17,21 +17,21 @@ macro_rules! check {
17
17
} ;
18
18
}
19
19
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 ;
23
23
}
24
24
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 > {
27
27
unsafe {
28
28
let name = CString :: new ( name) . unwrap ( ) ;
29
29
30
30
check ! ( av_opt_set_bin(
31
- self . as_mut_ptr( ) ,
31
+ self . as_mut_ptr( ) as * mut _ ,
32
32
name. as_ptr( ) ,
33
33
value as * const _ as * const _,
34
- mem:: size_of:: <T >( ) as c_int,
34
+ mem:: size_of:: <V >( ) as c_int,
35
35
AV_OPT_SEARCH_CHILDREN
36
36
) )
37
37
}
@@ -43,7 +43,7 @@ pub trait Settable: Target {
43
43
let value = CString :: new ( value) . unwrap ( ) ;
44
44
45
45
check ! ( av_opt_set(
46
- self . as_mut_ptr( ) ,
46
+ self . as_mut_ptr( ) as * mut _ ,
47
47
name. as_ptr( ) ,
48
48
value. as_ptr( ) ,
49
49
AV_OPT_SEARCH_CHILDREN
@@ -56,7 +56,7 @@ pub trait Settable: Target {
56
56
let name = CString :: new ( name) . unwrap ( ) ;
57
57
58
58
check ! ( av_opt_set_int(
59
- self . as_mut_ptr( ) ,
59
+ self . as_mut_ptr( ) as * mut _ ,
60
60
name. as_ptr( ) ,
61
61
value,
62
62
AV_OPT_SEARCH_CHILDREN
@@ -69,20 +69,20 @@ pub trait Settable: Target {
69
69
let name = CString :: new ( name) . unwrap ( ) ;
70
70
71
71
check ! ( av_opt_set_double(
72
- self . as_mut_ptr( ) ,
72
+ self . as_mut_ptr( ) as * mut _ ,
73
73
name. as_ptr( ) ,
74
74
value,
75
75
AV_OPT_SEARCH_CHILDREN
76
76
) )
77
77
}
78
78
}
79
79
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 > {
81
81
unsafe {
82
82
let name = CString :: new ( name) . unwrap ( ) ;
83
83
84
84
check ! ( av_opt_set_q(
85
- self . as_mut_ptr( ) ,
85
+ self . as_mut_ptr( ) as * mut _ ,
86
86
name. as_ptr( ) ,
87
87
value. into( ) . into( ) ,
88
88
AV_OPT_SEARCH_CHILDREN
@@ -95,7 +95,7 @@ pub trait Settable: Target {
95
95
let name = CString :: new ( name) . unwrap ( ) ;
96
96
97
97
check ! ( av_opt_set_image_size(
98
- self . as_mut_ptr( ) ,
98
+ self . as_mut_ptr( ) as * mut _ ,
99
99
name. as_ptr( ) ,
100
100
w as c_int,
101
101
h as c_int,
@@ -109,7 +109,7 @@ pub trait Settable: Target {
109
109
let name = CString :: new ( name) . unwrap ( ) ;
110
110
111
111
check ! ( av_opt_set_pixel_fmt(
112
- self . as_mut_ptr( ) ,
112
+ self . as_mut_ptr( ) as * mut _ ,
113
113
name. as_ptr( ) ,
114
114
format. into( ) ,
115
115
AV_OPT_SEARCH_CHILDREN
@@ -122,7 +122,7 @@ pub trait Settable: Target {
122
122
let name = CString :: new ( name) . unwrap ( ) ;
123
123
124
124
check ! ( av_opt_set_sample_fmt(
125
- self . as_mut_ptr( ) ,
125
+ self . as_mut_ptr( ) as * mut _ ,
126
126
name. as_ptr( ) ,
127
127
format. into( ) ,
128
128
AV_OPT_SEARCH_CHILDREN
@@ -137,7 +137,7 @@ pub trait Settable: Target {
137
137
#[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
138
138
{
139
139
check ! ( av_opt_set_channel_layout(
140
- self . as_mut_ptr( ) ,
140
+ self . as_mut_ptr( ) as * mut _ ,
141
141
name. as_ptr( ) ,
142
142
layout. bits( ) as i64 ,
143
143
AV_OPT_SEARCH_CHILDREN
@@ -147,7 +147,7 @@ pub trait Settable: Target {
147
147
#[ cfg( feature = "ffmpeg_7_0" ) ]
148
148
{
149
149
check ! ( av_opt_set_chlayout(
150
- self . as_mut_ptr( ) ,
150
+ self . as_mut_ptr( ) as * mut _ ,
151
151
name. as_ptr( ) ,
152
152
& layout. into( ) ,
153
153
AV_OPT_SEARCH_CHILDREN
@@ -157,6 +157,6 @@ pub trait Settable: Target {
157
157
}
158
158
}
159
159
160
- pub trait Gettable : Target { }
160
+ pub trait Gettable < T > : Target < T > { }
161
161
162
- pub trait Iterable : Target { }
162
+ pub trait Iterable < T > : Target < T > { }
0 commit comments