📄 synopen.c
字号:
/*------------------------------------------------------------------------- * synopen.c - synopen *------------------------------------------------------------------------- */#include <syn.h>#include <stdlib.h>#include <strings.h>#include <util.h>/*------------------------------------------------------------------------ * synopen - open a synchronization layer session *------------------------------------------------------------------------ */struct synsession *synopen(struct in_addr session, int port, int bpbufsz, int bpbufcnt){ struct session *psn; struct synsession *pssn; bool true; psn = rtpopen(session, port, bpbufsz, bpbufcnt); if (psn == NULL) return NULL; /* * Start threads at RTP layer. */ true = TRUE; rtpctl(psn, RTP_CTL_RTCPCYCLETHREAD, (char *) &true, 0, 0); rtpctl(psn, RTP_CTL_RTPRECVTHREAD, (char *) &true, 0, 0); rtpctl(psn, RTP_CTL_RTCPRECVTHREAD, (char *) &true, 0, 0); pssn = (struct synsession *) malloc(sizeof(struct synsession)); if (pssn == NULL) { rtpclose(psn); return NULL; } memset(pssn, 0, sizeof(struct synsession)); pssn->ssn_session = psn; pssn->ssn_ssrcs = htnew(SYN_SSRCHTSZ, hashunsignedint, unsignedinteq, NULL, NULL); if (pssn->ssn_ssrcs == NULL) { free(pssn); rtpclose(psn); return NULL; } pthread_mutex_init(&pssn->ssn_getstreammutex, NULL); pthread_mutex_init(&pssn->ssn_mutex, NULL); pthread_mutex_init(&pssn->ssn_eventthrmutex, NULL); pthread_mutex_init(&pssn->ssn_recvthrmutex, NULL); pthread_cond_init(&pssn->ssn_cond, NULL); eventqinit(&pssn->ssn_events, EVENT_QUEUE_HT_SZ, TRUE, SYN_DFLTEVENTBUFSZ, SYN_DFLTEVENTBUFCNT); /* * Start threads at synchronization layer. */ startthread(&pssn->ssn_eventthr, (void *(*)(void *)) syneventloop, (void *) pssn, &pssn->ssn_eventthrmutex, &pssn->ssn_cond, &pssn->ssn_eventthrstat);#ifdef RTPLIB_SYNCHRONIZE startthread(&pssn->ssn_recvthr, (void *(*)(void *)) synsyncrecvthr, (void *) pssn, &pssn->ssn_recvthrmutex, &pssn->ssn_cond, &pssn->ssn_recvthrstat);#endif /* RTPLIB_SYNCHRONIZE */ /* * Register our event queue in RTP layer. */ rtpctl(psn, RTP_CTL_ADDEVENTQUEUE, (char *) &pssn->ssn_events, 0, 0); return pssn;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -