AppStreamCompose.Media

g AppStreamCompose.Media AppStreamCompose.Media GObject.Object GObject.Object GObject.Object->AppStreamCompose.Media

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

ensure_worker (cancellable)

get_memory_limit ()

get_request_timeout ()

process_image (source, targets, out_dir, cancellable)

set_memory_limit (limit_mib)

set_request_timeout (seconds)

stop ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class AppStreamCompose.Media(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

AppStreamCompose.MediaClass

classmethod new()
Return type:

AppStreamCompose.Media

Creates a new AppStreamCompose.Media.

Added in version 1.2.0.

ensure_worker(cancellable)
Parameters:

cancellable (Gio.Cancellable or None) – a Gio.Cancellable, or None

Raises:

GLib.Error

Returns:

True if the worker is running.

Return type:

bool

Ensure a media worker process is running, spawning one if necessary. This function is called implicitly by all media operations, calling it explicitly is only useful to make worker startup problems surface early.

Added in version 1.2.0.

get_memory_limit()
Return type:

int

Get the address space limit applied to the worker process in MiB, or 0 if the worker may use as much memory as it wants.

Added in version 1.2.0.

get_request_timeout()
Return type:

int

Get the request timeout in seconds.

Added in version 1.2.0.

process_image(source, targets, out_dir, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

True if the image was processed.

Return type:

bool

Load an image (in the media worker process) and store an arbitrary set of scaled renditions of it in the given output directory. The directory is created if it does not exist yet.

On success, the dimensions the source image was loaded at are recorded in source, and the result fields of all targets are updated. Individual renditions may still have failed - this is recorded in their error message and does not affect the return value of this function.

Cancelling this operation terminates the media worker process, as its pending reply would otherwise desynchronize the next request. A fresh worker is spawned automatically for the next operation.

Added in version 1.2.0.

set_memory_limit(limit_mib)
Parameters:

limit_mib (int) – Address space limit for the worker process in MiB, 0 for no limit.

Limit the amount of memory the worker process may use. The limit is applied when the next worker process is spawned.

Added in version 1.2.0.

set_request_timeout(seconds)
Parameters:

seconds (int) – New timeout in seconds, 0 for no timeout.

Set the time a single media operation may take before the worker is assumed to hang and gets killed.

Added in version 1.2.0.

stop()

Stop the worker process of this instance, if it is running. A new worker will be spawned automatically if another media operation is requested.

Added in version 1.2.0.