Original commit message from CVS:
* gst/base/gsttypefindhelper.c:
* gst/gsttypefind.c:
* gst/gsttypefind.h:
This commit is contained in:
Edward Hervey 2005-11-09 16:44:40 +00:00
parent 5151ea3d9b
commit 04b5f119c6
5 changed files with 69 additions and 26 deletions

View file

@ -1,3 +1,10 @@
2005-11-09 Edward Hervey <edward@fluendo.com>
* gst/base/gsttypefindhelper.c:
* gst/gsttypefind.c:
* gst/gsttypefind.h:
2005-11-09 Wim Taymans <wim@fluendo.com> 2005-11-09 Wim Taymans <wim@fluendo.com>
* gst/gstiterator.c: * gst/gstiterator.c:

View file

@ -125,6 +125,17 @@ helper_find_suggest (gpointer data, guint probability, const GstCaps * caps)
} }
} }
/**
* gst_type_find_helper:
* @src: A source #GstPad
* @size: The length in bytes
*
* Tries to find what type of data is flowing from the given source #GstPad.
*
* Returns: The #GstCaps corresponding to the data stream.
* Returns #NULL if no #GstCaps matches the data stream.
*/
GstCaps * GstCaps *
gst_type_find_helper (GstPad * src, guint64 size) gst_type_find_helper (GstPad * src, guint64 size)
{ {

View file

@ -23,6 +23,10 @@
* SECTION:gsttypefind * SECTION:gsttypefind
* @short_description: Stream type detection * @short_description: Stream type detection
* *
* The following functions allow you to detect the media type of an unknown
* stream.
*
* Last reviewed on 2005-11-09 (0.9.4)
*/ */
#include "gst_private.h" #include "gst_private.h"
@ -36,13 +40,13 @@ GST_DEBUG_CATEGORY_EXTERN (gst_type_find_debug);
/** /**
* gst_type_find_register: * gst_type_find_register:
* @plugin: the GstPlugin to register with * @plugin: A #GstPlugin.
* @name: the name for registering * @name: The name for registering
* @rank: rank (or importance) of this typefind function * @rank: The rank (or importance) of this typefind function
* @func: the function to use for typefinding * @func: The #GstTypeFindFunction to use
* @extensions: optional extensions that could belong to this type * @extensions: Optional extensions that could belong to this type
* @possible_caps: optionally the caps that could be returned when typefinding succeeds * @possible_caps: Optionally the caps that could be returned when typefinding succeeds
* @data: optional user data. This user data must be available until the plugin * @data: Optional user data. This user data must be available until the plugin
* is unloaded. * is unloaded.
* *
* Registers a new typefind function to be used for typefinding. After * Registers a new typefind function to be used for typefinding. After
@ -90,18 +94,17 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
/** /**
* gst_type_find_peek: * gst_type_find_peek:
* @find: the find object the function was called with * @find: The #GstTypeFind object the function was called with
* @offset: the offset * @offset: The offset
* @size: the number of bytes to return * @size: The number of bytes to return
* *
* Returns size bytes of the stream to identify beginning at offset. If offset * Returns the @size bytes of the stream to identify beginning at offset. If
* is a positive number, the offset is relative to the beginning of the stream, * offset is a positive number, the offset is relative to the beginning of the
* if offset is a negative number the offset is relative to the end of the * stream, if offset is a negative number the offset is relative to the end of
* stream. The returned memory is valid until the typefinding function returns * the stream. The returned memory is valid until the typefinding function
* and must not be freed. * returns and must not be freed.
* If NULL is returned, that data is not available.
* *
* Returns: the requested data or NULL if that data is not available. * Returns: the requested data, or NULL if that data is not available.
*/ */
guint8 * guint8 *
gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size) gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
@ -113,14 +116,14 @@ gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
/** /**
* gst_type_find_suggest: * gst_type_find_suggest:
* @find: the find object the function was called with * @find: The #GstTypeFind object the function was called with
* @probability: the probability in percent that the suggestion is right * @probability: The probability in percent that the suggestion is right
* @caps: the fixed caps to suggest * @caps: The fixed #GstCaps to suggest
* *
* If a typefind function calls this function it suggests the caps with the * If a #GstTypeFindFunction calls this function it suggests the caps with the
* given probability. A typefind function may supply different suggestions * given probability. A #GstTypeFindFunction may supply different suggestions
* in one call. * in one call.
* It is up to the caller of the typefind function to interpret these values. * It is up to the caller of the #GstTypeFindFunction to interpret these values.
*/ */
void void
gst_type_find_suggest (GstTypeFind * find, guint probability, gst_type_find_suggest (GstTypeFind * find, guint probability,
@ -136,11 +139,11 @@ gst_type_find_suggest (GstTypeFind * find, guint probability,
/** /**
* gst_type_find_get_length: * gst_type_find_get_length:
* @find: the find object the function was called with * @find: The #GstTypeFind the function was called with
* *
* Get the length of the data stream. * Get the length of the data stream.
* *
* Returns: the length of the data stream or 0 if it is not available. * Returns: The length of the data stream, or 0 if it is not available.
*/ */
guint64 guint64
gst_type_find_get_length (GstTypeFind * find) gst_type_find_get_length (GstTypeFind * find)

View file

@ -31,6 +31,13 @@ G_BEGIN_DECLS
typedef struct _GstTypeFind GstTypeFind; typedef struct _GstTypeFind GstTypeFind;
/**
* GstTypeFindFunction:
* @find: A #GstTypeFind structure
* @data: optionnal data to pass to the function
*
* A function that will be called by typefinding.
*/
typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer data); typedef void (* GstTypeFindFunction) (GstTypeFind *find, gpointer data);
typedef enum { typedef enum {
@ -43,8 +50,12 @@ typedef enum {
/** /**
* GstTypeFind: * GstTypeFind:
* @peek: Method to peek data.
* @suggest: Method to suggest #GstCaps with a given probability.
* @data: The data used by the caller of the typefinding function.
* @get_length: Returns the length of current data.
* *
* Object that stores typefind callbacks. * Object that stores typefind callbacks. To use with #GstTypeFindFactory.
*/ */
struct _GstTypeFind { struct _GstTypeFind {
/* private to the caller of the typefind function */ /* private to the caller of the typefind function */

View file

@ -125,6 +125,17 @@ helper_find_suggest (gpointer data, guint probability, const GstCaps * caps)
} }
} }
/**
* gst_type_find_helper:
* @src: A source #GstPad
* @size: The length in bytes
*
* Tries to find what type of data is flowing from the given source #GstPad.
*
* Returns: The #GstCaps corresponding to the data stream.
* Returns #NULL if no #GstCaps matches the data stream.
*/
GstCaps * GstCaps *
gst_type_find_helper (GstPad * src, guint64 size) gst_type_find_helper (GstPad * src, guint64 size)
{ {