gstreamer_core/libs/gst/dataprotocol/dataprotocol.h
changeset 0 0e761a78d257
child 10 6f340f756486
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     1 /* GStreamer
       
     2  * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
       
     3  * Copyright (C) 2004,2006 Thomas Vander Stichele <thomas at apestaart dot org>
       
     4  *
       
     5  * dataprotocol.h: Functions implementing the GStreamer Data Protocol
       
     6  *
       
     7  * This library is free software; you can redistribute it and/or
       
     8  * modify it under the terms of the GNU Library General Public
       
     9  * License as published by the Free Software Foundation; either
       
    10  * version 2 of the License, or (at your option) any later version.
       
    11  *
       
    12  * This library is distributed in the hope that it will be useful,
       
    13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    15  * Library General Public License for more details.
       
    16  *
       
    17  * You should have received a copy of the GNU Library General Public
       
    18  * License along with this library; if not, write to the
       
    19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
       
    20  * Boston, MA 02111-1307, USA.
       
    21  */
       
    22 
       
    23 #ifndef __GST_DATA_PROTOCOL_H__
       
    24 #define __GST_DATA_PROTOCOL_H__
       
    25 
       
    26 #include <gst/gstbuffer.h>
       
    27 #include <gst/gstevent.h>
       
    28 #include <gst/gstcaps.h>
       
    29 
       
    30 G_BEGIN_DECLS
       
    31 
       
    32 /**
       
    33  * GstDPVersion:
       
    34  * @GST_DP_VERSION_0_2: protocol version 0.2
       
    35  * @GST_DP_VERSION_1_0: protocol version 1.0
       
    36  *
       
    37  * The version of the GDP protocol being used.
       
    38  */
       
    39 typedef enum {
       
    40   GST_DP_VERSION_0_2 = 1,
       
    41   GST_DP_VERSION_1_0,
       
    42 } GstDPVersion;
       
    43 #ifdef __SYMBIAN32__
       
    44 IMPORT_C
       
    45 #endif
       
    46 
       
    47 
       
    48 GType gst_dp_version_get_type (void);
       
    49 #define GST_TYPE_DP_VERSION (gst_dp_version_get_type ())
       
    50 
       
    51 /**
       
    52  * GST_DP_VERSION_MAJOR:
       
    53  *
       
    54  * The major version number of the GStreamer Data Protocol.
       
    55  */
       
    56 #define GST_DP_VERSION_MAJOR 0
       
    57 /**
       
    58  * GST_DP_VERSION_MINOR:
       
    59  *
       
    60  * The minor version number of the GStreamer Data Protocol.
       
    61  */
       
    62 #define GST_DP_VERSION_MINOR 2
       
    63 
       
    64 /**
       
    65  * GST_DP_HEADER_LENGTH:
       
    66  *
       
    67  * The header size in bytes.
       
    68  */
       
    69 #define GST_DP_HEADER_LENGTH 62
       
    70 
       
    71 /**
       
    72  * GstDPHeaderFlag:
       
    73  * @GST_DP_HEADER_FLAG_NONE: No flag present.
       
    74  * @GST_DP_HEADER_FLAG_CRC_HEADER: a header CRC field is present.
       
    75  * @GST_DP_HEADER_FLAG_CRC_PAYLOAD: a payload CRC field is present.
       
    76  * @GST_DP_HEADER_FLAG_CRC: a CRC for header and payload is present.
       
    77  *
       
    78  * header flags for the dataprotocol.
       
    79  */
       
    80 typedef enum {
       
    81   GST_DP_HEADER_FLAG_NONE        = 0,
       
    82   GST_DP_HEADER_FLAG_CRC_HEADER  = (1 << 0),
       
    83   GST_DP_HEADER_FLAG_CRC_PAYLOAD = (1 << 1),
       
    84   GST_DP_HEADER_FLAG_CRC         = (1 << 1) | (1 << 0),
       
    85 } GstDPHeaderFlag;
       
    86 
       
    87 /**
       
    88  * GstDPPayloadType:
       
    89  * @GST_DP_PAYLOAD_NONE: Invalid payload type.
       
    90  * @GST_DP_PAYLOAD_BUFFER: #GstBuffer payload packet.
       
    91  * @GST_DP_PAYLOAD_CAPS: #GstCaps payload packet.
       
    92  * @GST_DP_PAYLOAD_EVENT_NONE: First value of #GstEvent payload packets.
       
    93  *
       
    94  * The GDP payload types. a #GstEvent payload type is encoded with the
       
    95  * event type number starting from @GST_DP_PAYLOAD_EVENT_NONE.
       
    96  */
       
    97 typedef enum {
       
    98   GST_DP_PAYLOAD_NONE            = 0,
       
    99   GST_DP_PAYLOAD_BUFFER,
       
   100   GST_DP_PAYLOAD_CAPS,
       
   101   GST_DP_PAYLOAD_EVENT_NONE      = 64,
       
   102 } GstDPPayloadType;
       
   103 
       
   104 typedef gboolean (*GstDPHeaderFromBufferFunction) (const GstBuffer * buffer,
       
   105 						GstDPHeaderFlag flags,
       
   106 						guint * length,
       
   107 						guint8 ** header);
       
   108 typedef gboolean (*GstDPPacketFromCapsFunction) (const GstCaps * caps,
       
   109 						GstDPHeaderFlag flags,
       
   110 						guint * length,
       
   111 						guint8 ** header,
       
   112 						guint8 ** payload);
       
   113 typedef gboolean (*GstDPPacketFromEventFunction) (const GstEvent * event,
       
   114 						GstDPHeaderFlag flags,
       
   115 						guint * length,
       
   116 						guint8 ** header,
       
   117 						guint8 ** payload);
       
   118 typedef struct {
       
   119   GstDPVersion version;
       
   120 
       
   121   GstDPHeaderFromBufferFunction header_from_buffer;
       
   122   GstDPPacketFromCapsFunction packet_from_caps;
       
   123   GstDPPacketFromEventFunction packet_from_event;
       
   124 
       
   125   /*< private >*/
       
   126   gpointer _gst_reserved[GST_PADDING];
       
   127 } GstDPPacketizer;
       
   128 #ifdef __SYMBIAN32__
       
   129 IMPORT_C
       
   130 #endif
       
   131 
       
   132 
       
   133 
       
   134 void		gst_dp_init			(void);
       
   135 
       
   136 /* packetizer */
       
   137 #ifdef __SYMBIAN32__
       
   138 IMPORT_C
       
   139 #endif
       
   140 
       
   141 GstDPPacketizer *
       
   142                 gst_dp_packetizer_new           (GstDPVersion version);
       
   143 #ifdef __SYMBIAN32__
       
   144 IMPORT_C
       
   145 #endif
       
   146 
       
   147 void            gst_dp_packetizer_free          (GstDPPacketizer *packetizer);
       
   148 
       
   149 /* crc checksum */
       
   150 #ifdef __SYMBIAN32__
       
   151 IMPORT_C
       
   152 #endif
       
   153 
       
   154 guint16         gst_dp_crc                      (const guint8 * buffer,
       
   155                                                  guint length);
       
   156 
       
   157 /* payload information from header */
       
   158 #ifdef __SYMBIAN32__
       
   159 IMPORT_C
       
   160 #endif
       
   161 
       
   162 guint32		gst_dp_header_payload_length	(const guint8 * header);
       
   163 #ifdef __SYMBIAN32__
       
   164 IMPORT_C
       
   165 #endif
       
   166 
       
   167 GstDPPayloadType
       
   168 		gst_dp_header_payload_type	(const guint8 * header);
       
   169 
       
   170 /* converting from GstBuffer/GstEvent/GstCaps */
       
   171 #ifndef GST_DISABLE_DEPRECATED
       
   172 gboolean	gst_dp_header_from_buffer	(const GstBuffer * buffer,
       
   173 						GstDPHeaderFlag flags,
       
   174 						guint * length,
       
   175 						guint8 ** header);
       
   176 #endif
       
   177 #ifndef GST_DISABLE_DEPRECATED
       
   178 gboolean	gst_dp_packet_from_caps		(const GstCaps * caps,
       
   179 						GstDPHeaderFlag flags,
       
   180 						guint * length,
       
   181 						guint8 ** header,
       
   182 						guint8 ** payload);
       
   183 #endif
       
   184 #ifndef GST_DISABLE_DEPRECATED
       
   185 gboolean	gst_dp_packet_from_event	(const GstEvent * event,
       
   186 						GstDPHeaderFlag flags,
       
   187 						guint * length,
       
   188 						guint8 ** header,
       
   189 						guint8 ** payload);
       
   190 #endif
       
   191 /* converting to GstBuffer/GstEvent/GstCaps */
       
   192 #ifdef __SYMBIAN32__
       
   193 IMPORT_C
       
   194 #endif
       
   195 
       
   196 GstBuffer *	gst_dp_buffer_from_header	(guint header_length,
       
   197 						const guint8 * header);
       
   198 #ifdef __SYMBIAN32__
       
   199 IMPORT_C
       
   200 #endif
       
   201 
       
   202 GstCaps *	gst_dp_caps_from_packet		(guint header_length,
       
   203 						const guint8 * header,
       
   204 						const guint8 * payload);
       
   205 #ifdef __SYMBIAN32__
       
   206 IMPORT_C
       
   207 #endif
       
   208 
       
   209 GstEvent *	gst_dp_event_from_packet	(guint header_length,
       
   210 						const guint8 * header,
       
   211 						const guint8 * payload);
       
   212 
       
   213 /* validation */
       
   214 #ifdef __SYMBIAN32__
       
   215 IMPORT_C
       
   216 #endif
       
   217 
       
   218 gboolean	gst_dp_validate_header		(guint header_length,
       
   219 						const guint8 * header);
       
   220 #ifdef __SYMBIAN32__
       
   221 IMPORT_C
       
   222 #endif
       
   223 
       
   224 gboolean	gst_dp_validate_payload		(guint header_length,
       
   225 						const guint8 * header,
       
   226 						const guint8 * payload);
       
   227 #ifdef __SYMBIAN32__
       
   228 IMPORT_C
       
   229 #endif
       
   230 
       
   231 gboolean	gst_dp_validate_packet		(guint header_length,
       
   232 						const guint8 * header,
       
   233 						const guint8 * payload);
       
   234 
       
   235 G_END_DECLS
       
   236 
       
   237 #endif /* __GST_DATA_PROTOCOL_H__ */
       
   238