📄 jvoiprtptransmission.cpp
字号:
}bool JVOIPRTPTransmission::SupportsMulticasting(){ bool val; if (!init) return false; val = rtpsess->SupportsMulticasting(); return val;}bool JVOIPRTPTransmission::JoinMulticastGroup(JVOIPuint32 mcastip){ std::list<JVOIPuint32>::const_iterator it; bool found,val; if (!init) return false; // check if the IP is already in the list... for (found = false,it = mcastIPs.begin() ; !found && it != mcastIPs.end() ; ++it) { if ((*it) == mcastip) found = true; } if (!found) { RTPIPv4Address mcastgroup(mcastip); if (rtpsess->JoinMulticastGroup(mcastgroup) < 0) val = false; else val = true; } else val = true; return val;}bool JVOIPRTPTransmission::LeaveMulticastGroup(JVOIPuint32 mcastip){ std::list<JVOIPuint32>::iterator it; bool found,val; if (!init) return false; // check if the IP is already in the list... for (found = false,it = mcastIPs.begin() ; !found && it != mcastIPs.end() ; ) { if ((*it) == mcastip) found = true; else ++it; } if (!found) return false; RTPIPv4Address mcastgroup(mcastip); if (rtpsess->LeaveMulticastGroup(mcastgroup) < 0) val = false; else { val = true; mcastIPs.erase(it); } return val;}void JVOIPRTPTransmission::LeaveAllMulticastGroups(){ if (!init) return; rtpsess->LeaveAllMulticastGroups(); mcastIPs.clear();}bool JVOIPRTPTransmission::SupportsReceiveType(JVOIPSessionParams::ReceiveType rt){ if (!init) return false; switch(rt) { case JVOIPSessionParams::AcceptAll: return true; case JVOIPSessionParams::AcceptSome: return true; case JVOIPSessionParams::IgnoreSome: return true; } return false;}bool JVOIPRTPTransmission::SetReceiveType(JVOIPSessionParams::ReceiveType rt){ std::list<IPPortPair>::const_iterator it; if (!init) return false; if (receivetype == rt) // nothing changed return true; receivetype = rt; rtpsess->ClearIgnoreList(); rtpsess->ClearAcceptList(); switch(rt) { case JVOIPSessionParams::AcceptSome: { rtpsess->SetReceiveMode(RTPTransmitter::AcceptSome); for (it = acceptlist.begin() ; it != acceptlist.end() ; ++it) { if ((*it).port == JVOIP_ALLPORTS) { RTPIPv4Address dest((*it).ip); rtpsess->AddToAcceptList(dest); } else { RTPIPv4Address dest((*it).ip,(*it).port); rtpsess->AddToAcceptList(dest); } } } break; case JVOIPSessionParams::IgnoreSome: { rtpsess->SetReceiveMode(RTPTransmitter::IgnoreSome); for (it = ignorelist.begin() ; it != ignorelist.end() ; ++it) { if ((*it).port == JVOIP_ALLPORTS) { RTPIPv4Address dest((*it).ip); rtpsess->AddToIgnoreList(dest); } else { RTPIPv4Address dest((*it).ip,(*it).port); rtpsess->AddToIgnoreList(dest); } } } break; case JVOIPSessionParams::AcceptAll: default: rtpsess->SetReceiveMode(RTPTransmitter::AcceptAll); } return true;}bool JVOIPRTPTransmission::AddToAcceptList(JVOIPuint32 ip,JVOIPuint16 port /* = JVOIP_ALLPORTS */){ std::list<IPPortPair>::iterator it; bool val = false; if (!init) return false; if (port == JVOIP_ALLPORTS) { it = acceptlist.begin(); while(it != acceptlist.end()) { if ((*it).ip == ip && (*it).port == JVOIP_ALLPORTS) return true; if ((*it).ip == ip) { // remove the specific IP-port combinations which // have 'ip' as address if (receivetype == JVOIPSessionParams::AcceptSome) { RTPIPv4Address dest(ip,(*it).port); rtpsess->DeleteFromAcceptList(dest); } it = acceptlist.erase(it); } else ++it; } // now, add the entry if (receivetype == JVOIPSessionParams::AcceptSome) { RTPIPv4Address dest(ip); rtpsess->AddToAcceptList(dest); } val = true; acceptlist.push_back(IPPortPair(ip,port)); } else // one specific port { for (it = acceptlist.begin() ; it != acceptlist.end() ; ++it) { if ((*it).ip == ip && ((*it).port == JVOIP_ALLPORTS || (*it).port == port)) return true; } // The IP-port pair is not currently in the accept list if (receivetype == JVOIPSessionParams::AcceptSome) { RTPIPv4Address dest(ip,port); rtpsess->AddToAcceptList(dest); } val = true; acceptlist.push_back(IPPortPair(ip,port)); } return val;}bool JVOIPRTPTransmission::DeleteFromAcceptList(JVOIPuint32 ip,JVOIPuint16 port /* = JVOIP_ALLPORTS */){ std::list<IPPortPair>::iterator it; if (!init) return false; for (it = acceptlist.begin() ; it != acceptlist.end() ; ++it) { if ((*it).ip == ip && (*it).port == port) { if (receivetype == JVOIPSessionParams::AcceptSome) { if (port == JVOIP_ALLPORTS) { RTPIPv4Address dest(ip); rtpsess->DeleteFromAcceptList(dest); } else { RTPIPv4Address dest(ip,port); rtpsess->DeleteFromAcceptList(dest); } } acceptlist.erase(it); return true; } } return false;}void JVOIPRTPTransmission::ClearAcceptList(){ if (!init) return; if (receivetype == JVOIPSessionParams::AcceptSome) rtpsess->ClearAcceptList(); acceptlist.clear();}bool JVOIPRTPTransmission::AddToIgnoreList(JVOIPuint32 ip,JVOIPuint16 port /* = JVOIP_ALLPORTS */){ std::list<IPPortPair>::iterator it; bool val = false; if (!init) return false; if (port == JVOIP_ALLPORTS) { it = ignorelist.begin(); while(it != ignorelist.end()) { if ((*it).ip == ip && (*it).port == JVOIP_ALLPORTS) return true; if ((*it).ip == ip) { // remove the specific IP-port combinations which // have 'ip' as address if (receivetype == JVOIPSessionParams::IgnoreSome) { RTPIPv4Address dest(ip,(*it).port); rtpsess->DeleteFromIgnoreList(dest); } it = ignorelist.erase(it); } else ++it; } // now, add the entry if (receivetype == JVOIPSessionParams::IgnoreSome) { RTPIPv4Address dest(ip); rtpsess->AddToIgnoreList(dest); } val = true; ignorelist.push_back(IPPortPair(ip,port)); } else // one specific port { for (it = ignorelist.begin() ; it != ignorelist.end() ; ++it) { if ((*it).ip == ip && ((*it).port == JVOIP_ALLPORTS || (*it).port == port)) return true; } // The IP-port pair is not currently in the accept list if (receivetype == JVOIPSessionParams::IgnoreSome) { RTPIPv4Address dest(ip,port); rtpsess->AddToIgnoreList(dest); } val = true; ignorelist.push_back(IPPortPair(ip,port)); } return val;}bool JVOIPRTPTransmission::DeleteFromIgnoreList(JVOIPuint32 ip,JVOIPuint16 port /* = JVOIP_ALLPORTS */){ std::list<IPPortPair>::iterator it; if (!init) return false; for (it = ignorelist.begin() ; it != ignorelist.end() ; ++it) { if ((*it).ip == ip && (*it).port == port) { if (receivetype == JVOIPSessionParams::IgnoreSome) { if (port == JVOIP_ALLPORTS) { RTPIPv4Address dest(ip); rtpsess->DeleteFromIgnoreList(dest); } else { RTPIPv4Address dest(ip,port); rtpsess->DeleteFromIgnoreList(dest); } } ignorelist.erase(it); return true; } } return false;}void JVOIPRTPTransmission::ClearIgnoreList(){ if (!init) return; if (receivetype == JVOIPSessionParams::IgnoreSome) rtpsess->ClearIgnoreList(); ignorelist.clear();}bool JVOIPRTPTransmission::SupportsSampleInterval(int ival){ if (!init) return false; return true;}bool JVOIPRTPTransmission::SupportsInputSamplingRate(int irate){ if (!init) return false; return SupportedSampleRate(irate);}bool JVOIPRTPTransmission::SupportsInputBytesPerSample(int inputbytespersample){ if (!init) return false; if (inputbytespersample == 1 || inputbytespersample == 2) return true; return false;}int JVOIPRTPTransmission::SetSampleInterval(int ival){ if (!init) return ERR_JVOIPLIB_GENERAL_COMPONENTNOTINIT; interval = ((double)ival)/1000.0; // convert to seconds return 0;}int JVOIPRTPTransmission::SetInputSamplingRate(int irate){ int status; std::list<JVOIPuint32>::const_iterator it1; std::list<IPPortPair>::const_iterator it2; if (!init) return ERR_JVOIPLIB_GENERAL_COMPONENTNOTINIT; // NOTE: Since this will have an effect on the timestamp, we probably // should work with a new rtp session... rtpsess->BYEDestroy(RTPTime(0.5),0,0); delete rtpsess; if ((status = CreateNewRTPSession()) < 0) { rtpsess = NULL; return status; } // Reinstall the destinations, acceptlist, etc. for (it1 = mcastIPs.begin() ; it1 != mcastIPs.end() ; ++it1) { RTPIPv4Address mcastgroup(*it1); if ((rtpsess->JoinMulticastGroup(mcastgroup)) < 0) return ERR_JVOIPLIB_RTPTRANS_CANTREJOINMULTICASTGROUP; } for (it2 = destinations.begin() ; it2 != destinations.end() ; ++it2) { RTPIPv4Address dest((*it2).ip,(*it2).port); if ((rtpsess->AddDestination(dest)) < 0) return ERR_JVOIPLIB_RTPTRANS_CANTREINSTALLDESTINATIONS; } if (receivetype == JVOIPSessionParams::AcceptSome) { for (it2 = acceptlist.begin() ; it2 != acceptlist.end() ; ++it2) { if ((*it2).port == JVOIP_ALLPORTS) { RTPIPv4Address dest((*it2).ip); rtpsess->AddToAcceptList(dest); } else { RTPIPv4Address dest((*it2).ip,(*it2).port); rtpsess->AddToAcceptList(dest); } } } else if (receivetype == JVOIPSessionParams::IgnoreSome) { for (it2 = ignorelist.begin() ; it2 != ignorelist.end() ; ++it2) { if ((*it2).port == JVOIP_ALLPORTS) { RTPIPv4Address dest((*it2).ip); rtpsess->AddToIgnoreList(dest); } else { RTPIPv4Address dest((*it2).ip,(*it2).port); rtpsess->AddToIgnoreList(dest); } } } samplingrate = irate; return 0;}int JVOIPRTPTransmission::SetInputBytesPerSample(int inputbytespersample){ if (!init) return ERR_JVOIPLIB_GENERAL_COMPONENTNOTINIT; // REMINDER: check if this is enough! bytespersample = inputbytespersample; return 0;}int JVOIPRTPTransmission::GetComponentState(JVOIPComponentState **compstate){ if (!init) return ERR_JVOIPLIB_GENERAL_COMPONENTNOTINIT; try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -