[aravis] fake: answer to discovery command.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] fake: answer to discovery command.
- Date: Sun, 30 May 2010 10:32:39 +0000 (UTC)
commit bc0d02bfe686f4cc5d6a0e4f54de0b0e4cb11210
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sun May 30 12:32:06 2010 +0200
fake: answer to discovery command.
src/arvfakegvcamera.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/arvfakegvcamera.c b/src/arvfakegvcamera.c
index c38c691..e332494 100644
--- a/src/arvfakegvcamera.c
+++ b/src/arvfakegvcamera.c
@@ -22,22 +22,22 @@ arv_fake_gv_camera_thread (void *user_data)
}
void
-handle_control_packet (ArvFakeGvCamera *gv_camera, ArvGvcpPacket *packet, size_t size)
+handle_control_packet (ArvFakeGvCamera *gv_camera, GSocket *socket,
+ GSocketAddress *remote_address,
+ ArvGvcpPacket *packet, size_t size)
{
ArvGvcpPacket *ack_packet;
size_t ack_packet_size;
- if (g_ntohs (packet->header.packet_type) != ARV_GVCP_PACKET_TYPE_CMD)
- g_message ("Wrong packet type");
-
switch (g_ntohs (packet->header.command)) {
case ARV_GVCP_COMMAND_DISCOVERY_CMD:
arv_gvcp_packet_debug (packet);
ack_packet = arv_gvcp_packet_new_discovery_ack (&ack_packet_size);
arv_fake_camera_read_memory (gv_camera->camera, 0, ARV_GVBS_DISCOVERY_DATA_SIZE,
&ack_packet->data);
+ g_socket_send_to (socket, remote_address, (char *) ack_packet, ack_packet_size, NULL, NULL);
+ arv_gvcp_packet_debug (ack_packet);
g_free (ack_packet);
- g_message ("Discovery packet");
break;
case ARV_GVCP_COMMAND_READ_MEMORY_CMD:
g_message ("Read command ");
@@ -56,7 +56,7 @@ main (int argc, char **argv)
GInetAddress *address;
GPollFD poll_fd;
int n_events;
- ArvGvcpPacket *packet;
+ GInputVector input_vector;
g_thread_init (NULL);
g_type_init ();
@@ -70,10 +70,12 @@ main (int argc, char **argv)
address = g_inet_address_new_from_string ("127.0.0.1");
socket_address = g_inet_socket_address_new (address, ARV_GVCP_PORT);
+ arv_fake_camera_set_inet_address (gv_camera->camera, address);
g_object_unref (address);
g_socket_bind (socket, socket_address, TRUE, NULL);
- packet = g_malloc0 (ARV_FAKE_GV_CAMERA_BUFFER_SIZE);
+ input_vector.buffer = g_malloc0 (ARV_FAKE_GV_CAMERA_BUFFER_SIZE);
+ input_vector.size = ARV_FAKE_GV_CAMERA_BUFFER_SIZE;
poll_fd.fd = g_socket_get_fd (socket);
poll_fd.events = G_IO_IN;
@@ -84,16 +86,18 @@ main (int argc, char **argv)
do {
n_events = g_poll (&poll_fd, 1, 1000);
if (n_events > 0) {
+ GSocketAddress *remote_address;
int count;
- count = g_socket_receive (socket, (char *) packet, ARV_FAKE_GV_CAMERA_BUFFER_SIZE, NULL, NULL);
+ count = g_socket_receive_message (socket, &remote_address, &input_vector, 1, NULL, NULL,
+ G_SOCKET_MSG_NONE, NULL, NULL);
if (count > 0)
- handle_control_packet (gv_camera, packet, count);
+ handle_control_packet (gv_camera, socket, remote_address, input_vector.buffer, count);
}
} while (!cancel);
+ g_free (input_vector.buffer);
g_object_unref (socket);
-
g_object_unref (gv_camera->camera);
g_free (gv_camera);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]