|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jnetpcap.nio.JMemory
org.jnetpcap.nio.JBuffer
org.jnetpcap.packet.JHeader
org.jnetpcap.protocol.voip.Rtp
@Header(spec="rfc3550",
suite=VOIP,
description="real-time transfer protocol")
public class Rtp
The real-time transport protocol (RTP). RTP provides end-to-end network transport functions suitable for applications transmitting real-time data, such as audio, video or simulation data, over multicast or unicast network services. RTP does not address resource reservation and does not guarantee quality-of-service for real-time services. The data transport is augmented by a control protocol (RTCP) to allow monitoring of the data delivery in a manner scalable to large multicast networks, and to provide minimal control and identification functionality. RTP and RTCP are designed to be independent of the underlying transport and network layers. The protocol supports the use of RTP-level translators and mixers. *
Note that RTP itself does not provide any mechanism to ensure timely delivery or provide other quality-of-service guarantees, but relies on lower-layer services to do so. It does not guarantee delivery or prevent out-of-order delivery, nor does it assume that the underlying network is reliable and delivers packets in sequence. The sequence numbers included in RTP allow the receiver to reconstruct the sender's packet sequence, but sequence numbers might also be used to determine the proper location of a packet, for example in video decoding, without necessarily decoding packets in sequence.
The RTP header has the following format:
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |V=2|P|X| CC |M| PT | sequence number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | timestamp | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | synchronization source (SSRC) identifier | +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ | contributing source (CSRC) identifiers | | .... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
While RTP is primarily designed to satisfy the needs of multi- participant multimedia conferences, it is not limited to that particular application. Storage of continuous data, interactive distributed simulation, active badge, and control and measurement applications may also find RTP applicable.
| Nested Class Summary | |
|---|---|
static class |
Rtp.Extension
An extension mechanism is provided to allow individual implementations to experiment with new payload-format-independent functions that require additional information to be carried in the RTP data packet header. |
static class |
Rtp.PayloadType
Constant payload types that have been defined for type field. |
| Nested classes/interfaces inherited from class org.jnetpcap.packet.JHeader |
|---|
JHeader.State |
| Nested classes/interfaces inherited from class org.jnetpcap.nio.JMemory |
|---|
JMemory.Type |
| Field Summary | |
|---|---|
static int |
CC_MASK
Bitmask applied to byte 0 in the header which masks off the CSRC COUNT field. |
static int |
CC_OFFSET
Bit offset into byte 0 of the header for CSRC COUNT field. |
static int |
CSRC_LENGTH
Constant which defines the length of a CSRC entry in CSRC table in bytes. |
static java.lang.String |
DESCRIPTION
Constant containing a short description of this protocol header. |
static int |
EXTENSION_MASK
Bitmask applied to byte 0 in the header which masks off the extension bit option flag. |
static int |
EXTENSION_OFFSET
Bit offset into byte 0 of the header for EXTENSION field. |
static int |
ID
Registry assigned header ID. |
static int |
MARKER_MASK
Bitmask applied to byte 1 in the header which masks off the marker bit option flag. |
static int |
MARKER_OFFSET
Bit offset into byte 1 of the header for MARKER field. |
static int |
PADDING_MASK
Bitmask applied to byte 0 in the header which masks off the padding bit option flag. |
static int |
PADDING_OFFSET
Bit offset into byte 0 of the header for PADDING field. |
static java.lang.String |
RFC
Constant containing the name of the RFC that describes the specification of this header. |
static int |
RTP_UDP_PORT
Default RTP port number. |
static int |
STATIC_HEADER_LENGTH
Constant which defines the length of the static part of the header in bytes. |
static ProtocolSuite |
SUITE
Constant containing the name of the protocol suite this header belongs to. |
static int |
TYPE_MASK
Bitmask applied to byte 1 in the header which masks off the payload type field. |
static int |
TYPE_OFFSET
Bit offset into byte 1 of the header for PAYLOAD TYPE field. |
static int |
VERSION_MASK
Bitmask applied to byte 0 in the header which masks off the version number of the Rtp header within the packet. |
static int |
VERSION_OFFSET
Bit offset into byte 0 of the header for VERSION field. |
| Fields inherited from class org.jnetpcap.packet.JHeader |
|---|
annotatedHeader, BYTE, EMPTY_HEADER_ARRAY, isSubHeader, packet, state |
| Fields inherited from class org.jnetpcap.nio.JMemory |
|---|
JNETPCAP_LIBRARY_NAME, MAX_DIRECT_MEMORY_DEFAULT, POINTER |
| Constructor Summary | |
|---|---|
Rtp()
|
|
| Method Summary | |
|---|---|
int |
count()
The CSRC count contains the number of CSRC identifiers that follow the fixed header. |
int[] |
csrc()
The CSRC list identifies the contributing sources for the payload contained in this packet. |
int |
csrcLength()
Calculates the length of the csrc field in bits. |
boolean |
hasExtension()
If the extension bit is set, the fixed header MUST be followed by exactly one header extension, with a format defined in Section 5.3.1 of RFC3550 |
boolean |
hasMarker()
The interpretation of the marker is defined by a profile. |
boolean |
hasPadding()
If the padding bit is set, the packet contains one or more additional padding octets at the end which are not part of the payload. |
static int |
headerLength(JBuffer buffer,
int offset)
Determines the length of the header in octets. |
int |
paddingLength()
Returns the number of padding bytes that were appended at the end of this Rtp frame. |
static int |
postfixLength(JBuffer buffer,
int offset)
Determines the length of Rtp padding if the header has been padded. |
int |
sequence()
The sequence number increments by one for each RTP data packet sent, and may be used by the receiver to detect packet loss and to restore packet sequence. |
long |
ssrc()
The SSRC field identifies the synchronization source. |
long |
timestamp()
The timestamp reflects the sampling instant of the first octet in the RTP data packet. |
int |
type()
This field identifies the format of the RTP payload and determines its interpretation by the application. |
Rtp.PayloadType |
typeEnum()
This field identifies the format of the RTP payload and determines its interpretation by the application. |
int |
version()
This field identifies the version of RTP. |
| Methods inherited from class org.jnetpcap.nio.JBuffer |
|---|
findUTF8String, getByte, getByteArray, getByteArray, getByteArray, getDouble, getFloat, getInt, getLong, getShort, getUByte, getUInt, getUShort, getUTF8Char, getUTF8String, getUTF8String, getUTF8String, getUTF8String, isReadonly, order, order, peer, peer, peer, peer, setByte, setByteArray, setByteBuffer, setDouble, setFloat, setInt, setLong, setShort, setShort0, setUByte, setUInt, setUShort, transferFrom, transferFrom, transferFrom, transferTo, transferTo, transferTo |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int CC_MASK
public static final int CC_OFFSET
public static final int CSRC_LENGTH
public static final java.lang.String DESCRIPTION
public static final int EXTENSION_MASK
public static final int EXTENSION_OFFSET
public static int ID
public static final int MARKER_MASK
public static final int MARKER_OFFSET
public static final int PADDING_MASK
public static final int PADDING_OFFSET
public static final java.lang.String RFC
public static final int RTP_UDP_PORT
public static final int STATIC_HEADER_LENGTH
public static final ProtocolSuite SUITE
public static final int TYPE_MASK
public static final int TYPE_OFFSET
public static final int VERSION_MASK
public static final int VERSION_OFFSET
| Constructor Detail |
|---|
public Rtp()
| Method Detail |
|---|
@HeaderLength
public static int headerLength(JBuffer buffer,
int offset)
buffer - buffer containing the header dataoffset - offset within the buffer of the start of the header
@HeaderLength(value=POSTFIX)
public static int postfixLength(JBuffer buffer,
int offset)
buffer - buffer to read options and padding information fromoffset - offset to the start of the header
@Field(offset=4,
length=4)
public int count()
@Field(offset=96) public int[] csrc()
The CSRC list identifies the contributing sources for the payload contained in this packet. The number of identifiers is given by the CC field. If there are more than 15 contributing sources, only 15 can be identified. CSRC identifiers are inserted by mixers (see Section 7.1), using the SSRC identifiers of contributing sources. For example, for audio packets the SSRC identifiers of all sources that were mixed together to create a packet are listed, allowing correct talker indication at the receiver.
@Dynamic(value=LENGTH) public int csrcLength()
@Field(offset=3,
length=1)
public boolean hasExtension()
@Field(offset=8,
length=1)
public boolean hasMarker()
@Field(offset=2,
length=1)
public boolean hasPadding()
public int paddingLength()
@Field(offset=16,
length=16)
public int sequence()
@Field(offset=64,
length=32)
public long ssrc()
@Field(offset=32,
length=32)
public long timestamp()
The timestamp reflects the sampling instant of the first octet in the RTP data packet. The sampling instant MUST be derived from a clock that increments monotonically and linearly in time to allow synchronization and jitter calculations (see Section 6.4.1). The resolution of the clock MUST be sufficient for the desired synchronization accuracy and for measuring packet arrival jitter (one tick per video frame is typically not sufficient). The clock frequency is dependent on the format of data carried as payload and is specified statically in the profile or payload format specification that defines the format, or MAY be specified dynamically for payload formats defined through non-RTP means. If RTP packets are generated periodically, the nominal sampling instant as determined from the sampling clock is to be used, not a reading of the system clock. As an example, for fixed-rate audio the timestamp clock would likely increment by one for each sampling period. If an audio application reads blocks covering 160 sampling periods from the input device, the timestamp would be increased by 160 for each such block, regardless of whether the block is transmitted in a packet or dropped as silent.
The initial value of the timestamp SHOULD be random, as for the sequence number. Several consecutive RTP packets will have equal timestamps if they are (logically) generated at once, e.g., belong to the same video frame. Consecutive RTP packets MAY contain timestamps that are not monotonic if the data is not transmitted in the order it was sampled, as in the case of MPEG interpolated video frames. (The sequence numbers of the packets as transmitted will still be monotonic.) RTP timestamps from different media streams may advance at different rates and usually have independent, random offsets. Therefore, although these timestamps are sufficient to reconstruct the timing of a single stream, directly comparing RTP timestamps from different media is not effective for synchronization. Instead, for each medium the RTP timestamp is related to the sampling instant by pairing it with a timestamp from a reference clock (wallclock) that represents the time when the data corresponding to the RTP timestamp was sampled. The reference clock is shared by all media to be synchronized. The timestamp pairs are not transmitted in every data packet, but at a lower rate in RTCP SR packets as described in Section 6.4. The sampling instant is chosen as the point of reference for the RTP timestamp because it is known to the transmitting endpoint and has a common definition for all media, independent of encoding delays or other processing. The purpose is to allow synchronized presentation of all media sampled at the same time. Applications transmitting stored data rather than data sampled in real time typically use a virtual presentation timeline derived from wallclock time to determine when the next frame or other unit of each medium in the stored data should be presented. In this case, the RTP timestamp would reflect the presentation time for each unit. That is, the RTP timestamp for each unit would be related to the wallclock time at which the unit becomes current on the virtual presentation timeline. Actual presentation occurs some time later as determined by the receiver. An example describing live audio narration of prerecorded video illustrates the significance of choosing the sampling instant as the reference point. In this scenario, the video would be presented locally for the narrator to view and would be simultaneously transmitted using RTP. The "sampling instant" of a video frame transmitted in RTP would be established by referencing its timestamp to the wallclock time when that video frame was presented to the narrator. The sampling instant for the audio RTP packets containing the narrator's speech would be established by referencing the same wallclock time when the audio was sampled. The audio and video may even be transmitted by different hosts if the reference clocks on the two hosts are synchronized by some means such as NTP. A receiver can then synchronize presentation of the audio and video packets by relating their RTP timestamps using the timestamp pairs in RTCP SR packets.
@Field(offset=9,
length=7)
public int type()
public Rtp.PayloadType typeEnum()
@Field(offset=0,
length=2)
public int version()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||