Skip to content

Commit

Permalink
fix AvioContext write_packet callback changed in ffmpeg 7
Browse files Browse the repository at this point in the history
  • Loading branch information
gerwin3 committed Apr 16, 2024
1 parent cf949ee commit 734e1da
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::env;

fn main() {
for (name, _value) in env::vars() {
if name.starts_with("DEP_FFMPEG_") {
println!(
r#"cargo:rustc-cfg=feature="{}""#,
name["DEP_FFMPEG_".len()..name.len()].to_lowercase()
);
}
}
}
9 changes: 7 additions & 2 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub fn output_raw_packetized_buf_start(
// No `read_packet`.
None,
// Passthrough for `write_packet`.
Some(output_raw_buf_start_callback as _),
Some(output_raw_buf_start_callback),
// No `seek`.
None,
);
Expand Down Expand Up @@ -436,11 +436,16 @@ pub fn init_logging() {
}
}

#[cfg(feature = "ffmpeg_7_0")]
type __AvioContextWritePacketCbParam2Type = *const u8;
#[cfg(not(feature = "ffmpeg_7_0"))]
type __AvioContextWritePacketCbParam2Type = *mut u8;

/// Passthrough function that is passed to `libavformat` in `avio_alloc_context` and pushes buffers
/// from a packetized stream onto the packet buffer held in `opaque`.
extern "C" fn output_raw_buf_start_callback(
opaque: *mut std::ffi::c_void,
buffer: *mut u8,
buffer: __AvioContextWritePacketCbParam2Type,
buffer_size: i32,
) -> i32 {
unsafe {
Expand Down

0 comments on commit 734e1da

Please sign in to comment.