- inheritance works by calling the functions of the parent when creating/copying/freeing an object
- type recognition is done by the type field in the class struct
- memory allocation is specific to the struct.
Refcounting
-----------
GstData provides threadsafe refcounting. If you create a new object - either by copying or explicit creation - the refcount is initialized to 1.
This reference is owned by the creator of the object.
If the reference count reaches 0, the object is freed. The free function of the class is called for that purpose.
In accordance with GLib, that uses g_object_(un)ref for everything, gst_data_(un)ref is used and no wrapper macros are created.
MT safety
---------
Manipulating data inside an object is not threadsafe unless otherwise noted.
If an object has a reference count of 1 it is assumed that the reference holder is the only user of that object and he may modify it the way he likes.
If the reference count is greater than 1, the object may not be modified. If you need to modify it, you have to copy the object and use that copy instead.
NB: Object creation and refcounting are threadsafe - or must be implemented that way.
Flags
-----
Flags work and can be used like the GstObject flags.
GstData defines only one flag: GST_DATA_READONLY. If this flag is set, you are not allowed to modify the contents of a struct, even if the refcount is 1.
GBoxed
------
GstInstream
===========
GstInstream is the base class for events and buffers that are passed inside the stream.
It enhances the GstData struct by
guint64 offset[GST_OFFSET_TYPES];
This field describes the offset in the current stream in various different ways:
GST_OFFSET_BYTES: The number of bytes from the beginning of the stream.
GST_OFFSET_TIME: The timestamp in microseconds. The beginning of the stream equals timestamp 0. In buffers the timestamp should match the beginning of the data.
GST_OFFSET_FRAMES: This type is specific to the stream and should be defined there. (video will probably use it for frame numbers, audio to count samples)
If an offset can't be specified, it is set to GST_OFFSET_INVALID, which equals (guint64) -1. The byte offset always has to be specified. It is an error if it is invalid.
A plugin playing data from an "infinite" source (eg a shoutcast stream from the internet) it should start with byteoffset 0.
GstBuffer
=========
The buffer enhances the GstInstream struct by including a data and a size field.
Memory allocation
-----------------
Memory is allocated via a special memchunk implementation, that is threadsafe. The default implementation uses a mutex and GMemChunks.
FIXME: This is not true, we use g_malloc/g_free for now.
GstBufferClass
--------------
GstBufferClasses (note the plural) replace bufferpools. The default class uses g_free/g_malloc for storing data. However, you are free to write your own if
you need buffers that store data in another way.
Note however that the copy function needs to supply a writable copy of your buffer.
Subbuffers
----------
Subbuffers have been replaced by a special kind of GstBufferClass.
Instream events
===============
GstEventNewMedia
----------------
Signals the start of a new stream. This must be send before any buffer of a new stream can be send.
FIXME: The "must be send" can only be enforced if all elements are event aware. And this is necessary if we don't want to get parts of stream 1 inside stream 2.
GstEventDiscontinuous
---------------------
This must be send between buffers, that don't have continuous data. This is necessary for example after seeking or when data is dropped for speed.
GstEventEOS
-----------
Signals the end of a stream. Must be send after all data is finished. If you want to start a new stream, don't send this event, send a GstEventNewMedia instead.
After having processed this event, elements in the pipeline switch their state to paused.