anbox-platform-sdk 1.28.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
32typedef AnboxPlatform* (*AnboxInitializePlatformFunc)(const AnboxPlatformConfiguration* configuration);
33
42typedef void (*AnboxReleasePlatformFunc)(AnboxPlatform* platform);
43
52typedef const AnboxAudioProcessor* (*AnboxPlatformGetAudioProcessorFunc)(const AnboxPlatform* platform);
53
62typedef const AnboxInputProcessor* (*AnboxPlatformGetInputProcessorFunc)(const AnboxPlatform* platform);
63
72typedef const AnboxGraphicsProcessor* (*AnboxPlatformGetGraphicsProcessorFunc)(const AnboxPlatform* platform);
73
82typedef const AnboxSensorProcessor* (*AnboxPlatformGetSensorProcessorFunc)(const AnboxPlatform* platform);
83
92typedef const AnboxGpsProcessor* (*AnboxPlatformGetGpsProcessorFunc)(const AnboxPlatform* platform);
93
102typedef const AnboxCameraProcessor* (*AnboxPlatformGetCameraProcessorFunc)(const AnboxPlatform* platform);
103
112typedef const AnboxProxy* (*AnboxPlatformGetAnboxProxyFunc)(const AnboxPlatform* platform);
113
121typedef AnboxVideoDecoder* (*AnboxPlatformCreateVideoDecoderFunc)(const AnboxPlatform* platform, AnboxVideoCodecType codec_type);
122
130typedef bool (*AnboxPlatformReadyFunc)(const AnboxPlatform* platform);
131
139typedef int (*AnboxPlatformWaitUntilReadyFunc)(const AnboxPlatform* platform);
140
148typedef int (*AnboxPlatformGetConfigItemFunc)(const AnboxPlatform* platform,
150 void* data, size_t data_size);
151
159typedef int (*AnboxPlatformSetConfigItemFunc)(const AnboxPlatform* platform,
161 void* data, size_t data_size);
162
170typedef int (*AnboxPlatformSetConfigItemsFunc)(const AnboxPlatform* platform,
172 size_t count);
173
181typedef void (*AnboxPlatformSetupEventTracerFunc)(const AnboxPlatform* platform,
182 AnboxTracerGetCategoryEnabledFunc get_category_enabled_func,
183 AnboxTracerAddEventFunc add_event_func);
184
192typedef int (*AnboxPlatformStopFunc)(const AnboxPlatform* platform);
193
201typedef void (*AnboxPlatformHandleEventFunc)(const AnboxPlatform* platform, AnboxEventType type);
202
210typedef size_t (*AnboxAudioProcessorProcessDataFunc)(const AnboxAudioProcessor* audio_processor,
211 const uint8_t* data,
212 size_t size);
213
221typedef ssize_t (*AnboxAudioProcessorWriteDataFunc)(const AnboxAudioProcessor* audio_processor,
222 const uint8_t* data,
223 size_t size);
224
232typedef ssize_t (*AnboxAudioProcessorReadDataFunc)(const AnboxAudioProcessor* audio_processor,
233 uint8_t* data,
234 size_t size);
235
243typedef int (*AnboxAudioProcessorStandbyFunc)(const AnboxAudioProcessor* audio_processor,
245
253typedef int (*AnboxAudioProcessorActivateFunc)(const AnboxAudioProcessor* audio_processor,
255
264
272typedef int (*AnboxInputProcessorReadEventFunc)(const AnboxInputProcessor* input_processor,
273 AnboxInputEvent* event,
274 int timeout);
275
283typedef int (*AnboxInputProcessorInjectEventFunc)(const AnboxInputProcessor* input_processor,
284 AnboxInputEvent event);
285
292typedef int (*AnboxGraphicsProcessorInitializeFunc)(const AnboxGraphicsProcessor* graphics_processor,
293 AnboxGraphicsConfiguration* configuration);
294
301typedef EGLDisplay (*AnboxGraphicsProcessorCreateDisplayFunc)(const AnboxGraphicsProcessor* graphics_processor);
302
310typedef void (*AnboxGraphicsProcessorBeginFrameFunc)(const AnboxGraphicsProcessor* graphics_processor);
311
319typedef void (*AnboxGraphicsProcessorFinishFrameFunc)(const AnboxGraphicsProcessor* graphics_processor);
320
328typedef EGLSurface (*AnboxGraphicsProcessorCreateOffscreenSurfaceFunc)(const AnboxGraphicsProcessor* graphics_processor,
329 EGLDisplay display,
330 EGLConfig config,
331 const EGLint* attribs);
332
341 EGLDisplay display,
342 EGLSurface surface);
343
350typedef bool (*AnboxGraphicsProcessorPresentFunc)(const AnboxGraphicsProcessor* graphics_processor,
351 AnboxGraphicsBuffer* buffer,
352 AnboxCallback* callback);
353
360typedef bool (*AnboxGraphicsProcessorPresent2Func)(const AnboxGraphicsProcessor* graphics_processor,
361 AnboxGraphicsBuffer2* buffer,
362 AnboxCallback* callback);
363
364/*
365 * @brief Create a new graphics buffer
366 *
367 * The function prototype for C API function which stands for
368 * the C++ method of anbox::GraphicsProcessor::create_buffer
369 */
370typedef bool (*AnboxGraphicsProcessorCreateBufferFunc)(const AnboxGraphicsProcessor* graphics_processor,
371 uint32_t width, uint32_t height, uint32_t format,
372 uint32_t usage, AnboxGraphicsBuffer2** buffer);
373
374
375/*
376 * @brief Set the vsync callback
377 *
378 * The function prototype for C API function which stands for
379 * the C++ method of anbox::GraphicsProcessor::set_vsync_callback
380 */
382 const AnboxGraphicsProcessor* graphics_processor,
383 const AnboxVsyncCallback& callback, void* user_data);
384
393
402 const AnboxSensorType type,
403 bool on);
404
405
413typedef int (*AnboxSensorProcessorReadDataFunc)(const AnboxSensorProcessor* sensor_processor,
414 AnboxSensorData* data,
415 int timeout);
416
424typedef int (*AnboxSensorProcessorInjectDataFunc)(const AnboxSensorProcessor* sensor_processor,
425 AnboxSensorData data);
426
436 void* user_data);
437
446 const AnboxChangeDisplayDensityCallback& callback,
447 void* user_data);
448
457 const AnboxChangeDisplaySizeCallback& callback,
458 void* user_data);
459
467typedef int (*AnboxProxySendMessageFunc)(const AnboxProxy* anbox_proxy,
468 const char* type,
469 size_t type_size,
470 const char* data,
471 size_t data_size);
472
481 const AnboxTriggerActionCallback& callback,
482 void* user_data);
483
492 const AnboxCreateADBConnectionCallback& callback,
493 void* user_data);
494
504 void* user_data);
505
513typedef int (*AnboxGpsProcessorStartFunc)(const AnboxGpsProcessor* gps_processor);
514
522typedef int (*AnboxGpsProcessorStopFunc)(const AnboxGpsProcessor* gps_processor);
523
531typedef int (*AnboxGpsProcessorReadDataFunc)(const AnboxGpsProcessor* gps_processor,
532 AnboxGpsData* data,
533 int timeout);
534
542typedef int (*AnboxGpsProcessorInjectDataFunc)(const AnboxGpsProcessor* gps_processor,
543 AnboxGpsData data);
544
553 AnboxCameraSpec** specs,
554 size_t *length);
555
563typedef int (*AnboxCameraProcessorOpenDeviceFunc)(const AnboxCameraProcessor* camera_processor,
564 AnboxCameraSpec spec,
565 AnboxCameraOrientation orientation);
566
574typedef int (*AnboxCameraProcessorCloseDeviceFunc)(const AnboxCameraProcessor* camera_processor);
575
576
584typedef int (*AnboxCameraProcessorReadFrameFunc)(const AnboxCameraProcessor* camera_processor,
585 AnboxVideoFrame* frame,
586 int timeout);
587
595typedef int (*AnboxCameraProcessorInjectFrameFunc)(const AnboxCameraProcessor* camera_processor,
596 AnboxVideoFrame frame);
597
598/*
599 * @brief Release the video decoder instance
600 **/
602
603/*
604 * @brief Configure the video decoder with the given spec
605 *
606 * The function prototype for C API function which stands for
607 * the C++ method of anbox::VideoDecoder::configure
608 *
609 **/
611
612/*
613 * @brief Flush any pending work the video decoder may have
614 *
615 * The function prototype for C API function which stands for
616 * the C++ method of anbox::VideoDecoder::flush
617 *
618 **/
619typedef int (*AnboxVideoDecoderFlushFunc)(const AnboxVideoDecoder* decoder);
620
621/*
622 * @brief Submit the given frame to the video decoder
623 *
624 * The function prototype for C API function which stands for
625 * the C++ method of anbox::VideoDecoder::decode_frame
626 *
627 **/
628typedef uint64_t (*AnboxVideoDecoderDecodeFrameFunc)(const AnboxVideoDecoder* decoder, const AnboxVideoFrame* frame, uint64_t pts);
629
630/*
631 * @brief Retrieve a decoded image from the decoder
632 *
633 * The function prototype for C API function which stands for
634 * the C++ method of anbox::VideoDecoder::retrieve_image
635 *
636 **/
638
646typedef AnboxVhalConnector* (*AnboxPlatformGetVhalConnectorFunc)(const AnboxPlatform* platform);
647
656 const AnboxVhalConnectorCallbacks* callbacks,
657 void* user_data);
658
659#endif
int(* AnboxCreateADBConnectionCallback)(const char *id, void *user_data)
AnboxCreateADBConnectionCallback is invoked when creating ADB connection.
Definition anbox_proxy.h:57
int(* AnboxDisconnectADBConnectionCallback)(const char *id, void *user_data)
AnboxDisconnectADBConnectionCallback is invoked when disconnecting ADB connection.
Definition anbox_proxy.h:63
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
void(* AnboxVsyncCallback)(uint64_t time_ns, void *user_data)
AnboxVsyncCallback is invoked to signal a new vsync is about to start.
int(* AnboxVideoDecoderRetrieveImageFunc)(const AnboxVideoDecoder *decoder, AnboxVideoImage *img)
Definition public_api.h:637
int(* AnboxSensorProcessorActivateSensorFunc)(const AnboxSensorProcessor *sensor_processor, const AnboxSensorType type, bool on)
Activate or deactivate a specific sensor.
Definition public_api.h:401
int(* AnboxGraphicsProcessorInitializeFunc)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsConfiguration *configuration)
Initialize the graphics processor.
Definition public_api.h:292
int(* AnboxCameraProcessorInjectFrameFunc)(const AnboxCameraProcessor *camera_processor, AnboxVideoFrame frame)
Inject a video frame into AnboxPlatform.
Definition public_api.h:595
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:263
int(* AnboxSensorProcessorInjectDataFunc)(const AnboxSensorProcessor *sensor_processor, AnboxSensorData data)
Inject a sensor data into AnboxPlatform.
Definition public_api.h:424
ssize_t(* AnboxAudioProcessorWriteDataFunc)(const AnboxAudioProcessor *audio_processor, const uint8_t *data, size_t size)
Write a chunk of audio data.
Definition public_api.h:221
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:445
int(* AnboxAudioProcessorStandbyFunc)(const AnboxAudioProcessor *audio_processor, AnboxAudioStreamType type)
Notify the platform when an audio stream is in standby mode.
Definition public_api.h:243
int(* AnboxGpsProcessorStartFunc)(const AnboxGpsProcessor *gps_processor)
Request Gps processor to start forwarding the GPS data to Android container.
Definition public_api.h:513
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:192
bool(* AnboxGraphicsProcessorCreateBufferFunc)(const AnboxGraphicsProcessor *graphics_processor, uint32_t width, uint32_t height, uint32_t format, uint32_t usage, AnboxGraphicsBuffer2 **buffer)
Definition public_api.h:370
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:467
ssize_t(* AnboxAudioProcessorReadDataFunc)(const AnboxAudioProcessor *audio_processor, uint8_t *data, size_t size)
Read a chunk of audio data.
Definition public_api.h:232
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:619
int(* AnboxVideoDecoderReleaseFunc)(AnboxVideoDecoder *decoder)
Definition public_api.h:601
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:301
uint64_t(* AnboxVideoDecoderDecodeFrameFunc)(const AnboxVideoDecoder *decoder, const AnboxVideoFrame *frame, uint64_t pts)
Definition public_api.h:628
int(* AnboxProxySetCreateAdbConnectionCallbackFunc)(const AnboxProxy *proxy, const AnboxCreateADBConnectionCallback &callback, void *user_data)
Allows the platform to create ADB connection.
Definition public_api.h:491
int(* AnboxPlatformSetConfigItemsFunc)(const AnboxPlatform *platform, const AnboxPlatformConfigurationItem *items, size_t count)
Set multiple configuration items to the platform in a single transaction.
Definition public_api.h:170
int(* AnboxCameraProcessorCloseDeviceFunc)(const AnboxCameraProcessor *camera_processor)
Close a camera device.
Definition public_api.h:574
bool(* AnboxGraphicsProcessorPresent2Func)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsBuffer2 *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
Definition public_api.h:360
size_t(* AnboxAudioProcessorProcessDataFunc)(const AnboxAudioProcessor *audio_processor, const uint8_t *data, size_t size)
Process a chunk of audio data.
Definition public_api.h:210
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:181
int(* AnboxProxySetChangeScreenOrientationCallbackFunc)(const AnboxProxy *anbox_proxy, const AnboxChangeScreenOrientationCallback &callback, void *user_data)
Set the change screen orientation callback function.
Definition public_api.h:434
int(* AnboxGpsProcessorStopFunc)(const AnboxGpsProcessor *gps_processor)
Request Gps processor to stop forwarding the GPS data to Android container.
Definition public_api.h:522
bool(* AnboxGraphicsProcessorSetVsyncCallbackFunc)(const AnboxGraphicsProcessor *graphics_processor, const AnboxVsyncCallback &callback, void *user_data)
Definition public_api.h:381
int(* AnboxCameraProcessorReadFrameFunc)(const AnboxCameraProcessor *camera_processor, AnboxVideoFrame *frame, int timeout)
Read next available video frame.
Definition public_api.h:584
int(* AnboxSensorProcessorReadDataFunc)(const AnboxSensorProcessor *sensor_processor, AnboxSensorData *data, int timeout)
Read next available sensor data.
Definition public_api.h:413
int(* AnboxCameraProcessorGetDeviceSpecsFunc)(const AnboxCameraProcessor *camera_processor, AnboxCameraSpec **specs, size_t *length)
Open a camera device.
Definition public_api.h:552
int(* AnboxCameraProcessorOpenDeviceFunc)(const AnboxCameraProcessor *camera_processor, AnboxCameraSpec spec, AnboxCameraOrientation orientation)
Open a camera device.
Definition public_api.h:563
int(* AnboxVideoDecoderConfigureFunc)(const AnboxVideoDecoder *decoder, AnboxVideoDecoderConfig config)
Definition public_api.h:610
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:480
int(* AnboxInputProcessorInjectEventFunc)(const AnboxInputProcessor *input_processor, AnboxInputEvent event)
Inject an input event into AnboxPlatform.
Definition public_api.h:283
int(* AnboxAudioProcessorActivateFunc)(const AnboxAudioProcessor *audio_processor, AnboxAudioStreamType type)
Notify the platform when an audio stream is in activation mode.
Definition public_api.h:253
void(* AnboxPlatformHandleEventFunc)(const AnboxPlatform *platform, AnboxEventType type)
Handle an event fired from Anbox by a platform.
Definition public_api.h:201
int(* AnboxGpsProcessorInjectDataFunc)(const AnboxGpsProcessor *gps_processor, AnboxGpsData data)
Inject a gps data into AnboxPlatform.
Definition public_api.h:542
int(* AnboxProxySetDisconnectAdbConnectionCallbackFunc)(const AnboxProxy *proxy, const AnboxDisconnectADBConnectionCallback &callback, void *user_data)
Allows the platform to disconnect ADB connection.
Definition public_api.h:502
int(* AnboxGpsProcessorReadDataFunc)(const AnboxGpsProcessor *gps_processor, AnboxGpsData *data, int timeout)
Read next available gps data.
Definition public_api.h:531
AnboxSensorType(* AnboxSensorProcessorSupportedSensorsFunc)(const AnboxSensorProcessor *sensor_processor)
Sensors supported by the platform.
Definition public_api.h:392
void(* AnboxGraphicsProcessorBeginFrameFunc)(const AnboxGraphicsProcessor *graphics_processor)
Begin a new frame.
Definition public_api.h:310
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:655
EGLSurface(* AnboxGraphicsProcessorCreateOffscreenSurfaceFunc)(const AnboxGraphicsProcessor *graphics_processor, EGLDisplay display, EGLConfig config, const EGLint *attribs)
Create an offscreen EGL surface.
Definition public_api.h:328
int(* AnboxProxySetChangeDisplaySizeCallbackFunc)(const AnboxProxy *anbox_proxy, const AnboxChangeDisplaySizeCallback &callback, void *user_data)
Set the change display size callback function.
Definition public_api.h:456
int(* AnboxInputProcessorReadEventFunc)(const AnboxInputProcessor *input_processor, AnboxInputEvent *event, int timeout)
Read next available input event.
Definition public_api.h:272
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:319
bool(* AnboxGraphicsProcessorPresentFunc)(const AnboxGraphicsProcessor *graphics_processor, AnboxGraphicsBuffer *buffer, AnboxCallback *callback)
Present the given buffer to a display or other output.
Definition public_api.h:350
bool(* AnboxGraphicsProcessorDestroyOffscreenSurfaceFunc)(const AnboxGraphicsProcessor *graphics_processor, EGLDisplay display, EGLSurface surface)
Destroy an offscreen EGL surface.
Definition public_api.h:340
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:766
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:1273
AnboxInputEvent is similar to the input_event that is defined in the Linux kernel API....
Definition types.h:1332
Represents a single configuration item.
Definition types.h:654
AnboxPlatformConfiguration holds platform configuration options which Anbox supplies to the platform ...
Definition types.h:679
AnboxSensorData represents the sensor data stucture,.
Definition types.h:1406
AnboxVhalConnectorCallbacks is the structure holding all VHAL-related callbacks.
AnboxVideoDecoderConfig describes the configuration of a video decoder.
Definition types.h:1651
AnboxVideoFrame represents a single complete video frame.
Definition types.h:782
AnboxVideoImage describes a decoded image returned by the video decoder.
Definition types.h:1663
AnboxPlatformConfigurationKey
AnboxPlatformConfigurationKey specifies configuration items which allow to influence the behavior and...
Definition types.h:462
AnboxVideoCodecType
AnboxVideoCodecType describes the type of a video codec.
Definition types.h:1633
AnboxCameraOrientation
describes the orientations that Anbox supports in the camea processor
Definition types.h:746
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:1730
AnboxAudioStreamType
AnboxAudioStreamType describes the audio stream type.
Definition types.h:174
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:1690
AnboxSensorType
AnboxSensorType describes all sensor types supported by Anbox.
Definition types.h:1353
AnboxEventType
AnboxEventType describes the type of event sent from Anbox.
Definition types.h:708