2 * Copyright (C) <2012> Wim Taymans <wim.taymans@gmail.com>
3 * Copyright (C) <2020> Matthew Waters <matthew@centricular.com>
5 * gstrtphdrext.h: RTP header extensions
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.
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.
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.
23 #ifndef __GST_RTPHDREXT_H__
24 #define __GST_RTPHDREXT_H__
27 #include <gst/rtp/gstrtpbuffer.h>
31 #define GST_RTP_HDREXT_BASE "urn:ietf:params:rtp-hdrext:"
34 #define GST_RTP_HDREXT_NTP_64 "ntp-64"
36 #define GST_RTP_HDREXT_NTP_64_SIZE 8
39 gboolean gst_rtp_hdrext_set_ntp_64 (gpointer data, guint size, guint64 ntptime);
42 gboolean gst_rtp_hdrext_get_ntp_64 (gpointer data, guint size, guint64 *ntptime);
44 #define GST_RTP_HDREXT_NTP_56 "ntp-56"
46 #define GST_RTP_HDREXT_NTP_56_SIZE 7
49 gboolean gst_rtp_hdrext_set_ntp_56 (gpointer data, guint size, guint64 ntptime);
52 gboolean gst_rtp_hdrext_get_ntp_56 (gpointer data, guint size, guint64 *ntptime);
55 * GST_RTP_HDREXT_ELEMENT_CLASS:
57 * Constant string used in element classification to signal that this element
58 * is a RTP header extension.
62 #define GST_RTP_HDREXT_ELEMENT_CLASS "Network/Extension/RTPHeader"
65 GType gst_rtp_header_extension_get_type (void);
66 #define GST_TYPE_RTP_HEADER_EXTENSION (gst_rtp_header_extension_get_type())
67 #define GST_RTP_HEADER_EXTENSION(obj) \
68 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtension))
69 #define GST_RTP_HEADER_EXTENSION_CLASS(klass) \
70 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtensionClass))
71 #define GST_RTP_HEADER_EXTENSION_GET_CLASS(obj) \
72 (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtensionClass))
73 #define GST_IS_RTP_HEADER_EXTENSION(obj) \
74 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_HEADER_EXTENSION))
75 #define GST_IS_RTP_HEADER_EXTENSION_CLASS(klass) \
76 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_HEADER_EXTENSION))
78 * GST_RTP_HEADER_EXTENSION_CAST:
82 #define GST_RTP_HEADER_EXTENSION_CAST(obj) ((GstRTPHeaderExtension *)(obj))
84 typedef struct _GstRTPHeaderExtension GstRTPHeaderExtension;
85 typedef struct _GstRTPHeaderExtensionClass GstRTPHeaderExtensionClass;
88 * GstRTPHeaderExtensionFlags:
89 * @GST_RTP_HEADER_EXTENSION_ONE_BYTE: The one byte rtp extension header.
90 * 1-16 data bytes per extension with a maximum of
91 * 14 extension ids in total.
92 * @GST_RTP_HEADER_EXTENSION_TWO_BYTE: The two byte rtp extension header.
93 * 256 data bytes per extension with a maximum of 255 (or 256
94 * including appbits) extensions in total.
96 * Flags that apply to a RTP Audio/Video header extension.
100 typedef enum /*< underscore_name=gst_rtp_header_extension_flags >*/
102 GST_RTP_HEADER_EXTENSION_ONE_BYTE = (1 << 0),
103 GST_RTP_HEADER_EXTENSION_TWO_BYTE = (1 << 1),
104 } GstRTPHeaderExtensionFlags;
107 * GstRTPHeaderExtensionDirection:
108 * @GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE: Neither send nor
109 * receive RTP Header Extensions
110 * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY: Only send RTP Header
111 * Extensions @GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY: Only
112 * receive RTP Header Extensions
113 * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV: Send and receive RTP
114 * Header Extensions ext
115 * @GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED: RTP header extension
116 * direction is inherited from the stream
118 * Direction to which to apply the RTP Header Extension
122 typedef enum /*< underscore_name=gst_rtp_header_extension_direction >*/
124 GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE = 0,
125 GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY = (1 << 0),
126 GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY = (1 << 1),
127 GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV = (
128 GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY |
129 GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY),
130 GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED = (1 << 2)
131 } GstRTPHeaderExtensionDirection;
134 * GstRTPHeaderExtension:
135 * @parent: the parent #GObject
136 * @ext_id: the configured extension id
138 * Instance struct for a RTP Audio/Video header extension.
142 struct _GstRTPHeaderExtension
147 gpointer _gst_reserved[GST_PADDING];
151 * GstRTPHeaderExtensionClass:
152 * @parent_class: the parent class
153 * @get_uri: retrieve the RTP extension uri
154 * @get_supported_flags: retrieve the supported flags
155 * @get_max_size: retrieve the maximum size for this extension based on the
156 * information available from input_meta. Implementations should attempt
157 * to provide as accurate information as possible as the returned value
158 * will be used to control the amount of possible data in the payload.
159 * Implementations must return the maximum as the allocated size for
160 * writing the extension will be at least the size of the returned value.
161 * Return the amount of data read or <0 on failure.
162 * @write: write into @data the information for this extension. Various
163 * information is provided to help writing extensions in particular cases.
164 * @read: read from a rtp payloaded buffer and extract the extension
165 * information, optionally adding some meta onto the output buffer.
166 * @set_non_rtp_sink_caps: read any information from sink caps that the header
167 * extension needs for its function.
168 * @update_non_rtp_src_caps: update depayloader non-RTP (depayloaded) caps with
169 * the information parsed from RTP header.
170 * @set_attributes: set the necessary attributes that may be signaled e.g. with
172 * @set_caps_from_attributes: write the necessary caps field/s for the configured
173 * attributes e.g. as signalled with SDP.
175 * Base class for RTP Header extensions.
180 struct _GstRTPHeaderExtensionClass
182 GstElementClass parent_class;
185 GstRTPHeaderExtensionFlags (*get_supported_flags) (GstRTPHeaderExtension * ext);
187 gsize (*get_max_size) (GstRTPHeaderExtension * ext,
188 const GstBuffer * input_meta);
190 gssize (*write) (GstRTPHeaderExtension * ext,
191 const GstBuffer * input_meta,
192 GstRTPHeaderExtensionFlags write_flags,
197 gboolean (*read) (GstRTPHeaderExtension * ext,
198 GstRTPHeaderExtensionFlags read_flags,
202 gboolean (*set_non_rtp_sink_caps) (GstRTPHeaderExtension * ext,
203 const GstCaps * caps);
204 gboolean (*update_non_rtp_src_caps) (GstRTPHeaderExtension * ext,
206 gboolean (*set_attributes) (GstRTPHeaderExtension * ext,
207 GstRTPHeaderExtensionDirection direction,
208 const gchar * attributes);
209 gboolean (*set_caps_from_attributes) (GstRTPHeaderExtension * ext,
213 gpointer _gst_reserved[GST_PADDING];
216 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPHeaderExtension, gst_object_unref)
219 * GST_RTP_HEADER_EXTENSION_URI_METADATA_KEY:
223 #define GST_RTP_HEADER_EXTENSION_URI_METADATA_KEY "RTP-Header-Extension-URI"
226 void gst_rtp_header_extension_class_set_uri (GstRTPHeaderExtensionClass *klass,
230 const gchar * gst_rtp_header_extension_get_uri (GstRTPHeaderExtension * ext);
232 gsize gst_rtp_header_extension_get_max_size (GstRTPHeaderExtension * ext,
233 const GstBuffer * input_meta);
235 GstRTPHeaderExtensionFlags gst_rtp_header_extension_get_supported_flags (GstRTPHeaderExtension * ext);
237 guint gst_rtp_header_extension_get_id (GstRTPHeaderExtension * ext);
239 void gst_rtp_header_extension_set_id (GstRTPHeaderExtension * ext,
242 gssize gst_rtp_header_extension_write (GstRTPHeaderExtension * ext,
243 const GstBuffer * input_meta,
244 GstRTPHeaderExtensionFlags write_flags,
249 gboolean gst_rtp_header_extension_read (GstRTPHeaderExtension * ext,
250 GstRTPHeaderExtensionFlags read_flags,
255 gboolean gst_rtp_header_extension_set_non_rtp_sink_caps (GstRTPHeaderExtension * ext,
256 const GstCaps * caps);
258 gboolean gst_rtp_header_extension_wants_update_non_rtp_src_caps (GstRTPHeaderExtension * ext);
260 void gst_rtp_header_extension_set_wants_update_non_rtp_src_caps (GstRTPHeaderExtension * ext,
263 gboolean gst_rtp_header_extension_update_non_rtp_src_caps (GstRTPHeaderExtension * ext,
266 gboolean gst_rtp_header_extension_set_caps_from_attributes (GstRTPHeaderExtension * ext,
269 gboolean gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext,
270 const GstCaps * caps);
273 GList * gst_rtp_get_header_extension_list (void);
275 GstRTPHeaderExtension * gst_rtp_header_extension_create_from_uri (const gchar * uri);
278 gchar * gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext);
281 void gst_rtp_header_extension_set_direction (GstRTPHeaderExtension * ext,
282 GstRTPHeaderExtensionDirection direction);
284 GstRTPHeaderExtensionDirection gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext);
287 gboolean gst_rtp_header_extension_set_caps_from_attributes_helper (GstRTPHeaderExtension * ext,
289 const gchar * attributes);
293 #endif /* __GST_RTPHDREXT_H__ */