oocapability.c
来自「一个非常美妙的proxy。功能强大。基于sip的协议。如果还要的话」· C语言 代码 · 共 2,030 行 · 第 1/5 页
C
2,030 行
epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOH263CapParams)); OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } } if(dir & OOTX) { epCap = (ooH323EpCapability*)memAlloc(call->pctxt, sizeof(ooH323EpCapability)); params = (OOH263CapParams*) memAlloc(call->pctxt, sizeof(OOH263CapParams)); if(!epCap || !params) { OOTRACEERR3("Error:Memory - ooIsVideoDataTypeH263Supported - " "epCap/params. (%s, %s)\n", call->callType, call->callToken); return NULL; } epCap->params = params; epCap->cap = cur->cap; epCap->dir = cur->dir; epCap->capType = cur->capType; epCap->startReceiveChannel = cur->startReceiveChannel; epCap->startTransmitChannel= cur->startTransmitChannel; epCap->stopReceiveChannel = cur->stopReceiveChannel; epCap->stopTransmitChannel = cur->stopTransmitChannel; epCap->next = NULL; memcpy(epCap->params, cur->params, sizeof(OOH263CapParams)); if(params->MPI < mpi) { OOTRACEINFO5("Increasing minimum picture interval for transmission of" " H263 video capability from %d to %d to match receive " "capability of remote endpoint.(%s, %s)\n", params->MPI, mpi, call->callType, call->callToken); params->MPI = mpi; } OOTRACEDBGC4("Returning copy of matched receive capability %s. " "(%s, %s)\n", ooGetCapTypeText(cur->cap), call->callType, call->callToken); return epCap; } return NULL;}ooH323EpCapability* ooIsVideoDataTypeSupported (OOH323CallData *call, H245VideoCapability* pVideoCap, int dir){ switch(pVideoCap->t) { case T_H245VideoCapability_h263VideoCapability: if(pVideoCap->u.h263VideoCapability->m.sqcifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_SQCIF); else if(pVideoCap->u.h263VideoCapability->m.qcifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_QCIF); else if(pVideoCap->u.h263VideoCapability->m.cifMPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF); else if(pVideoCap->u.h263VideoCapability->m.cif4MPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF4); else if(pVideoCap->u.h263VideoCapability->m.cif16MPIPresent) return ooIsVideoDataTypeH263Supported(call, pVideoCap->u.h263VideoCapability, dir, OO_PICFORMAT_CIF16); break; case T_H245VideoCapability_nonStandard: case T_H245VideoCapability_h261VideoCapability: case T_H245VideoCapability_h262VideoCapability: case T_H245VideoCapability_is11172VideoCapability: case T_H245VideoCapability_genericVideoCapability: case T_H245VideoCapability_extElem1: default: OOTRACEDBGA1("Unsupported video capability type in " "ooIsVideoDataTypeSupported\n"); return NULL; } return NULL;}ooH323EpCapability* ooIsDataTypeSupported (OOH323CallData *call, H245DataType *data, int dir){ OOTRACEDBGC3("Looking for data type support. (%s, %s)\n", call->callType, call->callToken); switch(data->t) { case T_H245DataType_nonStandard: OOTRACEDBGC3("NonStandard data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_nullData: OOTRACEDBGC3("Null data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_videoData: OOTRACEDBGC3("Looking for video dataType support. (%s, %s)\n", call->callType, call->callToken); return ooIsVideoDataTypeSupported(call, data->u.videoData, dir); case T_H245DataType_audioData: OOTRACEDBGC3("Looking for audio dataType support. (%s, %s)\n", call->callType, call->callToken); return ooIsAudioDataTypeSupported(call, data->u.audioData, dir); case T_H245DataType_data: OOTRACEDBGC3("Data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_encryptionData: OOTRACEDBGC3("Encryption data type not supported.(%s, %s)\n", call->callType, call->callToken); return NULL; case T_H245DataType_h235Control: return NULL; case T_H245DataType_h235Media: return NULL; case T_H245DataType_multiplexedStream: return NULL; default: OOTRACEINFO3("Unknown data type (%s, %s)\n", call->callType, call->callToken); } return NULL;}int ooResetCapPrefs(OOH323CallData *call){ OOCapPrefs *capPrefs=NULL; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memset(capPrefs, 0, sizeof(OOCapPrefs)); return OO_OK;}int ooRemoveCapFromCapPrefs(OOH323CallData *call, int cap){ int i=0, j=0; OOCapPrefs *capPrefs=NULL, oldPrefs; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memcpy(&oldPrefs, capPrefs, sizeof(OOCapPrefs)); memset(capPrefs, 0, sizeof(OOCapPrefs)); for(i=0; i<oldPrefs.index; i++) { if(oldPrefs.order[i] != cap) capPrefs->order[j++] = oldPrefs.order[i]; } capPrefs->index = j; return OO_OK;} int ooAppendCapToCapPrefs(OOH323CallData *call, int cap){ OOCapPrefs *capPrefs=NULL; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; capPrefs->order[capPrefs->index++] = cap; return OO_OK;}int ooChangeCapPrefOrder(OOH323CallData *call, int cap, int pos){ int i=0, j=0; OOCapPrefs *capPrefs = NULL; /* Whether to change prefs for call or for endpoint as a whole */ if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; /* check whether cap exists, cap must exist */ for(i=0; i<capPrefs->index; i++) { if(capPrefs->order[i] == cap) break; } if(i == capPrefs->index) return OO_FAILED; if(i==pos) return OO_OK; /* No need to change */ /* Decrease Pref order */ if(i < pos) { for( ; i<pos; i++) capPrefs->order[i] = capPrefs->order[i+1]; capPrefs->order[i]=cap; return OO_OK; } /* Increase Pref order */ if(i>pos) { for(j=i; j>pos; j--) capPrefs->order[j] = capPrefs->order[j-1]; capPrefs->order[j] = cap; return OO_OK; } return OO_FAILED;}int ooPreppendCapToCapPrefs(OOH323CallData *call, int cap){ int i=0, j=0; OOCapPrefs *capPrefs=NULL, oldPrefs; if(call) capPrefs = &call->capPrefs; else capPrefs = &gH323ep.capPrefs; memcpy(&oldPrefs, capPrefs, sizeof(OOCapPrefs)); capPrefs->order[j++] = cap; for(i=0; i<oldPrefs.index; i++) { if(oldPrefs.order[i] != cap) capPrefs->order[j++] = oldPrefs.order[i]; } capPrefs->index = j; return OO_OK;} int ooAddRemoteCapability(OOH323CallData *call, H245Capability *cap){ switch(cap->t) { case T_H245Capability_receiveAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.receiveAudioCapability, OORX); case T_H245Capability_transmitAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.transmitAudioCapability, OOTX); case T_H245Capability_receiveAndTransmitAudioCapability: return ooAddRemoteAudioCapability(call, cap->u.receiveAndTransmitAudioCapability, OORXTX); default: OOTRACEDBGA3("Unsupported cap type encountered. Ignoring. (%s, %s)\n", call->callType, call->callToken); } return OO_OK;}int ooAddRemoteAudioCapability(OOH323CallData *call, H245AudioCapability *audioCap, int dir){ int rxframes=0, txframes=0; switch(audioCap->t) { case T_H245AudioCapability_g711Alaw64k: if(dir&OOTX) txframes = audioCap->u.g711Alaw64k; else if(dir&OORX) rxframes = audioCap->u.g711Alaw64k; else{ txframes = audioCap->u.g711Alaw64k; rxframes = audioCap->u.g711Alaw64k; } return ooCapabilityAddSimpleCapability(call, OO_G711ALAW64K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL,TRUE); case T_H245AudioCapability_g711Alaw56k: if(dir&OOTX) txframes = audioCap->u.g711Alaw56k; else if(dir&OORX) rxframes = audioCap->u.g711Alaw56k; else{ txframes = audioCap->u.g711Alaw56k; rxframes = audioCap->u.g711Alaw56k; } return ooCapabilityAddSimpleCapability(call, OO_G711ALAW56K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g711Ulaw64k: if(dir&OOTX) txframes = audioCap->u.g711Ulaw64k; else if(dir&OORX) rxframes = audioCap->u.g711Ulaw64k; else{ txframes = audioCap->u.g711Ulaw64k; rxframes = audioCap->u.g711Ulaw64k; } return ooCapabilityAddSimpleCapability(call, OO_G711ULAW64K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g711Ulaw56k: if(dir&OOTX) txframes = audioCap->u.g711Ulaw56k; else if(dir&OORX) rxframes = audioCap->u.g711Ulaw56k; else{ txframes = audioCap->u.g711Ulaw56k; rxframes = audioCap->u.g711Ulaw56k; } return ooCapabilityAddSimpleCapability(call, OO_G711ULAW56K, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g729: if(dir&OOTX) txframes = audioCap->u.g729; else if(dir&OORX) rxframes = audioCap->u.g729; else{ txframes = audioCap->u.g729; rxframes = audioCap->u.g729; } return ooCapabilityAddSimpleCapability(call, OO_G729, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g729AnnexA: if(dir&OOTX) txframes = audioCap->u.g729AnnexA; else if(dir&OORX) rxframes = audioCap->u.g729AnnexA; else{ txframes = audioCap->u.g729AnnexA; rxframes = audioCap->u.g729AnnexA; } return ooCapabilityAddSimpleCapability(call, OO_G729A, txframes, rxframes, FALSE, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_g7231: if(dir&OOTX) txframes = audioCap->u.g7231->maxAl_sduAudioFrames; else if(dir&OORX) rxframes = audioCap->u.g7231->maxAl_sduAudioFrames; else{ txframes = audioCap->u.g7231->maxAl_sduAudioFrames; rxframes = audioCap->u.g7231->maxAl_sduAudioFrames; } return ooCapabilityAddSimpleCapability(call, OO_G7231, txframes,rxframes, audioCap->u.g7231->silenceSuppression, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmFullRate: return ooCapabilityAddGSMCapability(call, OO_GSMFULLRATE, (unsigned)(audioCap->u.gsmFullRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmFullRate->comfortNoise, audioCap->u.gsmFullRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmHalfRate: return ooCapabilityAddGSMCapability(call, OO_GSMHALFRATE, (unsigned)(audioCap->u.gsmHalfRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmHalfRate->comfortNoise, audioCap->u.gsmHalfRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); case T_H245AudioCapability_gsmEnhancedFullRate: return ooCapabilityAddGSMCapability(call, OO_GSMENHANCEDFULLRATE, (unsigned)(audioCap->u.gsmEnhancedFullRate->audioUnitSize/OO_GSMFRAMESIZE), audioCap->u.gsmEnhancedFullRate->comfortNoise, audioCap->u.gsmEnhancedFullRate->scrambled, dir, NULL, NULL, NULL, NULL, TRUE); default: OOTRACEDBGA1("Unsupported audio capability type\n"); } return OO_OK;}int ooCapabilityUpdateJointCapabilities (OOH323CallData* call, H245Capability *cap){ ooH323EpCapability * epCap = NULL, *cur = NULL; OOTRACEDBGC3("checking whether we need to add cap to joint capabilities" "(%s, %s)\n", call->callType, call->callToken); switch(cap->t) { case T_H245Capability_receiveAudioCapability: epCap= ooIsAudioDataTypeSupported(call, cap->u.receiveAudioCapability, OOTX); break; case T_H245Capability_transmitAudioCapability: epCap = ooIsAudioDataTypeSupported(call, cap->u.transmitAudioCapability, OORX); break; case T_H245Capability_receiveAndTransmitAudioCapability: epCap = NULL; break; case T_H245Capability_receiveVideoCapability: return ooCapabilityUpdateJointCapabilitiesVideo(call, cap->u.receiveVideoCapability, OOTX); case T_H245Capability_transmitVideoCapability: return ooCapabilityUpdateJointCapabilitiesVideo(call, cap->u.transmitVideoCapability, OORX); case T_H245Capability_receiveUserInputCapability: if((cap->u.receiveUserInputCapability->t == T_H245UserInputCapability_basicString) && (call->dtmfmode & OO_CAP_DTMF_H245_alphanumeric)) { call->jointDtmfMode |= OO_CAP_DTMF_H245_alphanumeric; return OO_OK; }else if((cap->u.receiveUserInputCapability->t == T_H245UserInputCapability_dtmf) && (cal
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?