# GstSample

A GstSample is a small object containing data, a type, timing and extra arbitrary information.

## GstSample

The opaque structure of a GstSample. A sample contains a typed memory block and the associated timing information. It is mainly used to exchange buffers with an application.

## Gst.Sample

The opaque structure of a Gst.Sample. A sample contains a typed memory block and the associated timing information. It is mainly used to exchange buffers with an application.

## Gst.Sample

The opaque structure of a Gst.Sample. A sample contains a typed memory block and the associated timing information. It is mainly used to exchange buffers with an application.

### Constructors

#### gst_sample_new

    GstSample *
    gst_sample_new (GstBuffer * buffer,
                    GstCaps * caps,
                    const GstSegment * segment,
                    GstStructure * info)

Create a new GstSample with the provided details.

Free-function: gst_sample_unref

Parameters:

`buffer` ( [transfer: none][allow-none] ) –

a GstBuffer, or NULL

`caps` ( [transfer: none][allow-none] ) –

a GstCaps, or NULL

`segment` ( [transfer: none][allow-none] ) –

a GstSegment, or NULL

`info` ( [transfer: full][allow-none] ) –

a GstStructure, or NULL

Returns ( [transfer: full] ) –

the new GstSample. gst_sample_unref after usage.

#### Gst.Sample.prototype.new

    function Gst.Sample.prototype.new(buffer: Gst.Buffer, caps: Gst.Caps, segment: Gst.Segment, info: Gst.Structure): {
        // javascript wrapper for 'gst_sample_new'
    }

Create a new Gst.Sample with the provided details.

Free-function: gst_sample_unref

Parameters:

`buffer` ( Gst.Buffer ) –

a Gst.Buffer, or null

`caps` ( Gst.Caps ) –

a Gst.Caps, or null

`segment` ( Gst.Segment ) –

a Gst.Segment, or null

`info` ( Gst.Structure ) –

a Gst.Structure, or null

Returns ( Gst.Sample ) –

the new Gst.Sample. gst_sample_unref (not introspectable) after usage.

#### Gst.Sample.new

    def Gst.Sample.new (buffer, caps, segment, info):
        #python wrapper for 'gst_sample_new'

Create a new Gst.Sample with the provided details.

Free-function: gst_sample_unref

Parameters:

`buffer` ( Gst.Buffer ) –

a Gst.Buffer, or None

`caps` ( Gst.Caps ) –

a Gst.Caps, or None

`segment` ( Gst.Segment ) –

a Gst.Segment, or None

`info` ( Gst.Structure ) –

a Gst.Structure, or None

Returns ( Gst.Sample ) –

the new Gst.Sample. gst_sample_unref (not introspectable) after usage.

### Methods

#### gst_sample_copy

    GstSample *
    gst_sample_copy (const GstSample * buf)

Create a copy of the given sample. This will also make a newly allocated copy of the data the source sample contains.

Parameters:

`buf` –

a GstSample.

Returns ( [transfer: full] ) –

a new copy of buf.

Since : 1.2

#### gst_sample_get_buffer

    GstBuffer *
    gst_sample_get_buffer (GstSample * sample)

Get the buffer associated with sample

Parameters:

`sample` –

a GstSample

Returns ( [transfer: none][nullable] ) –

the buffer of sample or NULL when there is no buffer. The buffer remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer with gst_buffer_ref.

#### Gst.Sample.prototype.get_buffer

    function Gst.Sample.prototype.get_buffer(): {
        // javascript wrapper for 'gst_sample_get_buffer'
    }

Get the buffer associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Buffer ) –

the buffer of sample or null when there is no buffer. The buffer remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer with gst_buffer_ref (not introspectable).

#### Gst.Sample.get_buffer

    def Gst.Sample.get_buffer (self):
        #python wrapper for 'gst_sample_get_buffer'

Get the buffer associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Buffer ) –

the buffer of sample or None when there is no buffer. The buffer remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer with gst_buffer_ref (not introspectable).

#### gst_sample_get_buffer_list

    GstBufferList *
    gst_sample_get_buffer_list (GstSample * sample)

Get the buffer list associated with sample

Parameters:

`sample` –

a GstSample

Returns ( [transfer: none][nullable] ) –

the buffer list of sample or NULL when there is no buffer list. The buffer list remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer list with gst_mini_object_ref ().

Since : 1.6

#### Gst.Sample.prototype.get_buffer_list

    function Gst.Sample.prototype.get_buffer_list(): {
        // javascript wrapper for 'gst_sample_get_buffer_list'
    }

Get the buffer list associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.BufferList ) –

the buffer list of sample or null when there is no buffer list. The buffer list remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer list with gst_mini_object_ref ().

Since : 1.6

#### Gst.Sample.get_buffer_list

    def Gst.Sample.get_buffer_list (self):
        #python wrapper for 'gst_sample_get_buffer_list'

Get the buffer list associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.BufferList ) –

the buffer list of sample or None when there is no buffer list. The buffer list remains valid as long as sample is valid. If you need to hold on to it for longer than that, take a ref to the buffer list with gst_mini_object_ref ().

Since : 1.6

#### gst_sample_get_caps

    GstCaps *
    gst_sample_get_caps (GstSample * sample)

Get the caps associated with sample

Parameters:

`sample` –

a GstSample

Returns ( [transfer: none][nullable] ) –

the caps of sample or NULL when there is no caps. The caps remain valid as long as sample is valid. If you need to hold on to the caps for longer than that, take a ref to the caps with gst_caps_ref.

#### Gst.Sample.prototype.get_caps

    function Gst.Sample.prototype.get_caps(): {
        // javascript wrapper for 'gst_sample_get_caps'
    }

Get the caps associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Caps ) –

the caps of sample or null when there is no caps. The caps remain valid as long as sample is valid. If you need to hold on to the caps for longer than that, take a ref to the caps with gst_caps_ref (not introspectable).

#### Gst.Sample.get_caps

    def Gst.Sample.get_caps (self):
        #python wrapper for 'gst_sample_get_caps'

Get the caps associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Caps ) –

the caps of sample or None when there is no caps. The caps remain valid as long as sample is valid. If you need to hold on to the caps for longer than that, take a ref to the caps with gst_caps_ref (not introspectable).

#### gst_sample_get_info

    const GstStructure *
    gst_sample_get_info (GstSample * sample)

Get extra information associated with sample.

Parameters:

`sample` –

a GstSample

Returns ( [transfer: none][nullable] ) –

the extra info of sample. The info remains valid as long as sample is valid.

#### Gst.Sample.prototype.get_info

    function Gst.Sample.prototype.get_info(): {
        // javascript wrapper for 'gst_sample_get_info'
    }

Get extra information associated with sample.

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Structure ) –

the extra info of sample. The info remains valid as long as sample is valid.

#### Gst.Sample.get_info

    def Gst.Sample.get_info (self):
        #python wrapper for 'gst_sample_get_info'

Get extra information associated with sample.

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Structure ) –

the extra info of sample. The info remains valid as long as sample is valid.

#### gst_sample_get_segment

    GstSegment *
    gst_sample_get_segment (GstSample * sample)

Get the segment associated with sample

Parameters:

`sample` –

a GstSample

Returns ( [transfer: none] ) –

the segment of sample. The segment remains valid as long as sample is valid.

#### Gst.Sample.prototype.get_segment

    function Gst.Sample.prototype.get_segment(): {
        // javascript wrapper for 'gst_sample_get_segment'
    }

Get the segment associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Segment ) –

the segment of sample. The segment remains valid as long as sample is valid.

#### Gst.Sample.get_segment

    def Gst.Sample.get_segment (self):
        #python wrapper for 'gst_sample_get_segment'

Get the segment associated with sample

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

Returns ( Gst.Segment ) –

the segment of sample. The segment remains valid as long as sample is valid.

