Skip to content

Commit

Permalink
camera: add action API
Browse files Browse the repository at this point in the history
Without implementation for now.
  • Loading branch information
n115 authored and EmmanuelP committed Jul 21, 2021
1 parent f3d3fb5 commit 24a8035
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 0 deletions.
108 changes: 108 additions & 0 deletions src/arvcamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,114 @@ arv_camera_gv_set_packet_size_adjustment (ArvCamera *camera, ArvGvPacketSizeAdju
arv_gv_device_set_packet_size_adjustment (ARV_GV_DEVICE (priv->device), adjustment);
}

/**
* arv_camera_gv_configure_action_command:
* @camera: a #ArvCamera
* @command_name: the action command that will be configured (1-based)
* @device_key: a user defined 'password' that will be used to authorize action commands
* @group_key: a user defined group that will have to match for an action command
* @group_mask: a bit field that gets matched to a mask in the action command
* @error: a #GError placeholder, %NULL to ignore
*
* Configure a camera to accept action commands
*
* Since: 0.8.7
*/

void
arv_camera_gv_configure_action_command (ArvCamera *camera, const char *command_name,
guint32 device_key, guint32 group_key, guint32 group_mask, GError **error)
{
GError *local_error = NULL;

g_return_if_fail (arv_camera_is_gv_device (camera));

if (error == NULL)
arv_camera_set_string (camera, "ActionSelector", command_name, &local_error);
if (error == NULL)
arv_camera_set_integer (camera, "ActionDeviceKey", device_key, &local_error);
if (error == NULL)
arv_camera_set_integer (camera, "ActionGroupKey", group_key, &local_error);
if (error == NULL)
arv_camera_set_integer (camera, "ActionGroupMask", group_key, &local_error);

if (local_error != NULL)
g_propagate_error (error, local_error);
}

/**
* arv_camera_gv_get_available_action_commands:
* @camera: a #ArvCamera
* @n_commands: (out): number of action commands
* @error: a #GError placeholder, %NULL to ignore
*
* Returns: (array length=n_commands) (transfer container): a newly allocated array of strings, which must be freed
* using g_free().
*
* Since: 0.8.7
*/

const char **
arv_camera_gv_get_available_action_commands (ArvCamera *camera, guint *n_commands, GError **error)
{
return arv_camera_dup_available_enumerations_as_strings (camera, "ActionSelector", n_commands, error);
}

/**
* arv_camera_gv_issue_action_command:
* @device_key: a user defined 'password' that will be used to authorize action commands
* @group_key: a user defined group that will have to match for an action command
* @group_mask: a bit field that gets matched to a mask in the action command
* @broadcast_address: the address the action command is sent to
* @inet_addresses: (out): a placeholder for an array of acknowledge IP adresses
* @n_acknowledges: (out): a placeholder for the number of ackowledges
* @error: a GError placeholder, %NULL to ignore
*
* Issue action command
*
* Returns: %TRUE if successfull
*
* Since: 0.8.7
*/

gboolean
arv_camera_gv_issue_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges, GError **error)
{
return arv_gv_device_issue_scheduled_action_command (device_key, group_key, group_mask,
0, broadcast_address,
inet_addresses, n_acknowledges, error);
}

/**
* arv_camera_gv_issue_scheduled_action_command:
* @device_key: a user defined 'password' that will be used to authorize action commands
* @group_key: a user defined group that will have to match for an action command
* @group_mask: a bit field that gets matched to a mask in the action command
* @timestamp_ns: action time, in nanosecond
* @broadcast_address: the address the action command is sent to
* @inet_addresses: (out): a placeholder for an array of acknowledge IP adresses
* @n_acknowledges: (out): a placeholder for the number of ackowledges
* @error: a GError placeholder, %NULL to ignore
*
* Issue action command
*
* Returns: %TRUE if successfull
*
* Since: 0.8.7
*/

gboolean
arv_camera_gv_issue_scheduled_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
guint64 timestamp_ns, GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges, GError **error)
{
return arv_gv_device_issue_scheduled_action_command (device_key, group_key, group_mask,
timestamp_ns, broadcast_address,
inet_addresses, n_acknowledges, error);
}

/**
* arv_camera_is_uv_device:
* @camera: a #ArvCamera
Expand Down
13 changes: 13 additions & 0 deletions src/arvcamera.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <arvstream.h>
#include <arvgvstream.h>
#include <arvgvdevice.h>
#include <gio/gio.h>

G_BEGIN_DECLS

Expand Down Expand Up @@ -191,6 +192,18 @@ void arv_camera_gv_set_packet_size_adjustment (ArvCamera *camera,

void arv_camera_gv_set_stream_options (ArvCamera *camera, ArvGvStreamOption options);

void arv_camera_gv_configure_action_command (ArvCamera *camera, const char *command_name,
guint32 device_key, guint32 group_key, guint32 group_mask,
GError **error);
const char ** arv_camera_gv_get_available_action_commands (ArvCamera *camera, guint *n_commands, GError **error);
gboolean arv_camera_gv_issue_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges,
GError **error);
gboolean arv_camera_gv_issue_scheduled_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
guint64 timestamp_ns, GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges, GError **error);

/* USB3Vision specific API */

gboolean arv_camera_is_uv_device (ArvCamera *camera);
Expand Down
9 changes: 9 additions & 0 deletions src/arvgvdevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ arv_gv_device_heartbeat_thread (void *data)

/* ArvGvDevice implemenation */

gboolean
arv_gv_device_issue_scheduled_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
guint64 timestamp_ns, GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges,
GError **error)
{
return FALSE;
}

/**
* arv_gv_device_take_control:
* @gv_device: a #ArvGvDevice
Expand Down
5 changes: 5 additions & 0 deletions src/arvgvdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ void arv_gv_device_set_stream_options (ArvGvDevice *gv_device, ArvGvStreamO

gboolean arv_gv_device_is_controller (ArvGvDevice *gv_device);

gboolean arv_gv_device_issue_scheduled_action_command (guint32 device_key, guint32 group_key, guint32 group_mask,
guint64 timestamp_ns, GInetAddress *broadcast_address,
GInetAddress **inet_addresses, guint *n_acknowledges,
GError **error);

G_END_DECLS

#endif

0 comments on commit 24a8035

Please sign in to comment.