MapLibre Native C API
Public C ABI for the MapLibre Native wrapper.
Loading...
Searching...
No Matches
runtime.h
Go to the documentation of this file.
1
5
6#ifndef MAPLIBRE_NATIVE_C_RUNTIME_H
7#define MAPLIBRE_NATIVE_C_RUNTIME_H
8
9#ifndef __cplusplus
10#include <stdbool.h>
11#endif
12
13#include <stddef.h>
14#include <stdint.h>
15
16#include "base.h"
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22typedef enum mln_network_status : uint32_t {
23 MLN_NETWORK_STATUS_ONLINE = 1,
24 MLN_NETWORK_STATUS_OFFLINE = 2,
25} mln_network_status;
26
27typedef enum mln_runtime_option_flag : uint32_t {
28 MLN_RUNTIME_OPTION_MAXIMUM_CACHE_SIZE = 1U << 0U,
29} mln_runtime_option_flag;
30
31typedef enum mln_ambient_cache_operation : uint32_t {
32 MLN_AMBIENT_CACHE_OPERATION_RESET_DATABASE = 1,
33 MLN_AMBIENT_CACHE_OPERATION_PACK_DATABASE = 2,
34 MLN_AMBIENT_CACHE_OPERATION_INVALIDATE = 3,
35 MLN_AMBIENT_CACHE_OPERATION_CLEAR = 4,
36} mln_ambient_cache_operation;
37
38typedef int64_t mln_offline_region_id;
39
40typedef enum mln_offline_region_definition_type : uint32_t {
41 MLN_OFFLINE_REGION_DEFINITION_TILE_PYRAMID = 1,
42 MLN_OFFLINE_REGION_DEFINITION_GEOMETRY = 2,
43} mln_offline_region_definition_type;
44
45typedef enum mln_offline_region_download_state : uint32_t {
46 MLN_OFFLINE_REGION_DOWNLOAD_INACTIVE = 0,
47 MLN_OFFLINE_REGION_DOWNLOAD_ACTIVE = 1,
48} mln_offline_region_download_state;
49
51typedef uint64_t mln_offline_operation_id;
52
54typedef enum mln_offline_operation_kind : uint32_t {
55 MLN_OFFLINE_OPERATION_AMBIENT_CACHE = 1,
56 MLN_OFFLINE_OPERATION_REGION_CREATE = 2,
57 MLN_OFFLINE_OPERATION_REGION_GET = 3,
58 MLN_OFFLINE_OPERATION_REGIONS_LIST = 4,
59 MLN_OFFLINE_OPERATION_REGIONS_MERGE_DATABASE = 5,
60 MLN_OFFLINE_OPERATION_REGION_UPDATE_METADATA = 6,
61 MLN_OFFLINE_OPERATION_REGION_GET_STATUS = 7,
62 MLN_OFFLINE_OPERATION_REGION_SET_OBSERVED = 8,
63 MLN_OFFLINE_OPERATION_REGION_SET_DOWNLOAD_STATE = 9,
64 MLN_OFFLINE_OPERATION_REGION_INVALIDATE = 10,
65 MLN_OFFLINE_OPERATION_REGION_DELETE = 11,
67
69typedef enum mln_offline_operation_result_kind : uint32_t {
70 MLN_OFFLINE_OPERATION_RESULT_NONE = 0,
71 MLN_OFFLINE_OPERATION_RESULT_REGION = 1,
72 MLN_OFFLINE_OPERATION_RESULT_OPTIONAL_REGION = 2,
73 MLN_OFFLINE_OPERATION_RESULT_REGION_LIST = 3,
74 MLN_OFFLINE_OPERATION_RESULT_REGION_STATUS = 4,
76
79 uint32_t size;
82 uint64_t completed_resource_count;
83 uint64_t completed_resource_size;
84 uint64_t completed_tile_count;
85 uint64_t required_tile_count;
86 uint64_t completed_tile_size;
87 uint64_t required_resource_count;
88 bool required_resource_count_is_precise;
89 bool complete;
91
133typedef enum mln_runtime_event_type : uint32_t {
134 MLN_RUNTIME_EVENT_MAP_CAMERA_WILL_CHANGE = 1,
135 MLN_RUNTIME_EVENT_MAP_CAMERA_IS_CHANGING = 2,
136 MLN_RUNTIME_EVENT_MAP_CAMERA_DID_CHANGE = 3,
137 MLN_RUNTIME_EVENT_MAP_STYLE_LOADED = 4,
138 MLN_RUNTIME_EVENT_MAP_LOADING_STARTED = 5,
139 MLN_RUNTIME_EVENT_MAP_LOADING_FINISHED = 6,
140 MLN_RUNTIME_EVENT_MAP_LOADING_FAILED = 7,
141 MLN_RUNTIME_EVENT_MAP_IDLE = 8,
142 MLN_RUNTIME_EVENT_MAP_RENDER_UPDATE_AVAILABLE = 9,
143 MLN_RUNTIME_EVENT_MAP_RENDER_ERROR = 10,
144 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FINISHED = 11,
145 MLN_RUNTIME_EVENT_MAP_STILL_IMAGE_FAILED = 12,
146 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_STARTED = 13,
147 MLN_RUNTIME_EVENT_MAP_RENDER_FRAME_FINISHED = 14,
148 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_STARTED = 15,
149 MLN_RUNTIME_EVENT_MAP_RENDER_MAP_FINISHED = 16,
150 MLN_RUNTIME_EVENT_MAP_STYLE_IMAGE_MISSING = 17,
151 MLN_RUNTIME_EVENT_MAP_TILE_ACTION = 18,
152 MLN_RUNTIME_EVENT_OFFLINE_REGION_STATUS_CHANGED = 19,
153 MLN_RUNTIME_EVENT_OFFLINE_REGION_RESPONSE_ERROR = 20,
154 MLN_RUNTIME_EVENT_OFFLINE_REGION_TILE_COUNT_LIMIT_EXCEEDED = 21,
155 MLN_RUNTIME_EVENT_OFFLINE_OPERATION_COMPLETED = 22,
156 MLN_RUNTIME_EVENT_MAP_CAMERA_TRANSITION_FINISHED = 23,
158
160typedef enum mln_runtime_event_source_type : uint32_t {
161 MLN_RUNTIME_EVENT_SOURCE_RUNTIME = 0,
162 MLN_RUNTIME_EVENT_SOURCE_MAP = 1,
164
166typedef enum mln_runtime_event_payload_type : uint32_t {
167 MLN_RUNTIME_EVENT_PAYLOAD_NONE = 0,
168 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_FRAME = 1,
169 MLN_RUNTIME_EVENT_PAYLOAD_RENDER_MAP = 2,
170 MLN_RUNTIME_EVENT_PAYLOAD_STYLE_IMAGE_MISSING = 3,
171 MLN_RUNTIME_EVENT_PAYLOAD_TILE_ACTION = 4,
172 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_STATUS = 5,
173 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_RESPONSE_ERROR = 6,
174 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_REGION_TILE_COUNT_LIMIT = 7,
175 MLN_RUNTIME_EVENT_PAYLOAD_OFFLINE_OPERATION_COMPLETED = 8,
176 MLN_RUNTIME_EVENT_PAYLOAD_CAMERA_TRANSITION_FINISHED = 9,
178
186
188typedef enum mln_render_mode : uint32_t {
189 MLN_RENDER_MODE_PARTIAL = 0,
190 MLN_RENDER_MODE_FULL = 1,
192
194typedef enum mln_tile_operation : uint32_t {
195 MLN_TILE_OPERATION_REQUESTED_FROM_CACHE = 0,
196 MLN_TILE_OPERATION_REQUESTED_FROM_NETWORK = 1,
197 MLN_TILE_OPERATION_LOAD_FROM_NETWORK = 2,
198 MLN_TILE_OPERATION_LOAD_FROM_CACHE = 3,
199 MLN_TILE_OPERATION_START_PARSE = 4,
200 MLN_TILE_OPERATION_END_PARSE = 5,
201 MLN_TILE_OPERATION_ERROR = 6,
202 MLN_TILE_OPERATION_CANCELLED = 7,
203 MLN_TILE_OPERATION_NULL = 8,
205
206typedef enum mln_resource_kind : uint32_t {
207 MLN_RESOURCE_KIND_UNKNOWN = 0,
208 MLN_RESOURCE_KIND_STYLE = 1,
209 MLN_RESOURCE_KIND_SOURCE = 2,
210 MLN_RESOURCE_KIND_TILE = 3,
211 MLN_RESOURCE_KIND_GLYPHS = 4,
212 MLN_RESOURCE_KIND_SPRITE_IMAGE = 5,
213 MLN_RESOURCE_KIND_SPRITE_JSON = 6,
214 MLN_RESOURCE_KIND_IMAGE = 7,
215} mln_resource_kind;
216
217typedef enum mln_resource_loading_method : uint32_t {
218 MLN_RESOURCE_LOADING_METHOD_ALL = 0,
219 MLN_RESOURCE_LOADING_METHOD_CACHE_ONLY = 1,
220 MLN_RESOURCE_LOADING_METHOD_NETWORK_ONLY = 2,
221} mln_resource_loading_method;
222
223typedef enum mln_resource_priority : uint32_t {
224 MLN_RESOURCE_PRIORITY_REGULAR = 0,
225 MLN_RESOURCE_PRIORITY_LOW = 1,
226} mln_resource_priority;
227
228typedef enum mln_resource_usage : uint32_t {
229 MLN_RESOURCE_USAGE_ONLINE = 0,
230 MLN_RESOURCE_USAGE_OFFLINE = 1,
231} mln_resource_usage;
232
233typedef enum mln_resource_storage_policy : uint32_t {
234 MLN_RESOURCE_STORAGE_POLICY_PERMANENT = 0,
235 MLN_RESOURCE_STORAGE_POLICY_VOLATILE = 1,
236} mln_resource_storage_policy;
237
238typedef enum mln_resource_response_status : uint32_t {
239 MLN_RESOURCE_RESPONSE_STATUS_OK = 0,
240 MLN_RESOURCE_RESPONSE_STATUS_ERROR = 1,
241 MLN_RESOURCE_RESPONSE_STATUS_NO_CONTENT = 2,
242 MLN_RESOURCE_RESPONSE_STATUS_NOT_MODIFIED = 3,
243} mln_resource_response_status;
244
245typedef enum mln_resource_error_reason : uint32_t {
246 MLN_RESOURCE_ERROR_REASON_NONE = 0,
247 MLN_RESOURCE_ERROR_REASON_NOT_FOUND = 1,
248 MLN_RESOURCE_ERROR_REASON_SERVER = 2,
249 MLN_RESOURCE_ERROR_REASON_CONNECTION = 3,
250 MLN_RESOURCE_ERROR_REASON_RATE_LIMIT = 4,
251 MLN_RESOURCE_ERROR_REASON_OTHER = 5,
252} mln_resource_error_reason;
253
254typedef enum mln_resource_provider_decision : uint32_t {
255 MLN_RESOURCE_PROVIDER_DECISION_PASS_THROUGH = 0,
256 MLN_RESOURCE_PROVIDER_DECISION_HANDLE = 1,
257} mln_resource_provider_decision;
258
269MLN_API mln_status mln_network_status_get(uint32_t* out_status) MLN_NOEXCEPT;
270
284MLN_API mln_status mln_network_status_set(uint32_t status) MLN_NOEXCEPT;
285
286typedef struct mln_runtime_options {
287 uint32_t size;
288 uint32_t flags;
290 const char* asset_path;
292 const char* cache_path;
294 uint64_t maximum_cache_size;
295} mln_runtime_options;
296
298typedef struct mln_rendering_stats {
299 uint32_t size;
305 int64_t frame_count;
311
323
326 uint32_t size;
328 uint32_t mode;
330
342
344typedef struct mln_tile_id {
345 uint32_t overscaled_z;
346 int32_t wrap;
347 uint32_t canonical_z;
348 uint32_t canonical_x;
349 uint32_t canonical_y;
351
354 uint32_t size;
356 uint32_t operation;
357 mln_tile_id tile_id;
362 const char* source_id;
366
381
384 uint32_t size;
385 mln_offline_region_id region_id;
388
391 uint32_t size;
392 mln_offline_region_id region_id;
394 uint32_t reason;
396
399 uint32_t size;
400 mln_offline_region_id region_id;
401 uint64_t limit;
403
417
419typedef struct mln_runtime_event {
420 uint32_t size;
421 uint32_t type;
423 uint32_t source_type;
429 void* source;
435 int32_t code;
437 uint32_t payload_type;
439 const void* payload;
443 const char* message;
447
448typedef struct mln_resource_transform_response {
449 uint32_t size;
452 const char* url;
455 void* context;
456} mln_resource_transform_response;
457
472 mln_resource_transform_response* response, const char* url, size_t url_size
473) MLN_NOEXCEPT;
474
498 void* user_data, uint32_t kind, const char* url,
499 mln_resource_transform_response* out_response
500);
501
502typedef struct mln_resource_transform {
503 uint32_t size;
505 void* user_data;
506} mln_resource_transform;
507
508typedef struct mln_resource_request {
509 uint32_t size;
510 const char* url;
511 uint32_t kind;
512 uint32_t loading_method;
513 uint32_t priority;
514 uint32_t usage;
515 uint32_t storage_policy;
516 bool has_range;
517 uint64_t range_start;
518 uint64_t range_end;
519 bool has_prior_modified;
520 int64_t prior_modified_unix_ms;
521 bool has_prior_expires;
522 int64_t prior_expires_unix_ms;
523 const char* prior_etag;
524 const uint8_t* prior_data;
525 size_t prior_data_size;
526} mln_resource_request;
527
528typedef struct mln_resource_response {
529 uint32_t size;
530 uint32_t status;
531 uint32_t error_reason;
533 const uint8_t* bytes;
534 size_t byte_count;
535 const char* error_message;
536 bool must_revalidate;
537 bool has_modified;
538 int64_t modified_unix_ms;
539 bool has_expires;
540 int64_t expires_unix_ms;
541 const char* etag;
542 bool has_retry_after;
543 int64_t retry_after_unix_ms;
544} mln_resource_response;
545
576 void* user_data, const mln_resource_request* request,
577 mln_resource_request_handle* handle
578);
579
580typedef struct mln_resource_provider {
581 uint32_t size;
583 void* user_data;
584} mln_resource_provider;
585
589MLN_API mln_runtime_options mln_runtime_options_default(void) MLN_NOEXCEPT;
590
606 const mln_runtime_options* options, mln_runtime** out_runtime
607) MLN_NOEXCEPT;
608
637 mln_runtime* runtime, const mln_resource_provider* provider
638) MLN_NOEXCEPT;
639
657MLN_API mln_status
658mln_runtime_clear_resource_provider(mln_runtime* runtime) MLN_NOEXCEPT;
659
679 mln_resource_request_handle* handle, const mln_resource_response* response
680) MLN_NOEXCEPT;
681
694 const mln_resource_request_handle* handle, bool* out_cancelled
695) MLN_NOEXCEPT;
696
707 mln_resource_request_handle* handle
708) MLN_NOEXCEPT;
709
730 mln_runtime* runtime, const mln_resource_transform* transform
731) MLN_NOEXCEPT;
732
746MLN_API mln_status
747mln_runtime_clear_resource_transform(mln_runtime* runtime) MLN_NOEXCEPT;
748
766 mln_runtime* runtime, uint32_t operation,
767 mln_offline_operation_id* out_operation_id
768) MLN_NOEXCEPT;
769
786 mln_runtime* runtime, mln_offline_operation_id operation_id
787) MLN_NOEXCEPT;
788
823MLN_API mln_status mln_runtime_destroy(mln_runtime* runtime) MLN_NOEXCEPT;
824
878MLN_API mln_status
879mln_runtime_pump(mln_runtime* runtime, int64_t timeout_ms) MLN_NOEXCEPT;
880
898 mln_runtime* runtime, mln_wake_source** out_source
899) MLN_NOEXCEPT;
900
917MLN_API mln_status mln_wake_source_signal(mln_wake_source* source) MLN_NOEXCEPT;
918
925MLN_API void mln_wake_source_destroy(mln_wake_source* source) MLN_NOEXCEPT;
926
963 mln_runtime* runtime, mln_runtime_event* out_event, bool* out_has_event
964) MLN_NOEXCEPT;
965
966#ifdef __cplusplus
967}
968#endif
969
970#endif // MAPLIBRE_NATIVE_C_RUNTIME_H
mln_status
Definition base.h:39
mln_status mln_runtime_offline_operation_discard(mln_runtime *runtime, mln_offline_operation_id operation_id)
mln_tile_operation
Definition runtime.h:194
mln_status mln_network_status_get(uint32_t *out_status)
mln_runtime_event_payload_type
Definition runtime.h:166
mln_status mln_runtime_clear_resource_transform(mln_runtime *runtime)
mln_status mln_runtime_create(const mln_runtime_options *options, mln_runtime **out_runtime)
void mln_wake_source_destroy(mln_wake_source *source)
mln_status mln_runtime_set_resource_provider(mln_runtime *runtime, const mln_resource_provider *provider)
mln_runtime_event_type
Definition runtime.h:133
mln_status mln_resource_request_complete(mln_resource_request_handle *handle, const mln_resource_response *response)
mln_status mln_wake_source_signal(mln_wake_source *source)
mln_status mln_runtime_pump(mln_runtime *runtime, int64_t timeout_ms)
uint32_t(* mln_resource_provider_callback)(void *user_data, const mln_resource_request *request, mln_resource_request_handle *handle)
Definition runtime.h:575
mln_status mln_runtime_poll_event(mln_runtime *runtime, mln_runtime_event *out_event, bool *out_has_event)
mln_status mln_runtime_run_ambient_cache_operation_start(mln_runtime *runtime, uint32_t operation, mln_offline_operation_id *out_operation_id)
mln_offline_operation_result_kind
Definition runtime.h:69
mln_runtime_event_source_type
Definition runtime.h:160
mln_status mln_resource_request_cancelled(const mln_resource_request_handle *handle, bool *out_cancelled)
mln_camera_change_mode
Definition runtime.h:180
@ MLN_CAMERA_CHANGE_MODE_IMMEDIATE
Definition runtime.h:182
@ MLN_CAMERA_CHANGE_MODE_ANIMATED
Definition runtime.h:184
mln_status mln_resource_transform_response_set_url(mln_resource_transform_response *response, const char *url, size_t url_size)
mln_runtime_options mln_runtime_options_default(void)
mln_status mln_runtime_set_resource_transform(mln_runtime *runtime, const mln_resource_transform *transform)
mln_status(* mln_resource_transform_callback)(void *user_data, uint32_t kind, const char *url, mln_resource_transform_response *out_response)
Definition runtime.h:497
void mln_resource_request_release(mln_resource_request_handle *handle)
mln_status mln_runtime_wake_source_acquire(mln_runtime *runtime, mln_wake_source **out_source)
uint64_t mln_offline_operation_id
Definition runtime.h:51
mln_offline_operation_kind
Definition runtime.h:54
mln_status mln_network_status_set(uint32_t status)
mln_status mln_runtime_destroy(mln_runtime *runtime)
mln_render_mode
Definition runtime.h:188
mln_status mln_runtime_clear_resource_provider(mln_runtime *runtime)
Definition runtime.h:78
uint32_t download_state
Definition runtime.h:81
Definition runtime.h:298
int64_t draw_call_count
Definition runtime.h:307
double encoding_time
Definition runtime.h:301
int64_t total_draw_call_count
Definition runtime.h:309
double rendering_time
Definition runtime.h:303
int64_t frame_count
Definition runtime.h:305
uint64_t transition_id
Definition runtime.h:379
uint32_t result_kind
Definition runtime.h:411
uint32_t operation_kind
Definition runtime.h:409
int32_t result_status
Definition runtime.h:413
uint32_t reason
Definition runtime.h:394
Definition runtime.h:313
bool needs_repaint
Definition runtime.h:318
uint32_t mode
Definition runtime.h:316
bool placement_changed
Definition runtime.h:320
Definition runtime.h:325
uint32_t mode
Definition runtime.h:328
size_t image_id_size
Definition runtime.h:340
const char * image_id
Definition runtime.h:338
Definition runtime.h:353
size_t source_id_size
Definition runtime.h:364
const char * source_id
Definition runtime.h:362
uint32_t operation
Definition runtime.h:356
Definition runtime.h:419
uint32_t payload_type
Definition runtime.h:437
const void * payload
Definition runtime.h:439
void * source
Definition runtime.h:429
int32_t code
Definition runtime.h:435
size_t message_size
Definition runtime.h:445
uint32_t source_type
Definition runtime.h:423
const char * message
Definition runtime.h:443
size_t payload_size
Definition runtime.h:441
Definition runtime.h:344