[aravis] doc: add since information in user API, and a simple ArvCamera example app.



commit a141d84a723404fb5f32f3c5f76b7805681f75c6
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Wed Oct 17 14:40:52 2012 +0200

    doc: add since information in user API, and a simple ArvCamera example app.

 TODO                                      |    5 +-
 docs/reference/aravis/aravis-sections.txt |    2 +-
 src/arvbuffer.c                           |   10 ++
 src/arvcamera.c                           |  111 +++++++++++++++++++++++-
 src/arvdevice.c                           |   14 +++
 src/arvinterface.c                        |   39 ++++++---
 src/arvstream.c                           |   20 ++++-
 tests/.gitignore                          |    1 +
 tests/Makefile.am                         |    5 +-
 tests/arvexample.c                        |  133 +++++++++++++++++++++++++++++
 10 files changed, 318 insertions(+), 22 deletions(-)
---
diff --git a/TODO b/TODO
index b4058d0..17b5fe0 100644
--- a/TODO
+++ b/TODO
@@ -1,3 +1,6 @@
-- rework of genicam node objects, probably using the same code as lasem.
 - add a feature tree and editor to the simple viewer.
 - support more genicam features.
+- improve support of device creation by IP address.
+    As we have to find the interface with which we reach the device,
+    we need to extend the discovery code in order to send the discover
+    packet to a given IP address, instead of a broadcast one.
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 0f91fb8..c65fb86 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -581,7 +581,6 @@ arv_stream_get_n_buffers
 arv_stream_get_statistics
 arv_stream_get_emit_signals
 arv_stream_set_emit_signals
-arv_g_string_append_hex_dump
 <SUBSECTION Standard>
 ARV_STREAM
 ARV_IS_STREAM
@@ -1401,6 +1400,7 @@ arv_warning_interface
 arv_warning_misc
 arv_warning_stream
 arv_warning_stream_thread
+arv_g_string_append_hex_dump
 </SECTION>
 
 <SECTION>
diff --git a/src/arvbuffer.c b/src/arvbuffer.c
index 6ffab56..bd9d816 100644
--- a/src/arvbuffer.c
+++ b/src/arvbuffer.c
@@ -50,6 +50,10 @@ static GObjectClass *parent_class = NULL;
  *
  * If @user_data_destroy_func is non NULL, it will be called in order to destroy
  * user_data when the buffer is destroyed.
