#![allow(
non_snake_case,
non_camel_case_types,
dead_code,
clippy::upper_case_acronyms
)]
use std::ffi::c_char;
use std::os::raw::c_void;
pub const OH_DISPLAY_NAME_LENGTH: usize = 32;
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NativeDisplayManager_ErrorCode {
Ok = 0,
NoPermission = 201,
NotSystemApp = 202,
InvalidParam = 401,
DeviceNotSupported = 801,
InvalidScreen = 1400001,
InvalidCall = 1400002,
SystemAbnormal = 1400003,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NativeDisplayManager_Rotation {
Rotation0 = 0,
Rotation90 = 1,
Rotation180 = 2,
Rotation270 = 3,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NativeDisplayManager_Orientation {
Portrait = 0,
Landscape = 1,
PortraitInverted = 2,
LandscapeInverted = 3,
Unknown = 4,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NativeDisplayManager_DisplayState {
Unknown = 0,
Off = 1,
On = 2,
Doze = 3,
DozeSuspend = 4,
VR = 5,
OnSuspend = 6,
}
#[repr(C)]
pub struct NativeDisplayManager_DisplayHdrFormat {
pub hdrFormatLength: u32,
pub hdrFormats: *mut u32,
}
#[repr(C)]
pub struct NativeDisplayManager_DisplayColorSpace {
pub colorSpaceLength: u32,
pub colorSpaces: *mut u32,
}
#[repr(C)]
pub struct NativeDisplayManager_DisplayInfo {
pub id: u32,
pub name: [c_char; OH_DISPLAY_NAME_LENGTH + 1],
pub isAlive: bool,
pub width: i32,
pub height: i32,
pub physicalWidth: i32,
pub physicalHeight: i32,
pub refreshRate: u32,
pub availableWidth: u32,
pub availableHeight: u32,
pub densityDPI: f32,
pub densityPixels: f32,
pub scaledDensity: f32,
pub xDPI: f32,
pub yDPI: f32,
pub rotation: NativeDisplayManager_Rotation,
pub state: NativeDisplayManager_DisplayState,
pub orientation: NativeDisplayManager_Orientation,
pub hdrFormat: *mut NativeDisplayManager_DisplayHdrFormat,
pub colorSpace: *mut NativeDisplayManager_DisplayColorSpace,
}
#[repr(C)]
pub struct NativeDisplayManager_DisplaysInfo {
pub displaysLength: u32,
pub displaysInfo: *mut NativeDisplayManager_DisplayInfo,
}
#[repr(C)]
pub struct OH_AVScreenCapture {
_opaque: [u8; 0],
}
#[repr(C)]
pub struct OH_AVBuffer {
_opaque: [u8; 0],
}
#[repr(C)]
pub struct OH_NativeBuffer {
_opaque: [u8; 0],
}
#[repr(C)]
pub struct OH_PixelmapNative {
_opaque: [u8; 0],
}
#[repr(C)]
pub struct OH_Pixelmap_ImageInfo {
_opaque: [u8; 0],
}
pub const PIXEL_FORMAT_RGBA_8888: i32 = 3;
pub const PIXEL_FORMAT_BGRA_8888: i32 = 4;
pub const IMAGE_SUCCESS: i32 = 0;
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_CaptureMode {
HomeScreen = 0,
SpecifiedScreen = 1,
SpecifiedWindow = 2,
Invalid = -1,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_DataType {
OriginalStream = 0,
EncodedStream = 1,
CaptureFile = 2,
Invalid = -1,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_VideoSourceType {
Yuv = 0,
Es = 1,
Rgba = 2,
Butt = 3,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_AudioCaptureSourceType {
Invalid = -1,
Default = 0,
Mic = 1,
AllPlayback = 2,
AppPlayback = 3,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_AudioCodecFormat {
AudioDefault = 0,
AacLc = 3,
Butt = 100,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_VideoCodecFormat {
VideoDefault = 0,
H264 = 2,
H265 = 4,
Mpeg4 = 6,
VP8 = 8,
VP9 = 10,
Butt = 100,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_ContainerFormatType {
M4A = 0,
MP4 = 1,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_AVScreenCaptureBufferType {
Video = 0,
AudioInner = 1,
AudioMic = 2,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_AVScreenCaptureStateCode {
Started = 0,
Canceled = 1,
StoppedByUser = 2,
InterruptedByOther = 3,
StoppedByCall = 4,
MicUnavailable = 5,
MicMutedByUser = 6,
MicUnmutedByUser = 7,
EnterPrivateScene = 8,
ExitPrivateScene = 9,
StoppedByUserSwitches = 10,
}
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OH_AVSCREEN_CAPTURE_ErrCode {
Ok = 0,
NoMemory = 1,
OperateNotPermit = 2,
InvalidVal = 3,
IO = 4,
Timeout = 5,
Unknown = 6,
ServiceDied = 7,
InvalidState = 8,
Unsupport = 9,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OH_AudioCaptureInfo {
pub audioSampleRate: i32,
pub audioChannels: i32,
pub audioSource: OH_AudioCaptureSourceType,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OH_AudioEncInfo {
pub audioBitrate: i32,
pub audioCodecformat: OH_AudioCodecFormat,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OH_AudioInfo {
pub micCapInfo: OH_AudioCaptureInfo,
pub innerCapInfo: OH_AudioCaptureInfo,
pub audioEncInfo: OH_AudioEncInfo,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct OH_VideoCaptureInfo {
pub displayId: u64,
pub missionIDs: *mut i32,
pub missionIDsLen: i32,
pub videoFrameWidth: i32,
pub videoFrameHeight: i32,
pub videoSource: OH_VideoSourceType,
}
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct OH_VideoEncInfo {
pub videoCodec: OH_VideoCodecFormat,
pub videoBitrate: i32,
pub videoFrameRate: i32,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct OH_VideoInfo {
pub videoCapInfo: OH_VideoCaptureInfo,
pub videoEncInfo: OH_VideoEncInfo,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct OH_RecorderInfo {
pub url: *const c_char,
pub urlLen: i32,
pub fileFormat: OH_ContainerFormatType,
}
#[repr(C)]
pub struct OH_AVScreenCaptureConfig {
pub captureMode: OH_CaptureMode,
pub dataType: OH_DataType,
pub audioInfo: OH_AudioInfo,
pub videoInfo: OH_VideoInfo,
pub recorderInfo: OH_RecorderInfo,
}
pub type OH_AVScreenCapture_OnStateChange = unsafe extern "C" fn(
capture: *mut OH_AVScreenCapture,
state_code: OH_AVScreenCaptureStateCode,
user_data: *mut c_void,
);
pub type OH_AVScreenCapture_OnError =
unsafe extern "C" fn(capture: *mut OH_AVScreenCapture, error_code: i32, user_data: *mut c_void);
pub type OH_AVScreenCapture_OnBufferAvailable = unsafe extern "C" fn(
capture: *mut OH_AVScreenCapture,
buffer: *mut OH_AVBuffer,
buffer_type: OH_AVScreenCaptureBufferType,
timestamp: i64,
user_data: *mut c_void,
);
#[link(name = "native_display_manager")]
unsafe extern "C" {
pub fn OH_NativeDisplayManager_CreateAllDisplays(
all_displays: *mut *mut NativeDisplayManager_DisplaysInfo,
) -> NativeDisplayManager_ErrorCode;
pub fn OH_NativeDisplayManager_DestroyAllDisplays(
all_displays: *mut NativeDisplayManager_DisplaysInfo,
);
pub fn OH_NativeDisplayManager_CreatePrimaryDisplay(
display_info: *mut *mut NativeDisplayManager_DisplayInfo,
) -> NativeDisplayManager_ErrorCode;
pub fn OH_NativeDisplayManager_DestroyDisplay(
display_info: *mut NativeDisplayManager_DisplayInfo,
);
pub fn OH_NativeDisplayManager_GetDisplayPosition(
display_id: u64,
x: *mut i32,
y: *mut i32,
) -> NativeDisplayManager_ErrorCode;
pub fn OH_NativeDisplayManager_CaptureScreenPixelmap(
display_id: u32,
pixel_map: *mut *mut OH_PixelmapNative,
) -> i32;
}
#[link(name = "native_avscreen_capture")]
unsafe extern "C" {
pub fn OH_AVScreenCapture_Create() -> *mut OH_AVScreenCapture;
pub fn OH_AVScreenCapture_Init(
capture: *mut OH_AVScreenCapture,
config: OH_AVScreenCaptureConfig,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_StartScreenCapture(
capture: *mut OH_AVScreenCapture,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_StopScreenCapture(
capture: *mut OH_AVScreenCapture,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_Release(
capture: *mut OH_AVScreenCapture,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_SetStateCallback(
capture: *mut OH_AVScreenCapture,
callback: OH_AVScreenCapture_OnStateChange,
user_data: *mut c_void,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_SetDataCallback(
capture: *mut OH_AVScreenCapture,
callback: OH_AVScreenCapture_OnBufferAvailable,
user_data: *mut c_void,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_SetErrorCallback(
capture: *mut OH_AVScreenCapture,
callback: OH_AVScreenCapture_OnError,
user_data: *mut c_void,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
pub fn OH_AVScreenCapture_AcquireVideoBuffer(
capture: *mut OH_AVScreenCapture,
fence: *mut i32,
timestamp: *mut i64,
region: *mut OH_Rect,
) -> *mut OH_NativeBuffer;
pub fn OH_AVScreenCapture_ReleaseVideoBuffer(
capture: *mut OH_AVScreenCapture,
) -> OH_AVSCREEN_CAPTURE_ErrCode;
}
#[repr(C)]
#[derive(Debug, Clone, Copy, Default)]
pub struct OH_Rect {
pub x: i32,
pub y: i32,
pub width: i32,
pub height: i32,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, Default)]
pub struct OH_NativeBuffer_Config {
pub width: i32,
pub height: i32,
pub format: i32,
pub usage: i32,
pub stride: i32,
}
#[link(name = "pixelmap")]
unsafe extern "C" {
pub fn OH_PixelmapImageInfo_Create(info: *mut *mut OH_Pixelmap_ImageInfo) -> i32;
pub fn OH_PixelmapImageInfo_GetWidth(info: *mut OH_Pixelmap_ImageInfo, width: *mut u32) -> i32;
pub fn OH_PixelmapImageInfo_GetHeight(
info: *mut OH_Pixelmap_ImageInfo,
height: *mut u32,
) -> i32;
pub fn OH_PixelmapImageInfo_GetRowStride(
info: *mut OH_Pixelmap_ImageInfo,
row_stride: *mut u32,
) -> i32;
pub fn OH_PixelmapImageInfo_GetPixelFormat(
info: *mut OH_Pixelmap_ImageInfo,
pixel_format: *mut i32,
) -> i32;
pub fn OH_PixelmapImageInfo_Release(info: *mut OH_Pixelmap_ImageInfo) -> i32;
pub fn OH_PixelmapNative_GetImageInfo(
pixelmap: *mut OH_PixelmapNative,
image_info: *mut OH_Pixelmap_ImageInfo,
) -> i32;
pub fn OH_PixelmapNative_ReadPixels(
pixelmap: *mut OH_PixelmapNative,
destination: *mut u8,
buffer_size: *mut usize,
) -> i32;
pub fn OH_PixelmapNative_Release(pixelmap: *mut OH_PixelmapNative) -> i32;
}
#[link(name = "native_media_core")]
unsafe extern "C" {
pub fn OH_AVBuffer_GetAddr(buffer: *mut OH_AVBuffer) -> *mut u8;
pub fn OH_AVBuffer_GetCapacity(buffer: *mut OH_AVBuffer) -> i32;
pub fn OH_AVBuffer_GetNativeBuffer(buffer: *mut OH_AVBuffer) -> *mut OH_NativeBuffer;
}
#[link(name = "native_buffer")]
unsafe extern "C" {
pub fn OH_NativeBuffer_Unreference(buffer: *mut OH_NativeBuffer) -> i32;
pub fn OH_NativeBuffer_GetConfig(
buffer: *mut OH_NativeBuffer,
config: *mut OH_NativeBuffer_Config,
);
pub fn OH_NativeBuffer_Map(
buffer: *mut OH_NativeBuffer,
vir_addr: *mut *mut std::os::raw::c_void,
) -> i32;
pub fn OH_NativeBuffer_Unmap(buffer: *mut OH_NativeBuffer) -> i32;
}