static void arv_gv_stream_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { ArvGvStream *gv_stream = ARV_GV_STREAM (object); ArvGvStreamThreadData *thread_data; thread_data = gv_stream->thread_data; switch (prop_id) { case ARV_GV_STREAM_PROPERTY_SOCKET_BUFFER: g_value_set_enum (value, thread_data->socket_buffer_option); break; case ARV_GV_STREAM_PROPERTY_SOCKET_BUFFER_SIZE: g_value_set_int (value, thread_data->socket_buffer_size); break; case ARV_GV_STREAM_PROPERTY_PACKET_RESEND: g_value_set_enum (value, thread_data->packet_resend); break; case ARV_GV_STREAM_PROPERTY_PACKET_TIMEOUT: g_value_set_uint (value, thread_data->packet_timeout_us); break; case ARV_GV_STREAM_PROPERTY_FRAME_RETENTION: g_value_set_uint (value, thread_data->frame_retention_us); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static ArvStream * arv_gv_device_create_stream (ArvDevice *device, ArvStreamCallback callback, void *user_data) { ArvGvDevice *gv_device = ARV_GV_DEVICE (device); ArvGvDeviceIOData *io_data = gv_device->priv->io_data; ArvStream *stream; const guint8 *address_bytes; guint32 stream_port; guint packet_size; guint32 n_stream_channels; GInetAddress *interface_address; GInetAddress *device_address; arv_device_read_register (device, ARV_GVBS_N_STREAM_CHANNELS_OFFSET, &n_stream_channels, NULL); arv_debug_device ("[GvDevice::create_stream] Number of stream channels = %d", n_stream_channels); if (n_stream_channels < 1) return NULL; if (!io_data->is_controller) { arv_warning_device ("[GvDevice::create_stream] Can't create stream without control access"); return NULL; } interface_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (io_data->interface_address)); device_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (io_data->device_address)); address_bytes = g_inet_address_to_bytes (interface_address); /* On some cameras, the default packet size after reset is incorrect. * So, if the value is obviously incorrect, set it to a default size. */ packet_size = arv_gv_device_get_packet_size (gv_device); if (packet_size <= ARV_GVSP_PACKET_PROTOCOL_OVERHEAD) { arv_gv_device_set_packet_size (gv_device, ARV_GV_DEVICE_GVSP_PACKET_SIZE_DEFAULT); arv_debug_device ("[GvDevice::create_stream] Packet size set to default value (%d)", ARV_GV_DEVICE_GVSP_PACKET_SIZE_DEFAULT); } packet_size = arv_gv_device_get_packet_size (gv_device); arv_debug_device ("[GvDevice::create_stream] Packet size = %d byte(s)", packet_size); stream = arv_gv_stream_new (device_address, 0, callback, user_data, arv_gv_device_get_timestamp_tick_frequency (gv_device), packet_size); stream_port = arv_gv_stream_get_port (ARV_GV_STREAM (stream)); if (!arv_device_write_register (device, ARV_GVBS_STREAM_CHANNEL_0_IP_ADDRESS_OFFSET, g_htonl(*((guint32 *) address_bytes)), NULL) || !arv_device_write_register (device, ARV_GVBS_STREAM_CHANNEL_0_PORT_OFFSET, stream_port, NULL)) { arv_warning_device ("[GvDevice::create_stream] Stream configuration failed"); g_object_unref (stream); return NULL; } arv_debug_device ("[GvDevice::create_stream] Stream port = %d", stream_port); return stream; }
static void _get_statistics (ArvStream *stream, guint64 *n_completed_buffers, guint64 *n_failures, guint64 *n_underruns) { ArvGvStream *gv_stream = ARV_GV_STREAM (stream); ArvGvStreamThreadData *thread_data; thread_data = gv_stream->thread_data; *n_completed_buffers = thread_data->n_completed_buffers; *n_failures = thread_data->n_failures; *n_underruns = thread_data->n_underruns; }
static void arv_gv_stream_finalize (GObject *object) { ArvGvStream *gv_stream = ARV_GV_STREAM (object); if (gv_stream->thread != NULL) { ArvGvStreamThreadData *thread_data; char *statistic_string; thread_data = gv_stream->thread_data; thread_data->cancel = TRUE; g_thread_join (gv_stream->thread); g_object_unref (thread_data->device_address); statistic_string = arv_statistic_to_string (thread_data->statistic); arv_debug_stream (statistic_string); g_free (statistic_string); arv_statistic_free (thread_data->statistic); arv_debug_stream ("[GvStream::finalize] n_completed_buffers = %u", thread_data->n_completed_buffers); arv_debug_stream ("[GvStream::finalize] n_failures = %u", thread_data->n_failures); arv_debug_stream ("[GvStream::finalize] n_timeouts = %u", thread_data->n_timeouts); arv_debug_stream ("[GvStream::finalize] n_aborteds = %u", thread_data->n_aborteds); arv_debug_stream ("[GvStream::finalize] n_underruns = %u", thread_data->n_underruns); arv_debug_stream ("[GvStream::finalize] n_missing_frames = %u", thread_data->n_missing_frames); arv_debug_stream ("[GvStream::finalize] n_size_mismatch_errors = %u", thread_data->n_size_mismatch_errors); arv_debug_stream ("[GvStream::finalize] n_received_packets = %u", thread_data->n_received_packets); arv_debug_stream ("[GvStream::finalize] n_missing_packets = %u", thread_data->n_missing_packets); arv_debug_stream ("[GvStream::finalize] n_error_packets = %u", thread_data->n_error_packets); arv_debug_stream ("[GvStream::finalize] n_ignored_packets = %u", thread_data->n_ignored_packets); arv_debug_stream ("[GvStream::finalize] n_resend_requests = %u", thread_data->n_resend_requests); arv_debug_stream ("[GvStream::finalize] n_resent_packets = %u", thread_data->n_resent_packets); arv_debug_stream ("[GvStream::finalize] n_duplicated_packets = %u", thread_data->n_duplicated_packets); g_free (thread_data); gv_stream->thread_data = NULL; gv_stream->thread = NULL; } g_object_unref (gv_stream->incoming_address); g_object_unref (gv_stream->socket); parent_class->finalize (object); }