@@ -38,12 +38,16 @@ impl Audio {
3838
3939 pub fn channel_layouts ( & self ) -> Option < ChannelLayoutIter > {
4040 unsafe {
41- if ( * self . codec . as_ptr ( ) ) . channel_layouts . is_null ( ) {
41+ #[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
42+ let ptr = ( * self . codec . as_ptr ( ) ) . channel_layouts ;
43+
44+ #[ cfg( feature = "ffmpeg_7_0" ) ]
45+ let ptr = ( * self . codec . as_ptr ( ) ) . ch_layouts ;
46+
47+ if ptr. is_null ( ) {
4248 None
4349 } else {
44- Some ( ChannelLayoutIter :: new (
45- ( * self . codec . as_ptr ( ) ) . channel_layouts ,
46- ) )
50+ Some ( ChannelLayoutIter :: new ( ptr) )
4751 }
4852 }
4953 }
@@ -111,18 +115,23 @@ impl Iterator for FormatIter {
111115 }
112116}
113117
118+ #[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
119+ type ChannelLayoutType = u64 ;
120+ #[ cfg( feature = "ffmpeg_7_0" ) ]
121+ type ChannelLayoutType = AVChannelLayout ;
122+
114123pub struct ChannelLayoutIter {
115- ptr : * const u64 ,
124+ ptr : * const ChannelLayoutType ,
116125}
117126
118127impl ChannelLayoutIter {
119- pub fn new ( ptr : * const u64 ) -> Self {
128+ pub fn new ( ptr : * const ChannelLayoutType ) -> Self {
120129 ChannelLayoutIter { ptr }
121130 }
122131
123132 pub fn best ( self , max : i32 ) -> ChannelLayout {
124133 self . fold ( ChannelLayout :: MONO , |acc, cur| {
125- if cur. channels ( ) > acc. channels ( ) && cur. channels ( ) <= max {
134+ if cur. channels ( ) > acc. channels ( ) && cur. channels ( ) <= max as _ {
126135 cur
127136 } else {
128137 acc
@@ -136,11 +145,22 @@ impl Iterator for ChannelLayoutIter {
136145
137146 fn next ( & mut self ) -> Option < <Self as Iterator >:: Item > {
138147 unsafe {
148+ #[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
139149 if * self . ptr == 0 {
140150 return None ;
141151 }
142152
153+ #[ cfg( feature = "ffmpeg_7_0" ) ]
154+ if self . ptr . is_null ( ) || ( * self . ptr ) . u . mask == 0 {
155+ return None ;
156+ }
157+
158+ #[ cfg( not( feature = "ffmpeg_7_0" ) ) ]
143159 let layout = ChannelLayout :: from_bits_truncate ( * self . ptr ) ;
160+
161+ #[ cfg( feature = "ffmpeg_7_0" ) ]
162+ let layout = ChannelLayout :: from ( * self . ptr ) ;
163+
144164 self . ptr = self . ptr . offset ( 1 ) ;
145165
146166 Some ( layout)
0 commit comments