1、函数 sample_comm_fd_isset
在线程函数sample_comm_venc_get_venc_stream_proc中调用了函数 sample_comm_fd_isset,其内容如下:
static hi_void sample_comm_fd_isset(sample_comm_venc_stream_proc_info *stream_proc_info, fd_set *read_fds,
hi_venc_stream_buf_info *stream_buf_info, hi_payload_type *payload_type, sample_venc_getstream_para *para)
{
hi_s32 i, ret;
for (i = 0; (i < stream_proc_info->chn_total) && (i < HI_VENC_MAX_CHN_NUM); i++) {
if (FD_ISSET(stream_proc_info->venc_fd[i], read_fds)) {
stream_proc_info->venc_chn = para->venc_chn[i];
ret = sample_comm_get_stream_from_one_channl(stream_proc_info, i, stream_buf_info, payload_type);
if (ret == SAMPLE_RETURN_CONTINUE) {
continue;
} else if (ret == SAMPLE_RETURN_BREAK) {
break;
}
}
}
}
功能:在一个通信过程中处理来自VENC(Video Encoder)的输入数据。
相关函数:fd_set *read_fds
: 用于保存需要读取的文件描述符集合。
2、函数sample_comm_get_stream_from_one_channl
static hi_s32 sample_comm_get_stream_from_one_channl(sample_comm_venc_stream_proc_info *stream_proc_info,
hi_s32 index, hi_venc_stream_buf_info *stream_buf_info, hi_payload_type *payload_type)
{
hi_s32 ret;
hi_venc_stream stream;
hi_venc_chn_status stat;
/* step 2.1 : query how many packs in one-frame stream. */
if (memset_s(&stream, sizeof(stream), 0, sizeof(stream)) != EOK) {
printf("call memset_s error\n");
}
ret = hi_mpi_venc_query_status(index, &stat);
if (ret != HI_SUCCESS) {
sample_print("hi_mpi_venc_query_status chn[%d] failed with %#x!\n", index, ret);
return SAMPLE_RETURN_BREAK;
}
if (stat.cur_packs == 0) {
sample_print("NOTE: current frame is HI_NULL!\n");
return SAMPLE_RETURN_CONTINUE;
}