mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
improve debugging
Original commit message from CVS: improve debugging
This commit is contained in:
parent
930a02f6e5
commit
2260add03b
3 changed files with 38 additions and 11 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-08-11 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* gst/tcp/gsttcp.c:
|
||||||
|
* gst/tcp/gsttcpplugin.c:
|
||||||
|
improve debuggging, remove assert
|
||||||
|
|
||||||
2004-08-10 Wim Taymans <wim@fluendo.com>
|
2004-08-10 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* gst/tcp/gstmultifdsink.c: (gst_unit_type_get_type),
|
* gst/tcp/gstmultifdsink.c: (gst_unit_type_get_type),
|
||||||
|
|
|
@ -36,6 +36,9 @@
|
||||||
#include <gst/gst-i18n-plugin.h>
|
#include <gst/gst-i18n-plugin.h>
|
||||||
#include <gst/dataprotocol/dataprotocol.h>
|
#include <gst/dataprotocol/dataprotocol.h>
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_EXTERN (tcp_debug);
|
||||||
|
#define GST_CAT_DEFAULT tcp_debug
|
||||||
|
|
||||||
#ifndef MSG_NOSIGNAL
|
#ifndef MSG_NOSIGNAL
|
||||||
#define MSG_NOSIGNAL 0
|
#define MSG_NOSIGNAL 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -51,9 +54,11 @@ gst_tcp_host_to_ip (GstElement * element, const gchar * host)
|
||||||
gchar *ip;
|
gchar *ip;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (element, "resolving host %s", host);
|
||||||
/* first check if it already is an IP address */
|
/* first check if it already is an IP address */
|
||||||
if (inet_aton (host, &addr)) {
|
if (inet_aton (host, &addr)) {
|
||||||
return g_strdup (host);
|
ip = g_strdup (host);
|
||||||
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: could do a localhost check here */
|
/* FIXME: could do a localhost check here */
|
||||||
|
@ -76,6 +81,8 @@ gst_tcp_host_to_ip (GstElement * element, const gchar * host)
|
||||||
/* There could be more than one IP address, but we just return the first */
|
/* There could be more than one IP address, but we just return the first */
|
||||||
ip = g_strdup (inet_ntoa (*(struct in_addr *) *addrs));
|
ip = g_strdup (inet_ntoa (*(struct in_addr *) *addrs));
|
||||||
|
|
||||||
|
beach:
|
||||||
|
GST_DEBUG_OBJECT (element, "resolved to IP %s", ip);
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +105,17 @@ gst_tcp_socket_write (int socket, const void *buf, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes_written < 0)
|
if (bytes_written < 0)
|
||||||
GST_DEBUG ("error while writing");
|
GST_WARNING ("error while writing");
|
||||||
else
|
else
|
||||||
GST_DEBUG ("wrote %d bytes succesfully", bytes_written);
|
GST_LOG ("wrote %d bytes succesfully", bytes_written);
|
||||||
return bytes_written;
|
return bytes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read number of bytes from a socket into a given buffer incrementally.
|
/* read number of bytes from a socket into a given buffer incrementally.
|
||||||
* Returns number of bytes read.
|
* Returns number of bytes read with same semantics as read(2):
|
||||||
|
* < 0: error, see errno
|
||||||
|
* = 0: EOF
|
||||||
|
* > 0: bytes read
|
||||||
*/
|
*/
|
||||||
gint
|
gint
|
||||||
gst_tcp_socket_read (int socket, void *buf, size_t count)
|
gst_tcp_socket_read (int socket, void *buf, size_t count)
|
||||||
|
@ -126,7 +136,7 @@ gst_tcp_socket_read (int socket, void *buf, size_t count)
|
||||||
if (bytes_read < 0)
|
if (bytes_read < 0)
|
||||||
GST_WARNING ("error while reading: %s", g_strerror (errno));
|
GST_WARNING ("error while reading: %s", g_strerror (errno));
|
||||||
else
|
else
|
||||||
GST_DEBUG ("read %d bytes succesfully", bytes_read);
|
GST_LOG ("read %d bytes succesfully", bytes_read);
|
||||||
return bytes_read;
|
return bytes_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,8 +156,7 @@ gst_tcp_gdp_read_header (GstElement * this, int socket)
|
||||||
header = g_malloc (header_length);
|
header = g_malloc (header_length);
|
||||||
readsize = header_length;
|
readsize = header_length;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (this, "Reading %d bytes for buffer packet header",
|
GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header", readsize);
|
||||||
readsize);
|
|
||||||
ret = gst_tcp_socket_read (socket, header, readsize);
|
ret = gst_tcp_socket_read (socket, header, readsize);
|
||||||
/* if we read 0 bytes, and we're blocking, we hit eos */
|
/* if we read 0 bytes, and we're blocking, we hit eos */
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
|
@ -172,12 +181,12 @@ gst_tcp_gdp_read_header (GstElement * this, int socket)
|
||||||
g_free (header);
|
g_free (header);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (this, "validated buffer packet header");
|
GST_LOG_OBJECT (this, "validated buffer packet header");
|
||||||
|
|
||||||
buffer = gst_dp_buffer_from_header (header_length, header);
|
buffer = gst_dp_buffer_from_header (header_length, header);
|
||||||
g_free (header);
|
g_free (header);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (this, "created new buffer %p from packet header", buffer);
|
GST_LOG_OBJECT (this, "created new buffer %p from packet header", buffer);
|
||||||
return GST_DATA (buffer);
|
return GST_DATA (buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +213,15 @@ gst_tcp_gdp_read_caps (GstElement * this, int socket)
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
|
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
g_assert (ret == readsize);
|
if (ret == 0) {
|
||||||
|
GST_WARNING_OBJECT (this, "read returned EOF");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (ret != readsize) {
|
||||||
|
GST_WARNING_OBJECT (this, "Tried to read %d bytes but only read %d bytes",
|
||||||
|
readsize, ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (!gst_dp_validate_header (header_length, header)) {
|
if (!gst_dp_validate_header (header_length, header)) {
|
||||||
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
|
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
|
||||||
|
@ -243,7 +260,7 @@ gst_tcp_gdp_read_caps (GstElement * this, int socket)
|
||||||
|
|
||||||
caps = gst_dp_caps_from_packet (header_length, header, payload);
|
caps = gst_dp_caps_from_packet (header_length, header, payload);
|
||||||
string = gst_caps_to_string (caps);
|
string = gst_caps_to_string (caps);
|
||||||
GST_DEBUG_OBJECT (this, "retrieved GDP caps from packet payload: %s", string);
|
GST_LOG_OBJECT (this, "retrieved GDP caps from packet payload: %s", string);
|
||||||
g_free (string);
|
g_free (string);
|
||||||
|
|
||||||
g_free (header);
|
g_free (header);
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include "gsttcpserversink.h"
|
#include "gsttcpserversink.h"
|
||||||
#include "gstmultifdsink.h"
|
#include "gstmultifdsink.h"
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY (tcp_debug);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
plugin_init (GstPlugin * plugin)
|
plugin_init (GstPlugin * plugin)
|
||||||
{
|
{
|
||||||
|
@ -58,6 +60,8 @@ plugin_init (GstPlugin * plugin)
|
||||||
GST_TYPE_MULTIFDSINK))
|
GST_TYPE_MULTIFDSINK))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
GST_DEBUG_CATEGORY_INIT (tcp_debug, "tcp", 0, "TCP calls");
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue