extern "C" {
#endif
+/**
+ * @file muse_camera.h
+ * @brief This file contains the muse camera API for framework, related structures and enumerations.
+ */
+
#include "tbm_bufmgr.h"
#include <stdbool.h>
#include <glib.h>
#include <stdio.h>
+/**
+ * @brief Enumeration for the muse camera apis.
+ */
typedef enum {
MUSE_CAMERA_API_CREATE, //0
MUSE_CAMERA_API_DESTROY,
MUSE_CAMERA_API_MAX
} muse_camera_api_e;
+/**
+ * @brief Enumeration for the muse camera events.
+ */
typedef enum {
MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE, //0
MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE,
}muse_camera_event_e;
/**
- * @brief The structure type for data transport
+ * @brief The structure type for data transport for the muse camera
*/
typedef struct {
int data_size;
tbm_bufmgr bufmgr;
} muse_camera_transport_info_s;
+/**
+ * @brief The structure type for the userdata, registering into the daemon core.
+ */
typedef struct {
tbm_bufmgr bufmgr;
} muse_camera_info_s;
+/**
+ * @brief The structure type for muse camera errors.
+ */
typedef enum {
MUSE_CAMERA_ERROR_INVALID = -1,
MUSE_CAMERA_ERROR_NONE = 1,
} muse_camera_error_e;
+/**
+ * @brief Definition for the callback event id.
+ */
#define MUSE_CAMERA_CB_EVENT MUSE_CAMERA_API_MAX + 1 //129
+
+/**
+ * @brief Definition for the max message length.
+ */
#define MUSE_CAMERA_MSG_MAX_LENGTH 256
-#define MUSE_CAMERA_PARSE_STRING_SIZE 200
-#define KEY_HOUSE 0x8000
-//#define FD_SHARE
-
-#ifdef USE_SHARED_MEMORY
-int camera_ipc_create_shm(int key_num, int size, void *shm_addr);
-int camera_ipc_get_shm(int key_num, int size, void *shm_addr);
-int camera_ipc_dt_shm(void *shm_addr);
-
-typedef struct _camera_shm_info{
- int written;
- char data[4];
-}camera_shm_info;
-#endif
+/**
+ * @brief Definition for the socket path length of the shmsink.
+ */
#define SOCKET_PATH_LENGTH 32
+
+/**
+ * @brief Definition for the socket path base of the shmsink.
+ */
#define SOCKET_PATH_BASE "/tmp/mused_gst.%d"
+
+/**
+ * @brief Definition for the wait time of the ipc callback.
+ */
#define CALLBACK_TIME_OUT 3
+
+/**
+ * @brief Definition for the long wait time of the ipc callback.
+ */
#define CALLBACK_TIME_OUT_LONG 8
+
+/**
+ * @brief Makes the tbm buffer object, and set to the muse camera structure.
+ * @param[out] transport_info The allocated structure, tbm bo will be set in here.
+ * @return TRUE on success, otherwise a FALSE value
+ */
bool muse_camera_ipc_make_tbm(muse_camera_transport_info_s *transport_info);
+
+/**
+ * @brief Exports the tbm buffer object, another process can import this bo.
+ * @param[in] transport_info Using transport_info.bo to export.
+ * @return TBM gem name on success, otherwise a negative error value
+ */
int muse_camera_ipc_export_tbm(muse_camera_transport_info_s transport_info);
+
+/**
+ * @brief Initialize the tbm buffer manager, mainly at the client side.
+ * @param[out] transport_info The allocated structure, tbm bufmgr will be set in here.
+ * @return TRUE on success, otherwise a FALSE value
+ */
bool muse_camera_ipc_init_tbm(muse_camera_transport_info_s *transport_info);
+
+/**
+ * @brief Imports the tbm buffer object.
+ * @param[out] transport_info Set the transport_info.bo.
+ * @return TRUE on success, otherwise a FALSE value
+ */
int muse_camera_ipc_import_tbm(muse_camera_transport_info_s *transport_info);
+
+/**
+ * @brief Unreference the tbm buffer object.
+ * @param[in] transport_info Using the transport_info.bo.
+ * @return TRUE on success, otherwise a FALSE value
+ */
void muse_camera_unref_tbm(muse_camera_transport_info_s *transport_info);
#ifdef __cplusplus
/**
* @brief Send the message from proxy to module via ipc.
- * @param[in] param The key to query, the variable name should be matched to the message's one.
- * @param[out] buf The string of message buffer.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
*/
#define muse_camera_msg_send(api, fd, cb_info, ret) \
do{ \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Send the message from proxy to module via ipc, waits more period of time for the ack.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ */
#define muse_camera_msg_send_longtime(api, fd, cb_info, ret) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Send the message from proxy to module via ipc, adding 1 more parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] type The data type of the parameter.
+ * @param[in] param A single parameter to be included in the message.
+ */
#define muse_camera_msg_send1(api, fd, cb_info, ret, type, param) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Send the message from proxy to module via ipc, adding 2 more parameters.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] type1 The data type of the parameter.
+ * @param[in] param1 The first parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ */
#define muse_camera_msg_send2(api, fd, cb_info, ret, type1, param1, type2, param2) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Send the message from proxy to module via ipc, adding 3 more parameters.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] type1 The data type of the parameter.
+ * @param[in] param1 The first parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ * @param[in] type3 The data type of the parameter.
+ * @param[in] param3 The 3rd parameter to be included in the message.
+ */
#define muse_camera_msg_send3(api, fd, cb_info, ret, type1, param1, type2, param2, type3, param3) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Send the message from proxy to module via ipc, adding an array data.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[in] fd The socket fd that connected to the module via ipc.
+ * @param[in] cb_info The callback information, waiting for the ack from the module.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] param The array data parameter to be included in the message.
+ * @param[in] length The length of the array.
+ * @param[in] datum_size The size of the array.
+ */
#define muse_camera_msg_send_array(api, fd, cb_info, ret, param, length, datum_size) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
-#define muse_camera_msg_send1_async(api, camera, fd, type, param) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type __value__ = (type)param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type, #param, __value__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- return CAMERA_ERROR_INVALID_OPERATION; \
- } \
- }while(0)
-
-#define muse_camera_msg_send2_async(api, camera, fd, type1, param1, type2, param2) \
- do{ \
- char *__sndMsg__; \
- int __len__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- 0); \
- __len__ = muse_core_ipc_send_msg(fd, __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- if (__len__ <= 0) { \
- LOGE("sending message failed"); \
- return CAMERA_ERROR_INVALID_OPERATION; \
- } \
- }while(0)
-
+/**
+ * @brief Returning the ack message from the server to client side.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ */
#define muse_camera_msg_return(api, ret, module) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the ack message from the server to client side.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] type The data type of the parameter.
+ * @param[in] param A parameter to be included in the message.
+ */
#define muse_camera_msg_return1(api, ret, module, type, param) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the ack message from the server to client side, adding 2 parameters.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] type1 The data type of the parameter.
+ * @param[in] param1 The 1st parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ */
#define muse_camera_msg_return2(api, ret, module, type1, param1, type2, param2) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the ack message from the server to client side, adding 3 parameters.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] type1 The data type of the parameter.
+ * @param[in] param1 The 1st parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ * @param[in] type3 The data type of the parameter.
+ * @param[in] param3 The 3rd parameter to be included in the message.
+ */
#define muse_camera_msg_return3(api, ret, module, type1, param1, type2, param2, type3, param3) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the ack message from the server to client side, adding array parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] param The array data parameter to be included in the message.
+ * @param[in] length The length of the array.
+ * @param[in] datum_size The size of the array.
+ */
#define muse_camera_msg_return_array(api, ret, module, param, length, datum_size) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the event ack message from the server to client side, adding array parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ */
#define muse_camera_msg_event(api, event, module) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the event ack message from the server to client side, adding array parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] type The data type of the parameter.
+ * @param[in] param A parameter to be included in the message.
+ */
#define muse_camera_msg_event1(api, event, module, type, param) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the event ack message from the server to client side, adding array parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] param1 The 1st parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ */
#define muse_camera_msg_event2(api, event, module, type1, param1, type2, param2) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
+/**
+ * @brief Returning the event ack message from the server to client side, adding array parameter.
+ * @param[in] api The enumeration of the corresponding api.
+ * @param[out] ret The delivered return value from the module to proxy side.
+ * @param[in] module The module info for the ipc transportation.
+ * @param[in] param1 The 1st parameter to be included in the message.
+ * @param[in] type2 The data type of the parameter.
+ * @param[in] param2 The 2nd parameter to be included in the message.
+ * @param[in] type3 The data type of the parameter.
+ * @param[in] param3 The 3rd parameter to be included in the message.
+ */
#define muse_camera_msg_event3(api, event, module, type1, param1, type2, param2, type3, param3) \
do{ \
char *__sndMsg__; \
muse_core_msg_json_factory_free(__sndMsg__); \
}while(0)
-#define muse_camera_msg_event4(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-#define muse_camera_msg_event2_array(api, event, module, type1, param1, type2, param2, arr_param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- int *__arr_value__ = (int *)arr_param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #arr_param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __arr_value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-#define muse_camera_msg_event6_array(api, event, module, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6, arr_param, length, datum_size) \
- do{ \
- char *__sndMsg__; \
- type1 __value1__ = (type1)param1; \
- type2 __value2__ = (type2)param2; \
- type3 __value3__ = (type3)param3; \
- type4 __value4__ = (type4)param4; \
- type5 __value5__ = (type5)param5; \
- type6 __value6__ = (type6)param6; \
- int *__arr_value__ = (int *)arr_param; \
- __sndMsg__ = muse_core_msg_json_factory_new(api, \
- MUSE_TYPE_INT, PARAM_EVENT, event, \
- MUSE_TYPE_##type1, #param1, __value1__, \
- MUSE_TYPE_##type2, #param2, __value2__, \
- MUSE_TYPE_##type3, #param3, __value3__, \
- MUSE_TYPE_##type4, #param4, __value4__, \
- MUSE_TYPE_##type5, #param5, __value5__, \
- MUSE_TYPE_##type6, #param6, __value6__, \
- MUSE_TYPE_INT, #length, length, \
- MUSE_TYPE_ARRAY, #arr_param, \
- datum_size == sizeof(int)? length : \
- length / sizeof(int) + (length % sizeof(int)?1:0), \
- __arr_value__, \
- 0); \
- muse_core_ipc_send_msg(muse_core_client_get_msg_fd(module), __sndMsg__); \
- muse_core_msg_json_factory_free(__sndMsg__); \
- }while(0)
-
-
-
#ifdef __cplusplus
}
#endif