简单来说:
1,ais client app会调用qcarcam_initialize建立与server的连接,通信方式为本地socket通信
2,在建立通信后,会与server交换一部分信息,用于后续建立main connection以及event connection
3,在创建event connection的过程中,还会创建两个重要的线程:ais_client_event_recv_thread,ais_client_event_cb_thread
4,ais_client_event_recv_thread线程负责接收event事件,并且把接收到的时间入列(ais_event_queue_enqueue)
5,ais_client_event_cb_thread会从event队列中取出事件,并调用相应的回调函数进行处理,这里需要注意的是,这里的event队列不确定是否和4中描述的队列是同一个队列.
流程图:
这个函数中会从全局数组变量sgs_ais_client中找到一个空的位置来初始化client,sgs_ais_client数组最大成员为64,也就是ais支持的client个数为64个:
#define AIS_MAX_USR_CONTEXTS 64
static int ais_client_alloc(void)
{int rc = -1;int i;AIS_LOG_CLI_API("E");pthread_mutex_lock(&sgs_mutex);for (i = 0; i < AIS_MAX_USR_CONTEXTS; i++) { if (sgs_ais_client[i].qcarcam_hndl == NULL){ais_client_init(&sgs_ais_client[i]);sgs_ais_client[i].qcarcam_hndl = AIS_CONTEXT_IN_USE;rc = i; break;}}
这个函数会通过本地socket通信方式与server建立连接,交换连接信息.
/*** connection information to be exchanged between client/server*/
typedef struct
{int id; /**< connection id */int cnt; /**< number of connections */unsigned int gid; /**< group id of client*/unsigned int pid; /**< process id of client */unsigned int app_version; /**< QCarCam API version of application */unsigned int version; /**< QCarCam API version of client lib */CameraResult result; /**< result of exchange */unsigned int flags; /**< flags for new connection */
} s_ais_conn_info;
本文发布于:2024-01-31 19:37:33,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170670105330878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |