anbox-platform-sdk  1.28.0
Anbox Platform SDK API documentation
anbox::Platform Class Referenceabstract

Platform defines the custom Anbox platform implemented by a plugin. More...

#include <platform.h>

+ Collaboration diagram for anbox::Platform:

Public Member Functions

 Platform ()=default
 
virtual ~Platform ()=default
 
 Platform (const Platform &)=delete
 
Platformoperator= (const Platform &)=delete
 
virtual AudioProcessoraudio_processor ()=0
 Retrieve the platform audio processor instance. More...
 
virtual InputProcessorinput_processor ()=0
 Retrieve the platform input processor instance. More...
 
virtual GraphicsProcessorgraphics_processor ()
 Retrieve the platform graphics processor instance. More...
 
virtual SensorProcessorsensor_processor ()
 Retrieve the platform sensor processor instance. More...
 
virtual GpsProcessorgps_processor ()
 Retrieve the platform gps processor instance. More...
 
virtual CameraProcessorcamera_processor ()
 Retrieve the platform camera processor instance. More...
 
virtual AnboxProxyanbox_proxy ()
 Retrieve the platform anbox proxy. More...
 
virtual VideoDecodercreate_video_decoder (AnboxVideoCodecType codec_type)
 Create a video decoder instances for a codec of the given name. More...
 
virtual VhalConnectorvhal_connector ()
 Retrieve the platform vhal connector instance. More...
 
virtual bool ready () const =0
 Query the platform for its ready status. More...
 
virtual int wait_until_ready ()=0
 Wait for platform plugin to be initialized. More...
 
virtual int get_config_item (AnboxPlatformConfigurationKey key, void *data, size_t data_size)=0
 Retrieve the configuration options provided by the platform plugin. More...
 
virtual int stop ()
 Ask the platform to stop any pending work it has to prepare for Anbox to terminate. More...
 
virtual void handle_event (AnboxEventType type)
 Handle an event sending from Anbox. More...
 
virtual int set_config_item (AnboxPlatformConfigurationKey key, void *data, size_t data_size)
 Set the configuration options by Anbox to the platform. More...
 
virtual int set_config_items (const AnboxPlatformConfigurationItem *items, size_t count)
 Set multiple configuration options to the platform in a single transaction. More...
 
virtual void setup_event_tracer (AnboxTracerGetCategoryEnabledFunc get_category_enabled_callback, AnboxTracerAddEventFunc add_event_callback)
 Register an external event tracing implementation withe platform. More...
 

Detailed Description

Platform defines the custom Anbox platform implemented by a plugin.

It supports the following features:

  • Process the audio data that is passed by Anbox from the Anroid container.
  • Delivery of input events to the Android container.
  • Loading a custom Open GL ES/EGL driver implementation.

Definition at line 45 of file platform.h.

Constructor & Destructor Documentation

◆ Platform() [1/2]

anbox::Platform::Platform ( )
default

◆ ~Platform()

virtual anbox::Platform::~Platform ( )
virtualdefault

◆ Platform() [2/2]

anbox::Platform::Platform ( const Platform )
delete

Member Function Documentation

◆ anbox_proxy()

virtual AnboxProxy* anbox::Platform::anbox_proxy ( )
inlinevirtual

Retrieve the platform anbox proxy.

A platform is supposed to have only a single anbox proxy instance at all time.

Returns
a valid AnboxProxy instance, otherwise NULL when an error occured. or the platform does not support to handle the system behavior change via callbacks.

Definition at line 128 of file platform.h.

◆ audio_processor()

virtual AudioProcessor* anbox::Platform::audio_processor ( )
pure virtual

Retrieve the platform audio processor instance.

A platform is supposed to have only a single audio processor instance at all time.

Returns
a valid AudioProcessor instance, otherwise NULL when an error occured or the platform does not support audio processing.

◆ camera_processor()

virtual CameraProcessor* anbox::Platform::camera_processor ( )
inlinevirtual

Retrieve the platform camera processor instance.

A platform is supposed to have only a single camera processor instance at all time.

Returns
a valid CameraProcessor instance, otherwise NULL when an error occured. or the platform does not support posting a video frame to a camera application running in Android container.

Definition at line 118 of file platform.h.

◆ create_video_decoder()

virtual VideoDecoder* anbox::Platform::create_video_decoder ( AnboxVideoCodecType  codec_type)
inlinevirtual

Create a video decoder instances for a codec of the given name.

Returns
a valid VideoDecoder instance, otherwise NULL when an error occurred or if video decoding is not supported by the platform.

Definition at line 136 of file platform.h.

◆ get_config_item()

virtual int anbox::Platform::get_config_item ( AnboxPlatformConfigurationKey  key,
void *  data,
size_t  data_size 
)
pure virtual

Retrieve the configuration options provided by the platform plugin.

This function provides a way for Anbox to read a specific configuration option from the plugin.

Parameters
keyPlugin configuration option key to retrieve.
dataPointer to the buffer where the configuration value will be stored.
data_sizeSize in bytes of the memory buffer data points to.
Returns
0 on success, or a negative error code on failure. Possible codes include:
  • -EINVAL: Invalid arguments supplied (e.g., data is nullptr).
  • -ENOENT: The component of the platform plugin identified by key does not exist.
  • -ENOMEM: The buffer provided via data_size is not large enough to hold the value.
  • -EIO: An I/O error occurred while retrieving the value from the platform backend.
  • -EFAULT: An internal error occurred when accessing the configuration memory.

◆ gps_processor()

virtual GpsProcessor* anbox::Platform::gps_processor ( )
inlinevirtual

Retrieve the platform gps processor instance.

A platform is supposed to have only a single gps processor instance at all time.

Returns
a valid SensorProcessor instance, otherwise NULL when an error occured. or the platform does not support gps processing.

