* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef PERIPHERAL_API_H
#define PERIPHERAL_API_H
#include <stdint.h>
#define HIAI_MAX_CAMERA_COUNT (25)
#define HIAI_MAX_MIC_COUNT (25)
#define HIAI_MAX_CAMERARESOLUTION_COUNT (25)
enum LIBMEDIA_STATUS {
LIBMEDIA_STATUS_FAILED = 0,
LIBMEDIA_STATUS_OK,
};
int MediaLibInit();
int IsChipAlive(char *chipName);
uint32_t QueryCameraIds(int *cameraIds, uint32_t *count);
enum CameraStatus {
CAMERA_STATUS_OPEN = 1,
CAMERA_STATUS_CLOSED = 2,
CAMERA_NOT_EXISTS = 3,
CAMERA_STATUS_UNKOWN = 4,
};
enum CameraStatus QueryCameraStatus(int cameraId);
int OpenCamera(int cameraId);
enum CameraProperties {
CAMERA_PROP_RESOLUTION = 1,
CAMERA_PROP_FPS = 2,
CAMERA_PROP_IMAGE_FORMAT = 3,
CAMERA_PROP_SUPPORTED_RESOLUTION = 4,
CAMERA_PROP_CAP_MODE = 5,
CAMERA_PROP_BRIGHTNESS = 6,
CAMERA_PROP_CONTRAST = 7,
CAMERA_PROP_SATURATION = 8,
CAMERA_PROP_HUE = 9,
CAMERA_PROP_GAIN = 10,
CAMERA_PROP_EXPOSURE = 11,
};
enum CameraImageFormat {
CAMERA_IMAGE_YUV420_SP = 1,
};
enum CameraCapMode {
CAMERA_CAP_ACTIVE = 1,
CAMERA_CAP_PASSIVE = 2,
};
struct CameraResolution {
int width;
int height;
};
int SetCameraProperty(int cameraId, enum CameraProperties prop, const void *pInValue);
int GetCameraProperty(int cameraId, enum CameraProperties prop, void *pValue);
typedef int (*CAP_CAMERA_CALLBACK)(const void *pdata, int size, void *param);
int CapCamera(int cameraId, CAP_CAMERA_CALLBACK, void *param);
int ReadFrameFromCamera(int cameralId, void *pdata, int *size);
int CloseCamera(int cameraId);
enum MICCapMode {
MIC_CAP_ACTIVE = 1,
MIC_CAP_PASSIVE = 2,
};
enum AudioSampleRate {
MIC_AUDIO_SAMPLE_RATE_8000 = 8000,
MIC_AUDIO_SAMPLE_RATE_12000 = 12000,
MIC_AUDIO_SAMPLE_RATE_11025 = 11025,
MIC_AUDIO_SAMPLE_RATE_16000 = 16000,
MIC_AUDIO_SAMPLE_RATE_22050 = 22050,
MIC_AUDIO_SAMPLE_RATE_24000 = 24000,
MIC_AUDIO_SAMPLE_RATE_32000 = 32000,
MIC_AUDIO_SAMPLE_RATE_44100 = 44100,
MIC_AUDIO_SAMPLE_RATE_48000 = 48000,
MIC_AUDIO_SAMPLE_RATE_64000 = 64000,
MIC_AUDIO_SAMPLE_RATE_96000 = 96000,
MIC_AUDIO_SAMPLE_RATE_BUTT,
};
enum AudioSampleNumPerFrame {
MIC_SAMPLE_NUM_80 = 80,
MIC_SAMPLE_NUM_160 = 160,
MIC_SAMPLE_NUM_240 = 240,
MIC_SAMPLE_NUM_320 = 320,
MIC_SAMPLE_NUM_480 = 480,
MIC_SAMPLE_NUM_1024 = 1024,
MIC_SAMPLE_NUM_2048 = 2048,
};
enum AudioBitWidth {
MIC_AUDIO_BIT_WIDTH_16 = 1,
MIC_AUDIO_BIT_WIDTH_24 = 2,
MIC_AUDIO_BIT_WIDTH_BUTT,
};
enum AudioMode {
MIC_AUDIO_SOUND_MODE_MONO = 0,
MIC_AUDIO_SOUND_MODE_STEREO = 1,
MIC_AUDIO_SOUND_MODE_BUTT
};
struct MICProperties {
enum AudioSampleRate sample_rate;
enum MICCapMode cap_mode;
enum AudioBitWidth bit_width;
enum AudioSampleNumPerFrame frame_sample_rate;
enum AudioMode sound_mode;
};
enum MICStatus {
MIC_STATUS_OPEN = 1,
MIC_STATUS_CLOSED = 2,
MIC_NOT_EXISTS = 3,
MIC_STATUS_UNKOWN = 4,
};
enum MICStatus QueryMICStatus();
int OpenMIC();
int SetMICProperty(struct MICProperties *propties);
int GetMICProperty(struct MICProperties *propties);
typedef int (*CAP_MIC_CALLBACK)(const void *pdata, int size, void *param);
int CapMIC(CAP_MIC_CALLBACK, void *param);
int ReadMicSound(void *pdata, int *size);
int CloseMIC();
#endif