Jeff, Thank you for your answer. I used the same function as in the demo program. See below. I noticed that in the demo program, the gc_SetUserInfo() API is called twice. Once from the gc_set_channel_codecs() function and once from the process_event() function. See below. I don't understand the difference between the two calls... Mike switch (evttype) { case GCEV_OPENEX: .... if (pline- techtype == SIP) { GC_PARM_BLK *parmblkp = NULL; gc_util_insert_parm_val(&parmblkp, IPSET_DTMF, IPPARM_SUPPORT_DTMF_BITMASK, sizeof(char), IP_DTMF_TYPE_INBAND_RTP); if (gc_SetUserInfo(GCTGT_GCLIB_CHAN, port[index].ldev, parmblkp, GC_ALLCALLS) != GC_SUCCESS) { sprintf(str, "process_Event()- gc_SetUserInfo(linedev=%ld) Failed configuring DTMF mode", port[index].ldev); printandlog(index, GC_APIERR, NULL, str, 0); Close_Telephony(11); } static int gc_set_channel_codecs(index) { int i, j, scope,rc; IP_CAPABILITY ipcap; GC_PARM_BLK *parmblkp = NULL; char str[MAX_STRING_SIZE]; printandlog(index, MISC, NULL, "Specifying codecs", 0); for (i = 0; i port[index].num_codecs; i++) { memset(&ipcap, 0, sizeof(IP_CAPABILITY)); /* First obtain value of transmit codec type from translation table */ for (j = 0; j (sizeof(codecxlat) / sizeof(CODECXLAT)); j++) { if (!strcmp(port[index].codec .txcodec, codecxlat[j].codecname)) { ipcap.capability = codecxlat[j].codecvalue; break; } } /* if not found, log error and exit */ if (ipcap.capability == 0) { printf("Invalid codec type entry in %s\n", cfgfile); Close_Telephony(23); return(-1); // exit func due error } /* Specify TX codec, unless type is T.38 UDP which is bi-directional */ /* and handled separately as data codec. */ if (ipcap.capability != GCCAP_DATA_t38UDPFax) { ipcap.type = GCCAPTYPE_AUDIO; ipcap.direction = IP_CAP_DIR_LCLTRANSMIT; ipcap.extra.audio.frames_per_pkt = port[index].codec .txrate; /* Set VAD if and only if supported by codec type */ if (codecxlat[j].isVADsupported == YES) { /* If codec supports VAD, use setting from config file. */ /* Only check for "ON" for simplicity sake. */ ipcap.extra.audio.VAD = (strcmp(port[index].codec .txVAD, "ON") == 0); } else { /* VAD not supported */ ipcap.extra.audio.VAD = NO; } /* append the GC_PARM_BLK with the respective TX codec */ gc_util_insert_parm_ref(&parmblkp, GCSET_CHAN_CAPABILITY, IPPARM_LOCAL_CAPABILITY, sizeof(IP_CAPABILITY), &ipcap); /* Re-initialize for determining receive codec */ ipcap.capability = 0; /* Next obtain value of receive codec type from translation table */ for (j = 0; j (sizeof(codecxlat) / sizeof(CODECXLAT)); j++) { if (!strcmp(port[index].codec .rxcodec, codecxlat[j].codecname)) { ipcap.capability = codecxlat[j].codecvalue; break; } } /* If not found, log error and exit */ if (ipcap.capability == 0) { printf("Invalid codec type entry in %s\n", cfgfile); Close_Telephony(24); return(-1); // exit func due error } ipcap.direction = IP_CAP_DIR_LCLRECEIVE; ipcap.extra.audio.frames_per_pkt = port[index].codec .rxrate; /* Set VAD if and only if supported by codec type */ if (codecxlat[j].isVADsupported) { /* string validation minimized for simplicity sake */ ipcap.extra.audio.VAD = (strcmp(port[index].codec .rxVAD, "ON") == 0); } else { /* VAD not supported */ ipcap.extra.audio.VAD = NO; } /* append the GC_PARM_BLK with the respective RX codec */ gc_util_insert_parm_ref(&parmblkp, GCSET_CHAN_CAPABILITY, IPPARM_LOCAL_CAPABILITY, sizeof(IP_CAPABILITY), &ipcap); } else { /* else codec is T.38 UDP which is bi-directional data codec */ ipcap.type = GCCAPTYPE_RDATA; ipcap.direction = IP_CAP_DIR_LCLTXRX; ipcap.extra.data.max_bit_rate = 144; /* append the GC_PARM_BLK with the T.38 codec */ gc_util_insert_parm_ref(&parmblkp, GCSET_CHAN_CAPABILITY, IPPARM_LOCAL_CAPABILITY, sizeof(IP_CAPABILITY), &ipcap); } } /* end for loop for all codecs specified for device */ /* To interoperate with Microsoft Phoenix Version 5.0 Soft SIP phone,*/ /* we will set coders on SIP calls on a per call basis. Again, this */ /* is not required for other SIP clients. */ // SIP scope = GC_SINGLECALL; gc_util_insert_parm_val(&parmblkp, IPSET_DTMF, IPPARM_SUPPORT_DTMF_BITMASK, sizeof(char), IP_DTMF_TYPE_INBAND_RTP); rc = gc_SetUserInfo(GCTGT_GCLIB_CHAN, port[index].ldev, parmblkp, scope); if (rc != GC_SUCCESS) { sprintf(str, "gc_set_channel_codecs() - gc_SetUserInfo(linedev=%ld) Failed when specifying coders", port[index].ldev); printandlog(index, GC_APIERR, NULL, str, 0); Close_Telephony(25); return(-1); // exit func due error } gc_util_delete_parm_blk(parmblkp); return(0); } /* End of function */
↧