File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,12 @@ impl Clone for AVChannelLayout {
4747}
4848
4949impl AVChannelLayout {
50+ /// Create a new channel layout from raw, user need to be sure that channel
51+ /// layout is correctly constructed.
52+ pub unsafe fn new ( ch_layout : ffi:: AVChannelLayout ) -> Self {
53+ unsafe { Self :: from_raw ( NonNull :: new ( Box :: into_raw ( Box :: new ( ch_layout) ) ) . unwrap ( ) ) }
54+ }
55+
5056 /// Convert self into [`ffi::AVChannelLayout`]`.
5157 ///
5258 /// Be careful when using it. Since this fucntion leaks the raw type,
@@ -203,6 +209,14 @@ impl AVChannelLayout {
203209 }
204210}
205211
212+ impl AVChannelLayoutRef < ' _ > {
213+ /// Create a new channel layout reference from raw, user need to be sure
214+ /// that channel layout is correctly constructed.
215+ pub unsafe fn new ( ch_layout : & ffi:: AVChannelLayout ) -> Self {
216+ unsafe { Self :: from_raw ( NonNull :: new ( ch_layout as * const _ as * mut _ ) . unwrap ( ) ) }
217+ }
218+ }
219+
206220/// Iterate over all standard channel layouts.
207221pub struct AVChannelLayoutIter {
208222 opaque : * mut c_void ,
You can’t perform that action at this time.
0 commit comments