![]() |
Axoverlay Library
|
Overlay helper library for creating and rendering custom overlays. More...
#include <glib.h>
Go to the source code of this file.
Data Structures | |
struct | axoverlay_stream_data |
struct | axoverlay_overlay_data |
struct | axoverlay_palette_color |
struct | axoverlay_settings |
Macros | |
#define | AXOVERLAY_QUAD_CAMERA_ID 0 |
#define | AXOVERLAY_DEFAULT_CAMERA_ID 1 |
#define | AXOVERLAY_Z_PRIO_LOW 0 |
#define | AXOVERLAY_Z_PRIO_MEDIUM 1000 |
#define | AXOVERLAY_Z_PRIO_HIGH 2000 |
#define | AXOVERLAY_Z_PRIO_VERY_HIGH 3000 |
Typedefs | |
typedef gboolean(* | axoverlay_stream_select_function) (gint camera, gint width, gint height, gint rotation, gboolean is_mirrored, enum axoverlay_stream_type type) |
typedef void(* | axoverlay_adjustment_function) (gint id, struct axoverlay_stream_data *stream, enum axoverlay_position_type *postype, gfloat *overlay_x, gfloat *overlay_y, gint *overlay_width, gint *overlay_height, gpointer user_data) |
typedef void(* | axoverlay_render_function) (gpointer rendering_context, gint id, struct axoverlay_stream_data *stream, enum axoverlay_position_type postype, gfloat overlay_x, gfloat overlay_y, gint overlay_width, gint overlay_height, gpointer user_data) |
Overlay helper library for creating and rendering custom overlays.
axoverlay contains a number of functions that simplifies the task of creating and rendering custom overlays.
Copyright (C) 2017, Axis Communications AB, LUND, SWEDEN
#define AXOVERLAY_DEFAULT_CAMERA_ID 1 |
Id used for the default camera.
#define AXOVERLAY_QUAD_CAMERA_ID 0 |
Id used for the quad camera.
#define AXOVERLAY_Z_PRIO_HIGH 2000 |
Predefined value for high z order priority.
#define AXOVERLAY_Z_PRIO_LOW 0 |
Predefined value for low z order priority.
#define AXOVERLAY_Z_PRIO_MEDIUM 1000 |
Predefined value for medium z order priority.
#define AXOVERLAY_Z_PRIO_VERY_HIGH 3000 |
Predefined value for very high z order priority.
typedef void(* axoverlay_adjustment_function) (gint id, struct axoverlay_stream_data *stream, enum axoverlay_position_type *postype, gfloat *overlay_x, gfloat *overlay_y, gint *overlay_width, gint *overlay_height, gpointer user_data) |
The purpose of this callback is to let developers make adjustments to the size and position of their overlays for each stream. This callback function is called prior to rendering every time when an overlay is rendered on a stream. This may happen when a stream opens/changes or when you manually force a redraw. If the size of the overlay differs between invokations it will be restarted and may flicker. It is adviced to keep the size constant for performance reasons.
Note that there is no need to modify the size of the overlay to match the stream resolution since the is done automatically unless scale_to_stream was set to FALSE when the overlay was created..
id | The id of the overlay |
stream | The stream that the overlay is displayed on |
postype | The position type. |
overlay_x | The x coordinate of the overlay, may be changed |
overlay_y | The y coordinate of the overlay, may be changed |
overlay_width | The width of the overlay, may be changed |
overlay_height | The height of the overlay, may be changed |
user_data | Optional user data associated with this overlay |
typedef void(* axoverlay_render_function) (gpointer rendering_context, gint id, struct axoverlay_stream_data *stream, enum axoverlay_position_type postype, gfloat overlay_x, gfloat overlay_y, gint overlay_width, gint overlay_height, gpointer user_data) |
A callback function called whenever the system redraws an overlay. This can happen in two cases, axoverlay_redraw() is called or a new stream is started. In the first case the callback will execute in the thread that calls axoverlay_redraw() and in the second case it will execute in the thread that called axoverlay_init().
rendering_context | A pointer to the rendering context used by the backend. For the Cairo backend ithas the type 'cairo_t'. |
id | The id of the overlay |
stream | Information about the stream that is currently being rendered to, usually you do not need this information unless you want to rotate your overlay when the stream is rotated. |
postype | The position type. |
overlay_x | The x coordinate of the overlay, may be changed |
overlay_y | The y coordinate of the overlay, may be changed |
overlay_width | The width of the overlay, may be changed |
overlay_height | The height of the overlay, may be changed |
user_data | Optional user data associated with this overlay |
typedef gboolean(* axoverlay_stream_select_function) (gint camera, gint width, gint height, gint rotation, gboolean is_mirrored, enum axoverlay_stream_type type) |
Callback that can be used to select which streams to render overlays to. Note that YCBCR streams are always skipped since these are used for analytics.
camera | The id of the camera that the stream is for. |
width | The width of the stream For further details see the comments for the stream_data struct. |
height | The height of the stream For further details see the comments for the stream_data struct. |
rotation | The rotation of the stream. |
is_mirrored | TRUE if mirroring is enabled for the stream. |
This enum contains constants for the different anchor points of the overlay. All custom coordinates are fr the anchor point of the overlay. So the the nomalized position 0x0 menas that the top-left of the overlay is placed at 0x0 if anchor point is set to AXOVERLAY_ANCHOR_TOP_LEFT.
Enumerator | |
---|---|
AXOVERLAY_ANCHOR_TOP_LEFT | Anchor point top-left |
AXOVERLAY_ANCHOR_CENTER | Anchor center |
enum axoverlay_colorspace |
This enum contains constants for the different types of colorspaces the overlays can be created with. ARGB32 is the default, however the 1/4 bit palette formats may also be used. Note that when using the palette formats only the alpha channel matters (when rendering with cairo) and you also need to set the palette colors manually using dbus-commands.
enum axoverlay_error_code |
Axoverlay error codes.
This enum contains constants for the different position types. For the first four types any x and y coordinates specified are ignored.
void axoverlay_cleanup | ( | void | ) |
Frees up allocated resources.
gint axoverlay_create_overlay | ( | struct axoverlay_overlay_data * | data, |
gpointer | user_data, | ||
GError ** | error | ||
) |
Creates an overlay at the specified position. The overlay will be rendered once for each stream.
Note that this function does not cause the overlay to be drawn. To get the the overlay to show you have to call axoverlay_redraw().
data | Description of the overlay to create. |
user_data | Pointer to optional user data associated with this overlay. The user data pointer will be passed to the adjust and render callbacks |
error | Location to store potential error at. |
void axoverlay_destroy_overlay | ( | gint | id, |
GError ** | error | ||
) |
Destroys the overlay with the given id if it exists.
Note that this functions will trigger a redraw of all overlays on all streams.
id | The id of the overlay to destroy. This would be the id returned by the axoverlay_create_overlay() function. |
error | Location to store potential error at. |
gint axoverlay_get_max_resolution_height | ( | gint | camera, |
GError ** | error | ||
) |
Reads the width of the camera's base resolution.
camera | The camera to get resolution for. |
error | Location to store potential error at. |
gint axoverlay_get_max_resolution_width | ( | gint | camera, |
GError ** | error | ||
) |
Reads the width of the camera's base resolution.
camera | The camera to get resolution for. |
error | Location to store potential error at. |
gint axoverlay_get_number_of_palette_colors | ( | GError ** | error | ) |
Get the number of palette colors.
error | Location to store potential error at. |
void axoverlay_get_palette_color | ( | gint | index, |
struct axoverlay_palette_color * | color, | ||
GError ** | error | ||
) |
Get the palette color with a specific index.
index | The index of the color to get. |
color | Location to store the returned color at. |
error | Location to store potential error at. |
void axoverlay_init | ( | struct axoverlay_settings * | axoverlay_settings, |
GError ** | error | ||
) |
Initializes the axoverlay system. This function must be called before any other axoverlay function. The thread that calls this function must have a glib main-loop.
axoverlay_settings | A setting struct where general callbacks. |
error | Location to store potential error at. |
void axoverlay_init_axoverlay_settings | ( | struct axoverlay_settings * | axoverlay_settings | ) |
Initializes an axoverlay_settings struct with default values;
void axoverlay_init_overlay_data | ( | struct axoverlay_overlay_data * | data | ) |
Initialize an overlay_data struct with default values.
data | The struct to initialize. |
gboolean axoverlay_is_backend_supported | ( | enum axoverlay_backend_type | backend | ) |
Enables for axoverlay user to check if the intended backend to be used is supported.
void axoverlay_redraw | ( | GError ** | error | ) |
Signals to the system that a redraw should be done. This will in turn call the render function provided in axoverlay_init().
error | Location to store potential error at. |
void axoverlay_reload_streams | ( | GError ** | error | ) |
Reload all stream information. All information about running streams will be cleared and loaded again. The select callback will be invoked for each stream.
Note that all overlays will disappear for a short while since they are destroyed and then created again.
error | Location to store potential error at. |
void axoverlay_set_overlay_position | ( | gint | id, |
enum axoverlay_position_type | postype, | ||
gfloat | x, | ||
gfloat | y, | ||
GError ** | error | ||
) |
Updates the position of the overlay with the given id if it exists. Calling this function will not trigger the overlay to be redrawn. The new position will be applied the next time axoverlay_redraw() is called.
id | The id of the overlay. |
postype | The postion type. This parameter controls how the x and y parameters are interpreted. See documentation of position_type for details. |
x | The x position of the top-left corner of the overlay. |
y | The y position of the top-left corner of the overlay. |
error | Location to store potential error at. |
void axoverlay_set_overlay_size | ( | gint | id, |
gint | width, | ||
gint | height, | ||
GError ** | error | ||
) |
Updates the size of the overlay with the given id if it exists. Calling this function will not trigger the overlay to be redrawn. The new size will be applied the next time axoverlay_redraw() is called.
id | The id of the overlay. |
width | The width of the overlay in pixels. |
height | The height of the overlay in pixels. |
error | Location to store potential error at. |
void axoverlay_set_palette_color | ( | gint | index, |
struct axoverlay_palette_color * | color, | ||
GError ** | error | ||
) |
Set the palette color with a specific index.
index | The index of the color to set. |
color | The color to set. |
error | Location to store potential error at. |