mirror of https://github.com/f4exb/sdrangel.git
qrtplib: implemented Qt style RTP address object
This commit is contained in:
parent
dbbdc851c6
commit
a0c7381047
|
@ -63,6 +63,7 @@ set(qrtplib_SOURCES
|
||||||
rtcpsdesinfo.cpp
|
rtcpsdesinfo.cpp
|
||||||
rtcpsdespacket.cpp
|
rtcpsdespacket.cpp
|
||||||
rtcpsrpacket.cpp
|
rtcpsrpacket.cpp
|
||||||
|
rtpaddress.cpp
|
||||||
rtpcollisionlist.cpp
|
rtpcollisionlist.cpp
|
||||||
rtperrors.cpp
|
rtperrors.cpp
|
||||||
rtpinternalsourcedata.cpp
|
rtpinternalsourcedata.cpp
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
This file is a part of JRTPLIB
|
||||||
|
Copyright (c) 1999-2017 Jori Liesenborgs
|
||||||
|
|
||||||
|
Contact: jori.liesenborgs@gmail.com
|
||||||
|
|
||||||
|
This library was developed at the Expertise Centre for Digital Media
|
||||||
|
(http://www.edm.uhasselt.be), a research center of the Hasselt University
|
||||||
|
(http://www.uhasselt.be). The library is based upon work done for
|
||||||
|
my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included
|
||||||
|
in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "rtpaddress.h"
|
||||||
|
|
||||||
|
namespace qrtplib
|
||||||
|
{
|
||||||
|
|
||||||
|
RTPAddress *RTPAddress::CreateCopy() const
|
||||||
|
{
|
||||||
|
RTPAddress *a = new RTPAddress();
|
||||||
|
a->address = address;
|
||||||
|
a->port = port;
|
||||||
|
a->rtcpsendport = rtcpsendport;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RTPAddress::IsSameAddress(const RTPAddress *addr) const
|
||||||
|
{
|
||||||
|
if (addr == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr->address.protocol() != address.protocol()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr->address == address)
|
||||||
|
{
|
||||||
|
return addr->port == port;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RTPAddress::IsFromSameHost(const RTPAddress *addr) const
|
||||||
|
{
|
||||||
|
if (addr == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addr->address.protocol() != address.protocol()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr->address == address;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
|
@ -40,6 +40,8 @@
|
||||||
|
|
||||||
#include "rtpconfig.h"
|
#include "rtpconfig.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
namespace qrtplib
|
namespace qrtplib
|
||||||
{
|
{
|
||||||
|
@ -48,20 +50,10 @@ namespace qrtplib
|
||||||
class RTPAddress
|
class RTPAddress
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Identifies the actual implementation being used. */
|
|
||||||
enum AddressType
|
|
||||||
{
|
|
||||||
IPv4Address, /**< Used by the UDP over IPv4 transmitter. */
|
|
||||||
IPv6Address, /**< Used by the UDP over IPv6 transmitter. */
|
|
||||||
ByteAddress, /**< A very general type of address, consisting of a port number and a number of bytes representing the host address. */
|
|
||||||
UserDefinedAddress, /**< Can be useful for a user-defined transmitter. */
|
|
||||||
TCPAddress /**< Used by the TCP transmitter. */
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Returns the type of address the actual implementation represents. */
|
/** Returns the type of address the actual implementation represents. */
|
||||||
AddressType GetAddressType() const
|
QAbstractSocket::NetworkLayerProtocol GetAddressType() const
|
||||||
{
|
{
|
||||||
return addresstype;
|
return address.protocol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates a copy of the RTPAddress instance.
|
/** Creates a copy of the RTPAddress instance.
|
||||||
|
@ -69,31 +61,65 @@ public:
|
||||||
* corresponding memory manager will be used to allocate the memory for the address
|
* corresponding memory manager will be used to allocate the memory for the address
|
||||||
* copy.
|
* copy.
|
||||||
*/
|
*/
|
||||||
virtual RTPAddress *CreateCopy() const = 0;
|
RTPAddress *CreateCopy() const;
|
||||||
|
|
||||||
/** Checks if the address \c addr is the same address as the one this instance represents.
|
/** Checks if the address \c addr is the same address as the one this instance represents.
|
||||||
* Checks if the address \c addr is the same address as the one this instance represents.
|
* Checks if the address \c addr is the same address as the one this instance represents.
|
||||||
* Implementations must be able to handle a NULL argument.
|
* Implementations must be able to handle a NULL argument.
|
||||||
|
*
|
||||||
|
* Note that this function is only used for received packets, and for those
|
||||||
|
* the rtcpsendport variable is not important and should be ignored.
|
||||||
*/
|
*/
|
||||||
virtual bool IsSameAddress(const RTPAddress *addr) const = 0;
|
bool IsSameAddress(const RTPAddress *addr) const;
|
||||||
|
|
||||||
/** Checks if the address \c addr represents the same host as this instance.
|
/** Checks if the address \c addr represents the same host as this instance.
|
||||||
* Checks if the address \c addr represents the same host as this instance. Implementations
|
* Checks if the address \c addr represents the same host as this instance. Implementations
|
||||||
* must be able to handle a NULL argument.
|
* must be able to handle a NULL argument.
|
||||||
|
*
|
||||||
|
* Note that this function is only used for received packets.
|
||||||
*/
|
*/
|
||||||
virtual bool IsFromSameHost(const RTPAddress *addr) const = 0;
|
bool IsFromSameHost(const RTPAddress *addr) const;
|
||||||
|
|
||||||
virtual ~RTPAddress()
|
/** Get host address */
|
||||||
|
const QHostAddress& getAddress() const
|
||||||
{
|
{
|
||||||
|
return address;
|
||||||
}
|
}
|
||||||
protected:
|
|
||||||
// only allow subclasses to be created
|
/** Set host address */
|
||||||
RTPAddress(const AddressType t) :
|
void setAddress(const QHostAddress& address)
|
||||||
addresstype(t)
|
|
||||||
{
|
{
|
||||||
|
this->address = address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get RTP port */
|
||||||
|
uint16_t getPort() const
|
||||||
|
{
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set RTP port */
|
||||||
|
void setPort(uint16_t port)
|
||||||
|
{
|
||||||
|
this->port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get RTCP port */
|
||||||
|
uint16_t getRtcpsendport() const
|
||||||
|
{
|
||||||
|
return rtcpsendport;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set RTCP port */
|
||||||
|
void setRtcpsendport(uint16_t rtcpsendport)
|
||||||
|
{
|
||||||
|
this->rtcpsendport = rtcpsendport;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const AddressType addresstype;
|
QHostAddress address;
|
||||||
|
uint16_t port;
|
||||||
|
uint16_t rtcpsendport;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
|
@ -32,9 +32,10 @@
|
||||||
|
|
||||||
#include "rtpsession.h"
|
#include "rtpsession.h"
|
||||||
#include "rtperrors.h"
|
#include "rtperrors.h"
|
||||||
#include "rtpudpv4transmitter.h"
|
// TODO: this is for Create with transmitter creation. See if we keep it.
|
||||||
#include "rtptcptransmitter.h"
|
//#include "rtpudpv4transmitter.h"
|
||||||
#include "rtpexternaltransmitter.h"
|
//#include "rtptcptransmitter.h"
|
||||||
|
//#include "rtpexternaltransmitter.h"
|
||||||
#include "rtpsessionparams.h"
|
#include "rtpsessionparams.h"
|
||||||
#include "rtpdefines.h"
|
#include "rtpdefines.h"
|
||||||
#include "rtprawpacket.h"
|
#include "rtprawpacket.h"
|
||||||
|
@ -113,20 +114,21 @@ int RTPSession::Create(const RTPSessionParams &sessparams, const RTPTransmission
|
||||||
rtptrans = 0;
|
rtptrans = 0;
|
||||||
switch (protocol)
|
switch (protocol)
|
||||||
{
|
{
|
||||||
case RTPTransmitter::IPv4UDPProto:
|
// TODO: see if we keep this Create method or use the one with the transmitter specified
|
||||||
rtptrans = new RTPUDPv4Transmitter();
|
// case RTPTransmitter::IPv4UDPProto:
|
||||||
break;
|
// rtptrans = new RTPUDPv4Transmitter();
|
||||||
case RTPTransmitter::ExternalProto:
|
// break;
|
||||||
rtptrans = new RTPExternalTransmitter();
|
// case RTPTransmitter::ExternalProto:
|
||||||
break;
|
// rtptrans = new RTPExternalTransmitter();
|
||||||
case RTPTransmitter::UserDefinedProto:
|
// break;
|
||||||
rtptrans = NewUserDefinedTransmitter();
|
// case RTPTransmitter::UserDefinedProto:
|
||||||
if (rtptrans == 0)
|
// rtptrans = NewUserDefinedTransmitter();
|
||||||
return ERR_RTP_SESSION_USERDEFINEDTRANSMITTERNULL;
|
// if (rtptrans == 0)
|
||||||
break;
|
// return ERR_RTP_SESSION_USERDEFINEDTRANSMITTERNULL;
|
||||||
case RTPTransmitter::TCPProto:
|
// break;
|
||||||
rtptrans = new RTPTCPTransmitter();
|
// case RTPTransmitter::TCPProto:
|
||||||
break;
|
// rtptrans = new RTPTCPTransmitter();
|
||||||
|
// break;
|
||||||
default:
|
default:
|
||||||
return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL;
|
return ERR_RTP_SESSION_UNSUPPORTEDTRANSMISSIONPROTOCOL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue