## GstTypeFindHelper GstTypeFindHelper — Utility functions for typefinding |

## Functions

GstCaps * | gst_type_find_helper ()
GstCaps * | gst_type_find_helper_for_buffer ()
GstCaps * | gst_type_find_helper_for_buffer_with_extension ()
GstCaps * | gst_type_find_helper_for_extension ()
GstCaps * | gst_type_find_helper_for_data ()
GstCaps * | gst_type_find_helper_for_data_with_extension ()
GstFlowReturn | (*GstTypeFindHelperGetRangeFunction) ()
GstCaps * | gst_type_find_helper_get_range ()

## Includes

    #include <gst/base/base.h>

## Description

Utility functions for elements doing typefinding: `gst_type_find_helper()` does typefinding in pull mode, while `gst_type_find_helper_for_buffer()` is useful for elements needing to do typefinding in push mode from a chain function.

## Functions

### gst_type_find_helper ()

    GstCaps *
    gst_type_find_helper (GstPad *src,
                          guint64 size);

Tries to find what type of data is flowing from the given source GstPad.

Free-function: gst_caps_unref

#### Parameters

src | A source GstPad |
size | The length in bytes |

#### Returns

the GstCaps corresponding to the data stream. Returns `NULL` if no GstCaps matches the data stream.

[transfer full][nullable]

### gst_type_find_helper_for_buffer ()

    GstCaps *
    gst_type_find_helper_for_buffer (GstObject *obj,
                                     GstBuffer *buf,
                                     GstTypeFindProbability *prob);

Tries to find what type of data is contained in the given GstBuffer, the assumption being that the buffer represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of `GST_TYPE_FIND_MAXIMUM`, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or `NULL` if the content of the buffer could not be identified.

Free-function: gst_caps_unref

#### Parameters

obj | object doing the typefinding, or `NULL` (used for logging). | [allow-none]
buf | a GstBuffer with data to typefind. | [in][transfer none]
prob | location to store the probability of the found caps, or `NULL`. | [out][allow-none]

#### Returns

the GstCaps corresponding to the data, or `NULL` if no type could be found. The caller should free the caps returned with `gst_caps_unref()`.

[transfer full][nullable]

### gst_type_find_helper_for_buffer_with_extension ()

    GstCaps *
    gst_type_find_helper_for_buffer_with_extension
                                   (GstObject *obj,
                                    GstBuffer *buf,
                                    const gchar *extension,
                                    GstTypeFindProbability *prob);

Tries to find what type of data is contained in the given GstBuffer, the assumption being that the buffer represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of `GST_TYPE_FIND_MAXIMUM`, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or `NULL` if the content of the buffer could not be identified.

When `extension` is not `NULL`, this function will first try the typefind functions for the given extension, which might speed up the typefinding in many cases.

Free-function: gst_caps_unref

#### Parameters

obj | object doing the typefinding, or `NULL` (used for logging). | [allow-none]
buf | a GstBuffer with data to typefind. | [in][transfer none]
extension | extension of the media, or `NULL`. | [allow-none]
prob | location to store the probability of the found caps, or `NULL`. | [out][allow-none]

#### Returns

the GstCaps corresponding to the data, or `NULL` if no type could be found. The caller should free the caps returned with `gst_caps_unref()`.

[transfer full][nullable]

Since: 1.16

### gst_type_find_helper_for_extension ()

    GstCaps *
    gst_type_find_helper_for_extension (GstObject *obj,
                                        const gchar *extension);

Tries to find the best GstCaps associated with `extension` .

All available typefinders will be checked against the extension in order of rank. The caps of the first typefinder that can handle `extension` will be returned.

Free-function: gst_caps_unref

#### Parameters

obj | object doing the typefinding, or `NULL` (used for logging). | [allow-none]
extension | an extension |

#### Returns

the GstCaps corresponding to `extension` , or `NULL` if no type could be found. The caller should free the caps returned with `gst_caps_unref()`.

[transfer full][nullable]

### gst_type_find_helper_for_data ()

    GstCaps *
    gst_type_find_helper_for_data (GstObject *obj,
                                   const guint8 *data,
                                   gsize size,
                                   GstTypeFindProbability *prob);

