#ifndef daclient_h
#define daclient_h

#if __cplusplus
#define C_EXPORT extern "C" __attribute__ ((visibility ("default")))
#include <cstdint>
#else
#define C_EXPORT
#include <stdint.h>
#include <stdbool.h>
#endif


typedef struct daclient_attr_t {
    const char* name;
    const char* value;
    int value_len;
} daclient_attr_t;

#define MAX_EVENT_ATTRS 50

typedef struct daclient_event_t {
    const char* name;
    int n_attrs;
    int64_t timestamp;
    daclient_attr_t attrs[MAX_EVENT_ATTRS];
} daclient_event_t;

typedef int64_t (*daclient_timestamp_source)();
typedef void (*daclient_event_handler)(void* user_object, const daclient_event_t* event);

typedef struct daclient_settings_t {
    const char* assets_data;
    int assets_data_len;
    const char* config_mode;
    daclient_event_handler event_handler;
    void* user_object;
    const char* config_settings;
    const char* unused;
} daclient_settings_t;


C_EXPORT void* daclient_init(const daclient_settings_t* settings);
C_EXPORT void daclient_set_event_handler(void* ev_handle, daclient_event_handler event_handler, void* user_object);
C_EXPORT void* daclient_get_user_object(void* ev_handle);
C_EXPORT void daclient_deinit(void* ev_handle);

C_EXPORT void daclient_log_extra_output_events(void* ev_handle);
C_EXPORT void daclient_set_eventlog(void* ev_handle, const char* fname, const char* file, const char* title, bool include_timestamps);

C_EXPORT void daclient_start(void* ev_handle);
C_EXPORT void daclient_stop(void* ev_handle);
C_EXPORT bool daclient_is_busy(void* ev_handle);

C_EXPORT void daclient_send_event(void* ev_handle, int64_t timestamp, const char* event_type,
                                  const char* attr_name, const char* attr_value);
C_EXPORT void daclient_send_event2(void* ev_handle, int64_t timestamp, const char* event_type,
                                   const char* attr_name, const char* attr_value,
                                   const char* attr2_name, const char* attr2_value);
C_EXPORT void daclient_send_event_struct(void* ev_handle, const daclient_event_t* event);

C_EXPORT void daclient_send_bgra(void* ev_handle, int64_t timestamp, const char* image_data,
                                 int width, int height, int rotation, int iso);
C_EXPORT void daclient_send_bgra_with_attrs(void* ev_handle, int64_t timestamp, const char* image_data,
                                            int width, int height, int rotation, const daclient_attr_t* attrs, int n_attrs);
C_EXPORT void daclient_send_bgra_with_depth(void* ev_handle, int64_t timestamp, const char* image_data,
					    int width, int height, int rotation, int iso,
					    const char* depth_image_data, int depth_image_width, int depth_image_height,
					    int depth_image_rotation, const char* depth_image_type, bool is_float16);
C_EXPORT void daclient_send_bgra_with_attrs_with_depth(void* ev_handle, int64_t timestamp, const char* image_data,
                                                       int width, int height, int rotation, const daclient_attr_t* attrs, int n_attrs,
                                                       const char* depth_image_data, int depth_image_width, int depth_image_height,
                                                       int depth_image_rotation, const char* depth_image_type, bool is_float16);
C_EXPORT void daclient_send_rgba(void* ev_handle, int64_t timestamp, const char* image_data,
				 int width, int height, int rotation, int iso);
C_EXPORT void daclient_send_nv21(void* ev_handle, int64_t timestamp, const char* image_data,
                                 int width, int height, int rotation, int iso);
C_EXPORT void daclient_send_nv21_with_attrs(void* ev_handle, int64_t timestamp, const char* image_data,
                                            int width, int height, int rotation,
                                            const daclient_attr_t* attrs, int n_attrs);
C_EXPORT void daclient_send_gyro(void* ev_handle, int64_t timestamp,
                                 float x, float y, float z);
C_EXPORT void daclient_send_accel(void* ev_handle, int64_t timestamp,
                                  float x, float y, float z);
C_EXPORT void daclient_send_magnet(void* ev_handle, int64_t timestamp,
                                   float x, float y, float z);

C_EXPORT bool daclient_get_photinus_pattern(const char* hex, char* res_pattern, int res_pattern_len);


#endif
