public abstract class RTPConnectorOutputStream extends 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 List<InetSocketAddress> |
targets
Stream targets' IP addresses and ports.
|
| Modifier | Constructor and Description |
|---|---|
protected |
RTPConnectorOutputStream()
Initializes a new RTPConnectorOutputStream which is to send
packet data out through a specific socket.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTarget(InetAddress remoteAddr,
int remotePort)
Add a target to stream targets list
|
void |
close()
Close this output stream.
|
protected abstract void |
doLogPacket(RawPacket packet,
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. |
protected RawPacket[] |
packetize(byte[] buf,
int off,
int len,
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(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,
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,
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 List<InetSocketAddress> targets
protected RTPConnectorOutputStream()
public static boolean logDroppedPacket(int numDroppedPackets)
numDroppedPackets packets.numDroppedPackets - the number of dropped packets.true if a warning should be logged.public void addTarget(InetAddress remoteAddr, int remotePort)
remoteAddr - target ip addressremotePort - target portpublic void close()
protected RawPacket[] packetize(byte[] buf, int off, int len, 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, 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(InetAddress remoteAddr, int remotePort)
remoteAddr - target ip addressremotePort - target portpublic void removeTargets()
protected abstract void sendToTarget(RawPacket packet, InetSocketAddress target) throws 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 OutputDataStreamIOException - 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.OutputDataStreambuf - the byte[] to write into this OutputDataStreamoff - the offset in buf at which the bytes to be
written into this OutputDataStream startlen - the number of bytes in buf starting at
off to be written into this OutputDataStreambytes read from buf starting at
off and not exceeding len and written into this
OutputDataStreampublic int syncWrite(byte[] buf,
int off,
int len)
RTPConnectorOutputStream synchronously (
even when USE_SEND_THREAD is enabled).protected int write(byte[] buf,
int off,
int len,
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 OutputDataStreamoff - the offset in buf at which the bytes to be
written into this OutputDataStream startlen - the number of bytes in buf starting at
off to be written into this OutputDataStreamcontext - the Object to provide to invoked overridable
methods such as packetize(byte[],int,int,Object)bytes read from buf starting at
off and not exceeding len and written into this
OutputDataStreampublic long getOutputBitrate()
public long getOutputBitrate(long now)
now - the current time.Copyright © 2021 jitsi.org. All rights reserved.