#### gst_sample_ref

    GstSample *
    gst_sample_ref (GstSample * sample)

Increases the refcount of the given sample by one.

Parameters:

`sample` –

a GstSample

Returns ( [transfer: full] ) –

sample

#### gst_sample_set_buffer

    gst_sample_set_buffer (GstSample * sample,
                           GstBuffer * buffer)

Set the buffer associated with sample. sample must be writable.

Parameters:

`sample` –

A GstSample

`buffer` ( [transfer: none] ) –

A GstBuffer

Since : 1.16

#### Gst.Sample.prototype.set_buffer

    function Gst.Sample.prototype.set_buffer(buffer: Gst.Buffer): {
        // javascript wrapper for 'gst_sample_set_buffer'
    }

Set the buffer associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`buffer` ( Gst.Buffer ) –

A Gst.Buffer

Since : 1.16

#### Gst.Sample.set_buffer

    def Gst.Sample.set_buffer (self, buffer):
        #python wrapper for 'gst_sample_set_buffer'

Set the buffer associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`buffer` ( Gst.Buffer ) –

A Gst.Buffer

Since : 1.16

#### gst_sample_set_buffer_list

    gst_sample_set_buffer_list (GstSample * sample,
                                GstBufferList * buffer_list)

Set the buffer list associated with sample. sample must be writable.

Parameters:

`sample` –

a GstSample

`buffer_list` –

a GstBufferList

Since : 1.6

#### Gst.Sample.prototype.set_buffer_list

    function Gst.Sample.prototype.set_buffer_list(buffer_list: Gst.BufferList): {
        // javascript wrapper for 'gst_sample_set_buffer_list'
    }

Set the buffer list associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

`buffer_list` ( Gst.BufferList ) –

a Gst.BufferList

Since : 1.6

#### Gst.Sample.set_buffer_list

    def Gst.Sample.set_buffer_list (self, buffer_list):
        #python wrapper for 'gst_sample_set_buffer_list'

Set the buffer list associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

a Gst.Sample

`buffer_list` ( Gst.BufferList ) –

a Gst.BufferList

Since : 1.6

#### gst_sample_set_caps

    gst_sample_set_caps (GstSample * sample,
                         GstCaps * caps)

Set the caps associated with sample. sample must be writable.

Parameters:

`sample` –

A GstSample

`caps` ( [transfer: none] ) –

A GstCaps

Since : 1.16

#### Gst.Sample.prototype.set_caps

    function Gst.Sample.prototype.set_caps(caps: Gst.Caps): {
        // javascript wrapper for 'gst_sample_set_caps'
    }

Set the caps associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`caps` ( Gst.Caps ) –

A Gst.Caps

Since : 1.16

#### Gst.Sample.set_caps

    def Gst.Sample.set_caps (self, caps):
        #python wrapper for 'gst_sample_set_caps'

Set the caps associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`caps` ( Gst.Caps ) –

A Gst.Caps

Since : 1.16

#### gst_sample_set_info

    gboolean
    gst_sample_set_info (GstSample * sample,
                         GstStructure * info)

Set the info structure associated with sample. sample must be writable, and info must not have a parent set already.

Parameters:

`sample` –

A GstSample

`info` ( [transfer: full] ) –

A GstStructure

Returns –
No description available

Since : 1.16

#### Gst.Sample.prototype.set_info

    function Gst.Sample.prototype.set_info(info: Gst.Structure): {
        // javascript wrapper for 'gst_sample_set_info'
    }

Set the info structure associated with sample. sample must be writable, and info must not have a parent set already.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`info` ( Gst.Structure ) –

A Gst.Structure

Returns ( Number ) –
No description available

Since : 1.16

#### Gst.Sample.set_info

    def Gst.Sample.set_info (self, info):
        #python wrapper for 'gst_sample_set_info'

Set the info structure associated with sample. sample must be writable, and info must not have a parent set already.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`info` ( Gst.Structure ) –

A Gst.Structure

Returns ( bool ) –
No description available