Definition at line 106 of file platform.h.

◆ graphics_processor()

virtual GraphicsProcessor* anbox::Platform::graphics_processor ( )
inlinevirtual

Retrieve the platform graphics processor instance.

A platform is supposed to have only a single graphics processor instance at all time. Providing a graphics processor is not mandatory for a platform.

Returns
a valid GraphicsProcessor instance, otherwise NULL when an error occured. or the platform does not support graphics processing.

Definition at line 84 of file platform.h.

◆ handle_event()

virtual void anbox::Platform::handle_event ( AnboxEventType  type)
inlinevirtual

Handle an event sending from Anbox.

Some operations (E.g. trigger an action) or initialization routine of a platform may require Android container fully booted or all essential components of Anbox are fully initialized.

This enables a platform to get notified when an event was fired from Anbox and perform one specific operation when a certain event is received.

Definition at line 213 of file platform.h.

◆ input_processor()

virtual InputProcessor* anbox::Platform::input_processor ( )
pure virtual

Retrieve the platform input processor instance.

A platform is supposed to have only a single input processor instance at all time.

Returns
a valid InputProcessor instance, otherwise NULL when an error occured. or the platform does not support input processing.

◆ operator=()

Platform& anbox::Platform::operator= ( const Platform )
delete

◆ ready()

virtual bool anbox::Platform::ready ( ) const
pure virtual

Query the platform for its ready status.

A platform is supposed to have different status during initialization

Returns
true if the platform is fully initialized, otherwise false.

◆ sensor_processor()

virtual SensorProcessor* anbox::Platform::sensor_processor ( )
inlinevirtual

Retrieve the platform sensor processor instance.

A platform is supposed to have only a single sensor processor instance at all time.

Returns
a valid SensorProcessor instance, otherwise NULL when an error occured. or the platform does not support sensor processing.

Definition at line 95 of file platform.h.

◆ set_config_item()

virtual int anbox::Platform::set_config_item ( AnboxPlatformConfigurationKey  key,
void *  data,
size_t  data_size 
)
inlinevirtual

Set the configuration options by Anbox to the platform.

This function provides a way for Anbox to write a configuration option to the plugin.

Parameters
keyPlugin configuration option key.
dataPointer stores the address of the configuration key value. If nullptr is provided along with a data_size of 0, the platform should reset the configuration item to its default value.
data_sizeSize in bytes of the memory the data pointer points to. Must be 0 when data is nullptr for a reset operation.
Returns
0 on success, a negative error code otherwise. Possible codes include:
  • -EINVAL: Invalid arguments supplied.
  • -ENOMEM: The buffer provided via data_size is not large enough to hold the value.
  • -EIO: An I/O error occurred while communicating with the platform plugin.
  • -EFAULT: An internal error occurred when handling configuration item.

Definition at line 232 of file platform.h.

◆ set_config_items()

virtual int anbox::Platform::set_config_items ( const AnboxPlatformConfigurationItem items,
size_t  count 
)
inlinevirtual

Set multiple configuration options to the platform in a single transaction.

This function allows setting multiple configuration items simultaneously. It is particularly useful for updating interdependent parameters (e.g., min and max video bitrates) where individual updates might fail due to temporary validation inconsistencies.

Parameters
itemsPointer to an array of AnboxPlatformConfigurationItem structures. Each item in the array follows the same reset logic as set_config_item: if an item has its data field set to nullptr and data_size set to 0, that specific configuration item should be reset to its default value.
countThe number of configuration items in the items array.
Returns
0 on success, or a negative error code on failure. Possible error codes include: -EINVAL: If any provided argument is invalid or if the combined configuration logic is inconsistent. -ENOMEM: If the provided data size for an item is incorrect or memory allocation fails. -EIO: If the platform fails to apply the configuration.
Note
Implementation should guarantee atomicity: if any single item in the batch fails validation or application, no changes from the entire batch should be applied.

Definition at line 263 of file platform.h.

◆ setup_event_tracer()

virtual void anbox::Platform::setup_event_tracer ( AnboxTracerGetCategoryEnabledFunc  get_category_enabled_callback,
AnboxTracerAddEventFunc  add_event_callback 
)
inlinevirtual

Register an external event tracing implementation withe platform.

Parameters
get_category_enabled_callbackCallback the platform can use to determine if a certain tracing category is enabled
add_event_callbackCallback to submit a tracing event to the Anbox runtime

Definition at line 275 of file platform.h.

◆ stop()

virtual int anbox::Platform::stop ( )
inlinevirtual

Ask the platform to stop any pending work it has to prepare for Anbox to terminate.

Anbox will wait for the function to return before it finishes its termination process. The function is called very early on before the Android container is stopped.

The platform is expected to stop its processors and don't provide any further data to Anbox. Any further data provided to Anbox after the function has returned will not be considered.

Returns
0 on success, a negative error code otherwise. Possible is -EINVAL (invalid arguments supplied).

Definition at line 202 of file platform.h.

◆ vhal_connector()

virtual VhalConnector* anbox::Platform::vhal_connector ( )
inlinevirtual

Retrieve the platform vhal connector instance.

A platform is supposed to have only a single vhal connector instance at all time.

Returns
a valid VhalConnector instance, otherwise NULL when an error occured, or the platform does not support connecting to the vhal service running in Android container.

Definition at line 151 of file platform.h.

◆ wait_until_ready()

virtual int anbox::Platform::wait_until_ready ( )
pure virtual

Wait for platform plugin to be initialized.

This function allows the caller to wait until the plugin platform has fully initialized all internal components. Once the platform plugin reports it is ready Anbox will start the Android container.

Returns
0 on success, a negative error code otherwise.

The documentation for this class was generated from the following file: