Sample#

class Sample(**kwargs)#

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

Constructors#

class Sample
classmethod new(buffer: Buffer | None = None, caps: Caps | None = None, segment: Segment | None = None, info: Structure | None = None) Sample#

Create a new Sample with the provided details.

Free-function: gst_sample_unref

Parameters:

Methods#

class Sample
get_buffer() Buffer | None#

Get the buffer associated with sample

get_buffer_list() BufferList | None#

Get the buffer list associated with sample

Added in version 1.6.

get_caps() Caps | None#

Get the caps associated with sample

get_info() Structure | None#

Get extra information associated with sample.

get_segment() Segment#

Get the segment associated with sample

is_writable() bool#

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

Added in version 1.16.

make_writable() 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 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 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.

Added in version 1.16.

set_buffer(buffer: Buffer) None#

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

Added in version 1.16.

Parameters:

buffer – A Buffer

set_buffer_list(buffer_list: BufferList) None#

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

Added in version 1.6.

Parameters:

buffer_list – a BufferList

set_caps(caps: Caps) None#

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

Added in version 1.16.

Parameters:

caps – A Caps

set_info(info: Structure) bool#

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

Added in version 1.16.

Parameters:

info – A Structure

set_segment(segment: Segment) None#

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

Added in version 1.16.

Parameters:

segment – A Segment