1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use crate::{avcodec::AVCodecContext, ffi, shared::*};
use std::{clone::Clone, default::Default, ops::Drop};
wrap_ref_mut!(AVCodecParameters: ffi::AVCodecParameters);
impl AVCodecParameters {
pub fn new() -> Self {
let ptr = unsafe { ffi::avcodec_parameters_alloc() }
.upgrade()
.unwrap();
unsafe { Self::from_raw(ptr) }
}
pub fn from_context(&mut self, context: &AVCodecContext) {
unsafe { ffi::avcodec_parameters_from_context(self.as_mut_ptr(), context.as_ptr()) }
.upgrade()
.unwrap();
}
pub fn copy(&mut self, from: &Self) {
unsafe { ffi::avcodec_parameters_copy(self.as_mut_ptr(), from.as_ptr()) }
.upgrade()
.unwrap();
}
}
impl Default for AVCodecParameters {
fn default() -> Self {
Self::new()
}
}
impl Clone for AVCodecParameters {
fn clone(&self) -> Self {
let mut parameters = AVCodecParameters::new();
parameters.copy(self);
parameters
}
}
impl Drop for AVCodecParameters {
fn drop(&mut self) {
let mut ptr = self.as_mut_ptr();
unsafe { ffi::avcodec_parameters_free(&mut ptr) }
}
}