anbox-platform-sdk  1.23.0
Anbox Platform SDK API documentation
public_api.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_SDK_INTERNAL_PUBLIC_API_H_
20 #define ANBOX_SDK_INTERNAL_PUBLIC_API_H_
21 
23 
32 typedef AnboxPlatform* (*AnboxInitializePlatformFunc)(const AnboxPlatformConfiguration* configuration);
33 
42 typedef void (*AnboxReleasePlatformFunc)(AnboxPlatform* platform);
43 
52 typedef const AnboxAudioProcessor* (*AnboxPlatformGetAudioProcessorFunc)(const AnboxPlatform* platform);
53 
62 typedef const AnboxInputProcessor* (*AnboxPlatformGetInputProcessorFunc)(const AnboxPlatform* platform);
63 
72 typedef const AnboxGraphicsProcessor* (*AnboxPlatformGetGraphicsProcessorFunc)(const AnboxPlatform* platform);
73 
82 typedef const AnboxSensorProcessor* (*AnboxPlatformGetSensorProcessorFunc)(const AnboxPlatform* platform);
83 
92 typedef const AnboxGpsProcessor* (*AnboxPlatformGetGpsProcessorFunc)(const AnboxPlatform* platform);
93 
102 typedef const AnboxCameraProcessor* (*AnboxPlatformGetCameraProcessorFunc)(const AnboxPlatform* platform);
103 
112 typedef const AnboxProxy* (*AnboxPlatformGetAnboxProxyFunc)(const AnboxPlatform* platform);
113 
121 typedef AnboxVideoDecoder* (*AnboxPlatformCreateVideoDecoderFunc)(const AnboxPlatform* platform, AnboxVideoCodecType codec_type);
122 
130 typedef bool (*AnboxPlatformReadyFunc)(const AnboxPlatform* platform);
131 
139 typedef int (*AnboxPlatformWaitUntilReadyFunc)(const AnboxPlatform* platform);
140 
148 typedef int (*AnboxPlatformGetConfigItemFunc)(const AnboxPlatform* platform,
150  void* data, size_t data_size);
151 
159 typedef int (*AnboxPlatformSetConfigItemFunc)(const AnboxPlatform* platform,
161  void* data, size_t data_size);
162 
170 typedef void (*AnboxPlatformSetupEventTracerFunc)(const AnboxPlatform* platform,
171  AnboxTracerGetCategoryEnabledFunc get_category_enabled_func,
172  AnboxTracerAddEventFunc add_event_func);
173 
181 typedef int (*AnboxPlatformStopFunc)(const AnboxPlatform* platform);
182 
190 typedef void (*AnboxPlatformHandleEventFunc)(const AnboxPlatform* platform, AnboxEventType type);
191 
199 typedef size_t (*AnboxAudioProcessorProcessDataFunc)(const AnboxAudioProcessor* audio_processor,
200  const uint8_t* data,
201  size_t size);
202 
210 typedef ssize_t (*AnboxAudioProcessorWriteDataFunc)(const AnboxAudioProcessor* audio_processor,
211  const uint8_t* data,
212  size_t size);
213 
221 typedef ssize_t (*AnboxAudioProcessorReadDataFunc)(const AnboxAudioProcessor* audio_processor,
222  uint8_t* data,
223  size_t size);
224 
232 typedef int (*AnboxAudioProcessorStandbyFunc)(const AnboxAudioProcessor* audio_processor,
233  AnboxAudioStreamType type);
234 
242 typedef int (*AnboxAudioProcessorActivateFunc)(const AnboxAudioProcessor* audio_processor,
243  AnboxAudioStreamType type);
244 
252 typedef bool (*AnboxAudioProcessorNeedSilenceOnStandbyFunc)(const AnboxAudioProcessor* audio_processor);
253 
261 typedef int (*AnboxInputProcessorReadEventFunc)(const AnboxInputProcessor* input_processor,
262  AnboxInputEvent* event,
263  int timeout);
264 
272 typedef int (*AnboxInputProcessorInjectEventFunc)(const AnboxInputProcessor* input_processor,
273  AnboxInputEvent event);
274 
281 typedef int (*AnboxGraphicsProcessorInitializeFunc)(const AnboxGraphicsProcessor* graphics_processor,
282  AnboxGraphicsConfiguration* configuration);
283 
290 typedef EGLDisplay (*AnboxGraphicsProcessorCreateDisplayFunc)(const AnboxGraphicsProcessor* graphics_processor);
291 
299 typedef void (*AnboxGraphicsProcessorBeginFrameFunc)(const AnboxGraphicsProcessor* graphics_processor);
300 
308 typedef void (*AnboxGraphicsProcessorFinishFrameFunc)(const AnboxGraphicsProcessor* graphics_processor);
309 
317 typedef EGLSurface (*AnboxGraphicsProcessorCreateOffscreenSurfaceFunc)(const AnboxGraphicsProcessor* graphics_processor,
318  EGLDisplay display,
319  EGLConfig config,
320  const EGLint* attribs);
321 
330  EGLDisplay display,
331  EGLSurface surface);
332 
339 typedef bool (*AnboxGraphicsProcessorPresentFunc)(const AnboxGraphicsProcessor* graphics_processor,
340  AnboxGraphicsBuffer* buffer,
341  AnboxCallback* callback);
342 
349 typedef bool (*AnboxGraphicsProcessorPresent2Func)(const AnboxGraphicsProcessor* graphics_processor,
350  AnboxGraphicsBuffer2* buffer,
351  AnboxCallback* callback);
352 
353 /*
354  * @brief Create a new graphics buffer
355  *
356  * The function prototype for C API function which stands for
357  * the C++ method of anbox::GraphicsProcessor::create_buffer
358  */
359 typedef bool (*AnboxGraphicsProcessorCreateBufferFunc)(const AnboxGraphicsProcessor* graphics_processor,
360  uint32_t width, uint32_t height, uint32_t format,
361  uint32_t usage, AnboxGraphicsBuffer2** buffer);
362 
371 
379 typedef int (*AnboxSensorProcessorReadDataFunc)(const AnboxSensorProcessor* sensor_processor,
380  AnboxSensorData* data,
381  int timeout);
382 
390 typedef int (*AnboxSensorProcessorInjectDataFunc)(const AnboxSensorProcessor* sensor_processor,
391  AnboxSensorData data);
392 
401  const AnboxChangeScreenOrientationCallback& callback,
402  void* user_data);
403 
412  const AnboxChangeDisplayDensityCallback& callback,
413  void* user_data);
414 
422 typedef int (*AnboxProxySetChangeDisplaySizeCallbackFunc)(const AnboxProxy* anbox_proxy,
423  const AnboxChangeDisplaySizeCallback& callback,
424  void* user_data);
425 
433 typedef int (*AnboxProxySendMessageFunc)(const AnboxProxy* anbox_proxy,
434  const char* type,
435  size_t type_size,
436  const char* data,
437  size_t data_size);
438 
447  const AnboxTriggerActionCallback& callback,
448  void* user_data);
449 
458  const AnboxCreateADBConnectionCallback& callback,
459  void* user_data);
460 
468 typedef int (*AnboxGpsProcessorStartFunc)(const AnboxGpsProcessor* gps_processor);
469 
477 typedef int (*AnboxGpsProcessorStopFunc)(const AnboxGpsProcessor* gps_processor);
478 
486 typedef int (*AnboxGpsProcessorReadDataFunc)(const AnboxGpsProcessor* gps_processor,
487  AnboxGpsData* data,
488  int timeout);
489 
497 typedef int (*AnboxGpsProcessorInjectDataFunc)(const AnboxGpsProcessor* gps_processor,
498  AnboxGpsData data);
499 
507 typedef int (*AnboxCameraProcessorGetDeviceSpecsFunc)(const AnboxCameraProcessor* camera_processor,
508  AnboxCameraSpec** specs,
509  size_t *length);
510 
518 typedef int (*AnboxCameraProcessorOpenDeviceFunc)(const AnboxCameraProcessor* camera_processor,
519  AnboxCameraSpec spec,
520  AnboxCameraOrientation orientation);
521 
529 typedef int (*AnboxCameraProcessorCloseDeviceFunc)(const AnboxCameraProcessor* camera_processor);
530 
531 
539 typedef int (*AnboxCameraProcessorReadFrameFunc)(const AnboxCameraProcessor* camera_processor,
540  AnboxVideoFrame* frame,
541  int timeout);
542 
550 typedef int (*AnboxCameraProcessorInjectFrameFunc)(const AnboxCameraProcessor* camera_processor,
551  AnboxVideoFrame frame);
552 
553 /*
554  * @brief Release the video decoder instance
555  **/
557 
558 /*
559  * @brief Configure the video decoder with the given spec
560  *
561  * The function prototype for C API function which stands for
562  * the C++ method of anbox::VideoDecoder::configure
563  *
564  **/
566 
567 /*
568  * @brief Flush any pending work the video decoder may have
569  *
570  * The function prototype for C API function which stands for
571  * the C++ method of anbox::VideoDecoder::flush
572  *
573  **/
574 typedef int (*AnboxVideoDecoderFlushFunc)(const AnboxVideoDecoder* decoder);
575 
576 /*
577  * @brief Submit the given frame to the video decoder
578  *
579  * The function prototype for C API function which stands for
580  * the C++ method of anbox::VideoDecoder::decode_frame
581  *
582  **/
583 typedef uint64_t (*AnboxVideoDecoderDecodeFrameFunc)(const AnboxVideoDecoder* decoder, const AnboxVideoFrame* frame, uint64_t pts);
584 
585 /*
586  * @brief Retrieve a decoded image from the decoder
587  *
588  * The function prototype for C API function which stands for
589  * the C++ method of anbox::VideoDecoder::retrieve_image
590  *
591  **/
593 
601 typedef AnboxVhalConnector* (*AnboxPlatformGetVhalConnectorFunc)(const AnboxPlatform* platform);
602 
611  const AnboxVhalConnectorCallbacks* callbacks,
612  void* user_data);
613 
614 #endif
int(* AnboxCreateADBConnectionCallback)(const char *id, void *user_data)
AnboxCreateADBConnectionCallback is invoked when creating ADB connection.
Definition: anbox_proxy.h:57
int(* AnboxChangeDisplaySizeCallback)(uint32_t width, uint32_t height, void *user_data)
AnboxChangeDisplaySizeCallback is invoked when changing the display size.
Definition: anbox_proxy.h:44
int(* AnboxTriggerActionCallback)(const char *name, const char **args, size_t args_len, void *user_data)
AnboxTriggerActionCallback is invoked when an action is triggered within the Android system.
Definition: anbox_proxy.h:51
int(* AnboxChangeScreenOrientationCallback)(AnboxScreenOrientationType orientation_type, void *user_data)
AnboxChangeScreenOrientationCallback is invoked when changing the screen orientation.
Definition: anbox_proxy.h:32
int(* AnboxChangeDisplayDensityCallback)(uint32_t density, void *user_data)
AnboxChangeDisplayDensityCallback is invoked when changing the display density.
Definition: anbox_proxy.h:38
int(* AnboxVideoDecoderRetrieveImageFunc)(const AnboxVideoDecoder *decoder, AnboxVideoImage *img)
Definition: public_api.h:592
int(* AnboxGraphicsProcessorInitializeFunc)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsConfiguration *configuration)
Initialize the graphics processor.
Definition: public_api.h:281
int(* AnboxCameraProcessorInjectFrameFunc)(const AnboxCameraProcessor *camera_processor, AnboxVideoFrame frame)
Inject a video frame into AnboxPlatform.
Definition: public_api.h:550
bool(* AnboxAudioProcessorNeedSilenceOnStandbyFunc)(const AnboxAudioProcessor *audio_processor)
Produce a silent audio stream on need while the audio output stream goes into the standby state.
Definition: public_api.h:252
int(* AnboxSensorProcessorInjectDataFunc)(const AnboxSensorProcessor *sensor_processor, AnboxSensorData data)
Inject a sensor data into AnboxPlatform.
Definition: public_api.h:390
ssize_t(* AnboxAudioProcessorWriteDataFunc)(const AnboxAudioProcessor *audio_processor, const uint8_t *data, size_t size)
Write a chunk of audio data.
Definition: public_api.h:210
bool(* AnboxPlatformReadyFunc)(const AnboxPlatform *platform)
Query the platform for its ready status.
Definition: public_api.h:130
int(* AnboxProxySetChangeDisplayDensityCallbackFunc)(const AnboxProxy *anbox_proxy, const AnboxChangeDisplayDensityCallback &callback, void *user_data)
Set the change display density callback function.
Definition: public_api.h:411
int(* AnboxAudioProcessorStandbyFunc)(const AnboxAudioProcessor *audio_processor, AnboxAudioStreamType type)
Notify the platform when an audio stream is in standby mode.
Definition: public_api.h:232
int(* AnboxGpsProcessorStartFunc)(const AnboxGpsProcessor *gps_processor)
Request Gps processor to start forwarding the GPS data to Android container.
Definition: public_api.h:468
int(* AnboxPlatformStopFunc)(const AnboxPlatform *platform)
Ask the platform to stop any pending work it has to prepare for Anbox to terminate.
Definition: public_api.h:181
bool(* AnboxGraphicsProcessorCreateBufferFunc)(const AnboxGraphicsProcessor *graphics_processor, uint32_t width, uint32_t height, uint32_t format, uint32_t usage, AnboxGraphicsBuffer2 **buffer)
Definition: public_api.h:359
int(* AnboxProxySendMessageFunc)(const AnboxProxy *anbox_proxy, const char *type, size_t type_size, const char *data, size_t data_size)
Send a message from Anbox to the platform.
Definition: public_api.h:433
ssize_t(* AnboxAudioProcessorReadDataFunc)(const AnboxAudioProcessor *audio_processor, uint8_t *data, size_t size)
Read a chunk of audio data.
Definition: public_api.h:221
int(* AnboxPlatformWaitUntilReadyFunc)(const AnboxPlatform *platform)
Wait for platform plugin to be initialized.
Definition: public_api.h:139
int(* AnboxVideoDecoderFlushFunc)(const AnboxVideoDecoder *decoder)
Definition: public_api.h:574
int(* AnboxVideoDecoderReleaseFunc)(AnboxVideoDecoder *decoder)
Definition: public_api.h:556
int(* AnboxPlatformGetConfigItemFunc)(const AnboxPlatform *platform, AnboxPlatformConfigurationKey key, void *data, size_t data_size)
Retrieve the configuration options provided by platform plugin.
Definition: public_api.h:148
EGLDisplay(* AnboxGraphicsProcessorCreateDisplayFunc)(const AnboxGraphicsProcessor *graphics_processor)
Create an EGL display.
Definition: public_api.h:290
uint64_t(* AnboxVideoDecoderDecodeFrameFunc)(const AnboxVideoDecoder *decoder, const AnboxVideoFrame *frame, uint64_t pts)
Definition: public_api.h:583
int(* AnboxProxySetCreateAdbConnectionCallbackFunc)(const AnboxProxy *proxy, const AnboxCreateADBConnectionCallback &callback, void *user_data)
Allows the platform to create ADB connection.
Definition: public_api.h:457
int(* AnboxCameraProcessorCloseDeviceFunc)(const AnboxCameraProcessor *camera_processor)
Close a camera device.
Definition: public_api.h:529
bool(* AnboxGraphicsProcessorPresent2Func)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsBuffer2 *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
Definition: public_api.h:349
size_t(* AnboxAudioProcessorProcessDataFunc)(const AnboxAudioProcessor *audio_processor, const uint8_t *data, size_t size)
Process a chunk of audio data.
Definition: public_api.h:199
void(* AnboxPlatformSetupEventTracerFunc)(const AnboxPlatform *platform, AnboxTracerGetCategoryEnabledFunc get_category_enabled_func, AnboxTracerAddEventFunc add_event_func)
Register an external event tracing implementation with the platform.
Definition: public_api.h:170
int(* AnboxProxySetChangeScreenOrientationCallbackFunc)(const AnboxProxy *anbox_proxy, const AnboxChangeScreenOrientationCallback &callback, void *user_data)
Set the change screen orientation callback function.
Definition: public_api.h:400
int(* AnboxGpsProcessorStopFunc)(const AnboxGpsProcessor *gps_processor)
Request Gps processor to stop forwarding the GPS data to Android container.
Definition: public_api.h:477
int(* AnboxCameraProcessorReadFrameFunc)(const AnboxCameraProcessor *camera_processor, AnboxVideoFrame *frame, int timeout)
Read next available video frame.
Definition: public_api.h:539
int(* AnboxSensorProcessorReadDataFunc)(const AnboxSensorProcessor *sensor_processor, AnboxSensorData *data, int timeout)
Read next available sensor data.
Definition: public_api.h:379
int(* AnboxCameraProcessorGetDeviceSpecsFunc)(const AnboxCameraProcessor *camera_processor, AnboxCameraSpec **specs, size_t *length)
Open a camera device.
Definition: public_api.h:507
int(* AnboxCameraProcessorOpenDeviceFunc)(const AnboxCameraProcessor *camera_processor, AnboxCameraSpec spec, AnboxCameraOrientation orientation)
Open a camera device.
Definition: public_api.h:518
int(* AnboxVideoDecoderConfigureFunc)(const AnboxVideoDecoder *decoder, AnboxVideoDecoderConfig config)
Definition: public_api.h:565
int(* AnboxProxySetTriggerActionCallbackFunc)(const AnboxProxy *proxy, const AnboxTriggerActionCallback &callback, void *user_data)
Allows the platform to trigger an action within the Android system.
Definition: public_api.h:446
int(* AnboxInputProcessorInjectEventFunc)(const AnboxInputProcessor *input_processor, AnboxInputEvent event)
Inject an input event into AnboxPlatform.
Definition: public_api.h:272
int(* AnboxAudioProcessorActivateFunc)(const AnboxAudioProcessor *audio_processor, AnboxAudioStreamType type)
Notify the platform when an audio stream is in activation mode.
Definition: public_api.h:242
void(* AnboxPlatformHandleEventFunc)(const AnboxPlatform *platform, AnboxEventType type)
Handle an event fired from Anbox by a platform.
Definition: public_api.h:190
int(* AnboxGpsProcessorInjectDataFunc)(const AnboxGpsProcessor *gps_processor, AnboxGpsData data)
Inject a gps data into AnboxPlatform.
Definition: public_api.h:497
int(* AnboxGpsProcessorReadDataFunc)(const AnboxGpsProcessor *gps_processor, AnboxGpsData *data, int timeout)
Read next available gps data.
Definition: public_api.h:486
AnboxSensorType(* AnboxSensorProcessorSupportedSensorsFunc)(const AnboxSensorProcessor *sensor_processor)
Sensors supported by the platform.
Definition: public_api.h:370
void(* AnboxGraphicsProcessorBeginFrameFunc)(const AnboxGraphicsProcessor *graphics_processor)
Begin a new frame.
Definition: public_api.h:299
int(* AnboxVhalConnectorSetCallbacksFunc)(const AnboxVhalConnector *connector, const AnboxVhalConnectorCallbacks *callbacks, void *user_data)
Allows the platform to call Android VHAL functions through Anbox.
Definition: public_api.h:610
EGLSurface(* AnboxGraphicsProcessorCreateOffscreenSurfaceFunc)(const AnboxGraphicsProcessor *graphics_processor, EGLDisplay display, EGLConfig config, const EGLint *attribs)
Create an offscreen EGL surface.
Definition: public_api.h:317
int(* AnboxProxySetChangeDisplaySizeCallbackFunc)(const AnboxProxy *anbox_proxy, const AnboxChangeDisplaySizeCallback &callback, void *user_data)
Set the change display size callback function.
Definition: public_api.h:422
int(* AnboxInputProcessorReadEventFunc)(const AnboxInputProcessor *input_processor, AnboxInputEvent *event, int timeout)
Read next available input event.
Definition: public_api.h:261
void(* AnboxReleasePlatformFunc)(AnboxPlatform *platform)
Release a platform instance.
Definition: public_api.h:42
void(* AnboxGraphicsProcessorFinishFrameFunc)(const AnboxGraphicsProcessor *graphics_processor)
Finish the currently rendered frame.
Definition: public_api.h:308
bool(* AnboxGraphicsProcessorPresentFunc)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsBuffer *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
Definition: public_api.h:339
bool(* AnboxGraphicsProcessorDestroyOffscreenSurfaceFunc)(const AnboxGraphicsProcessor *graphics_processor, EGLDisplay display, EGLSurface surface)
Destroy an offscreen EGL surface.
Definition: public_api.h:329
int(* AnboxPlatformSetConfigItemFunc)(const AnboxPlatform *platform, AnboxPlatformConfigurationKey key, void *data, size_t data_size)
Set the configuration options by Anbox to the platform.
Definition: public_api.h:159
Generic callback wrapper.
Definition: types.h:314
AnboxCameraSpec represents the camera specification.
Definition: types.h:726
Graphics buffer.
Definition: types.h:292
Graphics buffer.
Definition: types.h:273
AnboxDisplaySpec describes properties of the Anbox rendering pipeline the platform plugin can influen...
Definition: types.h:1233
AnboxInputEvent is similar to the input_event that is defined in the Linux kernel API....
Definition: types.h:1292
AnboxPlatformConfiguration holds platform configuration options which Anbox supplies to the platform ...
Definition: types.h:648
AnboxSensorData represents the sensor data stucture,.
Definition: types.h:1366
AnboxVhalConnectorCallbacks is the structure holding all VHAL-related callbacks.
AnboxVideoDecoderConfig describes the configuration of a video decoder.
Definition: types.h:1611
AnboxVideoFrame represents a single complete video frame.
Definition: types.h:742
AnboxVideoImage describes a decoded image returned by the video decoder.
Definition: types.h:1623
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
AnboxCameraOrientation
describes the orientations that Anbox supports in the camea processor
Definition: types.h:706
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
AnboxAudioStreamType
AnboxAudioStreamType describes the audio stream type.
Definition: types.h:174
AnboxSensorType
AnboxSensorType describes all sensor types supported by Anbox.
Definition: types.h:1313
AnboxEventType
AnboxEventType describes the type of event sent from Anbox.
Definition: types.h:668