Since : 1.16

#### gst_sample_set_segment

    gst_sample_set_segment (GstSample * sample,
                            const GstSegment * segment)

Set the segment associated with sample. sample must be writable.

Parameters:

`sample` –

A GstSample

`segment` ( [transfer: none] ) –

A GstSegment

Since : 1.16

#### Gst.Sample.prototype.set_segment

    function Gst.Sample.prototype.set_segment(segment: Gst.Segment): {
        // javascript wrapper for 'gst_sample_set_segment'
    }

Set the segment associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`segment` ( Gst.Segment ) –

A Gst.Segment

Since : 1.16

#### Gst.Sample.set_segment

    def Gst.Sample.set_segment (self, segment):
        #python wrapper for 'gst_sample_set_segment'

Set the segment associated with sample. sample must be writable.

Parameters:

`sample` ( Gst.Sample ) –

A Gst.Sample

`segment` ( Gst.Segment ) –

A Gst.Segment

Since : 1.16

#### gst_sample_unref

    gst_sample_unref (GstSample * sample)

Decreases the refcount of the sample. If the refcount reaches 0, the sample will be freed.

Parameters:

`sample` ( [transfer: full] ) –

a GstSample

## Function Macros

### GST_IS_SAMPLE

    #define GST_IS_SAMPLE(obj)   (GST_IS_MINI_OBJECT_TYPE(obj, GST_TYPE_SAMPLE))

### GST_SAMPLE

    #define GST_SAMPLE(obj)      (GST_SAMPLE_CAST(obj))

### GST_SAMPLE_CAST

    #define GST_SAMPLE_CAST(obj) ((GstSample *)obj)

### gst_sample_is_writable

    #define gst_sample_is_writable(sample)     gst_mini_object_is_writable (GST_MINI_OBJECT_CAST (sample))

Tests if you can safely set the buffer and / or buffer list of sample.

Parameters:

`sample` –

A GstSample

### gst_sample_make_writable

    #define gst_sample_make_writable(sample)   GST_SAMPLE_CAST (gst_mini_object_make_writable (GST_MINI_OBJECT_CAST (sample)))

Returns a writable copy of sample. If the source sample is already writable, this will simply return the same sample.

Use this function to ensure that a sample can be safely modified before making changes to it, for example before calling gst_sample_set_buffer

If the reference count of the source sample sample is exactly one, the caller is the sole owner and this function will return the sample object unchanged.

If there is more than one reference on the object, a copy will be made using gst_sample_copy. The passed-in sample will be unreffed in that case, and the caller will now own a reference to the new returned sample object.

In short, this function unrefs the sample in the argument and refs the sample that it returns. Don't access the argument after calling this function unless you have an additional reference to it.

Parameters:

`sample` ( [transfer: full] ) –

A GstSample

Returns ( [transfer: full] ) –

a writable sample which may or may not be the same as sample

### gst_value_get_sample

    #define gst_value_get_sample(v)         GST_SAMPLE_CAST (g_value_get_boxed(v))

Receives a GstSample as the value of v. Does not return a reference to the sample, so the pointer is only valid for as long as the caller owns a reference to v.

Parameters:

`v` –

a GValue to query

Returns ( [transfer: none] ) –

sample

### gst_value_set_sample

    #define gst_value_set_sample(v,b)       g_value_set_boxed((v),(b))

Sets b as the value of v. Caller retains reference to sample.

Parameters:

`v` –

a GValue to receive the data

`b` ( [transfer: none] ) –

a GstSample to assign to the GstValue

### gst_value_take_sample

    #define gst_value_take_sample(v,b)      g_value_take_boxed(v,(b))

Sets b as the value of v. Caller gives away reference to sample.

Parameters:

`v` –

a GValue to receive the data

`b` ( [transfer: full] ) –

a GstSample to assign to the GstValue

## Constants

### GST_TYPE_SAMPLE

    #define GST_TYPE_SAMPLE      (_gst_sample_type)

The results of the search are