目录

Interface Summary

FileName

Description

dmsdp_camera_handler.h

Contains southbound camera adaptation APIs.

Public Method Summary

The DMSDPGetCameraHandler API obtains camera methods.

Format: int32_t DMSDPGetCameraHandler(DMSDPCameraHandler* cameraHandler)

Parameter: [in] N/A [out] cameraHandler

Output: The value 0 indicates success and negative values indicate failure.

Description: Obtains the camera functions, stored in the DMSDPCameraHandler structure.

Public Methods

[h2]RegisterSendDataCallback

Method

int32_t (*RegisterSendDataCallback)(const char* id, uint32_t idLen, const DMSDPSendBackDataCB cb)

Registers a callback for obtaining camera images.

Parameters

Name

Description

id

Camera ID.

idLen

Length of the camera ID.

cb

Callback function.

typedef int32_t (*DMSDPSendBackDataCB)(const uint8_t* buffer, uint32_t len, int32_t type)

buffer: Video stream data address.

len: Video stream length.

type: Video stream type (DMSDPCameraDataType).

typedef enum {

H264 = 1,

H265 = 2,

RGB565 = 4,

NV21 = 17

} DMSDPCameraDataType;

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]OpenCamera

Method

int32_t (*OpenCamera)(const DMSDPCameraParam* param)

Opens the camera to obtain images.

Parameters

Name

Description

param

Parameter object of the camera. The definition is as follows:

typedef struct {

/* id of camera */

const char* id;

uint32_t idLen;

/* frame width */

uint32_t width;

/* frame height */

uint32_t height;

/* fps */

uint32_t fps;

/* DMSDPCameraDataType */

uint32_t dataFormat;

} DMSDPCameraParam;

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]CloseCamera

Method

int32_t (*CloseCamera)(const char* id, uint32_t idLen)

Closes the camera.

Parameters

Name

Description

id

Camera ID.

idLen

Length of the camera ID.

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]UpdateConfig

Method

int32_t (*UpdateConfig)(const char* id, uint32_t idLen, int32_t key, char* value, uint32_t valLen)

Updates the camera configurations.

Parameters

Name

Description

id

Camera ID.

idLen

Length of the camera ID.

key

Parameter type.

typedef enum {

FPS,

} DSMDPCameraConfigKey;

value

Parameter string.

valLen

Parameter length.

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]GetCameraCapability

Method

int32_t (*GetCameraCapability)(DMSDPCameraCapabilities** capabilities, uint32_t* num)

Queries camera capabilities.

Parameters

Name

Description

char* id

Camera ID.

uint32_t idLen

Length of the camera ID.

DMSDPCameraAbility* abilities

typedef struct {

uint32_t min;

uint32_t max;

} DMSDPFpsRange;

typedef struct {

uint32_t width;

uint32_t height;

} DMSDPSize;

typedef struct {

DMSDPFpsRange*supportFpsRanges;

uint32_t fpsRangeNum;

DMSDPSize* supportSizes;

uint32_t sizeNum;

DMSDPCameraDataType dataType;

} DMSDPCameraAbility;

Camera capability.

supportFpsRanges: Frame rate range.

FpsRange: An integer multiple of 1000, for example, {20000, 30000} indicates 20–30 FPS.

fpsRangeNum: Number of lists.

supportSizes: Resolution list.

DMSDPSize: Length and width of the resolution, for example, {1280, 720} indicates the resolution of 1280*720.

sizeNum: Number of lists.

dataType: Supported frame types.

typedef enum {

H264 = 1,

H265 = 2,

RGB565 = 4,

NV21 = 17

} DMSDPCameraDataType;

Note: Select either H.264 or H.265, either RGB565 or NV21, and either video encoding transmission or original video frame mode.

uint32_t abilityNum;

Number of capability sets. Each type has one capability set.

DMSDPExtendInfos extendInfos

typedef struct {

char* key;

uint32_t keyLen;

char* value;

uint32_t valueLen;

} DMSDPExtendInfo;

typedef struct {

DMSDPExtendInfo* infos;

uint32_t num;

} DMSDPExtendInfos;

Reserved for extended information.

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]GetCameraCapabilityString

Method

const char* (*GetCameraCapabilityString)(uint32_t* len)

Queries camera capabilities.

Parameters

Name

Description

len

Length of the JSON string of the camera capability.

Return

Type

Description

const char*

Camera capability set.

[h2]Release

Method

void (*Release)(int32_t type, void* ptr, uint32_t num)

Releases resources.

Parameters

Name

Description

type

Type of resource to be released.

typedef enum {

RELEASE_TYPE_QUERY_ABLITIY = 1

} DMSDPCameraReleaseType;

Corresponds to QueryCameraCapability.

ptr

Corresponds to DMSDPCameraCapabilities* capabilities.

num

Number of cameras.

[h2]RegisterListener

Method

int32_t (*RegisterListener)(const DMSDPListener* listener)

Registers a listener.

Parameters

Name

Description

listener

Listener callback list.

dmsdp_business.h:

typedef struct {

int32_t (*UpdateServiceStatus)(const char* id, uint32_t idLen, const DMSDPServiceStatus status);

int32_t (*UpdateServiceAction)(const char* id, uint32_t idLen, DMSDPServiceAction* action);

} DMSDPListener;

typedef enum {

/* The peripheral is connected to the device, such as USB camera. */

PLUGIN = 1,

/* The peripheral is disconnected from the device, for example, a USB camera is removed from the head unit. */

UNPLUG,

/* The peripheral is connected to the device and is available. */

AVAILABLE,

/* The peripheral is connected to the device, but is unavailable because it's being used by another app. */

UNAVAILABLE,

} DMSDPServiceStatus;

Return

Type

Description

int32_t

0: Success; <0: Failure.

[h2]BusinessControl

Method

int32_t (*BusinessControl)(uint32_t cmd, void* inputPara, uint32_t inLen, void* outputPara, uint32_t outLen)

Controls the service.

Parameters

Name

Description

cmd

Command (reserved for extension).

typedef enum {

MSDP_BUSINESS_CTRL_RESERVED = 0

} DMSDPBusinessControlCmd;

inputPara

Input parameter.

inLen

Length of the input parameter.

outputPara

Output parameter.

outLen

Length of the output parameter.

Return

Type

Description

int32_t

0: Success; <0: Failure.