GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)

This commit is contained in:
lai
2026-09-06 03:52:57 +08:00
commit b1928b41c0
21813 changed files with 4413081 additions and 0 deletions
+120
View File
@@ -0,0 +1,120 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef __LIST_H__
#define __LIST_H__
#ifndef _LINUX_LIST_H
#define INIT_LIST_HEAD(ptr) \
do { \
(ptr)->next = (ptr); \
(ptr)->prev = (ptr); \
} while (0)
#define LIST_HEAD_INIT(name) { &(name), &(name) }
struct list_head {
struct list_head *next, *prev;
};
static inline void __list_add(struct list_head * _new, struct list_head * prev, struct list_head * next)
{
next->prev = _new;
_new->next = next;
_new->prev = prev;
prev->next = _new;
}
static inline void list_add(struct list_head *_new, struct list_head *head)
{
__list_add(_new, head, head->next);
}
static inline void list_add_tail(struct list_head *_new, struct list_head *head)
{
__list_add(_new, head->prev, head);
}
static inline void __list_del(struct list_head * prev, struct list_head * next)
{
next->prev = prev;
prev->next = next;
}
static inline void list_del(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
}
static inline void list_del_init(struct list_head *entry)
{
__list_del(entry->prev, entry->next);
INIT_LIST_HEAD(entry);
}
static inline void list_move(struct list_head *list, struct list_head *head)
{
__list_del(list->prev, list->next);
list_add(list, head);
}
static inline void list_move_tail(struct list_head *list,
struct list_head *head)
{
__list_del(list->prev, list->next);
list_add_tail(list, head);
}
static inline int list_empty(struct list_head *head)
{
return head->next == head;
}
static inline void __list_splice(struct list_head *list,
struct list_head *head)
{
struct list_head *first = list->next;
struct list_head *last = list->prev;
struct list_head *at = head->next;
first->prev = head;
head->next = first;
last->next = at;
at->prev = last;
}
static inline void list_splice(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
{
__list_splice(list, head);
}
}
static inline void list_splice_init(struct list_head *list, struct list_head *head)
{
if (!list_empty(list))
{
__list_splice(list, head);
INIT_LIST_HEAD(list);
}
}
#define list_entry(ptr, type, member) \
((type *)((uintptr_t)(ptr)-((unsigned long)(&((type *)1)->member) - 1)))
#define list_for_each(pos, head) \
for (pos = (head)->next; pos != (head); pos = pos->next)
#define list_for_each_safe(pos, n, head) \
for (pos = (head)->next, n = pos->next; pos != (head); \
pos = n, n = pos->next)
#define get_first_item(attached, type, member) \
((type *)((char *)((attached)->next)-(unsigned long)(&((type *)0)->member)))
#endif
#endif
+86
View File
@@ -0,0 +1,86 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef __XCAM_COMMON_H__
#define __XCAM_COMMON_H__
#include <stdlib.h>
#include "xcam_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif
typedef enum {
/* common */
XCAM_MOD_COMMON = 0x0,
XCAM_MOD_LOG = 0x1,
/* middleware */
XCAM_MOD_EVTHUB = 0x100,
XCAM_MOD_MBUF = 0x101,
XCAM_MOD_STORAGE = 0x102,
XCAM_MOD_TIMER = 0x103,
XCAM_MOD_MSGHANDLE = 0x104,
XCAM_MOD_BARCODE = 0x105,
XCAM_MOD_DCF = 0x106,
XCAM_MOD_DTCF = 0x107,
XCAM_MOD_TS = 0x108,
XCAM_MOD_MP4 = 0x109,
XCAM_MOD_EXIF = 0x10A,
XCAM_MOD_FSTOOL = 0x10B,
XCAM_MOD_RECORD = 0x10C,
XCAM_MOD_LIVESTREAM = 0x10D,
XCAM_MOD_STATEMACHINE = 0x10E,
XCAM_MOD_SYSLINK = 0x110,
XCAM_MOD_MAPI = 0x111,
XCAM_MOD_RTSP = 0x112,
/* product wrapper layer */
XCAM_MOD_FLASH = 0x200,
XCAM_MOD_CONFACCESS = 0x201,
XCAM_MOD_DEVMNG = 0x202,
XCAM_MOD_FILEMNG = 0x203,
XCAM_MOD_FILETRANS = 0x204,
XCAM_MOD_DEVHAL = 0x205,
XCAM_MOD_LIVESERVER = 0x206,
XCAM_MOD_MEDIA = 0x207,
XCAM_MOD_NETSERV = 0x208,
XCAM_MOD_PHOTOMNG = 0x209,
XCAM_MOD_PLAYBACK = 0x20A,
XCAM_MOD_PM = 0x20B,
XCAM_MOD_QUEUE = 0x20C,
XCAM_MOD_RAWCAP = 0x20D,
XCAM_MOD_RECORDMNG = 0x20E,
XCAM_MOD_SCENCEAUTO = 0x210,
XCAM_MOD_STORAGEMNG = 0x211,
XCAM_MOD_SYSCTL = 0x212,
XCAM_MOD_TIMEDTASK = 0x213,
XCAM_MOD_TIMESTAMP = 0x214,
XCAM_MOD_UPGRADE = 0x215,
XCAM_MOD_USBMNG = 0x216,
XCAM_MOD_VIDANALISIS = 0x217,
XCAM_MOD_VIDPROCESS = 0x218,
XCAM_MOD_UTILS = 0X219,
/* application */
XCAM_MOD_APPLICATION = 0x300,
XCAM_MOD_MAX
} xcam_mod_id;
#define XCAM_BUILD_ERRNO(module, errno) ((xcam_u32)((0x80000000L) | ((module) << 16) | (errno)))
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
+80
View File
@@ -0,0 +1,80 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef _XCAM_LIVESERVER_H_
#define _XCAM_LIVESERVER_H_
#include "xcam_define.h"
#include "xcam_log.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
/* name pattern that used in webserver distrib link */
#define XCAM_LIVESERVER_CONN_CNT_MIN 1
#define XCAM_LIVESERVER_CONN_CNT_MAX 32
enum {
ERR_CODE_INVALID_PARAM = 0x10,
ERR_CODE_NOT_INIT = 0x11,
ERR_CODE_WAS_INITED = 0x12,
ERR_CODE_ALREADY_EXISTED = 0x13,
ERR_CODE_NOT_FIND = 0x14,
ERR_CODE_NO_FREE_RESOURCE = 0x15,
ERR_CODE_BUTT
};
/* general error code */
#define XCAM_LIVESERVER_ERR_ILLEGAL_PARAM XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_INVALID_PARAM)
#define XCAM_LIVESERVER_ERR_NOT_INIT XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_NOT_INIT)
#define XCAM_LIVESERVER_ERR_WAS_INITED XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_WAS_INITED)
#define XCAM_LIVESERVER_ERR_EXISTED XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_ALREADY_EXISTED)
#define XCAM_LIVESERVER_ERR_NOT_FIND XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_NOT_FIND)
#define XCAM_LIVESERVER_ERR_NO_FREE_RESOURCE XCAM_BUILD_ERRNO(XCAM_MOD_LIVESERVER, ERR_CODE_NO_FREE_RESOURCE)
#define LOG_LIVESERVER_INFO(fmt...) XCAM_LOG_INFO_PRINT("liveserver", fmt);
#define LOG_LIVESERVER_WARN(fmt...) XCAM_LOG_WARN_PRINT("liveserver", fmt);
#define LOG_LIVESERVER_ERROR(fmt...) XCAM_LOG_ERR_PRINT("liveserver", fmt);
#define LOG_LIVESERVER_FATAL(fmt...) XCAM_LOG_FATAL_PRINT("liveserver", fmt);
#define PATTERN_NAME_LEN 16
typedef struct {
xcam_s32 max_conn_num;
xcam_u16 listen_port;
xcam_char pattern_name[PATTERN_NAME_LEN];
} xcam_liveserver_init_param;
xcam_s32 xcam_liveserver_add_stream(xcam_handle venc_handle, xcam_track_video_source_info *video_src_info,
xcam_handle aenc_handle, xcam_track_audio_source_info *audio_src_info,
const xcam_char* stream_name,
func_xcam_track_source_request_key_frame func_request_key_frame);
xcam_s32 xcam_liveserver_remove_stream(const xcam_char* stream_name);
xcam_s32 xcam_liveserver_remove_all_stream(xcam_void);
xcam_bool xcam_liveserver_is_init(xcam_void);
xcam_s32 xcam_liveserver_init(const xcam_liveserver_init_param param);
xcam_s32 xcam_liveserver_deinit(xcam_void);
xcam_s32 xcam_liveserver_send_video_data(xcam_handle venc_handle, xcam_livestream_rtsp_data *rtsp_data);
xcam_s32 xcam_liveserver_send_audio_data(xcam_handle aenc_handle, xcam_livestream_rtsp_data *rtsp_data);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /* _XCAM_LIVESERVER_H_ */
@@ -0,0 +1,150 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef _XCAM_LIVESTREAM_RTSP_SERVER_H_
#define _XCAM_LIVESTREAM_RTSP_SERVER_H_
#include "xcam_track_source.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
typedef struct server_state_listener {
/**
* @brief report of server internal error.
* @param[in] listener :listener obj
* @param[in] errid : server error id
* @param[in] msg : string server error message info
*/
xcam_void (*func_server_error)(struct server_state_listener* listener, xcam_s32 errid, xcam_char* msg);
/**
* @brief reporting client connected.
* @param[in] listener : listener obj
* @param[in] ipaddr : string connected client ipaddress
*/
xcam_void (*func_client_connect)(struct server_state_listener* listener, xcam_char* ipaddr);
/**
* @brief reporting client disconnected.
* @param[in] listener : listener obj
* @param[in] ipaddr : string disconnected client ipaddress
*/
xcam_void (*func_client_disconnect)(const struct server_state_listener* listener, const xcam_char* ipaddr);
/** handle for statelistener, do not change, used internal*/
xcam_void* handle;
} xcam_server_state_listener;
#define RTSPSVR_FRAME_MAX_BLOCK (8)
/** RTSP config object type*/
typedef struct {
xcam_s32 packet_len; /**< length of the send packet [500,5000]recommend 1500 unit:byte*/
xcam_s32 max_conn_num; /**< max connect client num[1,32]*/
xcam_s32 listen_port; /**< listen port of rtspserver[1,65535] normal 554*/
xcam_s32 max_payload; /**< max payloadtype num in mbuffer[1,254] normal 2*/
xcam_s32 timeout; /**<set the timeout of connect <0 for not use timeout unit: s*/
} xcam_livestream_rtsp_config;
typedef struct {
xcam_u8* data_ptr[RTSPSVR_FRAME_MAX_BLOCK]; /**< data address */
xcam_u32 data_len[RTSPSVR_FRAME_MAX_BLOCK]; /**< length of frame data */
xcam_u64 pts_us; /**< timestamp of frame unit:us*/
xcam_u32 seq_num; /**< frame sequence number */
xcam_u32 block_cnt;/**< block count for one frame*/
xcam_bool is_key_frame; /**< key frame flag */
} xcam_livestream_rtsp_data;
typedef struct {
xcam_track_source_handle video_src_handle;
xcam_track_source_handle audio_src_handle;
} xcam_livestream_rtsp_source;
/**
* @brief create server instance.
* @param[in,out] handle xcam_void* : return rtspserver handle
* @param[in] ptr_rtsp_config xcam_livestream_rtsp_config : rtsp config info
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_create(xcam_void** handle, xcam_livestream_rtsp_config* ptr_rtsp_config);
/**
* @brief destroy server instance.
* @param[in] handle xcam_void* : rtspserver handle
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_destroy(xcam_void* handle);
/**
* @brief make server running, could handle client connecting and request.
* @param[in] handle xcam_void* : rtspserver handle
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_start(xcam_void* handle);
/**
* @brief make server stoped, deny client connecting and request.
* @param[in] handle xcam_void* : rtspserver handle
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_stop(xcam_void* handle);
/**
* @brief add media source to server, client could use specified URL \n
* related with stream connect to this source.
* @param[in] handle xcam_void* : rtspserver handle
* @param[in] stream_name string : stream Name related with this mediaStream,max length 128
* @param[in] buf_size XM_U32: size of allocate mbuffer[216K,50M] suggest frame size*5 unit:byte
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_add_media_stream(xcam_void* handle, xcam_livestream_rtsp_source* stream_src,
xcam_char* stream_name, xcam_u32 buf_size);
/**
* @brief remove media source from server, client connecting with \n
* specified URL related with this stream will receive failing
* @param[in] handle xcam_void* : rtspserver handle
* @param[in] track_src xcam_track_source_handle : Source of outputing MediaInfo and \n
* @param[in] ptr_data xcam_livestream_rtsp_data : Media data \n
* VideoStream&AudioStream
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_write_frame(xcam_void* handle,
xcam_track_source_handle track_src, const xcam_livestream_rtsp_data* ptr_data);
/**
* @brief remove media source from server, client connecting with \n
* specified URL related with this stream will receive failing
* @param[in] handle xcam_void* : rtspserver handle
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_remove_media_stream(xcam_void* handle, const xcam_char* stream_name);
/**
* @brief setting listener for listenning client connect&disconnect, server internal error.
* @param[in] handle xcam_void* : rtspserver handle
* @param[in] ptr_listener xcam_server_state_listener : input listener object
* @return 0 success
* @return err num failure
*/
xcam_s32 xcam_livestream_rtsp_server_set_listener(xcam_void* handle, xcam_server_state_listener* ptr_listener);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif /*_XCAM_LIVESTREAM_RTSP_SERVER_H_*/
+93
View File
@@ -0,0 +1,93 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef __XCAM_LOG_H__
#define __XCAM_LOG_H__
#include "xcam_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif
typedef enum {
XCAM_LOG_LEVEL_FATAL = 0,
XCAM_LOG_LEVEL_ERR = 1,
XCAM_LOG_LEVEL_WARN = 2,
XCAM_LOG_LEVEL_INFO = 3,
XCAM_LOG_LEVEL_DBG = 4
} xcam_log_level;
typedef enum {
XCAM_LOG_MODE_PRINTF,
XCAM_LOG_MODE_FILE
} xcam_log_mode;
typedef struct {
xcam_log_level level;
xcam_log_mode mode;
xcam_u32 log_buffer_size;
} xcam_log_attr;
#define XCAM_LOG_TRACE(module, level, format...) \
do { \
xcam_log_output(module, level, __FUNCTION__, __LINE__, format); \
} while (0)
// use this config macro to optimize code size
#ifndef CONFIG_XCAM_LOG_LEVEL
#define CONFIG_XCAM_LOG_LEVEL 4
#endif
#if (CONFIG_XCAM_LOG_LEVEL == XCAM_LOG_LEVEL_FATAL)
#define XCAM_LOG_FATAL_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_FATAL, format)
#define XCAM_LOG_ERR_PRINT(module, format...)
#define XCAM_LOG_WARN_PRINT(module, format...)
#define XCAM_LOG_INFO_PRINT(module, format...)
#define XCAM_LOG_DBG_PRINT(module, format...)
#elif (CONFIG_XCAM_LOG_LEVEL == XCAM_LOG_LEVEL_ERR)
#define XCAM_LOG_FATAL_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_FATAL, format)
#define XCAM_LOG_ERR_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_ERR, format)
#define XCAM_LOG_WARN_PRINT(module, format...)
#define XCAM_LOG_INFO_PRINT(module, format...)
#define XCAM_LOG_DBG_PRINT(module, format...)
#elif (CONFIG_XCAM_LOG_LEVEL == XCAM_LOG_LEVEL_WARN)
#define XCAM_LOG_FATAL_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_FATAL, format)
#define XCAM_LOG_ERR_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_ERR, format)
#define XCAM_LOG_WARN_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_WARN, format)
#define XCAM_LOG_INFO_PRINT(module, format...)
#define XCAM_LOG_DBG_PRINT(module, format...)
#elif (CONFIG_XCAM_LOG_LEVEL == XCAM_LOG_LEVEL_INFO)
#define XCAM_LOG_FATAL_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_FATAL, format)
#define XCAM_LOG_ERR_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_ERR, format)
#define XCAM_LOG_WARN_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_WARN, format)
#define XCAM_LOG_INFO_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_INFO, format)
#define XCAM_LOG_DBG_PRINT(module, format...)
#else
#define XCAM_LOG_FATAL_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_FATAL, format)
#define XCAM_LOG_ERR_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_ERR, format)
#define XCAM_LOG_WARN_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_WARN, format)
#define XCAM_LOG_INFO_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_INFO, format)
#define XCAM_LOG_DBG_PRINT(module, format...) XCAM_LOG_TRACE(module, XCAM_LOG_LEVEL_DBG, format)
#endif
xcam_s32 xcam_log_init(xcam_void);
xcam_void xcam_log_deinit(xcam_void);
xcam_s32 xcam_log_set_attr(xcam_log_attr *attr);
xcam_s32 xcam_log_get_attr(xcam_log_attr *attr);
xcam_void xcam_log_output(const xcam_char *module, xcam_log_level level, const xcam_char *func, xcam_u32 line, const xcam_char *format, ...);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif
+170
View File
@@ -0,0 +1,170 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef __XCAM_MBUF_H__
#define __XCAM_MBUF_H__
#include "xcam_type.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif /* __cplusplus */
#define XCAM_MBUF_MAX_PACK (8)
#define XCAM_MBUF_PAYLOAD_TYPE_ALL (0xFFFE)
#define XCAM_MBUF_PAYLOAD_TYPE_INVALID (0xFFFF)
/* error number */
#define XCAM_ERR_MBUF_BASE XCAM_FAILURE
#define XCAM_ERR_MBUF_MUTEX_INIT_FAILED (XCAM_ERR_MBUF_BASE - 1)
#define XCAM_ERR_MBUF_PARAM_INVALID (XCAM_ERR_MBUF_BASE - 2)
#define XCAM_ERR_MBUF_ALLOC_FAILED (XCAM_ERR_MBUF_BASE - 3)
#define XCAM_ERR_MBUF_ADDR_NULL (XCAM_ERR_MBUF_BASE - 4)
#define XCAM_ERR_MBUF_NO_MEMORY (XCAM_ERR_MBUF_BASE - 5)
#define XCAM_ERR_MBUF_BUFFER_FULL (XCAM_ERR_MBUF_BASE - 6)
#define XCAM_ERR_MBUF_BUFFER_EMPTY (XCAM_ERR_MBUF_BASE - 7)
#define XCAM_ERR_MBUF_FREE_ERR (XCAM_ERR_MBUF_BASE - 8)
#define XCAM_ERR_MBUF_GET_BUF_FAILED (XCAM_ERR_MBUF_BASE - 9)
#define XCAM_ERR_MBUF_PUT_BUF_FAILED (XCAM_ERR_MBUF_BASE - 10)
#define XCAM_ERR_MBUF_READ_FAILED (XCAM_ERR_MBUF_BASE - 11)
#define XCAM_ERR_MBUF_BUSY (XCAM_ERR_MBUF_BASE - 12)
#define XCAM_ERR_MBUF_PAYLOAD_CHECK_ERR (XCAM_ERR_MBUF_BASE - 13)
#define XCAM_ERR_MBUF_NOT_REGISTERED (XCAM_ERR_MBUF_BASE - 14)
#define XCAM_ERR_MBUF_RELEASE_FAILED (XCAM_ERR_MBUF_BASE - 15)
/* mbuffer config */
typedef struct cam_mbuf_cfg_s {
xcam_u32 buf_size; /* memory size of mbuffer */
xcam_s32 payload_count; /* max patload type num in mbuffer */
} xcam_mbuf_cfg;
/* mbuffer pack info */
typedef struct cam_mbuf_pack_info_s {
xcam_u64 pts; /* timestamp if the frame */
xcam_u32 seq; /* sequence num of the frame */
xcam_u16 payload_type; /* mbuffer data payload type 0~0xFFF0,0xFFFE:all,0xFFFF:invalid */
xcam_u8 key_frame; /* whether keyframe or not */
xcam_u8 pack_count; /* pack_count < XCAM_MBUF_MAX_PACK*/
xcam_u8 *pack_addr[XCAM_MBUF_MAX_PACK]; /* start address of the data block */
xcam_u32 pack_size[XCAM_MBUF_MAX_PACK]; /* len of the block data agree with pAdder */
} xcam_mbuf_pack_info;
/*
* Create the instant of mbuf, allocate buf.
* param[in] xcam_mbuf_cfg *mbuf_cfg: property of buffer
* param[out] xcam_void **handle: mbuf handle
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_ERR_MBUF_ALLOC_FAILED buffer malloc failed
* XCAM_ERR_MBUF_MUTEX_INIT_FAILED
*/
xcam_s32 xcam_mbuf_get_buffer(xcam_handle **handle, xcam_mbuf_cfg *mbuf_cfg);
/*
* Realse mbuffer.
* param[in] xcam_void *handle: mbuf handle
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
*/
xcam_s32 xcam_mbuf_release_buffer(xcam_handle *handle);
/*
* register MBUF payload type, for example 0 for video 1 for audio.
* param[in] xcam_void * handle: mbuf handle
* param[in] xcam_u16 payload_type: payload type
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_FAILURE regiter space is full
*/
xcam_s32 xcam_mbuf_register_payload(xcam_handle *handle, xcam_u16 payload_type);
/*
* unregister MBUF payload type.
* param[in] xcam_void * handle: mbuf handle
* param[in] xcam_u16 payload_type: payload type
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_FAILURE
*/
xcam_s32 xcam_mbuf_unregister_payload(xcam_handle *handle, xcam_u16 payload_type);
/*
* Set read/write status of mbuf, according to the payload type.
* param[in] xcam_void * handle: muf handle
* param[in] xcam_u16 payload_type: payload type
* param[in] xcam_bool enable_read : enable read ptr or not
* param[in] xcam_bool enable_write: enable write ptr or not
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_FAILURE payload not found
*/
xcam_s32 xcam_mbuf_set_rw_enable(xcam_handle *handle, xcam_u16 payload_type, xcam_bool enable_read, xcam_bool enable_write);
/*
* Get the read/write status of mbuffer, according to the payload type.
* param[in] xcam_void *handle: the handle of mbuf
* param[in] xcam_u16 payload_type: payload type
* param[in] xcam_bool *enable_read : enable read ptr or not
* param[in] xcam_bool *enable_write: enable write ptr or not
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_ERR_MBUF_NOT_REGISTERED
*/
xcam_s32 xcam_mbuf_get_rw_enable(xcam_handle *handle, xcam_u16 payload_type, xcam_bool *enable_read, xcam_bool *enable_write);
/*
* Write package into mbuf
* param[in] xcam_void * handle: mbuf handle
* param[in] xcam_mbuf_pack_info *pack_info pack info data
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID,XCAM_ERR_MBUF_GET_BUF_FAILED,XCAM_ERR_MBUF_PUT_BUF_FAILED
* XCAM_ERR_MBUF_FULL,XCAM_ERR_MBUF_BUSY,
* XCAM_ERR_MBUF_BUSY
*/
xcam_s32 xcam_mbuf_write_pack(xcam_handle *handle, const xcam_mbuf_pack_info *pack_info);
/*
* Read data from mbuf
* param[in] xcam_void * handle: mbuf handle
* param[in] xcam_u16 payload_type payload type
* param[out] xcam_mbuf_pack_info *pack_info read out pack info
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_ERR_MBUF_BUFFER_EMPTY
* XCAM_ERR_MBUF_PAYLOAD_CHECK_ERR no such data of the giving payload type
*/
xcam_s32 xcam_mbuf_read_pack(xcam_handle *handle, xcam_u16 payload_type, xcam_mbuf_pack_info *pack_info);
/*
* Forward the read ptr for the payload type data
* param[in] xcam_void * handle: mbuf handle
* param[in] xcam_u16 payload_type: payload type
* param[out] xcam_u32 step: moving steps for the read ptr,1 for move one package after
* return XCAM_SUCCESS success
* XCAM_ERR_MBUF_PARAM_INVALID illegal params
* XCAM_ERR_MBUF_RELEASE_FAILED
*/
xcam_s32 xcam_mbuf_forward(xcam_handle *handle, xcam_u16 payload_type, xcam_u32 step);
/*
* Print the debug info
*/
xcam_s32 xcam_mbuf_debug(xcam_handle *handle, xcam_u16 payload_type);
/*
* Get package data offset
*/
xcam_s32 xcam_mbuf_get_package_data_offset(xcam_handle *handle, const xcam_mbuf_pack_info *pack_info, xcam_u32 *offset);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */
#endif /* __XCAM_MBUF_H__ */
+78
View File
@@ -0,0 +1,78 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef _XCAM_TRACK_SOURCE_H_
#define _XCAM_TRACK_SOURCE_H_
#include "xcam_type.h"
typedef enum {
XCAM_TRACK_SOURCE_TYPE_PRIV = 0,
XCAM_TRACK_SOURCE_TYPE_VIDEO,
XCAM_TRACK_SOURCE_TYPE_AUDIO,
XCAM_TRACK_SOURCE_TYPE_BUTT
} xcam_track_source_type;
typedef enum {
XCAM_TRACK_VIDEO_CODEC_H264 = 96,
XCAM_TRACK_VIDEO_CODEC_H265 = 98,
XCAM_TRACK_VIDEO_CODEC_MJPEG = 102,
XCAM_TRACK_VIDEO_CODEC_BUTT
} xcam_track_video_codec;
typedef enum {
XCAM_TRACK_AUDIO_CODEC_G711U = 0, /* G.711 U */
XCAM_TRACK_AUDIO_CODEC_G711A = 8, /* G.711 A */
XCAM_TRACK_AUDIO_CODEC_LPCM = 23, /* LPCM see cam_common.h file from sdk */
XCAM_TRACK_AUDIO_CODEC_G726 = 97, /* G.726 */
XCAM_TRACK_AUDIO_CODEC_AMR = 101, /* AMR encoder format */
XCAM_TRACK_AUDIO_CODEC_ADPCM = 104, /* ADPCM */
XCAM_TRACK_AUDIO_CODEC_AAC = 105,
XCAM_TRACK_AUDIO_CODEC_WAV = 108, /* WAV encoder */
XCAM_TRACK_AUDIO_CODEC_MP3 = 109,
XCAM_TRACK_AUDIO_CODEC_BUTT
} xcam_track_audio_codec;
typedef struct {
xcam_track_video_codec codec_type;
xcam_u32 width;
xcam_u32 height;
xcam_u32 bit_rate;
xcam_float frame_rate;
xcam_u32 gop;
xcam_float speed;
} xcam_track_video_source_info;
typedef struct {
xcam_track_audio_codec codec_type;
xcam_u32 chn_cnt;
xcam_u32 sample_rate;
xcam_u32 avg_bytes_per_sec;
xcam_u32 samples_per_frame;
xcam_u16 sample_bit_width;
} xcam_track_audio_source_info;
typedef struct {
xcam_u32 private_data;
xcam_float frame_rate;
xcam_u32 bytes_per_sec;
xcam_bool is_strict_sync;
} xcam_track_private_source_info;
typedef struct cam_track_source* xcam_track_source_handle;
typedef xcam_s32 (*func_xcam_track_source_request_key_frame)(xcam_handle venc_handle, xcam_void* param);
typedef struct cam_track_source {
intptr_t private_handle; // venc or aenc handle
func_xcam_track_source_request_key_frame func_request_key_frame;
xcam_track_source_type track_type;
union {
xcam_track_video_source_info video_info; /** video track info */
xcam_track_audio_source_info audio_info; /** audio track info */
xcam_track_private_source_info priv_info; /** private track info */
} track_source_attr;
} xcam_track_source;
#endif // _XCAM_TRACK_SOURCE_H_
+73
View File
@@ -0,0 +1,73 @@
/*
* Copyright (c) XCAM. All rights reserved.
*/
#ifndef __XCAM_TYPE_H__
#define __XCAM_TYPE_H__
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#endif
#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif
typedef enum {
XCAM_FALSE = 0,
XCAM_TRUE = 1,
} xcam_bool;
#ifndef NULL
#define NULL 0L
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
#define XCAM_NULL 0L
#define XCAM_SUCCESS 0
#define XCAM_FAILURE (-1)
typedef unsigned char xcam_uchar;
typedef unsigned char xcam_u8;
typedef unsigned short xcam_u16;
typedef unsigned int xcam_u32;
typedef unsigned long long xcam_u64;
typedef unsigned long xcam_ulong;
typedef char xcam_char;
typedef signed char xcam_s8;
typedef short xcam_s16;
typedef int xcam_s32;
typedef long long xcam_s64;
typedef long xcam_slong;
typedef float xcam_float;
typedef double xcam_double;
typedef void xcam_void;
typedef unsigned long xcam_size_t;
typedef unsigned long xcam_length_t;
typedef xcam_u32 xcam_handle;
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif