# GstTagDemux

Provides a base class for demuxing tags at the beginning or end of a stream and handles things like typefinding, querying, seeking, and different modes of operation (chain-based, pull_range-based, and providing downstream elements with random access if upstream supports that). The tag is stripped from the output, and all offsets are adjusted for the tag sizes, so that to the downstream element the stream will appear as if there was no tag at all. Also, once the tag has been parsed, GstTagDemux will try to determine the media type of the resulting stream and add a source pad with the appropriate caps in order to facilitate auto-plugging.

## Deriving from GstTagDemux

Subclasses have to do four things:

- In their base init function, they must add a pad template for the sink pad to the element class, describing the media type they can parse in the caps of the pad template.
- In their class init function, they must override GST_TAG_DEMUX_CLASS(demux_klass)->identify_tag with their own identify function.
- In their class init function, they must override GST_TAG_DEMUX_CLASS(demux_klass)->parse_tag with their own parse function.
- In their class init function, they must also set GST_TAG_DEMUX_CLASS(demux_klass)->min_start_size and/or GST_TAG_DEMUX_CLASS(demux_klass)->min_end_size to the minimum size required for the identify function to decide whether the stream has a supported tag or not. A class parsing ID3v1 tags, for example, would set min_end_size to 128 bytes.

## GstTagDemux

    GObject
        ╰──GInitiallyUnowned
            ╰──GstObject
                ╰──GstElement
                    ╰──GstTagDemux

Opaque GstTagDemux structure.

### Members

`element` (GstElement) –

parent element

### Class structure

#### GstTagDemuxClass

The GstTagDemuxClass structure. See documentation at beginning of section for details about what subclasses need to override and do.

##### Fields

`parent_class` (GstElementClass) –

the parent class.

`min_start_size` (guint) –

minimum size required to identify a tag at the start and determine its total size. Set to 0 if not interested in start tags. Subclasses should set this in their class_init function.

`min_end_size` (guint) –

minimum size required to identify a tag at the end and determine its total size. Set to 0 if not interested in end tags. Subclasses should set this in their class_init function.

### GstTag.TagDemuxClass

The GstTag.TagDemuxClass structure. See documentation at beginning of section for details about what subclasses need to override and do.

##### Attributes

`parent_class` (Gst.ElementClass) –

the parent class.

`min_start_size` (Number) –

minimum size required to identify a tag at the start and determine its total size. Set to 0 if not interested in start tags. Subclasses should set this in their class_init function.

`min_end_size` (Number) –

minimum size required to identify a tag at the end and determine its total size. Set to 0 if not interested in end tags. Subclasses should set this in their class_init function.

### GstTag.TagDemuxClass

The GstTag.TagDemuxClass structure. See documentation at beginning of section for details about what subclasses need to override and do.

##### Attributes

`parent_class` (Gst.ElementClass) –

the parent class.

`min_start_size` (int) –

minimum size required to identify a tag at the start and determine its total size. Set to 0 if not interested in start tags. Subclasses should set this in their class_init function.

`min_end_size` (int) –

minimum size required to identify a tag at the end and determine its total size. Set to 0 if not interested in end tags. Subclasses should set this in their class_init function.

## GstTag.TagDemux

    GObject.Object
        ╰──GObject.InitiallyUnowned
            ╰──Gst.Object
                ╰──Gst.Element
                    ╰──GstTag.TagDemux

Opaque GstTag.TagDemux structure.

### Members

`element` (Gst.Element) –

parent element

## GstTag.TagDemux

    GObject.Object
        ╰──GObject.InitiallyUnowned
            ╰──Gst.Object
                ╰──Gst.Element
                    ╰──GstTag.TagDemux

Opaque GstTag.TagDemux structure.

### Members

`element` (Gst.Element) –

parent element

### Virtual Methods

#### identify_tag

    gboolean
    identify_tag (GstTagDemux * demux,
                  GstBuffer * buffer,
                  gboolean start_tag,
                  guint* tag_size)

identify tag and determine the size required to parse the tag. Buffer may be larger than the specified minimum size. Subclassed MUST override this vfunc in their class_init function.

Parameters:

`demux` –
No description available
`buffer` –
No description available
`start_tag` –
No description available
`tag_size` –
No description available
Returns –
No description available

#### vfunc_identify_tag

    function vfunc_identify_tag(demux: GstTag.TagDemux, buffer: Gst.Buffer, start_tag: Number, tag_size: Number): {
        // javascript implementation of the 'identify_tag' virtual method
    }

identify tag and determine the size required to parse the tag. Buffer may be larger than the specified minimum size. Subclassed MUST override this vfunc in their class_init function.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`buffer` (Gst.Buffer) –
No description available
`start_tag` (Number) –
No description available
`tag_size` (Number) –
No description available
Returns (Number) –
No description available

#### do_identify_tag

    def do_identify_tag (demux, buffer, start_tag, tag_size):
        #python implementation of the 'identify_tag' virtual method

identify tag and determine the size required to parse the tag. Buffer may be larger than the specified minimum size. Subclassed MUST override this vfunc in their class_init function.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`buffer` (Gst.Buffer) –
No description available
`start_tag` (bool) –
No description available
`tag_size` (int) –
No description available
Returns (bool) –
No description available

#### merge_tags

    GstTagList *
    merge_tags (GstTagDemux * demux,
                const GstTagList * start_tags,
                const GstTagList * end_tags)

merge start and end tags. Subclasses may want to override this vfunc to allow prioritising of start or end tag according to user preference. Note that both start_tags and end_tags may be NULL. By default start tags are preferred over end tags.

Parameters:

`demux` –
No description available
`start_tags` –
No description available
`end_tags` –
No description available
Returns –
No description available

#### vfunc_merge_tags

    function vfunc_merge_tags(demux: GstTag.TagDemux, start_tags: Gst.TagList, end_tags: Gst.TagList): {
        // javascript implementation of the 'merge_tags' virtual method
    }

merge start and end tags. Subclasses may want to override this vfunc to allow prioritising of start or end tag according to user preference. Note that both start_tags and end_tags may be NULL. By default start tags are preferred over end tags.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`start_tags` (Gst.TagList) –
No description available
`end_tags` (Gst.TagList) –
No description available
Returns (Gst.TagList) –
No description available

#### do_merge_tags

    def do_merge_tags (demux, start_tags, end_tags):
        #python implementation of the 'merge_tags' virtual method

merge start and end tags. Subclasses may want to override this vfunc to allow prioritising of start or end tag according to user preference. Note that both start_tags and end_tags may be NULL. By default start tags are preferred over end tags.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`start_tags` (Gst.TagList) –
No description available
`end_tags` (Gst.TagList) –
No description available
Returns (Gst.TagList) –
No description available

#### parse_tag

    GstTagDemuxResult
    parse_tag (GstTagDemux * demux,
               GstBuffer * buffer,
               gboolean start_tag,
               guint* tag_size,
               GstTagList ** tags)

parse the tag. Buffer will be exactly of the size determined by the identify_tag vfunc before. The parse_tag vfunc may change the size stored in *tag_size and return GST_TAG_DEMUX_RESULT_AGAIN to request a larger or smaller buffer. It is also permitted to adjust the tag_size to a smaller value and then return GST_TAG_DEMUX_RESULT_OK in one go. Subclassed MUST override the parse_tag vfunc in their class_init function.

Parameters:

`demux` –
No description available
`buffer` –
No description available
`start_tag` –
No description available
`tag_size` –
No description available
`tags` –
No description available
Returns –
No description available

#### vfunc_parse_tag

    function vfunc_parse_tag(demux: GstTag.TagDemux, buffer: Gst.Buffer, start_tag: Number, tag_size: Number, tags: Gst.TagList): {
        // javascript implementation of the 'parse_tag' virtual method
    }

parse the tag. Buffer will be exactly of the size determined by the identify_tag vfunc before. The parse_tag vfunc may change the size stored in *tag_size and return GST_TAG_DEMUX_RESULT_AGAIN to request a larger or smaller buffer. It is also permitted to adjust the tag_size to a smaller value and then return GST_TAG_DEMUX_RESULT_OK in one go. Subclassed MUST override the parse_tag vfunc in their class_init function.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`buffer` (Gst.Buffer) –
No description available
`start_tag` (Number) –
No description available
`tag_size` (Number) –
No description available
`tags` (Gst.TagList) –
No description available
Returns (GstTag.TagDemuxResult) –
No description available

#### do_parse_tag

    def do_parse_tag (demux, buffer, start_tag, tag_size, tags):
        #python implementation of the 'parse_tag' virtual method

parse the tag. Buffer will be exactly of the size determined by the identify_tag vfunc before. The parse_tag vfunc may change the size stored in *tag_size and return GST_TAG_DEMUX_RESULT_AGAIN to request a larger or smaller buffer. It is also permitted to adjust the tag_size to a smaller value and then return GST_TAG_DEMUX_RESULT_OK in one go. Subclassed MUST override the parse_tag vfunc in their class_init function.

Parameters:

`demux` (GstTag.TagDemux) –
No description available
`buffer` (Gst.Buffer) –
No description available
`start_tag` (bool) –
No description available
`tag_size` (int) –
No description available
`tags` (Gst.TagList) –
No description available
Returns (GstTag.TagDemuxResult) –
No description available

## Enumerations

### GstTagDemuxResult

Result values from the parse_tag virtual function.

##### Members

`GST_TAG_DEMUX_RESULT_BROKEN_TAG` (0) –

cannot parse tag, just skip it

`GST_TAG_DEMUX_RESULT_AGAIN` (1) –

call again with less or more data

`GST_TAG_DEMUX_RESULT_OK` (2) –

parsed tag successfully

### GstTag.TagDemuxResult

Result values from the parse_tag virtual function.

##### Members

`GstTag.TagDemuxResult.BROKEN_TAG` (0) –

cannot parse tag, just skip it

`GstTag.TagDemuxResult.AGAIN` (1) –

call again with less or more data

`GstTag.TagDemuxResult.OK` (2) –

parsed tag successfully

### GstTag.TagDemuxResult

Result values from the parse_tag virtual function.

##### Members

`GstTag.TagDemuxResult.BROKEN_TAG` (0) –

cannot parse tag, just skip it

`GstTag.TagDemuxResult.AGAIN` (1) –

call again with less or more data

`GstTag.TagDemuxResult.OK` (2) –

parsed tag successfully

The results of the search are