File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -33,16 +33,17 @@ av_dump_format(
3333For the uninitiated, the std includes lots of convenient ffi related utilities. E.g. using ` std::slice::from_raw_parts ` :
3434``` rust
3535let ifmt_ctx : AVFormatContext = * ifmt_ctx ;
36+ let nb_streams = (* ifmt_ctx ). nb_streams as usize ;
3637
3738// Extract video/audio/etc. streams from our mp4 file
38- let streams : & [ AVStream ] = std :: slice :: from_raw_parts (
39- * ifmt_ctx . streams,
40- ifmt_ctx . nb_streams as usize
41- );
39+ let streams : Vec < AVStream > = std :: slice :: from_raw_parts (( * ifmt_ctx ) . streams, nb_streams )
40+ . iter ()
41+ . map ( | x | * ( * x ))
42+ . collect :: < Vec < AVStream >>( );
4243
4344// C bindings require zero for loops 😌 - instead turn C dynamic arrays into Rust array refs
44- for stream in std :: slice :: from_raw_parts (* ifmt_ctx . streams, ifmt_ctx . nb_streams as usize ) {
45- /// ... stream is of type '&AVStream'
45+ for stream_ptr in std :: slice :: from_raw_parts (( * ifmt_ctx ) . streams, nb_streams ) {
46+ // ...
4647}
4748```
4849
You can’t perform that action at this time.
0 commit comments