1use crate::ffi;
2use crate::stack::Stackable;
3use foreign_types::ForeignTypeRef;
4use libc::c_ulong;
5use std::ffi::CStr;
6use std::str;
7
8unsafe fn free(_profile: *mut ffi::SRTP_PROTECTION_PROFILE) {}
10
11foreign_type_and_impl_send_sync! {
12 type CType = ffi::SRTP_PROTECTION_PROFILE;
13 fn drop = free;
14
15 pub struct SrtpProtectionProfile;
16}
17
18impl Stackable for SrtpProtectionProfile {
19 type StackType = ffi::stack_st_SRTP_PROTECTION_PROFILE;
20}
21
22impl SrtpProtectionProfileRef {
23 pub fn id(&self) -> SrtpProfileId {
24 SrtpProfileId::from_raw(unsafe { (*self.as_ptr()).id })
25 }
26 pub fn name(&self) -> &'static str {
27 unsafe { CStr::from_ptr((*self.as_ptr()).name as *const _) }
28 .to_str()
29 .expect("should be UTF-8")
30 }
31}
32
33#[derive(Debug, Copy, Clone, PartialEq, Eq)]
35pub struct SrtpProfileId(c_ulong);
36
37impl SrtpProfileId {
38 pub const SRTP_AES128_CM_SHA1_80: SrtpProfileId =
39 SrtpProfileId(ffi::SRTP_AES128_CM_SHA1_80 as _);
40 pub const SRTP_AES128_CM_SHA1_32: SrtpProfileId =
41 SrtpProfileId(ffi::SRTP_AES128_CM_SHA1_32 as _);
42 pub const SRTP_AES128_F8_SHA1_80: SrtpProfileId =
43 SrtpProfileId(ffi::SRTP_AES128_F8_SHA1_80 as _);
44 pub const SRTP_AES128_F8_SHA1_32: SrtpProfileId =
45 SrtpProfileId(ffi::SRTP_AES128_F8_SHA1_32 as _);
46 pub const SRTP_NULL_SHA1_80: SrtpProfileId = SrtpProfileId(ffi::SRTP_NULL_SHA1_80 as _);
47 pub const SRTP_NULL_SHA1_32: SrtpProfileId = SrtpProfileId(ffi::SRTP_NULL_SHA1_32 as _);
48
49 pub fn from_raw(value: c_ulong) -> SrtpProfileId {
51 SrtpProfileId(value)
52 }
53
54 #[allow(clippy::trivially_copy_pass_by_ref)]
56 pub fn as_raw(&self) -> c_ulong {
57 self.0
58 }
59}