public class RTPSession
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected AppCallerThread |
appCallerThrd
The thread for invoking callbacks for RTP packets
|
protected RTPAppIntf |
appIntf
Handle to application interface for RTP
|
protected int |
bandwidth
Session bandwidth in BYTES per second
|
protected java.lang.String |
cname
SDES CNAME
|
protected boolean |
conflict
We're busy resolving a SSRC conflict, please try again later
|
protected int |
conflictCount
Number of conflicts observed, exessive number suggests loop in network
|
protected DebugAppIntf |
debugAppIntf
Handle to application interface for debugging
|
java.lang.String |
email
SDES The participant's email
|
protected boolean |
endSession
Enough is enough, set to true when you want to quit.
|
protected int |
fbEarlyThreshold |
protected int |
fbMaxDelay |
protected int |
fbRegularThreshold |
protected boolean |
frameReconstruction
Should the library attempt frame reconstruction?
|
protected long |
lastTimestamp
The last timestamp when we sent something
|
java.lang.String |
loc
SDES The participant's location
|
protected java.net.InetAddress |
mcGroup
RTP multicast group
|
protected boolean |
mcSession
Whether this session is a multicast session or not
|
protected int |
minInterval |
protected boolean |
naiveReception
By default we do not return packets from strangers in unicast mode
|
java.lang.String |
name
SDES The participant's real name
|
java.lang.String |
note
SDES A note
|
protected ParticipantDatabase |
partDb
Participant database
|
protected int |
payloadType
Current payload type, can be changed by application
|
java.lang.String |
phone
SDES The participant's phone number
|
protected int |
pktBufBehavior
Maximum number of packets used for reordering
|
protected java.util.concurrent.locks.Condition |
pktBufDataReady
Condition variable, to tell the
|
protected java.util.concurrent.locks.Lock |
pktBufLock
Lock to protect the packet buffers
|
java.lang.String |
priv
SDES A priv string, loosely defined
|
protected java.util.Random |
random
The random seed
|
protected RTPReceiverThread |
recvThrd
The thread for receiving RTP packets
|
protected boolean |
registered
Only one registered application, please
|
protected RTCPAppIntf |
rtcpAppIntf
Handle to application interface for RTCP (optional)
|
protected RTCPAVPFIntf |
rtcpAVPFIntf
Handle to application interface for AVPF, RFC 4585 (optional)
|
protected int |
rtcpBandwidth |
protected int |
rtcpMode |
protected RTCPSession |
rtcpSession
The RTCP session associated with this RTP Session
|
protected java.net.MulticastSocket |
rtpMCSock
RTP multicast socket
|
protected java.net.DatagramSocket |
rtpSock
RTP unicast socket
|
protected int |
sentOctetCount
Number of octets sent by this session
|
protected int |
sentPktCount
Number of packets sent by this session
|
protected int |
seqNum
Current sequence number
|
protected long |
ssrc
SSRC of this session
|
java.lang.String |
tool
SDES The tool the participants is using
|
Constructor and Description |
---|
RTPSession(java.net.DatagramSocket rtpSocket,
java.net.DatagramSocket rtcpSocket)
Returns an instance of a unicast RTP session.
|
RTPSession(java.net.MulticastSocket rtpSock,
java.net.MulticastSocket rtcpSock,
java.net.InetAddress multicastGroup)
Returns an instance of a multicast RTP session.
|
Modifier and Type | Method and Description |
---|---|
int |
addParticipant(Participant p)
Add a participant object to the participant database.
|
java.lang.String |
CNAME()
Get the current CNAME, used for outgoing SDES packets
|
void |
CNAME(java.lang.String cname)
Overrides CNAME, used for outgoing RTCP packets.
|
void |
endSession()
End the RTP Session.
|
int |
fbAppLayerFeedback(long ssrcMediaSource,
byte[] bitString)
Adds a Picture Loss Indication to the feedback queue
|
int |
fbPictureLossIndication(long ssrcMediaSource)
Adds a Picture Loss Indication to the feedback queue
|
int |
fbPictureLossIndication(long ssrcMediaSource,
int FMT,
int[] PID,
int[] BLP)
Adds a RTP Feedback packet to the feedback queue.
|
int |
fbRefPictureSelIndic(long ssrcMediaSource,
int bitPadding,
int payloadType,
byte[] bitString)
Adds a Reference Picture Selection Indication to the feedback queue
|
int |
fbSlicLossIndication(long ssrcMediaSource,
int[] sliFirst,
int[] sliNumber,
int[] sliPictureId)
Adds a Slice Loss Indication to the feedback queue
|
boolean |
frameReconstruction()
Whether the packet buffer will attempt to reconstruct
packet automatically.
|
void |
frameReconstruction(boolean toggle)
Enable / disable frame reconstruction in the packet buffers.
|
java.util.Enumeration<Participant> |
getParticipants() |
long |
getSsrc() |
java.util.Iterator<Participant> |
getUnicastReceivers() |
protected boolean |
isRegistered()
Checks if an application has been registered with this session.
|
boolean |
naivePktReception()
Are packets from unknown participants returned to the application?
|
void |
naivePktReception(boolean doAccept)
Should packets from unknown participants be returned to the application? This can be dangerous.
|
int |
packetBufferBehavior()
The number of RTP packets that should be buffered when a packet is
missing or received out of order.
|
int |
packetBufferBehavior(int behavior)
Set the number of RTP packets that should be buffered when a packet is
missing or received out of order.
|
int |
payloadType()
Get the payload type that is currently used for outgoing RTP packets.
|
int |
payloadType(int payloadT)
Update the payload type used for the session.
|
int |
registerAVPFIntf(RTCPAVPFIntf rtcpAVPFIntf,
int maxDelay,
int earlyThreshold,
int regularThreshold)
Set whether the stack should operate in RFC 4585 mode.
|
int |
registerRTPSession(RTPAppIntf rtpApp,
RTCPAppIntf rtcpApp,
DebugAppIntf debugApp)
Registers an application (RTPAppIntf) with the RTP session.
|
void |
removeParticipant(Participant p)
Remove a participant from the database.
|
protected void |
resolveSsrcConflict()
Resolve an SSRC conflict.
|
int |
rtcpBandwidth()
RFC 3550 dictates that 5% of the total bandwidth,
as set by sessionBandwidth, should be dedicated
to RTCP traffic.
|
int |
rtcpBandwidth(int bandwidth)
Set the RTCP bandwidth, see rtcpBandwidth(void) for details.
|
long[] |
sendData(byte[] buf)
Send data to all participants registered as receivers, using the current timeStamp,
dynamic sequence number and the current payload type specified for the session.
|
long[][] |
sendData(byte[][] buffers,
long[] csrcArray,
boolean[] markers,
long rtpTimestamp,
long[] seqNumbers)
Send data to all participants registered as receivers, using the current timeStamp and
payload type.
|
long[] |
sendData(byte[] buf,
long rtpTimestamp,
long seqNum)
Send data to all participants registered as receivers, using the specified timeStamp,
sequence number and the current payload type specified for the session.
|
int |
sendRTCPAppPacket(long ssrc,
int type,
byte[] name,
byte[] data)
Send RTCP App packet to receiver specified by ssrc
Return values:
0 okay
-1 no RTCP session established
-2 name is not byte[4];
-3 data is not byte[x], where x = 4*y for syme y
-4 type is not a 5 bit unsigned integer
Note that a return value of 0 does not guarantee delivery.
|
int |
sessionBandwidth()
The bandwidth currently allocated to the session,
in bytes per second.
|
int |
sessionBandwidth(int bandwidth)
Set the bandwidth of the session.
|
void |
unregisterAVPFIntf()
Unregisters the RTCP AVPF interface, thereby going from
RFC 4585 mode to RFC 3550
You still have to adjust packetBufferBehavior() and
frameReconstruction.
|
int |
updateRTCPSock(java.net.DatagramSocket newSock)
Change the RTCP socket of the session.
|
int |
updateRTCPSock(java.net.MulticastSocket newSock)
Change the RTCP multicast socket of the session.
|
int |
updateRTPSock(java.net.DatagramSocket newSock)
Change the RTP socket of the session.
|
int |
updateRTPSock(java.net.MulticastSocket newSock)
Change the RTP multicast socket of the session.
|
protected java.net.DatagramSocket rtpSock
protected java.net.MulticastSocket rtpMCSock
protected java.net.InetAddress mcGroup
protected boolean mcSession
protected int payloadType
protected long ssrc
protected long lastTimestamp
protected int seqNum
protected int sentPktCount
protected int sentOctetCount
protected java.util.Random random
protected int bandwidth
protected boolean naiveReception
protected boolean frameReconstruction
protected int pktBufBehavior
protected ParticipantDatabase partDb
protected RTPAppIntf appIntf
protected RTCPAppIntf rtcpAppIntf
protected RTCPAVPFIntf rtcpAVPFIntf
protected DebugAppIntf debugAppIntf
protected RTCPSession rtcpSession
protected RTPReceiverThread recvThrd
protected AppCallerThread appCallerThrd
protected final java.util.concurrent.locks.Lock pktBufLock
protected final java.util.concurrent.locks.Condition pktBufDataReady
protected boolean endSession
protected boolean registered
protected boolean conflict
protected int conflictCount
protected java.lang.String cname
public java.lang.String name
public java.lang.String email
public java.lang.String phone
public java.lang.String loc
public java.lang.String tool
public java.lang.String note
public java.lang.String priv
protected int rtcpMode
protected int fbEarlyThreshold
protected int fbRegularThreshold
protected int minInterval
protected int fbMaxDelay
protected int rtcpBandwidth
public RTPSession(java.net.DatagramSocket rtpSocket, java.net.DatagramSocket rtcpSocket)
rtpSocket
- UDP socket to receive RTP communication onrtcpSocket
- UDP socket to receive RTCP communication on, null if none.public RTPSession(java.net.MulticastSocket rtpSock, java.net.MulticastSocket rtcpSock, java.net.InetAddress multicastGroup) throws java.lang.Exception
rtpSock
- a multicast socket to receive RTP communication onrtcpSock
- a multicast socket to receive RTP communication onmulticastGroup
- the multicast group that we want to communicate with.java.lang.Exception
public int registerRTPSession(RTPAppIntf rtpApp, RTCPAppIntf rtcpApp, DebugAppIntf debugApp)
rtpApp
- an object that implements the RTPAppIntf-interfacertcpApp
- an object that implements the RTCPAppIntf-interface (optional)protected boolean isRegistered()
true
if an application has been registered with
this session.public long[] sendData(byte[] buf)
buf
- A buffer of bytes, less than 1496 bytespublic long[] sendData(byte[] buf, long rtpTimestamp, long seqNum)
buf
- A buffer of bytes, less than 1496 bytesrtpTimestamp
- the RTP timestamp to be used in the packetseqNum
- the sequence number to be used in the packetpublic long[][] sendData(byte[][] buffers, long[] csrcArray, boolean[] markers, long rtpTimestamp, long[] seqNumbers)
buffers
- A buffer of bytes, should not bed padded and less than 1500 bytes on most networks.csrcArray
- an array with the SSRCs of contributing sourcesmarkers
- An array indicating what packets should be marked. Rarely anything but the first onertpTimestamp
- The RTP timestamp to be applied to all packetsseqNumbers
- An array with the sequence number associated with each byte[]public int sendRTCPAppPacket(long ssrc, int type, byte[] name, byte[] data)
ssrc
- of the participant you want to reachtype
- the RTCP App packet subtype, default 0name
- the ASCII (in byte[4]) representationdata
- the data itselfpublic int addParticipant(Participant p)
p
- A participant.public void removeParticipant(Participant p)
p
- A participant.public java.util.Iterator<Participant> getUnicastReceivers()
public java.util.Enumeration<Participant> getParticipants()
public void endSession()
public void CNAME(java.lang.String cname)
cname
- a string, e.g. username@hostname. Must be unique for session.public java.lang.String CNAME()
public long getSsrc()
public int updateRTPSock(java.net.DatagramSocket newSock)
newSock
- integer for new port number, check it is free first.public int updateRTCPSock(java.net.DatagramSocket newSock)
newSock
- the new unicast socket for RTP communication.public int updateRTPSock(java.net.MulticastSocket newSock)
newSock
- the new multicast socket for RTP communication.public int updateRTCPSock(java.net.MulticastSocket newSock)
newSock
- the new multicast socket for RTCP communication.public int payloadType(int payloadT)
payloadT
- an integer representing the payload type of any subsequent packets that are sent.public int payloadType()
public void naivePktReception(boolean doAccept)
doAccept
- packets from participants not added by the application.public boolean naivePktReception()
public int packetBufferBehavior(int behavior)
behavior
- the bepublic int packetBufferBehavior()
public int registerAVPFIntf(RTCPAVPFIntf rtcpAVPFIntf, int maxDelay, int earlyThreshold, int regularThreshold)
rtcpAVPFIntf
- the inpublic void unregisterAVPFIntf()
public void frameReconstruction(boolean toggle)
public boolean frameReconstruction()
public int sessionBandwidth()
public int sessionBandwidth(int bandwidth)
bandwidth
- the new value requested, in bytes per secondpublic int rtcpBandwidth()
public int rtcpBandwidth(int bandwidth)
bandwidth
- the new value requested, in bytes per second or -1 to disablepublic int fbPictureLossIndication(long ssrcMediaSource)
ssrcMediaSource
- public int fbSlicLossIndication(long ssrcMediaSource, int[] sliFirst, int[] sliNumber, int[] sliPictureId)
ssrcMediaSource
- sliFirst
- macroblock (MB) address of the first lost macroblocksliNumber
- number of lost macroblockssliPictureId
- six least significant bits of the codec-specific identifpublic int fbRefPictureSelIndic(long ssrcMediaSource, int bitPadding, int payloadType, byte[] bitString)
ssrcMediaSource
- bitPadding
- number of padded bits at end of bitStringpayloadType
- RTP payload type for codecbitString
- RPSI information as natively defined by the video codecpublic int fbAppLayerFeedback(long ssrcMediaSource, byte[] bitString)
ssrcMediaSource
- bitString
- the original application messagepublic int fbPictureLossIndication(long ssrcMediaSource, int FMT, int[] PID, int[] BLP)
ssrcMediaSource
- FMT
- the Feedback Message SubtypePID
- RTP sequence numbers of lost packetsBLP
- bitmask of following lost packets, shared index with PIDprotected void resolveSsrcConflict()