2004-05-19 16:37:53 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
2006-06-02 10:58:47 +00:00
|
|
|
* Copyright (C) 2004,2006 Thomas Vander Stichele <thomas at apestaart dot org>
|
2014-12-26 11:27:38 +00:00
|
|
|
* Copyright (C) 2014 Tim-Philipp Müller <tim centricular com>
|
2004-05-19 16:37:53 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstdataprotocol
|
2017-03-08 18:01:13 +00:00
|
|
|
* @title: GstDataProtocol
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
* @short_description: Serialization of caps, buffers and events.
|
|
|
|
* @see_also: #GstCaps, #GstEvent, #GstBuffer
|
|
|
|
*
|
|
|
|
* This helper library provides serialization of GstBuffer, GstCaps and
|
|
|
|
* GstEvent structures.
|
|
|
|
*
|
|
|
|
* This serialization is useful when GStreamer needs to interface with
|
|
|
|
* the outside world to transport data between distinct GStreamer pipelines.
|
|
|
|
* The connections with the outside world generally don't have mechanisms
|
|
|
|
* to transport properties of these structures.
|
|
|
|
*
|
|
|
|
* For example, transporting buffers across named pipes or network connections
|
|
|
|
* doesn't maintain the buffer size and separation.
|
|
|
|
*
|
|
|
|
* This data protocol assumes a reliable connection-oriented transport, such as
|
|
|
|
* TCP, a pipe, or a file. The protocol does not serialize the caps for
|
|
|
|
* each buffer; instead, it transport the caps only when they change in the
|
|
|
|
* stream. This implies that there will always be a caps packet before any
|
|
|
|
* buffer packets.
|
|
|
|
*
|
2006-06-06 14:29:54 +00:00
|
|
|
* The versioning of the protocol is independent of GStreamer's version.
|
|
|
|
* The major number gets incremented, and the minor reset, for incompatible
|
|
|
|
* changes. The minor number gets incremented for compatible changes that
|
|
|
|
* allow clients who do not completely understand the newer protocol version
|
|
|
|
* to still decode what they do understand.
|
|
|
|
*
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
* Version 0.2 serializes only a small subset of all events, with a custom
|
|
|
|
* payload for each type. Also, all GDP streams start with the initial caps
|
|
|
|
* packet.
|
|
|
|
*
|
|
|
|
* Version 1.0 serializes all events by taking the string representation of
|
|
|
|
* the event as the payload. In addition, GDP streams can now start with
|
|
|
|
* events as well, as required by the new data stream model in GStreamer 0.10.
|
|
|
|
*
|
2014-12-15 00:41:22 +00:00
|
|
|
* Converting buffers, caps and events to GDP buffers is done using the
|
|
|
|
* appropriate functions.
|
2006-06-13 19:24:34 +00:00
|
|
|
*
|
|
|
|
* For reference, this image shows the byte layout of the GDP header:
|
|
|
|
*
|
|
|
|
* <inlinegraphic format="PNG" fileref="gdp-header.png"></inlinegraphic>
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
*/
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2011-12-25 23:19:57 +00:00
|
|
|
#include "dataprotocol.h"
|
2004-05-19 16:37:53 +00:00
|
|
|
#include <glib/gprintf.h> /* g_sprintf */
|
|
|
|
#include <string.h> /* strlen */
|
|
|
|
#include "dp-private.h"
|
|
|
|
|
|
|
|
/* debug category */
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (data_protocol_debug);
|
2013-02-11 12:34:24 +00:00
|
|
|
#ifndef GST_CAT_DEFAULT
|
|
|
|
#define GST_CAT_DEFAULT data_protocol_debug
|
|
|
|
#endif
|
2004-05-19 16:37:53 +00:00
|
|
|
|
2014-12-15 00:41:22 +00:00
|
|
|
/* The version of the GDP protocol being used */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GST_DP_VERSION_0_2 = 1,
|
|
|
|
GST_DP_VERSION_1_0,
|
|
|
|
} GstDPVersion;
|
|
|
|
|
2006-06-02 10:58:47 +00:00
|
|
|
/* helper macros */
|
|
|
|
|
2008-06-30 09:38:45 +00:00
|
|
|
/* write first 6 bytes of header */
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
#define GST_DP_INIT_HEADER(h, version, flags, type) \
|
2006-06-02 10:58:47 +00:00
|
|
|
G_STMT_START { \
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
gint maj = 0, min = 0; \
|
|
|
|
switch (version) { \
|
|
|
|
case GST_DP_VERSION_0_2: maj = 0; min = 2; break; \
|
|
|
|
case GST_DP_VERSION_1_0: maj = 1; min = 0; break; \
|
|
|
|
} \
|
2006-06-02 10:58:47 +00:00
|
|
|
h[0] = (guint8) maj; \
|
|
|
|
h[1] = (guint8) min; \
|
|
|
|
h[2] = (guint8) flags; \
|
|
|
|
h[3] = 0; /* padding byte */ \
|
|
|
|
GST_WRITE_UINT16_BE (h + 4, type); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
2006-06-02 16:46:19 +00:00
|
|
|
#define GST_DP_SET_CRC(h, flags, payload, length); \
|
|
|
|
G_STMT_START { \
|
|
|
|
guint16 crc = 0; \
|
|
|
|
if (flags & GST_DP_HEADER_FLAG_CRC_HEADER) \
|
|
|
|
/* we don't crc the last four bytes since they are crc's */ \
|
|
|
|
crc = gst_dp_crc (h, 58); \
|
|
|
|
GST_WRITE_UINT16_BE (h + 58, crc); \
|
|
|
|
\
|
|
|
|
crc = 0; \
|
|
|
|
if (length && (flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD)) \
|
|
|
|
crc = gst_dp_crc (payload, length); \
|
|
|
|
GST_WRITE_UINT16_BE (h + 60, crc); \
|
|
|
|
} G_STMT_END
|
2006-06-02 10:58:47 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
/* 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
|
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
static guint16 gst_dp_crc (const guint8 * buffer, guint length);
|
|
|
|
static guint16 gst_dp_crc_from_memory_maps (const GstMapInfo * maps,
|
|
|
|
guint n_maps);
|
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
/* payloading functions */
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
GstBuffer *
|
|
|
|
gst_dp_payload_buffer (GstBuffer * buffer, GstDPHeaderFlag flags)
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
{
|
2014-12-26 11:27:38 +00:00
|
|
|
GstBuffer *ret_buf;
|
|
|
|
GstMapInfo map;
|
|
|
|
GstMemory *mem;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
guint8 *h;
|
|
|
|
guint16 flags_mask;
|
2014-12-13 15:23:48 +00:00
|
|
|
guint16 header_crc = 0, crc = 0;
|
|
|
|
gsize buffer_size;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
mem = gst_allocator_alloc (NULL, GST_DP_HEADER_LENGTH, NULL);
|
|
|
|
gst_memory_map (mem, &map, GST_MAP_READWRITE);
|
|
|
|
h = memset (map.data, 0, map.size);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
/* version, flags, type */
|
2014-12-26 11:27:38 +00:00
|
|
|
GST_DP_INIT_HEADER (h, GST_DP_VERSION_1_0, flags, GST_DP_PAYLOAD_BUFFER);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
if ((flags & GST_DP_HEADER_FLAG_CRC_PAYLOAD)) {
|
|
|
|
GstMapInfo *maps;
|
|
|
|
guint n_maps, i;
|
|
|
|
|
|
|
|
buffer_size = 0;
|
|
|
|
|
|
|
|
n_maps = gst_buffer_n_memory (buffer);
|
|
|
|
if (n_maps > 0) {
|
|
|
|
maps = g_newa (GstMapInfo, n_maps);
|
|
|
|
|
|
|
|
for (i = 0; i < n_maps; ++i) {
|
|
|
|
GstMemory *mem;
|
|
|
|
|
|
|
|
mem = gst_buffer_peek_memory (buffer, i);
|
|
|
|
gst_memory_map (mem, &maps[i], GST_MAP_READ);
|
|
|
|
buffer_size += maps[i].size;
|
|
|
|
}
|
|
|
|
|
|
|
|
crc = gst_dp_crc_from_memory_maps (maps, n_maps);
|
|
|
|
|
|
|
|
for (i = 0; i < n_maps; ++i)
|
|
|
|
gst_memory_unmap (maps[i].memory, &maps[i]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
buffer_size = gst_buffer_get_size (buffer);
|
|
|
|
}
|
2011-03-21 17:13:55 +00:00
|
|
|
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
/* buffer properties */
|
2014-12-13 15:23:48 +00:00
|
|
|
GST_WRITE_UINT32_BE (h + 6, buffer_size);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
GST_WRITE_UINT64_BE (h + 10, GST_BUFFER_TIMESTAMP (buffer));
|
|
|
|
GST_WRITE_UINT64_BE (h + 18, GST_BUFFER_DURATION (buffer));
|
|
|
|
GST_WRITE_UINT64_BE (h + 26, GST_BUFFER_OFFSET (buffer));
|
|
|
|
GST_WRITE_UINT64_BE (h + 34, GST_BUFFER_OFFSET_END (buffer));
|
|
|
|
|
|
|
|
/* data flags; eats two bytes from the ABI area */
|
|
|
|
/* we copy everything but the read-only flags */
|
2011-08-16 15:32:20 +00:00
|
|
|
flags_mask = GST_BUFFER_FLAG_LIVE | GST_BUFFER_FLAG_DISCONT |
|
2012-01-30 16:16:17 +00:00
|
|
|
GST_BUFFER_FLAG_HEADER | GST_BUFFER_FLAG_GAP | GST_BUFFER_FLAG_DELTA_UNIT;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
GST_WRITE_UINT16_BE (h + 42, GST_BUFFER_FLAGS (buffer) & flags_mask);
|
|
|
|
|
2014-01-31 21:38:44 +00:00
|
|
|
/* from gstreamer 1.x, buffers also have the DTS */
|
|
|
|
GST_WRITE_UINT64_BE (h + 44, GST_BUFFER_DTS (buffer));
|
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
/* header CRC */
|
|
|
|
if ((flags & GST_DP_HEADER_FLAG_CRC_HEADER))
|
|
|
|
/* we don't crc the last four bytes since they are crc's */
|
|
|
|
header_crc = gst_dp_crc (h, 58);
|
|
|
|
else
|
|
|
|
header_crc = 0;
|
|
|
|
|
|
|
|
GST_WRITE_UINT16_BE (h + 58, header_crc);
|
2011-03-21 17:13:55 +00:00
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
/* payload CRC */
|
|
|
|
GST_WRITE_UINT16_BE (h + 60, crc);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
GST_MEMDUMP ("payload header for buffer", h, GST_DP_HEADER_LENGTH);
|
|
|
|
gst_memory_unmap (mem, &map);
|
|
|
|
|
|
|
|
ret_buf = gst_buffer_new ();
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
gst_buffer_append_memory (ret_buf, mem);
|
|
|
|
|
|
|
|
/* buffer data */
|
|
|
|
return gst_buffer_append (ret_buf, gst_buffer_ref (buffer));
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
}
|
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
GstBuffer *
|
|
|
|
gst_dp_payload_caps (const GstCaps * caps, GstDPHeaderFlag flags)
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
{
|
2014-12-26 11:27:38 +00:00
|
|
|
GstBuffer *buf;
|
|
|
|
GstMapInfo map;
|
|
|
|
GstMemory *mem;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
guint8 *h;
|
|
|
|
guchar *string;
|
|
|
|
guint payload_length;
|
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
g_assert (GST_IS_CAPS (caps));
|
|
|
|
|
|
|
|
buf = gst_buffer_new ();
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
mem = gst_allocator_alloc (NULL, GST_DP_HEADER_LENGTH, NULL);
|
|
|
|
gst_memory_map (mem, &map, GST_MAP_READWRITE);
|
|
|
|
h = memset (map.data, 0, map.size);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
string = (guchar *) gst_caps_to_string (caps);
|
|
|
|
payload_length = strlen ((gchar *) string) + 1; /* include trailing 0 */
|
|
|
|
|
|
|
|
/* version, flags, type */
|
2014-12-26 11:27:38 +00:00
|
|
|
GST_DP_INIT_HEADER (h, GST_DP_VERSION_1_0, flags, GST_DP_PAYLOAD_CAPS);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
/* buffer properties */
|
|
|
|
GST_WRITE_UINT32_BE (h + 6, payload_length);
|
|
|
|
GST_WRITE_UINT64_BE (h + 10, (guint64) 0);
|
|
|
|
GST_WRITE_UINT64_BE (h + 18, (guint64) 0);
|
|
|
|
GST_WRITE_UINT64_BE (h + 26, (guint64) 0);
|
|
|
|
GST_WRITE_UINT64_BE (h + 34, (guint64) 0);
|
|
|
|
|
|
|
|
GST_DP_SET_CRC (h, flags, string, payload_length);
|
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
GST_MEMDUMP ("payload header for caps", h, GST_DP_HEADER_LENGTH);
|
|
|
|
gst_memory_unmap (mem, &map);
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
gst_buffer_append_memory (buf, mem);
|
|
|
|
|
|
|
|
/* caps string */
|
|
|
|
gst_buffer_append_memory (buf,
|
|
|
|
gst_memory_new_wrapped (0, string, payload_length, 0, payload_length,
|
|
|
|
string, g_free));
|
|
|
|
|
|
|
|
return buf;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
}
|
|
|
|
|
2014-12-26 11:27:38 +00:00
|
|
|
GstBuffer *
|
|
|
|
gst_dp_payload_event (const GstEvent * event, GstDPHeaderFlag flags)
|
|
|
|
{
|
|
|
|
GstBuffer *buf;
|
|
|
|
GstMapInfo map;
|
|
|
|
GstMemory *mem;
|
|
|
|
guint8 *h;
|
|
|
|
guint32 pl_length; /* length of payload */
|
|
|
|
guchar *string = NULL;
|
|
|
|
const GstStructure *structure;
|
|
|
|
|
|
|
|
g_assert (GST_IS_EVENT (event));
|
|
|
|
|
|
|
|
buf = gst_buffer_new ();
|
|
|
|
|
|
|
|
mem = gst_allocator_alloc (NULL, GST_DP_HEADER_LENGTH, NULL);
|
|
|
|
gst_memory_map (mem, &map, GST_MAP_READWRITE);
|
|
|
|
h = memset (map.data, 0, map.size);
|
|
|
|
|
|
|
|
structure = gst_event_get_structure ((GstEvent *) event);
|
|
|
|
if (structure) {
|
|
|
|
string = (guchar *) gst_structure_to_string (structure);
|
|
|
|
GST_LOG ("event %p has structure, string %s", event, string);
|
|
|
|
pl_length = strlen ((gchar *) string) + 1; /* include trailing 0 */
|
|
|
|
} else {
|
|
|
|
GST_LOG ("event %p has no structure", event);
|
|
|
|
pl_length = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* version, flags, type */
|
|
|
|
GST_DP_INIT_HEADER (h, GST_DP_VERSION_1_0, flags,
|
|
|
|
GST_DP_PAYLOAD_EVENT_NONE + GST_EVENT_TYPE (event));
|
|
|
|
|
|
|
|
/* length */
|
|
|
|
GST_WRITE_UINT32_BE (h + 6, pl_length);
|
|
|
|
/* timestamp */
|
2016-02-02 17:18:26 +00:00
|
|
|
/* NOTE: timestamp field will be removed from GstEvent in 2.0 API */
|
|
|
|
GST_WRITE_UINT64_BE (h + 10, GST_CLOCK_TIME_NONE);
|
2014-12-26 11:27:38 +00:00
|
|
|
|
|
|
|
GST_DP_SET_CRC (h, flags, string, pl_length);
|
|
|
|
|
|
|
|
GST_MEMDUMP ("payload header for event", h, GST_DP_HEADER_LENGTH);
|
|
|
|
gst_memory_unmap (mem, &map);
|
|
|
|
|
|
|
|
/* header */
|
|
|
|
gst_buffer_append_memory (buf, mem);
|
|
|
|
|
|
|
|
/* event string */
|
|
|
|
if (pl_length > 0) {
|
|
|
|
gst_buffer_append_memory (buf,
|
|
|
|
gst_memory_new_wrapped (0, string, pl_length, 0, pl_length,
|
|
|
|
string, g_free));
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
/*** PUBLIC FUNCTIONS ***/
|
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
static const guint16 gst_dp_crc_table[256] = {
|
|
|
|
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
|
|
|
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
|
|
|
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
|
|
|
0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de,
|
|
|
|
0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485,
|
|
|
|
0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d,
|
|
|
|
0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4,
|
|
|
|
0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc,
|
|
|
|
0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823,
|
|
|
|
0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b,
|
|
|
|
0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12,
|
|
|
|
0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a,
|
|
|
|
0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41,
|
|
|
|
0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49,
|
|
|
|
0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70,
|
|
|
|
0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78,
|
|
|
|
0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f,
|
|
|
|
0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067,
|
|
|
|
0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e,
|
|
|
|
0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256,
|
|
|
|
0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d,
|
|
|
|
0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
|
|
|
0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c,
|
|
|
|
0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634,
|
|
|
|
0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab,
|
|
|
|
0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3,
|
|
|
|
0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a,
|
|
|
|
0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92,
|
|
|
|
0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9,
|
|
|
|
0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1,
|
|
|
|
0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8,
|
|
|
|
0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0
|
|
|
|
};
|
|
|
|
|
2006-06-02 10:08:31 +00:00
|
|
|
/**
|
|
|
|
* gst_dp_crc:
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
* @buffer: array of bytes
|
|
|
|
* @length: the length of @buffer
|
2006-06-02 10:08:31 +00:00
|
|
|
*
|
|
|
|
* Calculate a CRC for the given buffer over the given number of bytes.
|
|
|
|
* This is only provided for verification purposes; typical GDP users
|
|
|
|
* will not need this function.
|
|
|
|
*
|
|
|
|
* Returns: a two-byte CRC checksum.
|
|
|
|
*/
|
2014-12-13 15:23:48 +00:00
|
|
|
static guint16
|
2006-06-02 10:08:31 +00:00
|
|
|
gst_dp_crc (const guint8 * buffer, guint length)
|
2004-05-19 16:37:53 +00:00
|
|
|
{
|
2005-10-10 23:55:39 +00:00
|
|
|
guint16 crc_register = CRC_INIT;
|
2004-05-19 16:37:53 +00:00
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
if (length == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
g_assert (buffer != NULL);
|
2004-05-19 16:37:53 +00:00
|
|
|
|
|
|
|
/* calc CRC */
|
|
|
|
for (; length--;) {
|
|
|
|
crc_register = (guint16) ((crc_register << 8) ^
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
gst_dp_crc_table[((crc_register >> 8) & 0x00ff) ^ *buffer++]);
|
2004-05-19 16:37:53 +00:00
|
|
|
}
|
|
|
|
return (0xffff ^ crc_register);
|
|
|
|
}
|
|
|
|
|
2014-12-13 15:23:48 +00:00
|
|
|
static guint16
|
|
|
|
gst_dp_crc_from_memory_maps (const GstMapInfo * maps, guint n_maps)
|
|
|
|
{
|
|
|
|
guint16 crc_register = CRC_INIT;
|
|
|
|
gsize total_length = 0;
|
|
|
|
|
|
|
|
if (n_maps == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
g_assert (maps != NULL);
|
|
|
|
|
|
|
|
/* calc CRC */
|
|
|
|
while (n_maps > 0) {
|
|
|
|
guint8 *buffer = maps->data;
|
|
|
|
gsize length = maps->size;
|
|
|
|
|
|
|
|
total_length += length;
|
|
|
|
|
|
|
|
while (length-- > 0) {
|
|
|
|
crc_register = (guint16) ((crc_register << 8) ^
|
|
|
|
gst_dp_crc_table[((crc_register >> 8) & 0x00ff) ^ *buffer++]);
|
|
|
|
}
|
|
|
|
--n_maps;
|
|
|
|
++maps;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (G_UNLIKELY (total_length == 0))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return (0xffff ^ crc_register);
|
|
|
|
}
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
/**
|
|
|
|
* gst_dp_init:
|
|
|
|
*
|
|
|
|
* Initialize GStreamer Data Protocol library.
|
|
|
|
*
|
2005-07-05 10:20:14 +00:00
|
|
|
* Should be called before using these functions from source linking
|
|
|
|
* to this source file.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_dp_init (void)
|
|
|
|
{
|
|
|
|
GST_DEBUG_CATEGORY_INIT (data_protocol_debug, "gdp", 0,
|
|
|
|
"GStreamer Data Protocol");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dp_header_payload_length:
|
|
|
|
* @header: the byte header of the packet array
|
|
|
|
*
|
gdp: Documentation updates.
Original commit message from CVS:
* libs/gst/base/gstadapter.c:
* libs/gst/base/gstadapter.h:
* libs/gst/base/gstbasesink.c: (gst_base_sink_class_init),
(gst_base_sink_get_position):
* libs/gst/base/gstbasesink.h:
* libs/gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_default_query), (gst_base_src_default_do_seek),
(gst_base_src_do_seek), (gst_base_src_perform_seek),
(gst_base_src_send_event), (gst_base_src_update_length),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_start):
* libs/gst/base/gstbasesrc.h:
* libs/gst/base/gstbasetransform.h:
* libs/gst/base/gstcollectpads.h:
* libs/gst/base/gstpushsrc.c:
* libs/gst/base/gstpushsrc.h:
* libs/gst/dataprotocol/dataprotocol.c:
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/net/gstnetclientclock.h:
* libs/gst/net/gstnettimeprovider.h:
Documentation updates.
2005-12-18 16:04:41 +00:00
|
|
|
* Get the length of the payload described by @header.
|
|
|
|
*
|
2004-05-19 16:37:53 +00:00
|
|
|
* Returns: the length of the payload this header describes.
|
|
|
|
*/
|
|
|
|
guint32
|
|
|
|
gst_dp_header_payload_length (const guint8 * header)
|
|
|
|
{
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header != NULL, 0);
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
return GST_DP_HEADER_PAYLOAD_LENGTH (header);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_dp_header_payload_type:
|
|
|
|
* @header: the byte header of the packet array
|
|
|
|
*
|
gdp: Documentation updates.
Original commit message from CVS:
* libs/gst/base/gstadapter.c:
* libs/gst/base/gstadapter.h:
* libs/gst/base/gstbasesink.c: (gst_base_sink_class_init),
(gst_base_sink_get_position):
* libs/gst/base/gstbasesink.h:
* libs/gst/base/gstbasesrc.c: (gst_base_src_class_init),
(gst_base_src_default_query), (gst_base_src_default_do_seek),
(gst_base_src_do_seek), (gst_base_src_perform_seek),
(gst_base_src_send_event), (gst_base_src_update_length),
(gst_base_src_get_range), (gst_base_src_loop),
(gst_base_src_start):
* libs/gst/base/gstbasesrc.h:
* libs/gst/base/gstbasetransform.h:
* libs/gst/base/gstcollectpads.h:
* libs/gst/base/gstpushsrc.c:
* libs/gst/base/gstpushsrc.h:
* libs/gst/dataprotocol/dataprotocol.c:
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/net/gstnetclientclock.h:
* libs/gst/net/gstnettimeprovider.h:
Documentation updates.
2005-12-18 16:04:41 +00:00
|
|
|
* Get the type of the payload described by @header.
|
|
|
|
*
|
2004-05-19 16:37:53 +00:00
|
|
|
* Returns: the #GstDPPayloadType the payload this header describes.
|
|
|
|
*/
|
|
|
|
GstDPPayloadType
|
|
|
|
gst_dp_header_payload_type (const guint8 * header)
|
|
|
|
{
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header != NULL, GST_DP_PAYLOAD_NONE);
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
return GST_DP_HEADER_PAYLOAD_TYPE (header);
|
|
|
|
}
|
|
|
|
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
/*** DEPACKETIZING FUNCTIONS ***/
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
/**
|
|
|
|
* gst_dp_buffer_from_header:
|
|
|
|
* @header_length: the length of the packet header
|
|
|
|
* @header: the byte array of the packet header
|
2016-03-31 09:21:35 +00:00
|
|
|
* @allocator: the allocator used to allocate the new #GstBuffer
|
|
|
|
* @allocation_params: the allocations parameters used to allocate the new #GstBuffer
|
2004-05-19 16:37:53 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
* This function does not check the header passed to it, use
|
|
|
|
* gst_dp_validate_header() first if the header data is unchecked.
|
|
|
|
*
|
2006-03-10 15:30:27 +00:00
|
|
|
* Returns: A #GstBuffer if the buffer was successfully created, or NULL.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
GstBuffer *
|
2016-03-31 09:21:35 +00:00
|
|
|
gst_dp_buffer_from_header (guint header_length, const guint8 * header,
|
|
|
|
GstAllocator * allocator, GstAllocationParams * allocation_params)
|
2004-05-19 16:37:53 +00:00
|
|
|
{
|
|
|
|
GstBuffer *buffer;
|
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header != NULL, NULL);
|
|
|
|
g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL);
|
2004-05-19 16:37:53 +00:00
|
|
|
g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) ==
|
2005-09-27 16:30:26 +00:00
|
|
|
GST_DP_PAYLOAD_BUFFER, NULL);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
buffer =
|
2016-03-31 09:21:35 +00:00
|
|
|
gst_buffer_new_allocate (allocator,
|
|
|
|
(guint) GST_DP_HEADER_PAYLOAD_LENGTH (header), allocation_params);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (buffer) = GST_DP_HEADER_TIMESTAMP (header);
|
2014-01-31 21:38:44 +00:00
|
|
|
GST_BUFFER_DTS (buffer) = GST_DP_HEADER_DTS (header);
|
2004-05-19 16:37:53 +00:00
|
|
|
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);
|
2004-06-09 16:24:19 +00:00
|
|
|
GST_BUFFER_FLAGS (buffer) = GST_DP_HEADER_BUFFER_FLAGS (header);
|
2004-05-19 16:37:53 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
*
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
* This function does not check the arguments passed to it, use
|
|
|
|
* gst_dp_validate_packet() first if the header and payload data are
|
|
|
|
* unchecked.
|
|
|
|
*
|
2006-03-10 15:30:27 +00:00
|
|
|
* Returns: A #GstCaps containing the caps represented in the packet,
|
|
|
|
* or NULL if the packet could not be converted.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
GstCaps *
|
|
|
|
gst_dp_caps_from_packet (guint header_length, const guint8 * header,
|
|
|
|
const guint8 * payload)
|
|
|
|
{
|
|
|
|
GstCaps *caps;
|
2005-10-13 16:26:12 +00:00
|
|
|
gchar *string;
|
2004-05-19 16:37:53 +00:00
|
|
|
|
2005-09-27 16:30:26 +00:00
|
|
|
g_return_val_if_fail (header, NULL);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL);
|
2004-05-19 16:37:53 +00:00
|
|
|
g_return_val_if_fail (GST_DP_HEADER_PAYLOAD_TYPE (header) ==
|
2005-09-27 16:30:26 +00:00
|
|
|
GST_DP_PAYLOAD_CAPS, NULL);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (payload, NULL);
|
2004-05-19 16:37:53 +00:00
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
/* 0 sized payload length will work create NULL string */
|
2005-10-13 16:26:12 +00:00
|
|
|
string = g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header));
|
2004-05-19 16:37:53 +00:00
|
|
|
caps = gst_caps_from_string (string);
|
2005-10-13 16:26:12 +00:00
|
|
|
g_free (string);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
static GstEvent *
|
|
|
|
gst_dp_event_from_packet_0_2 (guint header_length, const guint8 * header,
|
2004-05-19 16:37:53 +00:00
|
|
|
const guint8 * payload)
|
|
|
|
{
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
GstEventType type;
|
|
|
|
|
|
|
|
type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE;
|
|
|
|
switch (type) {
|
|
|
|
case GST_EVENT_UNKNOWN:
|
2006-04-28 13:40:15 +00:00
|
|
|
GST_WARNING ("Unknown event, ignoring");
|
gdp: Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
return NULL;
|
2004-05-19 16:37:53 +00:00
|
|
|
case GST_EVENT_EOS:
|
gdp: Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
case GST_EVENT_FLUSH_START:
|
|
|
|
case GST_EVENT_FLUSH_STOP:
|
2011-05-13 16:07:24 +00:00
|
|
|
case GST_EVENT_SEGMENT:
|
gdp: Some docs updates
Original commit message from CVS:
* CHANGES-0.9:
* docs/design/part-TODO.txt:
* docs/design/part-events.txt:
Some docs updates
* gst/base/gstbasesink.c: (gst_base_sink_handle_object),
(gst_base_sink_event), (gst_base_sink_do_sync),
(gst_base_sink_activate_push), (gst_base_sink_activate_pull):
* gst/base/gstbasesrc.c: (gst_base_src_send_discont),
(gst_base_src_do_seek), (gst_base_src_event_handler),
(gst_base_src_loop):
* gst/base/gstbasetransform.c: (gst_base_transform_transform_caps),
(gst_base_transform_configure_caps), (gst_base_transform_setcaps),
(gst_base_transform_get_size), (gst_base_transform_buffer_alloc),
(gst_base_transform_event), (gst_base_transform_handle_buffer),
(gst_base_transform_set_passthrough),
(gst_base_transform_is_passthrough):
* gst/elements/gstfakesink.c: (gst_fake_sink_event):
* gst/elements/gstfilesink.c: (gst_file_sink_event):
Event updates.
* gst/gstbuffer.h:
Use faster casts.
* gst/gstelement.c: (gst_element_seek):
* gst/gstelement.h:
Update gst_element_seek.
* gst/gstevent.c: (gst_event_finalize), (_gst_event_copy),
(gst_event_new), (gst_event_new_custom), (gst_event_get_structure),
(gst_event_new_flush_start), (gst_event_new_flush_stop),
(gst_event_new_eos), (gst_event_new_newsegment),
(gst_event_parse_newsegment), (gst_event_new_tag),
(gst_event_parse_tag), (gst_event_new_filler), (gst_event_new_qos),
(gst_event_parse_qos), (gst_event_new_seek),
(gst_event_parse_seek), (gst_event_new_navigation):
* gst/gstevent.h:
Make GstEvent use GstStructure. Add parsing code, make sure the
API is sufficiently generic.
Mark possible directions of events and serialization.
* gst/gstmessage.c: (gst_message_init), (gst_message_finalize),
(_gst_message_copy), (gst_message_new_segment_start),
(gst_message_new_segment_done), (gst_message_new_custom),
(gst_message_parse_segment_start),
(gst_message_parse_segment_done):
Small cleanups.
* gst/gstpad.c: (gst_pad_get_caps_unlocked), (gst_pad_accept_caps),
(gst_pad_set_caps), (gst_pad_send_event):
Update for new events.
Catch events sent in wrong directions.
* gst/gstqueue.c: (gst_queue_link_src),
(gst_queue_handle_sink_event), (gst_queue_chain), (gst_queue_loop),
(gst_queue_handle_src_query):
Event updates.
* gst/gsttag.c:
* gst/gsttag.h:
Remove event code from this file.
* libs/gst/dataprotocol/dataprotocol.c: (gst_dp_packet_from_event),
(gst_dp_event_from_packet):
Event updates.
2005-07-27 18:33:03 +00:00
|
|
|
event = gst_event_new_custom (type, NULL);
|
2004-05-19 16:37:53 +00:00
|
|
|
break;
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
{
|
2005-07-27 19:00:36 +00:00
|
|
|
gdouble rate;
|
|
|
|
GstFormat format;
|
|
|
|
GstSeekFlags flags;
|
2012-07-27 13:21:51 +00:00
|
|
|
GstSeekType start_type, stop_type;
|
|
|
|
gint64 start, stop;
|
2005-07-27 19:00:36 +00:00
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (payload != NULL, NULL);
|
|
|
|
|
2005-07-27 19:00:36 +00:00
|
|
|
/* FIXME, read rate */
|
|
|
|
rate = 1.0;
|
|
|
|
format = (GstFormat) GST_READ_UINT32_BE (payload);
|
|
|
|
flags = (GstSeekFlags) GST_READ_UINT32_BE (payload + 4);
|
2012-07-27 13:21:51 +00:00
|
|
|
start_type = (GstSeekType) GST_READ_UINT32_BE (payload + 8);
|
|
|
|
start = (gint64) GST_READ_UINT64_BE (payload + 12);
|
2005-07-27 19:00:36 +00:00
|
|
|
stop_type = (GstSeekType) GST_READ_UINT32_BE (payload + 20);
|
|
|
|
stop = (gint64) GST_READ_UINT64_BE (payload + 24);
|
|
|
|
|
2012-07-27 13:21:51 +00:00
|
|
|
event = gst_event_new_seek (rate, format, flags, start_type, start,
|
2005-07-27 19:00:36 +00:00
|
|
|
stop_type, stop);
|
|
|
|
GST_EVENT_TIMESTAMP (event) = GST_DP_HEADER_TIMESTAMP (header);
|
2004-05-19 16:37:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GST_EVENT_QOS:
|
|
|
|
case GST_EVENT_NAVIGATION:
|
|
|
|
case GST_EVENT_TAG:
|
2006-04-28 13:40:15 +00:00
|
|
|
GST_WARNING ("Unhandled event type %d, ignoring", type);
|
gdp: Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
return NULL;
|
2004-05-19 16:37:53 +00:00
|
|
|
default:
|
2006-04-28 13:40:15 +00:00
|
|
|
GST_WARNING ("Unknown event type %d, ignoring", type);
|
gdp: Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* gst/gstconfig.h.in:
* libs/gst/base/gstcollectpads.c: (gst_collect_pads_read_buffer):
* libs/gst/check/gstcheck.c: (gst_check_log_message_func),
(gst_check_log_critical_func), (gst_check_drop_buffers),
(gst_check_element_push_buffer_list):
* libs/gst/controller/gstcontroller.c: (gst_controller_get),
(gst_controller_get_type):
* libs/gst/controller/gsthelper.c: (gst_object_control_properties),
(gst_object_get_controller), (gst_object_get_control_source):
* libs/gst/controller/gstinterpolationcontrolsource.c:
(gst_interpolation_control_source_new):
* libs/gst/controller/gstlfocontrolsource.c:
(gst_lfo_control_source_new):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_event_from_packet_0_2):
* plugins/elements/gstfdsrc.c:
* plugins/elements/gstmultiqueue.c:
* plugins/elements/gsttee.c:
* plugins/elements/gsttypefindelement.c:
* plugins/indexers/gstfileindex.c: (_file_index_id_save_xml),
(gst_file_index_add_association):
* plugins/indexers/gstmemindex.c:
* tests/benchmarks/gstpollstress.c: (mess_some_more):
* tests/check/elements/queue.c: (setup_queue):
* tests/check/gst/gstpipeline.c:
* tests/check/libs/collectpads.c: (setup), (teardown),
(gst_collect_pads_suite):
* tests/examples/adapter/adapter_test.c:
* tests/examples/metadata/read-metadata.c: (make_pipeline):
* tests/examples/xml/createxml.c:
* tests/examples/xml/runxml.c:
* tools/gst-inspect.c:
* tools/gst-run.c:
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers, not using variable sized arrays
on the stack, moving variable declarations to the beginning of
a block and using "foo (void)" instead of "foo ()" for declarations.
2008-02-29 12:41:33 +00:00
|
|
|
return NULL;
|
2004-05-19 16:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
static GstEvent *
|
|
|
|
gst_dp_event_from_packet_1_0 (guint header_length, const guint8 * header,
|
|
|
|
const guint8 * payload)
|
|
|
|
{
|
|
|
|
GstEvent *event = NULL;
|
|
|
|
GstEventType type;
|
2006-07-13 14:02:16 +00:00
|
|
|
gchar *string = NULL;
|
|
|
|
GstStructure *s = NULL;
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
type = GST_DP_HEADER_PAYLOAD_TYPE (header) - GST_DP_PAYLOAD_EVENT_NONE;
|
2006-07-13 14:02:16 +00:00
|
|
|
if (payload) {
|
|
|
|
string =
|
|
|
|
g_strndup ((gchar *) payload, GST_DP_HEADER_PAYLOAD_LENGTH (header));
|
|
|
|
s = gst_structure_from_string (string, NULL);
|
2014-06-03 01:43:56 +00:00
|
|
|
if (s == NULL) {
|
|
|
|
GST_WARNING ("Could not parse payload string: %s", string);
|
2014-06-09 09:10:01 +00:00
|
|
|
g_free (string);
|
2014-06-03 01:43:56 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2006-07-13 14:02:16 +00:00
|
|
|
g_free (string);
|
|
|
|
}
|
2012-09-09 17:05:55 +00:00
|
|
|
GST_LOG ("Creating event of type 0x%x with structure '%" GST_PTR_FORMAT "'",
|
|
|
|
type, s);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
event = gst_event_new_custom (type, s);
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
* This function does not check the arguments passed to it, use
|
|
|
|
* gst_dp_validate_packet() first if the header and payload data are
|
|
|
|
* unchecked.
|
|
|
|
*
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
* Returns: A #GstEvent if the event was successfully created,
|
|
|
|
* or NULL if an event could not be read from the payload.
|
|
|
|
*/
|
|
|
|
GstEvent *
|
|
|
|
gst_dp_event_from_packet (guint header_length, const guint8 * header,
|
|
|
|
const guint8 * payload)
|
|
|
|
{
|
|
|
|
guint8 major, minor;
|
|
|
|
|
|
|
|
g_return_val_if_fail (header, NULL);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, NULL);
|
gdp: add a GstDPPacketizer object, and create/free functions
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_version_get_type), (gst_dp_init),
(gst_dp_header_from_buffer), (gst_dp_header_from_buffer_1_0),
(gst_dp_packet_from_caps), (gst_dp_packet_from_caps_1_0),
(gst_dp_packet_from_event), (gst_dp_packet_from_event_1_0),
(gst_dp_event_from_packet_0_2), (gst_dp_event_from_packet_1_0),
(gst_dp_event_from_packet), (gst_dp_packetizer_new),
(gst_dp_packetizer_free):
* libs/gst/dataprotocol/dataprotocol.h:
API: add a GstDPPacketizer object, and create/free functions
API: add GstDPVersion enum
Add 1.0 event function that uses the string serialization
Serialize more useful buffer flags
Fixes #343988
2006-06-06 14:24:00 +00:00
|
|
|
|
|
|
|
major = GST_DP_HEADER_MAJOR_VERSION (header);
|
|
|
|
minor = GST_DP_HEADER_MINOR_VERSION (header);
|
|
|
|
|
|
|
|
if (major == 0 && minor == 2)
|
|
|
|
return gst_dp_event_from_packet_0_2 (header_length, header, payload);
|
|
|
|
else if (major == 1 && minor == 0)
|
|
|
|
return gst_dp_event_from_packet_1_0 (header_length, header, payload);
|
|
|
|
else {
|
|
|
|
GST_ERROR ("Unknown GDP version %d.%d", major, minor);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2004-07-28 10:22:07 +00:00
|
|
|
* Returns: %TRUE if the CRC matches, or no CRC checksum is present.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_dp_validate_header (guint header_length, const guint8 * header)
|
|
|
|
{
|
|
|
|
guint16 crc_read, crc_calculated;
|
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, FALSE);
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_HEADER))
|
|
|
|
return TRUE;
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
crc_read = GST_DP_HEADER_CRC_HEADER (header);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2006-05-08 15:53:12 +00:00
|
|
|
/* don't include the last two crc fields for the crc check */
|
2004-05-19 16:37:53 +00:00
|
|
|
crc_calculated = gst_dp_crc (header, header_length - 4);
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
if (crc_read != crc_calculated)
|
|
|
|
goto crc_error;
|
|
|
|
|
|
|
|
GST_LOG ("header crc validation: %02x", crc_read);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
crc_error:
|
|
|
|
{
|
2004-05-19 16:37:53 +00:00
|
|
|
GST_WARNING ("header crc mismatch: read %02x, calculated %02x", crc_read,
|
|
|
|
crc_calculated);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2004-07-28 10:22:07 +00:00
|
|
|
* Returns: %TRUE if the CRC matches, or no CRC checksum is present.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_dp_validate_payload (guint header_length, const guint8 * header,
|
|
|
|
const guint8 * payload)
|
|
|
|
{
|
|
|
|
guint16 crc_read, crc_calculated;
|
|
|
|
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
g_return_val_if_fail (header != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (header_length >= GST_DP_HEADER_LENGTH, FALSE);
|
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
if (!(GST_DP_HEADER_FLAGS (header) & GST_DP_HEADER_FLAG_CRC_PAYLOAD))
|
|
|
|
return TRUE;
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
|
2004-05-19 16:37:53 +00:00
|
|
|
crc_read = GST_DP_HEADER_CRC_PAYLOAD (header);
|
|
|
|
crc_calculated = gst_dp_crc (payload, GST_DP_HEADER_PAYLOAD_LENGTH (header));
|
gdp: Make debug category static
Original commit message from CVS:
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer_any), (gst_dp_packet_from_caps_any),
(gst_dp_crc), (gst_dp_header_payload_length),
(gst_dp_header_payload_type), (gst_dp_packet_from_event),
(gst_dp_packet_from_event_1_0), (gst_dp_buffer_from_header),
(gst_dp_caps_from_packet), (gst_dp_event_from_packet_0_2),
(gst_dp_event_from_packet), (gst_dp_validate_header),
(gst_dp_validate_payload):
Make debug category static
Constify the crc table.
Do some more arg checking in public functions.
Fix some docs and do some small cleanups.
* tests/check/libs/gdp.c: (GST_START_TEST), (gst_dp_suite):
Add some more checks to see if GDP deals with bogus input.
2006-08-02 15:19:30 +00:00
|
|
|
if (crc_read != crc_calculated)
|
|
|
|
goto crc_error;
|
|
|
|
|
|
|
|
GST_LOG ("payload crc validation: %02x", crc_read);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
crc_error:
|
|
|
|
{
|
2004-05-19 16:37:53 +00:00
|
|
|
GST_WARNING ("payload crc mismatch: read %02x, calculated %02x", crc_read,
|
|
|
|
crc_calculated);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2004-07-28 10:22:07 +00:00
|
|
|
* Returns: %TRUE if the packet validates.
|
2004-05-19 16:37:53 +00:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|