From db9c8b0add566f57760dfc021006cf591f6ed453 Mon Sep 17 00:00:00 2001 From: csoutheren Date: Thu, 25 Nov 2004 07:23:46 +0000 Subject: [PATCH] Added IsSupportingRTP function to simplify detecting when STUN supports RTP --- include/ptclib/pstun.h | 17 +++++++++++++++++ src/ptclib/pstun.cxx | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/include/ptclib/pstun.h b/include/ptclib/pstun.h index cced64a6..3018c987 100644 --- a/include/ptclib/pstun.h +++ b/include/ptclib/pstun.h @@ -24,6 +24,9 @@ * Contributor(s): ______________________________________. * * $Log$ + * Revision 1.9 2004/11/25 07:23:46 csoutheren + * Added IsSupportingRTP function to simplify detecting when STUN supports RTP + * * Revision 1.8 2004/03/14 05:47:52 rjongbloed * Fixed incorrect detection of symmetric NAT (eg Linux masquerading) and also * some NAT systems which are partially blocked due to firewall rules. @@ -173,6 +176,20 @@ class PSTUNClient : public PObject BOOL force = FALSE /// Force a new check ); + enum RTPSupportTypes { + RTPOK, + RTPUnknown, + RTPUnsupported, + RTPIfSendMedia + }; + + /**Return an indication if the current STUN type supports RTP + Use the force variable to guarantee an up to date test + */ + RTPSupportTypes IsSupportingRTP( + BOOL force = FALSE /// Force a new check + ); + /**Determine via the STUN protocol the NAT type for the router. As for GetNatType() but returns an English string for the type. */ diff --git a/src/ptclib/pstun.cxx b/src/ptclib/pstun.cxx index 0b96ffa5..9f13bd66 100644 --- a/src/ptclib/pstun.cxx +++ b/src/ptclib/pstun.cxx @@ -24,6 +24,9 @@ * Contributor(s): ______________________________________. * * $Log$ + * Revision 1.16 2004/11/25 07:23:46 csoutheren + * Added IsSupportingRTP function to simplify detecting when STUN supports RTP + * * Revision 1.15 2004/10/26 05:58:23 csoutheren * Increased timeout on STUN responses to avoid spurious STUN failures due * to network trsffic/congestion etc @@ -567,6 +570,36 @@ PString PSTUNClient::GetNatTypeName(BOOL force) } +PSTUNClient::RTPSupportTypes PSTUNClient::IsSupportingRTP(BOOL force) +{ + switch (GetNatType(force)) { + + // types that do support RTP + case OpenNat: + case ConeNat: + return RTPOK; + + // types that support RTP if media sent first + case SymmetricFirewall: + case RestrictedNat: + case PortRestrictedNat: + return RTPIfSendMedia; + + // types that do not support RTP + case BlockedNat: + case SymmetricNat: + return RTPUnsupported; + + // types that have unknown RTP support + case UnknownNat: + case PartialBlockedNat: + default: + break; + } + + return RTPUnknown; +} + BOOL PSTUNClient::GetExternalAddress(PIPSocket::Address & externalAddress, const PTimeInterval & maxAge) { -- 2.11.4.GIT