[aravis] gv_stream: debug error packets.



commit ebd1bb04864b3f46165386e0f2aa858fc7877e3b
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sun May 15 00:36:19 2011 +0200

    gv_stream: debug error packets.

 docs/reference/aravis/aravis-sections.txt |    1 +
 src/arvgvsp.c                             |   14 +++++++++++---
 src/arvgvsp.h                             |   17 +++++++++++++----
 src/arvgvstream.c                         |    4 ++++
 4 files changed, 29 insertions(+), 7 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index fc3f83f..076bf07 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -949,6 +949,7 @@ arv_gvsp_packet_get_data_size
 arv_gvsp_packet_get_frame_id
 arv_gvsp_packet_get_height
 arv_gvsp_packet_get_packet_id
+arv_gvsp_packet_get_packet_type
 arv_gvsp_packet_get_content_type
 arv_gvsp_packet_get_pixel_format
 arv_gvsp_packet_get_timestamp
diff --git a/src/arvgvsp.c b/src/arvgvsp.c
index c317172..54fa874 100644
--- a/src/arvgvsp.c
+++ b/src/arvgvsp.c
@@ -143,6 +143,12 @@ arv_enum_to_string (GType type,
 }
 
 static const char *
+arv_gvsp_packet_type_to_string (ArvGvspPacketType value)
+{
+	return arv_enum_to_string (ARV_TYPE_GVSP_PACKET_TYPE, value);
+}
+
+static const char *
 arv_gvsp_content_type_to_string (ArvGvspContentType value)
 {
 	return arv_enum_to_string (ARV_TYPE_GVSP_CONTENT_TYPE, value);
@@ -152,6 +158,7 @@ char *
 arv_gvsp_packet_to_string (const ArvGvspPacket *packet, size_t packet_size)
 {
 	ArvGvspDataLeader *leader;
+	ArvGvspPacketType packet_type;
 	ArvGvspContentType content_type;
 	GString *string;
 	char *c_string;
@@ -159,10 +166,11 @@ arv_gvsp_packet_to_string (const ArvGvspPacket *packet, size_t packet_size)
 
 	string = g_string_new ("");
 
-	content_type = (g_ntohl (packet->header.packet_infos) & ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_MASK) >>
-		ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_POS;
+	packet_type = arv_gvsp_packet_get_packet_type (packet);
+	content_type = arv_gvsp_packet_get_content_type (packet);
 
-	g_string_append_printf (string, "content_type  = %s\n", arv_gvsp_content_type_to_string (content_type));
+	g_string_append_printf (string, "packet_type  = %s\n", arv_gvsp_packet_type_to_string (content_type));
+	g_string_append_printf (string, "content_type = %s\n", arv_gvsp_content_type_to_string (content_type));
 
 	switch (content_type) {
 		case ARV_GVSP_CONTENT_TYPE_DATA_LEADER:
diff --git a/src/arvgvsp.h b/src/arvgvsp.h
index e6dad12..f0c8d83 100644
--- a/src/arvgvsp.h
+++ b/src/arvgvsp.h
@@ -35,6 +35,11 @@ G_BEGIN_DECLS
 #define ARV_GVSP_PACKET_PROTOCOL_OVERHEAD	(20 + 8 + 8)		/* IP + UDP + GVSP headers */
 
 typedef enum {
+	ARV_GVSP_PACKET_TYPE_OK =		0x0000,
+	ARV_GVSP_PACKET_TYPE_ERROR =		0x80c0
+} ArvGvspPacketType;
+
+typedef enum {
 	ARV_GVSP_CONTENT_TYPE_DATA_LEADER = 	0x01,
 	ARV_GVSP_CONTENT_TYPE_DATA_TRAILER = 	0x02,
 	ARV_GVSP_CONTENT_TYPE_DATA_BLOCK =	0x03
@@ -80,13 +85,17 @@ ArvGvspPacket *		arv_gvsp_packet_new_data_block		(guint16 frame_id, guint32 pack
 char * 			arv_gvsp_packet_to_string 		(const ArvGvspPacket *packet, size_t packet_size);
 void 			arv_gvsp_packet_debug 			(const ArvGvspPacket *packet, size_t packet_size,
 								 ArvDebugLevel level);
+static inline ArvGvspPacketType
+arv_gvsp_packet_get_packet_type (const ArvGvspPacket *packet)
+{
+	return g_ntohs (packet->header.packet_type);
+}
 
 static inline ArvGvspContentType
-arv_gvsp_packet_get_content_type	(const ArvGvspPacket *packet)
+arv_gvsp_packet_get_content_type (const ArvGvspPacket *packet)
 {
-	return (ArvGvspContentType) ((g_ntohl (packet->header.packet_infos) &
-					    ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_MASK) >>
-					   ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_POS);
+	return (g_ntohl (packet->header.packet_infos) & ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_MASK) >>
+		ARV_GVSP_PACKET_INFOS_CONTENT_TYPE_POS;
 }
 
 static inline guint16
diff --git a/src/arvgvstream.c b/src/arvgvstream.c
index 4174b55..84e2590 100644
--- a/src/arvgvstream.c
+++ b/src/arvgvstream.c
@@ -595,6 +595,10 @@ arv_gv_stream_thread (void *data)
 						break;
 				frame->last_valid_packet = i - 1;
 
+				if (arv_gvsp_packet_get_packet_type (packet) != ARV_GVSP_PACKET_TYPE_OK) {
+					arv_gvsp_packet_debug (packet, read_count, ARV_DEBUG_LEVEL_DEBUG);
+				}
+
 				switch (arv_gvsp_packet_get_content_type (packet)) {
 					case ARV_GVSP_CONTENT_TYPE_DATA_LEADER:
 						_process_data_leader (thread_data, frame, packet, packet_id);



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