public abstract class RTPConnectorInputStream<T>
extends java.lang.Object
implements javax.media.protocol.PushSourceStream
Modifier and Type | Field and Description |
---|---|
static int |
PACKET_RECEIVE_BUFFER_LENGTH
The length in bytes of the buffers of RTPConnectorInputStream
receiving packets from the network.
|
protected T |
socket |
Modifier | Constructor and Description |
---|---|
protected |
RTPConnectorInputStream(T socket)
Initializes a new RTPConnectorInputStream which is to receive
packet data from a specific UDP socket.
|
Modifier and Type | Method and Description |
---|---|
void |
addDatagramPacketFilter(org.ice4j.socket.DatagramPacketFilter datagramPacketFilter)
Adds a DatagramPacketFilter which allows dropping
DatagramPackets before they are converted into
RawPackets.
|
void |
close()
Close this stream, stops the worker thread.
|
protected RawPacket[] |
createRawPacket(java.net.DatagramPacket datagramPacket)
Creates a new RawPacket from a specific DatagramPacket
in order to have this instance receive its packet data through its
read(byte[], int, int) method. |
protected abstract void |
doLogPacket(java.net.DatagramPacket packet)
Log the packet.
|
boolean |
endOfStream()
Provides a dummy implementation of
SourceStream.endOfStream() that always returns
false. |
javax.media.protocol.ContentDescriptor |
getContentDescriptor()
Provides a dummy implementation of
SourceStream.getContentDescriptor() that always returns
null. |
long |
getContentLength()
Provides a dummy implementation of
SourceStream.getContentLength() that always returns
LENGTH_UNKNOWN. |
java.lang.Object |
getControl(java.lang.String controlType)
Provides a dummy implementation of
Controls.getControl(String) that always returns
null. |
java.lang.Object[] |
getControls()
Provides a dummy implementation of
Controls.getControls() that always returns
EMPTY_CONTROLS. |
protected org.ice4j.socket.DatagramPacketFilter[] |
getDatagramPacketFilters()
Gets the DatagramPacketFilters which allow dropping
DatagramPackets before they are converted into
RawPackets.
|
int |
getMinimumTransferSize()
Provides a dummy implementation of
PushSourceStream.getMinimumTransferSize() that always returns
2 * 1024. |
long |
getNumberOfReceivedBytes()
Returns the number of received bytes for the stream.
|
protected PacketLoggingService |
getPacketLoggingService()
Gets the
PacketLoggingService (to be) utilized by this instance. |
protected int |
read(javax.media.Buffer buffer,
byte[] data,
int offset,
int length)
Copies the content of the most recently received packet into
data.
|
int |
read(byte[] buffer,
int offset,
int length)
Copies the content of the most recently received packet into
buffer.
|
protected abstract void |
receive(java.net.DatagramPacket p)
Receive packet.
|
void |
setEnabled(boolean enabled)
Enables or disables this RTPConnectorInputStream.
|
void |
setPriority(int priority)
Changes current thread priority.
|
protected abstract void |
setReceiveBufferSize(int receiveBufferSize) |
static void |
setThreadPriority(java.lang.Thread thread,
int priority)
Sets a specific priority on a specific Thread.
|
void |
setTransferHandler(javax.media.protocol.SourceTransferHandler transferHandler)
Sets the transferHandler that this connector should be notifying
when new data is available for reading.
|
public static final int PACKET_RECEIVE_BUFFER_LENGTH
protected final T socket
protected RTPConnectorInputStream(T socket)
socket
- public static void setThreadPriority(java.lang.Thread thread, int priority)
thread
- the Thread to set the specified priority
onpriority
- the priority to set on the specified threadpublic void addDatagramPacketFilter(org.ice4j.socket.DatagramPacketFilter datagramPacketFilter)
datagramPacketFilter
- the DatagramPacketFilter which
allows dropping DatagramPackets before they are converted into
RawPacketspublic void close()
protected RawPacket[] createRawPacket(java.net.DatagramPacket datagramPacket)
read(byte[], int, int)
method. Returns an array of
RawPacket with the created packet as its first element (and
null for the other elements).
Allows extenders to intercept the packet data and possibly filter and/or
modify it.datagramPacket
- the DatagramPacket containing the packet
dataprotected abstract void doLogPacket(java.net.DatagramPacket packet)
packet
- packet to logpublic boolean endOfStream()
SourceStream.endOfStream()
that always returns
false.endOfStream
in interface javax.media.protocol.SourceStream
public javax.media.protocol.ContentDescriptor getContentDescriptor()
SourceStream.getContentDescriptor()
that always returns
null.getContentDescriptor
in interface javax.media.protocol.SourceStream
public long getContentLength()
SourceStream.getContentLength()
that always returns
LENGTH_UNKNOWN.getContentLength
in interface javax.media.protocol.SourceStream
public java.lang.Object getControl(java.lang.String controlType)
Controls.getControl(String)
that always returns
null.getControl
in interface javax.media.Controls
controlType
- ignored.public java.lang.Object[] getControls()
Controls.getControls()
that always returns
EMPTY_CONTROLS.getControls
in interface javax.media.Controls
protected org.ice4j.socket.DatagramPacketFilter[] getDatagramPacketFilters()
public int getMinimumTransferSize()
PushSourceStream.getMinimumTransferSize()
that always returns
2 * 1024.getMinimumTransferSize
in interface javax.media.protocol.PushSourceStream
public long getNumberOfReceivedBytes()
protected PacketLoggingService getPacketLoggingService()
PacketLoggingService
(to be) utilized by this instance.PacketLoggingService
(to be) utilized by this
instanceprotected int read(javax.media.Buffer buffer, byte[] data, int offset, int length) throws java.io.IOException
buffer
- an optional Buffer instance associated with the
specified data, offset and length and
provided to the method in case the implementation would like to provide
additional Buffer properties such as flagsdata
- the byte[] that we'd like to copy the content of
the packet to.offset
- the position where we are supposed to start writing in
data.length
- the number of bytes available for writing in
data.java.io.IOException
- if length is less than the size of the
packet.public int read(byte[] buffer, int offset, int length) throws java.io.IOException
read
in interface javax.media.protocol.PushSourceStream
buffer
- the byte[] that we'd like to copy the content of
the packet to.offset
- the position where we are supposed to start writing in
buffer.length
- the number of bytes available for writing in
buffer.java.io.IOException
- if length is less than the size of the
packet.protected abstract void receive(java.net.DatagramPacket p) throws java.io.IOException
p
- packet for receivingjava.io.IOException
- if something goes wrong during receivingpublic void setEnabled(boolean enabled)
enabled
- true to enable, false to disable.public void setPriority(int priority)
priority
- the new priority.protected abstract void setReceiveBufferSize(int receiveBufferSize) throws java.io.IOException
java.io.IOException
public void setTransferHandler(javax.media.protocol.SourceTransferHandler transferHandler)
setTransferHandler
in interface javax.media.protocol.PushSourceStream
transferHandler
- the transferHandler that this connector
should be notifying when new data is available for reading.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.