PStringArray PVideoOutputDevice_EKIGA::GetDeviceNames() const { PStringArray devlist; devlist.AppendString(GetDeviceName()); return devlist; }
void CMyPhoneEndPoint::LoadCapabilities() { BOOL sizeChange = FALSE; capabilities.RemoveAll(); // Add the codecs we know about AddAllCapabilities(0, 0, "*"); // Удаляю не поддерживаемые видео кодеки из реестра PINDEX videoNum = 0; for (;;) { PString key = psprintf("%u", ++videoNum); PString name = config.GetString(VideoCodecsConfigSection, key, ""); if (name.IsEmpty()) break; PINDEX suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); else { suffixPos = name.Find(OffCodecSuffix); name.Delete(suffixPos, P_MAX_INDEX); } int res = 0; for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Video) { if(capabilities[i].GetFormatName() == name) { res = 1; break; } } } if(res == 0) { PINDEX j = videoNum; videoNum--; for (;;) { PString key1 = psprintf("%u", ++j); PString name1 = config.GetString(VideoCodecsConfigSection, key1, ""); if (name1.IsEmpty()) break; config.SetString(VideoCodecsConfigSection, psprintf("%u", j-2), name1); } config.DeleteKey(VideoCodecsConfigSection, psprintf("%u", j-1)); } } // добавляю новые видео кодеки если их нет в конфигурации for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Video) { PINDEX codecNum=0; int res = 0; int suffix = 0; for (;;) { PString key = psprintf("%u", ++codecNum); PString name = config.GetString(VideoCodecsConfigSection, key, ""); if (name.IsEmpty()) break; suffix = 0; PINDEX suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); else { suffix = 1; suffixPos = name.Find(OffCodecSuffix); name.Delete(suffixPos, P_MAX_INDEX); } if(capabilities[i].GetFormatName() == name) { res = 1; break; } } if(res == 0) { config.SetString(VideoCodecsConfigSection, psprintf("%u", codecNum), capabilities[i].GetFormatName() + ((suffix==0)?OnCodecSuffix:OffCodecSuffix)); } } } PINDEX audioNum = 0; for (;;) { PString key = psprintf("%u", ++audioNum); PString name = config.GetString(CodecsConfigSection, key, ""); if (name.IsEmpty()) break; PINDEX suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); else { suffixPos = name.Find(OffCodecSuffix); name.Delete(suffixPos, P_MAX_INDEX); } int res = 0; for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Audio) { if(capabilities[i].GetFormatName() == name) { res = 1; break; } } } if(res == 0) { PINDEX j = audioNum; audioNum--; for (;;) { PString key1 = psprintf("%u", ++j); PString name1 = config.GetString(CodecsConfigSection, key1, ""); if (name1.IsEmpty()) break; config.SetString(CodecsConfigSection, psprintf("%u", j-2), name1); } config.DeleteKey(CodecsConfigSection, psprintf("%u", j-1)); } } for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Audio) { PINDEX codecNum=0; int res = 0; int suffix = 0; for (;;) { PString key = psprintf("%u", ++codecNum); PString name = config.GetString(CodecsConfigSection, key, ""); if (name.IsEmpty()) break; suffix = 0; PINDEX suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); else { suffix = 1; suffixPos = name.Find(OffCodecSuffix); name.Delete(suffixPos, P_MAX_INDEX); } if(capabilities[i].GetFormatName() == name) { res = 1; break; } } if(res == 0) { config.SetString(CodecsConfigSection, psprintf("%u", codecNum), capabilities[i].GetFormatName() + ((suffix==0)?OnCodecSuffix:OffCodecSuffix)); } } } // Add all the UserInput capabilities AddAllUserInputCapabilities(0, 1); int videoSizeRx = config.GetInteger(VideoInSizeConfigKey, 2); int videoSizeTx = config.GetInteger(VideoOutSizeConfigKey, 2); RemoveCapability(H323Capability::e_ExtendVideo); autoStartTransmitVideo = config.GetBoolean(AutoTransmitVideoConfigKey, TRUE); autoStartReceiveVideo = config.GetBoolean(AutoReceiveVideoConfigKey, TRUE); localVideo = config.GetBoolean(VideoLocalConfigKey, FALSE); localFlip = config.GetBoolean(VideoFlipLocalConfigKey, FALSE); int videoInMaxBitRate = config.GetInteger(VideoInMaxbandWidthKey, 320); videoInMaxBitRate = 1024 * PMAX(16, PMIN(10240, videoInMaxBitRate)); // changing audio codecs PStringArray enabledCodecs; PINDEX codecNum = 0; for (;;) { PString key = psprintf("%u", ++codecNum); PString name = config.GetString(CodecsConfigSection, key, ""); if (name.IsEmpty()) break; PINDEX suffixPos = name.Find(OffCodecSuffix); if (suffixPos != P_MAX_INDEX) { capabilities.Remove(name(0, suffixPos-1)); continue; } suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); enabledCodecs.AppendString(name); } codecNum = 0; for (;;) { PString key = psprintf("%u", ++codecNum); PString name = config.GetString(VideoCodecsConfigSection, key, ""); if (name.IsEmpty()) break; } int tvNum = 0; // if(tvCaps==NULL) this generates error in free tvCaps = (char **)calloc(codecNum+1,sizeof(char *)); // while(tvCaps[tvNum]!=NULL) { free(tvCaps[tvNum]); tvCaps[tvNum]=NULL; tvNum++; } tvNum = 0; codecNum = 0; for (;;) { PString key = psprintf("%u", ++codecNum); PString name = config.GetString(VideoCodecsConfigSection, key, ""); if (name.IsEmpty()) break; // удаление отключенных кодеков PINDEX suffixPos = name.Find(OffCodecSuffix); if (suffixPos != P_MAX_INDEX) { capabilities.Remove(name(0, suffixPos-1)); continue; } // удаление суффикса on из имени кодека suffixPos = name.Find(OnCodecSuffix); if (suffixPos != P_MAX_INDEX) name.Delete(suffixPos, P_MAX_INDEX); // проверка кодека на соответствие размеру принимаемой картинки // (меньше можно, больше нельзя) и удаление из списка локальных кодеков suffixPos = P_MAX_INDEX; switch(videoSizeRx) { case 0: //QCIF suffixPos = name.Find("-CIF"); if(suffixPos != P_MAX_INDEX) break; case 1: //QVGA case 2: //CIF suffixPos = name.Find("-4CIF"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-480P"); if(suffixPos != P_MAX_INDEX) break; case 3: //VGA case 4: //4CIF suffixPos = name.Find("-SD"); if(suffixPos != P_MAX_INDEX) break; case 5: //SVGA suffixPos = name.Find("-720P"); if(suffixPos != P_MAX_INDEX) break; case 6: //XVGA suffixPos = name.Find("-HD"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break; case 7: //SXGA suffixPos = name.Find("-FHD"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-1080P"); if(suffixPos != P_MAX_INDEX) break; case 8: //16CIF default: break; } if(suffixPos == P_MAX_INDEX) enabledCodecs.AppendString(name); else capabilities.Remove(name); // проверка кодека на соответствие размеру отправляемой картинки // (меньше можно, больше нельзя) и создание списка допустимых кодеков suffixPos = P_MAX_INDEX; switch(videoSizeTx) { case 0: //QCIF suffixPos = name.Find("-CIF"); if(suffixPos != P_MAX_INDEX) break; case 1: //QVGA case 2: //CIF suffixPos = name.Find("-4CIF"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-480P"); if(suffixPos != P_MAX_INDEX) break; case 3: //VGA case 4: //4CIF suffixPos = name.Find("-SD"); if(suffixPos != P_MAX_INDEX) break; case 5: //SVGA case 6: //XVGA suffixPos = name.Find("-HD"); if(suffixPos != P_MAX_INDEX) break; case 7: //HD 720 suffixPos = name.Find("-720P"); if(suffixPos != P_MAX_INDEX) break; case 8: //SXGA suffixPos = name.Find("-16CIF"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-FHD"); if(suffixPos != P_MAX_INDEX) break; suffixPos = name.Find("-1080P"); if(suffixPos != P_MAX_INDEX) break; case 9: //16CIF default: break; } if(suffixPos == P_MAX_INDEX) // добавляю в список допустимых { const char *p2pstr=name; tvCaps[tvNum]=strdup(p2pstr); tvNum++; } } // Reorder the codecs we have capabilities.Reorder(enabledCodecs); for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Video) { capabilities[i].SetMediaFormatOptionInteger(OpalVideoFormat::MaxBitRateOption, videoInMaxBitRate); if((capabilities[i].GetFormatName().Find("H.264")!=P_MAX_INDEX) || (capabilities[i].GetFormatName().Find("VP8-")==0)) { H323GenericVideoCapability *h264cap = (H323GenericVideoCapability *) &capabilities[i]; h264cap->SetMaxBitRate(videoInMaxBitRate/100); } } } /* PINDEX audioNum = 1; PINDEX videoNum = 1; for (PINDEX i = 0; i < capabilities.GetSize(); i++) { if (capabilities[i].GetMainType() == H323Capability::e_Audio) { config.SetString(CodecsConfigSection, psprintf("%u", audioNum++), capabilities[i].GetFormatName() + OnCodecSuffix); } else if (capabilities[i].GetMainType() == H323Capability::e_Video) { config.SetString(VideoCodecsConfigSection, psprintf("%u", videoNum++), capabilities[i].GetFormatName() + OnCodecSuffix); } } */ PTRACE(1, "MyPhone\tCapability Table:\n" << setprecision(4) << capabilities); }
/** * Add capability to the capability table of the end point. */ int h323_set_capability(int cap, int dtmfMode) { H323Capabilities oldcaps; PStringArray codecs; int g711Frames = 30; int gsmFrames = 4; if (!h323_end_point_exist()) { cout << " ERROR: [h323_set_capablity] No Endpoint, this is bad" << endl; return 1; } /* clean up old capabilities list before changing */ oldcaps = endPoint->GetCapabilities(); for (PINDEX i=0; i< oldcaps.GetSize(); i++) { codecs.AppendString(oldcaps[i].GetFormatName()); } endPoint->RemoveCapabilities(codecs); mode = dtmfMode; if (dtmfMode == H323_DTMF_INBAND) { endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsTone); } else { endPoint->SetSendUserInputMode(H323Connection::SendUserInputAsInlineRFC2833); } if (cap & AST_FORMAT_SPEEX) { /* Not real sure if Asterisk acutally supports all of the various different bit rates so add them all and figure it out later*/ endPoint->SetCapability(0, 0, new SpeexNarrow2AudioCapability()); endPoint->SetCapability(0, 0, new SpeexNarrow3AudioCapability()); endPoint->SetCapability(0, 0, new SpeexNarrow4AudioCapability()); endPoint->SetCapability(0, 0, new SpeexNarrow5AudioCapability()); endPoint->SetCapability(0, 0, new SpeexNarrow6AudioCapability()); } if (cap & AST_FORMAT_G729A) { AST_G729ACapability *g729aCap; AST_G729Capability *g729Cap; endPoint->SetCapability(0, 0, g729aCap = new AST_G729ACapability); endPoint->SetCapability(0, 0, g729Cap = new AST_G729Capability); } if (cap & AST_FORMAT_G723_1) { H323_G7231Capability *g7231Cap; endPoint->SetCapability(0, 0, g7231Cap = new H323_G7231Capability); } if (cap & AST_FORMAT_GSM) { H323_GSM0610Capability *gsmCap; endPoint->SetCapability(0, 0, gsmCap = new H323_GSM0610Capability); gsmCap->SetTxFramesInPacket(gsmFrames); } if (cap & AST_FORMAT_ULAW) { H323_G711Capability *g711uCap; endPoint->SetCapability(0, 0, g711uCap = new H323_G711Capability(H323_G711Capability::muLaw)); g711uCap->SetTxFramesInPacket(g711Frames); } if (cap & AST_FORMAT_ALAW) { H323_G711Capability *g711aCap; endPoint->SetCapability(0, 0, g711aCap = new H323_G711Capability(H323_G711Capability::ALaw)); g711aCap->SetTxFramesInPacket(g711Frames); } if (h323debug) { cout << "Allowed Codecs:\n\t" << setprecision(2) << endPoint->GetCapabilities() << endl; } return 0; }