From 5e2fb3d072a4afa6f33d9af9c4202381dd61f463 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Wed, 19 May 2004 16:37:53 +0000 Subject: [PATCH] clean up libs docs; add dataprotocol Original commit message from CVS: clean up libs docs; add dataprotocol --- ChangeLog | 23 ++ configure.ac | 1 + docs/libs/gstreamer-libs-docs.sgml | 6 +- docs/libs/gstreamer-libs-sections.txt | 81 +--- docs/libs/tmpl/gstdataprotocol.sgml | 156 ++++++++ libs/gst/Makefile.am | 4 +- libs/gst/dataprotocol/Makefile.am | 31 ++ libs/gst/dataprotocol/dataprotocol-test.c | 300 ++++++++++++++ libs/gst/dataprotocol/dataprotocol.c | 625 ++++++++++++++++++++++++++++++ libs/gst/dataprotocol/dataprotocol.h | 101 +++++ libs/gst/dataprotocol/dp-private.h | 56 +++ 11 files changed, 1314 insertions(+), 70 deletions(-) create mode 100644 docs/libs/tmpl/gstdataprotocol.sgml create mode 100644 libs/gst/dataprotocol/Makefile.am create mode 100644 libs/gst/dataprotocol/dataprotocol-test.c create mode 100644 libs/gst/dataprotocol/dataprotocol.c create mode 100644 libs/gst/dataprotocol/dataprotocol.h create mode 100644 libs/gst/dataprotocol/dp-private.h diff --git a/ChangeLog b/ChangeLog index 003f61a..417d601 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +2004-05-19 Thomas Vander Stichele + + * docs/libs/gstreamer-libs-docs.sgml: + * docs/libs/gstreamer-libs-sections.txt: + remove idct and putbits + * configure.ac: + * docs/libs/tmpl/gstdataprotocol.sgml: + * libs/gst/Makefile.am: + * libs/gst/dataprotocol/Makefile.am: + * libs/gst/dataprotocol/dataprotocol-test.c: (conversion_test), + (buffer_test), (caps_test), (event_test), (main): + * libs/gst/dataprotocol/dataprotocol.c: (gst_dp_crc), + (gst_dp_dump_byte_array), (gst_dp_init), + (gst_dp_header_payload_length), (gst_dp_header_payload_type), + (gst_dp_header_from_buffer), (gst_dp_packet_from_caps), + (gst_dp_packet_from_event), (gst_dp_buffer_from_header), + (gst_dp_caps_from_packet), (gst_dp_event_from_packet), + (gst_dp_validate_header), (gst_dp_validate_payload), + (gst_dp_validate_packet), (plugin_init): + * libs/gst/dataprotocol/dataprotocol.h: + * libs/gst/dataprotocol/dp-private.h: + add dataprotocol + 2004-05-19 Benjamin Otte * gst/gstvalue.c: (gst_value_deserialize_int_helper): diff --git a/configure.ac b/configure.ac index e163b5d..c04bebc 100644 --- a/configure.ac +++ b/configure.ac @@ -644,6 +644,7 @@ libs/Makefile libs/gst/Makefile libs/gst/bytestream/Makefile libs/gst/control/Makefile +libs/gst/dataprotocol/Makefile libs/gst/getbits/Makefile po/Makefile.in tests/Makefile diff --git a/docs/libs/gstreamer-libs-docs.sgml b/docs/libs/gstreamer-libs-docs.sgml index 5a169ec..3772eb3 100644 --- a/docs/libs/gstreamer-libs-docs.sgml +++ b/docs/libs/gstreamer-libs-docs.sgml @@ -4,9 +4,8 @@ %version-entities; - - + ]> @@ -26,9 +25,8 @@ GStreamer provides some standard libraries you can use to create plugins. &GstGetbits; - &GstPutbits; - &GstIDCT; &GstControl; + &GstDataProtocol; diff --git a/docs/libs/gstreamer-libs-sections.txt b/docs/libs/gstreamer-libs-sections.txt index 4679db9..14da64b 100644 --- a/docs/libs/gstreamer-libs-sections.txt +++ b/docs/libs/gstreamer-libs-sections.txt @@ -79,71 +79,26 @@ DEBUG
-gstputbits -libs/putbits/gstputbits.h -gst_putbits_t -gst_putbits_init -gst_putbits_new_empty_buffer -gst_putbits_new_buffer -gst_putbits_align -gst_putbits_bitcount -gst_putbits1 -gst_putbits2 -gst_putbits3 -gst_putbits4 -gst_putbits5 -gst_putbits6 -gst_putbits7 -gst_putbits8 -gst_putbits9 -gst_putbits10 -gst_putbits11 -gst_putbits12 -gst_putbits13 -gst_putbits14 -gst_putbits15 -gst_putbits16 -gst_putbits17 -gst_putbits18 -gst_putbits19 -gst_putbits20 -gst_putbits21 -gst_putbits22 -gst_putbits32 -gst_putbitsn - -gst_putbits -
+gstdataprotocol +libs/dataprotocol/dataprotocol.h +GstDPHeaderFlag +GstDPPayloadType -
-dct -DCTSIZE -DCTSIZE2 -EIGHT_BIT_SAMPLES -DCTELEM -DCTBLOCK[DCTSIZE2] -INT32 -gst_idct_int_idct -gst_idct_init_fast_int_idct -gst_idct_init_float_idct -gst_idct_fast_int_idct -gst_idct_mmx_idct -gst_idct_mmx32_idct -gst_idct_sse_idct -gst_idct_float_idct -
+gst_dp_header_payload_length +gst_dp_header_payload_type -
-gstidct -libs/idct/gstidct.h -GstIDCTMethod -GstIDCT -GstIDCTFunction -GST_IDCT_TRANSPOSE -gst_idct_new -gst_idct_convert -gst_idct_convert_sparse -gst_idct_destroy +gst_dp_header_from_buffer +gst_dp_packet_from_caps +gst_dp_packet_from_event + +gst_dp_buffer_from_header +gst_dp_caps_from_packet +gst_dp_event_from_packet + +gst_dp_validate_header +gst_dp_validate_payload +gst_dp_validate_packet +
diff --git a/docs/libs/tmpl/gstdataprotocol.sgml b/docs/libs/tmpl/gstdataprotocol.sgml new file mode 100644 index 0000000..c5f3478 --- /dev/null +++ b/docs/libs/tmpl/gstdataprotocol.sgml @@ -0,0 +1,156 @@ + +gstdataprotocol + + + + + + + + + + + + + + + + + + + +@GST_DP_HEADER_FLAG_NONE: +@GST_DP_HEADER_FLAG_CRC_HEADER: +@GST_DP_HEADER_FLAG_CRC_PAYLOAD: +@GST_DP_HEADER_FLAG_CRC: + + + + + + +@GST_DP_PAYLOAD_NONE: +@GST_DP_PAYLOAD_BUFFER: +@GST_DP_PAYLOAD_CAPS: +@GST_DP_PAYLOAD_EVENT_NONE: + + + + + + +@header: +@Returns: + + + + + + + +@header: +@Returns: + + + + + + + +@buffer: +@flags: +@length: +@header: +@Returns: + + + + + + + +@caps: +@flags: +@length: +@header: +@payload: +@Returns: + + + + + + + +@event: +@flags: +@length: +@header: +@payload: +@Returns: + + + + + + + +@header_length: +@header: +@Returns: + + + + + + + +@header_length: +@header: +@payload: +@Returns: + + + + + + + +@header_length: +@header: +@payload: +@Returns: + + + + + + + +@header_length: +@header: +@Returns: + + + + + + + +@header_length: +@header: +@payload: +@Returns: + + + + + + + +@header_length: +@header: +@payload: +@Returns: + + diff --git a/libs/gst/Makefile.am b/libs/gst/Makefile.am index fa04c8f..86d6564 100644 --- a/libs/gst/Makefile.am +++ b/libs/gst/Makefile.am @@ -1,3 +1 @@ -SUBDIRS = bytestream control getbits - -DIST_SUBDIRS = bytestream control getbits +SUBDIRS = bytestream control dataprotocol getbits diff --git a/libs/gst/dataprotocol/Makefile.am b/libs/gst/dataprotocol/Makefile.am new file mode 100644 index 0000000..cf6c767 --- /dev/null +++ b/libs/gst/dataprotocol/Makefile.am @@ -0,0 +1,31 @@ + +lib_LTLIBRARIES = libgstdataprotocol.la +AS_LIBTOOL_LIB = libgstdataprotocol + +EXTRA_DIST = $(as_libtool_EXTRA_DIST) +noinst_DATA = $(as_libtool_noinst_DATA_files) + +libgstdataprotocol_includedir = $(includedir)/gstreamer-@GST_MAJORMINOR@/gst/dataprotocol +libgstdataprotocol_include_HEADERS = \ + dataprotocol.h +noinst_HEADERS = dp-private.h + +libgstdataprotocol_la_SOURCES = \ + dataprotocol.c + +libgstdataprotocol_la_CFLAGS = $(GST_OBJ_CFLAGS) -I$(top_srcdir)/libs +libgstdataprotocol_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(as_libtool_LDFLAGS) +libgstdataprotocol_la_LIBADD = $(GST_OBJ_LIBS) + +install-data-local: as-libtool-install-data-local + +uninstall-local: as-libtool-uninstall-local + +include $(top_srcdir)/common/as-libtool.mak + +# regression test +check_PROGRAMS = dataprotocol-test +dataprotocol_test_SOURCES = dataprotocol-test.c dataprotocol.c +dataprotocol_test_CFLAGS = $(GST_LIB_CFLAGS) -I$(top_srcdir)/libs +dataprotocol_test_LDADD = $(GST_LIB_LIBS) + diff --git a/libs/gst/dataprotocol/dataprotocol-test.c b/libs/gst/dataprotocol/dataprotocol-test.c new file mode 100644 index 0000000..4737f38 --- /dev/null +++ b/libs/gst/dataprotocol/dataprotocol-test.c @@ -0,0 +1,300 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2004> Thomas Vander Stichele + * + * dataprotocol-test.c: Test functions for GStreamer Data Protocol + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include "dp-private.h" + +#include /* memcmp */ + +/* test our method of reading and writing headers using TO/FROM_BE */ +static int +conversion_test () +{ + guint8 array[9]; + guint8 write_array[9]; + guint16 read_two, expect_two; + guint32 read_four, expect_four; + guint64 read_eight, expect_eight; + int i; + + for (i = 0; i < 9; ++i) { + array[i] = i * 0x10; + } + + /* read 8 16 bits */ + for (i = 0; i < 8; ++i) { + read_two = GUINT16_FROM_BE (*((guint16 *) (array + i))); + expect_two = array[i] * (1 << 8) + array[i + 1]; + if (read_two != expect_two) { + g_print ("GUINT16_FROM_BE %d: read %d != %d\n", i, read_two, expect_two); + return -1; + } + } + + /* write 8 16 bit */ + for (i = 0; i < 8; ++i) { + *((guint16 *) & write_array[i]) = GUINT16_TO_BE (read_two); + if (memcmp (array + 7, write_array + i, 2) != 0) { + gst_dp_dump_byte_array (write_array + i, 2); + gst_dp_dump_byte_array (array + 7, 2); + return -1; + } + } + + /* read 5 32 bits */ + for (i = 0; i < 5; ++i) { + read_four = GUINT32_FROM_BE (*((guint32 *) (array + i))); + expect_four = array[i] * (1 << 24) + array[i + 1] * (1 << 16) + + array[i + 2] * (1 << 8) + array[i + 3]; + if (read_four != expect_four) { + g_print ("GUINT32_FROM_BE %d: read %d != %d\n", i, read_four, + expect_four); + return -1; + } + } + + /* read 2 64 bits */ + for (i = 0; i < 2; ++i) { + read_eight = GUINT64_FROM_BE (*((guint64 *) (array + i))); + expect_eight = array[i] * (1LL << 56) + array[i + 1] * (1LL << 48) + + array[i + 2] * (1LL << 40) + array[i + 3] * (1LL << 32) + + array[i + 4] * (1 << 24) + array[i + 5] * (1 << 16) + + array[i + 6] * (1 << 8) + array[i + 7]; + ; + if (read_eight != expect_eight) { + g_print ("GUINT64_FROM_BE %d: read %" G_GUINT64_FORMAT + " != %" G_GUINT64_FORMAT "\n", i, read_eight, expect_eight); + return -1; + } + } + + /* write 1 64 bit */ + *((guint64 *) & write_array[0]) = GUINT64_TO_BE (read_eight); + if (memcmp (array + 1, write_array, 8) != 0) { + gst_dp_dump_byte_array (write_array, 8); + gst_dp_dump_byte_array (array + 1, 8); + return -1; + } + + return 0; +} + +/* test creation of header from buffer and back again */ +static int +buffer_test () +{ + GstBuffer *buffer; + GstBuffer *newbuffer; + + guint header_length; + guint8 *header; + + /* create buffer */ + g_print ("Creating a new 8-byte buffer with ts 0.5 sec, dur 1 sec\n"); + buffer = gst_buffer_new_and_alloc (8); + GST_BUFFER_TIMESTAMP (buffer) = (GstClockTime) (GST_SECOND * 0.5); + GST_BUFFER_DURATION (buffer) = (GstClockTime) GST_SECOND; + GST_BUFFER_OFFSET (buffer) = (guint64) 10; + GST_BUFFER_OFFSET_END (buffer) = (guint64) 19; + memmove (GST_BUFFER_DATA (buffer), "a buffer", 8); + + /* create a buffer with CRC checking */ + if (!gst_dp_header_from_buffer (buffer, GST_DP_HEADER_FLAG_CRC, + &header_length, &header)) { + g_print ("Could not create header from buffer."); + exit (1); + } + + /* validate the header */ + g_return_val_if_fail (gst_dp_validate_header (header_length, header), -1); + /* create a new, empty buffer with the right size */ + newbuffer = gst_dp_buffer_from_header (header_length, header); + /* read/copy the data */ + memmove (GST_BUFFER_DATA (newbuffer), GST_BUFFER_DATA (buffer), + GST_BUFFER_SIZE (buffer)); + /* validate the buffer */ + g_return_val_if_fail (gst_dp_validate_payload (header_length, header, + GST_BUFFER_DATA (newbuffer)), -1); + + g_return_val_if_fail (newbuffer, -1); + g_return_val_if_fail (GST_IS_BUFFER (newbuffer), -1); + g_print ("new buffer timestamp: %" GST_TIME_FORMAT "\n", + GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (newbuffer))); + g_print ("new buffer duration: %" GST_TIME_FORMAT "\n", + GST_TIME_ARGS (GST_BUFFER_DURATION (newbuffer))); + g_print ("new buffer offset: %" G_GUINT64_FORMAT "\n", + GST_BUFFER_OFFSET (newbuffer)); + g_print ("new buffer offset_end: %" G_GUINT64_FORMAT "\n", + GST_BUFFER_OFFSET_END (newbuffer)); + if (GST_BUFFER_TIMESTAMP (newbuffer) != GST_BUFFER_TIMESTAMP (buffer)) { + g_error ("Timestamps don't match !"); + } + if (GST_BUFFER_DURATION (newbuffer) != GST_BUFFER_DURATION (buffer)) { + g_error ("Durations don't match !"); + } + if (GST_BUFFER_OFFSET (newbuffer) != GST_BUFFER_OFFSET (buffer)) { + g_error ("Offsets don't match !"); + } + if (GST_BUFFER_OFFSET_END (newbuffer) != GST_BUFFER_OFFSET_END (buffer)) { + g_error ("Offset ends don't match !"); + } + g_free (header); + + return 0; +} + +static int +caps_test () +{ + gchar *string, *newstring; + GstCaps *caps, *newcaps; + + guint header_length; + guint8 *header, *payload; + + caps = gst_caps_from_string ("audio/x-raw-float, " + "rate = (int) [ 11025, 48000 ], " + "channels = (int) [ 1, 2 ], " "endianness = (int) BYTE_ORDER, " + "width = (int) 32, " "buffer-frames = (int) 0"); + string = gst_caps_to_string (caps); + g_print ("Created caps: %s\n", string); + //g_assert (GST_IS_CAPS (caps)); + if (!gst_dp_packet_from_caps (caps, 0, &header_length, &header, &payload)) { + g_print ("Could not create packet from caps."); + exit (1); + } + + /* validate the packet */ + g_return_val_if_fail (gst_dp_validate_packet (header_length, header, payload), + FALSE); + newcaps = gst_dp_caps_from_packet (header_length, header, payload); + g_return_val_if_fail (newcaps, -1); + //g_return_val_if_fail (GST_IS_CAPS (newcaps), -1); + newstring = gst_caps_to_string (newcaps); + g_print ("Received caps: %s\n", newstring); + if (strcmp (string, newstring) != 0) + return -1; + g_free (string); + g_free (newstring); + + return 0; +} + +static int +event_test () +{ + GstEvent *send; + GstEvent *receive; + guint header_length; + guint8 *header, *payload; + + g_print ("Testing EOS event at 1s\n"); + send = gst_event_new (GST_EVENT_EOS); + GST_EVENT_TIMESTAMP (send) = GST_SECOND; + if (!gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, &header_length, + &header, &payload)) { + g_warning ("Could not create packet from eos event"); + return 1; + } + receive = gst_dp_event_from_packet (header_length, header, payload); + + g_print ("EOS, timestamp %" GST_TIME_FORMAT "\n", + GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive))); + g_assert (GST_EVENT_TYPE (receive) == GST_EVENT_EOS); + g_assert (GST_EVENT_TIMESTAMP (receive) == GST_SECOND); + gst_event_unref (send); + gst_event_unref (receive); + + g_print ("Testing FLUSH event at 2s\n"); + send = gst_event_new (GST_EVENT_FLUSH); + GST_EVENT_TIMESTAMP (send) = GST_SECOND * 2; + if (!gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, &header_length, + &header, &payload)) { + g_warning ("Could not create packet from flush event"); + return 1; + } + receive = gst_dp_event_from_packet (header_length, header, payload); + + g_print ("Flush, timestamp %" GST_TIME_FORMAT "\n", + GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive))); + g_assert (GST_EVENT_TYPE (receive) == GST_EVENT_FLUSH); + g_assert (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 2); + gst_event_unref (send); + gst_event_unref (receive); + + g_print ("Testing SEEK event with 1 second at 3 seconds\n"); + send = gst_event_new_seek (GST_FORMAT_TIME, GST_SECOND); + GST_EVENT_TIMESTAMP (send) = GST_SECOND * 3; + if (!gst_dp_packet_from_event (send, GST_DP_HEADER_FLAG_CRC, &header_length, + &header, &payload)) { + g_warning ("Could not create packet from seek event"); + return 1; + } + receive = gst_dp_event_from_packet (header_length, header, payload); + + g_print ("Seek, timestamp %" GST_TIME_FORMAT ", to %" GST_TIME_FORMAT "\n", + GST_TIME_ARGS (GST_EVENT_TIMESTAMP (receive)), + GST_TIME_ARGS (GST_EVENT_SEEK_OFFSET (receive))); + g_assert (GST_EVENT_TYPE (receive) == GST_EVENT_SEEK); + g_assert (GST_EVENT_TIMESTAMP (receive) == GST_SECOND * 3); + g_assert (GST_EVENT_SEEK_FORMAT (receive) == GST_FORMAT_TIME); + g_assert (GST_EVENT_SEEK_OFFSET (receive) == GST_SECOND); + gst_event_unref (send); + gst_event_unref (receive); + + + return 0; +} + +int +main (int argc, char *argv[]) +{ + int ret; + + gst_init (&argc, &argv); + gst_dp_init (); + + g_print ("\nconversion test\n\n"); + ret = conversion_test (); + if (ret != 0) + return ret; + + g_print ("\nbuffer test\n\n"); + ret = buffer_test (); + if (ret != 0) + return ret; + + g_print ("\ncaps test\n\n"); + ret = caps_test (); + if (ret != 0) + return ret; + + g_print ("\nevent test\n\n"); + ret = event_test (); + if (ret != 0) + return ret; + + + g_print ("\nall tests worked.\n\n"); + return 0; +} diff --git a/libs/gst/dataprotocol/dataprotocol.c b/libs/gst/dataprotocol/dataprotocol.c new file mode 100644 index 0000000..cabba42 --- /dev/null +++ b/libs/gst/dataprotocol/dataprotocol.c @@ -0,0 +1,625 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2004> Thomas Vander Stichele + * + * dataprotocol.c: Functions implementing the GStreamer Data Protocol + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include /* g_sprintf */ +#include /* strlen */ +#include "dp-private.h" + +/* debug category */ +GST_DEBUG_CATEGORY (data_protocol_debug); +#define GST_CAT_DEFAULT data_protocol_debug + +/*** private functions ***/ + +#define GST_DP_WRITE_GUINT64(buf, value) (*((guint64 *) (buf)) = GUINT64_TO_BE (value)) +#define GST_DP_WRITE_GUINT32(buf, value) (*((guint32 *) (buf)) = GUINT32_TO_BE (value)) +#define GST_DP_WRITE_GUINT16(buf, value) (*((guint16 *) (buf)) = GUINT16_TO_BE (value)) + +/* calculate a CCITT 16 bit CRC check value for a given byte array */ +/* + * this code snippet is adapted from a web page I found + * it is identical except for cleanups, and a final XOR with 0xffff + * as outlined in the uecp spec + * + * XMODEM x^16 + x^12 + x^5 + 1 + */ + +#define POLY 0x1021 +#define CRC_INIT 0xFFFF + +static guint16 +gst_dp_crc (const guint8 * buffer, register guint length) +{ + static gboolean initialized = FALSE; + static guint16 crc_register, crc_table[256]; + unsigned long i, j, k; + + if (!initialized) { + for (i = 0; i < 256; i++) { + j = i << 8; + for (k = 8; k--;) { + j = j & 0x8000 ? (j << 1) ^ POLY : j << 1; + } + + crc_table[i] = (guint16) j; + } + initialized = TRUE; + } + + crc_register = CRC_INIT; /* always init register */ + + /* calc CRC */ + for (; length--;) { + crc_register = (guint16) ((crc_register << 8) ^ + crc_table[((crc_register >> 8) & 0x00ff) ^ *buffer++]); + } + return (0xffff ^ crc_register); +} + +/* debugging function; dumps byte array values per 8 bytes */ +/* FIXME: would be nice to merge this with gst_util_dump_mem () */ +void +gst_dp_dump_byte_array (guint8 * array, guint length) +{ + int i; + int n = 8; /* number of bytes per line */ + gchar *line = g_malloc (3 * n); + + GST_LOG ("dumping byte array of length %d", length); + for (i = 0; i < length; ++i) { + g_sprintf (line + 3 * (i % n), "%02x ", array[i]); + if (i % n == (n - 1)) { + GST_LOG ("%03d: %s", i - (n - 1), line); + } + } + if (i % n != 0) { + GST_LOG ("%03d: %s", (i / n) * n, line); + } + g_free (line); +} + +/** + * gst_dp_init: + * + * Initialize GStreamer Data Protocol library. + * + * Should be called before using these functions; either from source linking + * to this source file or from plugin_init. + */ +void +gst_dp_init (void) +{ + static gboolean _gst_dp_initialized = FALSE; + + if (_gst_dp_initialized) + return; + + _gst_dp_initialized = TRUE; + + GST_DEBUG_CATEGORY_INIT (data_protocol_debug, "gdp", 0, + "GStreamer Data Protocol"); +} + +/*** PUBLIC FUNCTIONS ***/ + +/** + * gst_dp_header_payload_length: + * @header: the byte header of the packet array + * + * Returns: the length of the payload this header describes. + */ +guint32 +gst_dp_header_payload_length (const guint8 * header) +{ + return GST_DP_HEADER_PAYLOAD_LENGTH (header); +} + +/** + * gst_dp_header_payload_type: + * @header: the byte header of the packet array + * + * Returns: the #GstDPPayloadType the payload this header describes. + */ +GstDPPayloadType +gst_dp_header_payload_type (const guint8 * header) +{ + return GST_DP_HEADER_PAYLOAD_TYPE (header); +} + +/** + * gst_dp_header_from_buffer: + * @buffer: a #GstBuffer to create a header for + * @flags: the #GDPHeaderFlags to create the header with + * @length: a guint pointer to store the header length in + * @header: a guint8 * pointer to store a newly allocated header byte array in + * + * Creates a GDP header from the given buffer. + * + * Returns: %TRUE if the header was successfully created + */ + +gboolean +gst_dp_header_from_buffer (const GstBuffer * buffer, GstDPHeaderFlag flags, + guint * length, guint8 ** header) +{ + guint8 *h; + guint16 crc; + + g_return_val_if_fail (GST_IS_BUFFER (buffer), FALSE); + g_return_val_if_fail (GST_BUFFER_REFCOUNT_VALUE (buffer) > 0, FALSE); + + *length = GST_DP_HEADER_LENGTH; + h = g_malloc (GST_DP_HEADER_LENGTH); + + /* version, flags, type */ + h[0] = (guint8) GST_DP_VERSION_MAJOR; + h[1] = (guint8) GST_DP_VERSION_MINOR; + h[2] = (guint8) flags; + h[3] = GST_DP_PAYLOAD_BUFFER; + + /* buffer properties */ + GST_DP_WRITE_GUINT32 (h + 4, GST_BUFFER_SIZE (buffer)); + GST_DP_WRITE_GUINT64 (h + 8, GST_BUFFER_TIMESTAMP (buffer)); + GST_DP_WRITE_GUINT64 (h + 16, GST_BUFFER_DURATION (buffer)); + GST_DP_WRITE_GUINT64 (h + 24, GST_BUFFER_OFFSET (buffer)); + GST_DP_WRITE_GUINT64 (h + 32, GST_BUFFER_OFFSET_END (buffer)); + + /* ABI padding */ + GST_DP_WRITE_GUINT64 (h + 40, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 48, (guint64) 0); + + /* CRC */ + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_HEADER) { + /* we don't crc the last four bytes of the header since they are crc's */ + crc = gst_dp_crc (h, 56); + } + GST_DP_WRITE_GUINT16 (h + 56, crc); + + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD) { + crc = gst_dp_crc (GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer)); + } + GST_DP_WRITE_GUINT16 (h + 58, crc); + + GST_LOG ("created header from buffer:"); + gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH); + *header = h; + return TRUE; +} + + /** + * gst_dp_packet_from_caps: + * @caps: a #GstCaps to create a packet for + * @flags: the #GDPHeaderFlags to create the header with + * @length: a guint pointer to store the header length in + * @header: a guint8 pointer to store a newly allocated header byte array in + * @payload: a guint8 pointer to store a newly allocated payload byte array in + * + * Creates a GDP packet from the given caps. + * + * Returns: %TRUE if the packet was successfully created + */ +gboolean +gst_dp_packet_from_caps (const GstCaps * caps, GstDPHeaderFlag flags, + guint * length, guint8 ** header, guint8 ** payload) +{ + guint8 *h; + guint16 crc; + gchar *string; + + /* FIXME: GST_IS_CAPS doesn't work + g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); */ + + *length = GST_DP_HEADER_LENGTH; + h = g_malloc (GST_DP_HEADER_LENGTH); + + string = gst_caps_to_string (caps); + + /* version, flags, type */ + h[0] = (guint8) GST_DP_VERSION_MAJOR; + h[1] = (guint8) GST_DP_VERSION_MINOR; + h[2] = (guint8) flags; + h[3] = GST_DP_PAYLOAD_CAPS; + + /* buffer properties */ + GST_DP_WRITE_GUINT32 (h + 4, strlen (string) + 1); /* include trailing 0 */ + GST_DP_WRITE_GUINT64 (h + 8, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 16, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 24, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 32, (guint64) 0); + + /* ABI padding */ + GST_DP_WRITE_GUINT64 (h + 40, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 48, (guint64) 0); + + /* CRC */ + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_HEADER) { + crc = gst_dp_crc (h, 56); + } + GST_DP_WRITE_GUINT16 (h + 56, crc); + + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD) { + crc = gst_dp_crc (string, strlen (string) + 1); + } + GST_DP_WRITE_GUINT16 (h + 58, crc); + + GST_LOG ("created header from caps:"); + gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH); + *header = h; + *payload = string; + return TRUE; +} + +/** + * gst_dp_packet_from_event: + * @event: a #GstEvent to create a packet for + * @flags: the #GDPHeaderFlags to create the header with + * @length: a guint pointer to store the header length in + * @header: a guint8 pointer to store a newly allocated header byte array in + * @payload: a guint8 pointer to store a newly allocated payload byte array in + * + * Creates a GDP packet from the given event. + * + * Returns: %TRUE if the packet was successfully created + */ +gboolean +gst_dp_packet_from_event (const GstEvent * event, GstDPHeaderFlag flags, + guint * length, guint8 ** header, guint8 ** payload) +{ + guint8 *h; + guint16 crc; + gchar *string = NULL; + guint pl_length; /* length of payload */ + + g_return_val_if_fail (GST_IS_EVENT (event), FALSE); + + *length = GST_DP_HEADER_LENGTH; + h = g_malloc0 (GST_DP_HEADER_LENGTH); + + /* first construct payload, since we need the length */ + switch (GST_EVENT_TYPE (event)) { + case GST_EVENT_UNKNOWN: + g_warning ("Unknown event, ignoring"); + *length = 0; + g_free (h); + return FALSE; + case GST_EVENT_EOS: + case GST_EVENT_FLUSH: + case GST_EVENT_EMPTY: + case GST_EVENT_DISCONTINUOUS: + GST_DP_WRITE_GUINT64 (h + 8, GST_EVENT_TIMESTAMP (event)); + pl_length = 0; + *payload = NULL; + break; + case GST_EVENT_SEEK: + pl_length = 4 + 8 + 4; + *payload = g_malloc0 (pl_length); + GST_DP_WRITE_GUINT32 (*payload, (guint32) GST_EVENT_SEEK_TYPE (event)); + GST_DP_WRITE_GUINT64 (*payload + 4, + (guint64) GST_EVENT_SEEK_OFFSET (event)); + GST_DP_WRITE_GUINT32 (*payload + 12, + (guint32) GST_EVENT_SEEK_ACCURACY (event)); + break; + case GST_EVENT_SEEK_SEGMENT: + pl_length = 4 + 8 + 8 + 4; + *payload = g_malloc0 (pl_length); + GST_DP_WRITE_GUINT32 (*payload, (guint32) GST_EVENT_SEEK_TYPE (event)); + GST_DP_WRITE_GUINT64 (*payload + 4, + (guint64) GST_EVENT_SEEK_OFFSET (event)); + GST_DP_WRITE_GUINT64 (*payload + 12, + (guint64) GST_EVENT_SEEK_ENDOFFSET (event)); + GST_DP_WRITE_GUINT32 (*payload + 20, + (guint32) GST_EVENT_SEEK_ACCURACY (event)); + break; + case GST_EVENT_QOS: + case GST_EVENT_SEGMENT_DONE: + case GST_EVENT_SIZE: + case GST_EVENT_RATE: + case GST_EVENT_FILLER: + case GST_EVENT_TS_OFFSET: + case GST_EVENT_INTERRUPT: + case GST_EVENT_NAVIGATION: + case GST_EVENT_TAG: + g_warning ("Unhandled event type %d, ignoring", GST_EVENT_TYPE (event)); + return FALSE; + default: + g_warning ("Unknown event type %d, ignoring", GST_EVENT_TYPE (event)); + *length = 0; + g_free (h); + return FALSE; + } + + /* version, flags, type */ + h[0] = (guint8) GST_DP_VERSION_MAJOR; + h[1] = (guint8) GST_DP_VERSION_MINOR; + h[2] = (guint8) flags; + h[3] = GST_DP_PAYLOAD_EVENT_NONE + GST_EVENT_TYPE (event); + + /* length */ + GST_DP_WRITE_GUINT32 (h + 4, (guint32) pl_length); + /* timestamp */ + GST_DP_WRITE_GUINT64 (h + 8, GST_EVENT_TIMESTAMP (event)); + + /* ABI padding */ + GST_DP_WRITE_GUINT64 (h + 40, (guint64) 0); + GST_DP_WRITE_GUINT64 (h + 48, (guint64) 0); + + /* CRC */ + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_HEADER) { + crc = gst_dp_crc (h, 56); + } + GST_DP_WRITE_GUINT16 (h + 56, crc); + + crc = 0; + if (flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD) { + crc = gst_dp_crc (string, strlen (string) + 1); + } + GST_DP_WRITE_GUINT16 (h + 58, crc); + + GST_LOG ("created header from event:"); + gst_dp_dump_byte_array (h, GST_DP_HEADER_LENGTH); + *header = h; + return TRUE; +} + + +/** + * gst_dp_buffer_from_header: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * + * Creates a newly allocated #GstBuffer from the given header. + * The buffer data needs to be copied into it before validating. + * + * Use this function if you want to pre-allocate a buffer based on the + * packet header to read the packet payload in to. + * + * Returns: %TRUE if the buffer was successfully created + */ +GstBuffer * +gst_dp_buffer_from_header (guint header_length, const guint8 * header) +{ + GstBuffer *buffer; + + g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) == + GST_DP_PAYLOAD_BUFFER, FALSE); + buffer = + gst_buffer_new_and_alloc ((guint) GST_DP_HEADER_PAYLOAD_LENGTH (header)); + GST_BUFFER_TIMESTAMP (buffer) = GST_DP_HEADER_TIMESTAMP (header); + GST_BUFFER_DURATION (buffer) = GST_DP_HEADER_DURATION (header); + GST_BUFFER_OFFSET (buffer) = GST_DP_HEADER_OFFSET (header); + GST_BUFFER_OFFSET_END (buffer) = GST_DP_HEADER_OFFSET_END (header); + + return buffer; +} + +/** + * gst_dp_caps_from_packet: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * @payload: the byte array of the packet payload + * + * Creates a newly allocated #GstCaps from the given packet. + * + * Returns: %TRUE if the caps was successfully created + */ +GstCaps * +gst_dp_caps_from_packet (guint header_length, const guint8 * header, + const guint8 * payload) +{ + GstCaps *caps; + const gchar *string; + + g_return_val_if_fail (header, FALSE); + g_return_val_if_fail (payload, FALSE); + g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) == + GST_DP_PAYLOAD_CAPS, FALSE); + + string = payload; + caps = gst_caps_from_string (string); + return caps; +} + +/** + * gst_dp_event_from_packet: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * @payload: the byte array of the packet payload + * + * Creates a newly allocated #GstEvent from the given packet. + * + * Returns: %TRUE if the event was successfully created + */ +GstEvent * +gst_dp_event_from_packet (guint header_length, const guint8 * header, + const guint8 * payload) +{ + GstEvent *event = NULL; + GstEventType type; + + g_return_val_if_fail (header, FALSE); + /* payload can be NULL, e.g. for an EOS event */ + + type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE; + switch (type) { + case GST_EVENT_UNKNOWN: + g_warning ("Unknown event, ignoring"); + return FALSE; + case GST_EVENT_EOS: + case GST_EVENT_FLUSH: + case GST_EVENT_EMPTY: + case GST_EVENT_DISCONTINUOUS: + event = gst_event_new (type); + GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header); + break; + case GST_EVENT_SEEK: + { + GstSeekType type; + gint64 offset; + GstSeekAccuracy accuracy; + + type = (GstSeekType) GST_DP_GUINT32 (payload); + offset = (gint64) GST_DP_GUINT64 (payload + 4); + accuracy = (GstSeekAccuracy) GST_DP_GUINT32 (payload + 12); + event = gst_event_new_seek (type, offset); + GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header); + GST_EVENT_SEEK_ACCURACY (event) = accuracy; + break; + } + case GST_EVENT_SEEK_SEGMENT: + { + GstSeekType type; + gint64 offset, endoffset; + GstSeekAccuracy accuracy; + + type = (GstSeekType) GST_DP_GUINT32 (payload); + offset = (gint64) GST_DP_GUINT64 (payload + 4); + endoffset = (gint64) GST_DP_GUINT64 (payload + 12); + accuracy = (GstSeekAccuracy) GST_DP_GUINT32 (payload + 20); + event = gst_event_new_segment_seek (type, offset, endoffset); + GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header); + GST_EVENT_SEEK_ACCURACY (event) = accuracy; + break; + } + case GST_EVENT_QOS: + case GST_EVENT_SEGMENT_DONE: + case GST_EVENT_SIZE: + case GST_EVENT_RATE: + case GST_EVENT_FILLER: + case GST_EVENT_TS_OFFSET: + case GST_EVENT_INTERRUPT: + case GST_EVENT_NAVIGATION: + case GST_EVENT_TAG: + g_warning ("Unhandled event type %d, ignoring", GST_EVENT_TYPE (event)); + return FALSE; + default: + g_warning ("Unknown event type %d, ignoring", GST_EVENT_TYPE (event)); + return FALSE; + } + + return event; +} + +/** + * gst_dp_validate_header: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * + * Validates the given packet header by checking the CRC checksum. + * + * Returns: %TRUE if the CRC matches, or no CRC checksum is present + */ +gboolean +gst_dp_validate_header (guint header_length, const guint8 * header) +{ + guint16 crc_read, crc_calculated; + + if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_HEADER)) + return TRUE; + crc_read = GST_DP_HEADER_CRC_HEADER (header); + /* don't included the last two crc fields for the crc check */ + crc_calculated = gst_dp_crc (header, header_length - 4); + if (crc_read != crc_calculated) { + GST_WARNING ("header crc mismatch: read %02x, calculated %02x", crc_read, + crc_calculated); + return FALSE; + } + GST_LOG ("header crc validation: %02x", crc_read); + return TRUE; +} + +/** + * gst_dp_validate_payload: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * @payload: the byte array of the packet payload + * + * Validates the given packet payload using the given packet header + * by checking the CRC checksum. + * + * Returns: %TRUE if the CRC matches, or no CRC checksum is present + */ +gboolean +gst_dp_validate_payload (guint header_length, const guint8 * header, + const guint8 * payload) +{ + guint16 crc_read, crc_calculated; + + if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_PAYLOAD)) + return TRUE; + crc_read = GST_DP_HEADER_CRC_PAYLOAD (header); + crc_calculated = gst_dp_crc (payload, GST_DP_HEADER_PAYLOAD_LENGTH (header)); + if (crc_read != crc_calculated) { + GST_WARNING ("payload crc mismatch: read %02x, calculated %02x", crc_read, + crc_calculated); + return FALSE; + } + GST_LOG ("payload crc validation: %02x", crc_read); + return TRUE; +} + +/** + * gst_dp_validate_packet: + * @header_length: the length of the packet header + * @header: the byte array of the packet header + * @payload: the byte array of the packet payload + * + * Validates the given packet by checking version information and checksums. + * + * Returns: %TRUE if the packet validates + */ +gboolean +gst_dp_validate_packet (guint header_length, const guint8 * header, + const guint8 * payload) +{ + if (!gst_dp_validate_header (header_length, header)) + return FALSE; + if (!gst_dp_validate_payload (header_length, header, payload)) + return FALSE; + + return TRUE; +} + +/*** PLUGIN STUFF ***/ +static gboolean +plugin_init (GstPlugin * plugin) +{ + gst_dp_init (); + + return TRUE; +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "gstdataprotocol", + "a data protocol to serialize buffers, caps and events", + plugin_init, VERSION, GST_LICENSE, GST_PACKAGE, GST_ORIGIN) diff --git a/libs/gst/dataprotocol/dataprotocol.h b/libs/gst/dataprotocol/dataprotocol.h new file mode 100644 index 0000000..b3cba59 --- /dev/null +++ b/libs/gst/dataprotocol/dataprotocol.h @@ -0,0 +1,101 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2004> Thomas Vander Stichele + * + * dataprotocol.h: Functions implementing the GStreamer Data Protocol + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_DATA_PROTOCOL_H__ +#define __GST_DATA_PROTOCOL_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* GStreamer Data Protocol Version */ +#define GST_DP_VERSION_MAJOR 0 +#define GST_DP_VERSION_MINOR 0 + +#define GST_DP_HEADER_LENGTH 60 /* header size in bytes */ + + +/* header flags */ +typedef enum { + GST_DP_HEADER_FLAG_NONE = 0, + GST_DP_HEADER_FLAG_CRC_HEADER = (1 << 0), + GST_DP_HEADER_FLAG_CRC_PAYLOAD = (1 << 1), + GST_DP_HEADER_FLAG_CRC = (1 << 1) | (1 <<0), +} GstDPHeaderFlag; + +/* payload types */ +typedef enum { + GST_DP_PAYLOAD_NONE = 0, + GST_DP_PAYLOAD_BUFFER, + GST_DP_PAYLOAD_CAPS, + GST_DP_PAYLOAD_EVENT_NONE = 64, +} GstDPPayloadType; + +/* payload information from header */ +guint32 gst_dp_header_payload_length (const guint8 * header); +GstDPPayloadType + gst_dp_header_payload_type (const guint8 * header); + +/* converting from GstBuffer/GstEvent/GstCaps */ +gboolean gst_dp_header_from_buffer (const GstBuffer * buffer, + GstDPHeaderFlag flags, + guint * length, + guint8 ** header); +gboolean gst_dp_packet_from_caps (const GstCaps * caps, + GstDPHeaderFlag flags, + guint * length, + guint8 ** header, + guint8 ** payload); +gboolean gst_dp_packet_from_event (const GstEvent * event, + GstDPHeaderFlag flags, + guint * length, + guint8 ** header, + guint8 ** payload); + + +/* converting to GstBuffer/GstEvent/GstCaps */ +GstBuffer * gst_dp_buffer_from_header (guint header_length, + const guint8 * header); +GstCaps * gst_dp_caps_from_packet (guint header_length, + const guint8 * header, + const guint8 * payload); +GstEvent * gst_dp_event_from_packet (guint header_length, + const guint8 * header, + const guint8 * payload); + +/* validation */ +gboolean gst_dp_validate_header (guint header_length, + const guint8 * header); +gboolean gst_dp_validate_payload (guint header_length, + const guint8 * header, + const guint8 * payload); +gboolean gst_dp_validate_packet (guint header_length, + const guint8 * header, + const guint8 * payload); + +G_END_DECLS + +#endif /* __GST_DATA_PROTOCOL_H__ */ + diff --git a/libs/gst/dataprotocol/dp-private.h b/libs/gst/dataprotocol/dp-private.h new file mode 100644 index 0000000..ee738f0 --- /dev/null +++ b/libs/gst/dataprotocol/dp-private.h @@ -0,0 +1,56 @@ +/* GStreamer + * Copyright (C) <1999> Erik Walthinsen + * Copyright (C) <2004> Thomas Vander Stichele + * + * dp-private.h: private defines/macros for dataprotocol implementation + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_DP_PRIVATE_H__ +#define __GST_DP_PRIVATE_H__ + +#include +#include +#include +#include + +G_BEGIN_DECLS + +/* read the given type out of the byte buffer using glib conversion macros */ +#define GST_DP_GUINT16(x) GUINT16_FROM_BE (* (guint16 *) (x)) +#define GST_DP_GUINT32(x) GUINT32_FROM_BE (* (guint32 *) (x)) +#define GST_DP_GUINT64(x) GUINT64_FROM_BE (* (guint64 *) (x)) + +/* accessor defines */ +#define GST_DP_HEADER_MAJOR_VERSION(x) ((x)[0]) +#define GST_DP_HEADER_MINOR_VERSION(x) ((x)[1]) +#define GST_DP_HEADER_FLAGS(x) ((x)[2]) +#define GST_DP_HEADER_PAYLOAD_TYPE(x) ((x)[3]) +#define GST_DP_HEADER_PAYLOAD_LENGTH(x) GST_DP_GUINT32 (x + 4) +#define GST_DP_HEADER_TIMESTAMP(x) GST_DP_GUINT64 (x + 8) +#define GST_DP_HEADER_DURATION(x) GST_DP_GUINT64 (x + 16) +#define GST_DP_HEADER_OFFSET(x) GST_DP_GUINT64 (x + 24) +#define GST_DP_HEADER_OFFSET_END(x) GST_DP_GUINT64 (x + 32) +#define GST_DP_HEADER_CRC_HEADER(x) GST_DP_GUINT16 (x + 56) +#define GST_DP_HEADER_CRC_PAYLOAD(x) GST_DP_GUINT16 (x + 58) + +void gst_dp_dump_byte_array (guint8 *array, guint length); + +G_END_DECLS + +#endif /* __GST_DP_PRIVATE_H__ */ + -- 2.7.4