public abstract class RTPConnectorOutputStream
extends java.lang.Object
implements javax.media.rtp.OutputDataStream
Modifier and Type | Field and Description |
---|---|
static int |
PACKET_QUEUE_CAPACITY
The maximum number of packets to be sent to be kept in the queue of
RTPConnectorOutputStream . |
static int |
POOL_CAPACITY
The maximum size of the queues used as pools for unused objects.
|
protected java.util.List<java.net.InetSocketAddress> |
targets
Stream targets' IP addresses and ports.
|
Constructor and Description |
---|
RTPConnectorOutputStream()
Initializes a new RTPConnectorOutputStream which is to send
packet data out through a specific socket.
|
Modifier and Type | Method and Description |
---|---|
void |
addTarget(java.net.InetAddress remoteAddr,
int remotePort)
Add a target to stream targets list
|
void |
close()
Close this output stream.
|
protected abstract void |
doLogPacket(RawPacket packet,
java.net.InetSocketAddress target)
Logs a specific RawPacket associated with a specific remote
address.
|
long |
getNumberOfBytesSent()
Returns the number of bytes sent trough this stream
|
long |
getOutputBitrate() |
long |
getOutputBitrate(long now) |
protected PacketLoggingService |
getPacketLoggingService()
Gets the
PacketLoggingService (to be) utilized by this instance. |
protected abstract boolean |
isSocketValid()
Returns whether or not this RTPConnectorOutputStream has a valid
socket.
|
static boolean |
logDroppedPacket(int numDroppedPackets)
Returns true if a warning should be logged after a queue has dropped
numDroppedPackets packets. |
(package private) static boolean |
logPacket(long numOfPacket)
Determines whether a RawPacket which has a specific number in
the total number of sent RawPackets is to be logged by
PacketLoggingService . |
protected RawPacket[] |
packetize(byte[] buf,
int off,
int len,
java.lang.Object context)
Creates a RawPacket element from a specific byte[]
buffer in order to have this instance send its packet data through its
write(byte[], int, int) method. |
boolean |
removeTarget(java.net.InetAddress remoteAddr,
int remotePort)
Remove a target from stream targets list
|
void |
removeTargets()
Remove all stream targets from this session.
|
protected abstract void |
sendToTarget(RawPacket packet,
java.net.InetSocketAddress target)
Sends a specific RawPacket through this
OutputDataStream to a specific InetSocketAddress.
|
void |
setEnabled(boolean enabled)
Enables or disables this RTPConnectorOutputStream.
|
boolean |
setMaxPacketsPerMillis(int maxPackets,
long perMillis)
Sets the maximum number of RTP packets to be sent by this
OutputDataStream through its DatagramSocket per
a specific number of milliseconds.
|
void |
setPriority(int priority)
Changes current thread priority.
|
int |
syncWrite(byte[] buf,
int off,
int len)
Writes a byte[] to this
RTPConnectorOutputStream synchronously (
even when USE_SEND_THREAD is enabled). |
int |
write(byte[] buf,
int off,
int len)
Implements
OutputDataStream.write(byte[], int, int) . |
protected int |
write(byte[] buf,
int off,
int len,
java.lang.Object context)
Implements
OutputDataStream.write(byte[], int, int) . |
public static final int PACKET_QUEUE_CAPACITY
RTPConnectorOutputStream
. When the maximum is reached, the next
attempt to write a new packet in the queue will result in the first
packet in the queue being dropped.
Defined in order to prevent OutOfMemoryErrors which may arise if
the capacity of the queue is unlimited.public static final int POOL_CAPACITY
protected final java.util.List<java.net.InetSocketAddress> targets
public RTPConnectorOutputStream()
public static boolean logDroppedPacket(int numDroppedPackets)
numDroppedPackets
packets.numDroppedPackets
- the number of dropped packets.true
if a warning should be logged.static boolean logPacket(long numOfPacket)
PacketLoggingService
.numOfPacket
- the number of the RawPacket in the total
number of sent RawPacketspublic void addTarget(java.net.InetAddress remoteAddr, int remotePort)
remoteAddr
- target ip addressremotePort
- target portpublic void close()
protected RawPacket[] packetize(byte[] buf, int off, int len, java.lang.Object context)
write(byte[], int, int)
method. Returns an array of one or more
elements, with the created RawPacket as its first element (and
null for all other elements)
Allows extenders to intercept the array and possibly filter and/or
modify it.buf
- the packet data to be sent to the targets of this instance.
The contents of buf
starting at off
with the specified
len
is copied into the buffer of the returned RawPacket
.off
- the offset of the packet data in buflen
- the length of the packet data in bufcontext
- the Object
provided to
write(byte[], int, int, java.lang.Object)
. The implementation of
RTPConnectorOutputStream
ignores the context
.protected abstract void doLogPacket(RawPacket packet, java.net.InetSocketAddress target)
packet
- packet to logtarget
- the remote address associated with the packetpublic long getNumberOfBytesSent()
protected PacketLoggingService getPacketLoggingService()
PacketLoggingService
(to be) utilized by this instance.PacketLoggingService
(to be) utilized by this
instanceprotected abstract boolean isSocketValid()
public boolean removeTarget(java.net.InetAddress remoteAddr, int remotePort)
remoteAddr
- target ip addressremotePort
- target portpublic void removeTargets()
protected abstract void sendToTarget(RawPacket packet, java.net.InetSocketAddress target) throws java.io.IOException
packet
- the RawPacket to send through this
OutputDataStream to the specified targettarget
- the InetSocketAddress to which the specified
packet is to be sent through this OutputDataStreamjava.io.IOException
- if anything goes wrong while sending the specified
packet through this OutputDataStream to the specified
targetpublic void setEnabled(boolean enabled)
send(RawPacket)
.enabled
- true to enable, false to disable.public boolean setMaxPacketsPerMillis(int maxPackets, long perMillis)
maxPackets
- the maximum number of RTP packets to be sent by this
OutputDataStream through its DatagramSocket per the
specified number of milliseconds; -1 if no maximum is to be setperMillis
- the number of milliseconds per which maxPackets
are to be sent by this OutputDataStream through its
DatagramSocketpublic void setPriority(int priority)
priority
- the new priority.public int write(byte[] buf, int off, int len)
OutputDataStream.write(byte[], int, int)
.write
in interface javax.media.rtp.OutputDataStream
buf
- the byte[]
to write into this OutputDataStream
off
- the offset in buf
at which the byte
s to be
written into this OutputDataStream
startlen
- the number of byte
s in buf
starting at
off
to be written into this OutputDataStream
byte
s read from buf
starting at
off
and not exceeding len
and written into this
OutputDataStream
public int syncWrite(byte[] buf, int off, int len)
RTPConnectorOutputStream
synchronously (
even when USE_SEND_THREAD
is enabled).buf
- off
- len
- protected int write(byte[] buf, int off, int len, java.lang.Object context)
OutputDataStream.write(byte[], int, int)
. Allows
extenders to provide a context Object
to invoked overridable
methods such as packetize(byte[],int,int,Object)
.buf
- the byte[]
to write into this OutputDataStream
off
- the offset in buf
at which the byte
s to be
written into this OutputDataStream
startlen
- the number of byte
s in buf
starting at
off
to be written into this OutputDataStream
context
- the Object
to provide to invoked overridable
methods such as packetize(byte[],int,int,Object)
byte
s read from buf
starting at
off
and not exceeding len
and written into this
OutputDataStream
public long getOutputBitrate()
public long getOutputBitrate(long now)
now
- the current time.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.