+ *
+ * Returns: a new #ArvBuffer object
+ *
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -82,6 +86,10 @@ arv_buffer_new_full (size_t size, void *preallocated, void *user_data, GDestroyN
  * The data space can be either preallocated, and the caller is responsible
  * for it's deallocation, or allocated by this function. If it is the case,
  * data memory will be freed when the buffer is destroyed.
+ *
+ * Returns: a new #ArvBuffer object
+ *
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -95,6 +103,8 @@ arv_buffer_new (size_t size, void *preallocated)
  * @buffer: a #ArvBuffer
  *
  * Clears the buffer status.
+ *
+ * Since: 0.2.0
  */
 
 void
diff --git a/src/arvcamera.c b/src/arvcamera.c
index de3411b..33370d3 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -28,6 +28,14 @@
  * complexity of the genicam interface by providing a simple API, with the
  * drawback of not exposing all the available features. See #ArvDevice and
  * #ArvGc for a more advanced use of the Aravis library.
+ *
+ * <example id="arv-example"><title>Sample application of the ArvCamera API</title>
+ * <programlisting>
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"; parse="text" href="../../../../tests/arvexample.c">
+ *   <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
+ * </xi:include>
+ * </programlisting>
+ * </example>
  */
 
 #include <arvcamera.h>
@@ -92,6 +100,8 @@ enum
  * #ArvStreamCallback for details regarding the callback function.
  *
  * Returns: (transfer full): a new #ArvStream.
+ *
+ * Since: 0.2.0
  */
 
 ArvStream *
@@ -109,6 +119,8 @@ arv_camera_create_stream (ArvCamera *camera, ArvStreamCallback callback, gpointe
  * @camera: a #ArvCamera
  *
  * Returns: the camera vendor name.
+ *
+ * Since: 0.2.0
  */
 
 const char *
@@ -124,6 +136,8 @@ arv_camera_get_vendor_name (ArvCamera *camera)
  * @camera: a #ArvCamera
  *
  * Returns: the camera model name.
+ *
+ * Since: 0.2.0
  */
 
 const char *
@@ -139,6 +153,8 @@ arv_camera_get_model_name (ArvCamera *camera)
  * @camera: a #ArvCamera
  *
  * Returns: the camera device ID.
+ *
+ * Since: 0.2.0
  */
 
 const char *
@@ -156,6 +172,8 @@ arv_camera_get_device_id (ArvCamera *camera)
  * @camera: a #ArvCamera
  * @width: (out): camera sensor width
  * @height: (out): camera sensor height
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -179,6 +197,8 @@ arv_camera_get_sensor_size (ArvCamera *camera, gint *width, gint *height)
  *
  * Defines the region of interest which will be transmitted in the video
  * stream.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -205,6 +225,8 @@ arv_camera_set_region (ArvCamera *camera, gint x, gint y, gint width, gint heigh
  * @height: (out): region height
  *
  * Retrieves the current region of interest.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -229,6 +251,8 @@ arv_camera_get_region (ArvCamera *camera, gint *x, gint *y, gint *width, gint *h
  * @max: (out): maximum width
  *
  * Retrieves the valid range for image width.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -253,6 +277,8 @@ arv_camera_get_width_bounds (ArvCamera *camera, gint *min, gint *max)
  * @max: (out): maximum height
  *
  * Retrieves the valid range for image height.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -278,6 +304,8 @@ arv_camera_get_height_bounds (ArvCamera *camera, gint *min, gint *max)
  *
  * Defines binning in both directions. Not all cameras support this
  * feature.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -298,6 +326,8 @@ arv_camera_set_binning (ArvCamera *camera, gint dx, gint dy)
  * @dy: (out): vertical binning placeholder
  *
  * Retrieves binning in both directions.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -317,6 +347,8 @@ arv_camera_get_binning (ArvCamera *camera, gint *dx, gint *dy)
  * @format: pixel format
  *
  * Defines pixel format.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -333,6 +365,8 @@ arv_camera_set_pixel_format (ArvCamera *camera, ArvPixelFormat format)
  * @format: pixel format
  *
  * Defines pixel format described by a string.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -348,6 +382,8 @@ arv_camera_set_pixel_format_from_string (ArvCamera *camera, const char * format)
  * @camera: a #ArvCamera
  *
  * Returns: pixel format.
+ *
+ * Since: 0.2.0
  */
 
 ArvPixelFormat
@@ -363,6 +399,8 @@ arv_camera_get_pixel_format (ArvCamera *camera)
  * @camera: a #ArvCamera
  *
  * Retuns: pixel format as string, NULL on error.
+ *
+ * Since: 0.2.0
  */
 
 const char *
@@ -381,6 +419,8 @@ arv_camera_get_pixel_format_as_string (ArvCamera *camera)
  * Retrieves the list of all available pixel formats.
  *
  * Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of #ArvPixelFormat
+ *
+ * Since: 0.2.0
  */
 
 gint64 *
@@ -399,6 +439,8 @@ arv_camera_get_available_pixel_formats (ArvCamera *camera, guint *n_pixel_format
  * Retrieves the list of all available pixel formats as strings.
  *
  * Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of strings.
+ *
+ * Since: 0.2.0
  */
 
 const char **
@@ -418,6 +460,8 @@ arv_camera_get_available_pixel_formats_as_strings (ArvCamera *camera, guint *n_p
  * In general, these human-readable strings cannot be used as settings.
  *
  * Returns: (array length=n_pixel_formats) (transfer container): a newly allocated array of string constants.
+ *
+ * Since: 0.2.0
  */
 
 const char **
@@ -473,6 +517,8 @@ arv_camera_get_available_pixel_formats_as_display_names (ArvCamera *camera, guin
  * @camera: a #ArvCamera
  *
  * Starts video stream acquisition.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -488,6 +534,8 @@ arv_camera_start_acquisition (ArvCamera *camera)
  * @camera: a #ArvCamera
  *
  * Stops video stream acquisition.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -504,6 +552,8 @@ arv_camera_stop_acquisition (ArvCamera *camera)
  * @acquisition_mode: acquisition mode
  *
  * Defines acquisition mode.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -520,6 +570,8 @@ arv_camera_set_acquisition_mode (ArvCamera *camera, ArvAcquisitionMode acquisiti
  * @camera: a #ArvCamera
  *
  * Returns: acquisition mode.
+ *
+ * Since: 0.2.0
  */
 
 ArvAcquisitionMode
@@ -541,6 +593,8 @@ arv_camera_get_acquisition_mode (ArvCamera *camera)
  *
  * Configures a fixed frame rate mode. Once acquisition start is triggered, the
  * video stream will be acquired with the given frame rate.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -585,6 +639,8 @@ arv_camera_set_frame_rate (ArvCamera *camera, double frame_rate)
  * @camera: a #ArvCamera
  *
  * Returns: actual frame rate, in Hz.
+ *
+ * Since: 0.2.0
  */
 
 double
@@ -614,6 +670,8 @@ arv_camera_get_frame_rate (ArvCamera *camera)
  *
  * Source can also be "Software". In this case, an acquisition is triggered
  * by a call to arv_camera_software_trigger().
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -647,6 +705,8 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
  *
  * Sets the trigger source. This function doesn't check if the camera is configured
  * to actually use this source as a trigger.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -666,6 +726,8 @@ arv_camera_set_trigger_source (ArvCamera *camera, const char *source)
  * to actually use this source as a trigger.
  *
  * Returns: a string containing the trigger source name, NULL on error.
+ *
+ * Since: 0.2.0
  */
 
 const char *
@@ -682,6 +744,8 @@ arv_camera_get_trigger_source (ArvCamera *camera)
  *
  * Sends a software trigger command to @camera. The camera must be previously
  * configured to use a software trigger, using @arv_camera_set_trigger().
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -699,6 +763,8 @@ arv_camera_software_trigger (ArvCamera *camera)
  *
  * Sets exposure time. User should take care to set a value compatible with
  * the desired frame rate.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -727,6 +793,8 @@ arv_camera_set_exposure_time (ArvCamera *camera, double exposure_time_us)
  * @camera: a #ArvCamera
  *
  * Returns: current exposure time, in Âs.
+ *
+ * Since: 0.2.0
  */
 
 double
@@ -744,6 +812,8 @@ arv_camera_get_exposure_time (ArvCamera *camera)
  * @max: (out): maximum exposure time
  *
  * Retrieves exposure time bounds, in Âs.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -778,7 +848,9 @@ arv_camera_get_exposure_time_bounds (ArvCamera *camera, double *min, double *max
  * @auto_mode: auto exposure mode selection
  *
  * Configures automatic exposure feature.
- **/
+ *
+ * Since: 0.2.0
+ */
 
 void
 arv_camera_set_exposure_time_auto (ArvCamera *camera, ArvAuto auto_mode)
@@ -793,7 +865,9 @@ arv_camera_set_exposure_time_auto (ArvCamera *camera, ArvAuto auto_mode)
  * @camera: a #ArvCamera
  *
  * Returns: auto exposure mode selection
- **/
+ *
+ * Since: 0.2.0
+ */
 
 ArvAuto
 arv_camera_get_exposure_time_auto (ArvCamera *camera)
@@ -811,6 +885,8 @@ arv_camera_get_exposure_time_auto (ArvCamera *camera)
  * @gain: gain value
  *
  * Sets the gain of the ADC converter.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -832,6 +908,8 @@ arv_camera_set_gain (ArvCamera *camera, double gain)
  * @camera: a #ArvCamera
  *
  * Returns: the current gain setting.
+ *
+ * Since: 0.2.0
  */
 
 double
@@ -852,6 +930,8 @@ arv_camera_get_gain (ArvCamera *camera)
  * @max: (out): maximum gain
  *
  * Retrieves gain bounds.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -878,9 +958,11 @@ arv_camera_get_gain_bounds (ArvCamera *camera, double *min, double *max)
 /**
  * arv_camera_set_gain_auto:
  * @camera: a #ArvCamera
- * @auto_mode: auto gaine mode selection
+ * @auto_mode: auto gain mode selection
  *
  * Configures automatic gain feature.
+ *
+ * Since: 0.2.0
  **/
 
 void
@@ -896,6 +978,8 @@ arv_camera_set_gain_auto (ArvCamera *camera, ArvAuto auto_mode)
  * @camera: a #ArvCamera
  *
  * Returns: auto gain mode selection
+ *
+ * Since: 0.2.0
  **/
 
 ArvAuto
@@ -916,6 +1000,8 @@ arv_camera_get_gain_auto (ArvCamera *camera)
  * for the creation of the stream buffers.
  *
  * Returns: frame storage size, in bytes.
+ *
+ * Since: 0.2.0
  */
 
 guint
@@ -933,6 +1019,8 @@ arv_camera_get_payload (ArvCamera *camera)
  * Retrieves the #ArvDevice object for more complete access to camera features.
  *
  * Returns: (transfer none): underlying device object.
+ *
+ * Since: 0.2.0
  */
 
 ArvDevice *
@@ -946,7 +1034,10 @@ arv_camera_get_device (ArvCamera *camera)
 /**
  * arv_camera_is_frame_rate_available:
  * @camera: a #ArvCamera
+ *
  * Returns: TRUE if FrameRate feature is available
+ *
+ * Since: 0.2.0
  */
 
 gboolean
@@ -966,7 +1057,10 @@ arv_camera_is_frame_rate_available (ArvCamera *camera)
 /**
  * arv_camera_is_exposure_time_available:
  * @camera: a #ArvCamera
+ *
  * Returns: TRUE if Exposure Time feature is available.
+ *
+ * Since: 0.2.0
  */
 
 gboolean
@@ -980,7 +1074,10 @@ arv_camera_is_exposure_time_available (ArvCamera *camera)
 /**
  * arv_camera_is_exposure_auto_available:
  * @camera: a #ArvCamera
+ *
  * Returns: TRUE if Exposure Auto feature is available.
+ *
+ * Since: 0.2.0
  */
 
 gboolean
@@ -994,7 +1091,10 @@ arv_camera_is_exposure_auto_available (ArvCamera *camera)
 /**
  * arv_camera_is_gain_available:
  * @camera: a #ArvCamera
+ *
  * Returns: TRUE if Gain feature is available.
+ *
+ * Since: 0.2.0
  */
 
 gboolean
@@ -1011,7 +1111,10 @@ arv_camera_is_gain_available (ArvCamera *camera)
 /**
  * arv_camera_is_gain_auto_available:
  * @camera: a #ArvCamera
+ *
  * Returns: TRUE if Gain feature is available.
+ *
+ * Since: 0.2.0
  */
 
 gboolean
@@ -1030,6 +1133,8 @@ arv_camera_is_gain_auto_available (ArvCamera *camera)
  * first available camera.
  *
  * Returns: a new #ArvCamera.
+ *
+ * Since: 0.2.0
  */
 
 ArvCamera *
diff --git a/src/arvdevice.c b/src/arvdevice.c
index a7767b5..38fa500 100644
--- a/src/arvdevice.c
+++ b/src/arvdevice.c
@@ -64,6 +64,8 @@ arv_device_error_quark (void)
  *
  * Creates a new #ArvStream for video stream handling. See
  * @ArvStreamCallback for details regarding the callback function.
+ *
+ * Since: 0.2.0
  */
 
 ArvStream *
@@ -121,6 +123,8 @@ arv_device_write_register (ArvDevice *device, guint32 address, guint32 value, GE
  * Return value: (transfer none): the genicam interface.
  *
  * Retrieves the genicam interface of the given device.
+ *
+ * Since: 0.2.0
  */
 
 ArvGc *
@@ -146,6 +150,8 @@ _get_genicam_xml (ArvDevice *device, size_t *size)
  * Return value: a pointer to the Genicam XML data, owned by the device.
  *
  * Gets the Genicam XML data stored in the device memory.
+ *
+ * Since: 0.2.0
  **/
 
 const char *
@@ -163,6 +169,8 @@ arv_device_get_genicam_xml (ArvDevice *device, size_t *size)
  * @feature: feature name
  *
  * Return value: (transfer none): the genicam node corresponding to the feature name, NULL if not found.
+ *
+ * Since: 0.2.0
  */
 
 ArvGcNode *
@@ -195,6 +203,8 @@ _set_status (ArvDevice *device, ArvDeviceStatus status, const char *message)
  * @feature: feature name
  *
  * Execute a genicam command. If an error occur, this function change the device status.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -496,6 +506,8 @@ arv_device_get_available_enumeration_feature_values (ArvDevice *device, const ch
  * Get all the available values of @feature, as strings.
  *
  * Returns: (array length=n_values) (transfer container): a newly created array of const strings, which must freed after use using g_free.
+ *
+ * Since: 0.2.0
  */
 
 const char **
@@ -588,6 +600,8 @@ arv_device_class_init (ArvDeviceClass *device_class)
 	 *
 	 * This signal may be emited from a thread different than the main one,
 	 * so please take care to shared data access from the callback.
+	 *
+	 * Since: 0.2.0
 	 */
 
 	arv_device_signals[ARV_DEVICE_SIGNAL_CONTROL_LOST] =
diff --git a/src/arvinterface.c b/src/arvinterface.c
index 4a02a69..6a5fe18 100644
--- a/src/arvinterface.c
+++ b/src/arvinterface.c
@@ -58,7 +58,9 @@ arv_interface_clear_device_ids (ArvInterface *interface)
  *
  * Updates the internal list of available devices. This may change the
  * connection between a list index and a device ID.
- **/
+ *
+ * Since: 0.2.0
+ */
 
 void
 arv_interface_update_device_list (ArvInterface *interface)
@@ -73,12 +75,15 @@ arv_interface_update_device_list (ArvInterface *interface)
 /**
  * arv_interface_get_n_devices
  * @interface: a #ArvInterface
- * Return value: the number of available devices 
  *
  * Queries the number of available devices on this interface. Prior to this
  * call the @arv_interface_update_device_list function must be called. The list content will not
  * change until the next call of the update function.
- **/
+ *
+ * Returns: the number of available devices 
+ *
+ * Since: 0.2.0
+ */
 
 unsigned int
 arv_interface_get_n_devices (ArvInterface *interface)
@@ -93,11 +98,14 @@ arv_interface_get_n_devices (ArvInterface *interface)
  * arv_interface_get_device_id
  * @interface: a #ArvInterface
  * @index: device index
- * Return value: a unique device id
  *
  * Queries the unique device id corresponding to index.  Prior to this
  * call the @arv_interface_update_device_list function must be called.
- **/
+ *
+ * Returns: a unique device id
+ *
+ * Since: 0.2.0
+ */
 
 const char *
 arv_interface_get_device_id (ArvInterface *interface, unsigned int index)
@@ -115,7 +123,6 @@ arv_interface_get_device_id (ArvInterface *interface, unsigned int index)
  * arv_interface_get_device_physical_id
  * @interface: a #ArvInterface
  * @index: device index
- * Return value: a physical device id
  *
  * Queries the physical device id corresponding to index such
  * as the MAC address for Ethernet based devices, bus id for PCI,
@@ -123,7 +130,11 @@ arv_interface_get_device_id (ArvInterface *interface, unsigned int index)
  *
  * Prior to this call the @arv_interface_update_device_list
  * function must be called.
- **/
+ *
+ * Returns: a physical device id
+ *
+ * Since: 0.2.0
+ */
 
 const char *
 arv_interface_get_device_physical_id (ArvInterface *interface, unsigned int index)
@@ -141,7 +152,6 @@ arv_interface_get_device_physical_id (ArvInterface *interface, unsigned int inde
  * arv_interface_get_device_address
  * @interface: a #ArvInterface
  * @index: device index
- * Return value: (transfer none): the device address
  *
  * queries the device address (IP address in the case of an ethernet camera). Useful
  * for constructing manual connections to devices using @arv_gv_device_new
@@ -149,8 +159,10 @@ arv_interface_get_device_physical_id (ArvInterface *interface, unsigned int inde
  * Prior to this call the @arv_interface_update_device_list
  * function must be called.
  *
- * since: 0.1.14
- **/
+ * Returns: (transfer none): the device address
+ *
+ * Since: 0.2.0
+ */
 
 const char *
 arv_interface_get_device_address (ArvInterface *interface, unsigned int index)
@@ -168,10 +180,13 @@ arv_interface_get_device_address (ArvInterface *interface, unsigned int index)
  * arv_interface_open_device
  * @interface: a #ArvInterface
  * @device_id: (allow-none): device unique id
- * Return value: (transfer full): a new #ArvDevice
  *
  * Creates a new #ArvDevice object corresponding to the given device id string. The first available device is returned if @device_id is null.
- **/
+ *
+ * Returns: (transfer full): a new #ArvDevice
+ *
+ * Since: 0.2.0
+ */
 
 ArvDevice *
 arv_interface_open_device (ArvInterface *interface, const char *device_id)
diff --git a/src/arvstream.c b/src/arvstream.c
index f81a88d..77d42d1 100644
--- a/src/arvstream.c
+++ b/src/arvstream.c
@@ -63,6 +63,8 @@ struct _ArvStreamPrivate {
  *
  * Pushes a #ArvBuffer to the @stream thread. The @stream takes ownership of @buffer,
  * and will free all the buffers still in its queues when destroyed.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -83,7 +85,7 @@ arv_stream_push_buffer (ArvStream *stream, ArvBuffer *buffer)
  * may contain an invalid image. Caller should check the buffer status before using it.
  * This function blocks until a buffer is available.
  *
- * since: 0.1.12
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -103,7 +105,7 @@ arv_stream_pop_buffer (ArvStream *stream)
  * may contain an invalid image. Caller should check the buffer status before using it.
  * This is the non blocking version of pop_buffer.
  *
- * since: 0.1.12
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -122,6 +124,8 @@ arv_stream_try_pop_buffer (ArvStream *stream)
  *
  * Pops a buffer from the output queue of @stream, waiting no more than @timeout. The retrieved buffer
  * may contain an invalid image. Caller should check the buffer status before using it.
+ *
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -148,6 +152,8 @@ arv_stream_timeout_pop_buffer (ArvStream *stream, guint64 timeout)
  * @stream: (transfer full): a #ArvStream
  *
  * Pos a buffer from the input queue of @stream.
+ *
+ * Since: 0.2.0
  */
 
 ArvBuffer *
@@ -177,6 +183,8 @@ arv_stream_push_output_buffer (ArvStream *stream, ArvBuffer *buffer)
  * @n_output_buffers: (out) (allow-none): output queue length
  *
  * An accessor to the stream buffer queue lengths.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -204,6 +212,8 @@ arv_stream_get_n_buffers (ArvStream *stream, gint *n_input_buffers, gint *n_outp
  * @n_underruns: (out) (allow-none): number of input buffer underruns
  *
  * An accessor to the stream statistics.
+ *
+ * Since: 0.2.0
  */
 
 void
@@ -242,7 +252,7 @@ arv_stream_get_statistics (ArvStream *stream,
  * by default disabled because signal emission is expensive and unneeded when
  * the application prefers to operate in pull mode.
  *
- * Since: 0.1.3
+ * Since: 0.2.0
  */
 
 void
@@ -261,7 +271,7 @@ arv_stream_set_emit_signals (ArvStream *stream, gboolean emit_signals)
  *
  * Returns: %TRUE if @appsink is emiting its signals.
  *
- * Since: 0.1.3
+ * Since: 0.2.0
  */
 
 gboolean
@@ -370,6 +380,8 @@ arv_stream_class_init (ArvStreamClass *node_class)
 	 *
 	 * Note that this signal is only emited when the "emit-signals" property is
 	 * set to %TRUE, which it is not by default for performance reasons.
+	 *
+	 * Since: 0.2.0
 	 */
 
 	arv_stream_signals[ARV_STREAM_SIGNAL_NEW_BUFFER] =
diff --git a/tests/.gitignore b/tests/.gitignore
index 21574dd..71add26 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -10,3 +10,4 @@ arv-evaluator-test
 arv-zip-test
 arv-camera-test
 arv-heartbeat-test
+arv-example
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5d58ee2..5d5abdd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -6,7 +6,7 @@ test_progs_ldadd = 					\
 	$(top_builddir)/src/libaravis- ARAVIS_API_VERSION@.la		\
 	$(ARAVIS_LIBS)
 
-noinst_PROGRAMS = arv-test arv-genicam-test arv-evaluator-test arv-zip-test arv-camera-test arv-heartbeat-test
+noinst_PROGRAMS = arv-test arv-genicam-test arv-evaluator-test arv-zip-test arv-camera-test arv-heartbeat-test arv-example
 
 arv_test_SOURCES = arvtest.c
 arv_test_LDADD = $(test_progs_ldadd)
@@ -26,6 +26,9 @@ arv_camera_test_LDADD = $(test_progs_ldadd)
 arv_heartbeat_test_SOURCES = arvheartbeattest.c
 arv_heartbeat_test_LDADD = $(test_progs_ldadd)
 
+arv_example_SOURCES = arvexample.c
+arv_example_LDADD = $(test_progs_ldadd)
+
 TEST_PROGS += evaluator buffer misc fake genicam
 if ARAVIS_BUILD_CPP_TEST
 TEST_PROGS += cpp
diff --git a/tests/arvexample.c b/tests/arvexample.c
new file mode 100644
index 0000000..a77c56a
--- /dev/null
+++ b/tests/arvexample.c
@@ -0,0 +1,133 @@
+#include <arv.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <stdio.h>
+
+typedef struct {
+	GMainLoop *main_loop;
+	int buffer_count;
+} ApplicationData;
+
+static gboolean cancel = FALSE;
+
+static void
+set_cancel (int signal)
+{
+	cancel = TRUE;
+}
+
+static void
+new_buffer_cb (ArvStream *stream, ApplicationData *data)
+{
+	ArvBuffer *buffer;
+
+	buffer = arv_stream_try_pop_buffer (stream);
+	if (buffer != NULL) {
+		if (buffer->status == ARV_BUFFER_STATUS_SUCCESS)
+			data->buffer_count++;
+		/* Image processing here */
+		arv_stream_push_buffer (stream, buffer);
+	}
+}
+
+static gboolean
+periodic_task_cb (void *abstract_data)
+{
+	ApplicationData *data = abstract_data;
+
+	printf ("Frame rate = %d Hz\n", data->buffer_count);
+	data->buffer_count = 0;
+
+	if (cancel) {
+		g_main_loop_quit (data->main_loop);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void
+control_lost_cb (ArvGvDevice *gv_device)
+{
+	/* Control of the device is lost. Display a message and force application exit */
+	printf ("Control lost\n");
+
+	cancel = TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+	ApplicationData data;
+	ArvCamera *camera;
+	ArvStream *stream;
+	ArvBuffer *buffer;
+	int i;
+
+	data.buffer_count = 0;
+
+	/* Mandatory glib type system initialization */
+	g_type_init ();
+
+	/* Instantiation of the first available camera */
+	camera = arv_camera_new (NULL);
+
+	if (camera != NULL) {
+		void (*old_sigint_handler)(int);
+		gint payload;
+		guint software_trigger_source = 0;
+
+		/* Set region of interrest to a 200x200 pixel area */
+		arv_camera_set_region (camera, 0, 0, 200, 200);
+		/* Set frame rate to 10 Hz */
+		arv_camera_set_frame_rate (camera, 10.0);
+		/* retrieve image payload (number of bytes per image) */
+		payload = arv_camera_get_payload (camera);
+
+		/* Create a new stream object */
+		stream = arv_camera_create_stream (camera, NULL, NULL);
+		if (stream != NULL) {
+			/* Push 50 buffer in the stream input buffer queue */
+			for (i = 0; i < 50; i++)
+				arv_stream_push_buffer (stream, arv_buffer_new (payload, NULL));
+
+			/* Start the video stream */
+			arv_camera_start_acquisition (camera);
+
+			/* Connect the new-buffer signal */
+			g_signal_connect (stream, "new-buffer", G_CALLBACK (new_buffer_cb), &data);
+			/* And enable emission of this signal (it's disabled by default for performance reason) */
+			arv_stream_set_emit_signals (stream, TRUE);
+
+			/* Connect the control-lost signal */
+			g_signal_connect (arv_camera_get_device (camera), "control-lost",
+					  G_CALLBACK (control_lost_cb), NULL);
+
+			/* Install the callback for frame rate display */
+			g_timeout_add_seconds (1, periodic_task_cb, &data);
+
+			/* Create a new glib main loop */
+			data.main_loop = g_main_loop_new (NULL, FALSE);
+
+			old_sigint_handler = signal (SIGINT, set_cancel);
+
+			/* Run the main loop */
+			g_main_loop_run (data.main_loop);
+
+			signal (SIGINT, old_sigint_handler);
+
+			g_main_loop_unref (data.main_loop);
+
+			/* Stop the video stream */
+			arv_camera_stop_acquisition (camera);
+
+			g_object_unref (stream);
+		} else
+			printf ("Can't create stream thread (check if the device is not already used)\n");
+
+		g_object_unref (camera);
+	} else
+		printf ("No camera found\n");
+
+	return 0;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]