Added initial gstreamer audio playback.

x86 might not work due to misconfiguration because I could not test it since acinerella is broken in x86 currenty. Gstreamer video support is yet to follow.
Please report back any bugs you experience. To compile you will need Visual C++, I hope all files are included
This commit is contained in:
Stephan Sundermann committed 2013-02-09 23:32:02 +01:00
1 parent 8a11b0eff0
commit e653ac87a2
1326 files changed
+154559 -4

No files matched your search

@@ -0,0 +1,77 @@
/* GStreamer
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/gst.h>
#ifndef __GST_ADAPTER_H__
#define __GST_ADAPTER_H__
G_BEGIN_DECLS
#define GST_TYPE_ADAPTER \
(gst_adapter_get_type())
#define GST_ADAPTER(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_ADAPTER, GstAdapter))
#define GST_ADAPTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_ADAPTER, GstAdapterClass))
#define GST_ADAPTER_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_ADAPTER, GstAdapterClass))
#define GST_IS_ADAPTER(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_ADAPTER))
#define GST_IS_ADAPTER_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_ADAPTER))
/**
* GstAdapter:
*
* The opaque #GstAdapter data structure.
*/
typedef struct _GstAdapter GstAdapter;
typedef struct _GstAdapterClass GstAdapterClass;
GType gst_adapter_get_type (void);
GstAdapter * gst_adapter_new (void) G_GNUC_MALLOC;
void gst_adapter_clear (GstAdapter *adapter);
void gst_adapter_push (GstAdapter *adapter, GstBuffer* buf);
gconstpointer gst_adapter_map (GstAdapter *adapter, gsize size);
void gst_adapter_unmap (GstAdapter *adapter);
void gst_adapter_copy (GstAdapter *adapter, gpointer dest,
gsize offset, gsize size);
void gst_adapter_flush (GstAdapter *adapter, gsize flush);
gpointer gst_adapter_take (GstAdapter *adapter, gsize nbytes);
GstBuffer* gst_adapter_take_buffer (GstAdapter *adapter, gsize nbytes);
GList* gst_adapter_take_list (GstAdapter *adapter, gsize nbytes);
gsize gst_adapter_available (GstAdapter *adapter);
gsize gst_adapter_available_fast (GstAdapter *adapter);
GstClockTime gst_adapter_prev_pts (GstAdapter *adapter, guint64 *distance);
GstClockTime gst_adapter_prev_dts (GstAdapter *adapter, guint64 *distance);
gsize gst_adapter_masked_scan_uint32 (GstAdapter * adapter, guint32 mask,
guint32 pattern, gsize offset, gsize size);
gsize gst_adapter_masked_scan_uint32_peek (GstAdapter * adapter, guint32 mask,
guint32 pattern, gsize offset, gsize size, guint32 * value);
G_END_DECLS
#endif /* __GST_ADAPTER_H__ */
@@ -0,0 +1,329 @@
/* GStreamer
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
*
* Contact: Stefan Kost <stefan.kost@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BASE_PARSE_H__
#define __GST_BASE_PARSE_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_BASE_PARSE (gst_base_parse_get_type())
#define GST_BASE_PARSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_PARSE,GstBaseParse))
#define GST_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_PARSE,GstBaseParseClass))
#define GST_BASE_PARSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_PARSE,GstBaseParseClass))
#define GST_IS_BASE_PARSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_PARSE))
#define GST_IS_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_PARSE))
#define GST_BASE_PARSE_CAST(obj) ((GstBaseParse *)(obj))
/**
* GST_BASE_PARSE_SRC_PAD:
* @obj: base parse instance
*
* Gives the pointer to the source #GstPad object of the element.
*/
#define GST_BASE_PARSE_SRC_PAD(obj) (GST_BASE_PARSE_CAST (obj)->srcpad)
/**
* GST_BASE_PARSE_SINK_PAD:
* @obj: base parse instance
*
* Gives the pointer to the sink #GstPad object of the element.
*/
#define GST_BASE_PARSE_SINK_PAD(obj) (GST_BASE_PARSE_CAST (obj)->sinkpad)
/**
* GST_BASE_PARSE_FLOW_DROPPED:
*
* A #GstFlowReturn that can be returned from parse_frame to
* indicate that no output buffer was generated, or from pre_push_frame to
* to forego pushing buffer.
*/
#define GST_BASE_PARSE_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS
/* not public API, use accessor macros below */
#define GST_BASE_PARSE_FLAG_LOST_SYNC (1 << 0)
#define GST_BASE_PARSE_FLAG_DRAINING (1 << 1)
/**
* GST_BASE_PARSE_LOST_SYNC:
* @parse: base parse instance
*
* Obtains current sync status.
*/
#define GST_BASE_PARSE_LOST_SYNC(parse) (!!(GST_BASE_PARSE_CAST(parse)->flags & GST_BASE_PARSE_FLAG_LOST_SYNC))
/**
* GST_BASE_PARSE_DRAINING:
* @parse: base parse instance
*
* Obtains current drain status (ie. whether EOS has been received and
* the parser is now processing the frames at the end of the stream)
*/
#define GST_BASE_PARSE_DRAINING(parse) (!!(GST_BASE_PARSE_CAST(parse)->flags & GST_BASE_PARSE_FLAG_DRAINING))
/**
* GstBaseParseFrameFlags:
* @GST_BASE_PARSE_FRAME_FLAG_NONE: no flag
* @GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME: set by baseclass if current frame
* is passed for processing to the subclass for the first time
* (and not set on subsequent calls with same data).
* @GST_BASE_PARSE_FRAME_FLAG_NO_FRAME: set to indicate this buffer should not be
* counted as frame, e.g. if this frame is dependent on a previous one.
* As it is not counted as a frame, bitrate increases but frame to time
* conversions are maintained.
* @GST_BASE_PARSE_FRAME_FLAG_CLIP: @pre_push_frame can set this to indicate
* that regular segment clipping can still be performed (as opposed to
* any custom one having been done).
* @GST_BASE_PARSE_FRAME_FLAG_DROP: indicates to @finish_frame that the
* the frame should be dropped (and might be handled internall by subclass)
* @GST_BASE_PARSE_FRAME_FLAG_QUEUE: indicates to @finish_frame that the
* the frame should be queued for now and processed fully later
* when the first non-queued frame is finished
*
* Flags to be used in a #GstBaseParseFrame.
*/
typedef enum {
GST_BASE_PARSE_FRAME_FLAG_NONE = 0,
GST_BASE_PARSE_FRAME_FLAG_NEW_FRAME = (1 << 0),
GST_BASE_PARSE_FRAME_FLAG_NO_FRAME = (1 << 1),
GST_BASE_PARSE_FRAME_FLAG_CLIP = (1 << 2),
GST_BASE_PARSE_FRAME_FLAG_DROP = (1 << 3),
GST_BASE_PARSE_FRAME_FLAG_QUEUE = (1 << 4)
} GstBaseParseFrameFlags;
/**
* GstBaseParseFrame:
* @buffer: input data to be parsed for frames.
* @out_buffer: (optional) (replacement) output data.
* @offset: media specific offset of input frame
* Note that a converter may have a different one on the frame's buffer.
* @overhead: subclass can set this to indicates the metadata overhead
* for the given frame, which is then used to enable more accurate bitrate
* computations. If this is -1, it is assumed that this frame should be
* skipped in bitrate calculation.
* @flags: a combination of input and output #GstBaseParseFrameFlags that
* convey additional context to subclass or allow subclass to tune
* subsequent #GstBaseParse actions.
*
* Frame (context) data passed to each frame parsing virtual methods. In
* addition to providing the data to be checked for a valid frame or an already
* identified frame, it conveys additional metadata or control information
* from and to the subclass w.r.t. the particular frame in question (rather
* than global parameters). Some of these may apply to each parsing stage, others
* only to some a particular one. These parameters are effectively zeroed at start
* of each frame's processing, i.e. parsing virtual method invocation sequence.
*/
typedef struct {
GstBuffer * buffer;
GstBuffer * out_buffer;
guint flags;
guint64 offset;
gint overhead;
/*< private >*/
gint size;
guint _gst_reserved_i[2];
gpointer _gst_reserved_p[2];
guint _private_flags;
} GstBaseParseFrame;
typedef struct _GstBaseParse GstBaseParse;
typedef struct _GstBaseParseClass GstBaseParseClass;
typedef struct _GstBaseParsePrivate GstBaseParsePrivate;
/**
* GstBaseParse:
* @element: the parent element.
*
* The opaque #GstBaseParse data structure.
*/
struct _GstBaseParse {
GstElement element;
/*< protected >*/
/* source and sink pads */
GstPad *sinkpad;
GstPad *srcpad;
guint flags;
/* MT-protected (with STREAM_LOCK) */
GstSegment segment;
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
GstBaseParsePrivate *priv;
};
/**
* GstBaseParseClass:
* @parent_class: the parent class
* @start: Optional.
* Called when the element starts processing.
* Allows opening external resources.
* @stop: Optional.
* Called when the element stops processing.
* Allows closing external resources.
* @set_sink_caps: allows the subclass to be notified of the actual caps set.
* @get_sink_caps: allows the subclass to do its own sink get caps if needed.
* @handle_frame: Parses the input data into valid frames as defined by subclass
* which should be passed to gst_base_parse_finish_frame().
* The frame's input buffer is guaranteed writable,
* whereas the input frame ownership is held by caller
* (so subclass should make a copy if it needs to hang on).
* Input buffer (data) is provided by baseclass with as much
* metadata set as possible by baseclass according to upstream
* information and/or subclass settings,
* though subclass may still set buffer timestamp and duration
* if desired.
* @convert: Optional.
* Convert between formats.
* @sink_event: Optional.
* Event handler on the sink pad. This function should chain
* up to the parent implementation to let the default handler
* run.
* @src_event: Optional.
* Event handler on the source pad. Should chain up to the
* parent to let the default handler run.
* @pre_push_frame: Optional.
* Called just prior to pushing a frame (after any pending
* events have been sent) to give subclass a chance to perform
* additional actions at this time (e.g. tag sending) or to
* decide whether this buffer should be dropped or not
* (e.g. custom segment clipping).
* @detect: Optional.
* Called until it doesn't return GST_FLOW_OK anymore for
* the first buffers. Can be used by the subclass to detect
* the stream format.
*
* Subclasses can override any of the available virtual methods or not, as
* needed. At minimum @check_valid_frame and @parse_frame needs to be
* overridden.
*/
struct _GstBaseParseClass {
GstElementClass parent_class;
/*< public >*/
/* virtual methods for subclasses */
gboolean (*start) (GstBaseParse * parse);
gboolean (*stop) (GstBaseParse * parse);
gboolean (*set_sink_caps) (GstBaseParse * parse,
GstCaps * caps);
GstFlowReturn (*handle_frame) (GstBaseParse * parse,
GstBaseParseFrame * frame,
gint * skipsize);
GstFlowReturn (*pre_push_frame) (GstBaseParse * parse,
GstBaseParseFrame * frame);
gboolean (*convert) (GstBaseParse * parse,
GstFormat src_format,
gint64 src_value,
GstFormat dest_format,
gint64 * dest_value);
gboolean (*sink_event) (GstBaseParse * parse,
GstEvent * event);
gboolean (*src_event) (GstBaseParse * parse,
GstEvent * event);
GstCaps * (*get_sink_caps) (GstBaseParse * parse,
GstCaps * filter);
GstFlowReturn (*detect) (GstBaseParse * parse,
GstBuffer * buffer);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GType gst_base_parse_get_type (void);
GType gst_base_parse_frame_get_type (void);
GstBaseParseFrame * gst_base_parse_frame_new (GstBuffer * buffer,
GstBaseParseFrameFlags flags,
gint overhead);
void gst_base_parse_frame_init (GstBaseParseFrame * frame);
void gst_base_parse_frame_free (GstBaseParseFrame * frame);
GstFlowReturn gst_base_parse_push_frame (GstBaseParse * parse,
GstBaseParseFrame * frame);
GstFlowReturn gst_base_parse_finish_frame (GstBaseParse * parse,
GstBaseParseFrame * frame,
gint size);
void gst_base_parse_set_duration (GstBaseParse * parse,
GstFormat fmt,
gint64 duration,
gint interval);
void gst_base_parse_set_average_bitrate (GstBaseParse * parse,
guint bitrate);
void gst_base_parse_set_min_frame_size (GstBaseParse * parse,
guint min_size);
void gst_base_parse_set_has_timing_info (GstBaseParse * parse,
gboolean has_timing);
void gst_base_parse_set_syncable (GstBaseParse * parse,
gboolean syncable);
void gst_base_parse_set_passthrough (GstBaseParse * parse,
gboolean passthrough);
void gst_base_parse_set_pts_interpolation (GstBaseParse * parse,
gboolean pts_interpolate);
void gst_base_parse_set_frame_rate (GstBaseParse * parse,
guint fps_num,
guint fps_den,
guint lead_in,
guint lead_out);
void gst_base_parse_set_latency (GstBaseParse * parse,
GstClockTime min_latency,
GstClockTime max_latency);
gboolean gst_base_parse_convert_default (GstBaseParse * parse,
GstFormat src_format,
gint64 src_value,
GstFormat dest_format,
gint64 * dest_value);
gboolean gst_base_parse_add_index_entry (GstBaseParse * parse,
guint64 offset,
GstClockTime ts,
gboolean key,
gboolean force);
G_END_DECLS
#endif /* __GST_BASE_PARSE_H__ */
@@ -0,0 +1,255 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
*
* gstbasesink.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BASE_SINK_H__
#define __GST_BASE_SINK_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_BASE_SINK (gst_base_sink_get_type())
#define GST_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SINK,GstBaseSink))
#define GST_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SINK,GstBaseSinkClass))
#define GST_BASE_SINK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SINK, GstBaseSinkClass))
#define GST_IS_BASE_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SINK))
#define GST_IS_BASE_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SINK))
#define GST_BASE_SINK_CAST(obj) ((GstBaseSink *) (obj))
/**
* GST_BASE_SINK_PAD:
* @obj: base sink instance
*
* Gives the pointer to the #GstPad object of the element.
*/
#define GST_BASE_SINK_PAD(obj) (GST_BASE_SINK_CAST (obj)->sinkpad)
#define GST_BASE_SINK_GET_PREROLL_LOCK(pad) (&GST_BASE_SINK_CAST(pad)->preroll_lock)
#define GST_BASE_SINK_PREROLL_LOCK(pad) (g_mutex_lock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
#define GST_BASE_SINK_PREROLL_TRYLOCK(pad) (g_mutex_trylock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
#define GST_BASE_SINK_PREROLL_UNLOCK(pad) (g_mutex_unlock(GST_BASE_SINK_GET_PREROLL_LOCK(pad)))
#define GST_BASE_SINK_GET_PREROLL_COND(pad) (&GST_BASE_SINK_CAST(pad)->preroll_cond)
#define GST_BASE_SINK_PREROLL_WAIT(pad) \
g_cond_wait (GST_BASE_SINK_GET_PREROLL_COND (pad), GST_BASE_SINK_GET_PREROLL_LOCK (pad))
#define GST_BASE_SINK_PREROLL_WAIT_UNTIL(pad, end_time) \
g_cond_wait_until (GST_BASE_SINK_GET_PREROLL_COND (pad), GST_BASE_SINK_GET_PREROLL_LOCK (pad), end_time)
#define GST_BASE_SINK_PREROLL_SIGNAL(pad) g_cond_signal (GST_BASE_SINK_GET_PREROLL_COND (pad));
#define GST_BASE_SINK_PREROLL_BROADCAST(pad) g_cond_broadcast (GST_BASE_SINK_GET_PREROLL_COND (pad));
typedef struct _GstBaseSink GstBaseSink;
typedef struct _GstBaseSinkClass GstBaseSinkClass;
typedef struct _GstBaseSinkPrivate GstBaseSinkPrivate;
/**
* GstBaseSink:
*
* The opaque #GstBaseSink data structure.
*/
struct _GstBaseSink {
GstElement element;
/*< protected >*/
GstPad *sinkpad;
GstPadMode pad_mode;
/*< protected >*/ /* with LOCK */
guint64 offset;
gboolean can_activate_pull;
gboolean can_activate_push;
/*< protected >*/ /* with PREROLL_LOCK */
GMutex preroll_lock;
GCond preroll_cond;
gboolean eos;
gboolean need_preroll;
gboolean have_preroll;
gboolean playing_async;
/*< protected >*/ /* with STREAM_LOCK */
gboolean have_newsegment;
GstSegment segment;
/*< private >*/ /* with LOCK */
GstClockID clock_id;
gboolean sync;
gboolean flushing;
gboolean running;
gint64 max_lateness;
/*< private >*/
GstBaseSinkPrivate *priv;
gpointer _gst_reserved[GST_PADDING_LARGE];
};
/**
* GstBaseSinkClass:
* @parent_class: Element parent class
* @get_caps: Called to get sink pad caps from the subclass
* @set_caps: Notify subclass of changed caps
* @fixate: Only useful in pull mode. Implement if you have
* ideas about what should be the default values for the caps you support.
* @activate_pull: Subclasses should override this when they can provide an
* alternate method of spawning a thread to drive the pipeline in pull mode.
* Should start or stop the pulling thread, depending on the value of the
* "active" argument. Called after actually activating the sink pad in pull
* mode. The default implementation starts a task on the sink pad.
* @get_times: Called to get the start and end times for synchronising
* the passed buffer to the clock
* @propose_allocation: configure the allocation query
* @start: Start processing. Ideal for opening resources in the subclass
* @stop: Stop processing. Subclasses should use this to close resources.
* @unlock: Unlock any pending access to the resource. Subclasses should
* unblock any blocked function ASAP
* @unlock_stop: Clear the previous unlock request. Subclasses should clear
* any state they set during unlock(), such as clearing command queues.
* @query: perform a #GstQuery on the element.
* @event: Override this to handle events arriving on the sink pad
* @wait_event: Override this to implement custom logic to wait for the event
* time (for events like EOS and GAP). Subclasses should always first
* chain up to the default implementation.
* @prepare: Called to prepare the buffer for @render and @preroll. This
* function is called before synchronisation is performed.
* @prepare_list: Called to prepare the buffer list for @render_list. This
* function is called before synchronisation is performed.
* @preroll: Called to present the preroll buffer if desired.
* @render: Called when a buffer should be presented or output, at the
* correct moment if the #GstBaseSink has been set to sync to the clock.
* @render_list: Same as @render but used whith buffer lists instead of
* buffers.
*
* Subclasses can override any of the available virtual methods or not, as
* needed. At the minimum, the @render method should be overridden to
* output/present buffers.
*/
struct _GstBaseSinkClass {
GstElementClass parent_class;
/* get caps from subclass */
GstCaps* (*get_caps) (GstBaseSink *sink, GstCaps *filter);
/* notify subclass of new caps */
gboolean (*set_caps) (GstBaseSink *sink, GstCaps *caps);
/* fixate sink caps during pull-mode negotiation */
GstCaps * (*fixate) (GstBaseSink *sink, GstCaps *caps);
/* start or stop a pulling thread */
gboolean (*activate_pull)(GstBaseSink *sink, gboolean active);
/* get the start and end times for syncing on this buffer */
void (*get_times) (GstBaseSink *sink, GstBuffer *buffer,
GstClockTime *start, GstClockTime *end);
/* propose allocation parameters for upstream */
gboolean (*propose_allocation) (GstBaseSink *sink, GstQuery *query);
/* start and stop processing, ideal for opening/closing the resource */
gboolean (*start) (GstBaseSink *sink);
gboolean (*stop) (GstBaseSink *sink);
/* unlock any pending access to the resource. subclasses should unlock
* any function ASAP. */
gboolean (*unlock) (GstBaseSink *sink);
/* Clear a previously indicated unlock request not that unlocking is
* complete. Sub-classes should clear any command queue or indicator they
* set during unlock */
gboolean (*unlock_stop) (GstBaseSink *sink);
/* notify subclass of query */
gboolean (*query) (GstBaseSink *sink, GstQuery *query);
/* notify subclass of event */
gboolean (*event) (GstBaseSink *sink, GstEvent *event);
/* wait for eos or gap, subclasses should chain up to parent first */
GstFlowReturn (*wait_event) (GstBaseSink *sink, GstEvent *event);
/* notify subclass of buffer or list before doing sync */
GstFlowReturn (*prepare) (GstBaseSink *sink, GstBuffer *buffer);
GstFlowReturn (*prepare_list) (GstBaseSink *sink, GstBufferList *buffer_list);
/* notify subclass of preroll buffer or real buffer */
GstFlowReturn (*preroll) (GstBaseSink *sink, GstBuffer *buffer);
GstFlowReturn (*render) (GstBaseSink *sink, GstBuffer *buffer);
/* Render a BufferList */
GstFlowReturn (*render_list) (GstBaseSink *sink, GstBufferList *buffer_list);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GType gst_base_sink_get_type(void);
GstFlowReturn gst_base_sink_do_preroll (GstBaseSink *sink, GstMiniObject *obj);
GstFlowReturn gst_base_sink_wait_preroll (GstBaseSink *sink);
/* synchronizing against the clock */
void gst_base_sink_set_sync (GstBaseSink *sink, gboolean sync);
gboolean gst_base_sink_get_sync (GstBaseSink *sink);
/* dropping late buffers */
void gst_base_sink_set_max_lateness (GstBaseSink *sink, gint64 max_lateness);
gint64 gst_base_sink_get_max_lateness (GstBaseSink *sink);
/* performing QoS */
void gst_base_sink_set_qos_enabled (GstBaseSink *sink, gboolean enabled);
gboolean gst_base_sink_is_qos_enabled (GstBaseSink *sink);
/* doing async state changes */
void gst_base_sink_set_async_enabled (GstBaseSink *sink, gboolean enabled);
gboolean gst_base_sink_is_async_enabled (GstBaseSink *sink);
/* tuning synchronisation */
void gst_base_sink_set_ts_offset (GstBaseSink *sink, GstClockTimeDiff offset);
GstClockTimeDiff gst_base_sink_get_ts_offset (GstBaseSink *sink);
/* last sample */
GstSample * gst_base_sink_get_last_sample (GstBaseSink *sink);
void gst_base_sink_set_last_sample_enabled (GstBaseSink *sink, gboolean enabled);
gboolean gst_base_sink_is_last_sample_enabled (GstBaseSink *sink);
/* latency */
gboolean gst_base_sink_query_latency (GstBaseSink *sink, gboolean *live, gboolean *upstream_live,
GstClockTime *min_latency, GstClockTime *max_latency);
GstClockTime gst_base_sink_get_latency (GstBaseSink *sink);
/* render delay */
void gst_base_sink_set_render_delay (GstBaseSink *sink, GstClockTime delay);
GstClockTime gst_base_sink_get_render_delay (GstBaseSink *sink);
/* blocksize */
void gst_base_sink_set_blocksize (GstBaseSink *sink, guint blocksize);
guint gst_base_sink_get_blocksize (GstBaseSink *sink);
/* throttle-time */
void gst_base_sink_set_throttle_time (GstBaseSink *sink, guint64 throttle);
guint64 gst_base_sink_get_throttle_time (GstBaseSink *sink);
GstClockReturn gst_base_sink_wait_clock (GstBaseSink *sink, GstClockTime time,
GstClockTimeDiff * jitter);
GstFlowReturn gst_base_sink_wait (GstBaseSink *sink, GstClockTime time,
GstClockTimeDiff *jitter);
G_END_DECLS
#endif /* __GST_BASE_SINK_H__ */
@@ -0,0 +1,270 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2005 Wim Taymans <wim@fluendo.com>
*
* gstbasesrc.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BASE_SRC_H__
#define __GST_BASE_SRC_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_BASE_SRC (gst_base_src_get_type())
#define GST_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_SRC,GstBaseSrc))
#define GST_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_SRC,GstBaseSrcClass))
#define GST_BASE_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BASE_SRC, GstBaseSrcClass))
#define GST_IS_BASE_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_SRC))
#define GST_IS_BASE_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_SRC))
#define GST_BASE_SRC_CAST(obj) ((GstBaseSrc *)(obj))
/**
* GstBaseSrcFlags:
* @GST_BASE_SRC_FLAG_STARTING: has source is starting
* @GST_BASE_SRC_FLAG_STARTED: has source been started
* @GST_BASE_SRC_FLAG_LAST: offset to define more flags
*
* The #GstElement flags that a basesrc element may have.
*/
typedef enum {
GST_BASE_SRC_FLAG_STARTING = (GST_ELEMENT_FLAG_LAST << 0),
GST_BASE_SRC_FLAG_STARTED = (GST_ELEMENT_FLAG_LAST << 1),
/* padding */
GST_BASE_SRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 6)
} GstBaseSrcFlags;
#define GST_BASE_SRC_IS_STARTING(obj) GST_OBJECT_FLAG_IS_SET ((obj), GST_BASE_SRC_FLAG_STARTING)
#define GST_BASE_SRC_IS_STARTED(obj) GST_OBJECT_FLAG_IS_SET ((obj), GST_BASE_SRC_FLAG_STARTED)
typedef struct _GstBaseSrc GstBaseSrc;
typedef struct _GstBaseSrcClass GstBaseSrcClass;
typedef struct _GstBaseSrcPrivate GstBaseSrcPrivate;
/**
* GST_BASE_SRC_PAD:
* @obj: base source instance
*
* Gives the pointer to the #GstPad object of the element.
*/
#define GST_BASE_SRC_PAD(obj) (GST_BASE_SRC_CAST (obj)->srcpad)
/**
* GstBaseSrc:
*
* The opaque #GstBaseSrc data structure.
*/
struct _GstBaseSrc {
GstElement element;
/*< protected >*/
GstPad *srcpad;
/* available to subclass implementations */
/* MT-protected (with LIVE_LOCK) */
GMutex live_lock;
GCond live_cond;
gboolean is_live;
gboolean live_running;
/* MT-protected (with LOCK) */
guint blocksize; /* size of buffers when operating push based */
gboolean can_activate_push; /* some scheduling properties */
gboolean random_access;
GstClockID clock_id; /* for syncing */
/* MT-protected (with STREAM_LOCK *and* OBJECT_LOCK) */
GstSegment segment;
/* MT-protected (with STREAM_LOCK) */
gboolean need_newsegment;
gint num_buffers;
gint num_buffers_left;
gboolean typefind;
gboolean running;
GstEvent *pending_seek;
GstBaseSrcPrivate *priv;
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
/**
* GstBaseSrcClass:
* @parent_class: Element parent class
* @get_caps: Called to get the caps to report
* @negotiate: Negotiated the caps with the peer.
* @fixate: Called during negotiation if caps need fixating. Implement instead of
* setting a fixate function on the source pad.
* @set_caps: Notify subclass of changed output caps
* @decide_allocation: configure the allocation query
* @start: Start processing. Subclasses should open resources and prepare
* to produce data. Implementation should call gst_base_src_start_complete()
* when the operation completes, either from the current thread or any other
* thread that finishes the start operation asynchronously.
* @stop: Stop processing. Subclasses should use this to close resources.
* @get_times: Given a buffer, return the start and stop time when it
* should be pushed out. The base class will sync on the clock using
* these times.
* @get_size: Return the total size of the resource, in the configured format.
* @is_seekable: Check if the source can seek
* @prepare_seek_segment: Prepare the GstSegment that will be passed to the
* do_seek vmethod for executing a seek request. Sub-classes should override
* this if they support seeking in formats other than the configured native
* format. By default, it tries to convert the seek arguments to the
* configured native format and prepare a segment in that format.
* @do_seek: Perform seeking on the resource to the indicated segment.
* @unlock: Unlock any pending access to the resource. Subclasses should
* unblock any blocked function ASAP. In particular, any create() function in
* progress should be unblocked and should return GST_FLOW_FLUSHING. Any
* future @create<!-- -->() function call should also return GST_FLOW_FLUSHING
* until the @unlock_stop<!-- -->() function has been called.
* @unlock_stop: Clear the previous unlock request. Subclasses should clear
* any state they set during unlock(), such as clearing command queues.
* @query: Handle a requested query.
* @event: Override this to implement custom event handling.
* @create: Ask the subclass to create a buffer with offset and size.
* When the subclass returns GST_FLOW_OK, it MUST return a buffer of the
* requested size unless fewer bytes are available because an EOS condition
* is near. No buffer should be returned when the return value is different
* from GST_FLOW_OK. A return value of GST_FLOW_EOS signifies that the
* end of stream is reached. The default implementation will call @alloc and
* then call @fill.
* @alloc: Ask the subclass to allocate a buffer with for offset and size. The
* default implementation will create a new buffer from the negotiated allocator.
* @fill: Ask the subclass to fill the buffer with data for offset and size. The
* passed buffer is guaranteed to hold the requested amount of bytes.
*
* Subclasses can override any of the available virtual methods or not, as
* needed. At the minimum, the @create method should be overridden to produce
* buffers.
*/
struct _GstBaseSrcClass {
GstElementClass parent_class;
/*< public >*/
/* virtual methods for subclasses */
/* get caps from subclass */
GstCaps* (*get_caps) (GstBaseSrc *src, GstCaps *filter);
/* decide on caps */
gboolean (*negotiate) (GstBaseSrc *src);
/* called if, in negotiation, caps need fixating */
GstCaps * (*fixate) (GstBaseSrc *src, GstCaps *caps);
/* notify the subclass of new caps */
gboolean (*set_caps) (GstBaseSrc *src, GstCaps *caps);
/* setup allocation query */
gboolean (*decide_allocation) (GstBaseSrc *src, GstQuery *query);
/* start and stop processing, ideal for opening/closing the resource */
gboolean (*start) (GstBaseSrc *src);
gboolean (*stop) (GstBaseSrc *src);
/* given a buffer, return start and stop time when it should be pushed
* out. The base class will sync on the clock using these times. */
void (*get_times) (GstBaseSrc *src, GstBuffer *buffer,
GstClockTime *start, GstClockTime *end);
/* get the total size of the resource in bytes */
gboolean (*get_size) (GstBaseSrc *src, guint64 *size);
/* check if the resource is seekable */
gboolean (*is_seekable) (GstBaseSrc *src);
/* Prepare the segment on which to perform do_seek(), converting to the
* current basesrc format. */
gboolean (*prepare_seek_segment) (GstBaseSrc *src, GstEvent *seek,
GstSegment *segment);
/* notify subclasses of a seek */
gboolean (*do_seek) (GstBaseSrc *src, GstSegment *segment);
/* unlock any pending access to the resource. subclasses should unlock
* any function ASAP. */
gboolean (*unlock) (GstBaseSrc *src);
/* Clear any pending unlock request, as we succeeded in unlocking */
gboolean (*unlock_stop) (GstBaseSrc *src);
/* notify subclasses of a query */
gboolean (*query) (GstBaseSrc *src, GstQuery *query);
/* notify subclasses of an event */
gboolean (*event) (GstBaseSrc *src, GstEvent *event);
/* ask the subclass to create a buffer with offset and size, the default
* implementation will call alloc and fill. */
GstFlowReturn (*create) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer **buf);
/* ask the subclass to allocate an output buffer. The default implementation
* will use the negotiated allocator. */
GstFlowReturn (*alloc) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer **buf);
/* ask the subclass to fill the buffer with data from offset and size */
GstFlowReturn (*fill) (GstBaseSrc *src, guint64 offset, guint size,
GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GType gst_base_src_get_type (void);
GstFlowReturn gst_base_src_wait_playing (GstBaseSrc *src);
void gst_base_src_set_live (GstBaseSrc *src, gboolean live);
gboolean gst_base_src_is_live (GstBaseSrc *src);
void gst_base_src_set_format (GstBaseSrc *src, GstFormat format);
void gst_base_src_set_dynamic_size (GstBaseSrc * src, gboolean dynamic);
void gst_base_src_set_async (GstBaseSrc *src, gboolean async);
gboolean gst_base_src_is_async (GstBaseSrc *src);
void gst_base_src_start_complete (GstBaseSrc * basesrc, GstFlowReturn ret);
GstFlowReturn gst_base_src_start_wait (GstBaseSrc * basesrc);
gboolean gst_base_src_query_latency (GstBaseSrc *src, gboolean * live,
GstClockTime * min_latency,
GstClockTime * max_latency);
void gst_base_src_set_blocksize (GstBaseSrc *src, guint blocksize);
guint gst_base_src_get_blocksize (GstBaseSrc *src);
void gst_base_src_set_do_timestamp (GstBaseSrc *src, gboolean timestamp);
gboolean gst_base_src_get_do_timestamp (GstBaseSrc *src);
gboolean gst_base_src_new_seamless_segment (GstBaseSrc *src, gint64 start, gint64 stop, gint64 time);
gboolean gst_base_src_set_caps (GstBaseSrc *src, GstCaps *caps);
GstBufferPool * gst_base_src_get_buffer_pool (GstBaseSrc *src);
void gst_base_src_get_allocator (GstBaseSrc *src,
GstAllocator **allocator,
GstAllocationParams *params);
G_END_DECLS
#endif /* __GST_BASE_SRC_H__ */
@@ -0,0 +1,298 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2005 Wim Taymans <wim@fluendo.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BASE_TRANSFORM_H__
#define __GST_BASE_TRANSFORM_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_BASE_TRANSFORM (gst_base_transform_get_type())
#define GST_BASE_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_TRANSFORM,GstBaseTransform))
#define GST_BASE_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_TRANSFORM,GstBaseTransformClass))
#define GST_BASE_TRANSFORM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_TRANSFORM,GstBaseTransformClass))
#define GST_IS_BASE_TRANSFORM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_TRANSFORM))
#define GST_IS_BASE_TRANSFORM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_TRANSFORM))
#define GST_BASE_TRANSFORM_CAST(obj) ((GstBaseTransform *)(obj))
/**
* GST_BASE_TRANSFORM_SINK_NAME:
*
* The name of the templates for the sink pad.
*/
#define GST_BASE_TRANSFORM_SINK_NAME "sink"
/**
* GST_BASE_TRANSFORM_SRC_NAME:
*
* The name of the templates for the source pad.
*/
#define GST_BASE_TRANSFORM_SRC_NAME "src"
/**
* GST_BASE_TRANSFORM_SRC_PAD:
* @obj: base transform instance
*
* Gives the pointer to the source #GstPad object of the element.
*/
#define GST_BASE_TRANSFORM_SRC_PAD(obj) (GST_BASE_TRANSFORM_CAST (obj)->srcpad)
/**
* GST_BASE_TRANSFORM_SINK_PAD:
* @obj: base transform instance
*
* Gives the pointer to the sink #GstPad object of the element.
*/
#define GST_BASE_TRANSFORM_SINK_PAD(obj) (GST_BASE_TRANSFORM_CAST (obj)->sinkpad)
/**
* GST_BASE_TRANSFORM_FLOW_DROPPED:
*
* A #GstFlowReturn that can be returned from transform and transform_ip to
* indicate that no output buffer was generated.
*/
#define GST_BASE_TRANSFORM_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS
typedef struct _GstBaseTransform GstBaseTransform;
typedef struct _GstBaseTransformClass GstBaseTransformClass;
typedef struct _GstBaseTransformPrivate GstBaseTransformPrivate;
/**
* GstBaseTransform:
*
* The opaque #GstBaseTransform data structure.
*/
struct _GstBaseTransform {
GstElement element;
/*< protected >*/
/* source and sink pads */
GstPad *sinkpad;
GstPad *srcpad;
/* MT-protected (with STREAM_LOCK) */
gboolean have_segment;
GstSegment segment;
/*< private >*/
GstBaseTransformPrivate *priv;
gpointer _gst_reserved[GST_PADDING_LARGE];
};
/**
* GstBaseTransformClass:
* @parent_class: Element parent class
* @passthrough_on_same_caps: If set to %TRUE, passthrough mode will be
* automatically enabled if the caps are the same.
* Set to %FALSE by default.
* @transform_ip_on_passthrough: If set to %TRUE, @transform_ip will be called in
* passthrough mode. The passed buffer might not be
* writable. When %FALSE, neither @transform nor
* @transform_ip will be called in passthrough mode.
* Set to %TRUE by default.
* @transform_caps: Optional. Given the pad in this direction and the given
* caps, what caps are allowed on the other pad in this
* element ?
* @fixate_caps: Optional. Given the pad in this direction and the given
* caps, fixate the caps on the other pad. The function takes
* ownership of @othercaps and returns a fixated version of
* @othercaps. @othercaps is not guaranteed to be writable.
* @accept_caps: Optional.
* Subclasses can override this method to check if @caps can be
* handled by the element. The default implementation might not be
* the most optimal way to check this in all cases.
* @set_caps: allows the subclass to be notified of the actual caps set.
* @query: Optional.
* Handle a requested query. Subclasses that implement this
* should must chain up to the parent if they didn't handle the
* query
* @decide_allocation: Setup the allocation parameters for allocating output
* buffers. The passed in query contains the result of the
* downstream allocation query. This function is only called
* when not operating in passthrough mode. The default
* implementation will remove all memory dependent metadata.
* If there is ia @filter_meta method implementation, it will
* be called for all metadata API in the downstream query,
* otherwise the metadata API is removed.
* @filter_meta: Return TRUE if the metadata API should be proposed in the
* upstream allocation query. The default implementation is NULL
* and will cause all metadata to be removed.
* @propose_allocation: Propose buffer allocation parameters for upstream elements.
* This function must be implemented if the element reads or
* writes the buffer content. The query that was passed to
* the decide_allocation is passed in this method (or NULL
* when the element is in passthrough mode). The default
* implementation will pass the query downstream when in
* passthrough mode and will copy all the filtered metadata
* API in non-passthrough mode.
* @transform_size: Optional. Given the size of a buffer in the given direction
* with the given caps, calculate the size in bytes of a buffer
* on the other pad with the given other caps.
* The default implementation uses get_unit_size and keeps
* the number of units the same.
* @get_unit_size: Required if the transform is not in-place.
* get the size in bytes of one unit for the given caps.
* @start: Optional.
* Called when the element starts processing.
* Allows opening external resources.
* @stop: Optional.
* Called when the element stops processing.
* Allows closing external resources.
* @sink_event: Optional.
* Event handler on the sink pad. The default implementation
* handles the event and forwards it downstream.
* @src_event: Optional.
* Event handler on the source pad. The default implementation
* handles the event and forwards it upstream.
* @prepare_output_buffer: Optional.
* Subclasses can override this to do their own
* allocation of output buffers. Elements that only do
* analysis can return a subbuffer or even just
* return a reference to the input buffer (if in
* passthrough mode). The default implementation will
* use the negotiated allocator or bufferpool and
* transform_size to allocate an output buffer or it
* will return the input buffer in passthrough mode.
* @copy_metadata: Optional.
* Copy the metadata from the input buffer to the output buffer.
* The default implementation will copy the flags, timestamps and
* offsets of the buffer.
* @transform_meta: Optional. Transform the metadata on the input buffer to the
* output buffer. By default this method is NULL and no
* metadata is copied. subclasses can implement this method and
* return TRUE if the metadata is to be copied.
* @before_transform: Optional.
* This method is called right before the base class will
* start processing. Dynamic properties or other delayed
* configuration could be performed in this method.
* @transform: Required if the element does not operate in-place.
* Transforms one incoming buffer to one outgoing buffer.
* The function is allowed to change size/timestamp/duration
* of the outgoing buffer.
* @transform_ip: Required if the element operates in-place.
* Transform the incoming buffer in-place.
*
* Subclasses can override any of the available virtual methods or not, as
* needed. At minimum either @transform or @transform_ip need to be overridden.
* If the element can overwrite the input data with the results (data is of the
* same type and quantity) it should provide @transform_ip.
*/
struct _GstBaseTransformClass {
GstElementClass parent_class;
/*< public >*/
gboolean passthrough_on_same_caps;
gboolean transform_ip_on_passthrough;
/* virtual methods for subclasses */
GstCaps* (*transform_caps) (GstBaseTransform *trans,
GstPadDirection direction,
GstCaps *caps, GstCaps *filter);
GstCaps* (*fixate_caps) (GstBaseTransform *trans,
GstPadDirection direction, GstCaps *caps,
GstCaps *othercaps);
gboolean (*accept_caps) (GstBaseTransform *trans, GstPadDirection direction,
GstCaps *caps);
gboolean (*set_caps) (GstBaseTransform *trans, GstCaps *incaps,
GstCaps *outcaps);
gboolean (*query) (GstBaseTransform *trans, GstPadDirection direction,
GstQuery *query);
/* decide allocation query for output buffers */
gboolean (*decide_allocation) (GstBaseTransform *trans, GstQuery *query);
gboolean (*filter_meta) (GstBaseTransform *trans, GstQuery *query,
GType api, const GstStructure *params);
/* propose allocation query parameters for input buffers */
gboolean (*propose_allocation) (GstBaseTransform *trans, GstQuery *decide_query,
GstQuery *query);
/* transform size */
gboolean (*transform_size) (GstBaseTransform *trans,
GstPadDirection direction,
GstCaps *caps, gsize size,
GstCaps *othercaps, gsize *othersize);
gboolean (*get_unit_size) (GstBaseTransform *trans, GstCaps *caps,
gsize *size);
/* states */
gboolean (*start) (GstBaseTransform *trans);
gboolean (*stop) (GstBaseTransform *trans);
/* sink and src pad event handlers */
gboolean (*sink_event) (GstBaseTransform *trans, GstEvent *event);
gboolean (*src_event) (GstBaseTransform *trans, GstEvent *event);
GstFlowReturn (*prepare_output_buffer) (GstBaseTransform * trans,
GstBuffer *input, GstBuffer **outbuf);
/* metadata */
gboolean (*copy_metadata) (GstBaseTransform *trans, GstBuffer *input,
GstBuffer *outbuf);
gboolean (*transform_meta) (GstBaseTransform *trans, GstBuffer *outbuf,
GstMeta *meta, GstBuffer *inbuf);
void (*before_transform) (GstBaseTransform *trans, GstBuffer *buffer);
/* transform */
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf,
GstBuffer *outbuf);
GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
};
GType gst_base_transform_get_type (void);
void gst_base_transform_set_passthrough (GstBaseTransform *trans,
gboolean passthrough);
gboolean gst_base_transform_is_passthrough (GstBaseTransform *trans);
void gst_base_transform_set_in_place (GstBaseTransform *trans,
gboolean in_place);
gboolean gst_base_transform_is_in_place (GstBaseTransform *trans);
void gst_base_transform_update_qos (GstBaseTransform *trans,
gdouble proportion,
GstClockTimeDiff diff,
GstClockTime timestamp);
void gst_base_transform_set_qos_enabled (GstBaseTransform *trans,
gboolean enabled);
gboolean gst_base_transform_is_qos_enabled (GstBaseTransform *trans);
void gst_base_transform_set_gap_aware (GstBaseTransform *trans,
gboolean gap_aware);
void gst_base_transform_set_prefer_passthrough (GstBaseTransform *trans,
gboolean prefer_passthrough);
GstBufferPool * gst_base_transform_get_buffer_pool (GstBaseTransform *trans);
void gst_base_transform_get_allocator (GstBaseTransform *trans,
GstAllocator **allocator,
GstAllocationParams *params);
void gst_base_transform_reconfigure_sink (GstBaseTransform *trans);
void gst_base_transform_reconfigure_src (GstBaseTransform *trans);
G_END_DECLS
#endif /* __GST_BASE_TRANSFORM_H__ */
@@ -0,0 +1,301 @@
/* GStreamer
*
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BIT_READER_H__
#define __GST_BIT_READER_H__
#include <gst/gst.h>
/* FIXME: inline functions */
G_BEGIN_DECLS
#define GST_BIT_READER(reader) ((GstBitReader *) (reader))
/**
* GstBitReader:
* @data: (array length=size): Data from which the bit reader will
* read
* @size: Size of @data in bytes
* @byte: Current byte position
* @bit: Bit position in the current byte
*
* A bit reader instance.
*/
typedef struct {
const guint8 *data;
guint size;
guint byte; /* Byte position */
guint bit; /* Bit position in the current byte */
/* < private > */
gpointer _gst_reserved[GST_PADDING];
} GstBitReader;
GstBitReader * gst_bit_reader_new (const guint8 *data, guint size) G_GNUC_MALLOC;
void gst_bit_reader_free (GstBitReader *reader);
void gst_bit_reader_init (GstBitReader *reader, const guint8 *data, guint size);
gboolean gst_bit_reader_set_pos (GstBitReader *reader, guint pos);
guint gst_bit_reader_get_pos (const GstBitReader *reader);
guint gst_bit_reader_get_remaining (const GstBitReader *reader);
guint gst_bit_reader_get_size (const GstBitReader *reader);
gboolean gst_bit_reader_skip (GstBitReader *reader, guint nbits);
gboolean gst_bit_reader_skip_to_byte (GstBitReader *reader);
gboolean gst_bit_reader_get_bits_uint8 (GstBitReader *reader, guint8 *val, guint nbits);
gboolean gst_bit_reader_get_bits_uint16 (GstBitReader *reader, guint16 *val, guint nbits);
gboolean gst_bit_reader_get_bits_uint32 (GstBitReader *reader, guint32 *val, guint nbits);
gboolean gst_bit_reader_get_bits_uint64 (GstBitReader *reader, guint64 *val, guint nbits);
gboolean gst_bit_reader_peek_bits_uint8 (const GstBitReader *reader, guint8 *val, guint nbits);
gboolean gst_bit_reader_peek_bits_uint16 (const GstBitReader *reader, guint16 *val, guint nbits);
gboolean gst_bit_reader_peek_bits_uint32 (const GstBitReader *reader, guint32 *val, guint nbits);
gboolean gst_bit_reader_peek_bits_uint64 (const GstBitReader *reader, guint64 *val, guint nbits);
/**
* GST_BIT_READER_INIT:
* @data: Data from which the #GstBitReader should read
* @size: Size of @data in bytes
*
* A #GstBitReader must be initialized with this macro, before it can be
* used. This macro can used be to initialize a variable, but it cannot
* be assigned to a variable. In that case you have to use
* gst_bit_reader_init().
*/
#define GST_BIT_READER_INIT(data, size) {data, size, 0, 0}
/* Unchecked variants */
static inline void
gst_bit_reader_skip_unchecked (GstBitReader * reader, guint nbits)
{
reader->bit += nbits;
reader->byte += reader->bit / 8;
reader->bit = reader->bit % 8;
}
static inline void
gst_bit_reader_skip_to_byte_unchecked (GstBitReader * reader)
{
if (reader->bit) {
reader->bit = 0;
reader->byte++;
}
}
#define __GST_BIT_READER_READ_BITS_UNCHECKED(bits) \
static inline guint##bits \
gst_bit_reader_peek_bits_uint##bits##_unchecked (const GstBitReader *reader, guint nbits) \
{ \
guint##bits ret = 0; \
const guint8 *data; \
guint byte, bit; \
\
data = reader->data; \
byte = reader->byte; \
bit = reader->bit; \
\
while (nbits > 0) { \
guint toread = MIN (nbits, 8 - bit); \
\
ret <<= toread; \
ret |= (data[byte] & (0xff >> bit)) >> (8 - toread - bit); \
\
bit += toread; \
if (bit >= 8) { \
byte++; \
bit = 0; \
} \
nbits -= toread; \
} \
\
return ret; \
} \
\
static inline guint##bits \
gst_bit_reader_get_bits_uint##bits##_unchecked (GstBitReader *reader, guint nbits) \
{ \
guint##bits ret; \
\
ret = gst_bit_reader_peek_bits_uint##bits##_unchecked (reader, nbits); \
\
gst_bit_reader_skip_unchecked (reader, nbits); \
\
return ret; \
}
__GST_BIT_READER_READ_BITS_UNCHECKED (8)
__GST_BIT_READER_READ_BITS_UNCHECKED (16)
__GST_BIT_READER_READ_BITS_UNCHECKED (32)
__GST_BIT_READER_READ_BITS_UNCHECKED (64)
#undef __GST_BIT_READER_READ_BITS_UNCHECKED
/* unchecked variants -- do not use */
static inline guint
_gst_bit_reader_get_size_unchecked (const GstBitReader * reader)
{
return reader->size * 8;
}
static inline guint
_gst_bit_reader_get_pos_unchecked (const GstBitReader * reader)
{
return reader->byte * 8 + reader->bit;
}
static inline guint
_gst_bit_reader_get_remaining_unchecked (const GstBitReader * reader)
{
return reader->size * 8 - (reader->byte * 8 + reader->bit);
}
/* inlined variants -- do not use directly */
static inline guint
_gst_bit_reader_get_size_inline (const GstBitReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_bit_reader_get_size_unchecked (reader);
}
static inline guint
_gst_bit_reader_get_pos_inline (const GstBitReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_bit_reader_get_pos_unchecked (reader);
}
static inline guint
_gst_bit_reader_get_remaining_inline (const GstBitReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_bit_reader_get_remaining_unchecked (reader);
}
static inline gboolean
_gst_bit_reader_skip_inline (GstBitReader * reader, guint nbits)
{
g_return_val_if_fail (reader != NULL, FALSE);
if (_gst_bit_reader_get_remaining_unchecked (reader) < nbits)
return FALSE;
gst_bit_reader_skip_unchecked (reader, nbits);
return TRUE;
}
static inline gboolean
_gst_bit_reader_skip_to_byte_inline (GstBitReader * reader)
{
g_return_val_if_fail (reader != NULL, FALSE);
if (reader->byte > reader->size)
return FALSE;
gst_bit_reader_skip_to_byte_unchecked (reader);
return TRUE;
}
#define __GST_BIT_READER_READ_BITS_INLINE(bits) \
static inline gboolean \
_gst_bit_reader_get_bits_uint##bits##_inline (GstBitReader *reader, guint##bits *val, guint nbits) \
{ \
g_return_val_if_fail (reader != NULL, FALSE); \
g_return_val_if_fail (val != NULL, FALSE); \
g_return_val_if_fail (nbits <= bits, FALSE); \
\
if (_gst_bit_reader_get_remaining_unchecked (reader) < nbits) \
return FALSE; \
\
*val = gst_bit_reader_get_bits_uint##bits##_unchecked (reader, nbits); \
return TRUE; \
} \
\
static inline gboolean \
_gst_bit_reader_peek_bits_uint##bits##_inline (const GstBitReader *reader, guint##bits *val, guint nbits) \
{ \
g_return_val_if_fail (reader != NULL, FALSE); \
g_return_val_if_fail (val != NULL, FALSE); \
g_return_val_if_fail (nbits <= bits, FALSE); \
\
if (_gst_bit_reader_get_remaining_unchecked (reader) < nbits) \
return FALSE; \
\
*val = gst_bit_reader_peek_bits_uint##bits##_unchecked (reader, nbits); \
return TRUE; \
}
__GST_BIT_READER_READ_BITS_INLINE (8)
__GST_BIT_READER_READ_BITS_INLINE (16)
__GST_BIT_READER_READ_BITS_INLINE (32)
__GST_BIT_READER_READ_BITS_INLINE (64)
#undef __GST_BIT_READER_READ_BITS_INLINE
#ifndef GST_BIT_READER_DISABLE_INLINES
#define gst_bit_reader_get_size(reader) \
_gst_bit_reader_get_size_inline (reader)
#define gst_bit_reader_get_pos(reader) \
_gst_bit_reader_get_pos_inline (reader)
#define gst_bit_reader_get_remaining(reader) \
_gst_bit_reader_get_remaining_inline (reader)
/* we use defines here so we can add the G_LIKELY() */
#define gst_bit_reader_skip(reader, nbits)\
G_LIKELY (_gst_bit_reader_skip_inline(reader, nbits))
#define gst_bit_reader_skip_to_byte(reader)\
G_LIKELY (_gst_bit_reader_skip_to_byte_inline(reader))
#define gst_bit_reader_get_bits_uint8(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_get_bits_uint8_inline (reader, val, nbits))
#define gst_bit_reader_get_bits_uint16(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_get_bits_uint16_inline (reader, val, nbits))
#define gst_bit_reader_get_bits_uint32(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_get_bits_uint32_inline (reader, val, nbits))
#define gst_bit_reader_get_bits_uint64(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_get_bits_uint64_inline (reader, val, nbits))
#define gst_bit_reader_peek_bits_uint8(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_peek_bits_uint8_inline (reader, val, nbits))
#define gst_bit_reader_peek_bits_uint16(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_peek_bits_uint16_inline (reader, val, nbits))
#define gst_bit_reader_peek_bits_uint32(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_peek_bits_uint32_inline (reader, val, nbits))
#define gst_bit_reader_peek_bits_uint64(reader, val, nbits) \
G_LIKELY (_gst_bit_reader_peek_bits_uint64_inline (reader, val, nbits))
#endif
G_END_DECLS
#endif /* __GST_BIT_READER_H__ */
@@ -0,0 +1,513 @@
/* GStreamer byte reader
*
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
* Copyright (C) 2009 Tim-Philipp Müller <tim centricular net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BYTE_READER_H__
#define __GST_BYTE_READER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_BYTE_READER(reader) ((GstByteReader *) (reader))
/**
* GstByteReader:
* @data: (array length=size): Data from which the bit reader will
* read
* @size: Size of @data in bytes
* @byte: Current byte position
*
* A byte reader instance.
*/
typedef struct {
const guint8 *data;
guint size;
guint byte; /* Byte position */
/* < private > */
gpointer _gst_reserved[GST_PADDING];
} GstByteReader;
GstByteReader * gst_byte_reader_new (const guint8 *data, guint size) G_GNUC_MALLOC;
void gst_byte_reader_free (GstByteReader *reader);
void gst_byte_reader_init (GstByteReader *reader, const guint8 *data, guint size);
gboolean gst_byte_reader_set_pos (GstByteReader *reader, guint pos);
guint gst_byte_reader_get_pos (const GstByteReader *reader);
guint gst_byte_reader_get_remaining (const GstByteReader *reader);
guint gst_byte_reader_get_size (const GstByteReader *reader);
gboolean gst_byte_reader_skip (GstByteReader *reader, guint nbytes);
gboolean gst_byte_reader_get_uint8 (GstByteReader *reader, guint8 *val);
gboolean gst_byte_reader_get_int8 (GstByteReader *reader, gint8 *val);
gboolean gst_byte_reader_get_uint16_le (GstByteReader *reader, guint16 *val);
gboolean gst_byte_reader_get_int16_le (GstByteReader *reader, gint16 *val);
gboolean gst_byte_reader_get_uint16_be (GstByteReader *reader, guint16 *val);
gboolean gst_byte_reader_get_int16_be (GstByteReader *reader, gint16 *val);
gboolean gst_byte_reader_get_uint24_le (GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_get_int24_le (GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_get_uint24_be (GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_get_int24_be (GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_get_uint32_le (GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_get_int32_le (GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_get_uint32_be (GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_get_int32_be (GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_get_uint64_le (GstByteReader *reader, guint64 *val);
gboolean gst_byte_reader_get_int64_le (GstByteReader *reader, gint64 *val);
gboolean gst_byte_reader_get_uint64_be (GstByteReader *reader, guint64 *val);
gboolean gst_byte_reader_get_int64_be (GstByteReader *reader, gint64 *val);
gboolean gst_byte_reader_peek_uint8 (const GstByteReader *reader, guint8 *val);
gboolean gst_byte_reader_peek_int8 (const GstByteReader *reader, gint8 *val);
gboolean gst_byte_reader_peek_uint16_le (const GstByteReader *reader, guint16 *val);
gboolean gst_byte_reader_peek_int16_le (const GstByteReader *reader, gint16 *val);
gboolean gst_byte_reader_peek_uint16_be (const GstByteReader *reader, guint16 *val);
gboolean gst_byte_reader_peek_int16_be (const GstByteReader *reader, gint16 *val);
gboolean gst_byte_reader_peek_uint24_le (const GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_peek_int24_le (const GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_peek_uint24_be (const GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_peek_int24_be (const GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_peek_uint32_le (const GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_peek_int32_le (const GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_peek_uint32_be (const GstByteReader *reader, guint32 *val);
gboolean gst_byte_reader_peek_int32_be (const GstByteReader *reader, gint32 *val);
gboolean gst_byte_reader_peek_uint64_le (const GstByteReader *reader, guint64 *val);
gboolean gst_byte_reader_peek_int64_le (const GstByteReader *reader, gint64 *val);
gboolean gst_byte_reader_peek_uint64_be (const GstByteReader *reader, guint64 *val);
gboolean gst_byte_reader_peek_int64_be (const GstByteReader *reader, gint64 *val);
gboolean gst_byte_reader_get_float32_le (GstByteReader *reader, gfloat *val);
gboolean gst_byte_reader_get_float32_be (GstByteReader *reader, gfloat *val);
gboolean gst_byte_reader_get_float64_le (GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_get_float64_be (GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_peek_float32_le (const GstByteReader *reader, gfloat *val);
gboolean gst_byte_reader_peek_float32_be (const GstByteReader *reader, gfloat *val);
gboolean gst_byte_reader_peek_float64_le (const GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_peek_float64_be (const GstByteReader *reader, gdouble *val);
gboolean gst_byte_reader_dup_data (GstByteReader * reader, guint size, guint8 ** val);
gboolean gst_byte_reader_get_data (GstByteReader * reader, guint size, const guint8 ** val);
gboolean gst_byte_reader_peek_data (const GstByteReader * reader, guint size, const guint8 ** val);
#define gst_byte_reader_dup_string(reader,str) \
gst_byte_reader_dup_string_utf8(reader,str)
gboolean gst_byte_reader_dup_string_utf8 (GstByteReader * reader, gchar ** str);
gboolean gst_byte_reader_dup_string_utf16 (GstByteReader * reader, guint16 ** str);
gboolean gst_byte_reader_dup_string_utf32 (GstByteReader * reader, guint32 ** str);
#define gst_byte_reader_skip_string(reader) \
gst_byte_reader_skip_string_utf8(reader)
gboolean gst_byte_reader_skip_string_utf8 (GstByteReader * reader);
gboolean gst_byte_reader_skip_string_utf16 (GstByteReader * reader);
gboolean gst_byte_reader_skip_string_utf32 (GstByteReader * reader);
#define gst_byte_reader_get_string(reader,str) \
gst_byte_reader_get_string_utf8(reader,str)
#define gst_byte_reader_peek_string(reader,str) \
gst_byte_reader_peek_string_utf8(reader,str)
gboolean gst_byte_reader_get_string_utf8 (GstByteReader * reader, const gchar ** str);
gboolean gst_byte_reader_peek_string_utf8 (const GstByteReader * reader, const gchar ** str);
guint gst_byte_reader_masked_scan_uint32 (const GstByteReader * reader,
guint32 mask,
guint32 pattern,
guint offset,
guint size);
/**
* GST_BYTE_READER_INIT:
* @data: Data from which the #GstByteReader should read
* @size: Size of @data in bytes
*
* A #GstByteReader must be initialized with this macro, before it can be
* used. This macro can used be to initialize a variable, but it cannot
* be assigned to a variable. In that case you have to use
* gst_byte_reader_init().
*/
#define GST_BYTE_READER_INIT(data, size) {data, size, 0}
/* unchecked variants */
static inline void
gst_byte_reader_skip_unchecked (GstByteReader * reader, guint nbytes)
{
reader->byte += nbytes;
}
#define __GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(bits,type,lower,upper,adj) \
\
static inline type \
gst_byte_reader_peek_##lower##_unchecked (const GstByteReader * reader) \
{ \
type val = (type) GST_READ_##upper (reader->data + reader->byte); \
adj \
return val; \
} \
\
static inline type \
gst_byte_reader_get_##lower##_unchecked (GstByteReader * reader) \
{ \
type val = gst_byte_reader_peek_##lower##_unchecked (reader); \
reader->byte += bits / 8; \
return val; \
}
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(8,guint8,uint8,UINT8,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(8,gint8,int8,UINT8,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(16,guint16,uint16_le,UINT16_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(16,guint16,uint16_be,UINT16_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(16,gint16,int16_le,UINT16_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(16,gint16,int16_be,UINT16_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,guint32,uint32_le,UINT32_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,guint32,uint32_be,UINT32_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gint32,int32_le,UINT32_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gint32,int32_be,UINT32_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(24,guint32,uint24_le,UINT24_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(24,guint32,uint24_be,UINT24_BE,/* */)
/* fix up the sign for 24-bit signed ints stored in 32-bit signed ints */
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(24,gint32,int24_le,UINT24_LE,
if (val & 0x00800000) val |= 0xff000000;)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(24,gint32,int24_be,UINT24_BE,
if (val & 0x00800000) val |= 0xff000000;)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,guint64,uint64_le,UINT64_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,guint64,uint64_be,UINT64_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gint64,int64_le,UINT64_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gint64,int64_be,UINT64_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gfloat,float32_le,FLOAT_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(32,gfloat,float32_be,FLOAT_BE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gdouble,float64_le,DOUBLE_LE,/* */)
__GST_BYTE_READER_GET_PEEK_BITS_UNCHECKED(64,gdouble,float64_be,DOUBLE_BE,/* */)
#undef __GET_PEEK_BITS_UNCHECKED
static inline const guint8 *
gst_byte_reader_peek_data_unchecked (const GstByteReader * reader)
{
return (const guint8 *) (reader->data + reader->byte);
}
static inline const guint8 *
gst_byte_reader_get_data_unchecked (GstByteReader * reader, guint size)
{
const guint8 *data;
data = gst_byte_reader_peek_data_unchecked (reader);
gst_byte_reader_skip_unchecked (reader, size);
return data;
}
static inline guint8 *
gst_byte_reader_dup_data_unchecked (GstByteReader * reader, guint size)
{
gconstpointer data = gst_byte_reader_get_data_unchecked (reader, size);
return (guint8 *) g_memdup (data, size);
}
/* Unchecked variants that should not be used */
static inline guint
_gst_byte_reader_get_pos_unchecked (const GstByteReader * reader)
{
return reader->byte;
}
static inline guint
_gst_byte_reader_get_remaining_unchecked (const GstByteReader * reader)
{
return reader->size - reader->byte;
}
static inline guint
_gst_byte_reader_get_size_unchecked (const GstByteReader * reader)
{
return reader->size;
}
/* inlined variants (do not use directly) */
static inline guint
_gst_byte_reader_get_remaining_inline (const GstByteReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_byte_reader_get_remaining_unchecked (reader);
}
static inline guint
_gst_byte_reader_get_size_inline (const GstByteReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_byte_reader_get_size_unchecked (reader);
}
#define __GST_BYTE_READER_GET_PEEK_BITS_INLINE(bits,type,name) \
\
static inline gboolean \
_gst_byte_reader_peek_##name##_inline (const GstByteReader * reader, type * val) \
{ \
g_return_val_if_fail (reader != NULL, FALSE); \
g_return_val_if_fail (val != NULL, FALSE); \
\
if (_gst_byte_reader_get_remaining_unchecked (reader) < (bits / 8)) \
return FALSE; \
\
*val = gst_byte_reader_peek_##name##_unchecked (reader); \
return TRUE; \
} \
\
static inline gboolean \
_gst_byte_reader_get_##name##_inline (GstByteReader * reader, type * val) \
{ \
g_return_val_if_fail (reader != NULL, FALSE); \
g_return_val_if_fail (val != NULL, FALSE); \
\
if (_gst_byte_reader_get_remaining_unchecked (reader) < (bits / 8)) \
return FALSE; \
\
*val = gst_byte_reader_get_##name##_unchecked (reader); \
return TRUE; \
}
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(8,guint8,uint8)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(8,gint8,int8)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(16,guint16,uint16_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(16,guint16,uint16_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(16,gint16,int16_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(16,gint16,int16_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,guint32,uint32_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,guint32,uint32_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gint32,int32_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gint32,int32_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(24,guint32,uint24_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(24,guint32,uint24_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(24,gint32,int24_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(24,gint32,int24_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,guint64,uint64_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,guint64,uint64_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gint64,int64_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gint64,int64_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gfloat,float32_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(32,gfloat,float32_be)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gdouble,float64_le)
__GST_BYTE_READER_GET_PEEK_BITS_INLINE(64,gdouble,float64_be)
#undef __GST_BYTE_READER_GET_PEEK_BITS_INLINE
#ifndef GST_BYTE_READER_DISABLE_INLINES
#define gst_byte_reader_get_remaining(reader) \
_gst_byte_reader_get_remaining_inline(reader)
#define gst_byte_reader_get_size(reader) \
_gst_byte_reader_get_size_inline(reader)
#define gst_byte_reader_get_pos(reader) \
_gst_byte_reader_get_pos_inline(reader)
/* we use defines here so we can add the G_LIKELY() */
#define gst_byte_reader_get_uint8(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint8_inline(reader,val))
#define gst_byte_reader_get_int8(reader,val) \
G_LIKELY(_gst_byte_reader_get_int8_inline(reader,val))
#define gst_byte_reader_get_uint16_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint16_le_inline(reader,val))
#define gst_byte_reader_get_int16_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_int16_le_inline(reader,val))
#define gst_byte_reader_get_uint16_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint16_be_inline(reader,val))
#define gst_byte_reader_get_int16_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_int16_be_inline(reader,val))
#define gst_byte_reader_get_uint24_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint24_le_inline(reader,val))
#define gst_byte_reader_get_int24_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_int24_le_inline(reader,val))
#define gst_byte_reader_get_uint24_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint24_be_inline(reader,val))
#define gst_byte_reader_get_int24_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_int24_be_inline(reader,val))
#define gst_byte_reader_get_uint32_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint32_le_inline(reader,val))
#define gst_byte_reader_get_int32_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_int32_le_inline(reader,val))
#define gst_byte_reader_get_uint32_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint32_be_inline(reader,val))
#define gst_byte_reader_get_int32_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_int32_be_inline(reader,val))
#define gst_byte_reader_get_uint64_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint64_le_inline(reader,val))
#define gst_byte_reader_get_int64_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_int64_le_inline(reader,val))
#define gst_byte_reader_get_uint64_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_uint64_be_inline(reader,val))
#define gst_byte_reader_get_int64_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_int64_be_inline(reader,val))
#define gst_byte_reader_peek_uint8(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint8_inline(reader,val))
#define gst_byte_reader_peek_int8(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int8_inline(reader,val))
#define gst_byte_reader_peek_uint16_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint16_le_inline(reader,val))
#define gst_byte_reader_peek_int16_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int16_le_inline(reader,val))
#define gst_byte_reader_peek_uint16_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint16_be_inline(reader,val))
#define gst_byte_reader_peek_int16_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int16_be_inline(reader,val))
#define gst_byte_reader_peek_uint24_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint24_le_inline(reader,val))
#define gst_byte_reader_peek_int24_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int24_le_inline(reader,val))
#define gst_byte_reader_peek_uint24_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint24_be_inline(reader,val))
#define gst_byte_reader_peek_int24_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int24_be_inline(reader,val))
#define gst_byte_reader_peek_uint32_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint32_le_inline(reader,val))
#define gst_byte_reader_peek_int32_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int32_le_inline(reader,val))
#define gst_byte_reader_peek_uint32_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint32_be_inline(reader,val))
#define gst_byte_reader_peek_int32_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int32_be_inline(reader,val))
#define gst_byte_reader_peek_uint64_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint64_le_inline(reader,val))
#define gst_byte_reader_peek_int64_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int64_le_inline(reader,val))
#define gst_byte_reader_peek_uint64_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_uint64_be_inline(reader,val))
#define gst_byte_reader_peek_int64_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_int64_be_inline(reader,val))
#define gst_byte_reader_get_float32_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_float32_le_inline(reader,val))
#define gst_byte_reader_get_float32_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_float32_be_inline(reader,val))
#define gst_byte_reader_get_float64_le(reader,val) \
G_LIKELY(_gst_byte_reader_get_float64_le_inline(reader,val))
#define gst_byte_reader_get_float64_be(reader,val) \
G_LIKELY(_gst_byte_reader_get_float64_be_inline(reader,val))
#define gst_byte_reader_peek_float32_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_float32_le_inline(reader,val))
#define gst_byte_reader_peek_float32_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_float32_be_inline(reader,val))
#define gst_byte_reader_peek_float64_le(reader,val) \
G_LIKELY(_gst_byte_reader_peek_float64_le_inline(reader,val))
#define gst_byte_reader_peek_float64_be(reader,val) \
G_LIKELY(_gst_byte_reader_peek_float64_be_inline(reader,val))
#endif /* GST_BYTE_READER_DISABLE_INLINES */
static inline gboolean
_gst_byte_reader_dup_data_inline (GstByteReader * reader, guint size, guint8 ** val)
{
g_return_val_if_fail (reader != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
if (G_UNLIKELY (size > reader->size || _gst_byte_reader_get_remaining_inline (reader) < size))
return FALSE;
*val = gst_byte_reader_dup_data_unchecked (reader, size);
return TRUE;
}
static inline gboolean
_gst_byte_reader_get_data_inline (GstByteReader * reader, guint size, const guint8 ** val)
{
g_return_val_if_fail (reader != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
if (G_UNLIKELY (size > reader->size || _gst_byte_reader_get_remaining_inline (reader) < size))
return FALSE;
*val = gst_byte_reader_get_data_unchecked (reader, size);
return TRUE;
}
static inline gboolean
_gst_byte_reader_peek_data_inline (const GstByteReader * reader, guint size, const guint8 ** val)
{
g_return_val_if_fail (reader != NULL, FALSE);
g_return_val_if_fail (val != NULL, FALSE);
if (G_UNLIKELY (size > reader->size || _gst_byte_reader_get_remaining_inline (reader) < size))
return FALSE;
*val = gst_byte_reader_peek_data_unchecked (reader);
return TRUE;
}
static inline guint
_gst_byte_reader_get_pos_inline (const GstByteReader * reader)
{
g_return_val_if_fail (reader != NULL, 0);
return _gst_byte_reader_get_pos_unchecked (reader);
}
static inline gboolean
_gst_byte_reader_skip_inline (GstByteReader * reader, guint nbytes)
{
g_return_val_if_fail (reader != NULL, FALSE);
if (G_UNLIKELY (_gst_byte_reader_get_remaining_unchecked (reader) < nbytes))
return FALSE;
reader->byte += nbytes;
return TRUE;
}
#ifndef GST_BYTE_READER_DISABLE_INLINES
#define gst_byte_reader_dup_data(reader,size,val) \
G_LIKELY(_gst_byte_reader_dup_data_inline(reader,size,val))
#define gst_byte_reader_get_data(reader,size,val) \
G_LIKELY(_gst_byte_reader_get_data_inline(reader,size,val))
#define gst_byte_reader_peek_data(reader,size,val) \
G_LIKELY(_gst_byte_reader_peek_data_inline(reader,size,val))
#define gst_byte_reader_skip(reader,nbytes) \
G_LIKELY(_gst_byte_reader_skip_inline(reader,nbytes))
#endif /* GST_BYTE_READER_DISABLE_INLINES */
G_END_DECLS
#endif /* __GST_BYTE_READER_H__ */
@@ -0,0 +1,401 @@
/* GStreamer byte writer
*
* Copyright (C) 2009 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_BYTE_WRITER_H__
#define __GST_BYTE_WRITER_H__
#include <gst/gst.h>
#include <gst/base/gstbytereader.h>
#include <string.h>
G_BEGIN_DECLS
#define GST_BYTE_WRITER(writer) ((GstByteWriter *) (writer))
/**
* GstByteWriter:
* @parent: #GstByteReader parent
* @alloc_size: Allocation size of the data
* @fixed: If %TRUE no reallocations are allowed
* @owned: If %FALSE no reallocations are allowed and copies of data are returned
*
* A byte writer instance.
*/
typedef struct {
GstByteReader parent;
guint alloc_size;
gboolean fixed;
gboolean owned;
/* < private > */
gpointer _gst_reserved[GST_PADDING];
} GstByteWriter;
GstByteWriter * gst_byte_writer_new (void) G_GNUC_MALLOC;
GstByteWriter * gst_byte_writer_new_with_size (guint size, gboolean fixed) G_GNUC_MALLOC;
GstByteWriter * gst_byte_writer_new_with_data (guint8 *data, guint size, gboolean initialized) G_GNUC_MALLOC;
void gst_byte_writer_init (GstByteWriter *writer);
void gst_byte_writer_init_with_size (GstByteWriter *writer, guint size, gboolean fixed);
void gst_byte_writer_init_with_data (GstByteWriter *writer, guint8 *data,
guint size, gboolean initialized);
void gst_byte_writer_free (GstByteWriter *writer);
guint8 * gst_byte_writer_free_and_get_data (GstByteWriter *writer);
GstBuffer * gst_byte_writer_free_and_get_buffer (GstByteWriter *writer) G_GNUC_MALLOC;
void gst_byte_writer_reset (GstByteWriter *writer);
guint8 * gst_byte_writer_reset_and_get_data (GstByteWriter *writer);
GstBuffer * gst_byte_writer_reset_and_get_buffer (GstByteWriter *writer) G_GNUC_MALLOC;
/**
* gst_byte_writer_get_pos:
* @writer: #GstByteWriter instance
*
* Returns: The current position of the read/write cursor
*/
/**
* gst_byte_writer_set_pos:
* @writer: #GstByteWriter instance
* @pos: new position
*
* Sets the current read/write cursor of @writer. The new position
* can only be between 0 and the current size.
*
* Returns: %TRUE if the new position could be set
*/
/**
* gst_byte_writer_get_size:
* @writer: #GstByteWriter instance
*
* Returns: The current, initialized size of the data
*/
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC guint gst_byte_writer_get_pos (const GstByteWriter *writer);
G_INLINE_FUNC gboolean gst_byte_writer_set_pos (GstByteWriter *writer, guint pos);
G_INLINE_FUNC guint gst_byte_writer_get_size (const GstByteWriter *writer);
#else
static inline guint
gst_byte_writer_get_pos (const GstByteWriter *writer)
{
return gst_byte_reader_get_pos ((const GstByteReader *) writer);
}
static inline gboolean
gst_byte_writer_set_pos (GstByteWriter *writer, guint pos)
{
return gst_byte_reader_set_pos (GST_BYTE_READER (writer), pos);
}
static inline guint
gst_byte_writer_get_size (const GstByteWriter *writer)
{
return gst_byte_reader_get_size ((const GstByteReader *) writer);
}
#endif
guint gst_byte_writer_get_remaining (const GstByteWriter *writer);
gboolean gst_byte_writer_ensure_free_space (GstByteWriter *writer, guint size);
gboolean gst_byte_writer_put_uint8 (GstByteWriter *writer, guint8 val);
gboolean gst_byte_writer_put_int8 (GstByteWriter *writer, gint8 val);
gboolean gst_byte_writer_put_uint16_be (GstByteWriter *writer, guint16 val);
gboolean gst_byte_writer_put_uint16_le (GstByteWriter *writer, guint16 val);
gboolean gst_byte_writer_put_int16_be (GstByteWriter *writer, gint16 val);
gboolean gst_byte_writer_put_int16_le (GstByteWriter *writer, gint16 val);
gboolean gst_byte_writer_put_uint24_be (GstByteWriter *writer, guint32 val);
gboolean gst_byte_writer_put_uint24_le (GstByteWriter *writer, guint32 val);
gboolean gst_byte_writer_put_int24_be (GstByteWriter *writer, gint32 val);
gboolean gst_byte_writer_put_int24_le (GstByteWriter *writer, gint32 val);
gboolean gst_byte_writer_put_uint32_be (GstByteWriter *writer, guint32 val);
gboolean gst_byte_writer_put_uint32_le (GstByteWriter *writer, guint32 val);
gboolean gst_byte_writer_put_int32_be (GstByteWriter *writer, gint32 val);
gboolean gst_byte_writer_put_int32_le (GstByteWriter *writer, gint32 val);
gboolean gst_byte_writer_put_uint64_be (GstByteWriter *writer, guint64 val);
gboolean gst_byte_writer_put_uint64_le (GstByteWriter *writer, guint64 val);
gboolean gst_byte_writer_put_int64_be (GstByteWriter *writer, gint64 val);
gboolean gst_byte_writer_put_int64_le (GstByteWriter *writer, gint64 val);
gboolean gst_byte_writer_put_float32_be (GstByteWriter *writer, gfloat val);
gboolean gst_byte_writer_put_float32_le (GstByteWriter *writer, gfloat val);
gboolean gst_byte_writer_put_float64_be (GstByteWriter *writer, gdouble val);
gboolean gst_byte_writer_put_float64_le (GstByteWriter *writer, gdouble val);
gboolean gst_byte_writer_put_data (GstByteWriter *writer, const guint8 *data, guint size);
gboolean gst_byte_writer_fill (GstByteWriter *writer, guint8 value, guint size);
gboolean gst_byte_writer_put_string_utf8 (GstByteWriter *writer, const gchar *data);
gboolean gst_byte_writer_put_string_utf16 (GstByteWriter *writer, const guint16 *data);
gboolean gst_byte_writer_put_string_utf32 (GstByteWriter *writer, const guint32 *data);
gboolean gst_byte_writer_put_buffer (GstByteWriter *writer, GstBuffer * buffer, gsize offset, gssize size);
/**
* gst_byte_writer_put_string:
* @writer: #GstByteWriter instance
* @data: (in) (array zero-terminated=1): Null terminated string
*
* Write a NUL-terminated string to @writer (including the terminator). The
* string is assumed to be in an 8-bit encoding (e.g. ASCII,UTF-8 or
* ISO-8859-1).
*
* Returns: %TRUE if the string could be written
*/
#define gst_byte_writer_put_string(writer, data) \
gst_byte_writer_put_string_utf8(writer, data)
static inline guint
_gst_byte_writer_next_pow2 (guint n)
{
guint ret = 16;
/* We start with 16, smaller allocations make no sense */
while (ret < n && ret > 0)
ret <<= 1;
return ret ? ret : n;
}
static inline gboolean
_gst_byte_writer_ensure_free_space_inline (GstByteWriter * writer, guint size)
{
gpointer data;
if (G_LIKELY (size <= writer->alloc_size - writer->parent.byte))
return TRUE;
if (G_UNLIKELY (writer->fixed || !writer->owned))
return FALSE;
if (G_UNLIKELY (writer->parent.byte > G_MAXUINT - size))
return FALSE;
writer->alloc_size = _gst_byte_writer_next_pow2 (writer->parent.byte + size);
data = g_try_realloc ((guint8 *) writer->parent.data, writer->alloc_size);
if (G_UNLIKELY (data == NULL))
return FALSE;
writer->parent.data = (guint8 *) data;
return TRUE;
}
#define __GST_BYTE_WRITER_CREATE_WRITE_FUNC(bits,type,name,write_func) \
static inline void \
gst_byte_writer_put_##name##_unchecked (GstByteWriter *writer, type val) \
{ \
guint8 *write_data; \
\
write_data = (guint8 *) writer->parent.data + writer->parent.byte; \
write_func (write_data, val); \
writer->parent.byte += bits/8; \
writer->parent.size = MAX (writer->parent.size, writer->parent.byte); \
} \
\
static inline gboolean \
_gst_byte_writer_put_##name##_inline (GstByteWriter *writer, type val) \
{ \
g_return_val_if_fail (writer != NULL, FALSE); \
\
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline(writer, bits/8))) \
return FALSE; \
\
gst_byte_writer_put_##name##_unchecked (writer, val); \
\
return TRUE; \
}
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (8, guint8, uint8, GST_WRITE_UINT8)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (8, gint8, int8, GST_WRITE_UINT8)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (16, guint16, uint16_le, GST_WRITE_UINT16_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (16, guint16, uint16_be, GST_WRITE_UINT16_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (16, gint16, int16_le, GST_WRITE_UINT16_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (16, gint16, int16_be, GST_WRITE_UINT16_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (24, guint32, uint24_le, GST_WRITE_UINT24_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (24, guint32, uint24_be, GST_WRITE_UINT24_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (24, gint32, int24_le, GST_WRITE_UINT24_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (24, gint32, int24_be, GST_WRITE_UINT24_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, guint32, uint32_le, GST_WRITE_UINT32_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, guint32, uint32_be, GST_WRITE_UINT32_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, gint32, int32_le, GST_WRITE_UINT32_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, gint32, int32_be, GST_WRITE_UINT32_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, guint64, uint64_le, GST_WRITE_UINT64_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, guint64, uint64_be, GST_WRITE_UINT64_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, gint64, int64_le, GST_WRITE_UINT64_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, gint64, int64_be, GST_WRITE_UINT64_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, gfloat, float32_be, GST_WRITE_FLOAT_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (32, gfloat, float32_le, GST_WRITE_FLOAT_LE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, gdouble, float64_be, GST_WRITE_DOUBLE_BE)
__GST_BYTE_WRITER_CREATE_WRITE_FUNC (64, gdouble, float64_le, GST_WRITE_DOUBLE_LE)
#undef __GST_BYTE_WRITER_CREATE_WRITE_FUNC
static inline void
gst_byte_writer_put_data_unchecked (GstByteWriter * writer, const guint8 * data,
guint size)
{
memcpy ((guint8 *) & writer->parent.data[writer->parent.byte], data, size);
writer->parent.byte += size;
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
}
static inline gboolean
_gst_byte_writer_put_data_inline (GstByteWriter * writer, const guint8 * data,
guint size)
{
g_return_val_if_fail (writer != NULL, FALSE);
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
return FALSE;
gst_byte_writer_put_data_unchecked (writer, data, size);
return TRUE;
}
static inline void
gst_byte_writer_fill_unchecked (GstByteWriter * writer, guint8 value, guint size)
{
memset ((guint8 *) & writer->parent.data[writer->parent.byte], value, size);
writer->parent.byte += size;
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
}
static inline gboolean
_gst_byte_writer_fill_inline (GstByteWriter * writer, guint8 value, guint size)
{
g_return_val_if_fail (writer != NULL, FALSE);
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
return FALSE;
gst_byte_writer_fill_unchecked (writer, value, size);
return TRUE;
}
static inline void
gst_byte_writer_put_buffer_unchecked (GstByteWriter * writer, GstBuffer * buffer,
gsize offset, gssize size)
{
if (size == -1) {
size = gst_buffer_get_size (buffer);
if (offset >= (gsize) size)
return;
size -= offset;
}
gst_buffer_extract (buffer, offset,
(guint8 *) & writer->parent.data[writer->parent.byte], size);
writer->parent.byte += size;
writer->parent.size = MAX (writer->parent.size, writer->parent.byte);
}
static inline gboolean
_gst_byte_writer_put_buffer_inline (GstByteWriter * writer, GstBuffer * buffer,
gsize offset, gssize size)
{
g_return_val_if_fail (writer != NULL, FALSE);
g_return_val_if_fail (size >= -1, FALSE);
if (size == -1) {
size = gst_buffer_get_size (buffer);
if (offset >= (gsize) size)
return TRUE;
size -= offset;
}
if (G_UNLIKELY (!_gst_byte_writer_ensure_free_space_inline (writer, size)))
return FALSE;
gst_byte_writer_put_buffer_unchecked (writer, buffer, offset, size);
return TRUE;
}
#ifndef GST_BYTE_WRITER_DISABLE_INLINES
/* we use defines here so we can add the G_LIKELY() */
#define gst_byte_writer_ensure_free_space(writer, size) \
G_LIKELY (_gst_byte_writer_ensure_free_space_inline (writer, size))
#define gst_byte_writer_put_uint8(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint8_inline (writer, val))
#define gst_byte_writer_put_int8(writer, val) \
G_LIKELY (_gst_byte_writer_put_int8_inline (writer, val))
#define gst_byte_writer_put_uint16_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint16_be_inline (writer, val))
#define gst_byte_writer_put_uint16_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint16_le_inline (writer, val))
#define gst_byte_writer_put_int16_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_int16_be_inline (writer, val))
#define gst_byte_writer_put_int16_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_int16_le_inline (writer, val))
#define gst_byte_writer_put_uint24_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint24_be_inline (writer, val))
#define gst_byte_writer_put_uint24_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint24_le_inline (writer, val))
#define gst_byte_writer_put_int24_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_int24_be_inline (writer, val))
#define gst_byte_writer_put_int24_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_int24_le_inline (writer, val))
#define gst_byte_writer_put_uint32_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint32_be_inline (writer, val))
#define gst_byte_writer_put_uint32_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint32_le_inline (writer, val))
#define gst_byte_writer_put_int32_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_int32_be_inline (writer, val))
#define gst_byte_writer_put_int32_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_int32_le_inline (writer, val))
#define gst_byte_writer_put_uint64_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint64_be_inline (writer, val))
#define gst_byte_writer_put_uint64_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_uint64_le_inline (writer, val))
#define gst_byte_writer_put_int64_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_int64_be_inline (writer, val))
#define gst_byte_writer_put_int64_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_int64_le_inline (writer, val))
#define gst_byte_writer_put_float32_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_float32_be_inline (writer, val))
#define gst_byte_writer_put_float32_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_float32_le_inline (writer, val))
#define gst_byte_writer_put_float64_be(writer, val) \
G_LIKELY (_gst_byte_writer_put_float64_be_inline (writer, val))
#define gst_byte_writer_put_float64_le(writer, val) \
G_LIKELY (_gst_byte_writer_put_float64_le_inline (writer, val))
#define gst_byte_writer_put_data(writer, data, size) \
G_LIKELY (_gst_byte_writer_put_data_inline (writer, data, size))
#define gst_byte_writer_fill(writer, val, size) \
G_LIKELY (_gst_byte_writer_fill_inline (writer, val, size))
#define gst_byte_writer_put_buffer(writer, buffer, offset, size) \
G_LIKELY (_gst_byte_writer_put_buffer_inline (writer, buffer, offset, size))
#endif
G_END_DECLS
#endif /* __GST_BYTE_WRITER_H__ */
@@ -0,0 +1,358 @@
/* GStreamer
* Copyright (C) 2005 Wim Taymans <wim@fluendo.com>
* Copyright (C) 2008 Mark Nauwelaerts <mnauw@users.sourceforge.net>
*
* gstcollectpads.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_COLLECT_PADS_H__
#define __GST_COLLECT_PADS_H__
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_COLLECT_PADS (gst_collect_pads_get_type())
#define GST_COLLECT_PADS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_COLLECT_PADS,GstCollectPads))
#define GST_COLLECT_PADS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_COLLECT_PADS,GstCollectPadsClass))
#define GST_COLLECT_PADS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_COLLECT_PADS,GstCollectPadsClass))
#define GST_IS_COLLECT_PADS(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_COLLECT_PADS))
#define GST_IS_COLLECT_PADS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_COLLECT_PADS))
typedef struct _GstCollectData GstCollectData;
typedef struct _GstCollectDataPrivate GstCollectDataPrivate;
typedef struct _GstCollectPads GstCollectPads;
typedef struct _GstCollectPadsPrivate GstCollectPadsPrivate;
typedef struct _GstCollectPadsClass GstCollectPadsClass;
/**
* GstCollectDataDestroyNotify:
* @data: the #GstCollectData that will be freed
*
* A function that will be called when the #GstCollectData will be freed.
* It is passed the pointer to the structure and should free any custom
* memory and resources allocated for it.
*/
typedef void (*GstCollectDataDestroyNotify) (GstCollectData *data);
/**
* GstCollectPadsStateFlags:
* @GST_COLLECT_PADS_STATE_EOS: Set if collectdata's pad is EOS.
* @GST_COLLECT_PADS_STATE_FLUSHING: Set if collectdata's pad is flushing.
* @GST_COLLECT_PADS_STATE_NEW_SEGMENT: Set if collectdata's pad received a
* new_segment event.
* @GST_COLLECT_PADS_STATE_WAITING: Set if collectdata's pad must be waited
* for when collecting.
* @GST_COLLECT_PADS_STATE_LOCKED: Set collectdata's pad WAITING state must
* not be changed.
* #GstCollectPadsStateFlags indicate private state of a collectdata('s pad).
*/
typedef enum {
GST_COLLECT_PADS_STATE_EOS = 1 << 0,
GST_COLLECT_PADS_STATE_FLUSHING = 1 << 1,
GST_COLLECT_PADS_STATE_NEW_SEGMENT = 1 << 2,
GST_COLLECT_PADS_STATE_WAITING = 1 << 3,
GST_COLLECT_PADS_STATE_LOCKED = 1 << 4
} GstCollectPadsStateFlags;
/**
* GST_COLLECT_PADS_STATE:
* @data: a #GstCollectData.
*
* A flags word containing #GstCollectPadsStateFlags flags set
* on this collected pad.
*/
#define GST_COLLECT_PADS_STATE(data) (((GstCollectData *) data)->state)
/**
* GST_COLLECT_PADS_STATE_IS_SET:
* @data: a #GstCollectData.
* @flag: the #GstCollectPadsStateFlags to check.
*
* Gives the status of a specific flag on a collected pad.
*/
#define GST_COLLECT_PADS_STATE_IS_SET(data,flag) !!(GST_COLLECT_PADS_STATE (data) & flag)
/**
* GST_COLLECT_PADS_STATE_SET:
* @data: a #GstCollectData.
* @flag: the #GstCollectPadsStateFlags to set.
*
* Sets a state flag on a collected pad.
*/
#define GST_COLLECT_PADS_STATE_SET(data,flag) (GST_COLLECT_PADS_STATE (data) |= flag)
/**
* GST_COLLECT_PADS_STATE_UNSET:
* @data: a #GstCollectData.
* @flag: the #GstCollectPadsStateFlags to clear.
*
* Clears a state flag on a collected pad.
*/
#define GST_COLLECT_PADS_STATE_UNSET(data,flag) (GST_COLLECT_PADS_STATE (data) &= ~(flag))
/**
* GstCollectData:
* @collect: owner #GstCollectPads
* @pad: #GstPad managed by this data
* @buffer: currently queued buffer.
* @pos: position in the buffer
* @segment: last segment received.
*
* Structure used by the collect_pads.
*/
struct _GstCollectData
{
/* with STREAM_LOCK of @collect */
GstCollectPads *collect;
GstPad *pad;
GstBuffer *buffer;
guint pos;
GstSegment segment;
/*< private >*/
/* state: bitfield for easier extension;
* eos, flushing, new_segment, waiting */
GstCollectPadsStateFlags state;
GstCollectDataPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstCollectPadsFunction:
* @pads: the #GstCollectPads that trigered the callback
* @user_data: user data passed to gst_collect_pads_set_function()
*
* A function that will be called when all pads have received data.
*
* Returns: #GST_FLOW_OK for success
*/
typedef GstFlowReturn (*GstCollectPadsFunction) (GstCollectPads *pads, gpointer user_data);
/**
* GstCollectPadsBufferFunction:
* @pads: the #GstCollectPads that trigered the callback
* @data: the #GstCollectData of pad that has received the buffer
* @buffer: (transfer full): the #GstBuffer
* @user_data: user data passed to gst_collect_pads_set_buffer_function()
*
* A function that will be called when a (considered oldest) buffer can be muxed.
* If all pads have reached EOS, this function is called with NULL @buffer
* and NULL @data.
*
* Returns: #GST_FLOW_OK for success
*/
typedef GstFlowReturn (*GstCollectPadsBufferFunction) (GstCollectPads *pads, GstCollectData *data,
GstBuffer *buffer, gpointer user_data);
/**
* GstCollectPadsCompareFunction:
* @pads: the #GstCollectPads that is comparing the timestamps
* @data1: the first #GstCollectData
* @timestamp1: the first timestamp
* @data2: the second #GstCollectData
* @timestamp2: the second timestamp
* @user_data: user data passed to gst_collect_pads_set_compare_function()
*
* A function for comparing two timestamps of buffers or newsegments collected on one pad.
*
* Returns: Integer less than zero when first timestamp is deemed older than the second one.
* Zero if the timestamps are deemed equally old.
* Integer greate than zero when second timestamp is deemed older than the first one.
*/
typedef gint (*GstCollectPadsCompareFunction) (GstCollectPads *pads,
GstCollectData * data1, GstClockTime timestamp1,
GstCollectData * data2, GstClockTime timestamp2,
gpointer user_data);
/**
* GstCollectPadsEventFunction:
* @pads: the #GstCollectPads that trigered the callback
* @pad: the #GstPad that received an event
* @event: the #GstEvent received
* @user_data: user data passed to gst_collect_pads_set_event_function()
*
* A function that will be called while processing an event. It takes
* ownership of the event and is responsible for chaining up (to
* gst_collect_pads_event_default()) or dropping events (such typical cases
* being handled by the default handler).
*
* Returns: %TRUE if the pad could handle the event
*/
typedef gboolean (*GstCollectPadsEventFunction) (GstCollectPads *pads, GstCollectData * pad,
GstEvent * event, gpointer user_data);
/**
* GstCollectPadsQueryFunction:
* @pads: the #GstCollectPads that trigered the callback
* @pad: the #GstPad that received an event
* @query: the #GstEvent received
* @user_data: user data passed to gst_collect_pads_set_query_function()
*
* A function that will be called while processing a query. It takes
* ownership of the query and is responsible for chaining up (to
* events downstream (with gst_pad_event_default()).
*
* Returns: %TRUE if the pad could handle the event
*/
typedef gboolean (*GstCollectPadsQueryFunction) (GstCollectPads *pads, GstCollectData * pad,
GstQuery * query, gpointer user_data);
/**
* GstCollectPadsClipFunction:
* @pads: a #GstCollectPads
* @data: a #GstCollectData
* @inbuffer: (transfer full): the input #GstBuffer
* @outbuffer: the output #GstBuffer
* @user_data: user data
*
* A function that will be called when @inbuffer is received on the pad managed
* by @data in the collecpad object @pads.
*
* The function should use the segment of @data and the negotiated media type on
* the pad to perform clipping of @inbuffer.
*
* This function takes ownership of @inbuffer and should output a buffer in
* @outbuffer or return %NULL in @outbuffer if the buffer should be dropped.
*
* Returns: a #GstFlowReturn that corresponds to the result of clipping.
*/
typedef GstFlowReturn (*GstCollectPadsClipFunction) (GstCollectPads *pads, GstCollectData *data,
GstBuffer *inbuffer, GstBuffer **outbuffer,
gpointer user_data);
/**
* GST_COLLECT_PADS_GET_STREAM_LOCK:
* @pads: a #GstCollectPads
*
* Get the stream lock of @pads. The stream lock is used to coordinate and
* serialize execution among the various streams being collected, and in
* protecting the resources used to accomplish this.
*/
#define GST_COLLECT_PADS_GET_STREAM_LOCK(pads) (&((GstCollectPads *)pads)->stream_lock)
/**
* GST_COLLECT_PADS_STREAM_LOCK:
* @pads: a #GstCollectPads
*
* Lock the stream lock of @pads.
*/
#define GST_COLLECT_PADS_STREAM_LOCK(pads) g_rec_mutex_lock(GST_COLLECT_PADS_GET_STREAM_LOCK (pads))
/**
* GST_COLLECT_PADS_STREAM_UNLOCK:
* @pads: a #GstCollectPads
*
* Unlock the stream lock of @pads.
*/
#define GST_COLLECT_PADS_STREAM_UNLOCK(pads) g_rec_mutex_unlock(GST_COLLECT_PADS_GET_STREAM_LOCK (pads))
/**
* GstCollectPads:
* @data: #GList of #GstCollectData managed by this #GstCollectPads.
*
* Collectpads object.
*/
struct _GstCollectPads {
GstObject object;
/*< public >*/ /* with LOCK and/or STREAM_LOCK */
GSList *data; /* list of CollectData items */
/*< private >*/
GRecMutex stream_lock; /* used to serialize collection among several streams */
GstCollectPadsPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstCollectPadsClass {
GstObjectClass parent_class;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_collect_pads_get_type(void);
/* creating the object */
GstCollectPads* gst_collect_pads_new (void);
/* set the callbacks */
void gst_collect_pads_set_function (GstCollectPads *pads,
GstCollectPadsFunction func,
gpointer user_data);
void gst_collect_pads_set_buffer_function (GstCollectPads *pads,
GstCollectPadsBufferFunction func,
gpointer user_data);
void gst_collect_pads_set_event_function (GstCollectPads *pads,
GstCollectPadsEventFunction func,
gpointer user_data);
void gst_collect_pads_set_query_function (GstCollectPads *pads,
GstCollectPadsQueryFunction func,
gpointer user_data);
void gst_collect_pads_set_compare_function (GstCollectPads *pads,
GstCollectPadsCompareFunction func,
gpointer user_data);
void gst_collect_pads_set_clip_function (GstCollectPads *pads,
GstCollectPadsClipFunction clipfunc,
gpointer user_data);
/* pad management */
GstCollectData* gst_collect_pads_add_pad (GstCollectPads *pads, GstPad *pad, guint size,
GstCollectDataDestroyNotify destroy_notify,
gboolean lock);
gboolean gst_collect_pads_remove_pad (GstCollectPads *pads, GstPad *pad);
/* start/stop collection */
void gst_collect_pads_start (GstCollectPads *pads);
void gst_collect_pads_stop (GstCollectPads *pads);
void gst_collect_pads_set_flushing (GstCollectPads *pads, gboolean flushing);
/* get collected buffers */
GstBuffer* gst_collect_pads_peek (GstCollectPads *pads, GstCollectData *data);
GstBuffer* gst_collect_pads_pop (GstCollectPads *pads, GstCollectData *data);
/* get collected bytes */
guint gst_collect_pads_available (GstCollectPads *pads);
guint gst_collect_pads_flush (GstCollectPads *pads, GstCollectData *data,
guint size);
GstBuffer* gst_collect_pads_read_buffer (GstCollectPads * pads, GstCollectData * data,
guint size);
GstBuffer* gst_collect_pads_take_buffer (GstCollectPads * pads, GstCollectData * data,
guint size);
/* setting and unsetting waiting mode */
void gst_collect_pads_set_waiting (GstCollectPads *pads, GstCollectData *data,
gboolean waiting);
/* convenience helper */
GstFlowReturn gst_collect_pads_clip_running_time (GstCollectPads * pads,
GstCollectData * cdata,
GstBuffer * buf, GstBuffer ** outbuf,
gpointer user_data);
/* default handlers */
gboolean gst_collect_pads_event_default (GstCollectPads * pads, GstCollectData * data,
GstEvent * event, gboolean discard);
gboolean gst_collect_pads_query_default (GstCollectPads * pads, GstCollectData * data,
GstQuery * query, gboolean discard);
G_END_DECLS
#endif /* __GST_COLLECT_PADS_H__ */
@@ -0,0 +1,73 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000 Wim Taymans <wtay@chello.be>
* 2005 Wim Taymans <wim@fluendo.com>
*
* gstpushsrc.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_PUSH_SRC_H__
#define __GST_PUSH_SRC_H__
#include <gst/gst.h>
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#define GST_TYPE_PUSH_SRC (gst_push_src_get_type())
#define GST_PUSH_SRC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_PUSH_SRC,GstPushSrc))
#define GST_PUSH_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_PUSH_SRC,GstPushSrcClass))
#define GST_PUSH_SRC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PUSH_SRC, GstPushSrcClass))
#define GST_IS_PUSH_SRC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_PUSH_SRC))
#define GST_IS_PUSH_SRC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_PUSH_SRC))
typedef struct _GstPushSrc GstPushSrc;
typedef struct _GstPushSrcClass GstPushSrcClass;
/**
* GstPushSrc:
*
* The opaque #GstPushSrc data structure.
*/
struct _GstPushSrc {
GstBaseSrc parent;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
struct _GstPushSrcClass {
GstBaseSrcClass parent_class;
/* ask the subclass to create a buffer, the default implementation
* uses alloc and fill */
GstFlowReturn (*create) (GstPushSrc *src, GstBuffer **buf);
/* allocate memory for a buffer */
GstFlowReturn (*alloc) (GstPushSrc *src, GstBuffer **buf);
/* ask the subclass to fill a buffer */
GstFlowReturn (*fill) (GstPushSrc *src, GstBuffer *buf);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_push_src_get_type(void);
G_END_DECLS
#endif /* __GST_PUSH_SRC_H__ */
@@ -0,0 +1,77 @@
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) 2000,2005 Wim Taymans <wim@fluendo.com>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
*
* gsttypefindhelper.h:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_TYPEFINDHELPER_H__
#define __GST_TYPEFINDHELPER_H__
#include <gst/gst.h>
G_BEGIN_DECLS
GstCaps * gst_type_find_helper (GstPad *src, guint64 size);
GstCaps * gst_type_find_helper_for_data (GstObject *obj,
const guint8 *data,
gsize size,
GstTypeFindProbability *prob);
GstCaps * gst_type_find_helper_for_buffer (GstObject *obj,
GstBuffer *buf,
GstTypeFindProbability *prob);
GstCaps * gst_type_find_helper_for_extension (GstObject * obj,
const gchar * extension);
/**
* GstTypeFindHelperGetRangeFunction:
* @obj: a #GstObject that will handle the getrange request
* @parent: the parent of @obj or NULL
* @offset: the offset of the range
* @length: the length of the range
* @buffer: a memory location to hold the result buffer
*
* This function will be called by gst_type_find_helper_get_range() when
* typefinding functions request to peek at the data of a stream at certain
* offsets. If this function returns GST_FLOW_OK, the result buffer will be
* stored in @buffer. The contents of @buffer is invalid for any other
* return value.
*
* This function is supposed to behave exactly like a #GstPadGetRangeFunction.
*
* Returns: GST_FLOW_OK for success
*/
typedef GstFlowReturn (*GstTypeFindHelperGetRangeFunction) (GstObject *obj,
GstObject *parent,
guint64 offset,
guint length,
GstBuffer **buffer);
GstCaps * gst_type_find_helper_get_range (GstObject *obj,
GstObject *parent,
GstTypeFindHelperGetRangeFunction func,
guint64 size,
const gchar *extension,
GstTypeFindProbability *prob);
G_END_DECLS
#endif /* __GST_TYPEFINDHELPER_H__ */