Tries to find what type of data is contained in the given `data` , the assumption being that the data represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of `GST_TYPE_FIND_MAXIMUM`, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or `NULL` if the content of `data` could not be identified.

Free-function: gst_caps_unref

#### Parameters

obj | object doing the typefinding, or `NULL` (used for logging). | [allow-none]
data | a pointer with data to typefind. | [transfer none][array length=size]
size | the size of `data` |
prob | location to store the probability of the found caps, or `NULL`. | [out][allow-none]

#### Returns

the GstCaps corresponding to the data, or `NULL` if no type could be found. The caller should free the caps returned with `gst_caps_unref()`.

[transfer full][nullable]

### gst_type_find_helper_for_data_with_extension ()

    GstCaps *
    gst_type_find_helper_for_data_with_extension
                                   (GstObject *obj,
                                    const guint8 *data,
                                    gsize size,
                                    const gchar *extension,
                                    GstTypeFindProbability *prob);

Tries to find what type of data is contained in the given `data` , the assumption being that the data represents the beginning of the stream or file.

All available typefinders will be called on the data in order of rank. If a typefinding function returns a probability of `GST_TYPE_FIND_MAXIMUM`, typefinding is stopped immediately and the found caps will be returned right away. Otherwise, all available typefind functions will the tried, and the caps with the highest probability will be returned, or `NULL` if the content of `data` could not be identified.

When `extension` is not `NULL`, this function will first try the typefind functions for the given extension, which might speed up the typefinding in many cases.

Free-function: gst_caps_unref

#### Parameters

obj | object doing the typefinding, or `NULL` (used for logging). | [allow-none]
data | a pointer with data to typefind. | [transfer none][array length=size]
size | the size of `data` |
extension | extension of the media, or `NULL`. | [allow-none]
prob | location to store the probability of the found caps, or `NULL`. | [out][allow-none]

#### Returns

the GstCaps corresponding to the data, or `NULL` if no type could be found. The caller should free the caps returned with `gst_caps_unref()`.

[transfer full][nullable]

Since: 1.16

### GstTypeFindHelperGetRangeFunction ()

    GstFlowReturn
    (*GstTypeFindHelperGetRangeFunction) (GstObject *obj,
                                          GstObject *parent,
                                          guint64 offset,
                                          guint length,
                                          GstBuffer **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.

#### Parameters

obj | a GstObject that will handle the getrange request |
parent | the parent of `obj` or `NULL`. | [allow-none]
offset | the offset of the range |
length | the length of the range |
buffer | a memory location to hold the result buffer. | [out]

#### Returns

GST_FLOW_OK for success

### gst_type_find_helper_get_range ()

    GstCaps *
    gst_type_find_helper_get_range (GstObject *obj,
                                    GstObject *parent,
                                    GstTypeFindHelperGetRangeFunction func,
                                    guint64 size,
                                    const gchar *extension,
                                    GstTypeFindProbability *prob);

Utility function to do pull-based typefinding. Unlike `gst_type_find_helper()` however, this function will use the specified function `func` to obtain the data needed by the typefind functions, rather than operating on a given source pad. This is useful mostly for elements like tag demuxers which strip off data at the beginning and/or end of a file and want to typefind the stripped data stream before adding their own source pad (the specified callback can then call the upstream peer pad with offsets adjusted for the tag size, for example).

When `extension` is not `NULL`, this function will first try the typefind functions for the given extension, which might speed up the typefinding in many cases.

Free-function: gst_caps_unref

#### Parameters

obj | A GstObject that will be passed as first argument to `func` |
parent | the parent of `obj` or `NULL`. | [allow-none]
func | A generic GstTypeFindHelperGetRangeFunction that will be used to access data at random offsets when doing the typefinding. | [scope call]
size | The length in bytes |
extension | extension of the media, or `NULL`. | [allow-none]
prob | location to store the probability of the found caps, or `NULL`. | [out][allow-none]

#### Returns

the GstCaps corresponding to the data stream. Returns `NULL` if no GstCaps matches the data stream.

[transfer full][nullable]

## Types and Values