192f3ab15Sopenharmony_ciuse crate::stack::Stackable;
292f3ab15Sopenharmony_ciuse foreign_types::ForeignTypeRef;
392f3ab15Sopenharmony_ciuse libc::c_ulong;
492f3ab15Sopenharmony_ciuse std::ffi::CStr;
592f3ab15Sopenharmony_ciuse std::str;
692f3ab15Sopenharmony_ci
792f3ab15Sopenharmony_ci/// fake free method, since SRTP_PROTECTION_PROFILE is static
892f3ab15Sopenharmony_ciunsafe fn free(_profile: *mut ffi::SRTP_PROTECTION_PROFILE) {}
992f3ab15Sopenharmony_ci
1092f3ab15Sopenharmony_ciforeign_type_and_impl_send_sync! {
1192f3ab15Sopenharmony_ci    type CType = ffi::SRTP_PROTECTION_PROFILE;
1292f3ab15Sopenharmony_ci    fn drop = free;
1392f3ab15Sopenharmony_ci
1492f3ab15Sopenharmony_ci    pub struct SrtpProtectionProfile;
1592f3ab15Sopenharmony_ci    /// Reference to `SrtpProtectionProfile`.
1692f3ab15Sopenharmony_ci    pub struct SrtpProtectionProfileRef;
1792f3ab15Sopenharmony_ci}
1892f3ab15Sopenharmony_ci
1992f3ab15Sopenharmony_ciimpl Stackable for SrtpProtectionProfile {
2092f3ab15Sopenharmony_ci    type StackType = ffi::stack_st_SRTP_PROTECTION_PROFILE;
2192f3ab15Sopenharmony_ci}
2292f3ab15Sopenharmony_ci
2392f3ab15Sopenharmony_ciimpl SrtpProtectionProfileRef {
2492f3ab15Sopenharmony_ci    pub fn id(&self) -> SrtpProfileId {
2592f3ab15Sopenharmony_ci        SrtpProfileId::from_raw(unsafe { (*self.as_ptr()).id })
2692f3ab15Sopenharmony_ci    }
2792f3ab15Sopenharmony_ci    pub fn name(&self) -> &'static str {
2892f3ab15Sopenharmony_ci        unsafe { CStr::from_ptr((*self.as_ptr()).name as *const _) }
2992f3ab15Sopenharmony_ci            .to_str()
3092f3ab15Sopenharmony_ci            .expect("should be UTF-8")
3192f3ab15Sopenharmony_ci    }
3292f3ab15Sopenharmony_ci}
3392f3ab15Sopenharmony_ci
3492f3ab15Sopenharmony_ci/// An identifier of an SRTP protection profile.
3592f3ab15Sopenharmony_ci#[derive(Debug, Copy, Clone, PartialEq, Eq)]
3692f3ab15Sopenharmony_cipub struct SrtpProfileId(c_ulong);
3792f3ab15Sopenharmony_ci
3892f3ab15Sopenharmony_ciimpl SrtpProfileId {
3992f3ab15Sopenharmony_ci    pub const SRTP_AES128_CM_SHA1_80: SrtpProfileId =
4092f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AES128_CM_SHA1_80 as c_ulong);
4192f3ab15Sopenharmony_ci    pub const SRTP_AES128_CM_SHA1_32: SrtpProfileId =
4292f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AES128_CM_SHA1_32 as c_ulong);
4392f3ab15Sopenharmony_ci    pub const SRTP_AES128_F8_SHA1_80: SrtpProfileId =
4492f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AES128_F8_SHA1_80 as c_ulong);
4592f3ab15Sopenharmony_ci    pub const SRTP_AES128_F8_SHA1_32: SrtpProfileId =
4692f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AES128_F8_SHA1_32 as c_ulong);
4792f3ab15Sopenharmony_ci    pub const SRTP_NULL_SHA1_80: SrtpProfileId = SrtpProfileId(ffi::SRTP_NULL_SHA1_80 as c_ulong);
4892f3ab15Sopenharmony_ci    pub const SRTP_NULL_SHA1_32: SrtpProfileId = SrtpProfileId(ffi::SRTP_NULL_SHA1_32 as c_ulong);
4992f3ab15Sopenharmony_ci    #[cfg(any(boringssl, ossl110))]
5092f3ab15Sopenharmony_ci    pub const SRTP_AEAD_AES_128_GCM: SrtpProfileId =
5192f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AEAD_AES_128_GCM as c_ulong);
5292f3ab15Sopenharmony_ci    #[cfg(any(boringssl, ossl110))]
5392f3ab15Sopenharmony_ci    pub const SRTP_AEAD_AES_256_GCM: SrtpProfileId =
5492f3ab15Sopenharmony_ci        SrtpProfileId(ffi::SRTP_AEAD_AES_256_GCM as c_ulong);
5592f3ab15Sopenharmony_ci
5692f3ab15Sopenharmony_ci    /// Creates a `SrtpProfileId` from an integer representation.
5792f3ab15Sopenharmony_ci    pub fn from_raw(value: c_ulong) -> SrtpProfileId {
5892f3ab15Sopenharmony_ci        SrtpProfileId(value)
5992f3ab15Sopenharmony_ci    }
6092f3ab15Sopenharmony_ci
6192f3ab15Sopenharmony_ci    /// Returns the integer representation of `SrtpProfileId`.
6292f3ab15Sopenharmony_ci    #[allow(clippy::trivially_copy_pass_by_ref)]
6392f3ab15Sopenharmony_ci    pub fn as_raw(&self) -> c_ulong {
6492f3ab15Sopenharmony_ci        self.0
6592f3ab15Sopenharmony_ci    }
6692f3ab15Sopenharmony_ci}
67