📄 jrtplib.tex
字号:
\subsubsection{\tt RTPAddress}\headerfile{rtpaddress.h} The class {\tt RTPAddress} is an abstract class which is used to specify destinations, multicast groups etc. To check which actual implementation is used, the class defines the following type: \begin{verbatim} enum AddressType { IPv4Address, IPv6Address, UserDefinedAddress }; \end{verbatim} The type {\tt RTPAddress::IPv4Address} is used by the UDP over IPv4 transmitter; {\tt RTPAddress::IPv6Address} is used by the UDP over IPv6 transmitter. The {\tt RTPAddress::UserDefinedAddress} type can be useful when using a user-defined transmission component. The class defines the following interface: \begin{itemize} \item {\tt AddressType GetAddressType() const}\\ Returns the type of address the actual implementation represents. \item {\tt RTPAddress *CreateCopy() const}\\ Creates a copy of the {\tt RTPAddress} instance. \item {\tt bool IsSameAddress(const RTPAddress *addr) const}\\ Checks if the address {\tt addr} is the same address as the one this instance represents. Implementations must be able ti handle a NULL argument. \item {\tt bool IsFromSameHost(const RTPAddress *addr) const}\\ Checks if the address {\tt addr} represents the same host as this instance. Implementations must be able to handle a NULL argument. \end{itemize} \Paragraph{\tt RTPIPv4Address}\headerfile{rtpipv4address.h}\inherits{RTPAddress} \label{rtpipv4address} This class is used by the UDP over IPv4 transmission component. The following member functions are defined in this class: \begin{itemize} \item {\tt RTPIPv4Address(u\_int32\_t ip = 0, u\_int16\_t port = 0)}\\ Creates an instance with IP address {\tt ip} and port number {\tt port}. Both are interpreted in host byte order. \item {\tt RTPIPv4Address(const u\_int8\_t ip[4], u\_int16\_t port = 0)}\\ Creates an instance with IP address {\tt ip} and port {\tt port}. The port number is interpreted in host byte order. \item {\tt void SetIP(u\_int32\_t ip)}\\ Sets the IP address for this instance to {\tt ip} which is assumed to be in host byte order. \item {\tt void SetIP(const u\_int8\_t ip[4])}\\ Sets the IP address of this instance to {\tt ip}. \item {\tt void SetPort(u\_int16\_t port)}\\ Sets the port number for this instance to {\tt port} which is interpreted in host byte order. \item {\tt u\_int32\_t GetIP() const}\\ Returns the IP address contained in this instance in host byte order. \item {\tt u\_int16\_t GetPort() const}\\ Returns the port number of this instance in host byte order. \end{itemize} When an {\tt RTPIPv4Address} is used in one of the multicast functions of the transmitter, the port number is ignored. When an instance is used in one of the accept or ignore functions of the transmitter, a zero port number represents all ports for the specified IP address. \Paragraph{\tt RTPIPv6Address}\headerfile{rtpipv6address.h}\inherits{RTPAddress} \label{rtpipv6address} This class is used by the UDP over IPv4 transmission component. The following member functions are defined: \begin{itemize} \item {\tt RTPIPv6Address()}\\ Creates an instance with IP address and port number set to zero. \item {\tt RTPIPv6Address(const u\_int8\_t ip[16], u\_int16\_t port = 0)}\\ Creates an instance with IP address {\tt ip} and port number {\tt port}. The port number is assumed to be in host byte order. \item {\tt RTPIPv6Address(in6\_addr ip, u\_int16\_t port = 0)}\\ Creates an instance with IP address {\tt ip} and port number {\tt port}. The port number is assumed to be in host byte order. \item {\tt void SetIP(in6\_addr ip)}\\ Sets the IP address for this instance to {\tt ip}. \item {\tt void SetIP(const u\_int8\_t ip[16])}\\ Sets the IP address for this instance to {\tt ip}. \item {\tt void SetPort(u\_int16\_t port)}\\ Sets the port number for this instance to {\tt port}, which is interpreted in host byte order. \item {\tt void GetIP(u\_int8\_t ip[16]) const}\\ Copies the IP address of this instance in {\tt ip}. \item {\tt in6\_addr GetIP() const}\\ Returns the IP address of this instance. \item {\tt u\_int16\_t GetPort() const}\\ Returns the port number contained in this instance in host byte order. \end{itemize} When an {\tt RTPIPv6Address} is used in one of the multicast functions of the transmitter, the port number is ignored. When an instance is used in one of the accept or ignore functions of the transmitter, a zero port number represents all ports for the specified IP address. \subsubsection{\tt RTPRawPacket}\headerfile{rtprawpacket.h} The {\tt RTPRawPacket} class is used by the transmission component to store the incoming RTP and RTCP data in. It has the following interface: \begin{itemize} \item {\tt RTPRawPacket(u\_int8\_t *data, size\_t datalen, RTPAddress *address, RTPTime \&recvtime, bool rtp)}\\ Creates an instance which stores data from {\tt data} with length {\tt datalen}. Only the pointer to the data is stored, no actual copy is made! The address from which this packet originated is set to {\tt address} and the time at which the packet was received is set to {\tt recvtime}. The flag which indicates whether this data is RTP or RTCP data is set to {\tt rtp}. \item {\tt u\_int8\_t *GetData()}\\ Returns the pointer to the data which is contained in this packet. \item {\tt size\_t GetDataLength() const}\\ Returns the length of the packet described by this instance. \item {\tt RTPTime GetReceiveTime() const}\\ Returns the time at which this packet was received. \item {\tt const RTPAddress *GetSenderAddress() const}\\ Returns the address stored in this packet. \item {\tt bool IsRTP() const}\\ Returns {\tt true} if this data is RTP data, {\tt false} if it is RTCP data. \item {\tt void ZeroData()}\\ Sets the pointer to the data stored in this packet to zero. This will prevent a {\tt delete} call for the actual data when the destructor of {\tt RTPRawPacket} is called. This function is used by the {\tt RTPPacket} and {\tt RTCPCompoundPacket} classes to obtain the packet data (without having to copy it) and to make sure the data isn't deleted when the destructor of {\tt RTPRawPacket} is called. \end{itemize} \subsubsection{\tt RTPPacket}\headerfile{rtppacket.h} The {\tt RTPPacket} class can be used to parse a {\tt RTPRawPacket} instance if it represents RTP data. The class can also be used to create a new RTP packet according to the parameters specified by the user. The interface of this class is the following: \begin{itemize} \item {\tt RTPPacket(RTPRawPacket \&rawpack)}\\ Creates an RTPPacket instance based upon the data in {\tt rawpack}. \item {\tt RTPPacket(u\_int8\_t payloadtype, const void *payloaddata, size\_t payloadlen, u\_int16\_t seqnr, u\_int32\_t timestamp, u\_int32\_t ssrc, bool gotmarker, u\_int8\_t numcsrcs, const u\_int32\_t *csrcs, bool gotextension, u\_int16\_t extensionid, u\_int16\_t extensionlen\_numwords, const void *extensiondata, size\_t maxpacksize = 0)}\\ Creates an new buffer for an RTP packet and fills in the fields according to the specified parameters. If {\tt maxpacksize} is not equal to zero, an error is generated if the total packet size would exceed {\tt maxpacksize}. The arguments of the constructor are self-explanatory. Note that the size of a header extension is specified in a number of $32$-bit words. \item {\tt RTPPacket(u\_int8\_t payloadtype, const void *payloaddata, size\_t payloadlen, u\_int16\_t seqnr, u\_int32\_t timestamp, u\_int32\_t ssrc, bool gotmarker, u\_int8\_t numcsrcs, const u\_int32\_t *csrcs, bool gotextension, u\_int16\_t extensionid, u\_int16\_t extensionlen\_numwords, const void *extensiondata, void *buffer, size\_t buffersize)}\\ Pretty much the same function as the previous one, except that data is stored in an external buffer {\tt buffer} with buffer size {\tt buffersize}. \item {\tt int GetCreationError() const}\\ If an error occurred in one of the constructors, this function returns the error code. \item {\tt bool HasExtension() const}\\ Returns {\tt true} if the RTP packet has a header extension and {\tt false} otherwise. \item {\tt bool HasMarker() const}\\ Returns {\tt true} is the marker bit was set and {\tt false} otherwise. \item {\tt int GetCSRCCount() const}\\ Returns the number of CSRCs contained in this packet. \item {\tt u\_int32\_t GetCSRC(int num) const}\\ Returns a specific CSRC identifier. The parameter {\tt num} can go from $0$ to {\tt GetCSRCCount()}-$1$. \item {\tt u\_int8\_t GetPayloadType() const}\\ Returns the payload type of the packet. \item {\tt u\_int32\_t GetExtendedSequenceNumber() const}\\ Returns the extended sequence number of the packet. When the packet is just received, only the low $16$ bits will be set. The high $16$ bits can be filled in later. \item {\tt u\_int16\_t GetSequenceNumber() const}\\ Returns the sequence number of this packet. \item {\tt void SetExtendedSequenceNumber(u\_int32\_t seq)}\\ Sets the extended sequence number of this packet to {\tt seq}. \item {\tt u\_int32\_t GetTimestamp() const}\\ Returns the timestamp of this packet. \item {\tt u\_int32\_t GetSSRC() const}\\ Returns the SSRC identifier stored in this packet. \item {\tt u\_int8\_t *GetPacketData() const}\\ Returns a pointer to the data of the entire packet. \item {\tt u\_int8\_t *GetPayloadData() const}\\ Returns a pointer to the actual payload data. \item {\tt size\_t GetPacketLength() const}\\ Returns the length of the entire packet. \item {\tt size\_t GetPayloadLength() const}\\ Returns the payload length. \item {\tt u\_int16\_t GetExtensionID() const}\\ If a header extension is present, this function returns the extension identifier. \item {\tt u\_int8\_t *GetExtensionData() const}\\ Returns a pointer to the header extension data. \item {\tt size\_t GetExtensionLength() const}\\ Returns the length of the header extension data. \item {\tt RTPTime GetReceiveTime() const}\\ When an {\tt RTPPacket} instance is created from an {\tt RTPRawPacket} instance, the raw packet's reception time is stored in the {\tt RTPPacket} instance. This function then retrieves that time. \end{itemize} \subsubsection{\tt RTCPCompoundPacket}\headerfile{rtpcompoundpacket.h} This class describes an RTCP compound packet and has the following interface: \begin{itemize} \item {\tt RTCPCompoundPacket(RTPRawPacket \&rawpack)}\\ Creates an {\tt RTCPCompoundPacket} instance from the data in {\tt rawpack}. \item {\tt int GetCreationError()}\\ If the raw packet data in the constructor could not be parsed, this function returns the error code of what went wrong. If the packet had an invalid format, the return value is {\tt ERR\_\-RTP\_\-RTCPCOMPOUND\_\-INVALID\-PACKET}. \item {\tt u\_int8\_t *GetCompoundPacketData()}\\ Returns a pointer to the data of the entire RTCP compound packet. \item {\tt size\_t GetCompoundPacketLength()}\\ Returns the size of the entire RTCP compound packet \item {\tt void GotoFirstPacket()}\\ Starts the iteration over the individual RTCP packets in the RTCP compound packet. \item {\tt RTCPPacket *GetNextPacket()}\\ Returns a pointer to the next individual RTCP packet. Note that no {\tt delete} call may be done on the {\tt RTCPPacket} instance which is returned. The {\tt RTCPPacket} class is described below. \end{itemize} \Paragraph{\tt RTCPPacket}\headerfile{rtcppacket.h} The class {\tt RTCPPacket} is a base class for specific types of RTCP packets. The following type in the {\tt RTCPPacket} class identifies the different packet types: \begin{verbatim} enum PacketType { SR, RR, SDES, BYE, APP, Unknown }; \end{verbatim} The class contains the following member functions: \begin{itemize} \item {\tt bool IsKnownFormat() const}\\ Returns {\tt true} if the subclass was able to interpret the data and {\tt false} otherwise. \item {\tt PacketType GetPacketType() const}\\ Returns the actual packet type which the subclass implements: \begin{itemize} \item {\tt RTCPPacket::SR}: indicates an {\tt RTCPSRPacket} instance \item {\tt RTCPPacket::RR}: indicates an {\tt RTCPRRPacket} instance \item {\tt RTCPPacket::SDES}: indicates an {\tt RTCPSDESPacket} instance \item {\tt RTCPPacket::BYE}: indicates an {\tt RTCPBYEPacket} instance \item {\tt RTCPPacket::APP}: indicates an {\tt RTCPAPPPacket} instance \item {\tt RTCPPacket::Unknown}: indicates an {\tt RTCPUnknownPacket} instance \end{itemize} \item {\tt u\_int8\_t *GetPacketData()}\\ Returns a pointer to the data of this RTCP packet. \item {\tt size\_t GetPacketLength() const}\\ Returns the length of this RTCP packet.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -