public class RtpSocket
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
static int |
MTU |
static int |
RTP_HEADER_LENGTH |
static java.lang.String |
TAG |
static int |
TRANSPORT_TCP
Use this to use TCP for the transport protocol.
|
static int |
TRANSPORT_UDP
Use this to use UDP for the transport protocol.
|
Constructor and Description |
---|
RtpSocket()
This RTP socket implements a buffering mechanism relying on a FIFO of buffers and a Thread.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the underlying socket.
|
void |
commitBuffer()
Puts the buffer back into the FIFO without sending the packet.
|
void |
commitBuffer(int length)
Sends the RTP packet over the network.
|
long |
getBitrate()
Returns an approximation of the bitrate of the RTP stream in bits per second.
|
int[] |
getLocalPorts() |
int |
getPort() |
int |
getSSRC()
Returns the SSRC of the stream.
|
void |
markNextPacket()
Sets the marker in the RTP packet.
|
byte[] |
requestBuffer()
Returns an available buffer from the FIFO, it can then be modified.
|
void |
run()
The Thread sends the packets in the FIFO one by one at a constant rate.
|
void |
setCacheSize(long cacheSize)
Sets the size of the FIFO in ms.
|
void |
setClockFrequency(long clock)
Sets the clock frequency of the stream in Hz.
|
void |
setDestination(java.net.InetAddress dest,
int dport,
int rtcpPort)
Sets the destination address and to which the packets will be sent.
|
void |
setOutputStream(java.io.OutputStream outputStream,
byte channelIdentifier)
If a TCP is used as the transport protocol for the RTP session,
the output stream to which RTP packets will be written to must
be specified with this method.
|
void |
setSSRC(int ssrc)
Sets the SSRC of the stream.
|
void |
setTimeToLive(int ttl)
Sets the Time To Live of the UDP packets.
|
void |
updateTimestamp(long timestamp)
Overwrites the timestamp in the packet.
|
public static final java.lang.String TAG
public static final int TRANSPORT_UDP
public static final int TRANSPORT_TCP
public static final int RTP_HEADER_LENGTH
public static final int MTU
public RtpSocket()
java.io.IOException
public void close()
public void setSSRC(int ssrc)
public int getSSRC()
public void setClockFrequency(long clock)
public void setCacheSize(long cacheSize)
public void setTimeToLive(int ttl) throws java.io.IOException
java.io.IOException
public void setDestination(java.net.InetAddress dest, int dport, int rtcpPort)
public void setOutputStream(java.io.OutputStream outputStream, byte channelIdentifier)
public int getPort()
public int[] getLocalPorts()
public byte[] requestBuffer() throws java.lang.InterruptedException
commitBuffer(int)
to send it over the network.java.lang.InterruptedException
public void commitBuffer() throws java.io.IOException
java.io.IOException
public void commitBuffer(int length) throws java.io.IOException
java.io.IOException
public long getBitrate()
public void updateTimestamp(long timestamp)
timestamp
- The new timestamp in ns.public void markNextPacket()
public void run()
run
in interface java.lang.Runnable