anbox-platform-sdk  1.23.0
Anbox Platform SDK API documentation
platform.h
Go to the documentation of this file.
1 /*
2  * This file is part of Anbox Platform SDK
3  *
4  * Copyright 2021 Canonical Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #ifndef ANBOX_PLATFORM_SDK_PLATFORM_H_
20 #define ANBOX_PLATFORM_SDK_PLATFORM_H_
21 
34 
35 namespace anbox {
36 
45 class Platform {
46  public:
47  Platform() = default;
48  virtual ~Platform() = default;
49  Platform(const Platform &) = delete;
50  Platform& operator=(const Platform &) = delete;
51 
62 
73 
84  virtual GraphicsProcessor* graphics_processor() { return nullptr; }
85 
95  virtual SensorProcessor* sensor_processor() { return nullptr; }
96 
106  virtual GpsProcessor* gps_processor() { return nullptr; }
107 
118  virtual CameraProcessor* camera_processor() { return nullptr; }
119 
128  virtual AnboxProxy* anbox_proxy() { return &anbox_proxy_; }
129 
137  (void) codec_type;
138  return nullptr;
139  }
140 
151  virtual VhalConnector* vhal_connector() { return &vhal_connector_; }
152 
160  virtual bool ready() const = 0;
161 
170  virtual int wait_until_ready() = 0;
171 
183  virtual int get_config_item(AnboxPlatformConfigurationKey key, void* data, size_t data_size) = 0;
184 
198  virtual int stop() { return 0; }
199 
209  virtual void handle_event(AnboxEventType type) { (void)type; }
210 
223  virtual int set_config_item(AnboxPlatformConfigurationKey key, void* data, size_t data_size) {
224  (void)key;
225  (void)data;
226  (void)data_size;
227  return 0;
228  }
229 
236  virtual void setup_event_tracer(
237  AnboxTracerGetCategoryEnabledFunc get_category_enabled_callback,
238  AnboxTracerAddEventFunc add_event_callback) {
239  (void) get_category_enabled_callback;
240  (void) add_event_callback;
241  }
242 
243  private:
244  AnboxProxy anbox_proxy_;
245  VhalConnector vhal_connector_;
246 };
247 }
248 
262 #define ANBOX_PLATFORM_PLUGIN_DESCRIBE(platform_type, name, vendor, description) \
263  AnboxPlatformDescriptor anbox_platform_descriptor __attribute((section(ANBOX_PLATFORM_DESCRIPTOR_SECTION))) = \
264  { name, vendor, description, ANBOX_PLATFORM_VERSION }; \
265 extern "C" { \
266  ANBOX_EXPORT AnboxPlatform* anbox_initialize(const AnboxPlatformConfiguration* configuration) { \
267  auto platform = std::make_unique<platform_type>(configuration); \
268  return anbox_platform_plugin_register(std::move(platform)); \
269  } \
270  ANBOX_EXPORT void anbox_deinitialize(AnboxPlatform* platform) { \
271  anbox_platform_plugin_unregister(platform); \
272  } \
273 }
274 #endif
AnboxProxy provides a proxy layer which encapsulates callbacks that can be used by a platform to chan...
Definition: anbox_proxy.h:65
AudioProcessor allows processing audio data from the Android container and perform audio processing l...
CameraProcessor allows a plugin to respond to the camera actions triggered from Anobx and post video ...
GpsProcessor allows forwarding the gps data from platform plugin to Android container and process gps...
Definition: gps_processor.h:38
GraphicsProcessor allows integration with the graphics engine inside Anbox.
InputProcessor allows a plugin to propagate input events to Anbox which will forward them to the Andr...
Platform defines the custom Anbox platform implemented by a plugin.
Definition: platform.h:45
virtual InputProcessor * input_processor()=0
Retrieve the platform input processor instance.
virtual AnboxProxy * anbox_proxy()
Retrieve the platform anbox proxy.
Definition: platform.h:128
Platform()=default
virtual CameraProcessor * camera_processor()
Retrieve the platform camera processor instance.
Definition: platform.h:118
virtual GpsProcessor * gps_processor()
Retrieve the platform gps processor instance.
Definition: platform.h:106
virtual GraphicsProcessor * graphics_processor()
Retrieve the platform graphics processor instance.
Definition: platform.h:84
virtual void handle_event(AnboxEventType type)
Handle an event sending from Anbox.
Definition: platform.h:209
virtual bool ready() const =0
Query the platform for its ready status.
virtual AudioProcessor * audio_processor()=0
Retrieve the platform audio processor instance.
virtual VideoDecoder * create_video_decoder(AnboxVideoCodecType codec_type)
Create a video decoder instances for a codec of the given name.
Definition: platform.h:136
virtual ~Platform()=default
virtual int wait_until_ready()=0
Wait for platform plugin to be initialized.
virtual VhalConnector * vhal_connector()
Retrieve the platform vhal connector instance.
Definition: platform.h:151
virtual int get_config_item(AnboxPlatformConfigurationKey key, void *data, size_t data_size)=0
Retrieve the configuration options provided by platform plugin.
Platform & operator=(const Platform &)=delete
virtual int set_config_item(AnboxPlatformConfigurationKey key, void *data, size_t data_size)
Set the configuration options by Anbox to the platform.
Definition: platform.h:223
Platform(const Platform &)=delete
virtual void setup_event_tracer(AnboxTracerGetCategoryEnabledFunc get_category_enabled_callback, AnboxTracerAddEventFunc add_event_callback)
Register an external event tracing implementation withe platform.
Definition: platform.h:236
virtual SensorProcessor * sensor_processor()
Retrieve the platform sensor processor instance.
Definition: platform.h:95
virtual int stop()
Ask the platform to stop any pending work it has to prepare for Anbox to terminate.
Definition: platform.h:198
SensorProcessor allows processing sensor events from the Android container and perform sensor process...
Connects a platform with the Android VHAL interface. The platform can invoke the callbacks which are ...
Provides access to a video decoder which will be used by both Anbox and the Android instance for hard...
Definition: video_decoder.h:29
AnboxPlatformConfigurationKey
AnboxPlatformConfigurationKey specifies configuration items which allow to influence the behavior and...
Definition: types.h:458
AnboxVideoCodecType
AnboxVideoCodecType describes the type of a video codec.
Definition: types.h:1593
const unsigned char *(* AnboxTracerGetCategoryEnabledFunc)(const char *name)
Method prototype which will be used to determine if the given tracing category is enabled for tracing...
Definition: types.h:1650
void(* AnboxTracerAddEventFunc)(char phase, const unsigned char *category, const char *name, unsigned long long id, int num_args, const char **arg_names, const unsigned char *arg_types, const unsigned long long *arg_values, unsigned char flags)
Method prototype which will be used by the platform to submit trace events to the tracing implementat...
Definition: types.h:1690
AnboxEventType
AnboxEventType describes the type of event sent from Anbox.
Definition: types.h:668