From: Tim-Philipp Müller Date: Sun, 25 Dec 2011 23:10:23 +0000 (+0000) Subject: tcp: remove some dataprotocol cruft X-Git-Tag: RELEASE-0.11.2~246 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=17359744f34938dcd7675abd78c7ca584c6a353d;p=platform%2Fupstream%2Fgst-plugins-base.git tcp: remove some dataprotocol cruft The protocol=gdp property has been removed in favour of explicit gdppay/depay. --- diff --git a/android/tcp.mk b/android/tcp.mk index a4d6aa8..a5dfb39 100644 --- a/android/tcp.mk +++ b/android/tcp.mk @@ -23,8 +23,7 @@ LOCAL_SHARED_LIBRARIES := \ libglib-2.0 \ libgthread-2.0 \ libgmodule-2.0 \ - libgobject-2.0 \ - libgstdataprotocol-0.11 + libgobject-2.0 LOCAL_MODULE:= libgsttcp diff --git a/gst/tcp/Makefile.am b/gst/tcp/Makefile.am index a970a2b..6676ef4 100644 --- a/gst/tcp/Makefile.am +++ b/gst/tcp/Makefile.am @@ -23,10 +23,9 @@ libgsttcp_la_SOURCES = \ nodist_libgsttcp_la_SOURCES = \ $(built_sources) -# remove ENABLE_NEW when dataprotocol is stable -libgsttcp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_GDP_CFLAGS) $(GST_CFLAGS) -DGST_ENABLE_NEW +libgsttcp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) libgsttcp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) -libgsttcp_la_LIBADD = $(GST_BASE_LIBS) $(GST_GDP_LIBS) $(GST_LIBS) +libgsttcp_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) libgsttcp_la_LIBTOOLFLAGS = --tag=disable-static noinst_HEADERS = \ diff --git a/gst/tcp/gstmultifdsink.c b/gst/tcp/gstmultifdsink.c index 6c0e6b7..7110574 100644 --- a/gst/tcp/gstmultifdsink.c +++ b/gst/tcp/gstmultifdsink.c @@ -1296,8 +1296,7 @@ is_sync_frame (GstMultiFdSink * sink, GstBuffer * buffer) return FALSE; } -/* queue the given buffer for the given client, possibly adding the GDP - * header if GDP is being used */ +/* queue the given buffer for the given client */ static gboolean gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink, GstTCPClient * client, GstBuffer * buffer) @@ -1878,12 +1877,9 @@ gst_multi_fd_sink_new_client (GstMultiFdSink * sink, GstTCPClient * client) * which indicates a read request from a client. * * For each client we maintain a queue of GstBuffers that contain the raw bytes - * we need to send to the client. In the case of the GDP protocol, we create - * buffers out of the header bytes so that we can focus only on sending - * buffers. + * we need to send to the client. * - * We first check to see if we need to send caps (in GDP) and streamheaders. - * If so, we queue them. + * We first check to see if we need to send streamheaders. If so, we queue them. * * Then we run into the main loop that tries to send as many buffers as * possible. It will first exhaust the client->sending queue and if the queue diff --git a/gst/tcp/gsttcp.c b/gst/tcp/gsttcp.c index e5e7248..cf1c4ad 100644 --- a/gst/tcp/gsttcp.c +++ b/gst/tcp/gsttcp.c @@ -120,91 +120,6 @@ gst_tcp_socket_write (int socket, const void *buf, size_t count) return bytes_written; } -/* atomically read count bytes into buf, cancellable. return val of GST_FLOW_OK - * indicates success, anything else is failure. - */ -static GstFlowReturn -gst_tcp_socket_read (GstElement * this, int socket, void *buf, size_t count, - GstPoll * fdset) -{ - ssize_t n; - size_t bytes_read; - int num_to_read; - int ret; - - bytes_read = 0; - - while (bytes_read < count) { - /* do a blocking select on the socket */ - /* no action (0) is an error too in our case */ - if ((ret = gst_poll_wait (fdset, GST_CLOCK_TIME_NONE)) <= 0) { - if (ret == -1 && errno == EBUSY) - goto cancelled; - else - goto select_error; - } - - /* ask how much is available for reading on the socket */ - if (ioctl (socket, FIONREAD, &num_to_read) < 0) - goto ioctl_error; - - if (num_to_read == 0) - goto got_eos; - - /* sizeof(ssize_t) >= sizeof(int), so I know num_to_read <= SSIZE_MAX */ - - num_to_read = MIN (num_to_read, count - bytes_read); - - n = read (socket, ((guint8 *) buf) + bytes_read, num_to_read); - - if (n < 0) - goto read_error; - - if (n < num_to_read) - goto short_read; - - bytes_read += num_to_read; - } - - return GST_FLOW_OK; - - /* ERRORS */ -select_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("select failed: %s", g_strerror (errno))); - return GST_FLOW_ERROR; - } -cancelled: - { - GST_DEBUG_OBJECT (this, "Select was cancelled"); - return GST_FLOW_WRONG_STATE; - } -ioctl_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("ioctl failed: %s", g_strerror (errno))); - return GST_FLOW_ERROR; - } -got_eos: - { - GST_DEBUG_OBJECT (this, "Got EOS on socket stream"); - return GST_FLOW_EOS; - } -read_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("read failed: %s", g_strerror (errno))); - return GST_FLOW_ERROR; - } -short_read: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("short read: wanted %d bytes, got %" G_GSSIZE_FORMAT, num_to_read, n)); - return GST_FLOW_ERROR; - } -} - /* close the socket and reset the fd. Used to clean up after errors. */ void gst_tcp_socket_close (GstPollFD * socket) @@ -308,168 +223,3 @@ short_read: return GST_FLOW_ERROR; } } - -/* read a buffer from the given socket - * returns: - * - a GstBuffer in which data should be read - * - NULL, indicating a connection close or an error, to be handled with - * EOS - */ -GstFlowReturn -gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset, - GstBuffer ** buf) -{ - GstFlowReturn ret; - guint8 *header = NULL; - guint8 *data; - gsize size; - - GST_LOG_OBJECT (this, "Reading %d bytes for buffer packet header", - GST_DP_HEADER_LENGTH); - - *buf = NULL; - header = g_malloc (GST_DP_HEADER_LENGTH); - - ret = gst_tcp_socket_read (this, socket, header, GST_DP_HEADER_LENGTH, fdset); - - if (ret != GST_FLOW_OK) - goto header_read_error; - - if (!gst_dp_validate_header (GST_DP_HEADER_LENGTH, header)) - goto validate_error; - - if (gst_dp_header_payload_type (header) != GST_DP_PAYLOAD_BUFFER) - goto is_not_buffer; - - GST_LOG_OBJECT (this, "validated buffer packet header"); - - *buf = gst_dp_buffer_from_header (GST_DP_HEADER_LENGTH, header); - - g_free (header); - - data = gst_buffer_map (*buf, &size, NULL, GST_MAP_WRITE); - ret = gst_tcp_socket_read (this, socket, data, size, fdset); - gst_buffer_unmap (*buf, data, size); - - if (ret != GST_FLOW_OK) - goto data_read_error; - - return GST_FLOW_OK; - - /* ERRORS */ -header_read_error: - { - g_free (header); - return ret; - } -validate_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("GDP buffer packet header does not validate")); - g_free (header); - return GST_FLOW_ERROR; - } -is_not_buffer: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("GDP packet contains something that is not a buffer (type %d)", - gst_dp_header_payload_type (header))); - g_free (header); - return GST_FLOW_ERROR; - } -data_read_error: - { - gst_buffer_unref (*buf); - *buf = NULL; - return ret; - } -} - -GstFlowReturn -gst_tcp_gdp_read_caps (GstElement * this, int socket, GstPoll * fdset, - GstCaps ** caps) -{ - GstFlowReturn ret; - guint8 *header = NULL; - guint8 *payload = NULL; - size_t payload_length; - - GST_LOG_OBJECT (this, "Reading %d bytes for caps packet header", - GST_DP_HEADER_LENGTH); - - *caps = NULL; - header = g_malloc (GST_DP_HEADER_LENGTH); - - ret = gst_tcp_socket_read (this, socket, header, GST_DP_HEADER_LENGTH, fdset); - - if (ret != GST_FLOW_OK) - goto header_read_error; - - if (!gst_dp_validate_header (GST_DP_HEADER_LENGTH, header)) - goto header_validate_error; - - if (gst_dp_header_payload_type (header) != GST_DP_PAYLOAD_CAPS) - goto is_not_caps; - - GST_LOG_OBJECT (this, "validated caps packet header"); - - payload_length = gst_dp_header_payload_length (header); - payload = g_malloc (payload_length); - - GST_LOG_OBJECT (this, - "Reading %" G_GSIZE_FORMAT " bytes for caps packet payload", - payload_length); - - ret = gst_tcp_socket_read (this, socket, payload, payload_length, fdset); - - if (ret != GST_FLOW_OK) - goto payload_read_error; - - if (!gst_dp_validate_payload (GST_DP_HEADER_LENGTH, header, payload)) - goto payload_validate_error; - - *caps = gst_dp_caps_from_packet (GST_DP_HEADER_LENGTH, header, payload); - - GST_DEBUG_OBJECT (this, "Got caps over GDP: %" GST_PTR_FORMAT, *caps); - - g_free (header); - g_free (payload); - - return GST_FLOW_OK; - - /* ERRORS */ -header_read_error: - { - g_free (header); - return ret; - } -header_validate_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("GDP caps packet header does not validate")); - g_free (header); - return GST_FLOW_ERROR; - } -is_not_caps: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("GDP packet contains something that is not a caps (type %d)", - gst_dp_header_payload_type (header))); - g_free (header); - return GST_FLOW_ERROR; - } -payload_read_error: - { - g_free (header); - g_free (payload); - return ret; - } -payload_validate_error: - { - GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL), - ("GDP caps packet payload does not validate")); - g_free (header); - g_free (payload); - return GST_FLOW_ERROR; - } -} diff --git a/gst/tcp/gsttcp.h b/gst/tcp/gsttcp.h index 64299ef..c588daa 100644 --- a/gst/tcp/gsttcp.h +++ b/gst/tcp/gsttcp.h @@ -26,7 +26,6 @@ #include "gsttcp-enumtypes.h" #include #undef GST_DISABLE_DEPRECATED -#include #define TCP_HIGHEST_PORT 65535 #define TCP_DEFAULT_HOST "localhost" @@ -42,9 +41,6 @@ void gst_tcp_socket_close (GstPollFD *socket); GstFlowReturn gst_tcp_read_buffer (GstElement * this, int socket, GstPoll * fdset, GstBuffer **buf); -GstFlowReturn gst_tcp_gdp_read_buffer (GstElement * this, int socket, GstPoll * fdset, GstBuffer **buf); -GstFlowReturn gst_tcp_gdp_read_caps (GstElement * this, int socket, GstPoll * fdset, GstCaps **caps); - G_END_DECLS #endif /* __GST_TCP_HELP_H__ */ diff --git a/gst/tcp/gsttcpclientsink.c b/gst/tcp/gsttcpclientsink.c index a8dc756..b53afe1 100644 --- a/gst/tcp/gsttcpclientsink.c +++ b/gst/tcp/gsttcpclientsink.c @@ -28,7 +28,7 @@ * # server: * nc -l -p 3000 * # client: - * gst-launch fdsrc fd=1 ! tcpclientsink protocol=none port=3000 + * gst-launch fdsrc fd=1 ! tcpclientsink port=3000 * ]| everything you type in the client is shown on the server * */ @@ -37,7 +37,6 @@ #include "config.h" #endif #include -#include #include "gsttcp.h" #include "gsttcpclientsink.h" #include /* memset */ diff --git a/gst/tcp/gsttcpclientsrc.c b/gst/tcp/gsttcpclientsrc.c index 3a83fba..fe34a9e 100644 --- a/gst/tcp/gsttcpclientsrc.c +++ b/gst/tcp/gsttcpclientsrc.c @@ -28,7 +28,7 @@ * # server: * nc -l -p 3000 * # client: - * gst-launch tcpclientsrc protocol=none port=3000 ! fdsink fd=2 + * gst-launch tcpclientsrc port=3000 ! fdsink fd=2 * ]| everything you type in the server is shown on the client * */ diff --git a/gst/tcp/gsttcpplugin.c b/gst/tcp/gsttcpplugin.c index bb2cf48..02c71b3 100644 --- a/gst/tcp/gsttcpplugin.c +++ b/gst/tcp/gsttcpplugin.c @@ -21,7 +21,6 @@ #include "config.h" #endif -#include #include "gsttcpclientsrc.h" #include "gsttcpclientsink.h" #include "gsttcpserversrc.h" @@ -33,8 +32,6 @@ GST_DEBUG_CATEGORY (tcp_debug); static gboolean plugin_init (GstPlugin * plugin) { - gst_dp_init (); - if (!gst_element_register (plugin, "tcpclientsink", GST_RANK_NONE, GST_TYPE_TCP_CLIENT_SINK)) return FALSE; diff --git a/gst/tcp/gsttcpserversink.c b/gst/tcp/gsttcpserversink.c index 1c9ea4a..a654b84 100644 --- a/gst/tcp/gsttcpserversink.c +++ b/gst/tcp/gsttcpserversink.c @@ -26,9 +26,9 @@ * Example launch line * |[ * # server: - * gst-launch fdsrc fd=1 ! tcpserversink protocol=none port=3000 + * gst-launch fdsrc fd=1 ! tcpserversink port=3000 * # client: - * gst-launch tcpclientsrc protocol=none port=3000 ! fdsink fd=2 + * gst-launch tcpclientsrc port=3000 ! fdsink fd=2 * ]| * */ diff --git a/gst/tcp/gsttcpserversrc.c b/gst/tcp/gsttcpserversrc.c index 786557e..3c4b5b1 100644 --- a/gst/tcp/gsttcpserversrc.c +++ b/gst/tcp/gsttcpserversrc.c @@ -26,9 +26,9 @@ * Example launch line * |[ * # server: - * gst-launch tcpserversrc protocol=none port=3000 ! fdsink fd=2 + * gst-launch tcpserversrc port=3000 ! fdsink fd=2 * # client: - * gst-launch fdsrc fd=1 ! tcpclientsink protocol=none port=3000 + * gst-launch fdsrc fd=1 ! tcpclientsink port=3000 * ]| * */