📄 pthread_trans.c
字号:
} return (cnt_main); }void *pthread_trans(void *args){ int p_value = -1; int in_size = 0; STRDATA str_data_trans; unsigned short *trans_ves_temp; unsigned short *trans_ves_data; unsigned short buf_count_ipb_trans[MAX_CH]; int vid_cnt_trans; unsigned short pic_type_trans; unsigned short pic_id_trans; struct timeval m1_timeout_at2021; struct timezone rok_zone_at2021; if(create_shm_net_stream() > 0) DEV_LEVEL1("[OK create_shm_net_stream]\n"); /* Buffer for Send to client */ for (vid_cnt_trans = 0 ; vid_cnt_trans < MAX_CH ; vid_cnt_trans++) { if ((send_buff_trans[vid_cnt_trans] = (unsigned char *)malloc(BUFFER_LEN))==NULL) { DEV_LEVEL0("send_buff_trans\n"); exit(1); } else memset(send_buff_trans[vid_cnt_trans], '\0', BUFFER_LEN); } /* GOP Number for each Channel */ for (vid_cnt_trans = 0 ; vid_cnt_trans < MAX_CH ; vid_cnt_trans++) { buf_count_ipb_trans[vid_cnt_trans] = 0 ; } if ( ((unsigned short *)trans_ves_temp = (unsigned short *)malloc (BUFFER_LEN)) == NULL) { DEV_LEVEL0("trans_ves_temp\n"); exit(1); } else memset(trans_ves_temp, '\0', BUFFER_LEN); if ( ((unsigned short *)trans_ves_data = (unsigned short *)malloc (BUFFER_LEN)) == NULL) { DEV_LEVEL0("trans_ves_data\n"); exit(1); } else memset(trans_ves_data, '\0', BUFFER_LEN); #ifndef __DETACH_THREAD__ if( pthread_detach(pthread_self()) != 0) perror("pthread_detatch"); else DEV_LEVEL2 ("trans_thr_start\n"); #endif QUIT_SDVR_MAIN=0; while(!QUIT_SDVR_MAIN) { if (trans_read_signal(&str_data_trans, trans_ves_temp, trans_channel, __WAITS__) ) { in_size = (int)str_data_trans.frame_size; pic_type_trans = str_data_trans.frame_type; pic_id_trans = str_data_trans.frame_id; #if 0//xchannel testprintf("\ntrans: id=%02d, number=%08d, type=%02d, size=%08d ", str_data_trans.frame_id, str_data_trans.frame_number, str_data_trans.frame_type, str_data_trans.frame_size);fflush(stdout);#endif } else { DEV_LEVEL0("sync\n"); continue ; } str_data_trans.frame_size = (unsigned short)(in_size); if (buf_count_ipb_trans[pic_id_trans]>=MAX_FRAME_IPB) { buf_count_ipb_trans[pic_id_trans] = 0; } if (buf_count_ipb_trans[pic_id_trans]>=str_data_trans.frame_nm) { buf_count_ipb_trans[pic_id_trans] = 0; } if (pic_type_trans==0) { buf_count_ipb_trans[pic_id_trans] = 0; } switch (pic_type_trans) { case 0: /* I-Frame */ if (buf_count_ipb_trans[pic_id_trans] == 0) { gettimeofday( (struct timeval *)&m1_timeout_at2021, (struct timezone *)&rok_zone_at2021); str_data_trans.tv_sec=m1_timeout_at2021.tv_sec; str_data_trans.tv_usec=m1_timeout_at2021.tv_usec; switch(pic_id_trans) { case 0: /* CH 1*/ //memset(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA) , trans_ves_temp, str_data_trans.frame_size); break; case 1: /* CH 2*/ //memset(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 2: /* CH 3*/ //memset(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 3: /* CH 4*/ //memset(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; default: break; }//end of switch buf_count_ipb_trans[pic_id_trans]++; } break; case 1: /* P-Frame */ if (buf_count_ipb_trans[pic_id_trans] > 0) { gettimeofday( (struct timeval *)&m1_timeout_at2021, (struct timezone *)&rok_zone_at2021); str_data_trans.tv_sec=m1_timeout_at2021.tv_sec; str_data_trans.tv_usec=m1_timeout_at2021.tv_usec; switch(pic_id_trans){ case 0: /* CH 1*/ //memset(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 1: /* CH 2*/ //memset(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 2: /* CH 3*/ //memset(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 3: /* CH 4*/ //memset(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; default: break; }//end of switch buf_count_ipb_trans[pic_id_trans]++; } break;#if 0 case 2: /* B-Frame */ if (buf_count_ipb_trans[pic_id_trans] > 0) { gettimeofday( (struct timeval *)&m1_timeout_at2021, (struct timezone *)&rok_zone_at2021); str_data_trans.tv_sec=m1_timeout_at2021.tv_sec;str_data_trans.tv_usec=m1_timeout_at2021.tv_usec; switch(pic_id_trans){ case 0: /* CH 1*/ //memset(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_0_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 1: /* CH 2 */ //memset(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_1_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 2: /* CH 3 */ //memset(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_2_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; case 3: /* CH 4 */ //memset(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], '\0' , BUFFER_LEN); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]], (STRDATA *)&str_data_trans , sizeof(STRDATA)); memcpy(ch_buff_3_ipb[buf_count_ipb_trans[pic_id_trans]]+sizeof(STRDATA), trans_ves_temp, str_data_trans.frame_size); break; default: break; }//end of switch buf_count_ipb_trans[pic_id_trans]++; } break;#endif default : break; }//switch (pic_type_trans) } for (vid_cnt_trans = 0 ; vid_cnt_trans < MAX_CH ; vid_cnt_trans++) { free((unsigned char *)send_buff_trans[vid_cnt_trans]); } free((unsigned short *)trans_ves_temp); free((unsigned short *)trans_ves_data); DEV_LEVEL0( "trans_thr_exit\n"); pthread_exit((void*)p_value);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -