mirror of
https://github.com/v0l/zap-stream-core.git
synced 2025-06-20 10:47:02 +00:00
Remove opaque pointers in pkts
This commit is contained in:
61
src/utils.rs
61
src/utils.rs
@ -13,63 +13,4 @@ pub fn get_ffmpeg_error_msg(ret: libc::c_int) -> String {
|
||||
av_make_error_string(buf.as_mut_ptr(), BUF_SIZE, ret);
|
||||
String::from(CStr::from_ptr(buf.as_ptr()).to_str().unwrap())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn variant_id_ref(var: &VariantStream) -> Result<*mut AVBufferRef, Error> {
|
||||
unsafe {
|
||||
match var {
|
||||
VariantStream::Audio(va) => {
|
||||
let buf = av_buffer_allocz(16);
|
||||
memcpy(
|
||||
(*buf).data as *mut libc::c_void,
|
||||
va.id.as_bytes().as_ptr() as *const libc::c_void,
|
||||
16,
|
||||
);
|
||||
Ok(buf)
|
||||
}
|
||||
VariantStream::Video(vv) => {
|
||||
let buf = av_buffer_allocz(16);
|
||||
memcpy(
|
||||
(*buf).data as *mut libc::c_void,
|
||||
vv.id.as_bytes().as_ptr() as *const libc::c_void,
|
||||
16,
|
||||
);
|
||||
Ok(buf)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn video_variant_id_ref(var: &VideoVariant) -> *mut AVBufferRef {
|
||||
unsafe {
|
||||
let buf = av_buffer_allocz(16);
|
||||
memcpy(
|
||||
(*buf).data as *mut libc::c_void,
|
||||
var.id.as_bytes().as_ptr() as *const libc::c_void,
|
||||
16,
|
||||
);
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
pub fn audio_variant_id_ref(var: &AudioVariant) -> *mut AVBufferRef {
|
||||
unsafe {
|
||||
let buf = av_buffer_allocz(16);
|
||||
memcpy(
|
||||
(*buf).data as *mut libc::c_void,
|
||||
var.id.as_bytes().as_ptr() as *const libc::c_void,
|
||||
16,
|
||||
);
|
||||
buf
|
||||
}
|
||||
}
|
||||
|
||||
pub fn id_ref_to_uuid(buf: *mut AVBufferRef) -> Result<Uuid, Error> {
|
||||
unsafe {
|
||||
if buf.is_null() {
|
||||
return Err(Error::msg("Buffer was null"));
|
||||
}
|
||||
let binding = Bytes::from(*((*buf).data as *const [u8; 16]));
|
||||
Ok(*Uuid::from_bytes_ref(&binding))
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user