Circular memory buffer for a link, transport, application or user layer frame management, with 2 pointers
A buffer can be described by following properties:
limit - 1
. Accessing elements out of the scope will cause exception. Limit is no less than zero and no greater than capacity.ReadOnlyBufferException
, while changing the position, limit and mark of a readonly buffer is OK.Buffers are not thread-safe. If concurrent access to a buffer instance is required, then the callers are responsible to take care of the synchronization issues.
java.nio.ByteBuffer
. Advantage:
Buffers are not safe for use by multiple concurrent threads. If a buffer is to be used by more than one thread then access to the buffer should be controlled by appropriate synchronization. @author Roger Chen @version $id$
The removal order can be based on insertion order (eg, a FIFO queue or a LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator (eg, a priority queue) or on any other well-defined ordering.
Note that the removal order is not necessarily the same as the iteration order. A Buffer
implementation may have equivalent removal and iteration orders, but this is not required.
This interface does not specify any behavior for {@link Object#equals(Object)} and {@link Object#hashCode} methods. Itis therefore possible for a Buffer
implementation to also also implement {@link java.util.List}, {@link java.util.Set} or {@link Bag}.
@since Commons Collections 2.1
@version $Revision: 1.10 $ $Date: 2004/02/18 01:15:42 $
@author Avalon
@author Berin Loritsch
@author Paul Jack
@author Stephen Colebourne
Buffer
implementation may have equivalent removal and iteration orders, but this is not required. This interface does not specify any behavior for {@link Object#equals(Object)} and {@link Object#hashCode} methods. Itis therefore possible for a Buffer
implementation to also also implement {@link java.util.List}, {@link java.util.Set} or{@link Bag}.
@author Avalon
@author Berin Loritsch
@author Paul Jack
@author Matt Hall, John Watkinson, Stephen Colebourne
@version $Revision: 1.1 $ $Date: 2005/10/11 17:05:19 $
@since Commons Collections 2.1
Buffer
represents the contents of an open text file as it is maintained in the computer's memory (as opposed to how it may be stored on a disk). In a BeanShell script, you can obtain the current buffer instance from the buffer
variable.
This class does not have a public constructor. Buffers can be opened and closed using methods in the jEdit
class.
This class is partially thread-safe, however you must pay attention to two very important guidelines:
Buffers are the basic unit of data transfer in GStreamer. The Buffer type provides all the state necessary to define a region of memory as part of a stream. Sub-buffers are also supported, allowing a smaller region of a buffer to become its own buffer, with mechanisms in place to ensure that neither memory space goes away prematurely.
Non-plugins will usually not need to allocate buffers, but they can be allocated using new {@link #Buffer(int)} to create a buffer with preallocated data of a given size.
The data pointed to by the buffer can be accessed with the {@link #getByteBuffer}method. For buffers of size 0, the data pointer is undefined (usually NULL) and should never be used.
If an element knows what pad you will push the buffer out on, it should use gst_pad_alloc_buffer() instead to create a buffer. This allows downstream elements to provide special buffers to write in, like hardware buffers.
A buffer has a pointer to a {@link Caps} describing the media type of the datain the buffer. Attach caps to the buffer with {@link #setCaps}; this is typically done before pushing out a buffer using gst_pad_push() so that the downstream element knows the type of the buffer.
A buffer will usually have a timestamp, and a duration, but neither of these are guaranteed (they may be set to -1). Whenever a meaningful value can be given for these, they should be set. The timestamp and duration are measured in nanoseconds (they are long values).
A buffer can also have one or both of a start and an end offset. These are media-type specific. For video buffers, the start offset will generally be the frame number. For audio buffers, it will be the number of samples produced so far. For compressed data, it could be the byte offset in a source or destination file. Likewise, the end offset will be the offset of the end of the buffer. These can only be meaningfully interpreted if you know the media type of the buffer (the #GstCaps set on it). Either or both can be set to -1.
To efficiently create a smaller buffer out of an existing one, you can use {@link #createSubBuffer}.
If a plug-in wants to modify the buffer data in-place, it should first obtain a buffer that is safe to modify by using {@link #makeWritable}. This function is optimized so that a copy will only be made when it is necessary.
A plugin that only wishes to modify the metadata of a buffer, such as the offset, timestamp or caps, should use gst_buffer_make_metadata_writable(), which will create a subbuffer of the original buffer to ensure the caller has sole ownership, and not copy the buffer data.
Buffers can be efficiently merged into a larger buffer with gst_buffer_merge() and gst_buffer_span() if the gst_buffer_is_span_fast() function returns TRUE.
This is a pretty standard buffer in terms of everything else. I've used it extensively and have complete confidence in it. @author iago
The buffer can begin initially as a wrapped {@link LuaValue} and only when concatenation actually occurs are the bytes first copied.
To convert back to a {@link LuaValue} again, the function {@link Buffer#value()} is used. @see LuaValue @see LuaValue#buffer() @see LuaString
Buffer
interface represents a collection of bytes that can be written to and later read. This is used to provide a region of memory is such a way that the underlying representation of that memory is independent of its use. Typically buffers are implemented as either allocated byte arrays or files.
@author Niall Gallagher
@see org.simpleframework.util.buffer.Allocator
RFC 4253 - The Secure Shell (SSH) Transport Layer Protocol: Binary Packet Protocol
Note: This class is not thread-safe and must be externally synchronized.
@see org.vngx.jsch.Packet @author Michael LaudatiThis is a pretty standard buffer in terms of everything else. I've used it extensively and have complete confidence in it. @author Ron
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|