diff options
author | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-08-03 21:02:36 +0300 |
commit | 5323a782c4e8c42781f22ce2f488962a18f82554 (patch) | |
tree | f71537197b16f0f8fd0d6937f7120d018d220814 /include/gst/rtp | |
parent | 50acf9d37183f86f6f623aad410003392b0af41f (diff) |
Jabber: initial version of Jingle support
Diffstat (limited to 'include/gst/rtp')
-rw-r--r-- | include/gst/rtp/gstrtcpbuffer.h | 671 | ||||
-rw-r--r-- | include/gst/rtp/gstrtp-enumtypes.h | 64 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpbaseaudiopayload.h | 124 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpbasedepayload.h | 135 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpbasepayload.h | 199 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpbuffer.h | 286 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpdefs.h | 58 | ||||
-rw-r--r-- | include/gst/rtp/gstrtphdrext.h | 294 | ||||
-rw-r--r-- | include/gst/rtp/gstrtpmeta.h | 79 | ||||
-rw-r--r-- | include/gst/rtp/gstrtppayloads.h | 199 | ||||
-rw-r--r-- | include/gst/rtp/rtp-prelude.h | 33 | ||||
-rw-r--r-- | include/gst/rtp/rtp.h | 36 |
12 files changed, 2178 insertions, 0 deletions
diff --git a/include/gst/rtp/gstrtcpbuffer.h b/include/gst/rtp/gstrtcpbuffer.h new file mode 100644 index 0000000000..b6410a5a1f --- /dev/null +++ b/include/gst/rtp/gstrtcpbuffer.h @@ -0,0 +1,671 @@ +/* GStreamer + * Copyright (C) <2007> Wim Taymans <wim@fluendo.com> + * + * gstrtcpbuffer.h: various helper functions to manipulate buffers + * with RTCP payload. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTCPBUFFER_H__ +#define __GST_RTCPBUFFER_H__ + +#include <gst/gst.h> +#include <gst/rtp/rtp-prelude.h> + +G_BEGIN_DECLS + +/** + * GST_RTCP_VERSION: + * + * The supported RTCP version 2. + */ +#define GST_RTCP_VERSION 2 + +/** + * GstRTCPType: + * @GST_RTCP_TYPE_INVALID: Invalid type + * @GST_RTCP_TYPE_SR: Sender report + * @GST_RTCP_TYPE_RR: Receiver report + * @GST_RTCP_TYPE_SDES: Source description + * @GST_RTCP_TYPE_BYE: Goodbye + * @GST_RTCP_TYPE_APP: Application defined + * @GST_RTCP_TYPE_RTPFB: Transport layer feedback. + * @GST_RTCP_TYPE_PSFB: Payload-specific feedback. + * @GST_RTCP_TYPE_XR: Extended report. + * + * Different RTCP packet types. + */ +typedef enum +{ + GST_RTCP_TYPE_INVALID = 0, + GST_RTCP_TYPE_SR = 200, + GST_RTCP_TYPE_RR = 201, + GST_RTCP_TYPE_SDES = 202, + GST_RTCP_TYPE_BYE = 203, + GST_RTCP_TYPE_APP = 204, + GST_RTCP_TYPE_RTPFB = 205, + GST_RTCP_TYPE_PSFB = 206, + GST_RTCP_TYPE_XR = 207 +} GstRTCPType; + +/* FIXME 2.0: backwards compatibility define for enum typo */ +#define GST_RTCP_RTPFB_TYPE_RCTP_SR_REQ GST_RTCP_RTPFB_TYPE_RTCP_SR_REQ + +/** + * GstRTCPFBType: + * @GST_RTCP_FB_TYPE_INVALID: Invalid type + * @GST_RTCP_RTPFB_TYPE_NACK: Generic NACK + * @GST_RTCP_RTPFB_TYPE_TMMBR: Temporary Maximum Media Stream Bit Rate Request + * @GST_RTCP_RTPFB_TYPE_TMMBN: Temporary Maximum Media Stream Bit Rate + * Notification + * @GST_RTCP_RTPFB_TYPE_RTCP_SR_REQ: Request an SR packet for early + * synchronization + * @GST_RTCP_PSFB_TYPE_PLI: Picture Loss Indication + * @GST_RTCP_PSFB_TYPE_SLI: Slice Loss Indication + * @GST_RTCP_PSFB_TYPE_RPSI: Reference Picture Selection Indication + * @GST_RTCP_PSFB_TYPE_AFB: Application layer Feedback + * @GST_RTCP_PSFB_TYPE_FIR: Full Intra Request Command + * @GST_RTCP_PSFB_TYPE_TSTR: Temporal-Spatial Trade-off Request + * @GST_RTCP_PSFB_TYPE_TSTN: Temporal-Spatial Trade-off Notification + * @GST_RTCP_PSFB_TYPE_VBCN: Video Back Channel Message + * + * Different types of feedback messages. + */ +typedef enum +{ + /* generic */ + GST_RTCP_FB_TYPE_INVALID = 0, + /* RTPFB types */ + GST_RTCP_RTPFB_TYPE_NACK = 1, + /* RTPFB types assigned in RFC 5104 */ + GST_RTCP_RTPFB_TYPE_TMMBR = 3, + GST_RTCP_RTPFB_TYPE_TMMBN = 4, + /* RTPFB types assigned in RFC 6051 */ + GST_RTCP_RTPFB_TYPE_RTCP_SR_REQ = 5, + /* draft-holmer-rmcat-transport-wide-cc-extensions-01 */ + GST_RTCP_RTPFB_TYPE_TWCC = 15, + + /* PSFB types */ + GST_RTCP_PSFB_TYPE_PLI = 1, + GST_RTCP_PSFB_TYPE_SLI = 2, + GST_RTCP_PSFB_TYPE_RPSI = 3, + GST_RTCP_PSFB_TYPE_AFB = 15, + /* PSFB types assigned in RFC 5104 */ + GST_RTCP_PSFB_TYPE_FIR = 4, + GST_RTCP_PSFB_TYPE_TSTR = 5, + GST_RTCP_PSFB_TYPE_TSTN = 6, + GST_RTCP_PSFB_TYPE_VBCN = 7, +} GstRTCPFBType; + +/** + * GstRTCPSDESType: + * @GST_RTCP_SDES_INVALID: Invalid SDES entry + * @GST_RTCP_SDES_END: End of SDES list + * @GST_RTCP_SDES_CNAME: Canonical name + * @GST_RTCP_SDES_NAME: User name + * @GST_RTCP_SDES_EMAIL: User's electronic mail address + * @GST_RTCP_SDES_PHONE: User's phone number + * @GST_RTCP_SDES_LOC: Geographic user location + * @GST_RTCP_SDES_TOOL: Name of application or tool + * @GST_RTCP_SDES_NOTE: Notice about the source + * @GST_RTCP_SDES_PRIV: Private extensions + * + * Different types of SDES content. + */ +/** + * GST_RTCP_SDES_H323_CADDR: + * + * H.323 callable address + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_APSI: + * + * Application Specific Identifier (RFC6776) + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_RGRP: + * + * Reporting Group Identifier (RFC8861) + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_RTP_STREAM_ID: + * + * RtpStreamId SDES item (RFC8852). + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_REPAIRED_RTP_STREAM_ID: + * + * RepairedRtpStreamId SDES item (RFC8852). + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_CCID: + * + * CLUE CaptId (RFC8849) + * + * Since: 1.20: + */ +/** + * GST_RTCP_SDES_MID: + * + * MID SDES item (RFC8843). + * + * Since: 1.20: + */ +typedef enum +{ + GST_RTCP_SDES_INVALID = -1, + GST_RTCP_SDES_END = 0, + GST_RTCP_SDES_CNAME = 1, + GST_RTCP_SDES_NAME = 2, + GST_RTCP_SDES_EMAIL = 3, + GST_RTCP_SDES_PHONE = 4, + GST_RTCP_SDES_LOC = 5, + GST_RTCP_SDES_TOOL = 6, + GST_RTCP_SDES_NOTE = 7, + GST_RTCP_SDES_PRIV = 8, + GST_RTCP_SDES_H323_CADDR = 9, + GST_RTCP_SDES_APSI = 10, + GST_RTCP_SDES_RGRP = 11, + GST_RTCP_SDES_RTP_STREAM_ID = 12, + GST_RTCP_SDES_REPAIRED_RTP_STREAM_ID = 13, + GST_RTCP_SDES_CCID = 14, + GST_RTCP_SDES_MID = 15, +} GstRTCPSDESType; + +/** + * GstRTCPXRType: + * @GST_RTCP_XR_TYPE_INVALID: Invalid XR Report Block + * @GST_RTCP_XR_TYPE_LRLE: Loss RLE Report Block + * @GST_RTCP_XR_TYPE_DRLE: Duplicate RLE Report Block + * @GST_RTCP_XR_TYPE_PRT: Packet Receipt Times Report Block + * @GST_RTCP_XR_TYPE_RRT: Receiver Reference Time Report Block + * @GST_RTCP_XR_TYPE_DLRR: Delay since the last Receiver Report + * @GST_RTCP_XR_TYPE_SSUMM: Statistics Summary Report Block + * @GST_RTCP_XR_TYPE_VOIP_METRICS: VoIP Metrics Report Block + * + * Types of RTCP Extended Reports, those are defined in RFC 3611 and other RFCs + * according to the [IANA registry](https://www.iana.org/assignments/rtcp-xr-block-types/rtcp-xr-block-types.xhtml). + * + * Since: 1.16 + */ +typedef enum +{ + GST_RTCP_XR_TYPE_INVALID = -1, + GST_RTCP_XR_TYPE_LRLE = 1, + GST_RTCP_XR_TYPE_DRLE = 2, + GST_RTCP_XR_TYPE_PRT = 3, + GST_RTCP_XR_TYPE_RRT = 4, + GST_RTCP_XR_TYPE_DLRR = 5, + GST_RTCP_XR_TYPE_SSUMM = 6, + GST_RTCP_XR_TYPE_VOIP_METRICS = 7 +} GstRTCPXRType; + +/** + * GST_RTCP_MAX_SDES: + * + * The maximum text length for an SDES item. + */ +#define GST_RTCP_MAX_SDES 255 + +/** + * GST_RTCP_MAX_RB_COUNT: + * + * The maximum amount of Receiver report blocks in RR and SR messages. + */ +#define GST_RTCP_MAX_RB_COUNT 31 + +/** + * GST_RTCP_MAX_SDES_ITEM_COUNT: + * + * The maximum amount of SDES items. + */ +#define GST_RTCP_MAX_SDES_ITEM_COUNT 31 + +/** + * GST_RTCP_MAX_BYE_SSRC_COUNT: + * + * The maximum amount of SSRCs in a BYE packet. + */ +#define GST_RTCP_MAX_BYE_SSRC_COUNT 31 + +/** + * GST_RTCP_VALID_MASK: + * + * Mask for version, padding bit and packet type pair + */ +#define GST_RTCP_VALID_MASK (0xc000 | 0x2000 | 0xfe) + +/** + * GST_RTCP_REDUCED_SIZE_VALID_MASK: + * + * Mask for version and packet type pair allowing reduced size + * packets, basically it accepts other types than RR and SR + */ +#define GST_RTCP_REDUCED_SIZE_VALID_MASK (0xc000 | 0xf8) + +/** + * GST_RTCP_VALID_VALUE: + * + * Valid value for the first two bytes of an RTCP packet after applying + * #GST_RTCP_VALID_MASK to them. + */ +#define GST_RTCP_VALID_VALUE ((GST_RTCP_VERSION << 14) | GST_RTCP_TYPE_SR) + +typedef struct _GstRTCPBuffer GstRTCPBuffer; +typedef struct _GstRTCPPacket GstRTCPPacket; + +struct _GstRTCPBuffer +{ + GstBuffer *buffer; + GstMapInfo map; +}; + +#define GST_RTCP_BUFFER_INIT { NULL, GST_MAP_INFO_INIT } + +/** + * GstRTCPPacket: + * @rtcp: pointer to RTCP buffer + * @offset: offset of packet in buffer data + * + * Data structure that points to a packet at @offset in @buffer. + * The size of the structure is made public to allow stack allocations. + */ +struct _GstRTCPPacket +{ + /*< public >*/ + GstRTCPBuffer *rtcp; + guint offset; + + /*< private >*/ + gboolean padding; /* padding field of current packet */ + guint8 count; /* count field of current packet */ + GstRTCPType type; /* type of current packet */ + guint16 length; /* length of current packet in 32-bits words minus one, this is validated when doing _get_first_packet() and _move_to_next() */ + + guint item_offset; /* current item offset for navigating SDES */ + guint item_count; /* current item count */ + guint entry_offset; /* current entry offset for navigating SDES items */ +}; + +/* creating buffers */ + +GST_RTP_API +GstBuffer* gst_rtcp_buffer_new_take_data (gpointer data, guint len); + +GST_RTP_API +GstBuffer* gst_rtcp_buffer_new_copy_data (gconstpointer data, guint len); + +GST_RTP_API +gboolean gst_rtcp_buffer_validate_data (guint8 *data, guint len); + +GST_RTP_API +gboolean gst_rtcp_buffer_validate (GstBuffer *buffer); + +GST_RTP_API +gboolean gst_rtcp_buffer_validate_data_reduced (guint8 *data, guint len); + +GST_RTP_API +gboolean gst_rtcp_buffer_validate_reduced (GstBuffer *buffer); + + +GST_RTP_API +GstBuffer* gst_rtcp_buffer_new (guint mtu); + +GST_RTP_API +gboolean gst_rtcp_buffer_map (GstBuffer *buffer, GstMapFlags flags, GstRTCPBuffer *rtcp); + +GST_RTP_API +gboolean gst_rtcp_buffer_unmap (GstRTCPBuffer *rtcp); + +/* adding/retrieving packets */ + +GST_RTP_API +guint gst_rtcp_buffer_get_packet_count (GstRTCPBuffer *rtcp); + +GST_RTP_API +gboolean gst_rtcp_buffer_get_first_packet (GstRTCPBuffer *rtcp, GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_move_to_next (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_buffer_add_packet (GstRTCPBuffer *rtcp, GstRTCPType type, + GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_remove (GstRTCPPacket *packet); + +/* working with packets */ + +GST_RTP_API +gboolean gst_rtcp_packet_get_padding (GstRTCPPacket *packet); + +GST_RTP_API +guint8 gst_rtcp_packet_get_count (GstRTCPPacket *packet); + +GST_RTP_API +GstRTCPType gst_rtcp_packet_get_type (GstRTCPPacket *packet); + +GST_RTP_API +guint16 gst_rtcp_packet_get_length (GstRTCPPacket *packet); + + +/* sender reports */ + +GST_RTP_API +void gst_rtcp_packet_sr_get_sender_info (GstRTCPPacket *packet, guint32 *ssrc, + guint64 *ntptime, guint32 *rtptime, + guint32 *packet_count, guint32 *octet_count); + +GST_RTP_API +void gst_rtcp_packet_sr_set_sender_info (GstRTCPPacket *packet, guint32 ssrc, + guint64 ntptime, guint32 rtptime, + guint32 packet_count, guint32 octet_count); +/* receiver reports */ + +GST_RTP_API +guint32 gst_rtcp_packet_rr_get_ssrc (GstRTCPPacket *packet); + +GST_RTP_API +void gst_rtcp_packet_rr_set_ssrc (GstRTCPPacket *packet, guint32 ssrc); + + +/* report blocks for SR and RR */ + +GST_RTP_API +guint gst_rtcp_packet_get_rb_count (GstRTCPPacket *packet); + +GST_RTP_API +void gst_rtcp_packet_get_rb (GstRTCPPacket *packet, guint nth, guint32 *ssrc, + guint8 *fractionlost, gint32 *packetslost, + guint32 *exthighestseq, guint32 *jitter, + guint32 *lsr, guint32 *dlsr); + +GST_RTP_API +gboolean gst_rtcp_packet_add_rb (GstRTCPPacket *packet, guint32 ssrc, + guint8 fractionlost, gint32 packetslost, + guint32 exthighestseq, guint32 jitter, + guint32 lsr, guint32 dlsr); + +GST_RTP_API +void gst_rtcp_packet_set_rb (GstRTCPPacket *packet, guint nth, guint32 ssrc, + guint8 fractionlost, gint32 packetslost, + guint32 exthighestseq, guint32 jitter, + guint32 lsr, guint32 dlsr); + +/* profile-specific extensions for SR and RR */ + +GST_RTP_API +gboolean gst_rtcp_packet_add_profile_specific_ext (GstRTCPPacket * packet, + const guint8 * data, guint len); + +GST_RTP_API +guint16 gst_rtcp_packet_get_profile_specific_ext_length (GstRTCPPacket * packet); + +GST_RTP_API +gboolean gst_rtcp_packet_get_profile_specific_ext (GstRTCPPacket * packet, + guint8 ** data, guint * len); + +GST_RTP_API +gboolean gst_rtcp_packet_copy_profile_specific_ext (GstRTCPPacket * packet, + guint8 ** data, guint * len); + +/* source description packet */ + +GST_RTP_API +guint gst_rtcp_packet_sdes_get_item_count (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_first_item (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_next_item (GstRTCPPacket *packet); + +GST_RTP_API +guint32 gst_rtcp_packet_sdes_get_ssrc (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_first_entry (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_next_entry (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_get_entry (GstRTCPPacket *packet, + GstRTCPSDESType *type, guint8 *len, + guint8 **data); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_copy_entry (GstRTCPPacket *packet, + GstRTCPSDESType *type, guint8 *len, + guint8 **data); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_add_item (GstRTCPPacket *packet, guint32 ssrc); + +GST_RTP_API +gboolean gst_rtcp_packet_sdes_add_entry (GstRTCPPacket *packet, GstRTCPSDESType type, + guint8 len, const guint8 *data); + +/* bye packet */ + +GST_RTP_API +guint gst_rtcp_packet_bye_get_ssrc_count (GstRTCPPacket *packet); + +GST_RTP_API +guint32 gst_rtcp_packet_bye_get_nth_ssrc (GstRTCPPacket *packet, guint nth); + +GST_RTP_API +gboolean gst_rtcp_packet_bye_add_ssrc (GstRTCPPacket *packet, guint32 ssrc); + +GST_RTP_API +gboolean gst_rtcp_packet_bye_add_ssrcs (GstRTCPPacket *packet, guint32 *ssrc, guint len); + +GST_RTP_API +guint8 gst_rtcp_packet_bye_get_reason_len (GstRTCPPacket *packet); + +GST_RTP_API +gchar* gst_rtcp_packet_bye_get_reason (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_bye_set_reason (GstRTCPPacket *packet, const gchar *reason); + +/* app packets */ + +GST_RTP_API +void gst_rtcp_packet_app_set_subtype (GstRTCPPacket * packet, guint8 subtype); + +GST_RTP_API +guint8 gst_rtcp_packet_app_get_subtype (GstRTCPPacket * packet); + +GST_RTP_API +void gst_rtcp_packet_app_set_ssrc (GstRTCPPacket * packet, guint32 ssrc); + +GST_RTP_API +guint32 gst_rtcp_packet_app_get_ssrc (GstRTCPPacket * packet); + +GST_RTP_API +void gst_rtcp_packet_app_set_name (GstRTCPPacket * packet, const gchar *name); + +GST_RTP_API +const gchar* gst_rtcp_packet_app_get_name (GstRTCPPacket * packet); + +GST_RTP_API +guint16 gst_rtcp_packet_app_get_data_length (GstRTCPPacket * packet); + +GST_RTP_API +gboolean gst_rtcp_packet_app_set_data_length (GstRTCPPacket * packet, guint16 wordlen); + +GST_RTP_API +guint8* gst_rtcp_packet_app_get_data (GstRTCPPacket * packet); + +/* feedback packets */ + +GST_RTP_API +guint32 gst_rtcp_packet_fb_get_sender_ssrc (GstRTCPPacket *packet); + +GST_RTP_API +void gst_rtcp_packet_fb_set_sender_ssrc (GstRTCPPacket *packet, guint32 ssrc); + +GST_RTP_API +guint32 gst_rtcp_packet_fb_get_media_ssrc (GstRTCPPacket *packet); + +GST_RTP_API +void gst_rtcp_packet_fb_set_media_ssrc (GstRTCPPacket *packet, guint32 ssrc); + +GST_RTP_API +GstRTCPFBType gst_rtcp_packet_fb_get_type (GstRTCPPacket *packet); + +GST_RTP_API +void gst_rtcp_packet_fb_set_type (GstRTCPPacket *packet, GstRTCPFBType type); + +GST_RTP_API +guint16 gst_rtcp_packet_fb_get_fci_length (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_fb_set_fci_length (GstRTCPPacket *packet, guint16 wordlen); + +GST_RTP_API +guint8 * gst_rtcp_packet_fb_get_fci (GstRTCPPacket *packet); + +/* helper functions */ + +GST_RTP_API +guint64 gst_rtcp_ntp_to_unix (guint64 ntptime); + +GST_RTP_API +guint64 gst_rtcp_unix_to_ntp (guint64 unixtime); + +GST_RTP_API +const gchar * gst_rtcp_sdes_type_to_name (GstRTCPSDESType type); + +GST_RTP_API +GstRTCPSDESType gst_rtcp_sdes_name_to_type (const gchar *name); + +/* extended report */ + +GST_RTP_API +guint32 gst_rtcp_packet_xr_get_ssrc (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_first_rb (GstRTCPPacket *packet); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_next_rb (GstRTCPPacket * packet); + +GST_RTP_API +GstRTCPXRType gst_rtcp_packet_xr_get_block_type (GstRTCPPacket * packet); + +GST_RTP_API +guint16 gst_rtcp_packet_xr_get_block_length (GstRTCPPacket * packet); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_rle_info (GstRTCPPacket * packet, + guint32 * ssrc, guint8 * thinning, + guint16 * begin_seq, guint16 * end_seq, + guint32 * chunk_count); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_rle_nth_chunk (GstRTCPPacket * packet, guint nth, + guint16 * chunk); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_prt_info (GstRTCPPacket * packet, + guint32 * ssrc, guint8 * thinning, + guint16 * begin_seq, guint16 * end_seq); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_prt_by_seq (GstRTCPPacket * packet, guint16 seq, + guint32 * receipt_time); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_rrt (GstRTCPPacket * packet, guint64 * timestamp); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_dlrr_block (GstRTCPPacket * packet, + guint nth, guint32 * ssrc, + guint32 * last_rr, guint32 * delay); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_summary_info (GstRTCPPacket * packet, guint32 * ssrc, + guint16 * begin_seq, guint16 * end_seq); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_summary_pkt (GstRTCPPacket * packet, + guint32 * lost_packets, guint32 * dup_packets); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_summary_jitter (GstRTCPPacket * packet, + guint32 * min_jitter, guint32 * max_jitter, + guint32 * mean_jitter, guint32 * dev_jitter); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_summary_ttl (GstRTCPPacket * packet, gboolean * is_ipv4, + guint8 * min_ttl, guint8 * max_ttl, + guint8 * mean_ttl, guint8 * dev_ttl); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_metrics_ssrc (GstRTCPPacket * packet, guint32 * ssrc); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_packet_metrics (GstRTCPPacket * packet, + guint8 * loss_rate, guint8 * discard_rate); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_burst_metrics (GstRTCPPacket * packet, + guint8 * burst_density, guint8 * gap_density, + guint16 * burst_duration, guint16 * gap_duration); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_delay_metrics (GstRTCPPacket * packet, + guint16 * roundtrip_delay, + guint16 * end_system_delay); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_signal_metrics (GstRTCPPacket * packet, + guint8 * signal_level, guint8 * noise_level, + guint8 * rerl, guint8 * gmin); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_quality_metrics (GstRTCPPacket * packet, + guint8 * r_factor, guint8 * ext_r_factor, + guint8 * mos_lq, guint8 * mos_cq); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_configuration_params (GstRTCPPacket * packet, + guint8 * gmin, guint8 * rx_config); + +GST_RTP_API +gboolean gst_rtcp_packet_xr_get_voip_jitter_buffer_params (GstRTCPPacket * packet, + guint16 * jb_nominal, + guint16 * jb_maximum, + guint16 * jb_abs_max); + +G_END_DECLS + +#endif /* __GST_RTCPBUFFER_H__ */ + diff --git a/include/gst/rtp/gstrtp-enumtypes.h b/include/gst/rtp/gstrtp-enumtypes.h new file mode 100644 index 0000000000..1cb86d4825 --- /dev/null +++ b/include/gst/rtp/gstrtp-enumtypes.h @@ -0,0 +1,64 @@ + +/* This file is generated by glib-mkenums, do not modify it. This code is licensed under the same license as the containing project. Note that it links to GLib, so must comply with the LGPL linking clauses. */ + +#pragma once + + #include <glib-object.h> + #include <gst/rtp/rtp-prelude.h> + + G_BEGIN_DECLS + +/* enumerations from "gstrtcpbuffer.h" */ + +GST_RTP_API +GType gst_rtcp_type_get_type (void); +#define GST_TYPE_RTCP_TYPE (gst_rtcp_type_get_type()) + +GST_RTP_API +GType gst_rtcpfb_type_get_type (void); +#define GST_TYPE_RTCPFB_TYPE (gst_rtcpfb_type_get_type()) + +GST_RTP_API +GType gst_rtcpsdes_type_get_type (void); +#define GST_TYPE_RTCPSDES_TYPE (gst_rtcpsdes_type_get_type()) + +GST_RTP_API +GType gst_rtcpxr_type_get_type (void); +#define GST_TYPE_RTCPXR_TYPE (gst_rtcpxr_type_get_type()) + +/* enumerations from "gstrtpbuffer.h" */ + +GST_RTP_API +GType gst_rtp_buffer_flags_get_type (void); +#define GST_TYPE_RTP_BUFFER_FLAGS (gst_rtp_buffer_flags_get_type()) + +GST_RTP_API +GType gst_rtp_buffer_map_flags_get_type (void); +#define GST_TYPE_RTP_BUFFER_MAP_FLAGS (gst_rtp_buffer_map_flags_get_type()) + +/* enumerations from "gstrtpdefs.h" */ + +GST_RTP_API +GType gst_rtp_profile_get_type (void); +#define GST_TYPE_RTP_PROFILE (gst_rtp_profile_get_type()) + +/* enumerations from "gstrtphdrext.h" */ + +GST_RTP_API +GType gst_rtp_header_extension_flags_get_type (void); +#define GST_TYPE_RTP_HEADER_EXTENSION_FLAGS (gst_rtp_header_extension_flags_get_type()) + +GST_RTP_API +GType gst_rtp_header_extension_direction_get_type (void); +#define GST_TYPE_RTP_HEADER_EXTENSION_DIRECTION (gst_rtp_header_extension_direction_get_type()) + +/* enumerations from "gstrtppayloads.h" */ + +GST_RTP_API +GType gst_rtp_payload_get_type (void); +#define GST_TYPE_RTP_PAYLOAD (gst_rtp_payload_get_type()) + +G_END_DECLS + +/* Generated data ends here */ + diff --git a/include/gst/rtp/gstrtpbaseaudiopayload.h b/include/gst/rtp/gstrtpbaseaudiopayload.h new file mode 100644 index 0000000000..773a49caba --- /dev/null +++ b/include/gst/rtp/gstrtpbaseaudiopayload.h @@ -0,0 +1,124 @@ +/* GStreamer + * Copyright (C) <2006> Philippe Khalaf <philippe.kalaf@collabora.co.uk> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_BASE_AUDIO_PAYLOAD_H__ +#define __GST_RTP_BASE_AUDIO_PAYLOAD_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtpbasepayload.h> +#include <gst/base/gstadapter.h> + +G_BEGIN_DECLS + +typedef struct _GstRTPBaseAudioPayload GstRTPBaseAudioPayload; +typedef struct _GstRTPBaseAudioPayloadClass GstRTPBaseAudioPayloadClass; + +typedef struct _GstRTPBaseAudioPayloadPrivate GstRTPBaseAudioPayloadPrivate; + +#define GST_TYPE_RTP_BASE_AUDIO_PAYLOAD \ + (gst_rtp_base_audio_payload_get_type()) +#define GST_RTP_BASE_AUDIO_PAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj), \ + GST_TYPE_RTP_BASE_AUDIO_PAYLOAD,GstRTPBaseAudioPayload)) +#define GST_RTP_BASE_AUDIO_PAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass), \ + GST_TYPE_RTP_BASE_AUDIO_PAYLOAD,GstRTPBaseAudioPayloadClass)) +#define GST_IS_RTP_BASE_AUDIO_PAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_BASE_AUDIO_PAYLOAD)) +#define GST_IS_RTP_BASE_AUDIO_PAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_BASE_AUDIO_PAYLOAD)) +#define GST_RTP_BASE_AUDIO_PAYLOAD_CAST(obj) \ + ((GstRTPBaseAudioPayload *) (obj)) + +struct _GstRTPBaseAudioPayload +{ + GstRTPBasePayload payload; + + GstRTPBaseAudioPayloadPrivate *priv; + + GstClockTime base_ts; + gint frame_size; + gint frame_duration; + + gint sample_size; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTPBaseAudioPayloadClass: + * @parent_class: the parent class + * + * Base class for audio RTP payloader. + */ +struct _GstRTPBaseAudioPayloadClass +{ + GstRTPBasePayloadClass parent_class; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTP_API +GType gst_rtp_base_audio_payload_get_type (void); + +/* configure frame based */ + +GST_RTP_API +void gst_rtp_base_audio_payload_set_frame_based (GstRTPBaseAudioPayload *rtpbaseaudiopayload); + +GST_RTP_API +void gst_rtp_base_audio_payload_set_frame_options (GstRTPBaseAudioPayload *rtpbaseaudiopayload, + gint frame_duration, gint frame_size); + +/* configure sample based */ + +GST_RTP_API +void gst_rtp_base_audio_payload_set_sample_based (GstRTPBaseAudioPayload *rtpbaseaudiopayload); + +GST_RTP_API +void gst_rtp_base_audio_payload_set_sample_options (GstRTPBaseAudioPayload *rtpbaseaudiopayload, + gint sample_size); + +GST_RTP_API +void gst_rtp_base_audio_payload_set_samplebits_options (GstRTPBaseAudioPayload *rtpbaseaudiopayload, + gint sample_size); + +/* get the internal adapter */ + +GST_RTP_API +GstAdapter* gst_rtp_base_audio_payload_get_adapter (GstRTPBaseAudioPayload *rtpbaseaudiopayload); + +/* push and flushing data */ + +GST_RTP_API +GstFlowReturn gst_rtp_base_audio_payload_push (GstRTPBaseAudioPayload * baseaudiopayload, + const guint8 * data, guint payload_len, + GstClockTime timestamp); + +GST_RTP_API +GstFlowReturn gst_rtp_base_audio_payload_flush (GstRTPBaseAudioPayload * baseaudiopayload, + guint payload_len, GstClockTime timestamp); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBaseAudioPayload, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_RTP_BASE_AUDIO_PAYLOAD_H__ */ diff --git a/include/gst/rtp/gstrtpbasedepayload.h b/include/gst/rtp/gstrtpbasedepayload.h new file mode 100644 index 0000000000..341a61551c --- /dev/null +++ b/include/gst/rtp/gstrtpbasedepayload.h @@ -0,0 +1,135 @@ +/* GStreamer + * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_BASE_DEPAYLOAD_H__ +#define __GST_RTP_BASE_DEPAYLOAD_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtpbuffer.h> + +G_BEGIN_DECLS + +#define GST_TYPE_RTP_BASE_DEPAYLOAD (gst_rtp_base_depayload_get_type()) +#define GST_RTP_BASE_DEPAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayload)) +#define GST_RTP_BASE_DEPAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayloadClass)) +#define GST_RTP_BASE_DEPAYLOAD_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_RTP_BASE_DEPAYLOAD,GstRTPBaseDepayloadClass)) +#define GST_IS_RTP_BASE_DEPAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_BASE_DEPAYLOAD)) +#define GST_IS_RTP_BASE_DEPAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_BASE_DEPAYLOAD)) +#define GST_RTP_BASE_DEPAYLOAD_CAST(obj) ((GstRTPBaseDepayload *)(obj)) + +#define GST_RTP_BASE_DEPAYLOAD_SINKPAD(depayload) (GST_RTP_BASE_DEPAYLOAD_CAST (depayload)->sinkpad) +#define GST_RTP_BASE_DEPAYLOAD_SRCPAD(depayload) (GST_RTP_BASE_DEPAYLOAD_CAST (depayload)->srcpad) + +typedef struct _GstRTPBaseDepayload GstRTPBaseDepayload; +typedef struct _GstRTPBaseDepayloadClass GstRTPBaseDepayloadClass; +typedef struct _GstRTPBaseDepayloadPrivate GstRTPBaseDepayloadPrivate; + +struct _GstRTPBaseDepayload +{ + GstElement parent; + + GstPad *sinkpad, *srcpad; + + /* this attribute must be set by the child */ + guint clock_rate; + + GstSegment segment; + gboolean need_newsegment; + + /*< private >*/ + GstRTPBaseDepayloadPrivate *priv; + + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTPBaseDepayloadClass: + * @parent_class: the parent class + * @set_caps: configure the depayloader + * @process: process incoming rtp packets. Subclass must implement either + * this method or @process_rtp_packet to process incoming rtp packets. + * If the child returns a buffer without a valid timestamp, the timestamp + * of the provided buffer will be applied to the result buffer and the + * buffer will be pushed. If this function returns %NULL, nothing is pushed. + * @packet_lost: signal the depayloader about packet loss + * @handle_event: custom event handling + * @process_rtp_packet: Same as the process virtual function, but slightly more + * efficient, since it is passed the rtp buffer structure that has already + * been mapped (with GST_MAP_READ) by the base class and thus does not have + * to be mapped again by the subclass. Can be used by the subclass to process + * incoming rtp packets. If the subclass returns a buffer without a valid + * timestamp, the timestamp of the input buffer will be applied to the result + * buffer and the output buffer will be pushed out. If this function returns + * %NULL, nothing is pushed out. Since: 1.6. + * + * Base class for RTP depayloaders. + */ +struct _GstRTPBaseDepayloadClass +{ + GstElementClass parent_class; + + /*< public >*/ + /* virtuals, inform the subclass of the caps. */ + gboolean (*set_caps) (GstRTPBaseDepayload *filter, GstCaps *caps); + + /* pure virtual function */ + GstBuffer * (*process) (GstRTPBaseDepayload *base, GstBuffer *in); + + /* non-pure function used to to signal the depayloader about packet loss. the + * timestamp and duration are the estimated values of the lost packet. + * The default implementation of this message pushes a segment update. */ + gboolean (*packet_lost) (GstRTPBaseDepayload *filter, GstEvent *event); + + /* the default implementation does the default actions for events but + * implementation can override. */ + gboolean (*handle_event) (GstRTPBaseDepayload * filter, GstEvent * event); + + GstBuffer * (*process_rtp_packet) (GstRTPBaseDepayload *base, GstRTPBuffer * rtp_buffer); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING - 1]; +}; + +GST_RTP_API +GType gst_rtp_base_depayload_get_type (void); + +GST_RTP_API +GstFlowReturn gst_rtp_base_depayload_push (GstRTPBaseDepayload *filter, GstBuffer *out_buf); + +GST_RTP_API +GstFlowReturn gst_rtp_base_depayload_push_list (GstRTPBaseDepayload *filter, GstBufferList *out_list); + +GST_RTP_API +gboolean gst_rtp_base_depayload_is_source_info_enabled (GstRTPBaseDepayload * depayload); + +GST_RTP_API +void gst_rtp_base_depayload_set_source_info_enabled (GstRTPBaseDepayload * depayload, + gboolean enable); + + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBaseDepayload, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_RTP_BASE_DEPAYLOAD_H__ */ diff --git a/include/gst/rtp/gstrtpbasepayload.h b/include/gst/rtp/gstrtpbasepayload.h new file mode 100644 index 0000000000..00bf99e196 --- /dev/null +++ b/include/gst/rtp/gstrtpbasepayload.h @@ -0,0 +1,199 @@ +/* GStreamer + * Copyright (C) <2005> Wim Taymans <wim@fluendo.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_BASE_PAYLOAD_H__ +#define __GST_RTP_BASE_PAYLOAD_H__ + +#include <gst/gst.h> +#include <gst/rtp/rtp-prelude.h> + +G_BEGIN_DECLS + +#define GST_TYPE_RTP_BASE_PAYLOAD \ + (gst_rtp_base_payload_get_type()) +#define GST_RTP_BASE_PAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_BASE_PAYLOAD,GstRTPBasePayload)) +#define GST_RTP_BASE_PAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_BASE_PAYLOAD,GstRTPBasePayloadClass)) +#define GST_RTP_BASE_PAYLOAD_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_RTP_BASE_PAYLOAD, GstRTPBasePayloadClass)) +#define GST_IS_RTP_BASE_PAYLOAD(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_BASE_PAYLOAD)) +#define GST_IS_RTP_BASE_PAYLOAD_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_BASE_PAYLOAD)) +#define GST_RTP_BASE_PAYLOAD_CAST(obj) \ + ((GstRTPBasePayload*)(obj)) + +typedef struct _GstRTPBasePayload GstRTPBasePayload; +typedef struct _GstRTPBasePayloadPrivate GstRTPBasePayloadPrivate; +typedef struct _GstRTPBasePayloadClass GstRTPBasePayloadClass; + +/** + * GST_RTP_BASE_PAYLOAD_SINKPAD: + * @payload: a #GstRTPBasePayload + * + * Get access to the sinkpad of @payload. + */ +#define GST_RTP_BASE_PAYLOAD_SINKPAD(payload) (GST_RTP_BASE_PAYLOAD (payload)->sinkpad) +/** + * GST_RTP_BASE_PAYLOAD_SRCPAD: + * @payload: a #GstRTPBasePayload + * + * Get access to the srcpad of @payload. + */ +#define GST_RTP_BASE_PAYLOAD_SRCPAD(payload) (GST_RTP_BASE_PAYLOAD (payload)->srcpad) + +/** + * GST_RTP_BASE_PAYLOAD_PT: + * @payload: a #GstRTPBasePayload + * + * Get access to the configured payload type of @payload. + */ +#define GST_RTP_BASE_PAYLOAD_PT(payload) (GST_RTP_BASE_PAYLOAD (payload)->pt) +/** + * GST_RTP_BASE_PAYLOAD_MTU: + * @payload: a #GstRTPBasePayload + * + * Get access to the configured MTU of @payload. + */ +#define GST_RTP_BASE_PAYLOAD_MTU(payload) (GST_RTP_BASE_PAYLOAD (payload)->mtu) + +struct _GstRTPBasePayload +{ + GstElement element; + + /*< private >*/ + GstPad *sinkpad; + GstPad *srcpad; + + guint32 ts_base; + guint16 seqnum_base; + + gchar *media; + gchar *encoding_name; + gboolean dynamic; + guint32 clock_rate; + + gint32 ts_offset; + guint32 timestamp; + gint16 seqnum_offset; + guint16 seqnum; + gint64 max_ptime; + guint pt; + guint ssrc; + guint current_ssrc; + guint mtu; + + GstSegment segment; + + guint64 min_ptime; + guint64 ptime; /* in ns */ + guint64 ptime_multiple; /* in ns */ + + /*< private >*/ + GstRTPBasePayloadPrivate *priv; + + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTPBasePayloadClass: + * @parent_class: the parent class + * @get_caps: get desired caps + * @set_caps: configure the payloader + * @handle_buffer: process data + * @sink_event: custom event handling on the sinkpad + * @src_event: custom event handling on the srcpad + * @query: custom query handling + * + * Base class for audio RTP payloader. + */ +struct _GstRTPBasePayloadClass +{ + GstElementClass parent_class; + + /* query accepted caps */ + GstCaps * (*get_caps) (GstRTPBasePayload *payload, GstPad * pad, GstCaps * filter); + /* receive caps on the sink pad, configure the payloader. */ + gboolean (*set_caps) (GstRTPBasePayload *payload, GstCaps *caps); + + /* handle a buffer, perform 0 or more gst_rtp_base_payload_push() on + * the RTP buffers. This function takes ownership of the buffer. */ + GstFlowReturn (*handle_buffer) (GstRTPBasePayload *payload, + GstBuffer *buffer); + /* handle events and queries */ + gboolean (*sink_event) (GstRTPBasePayload *payload, GstEvent * event); + gboolean (*src_event) (GstRTPBasePayload *payload, GstEvent * event); + gboolean (*query) (GstRTPBasePayload *payload, GstPad *pad, GstQuery * query); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTP_API +GType gst_rtp_base_payload_get_type (void); + +GST_RTP_API +void gst_rtp_base_payload_set_options (GstRTPBasePayload *payload, + const gchar *media, + gboolean dynamic, + const gchar *encoding_name, + guint32 clock_rate); + +GST_RTP_API +gboolean gst_rtp_base_payload_set_outcaps (GstRTPBasePayload *payload, + const gchar *fieldname, ...); + +GST_RTP_API +gboolean gst_rtp_base_payload_set_outcaps_structure (GstRTPBasePayload *payload, + GstStructure *s); + +GST_RTP_API +gboolean gst_rtp_base_payload_is_filled (GstRTPBasePayload *payload, + guint size, GstClockTime duration); + +GST_RTP_API +GstFlowReturn gst_rtp_base_payload_push (GstRTPBasePayload *payload, + GstBuffer *buffer); + +GST_RTP_API +GstFlowReturn gst_rtp_base_payload_push_list (GstRTPBasePayload *payload, + GstBufferList *list); + +GST_RTP_API +GstBuffer * gst_rtp_base_payload_allocate_output_buffer (GstRTPBasePayload * payload, + guint payload_len, guint8 pad_len, + guint8 csrc_count); + +GST_RTP_API +void gst_rtp_base_payload_set_source_info_enabled (GstRTPBasePayload * payload, + gboolean enable); + +GST_RTP_API +gboolean gst_rtp_base_payload_is_source_info_enabled (GstRTPBasePayload * payload); + +GST_RTP_API +guint gst_rtp_base_payload_get_source_count (GstRTPBasePayload * payload, + GstBuffer * buffer); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPBasePayload, gst_object_unref) + +G_END_DECLS + +#endif /* __GST_RTP_BASE_PAYLOAD_H__ */ diff --git a/include/gst/rtp/gstrtpbuffer.h b/include/gst/rtp/gstrtpbuffer.h new file mode 100644 index 0000000000..cac8998c2b --- /dev/null +++ b/include/gst/rtp/gstrtpbuffer.h @@ -0,0 +1,286 @@ +/* GStreamer + * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org> + * <2005> Wim Taymans <wim@fluendo.com> + * + * gstrtpbuffer.h: various helper functions to manipulate buffers + * with RTP payload. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTPBUFFER_H__ +#define __GST_RTPBUFFER_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtppayloads.h> + +G_BEGIN_DECLS + +/** + * GST_RTP_VERSION: + * + * The supported RTP version 2. + */ +#define GST_RTP_VERSION 2 + + +typedef struct _GstRTPBuffer GstRTPBuffer; + +/** + * GstRTPBuffer: + * @buffer: pointer to RTP buffer + * @state: internal state + * @data: array of data + * @size: array of size + * @map: array of #GstMapInfo + * + * Data structure that points to an RTP packet. + * The size of the structure is made public to allow stack allocations. + */ +struct _GstRTPBuffer +{ + GstBuffer *buffer; + guint state; + gpointer data[4]; + gsize size[4]; + GstMapInfo map[4]; +}; + +#define GST_RTP_BUFFER_INIT { NULL, 0, { NULL, NULL, NULL, NULL}, { 0, 0, 0, 0 }, \ + { GST_MAP_INFO_INIT, GST_MAP_INFO_INIT, GST_MAP_INFO_INIT, GST_MAP_INFO_INIT} } + +/* creating buffers */ + +GST_RTP_API +void gst_rtp_buffer_allocate_data (GstBuffer *buffer, guint payload_len, + guint8 pad_len, guint8 csrc_count); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_new_take_data (gpointer data, gsize len); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_new_copy_data (gconstpointer data, gsize len); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_new_allocate (guint payload_len, guint8 pad_len, guint8 csrc_count); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_new_allocate_len (guint packet_len, guint8 pad_len, guint8 csrc_count); + +GST_RTP_API +guint gst_rtp_buffer_calc_header_len (guint8 csrc_count); + +GST_RTP_API +guint gst_rtp_buffer_calc_packet_len (guint payload_len, guint8 pad_len, guint8 csrc_count); + +GST_RTP_API +guint gst_rtp_buffer_calc_payload_len (guint packet_len, guint8 pad_len, guint8 csrc_count); + +GST_RTP_API +gboolean gst_rtp_buffer_map (GstBuffer *buffer, GstMapFlags flags, GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_unmap (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_packet_len (GstRTPBuffer *rtp, guint len); + +GST_RTP_API +guint gst_rtp_buffer_get_packet_len (GstRTPBuffer *rtp); + +GST_RTP_API +guint gst_rtp_buffer_get_header_len (GstRTPBuffer *rtp); + +GST_RTP_API +guint8 gst_rtp_buffer_get_version (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_version (GstRTPBuffer *rtp, guint8 version); + +GST_RTP_API +gboolean gst_rtp_buffer_get_padding (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_padding (GstRTPBuffer *rtp, gboolean padding); + +GST_RTP_API +void gst_rtp_buffer_pad_to (GstRTPBuffer *rtp, guint len); + +GST_RTP_API +gboolean gst_rtp_buffer_get_extension (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_extension (GstRTPBuffer *rtp, gboolean extension); + +GST_RTP_API +gboolean gst_rtp_buffer_get_extension_data (GstRTPBuffer *rtp, guint16 *bits, + gpointer *data, guint *wordlen); + +GST_RTP_API +GBytes* gst_rtp_buffer_get_extension_bytes (GstRTPBuffer *rtp, guint16 *bits); + +GST_RTP_API +gboolean gst_rtp_buffer_set_extension_data (GstRTPBuffer *rtp, guint16 bits, guint16 length); + +GST_RTP_API +void gst_rtp_buffer_remove_extension_data (GstRTPBuffer *rtp); + +GST_RTP_API +guint32 gst_rtp_buffer_get_ssrc (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_ssrc (GstRTPBuffer *rtp, guint32 ssrc); + +GST_RTP_API +guint8 gst_rtp_buffer_get_csrc_count (GstRTPBuffer *rtp); + +GST_RTP_API +guint32 gst_rtp_buffer_get_csrc (GstRTPBuffer *rtp, guint8 idx); + +GST_RTP_API +void gst_rtp_buffer_set_csrc (GstRTPBuffer *rtp, guint8 idx, guint32 csrc); + +GST_RTP_API +gboolean gst_rtp_buffer_get_marker (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_marker (GstRTPBuffer *rtp, gboolean marker); + +GST_RTP_API +guint8 gst_rtp_buffer_get_payload_type (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_payload_type (GstRTPBuffer *rtp, guint8 payload_type); + +GST_RTP_API +guint16 gst_rtp_buffer_get_seq (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_seq (GstRTPBuffer *rtp, guint16 seq); + +GST_RTP_API +guint32 gst_rtp_buffer_get_timestamp (GstRTPBuffer *rtp); + +GST_RTP_API +void gst_rtp_buffer_set_timestamp (GstRTPBuffer *rtp, guint32 timestamp); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_get_payload_buffer (GstRTPBuffer *rtp); + +GST_RTP_API +GstBuffer* gst_rtp_buffer_get_payload_subbuffer (GstRTPBuffer *rtp, guint offset, guint len); + +GST_RTP_API +guint gst_rtp_buffer_get_payload_len (GstRTPBuffer *rtp); + +GST_RTP_API +gpointer gst_rtp_buffer_get_payload (GstRTPBuffer *rtp); + +GST_RTP_API +GBytes* gst_rtp_buffer_get_payload_bytes (GstRTPBuffer *rtp); + +/* some helpers */ + +GST_RTP_API +guint32 gst_rtp_buffer_default_clock_rate (guint8 payload_type); + +GST_RTP_API +gint gst_rtp_buffer_compare_seqnum (guint16 seqnum1, guint16 seqnum2); + +GST_RTP_API +guint64 gst_rtp_buffer_ext_timestamp (guint64 *exttimestamp, guint32 timestamp); + +GST_RTP_API +gboolean gst_rtp_buffer_get_extension_onebyte_header (GstRTPBuffer *rtp, + guint8 id, + guint nth, + gpointer * data, + guint * size); + +GST_RTP_API +gboolean gst_rtp_buffer_get_extension_twobytes_header (GstRTPBuffer *rtp, + guint8 * appbits, + guint8 id, + guint nth, + gpointer * data, + guint * size); + +GST_RTP_API +gboolean gst_rtp_buffer_add_extension_onebyte_header (GstRTPBuffer *rtp, + guint8 id, + gconstpointer data, + guint size); + +GST_RTP_API +gboolean gst_rtp_buffer_add_extension_twobytes_header (GstRTPBuffer *rtp, + guint8 appbits, + guint8 id, + gconstpointer data, + guint size); + +GST_RTP_API +gboolean gst_rtp_buffer_get_extension_onebyte_header_from_bytes (GBytes * bytes, + guint16 bit_pattern, + guint8 id, + guint nth, + gpointer * data, + guint * size); + +/** + * GstRTPBufferFlags: + * @GST_RTP_BUFFER_FLAG_RETRANSMISSION: The #GstBuffer was once wrapped + * in a retransmitted packet as specified by RFC 4588. + * @GST_RTP_BUFFER_FLAG_REDUNDANT: The packet represents redundant RTP packet. + * The flag is used in gstrtpstorage to be able to hold the packetback + * and use it only for recovery from packet loss. + * Since: 1.14 + * @GST_RTP_BUFFER_FLAG_LAST: Offset to define more flags. + * + * Additional RTP buffer flags. These flags can potentially be used on any + * buffers carrying RTP packets. + * + * Note that these are only valid for #GstCaps of type: application/x-rtp (x-rtcp). + * They can conflict with other extended buffer flags. + * + * Since: 1.10 + */ +typedef enum { + GST_RTP_BUFFER_FLAG_RETRANSMISSION = (GST_BUFFER_FLAG_LAST << 0), + GST_RTP_BUFFER_FLAG_REDUNDANT = (GST_BUFFER_FLAG_LAST << 1), + GST_RTP_BUFFER_FLAG_LAST = (GST_BUFFER_FLAG_LAST << 8) +} GstRTPBufferFlags; + +/** + * GstRTPBufferMapFlags: + * @GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING: Skip mapping and validation of RTP + * padding and RTP pad count when present. Useful for buffers where + * the padding may be encrypted. + * @GST_RTP_BUFFER_MAP_FLAG_LAST: Offset to define more flags + * + * Additional mapping flags for gst_rtp_buffer_map(). + * + * Since: 1.6.1 + */ +typedef enum { + GST_RTP_BUFFER_MAP_FLAG_SKIP_PADDING = (GST_MAP_FLAG_LAST << 0), + GST_RTP_BUFFER_MAP_FLAG_LAST = (GST_MAP_FLAG_LAST << 8) + /* 8 more flags possible afterwards */ +} GstRTPBufferMapFlags; + +G_END_DECLS + +#endif /* __GST_RTPBUFFER_H__ */ + diff --git a/include/gst/rtp/gstrtpdefs.h b/include/gst/rtp/gstrtpdefs.h new file mode 100644 index 0000000000..14aff5613a --- /dev/null +++ b/include/gst/rtp/gstrtpdefs.h @@ -0,0 +1,58 @@ +/* GStreamer + * Copyright (C) <2005> Philippe Khalaf <burger@speedy.org> + * <2005> Wim Taymans <wim@fluendo.com> + * + * gstrtpbuffer.h: various helper functions to manipulate buffers + * with RTP payload. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTPDEFS_H__ +#define __GST_RTPDEFS_H__ + +#include <gst/gst.h> +#include <gst/rtp/rtp-prelude.h> + +/** + * SECTION:gstrtpdefs + * @title: GstRTPdefs + * @short_description: common RTP defines + * + * Provides common defines for the RTP library. + */ + +/** + * GstRTPProfile: + * @GST_RTP_PROFILE_UNKNOWN: invalid profile + * @GST_RTP_PROFILE_AVP: the Audio/Visual profile (RFC 3551) + * @GST_RTP_PROFILE_SAVP: the secure Audio/Visual profile (RFC 3711) + * @GST_RTP_PROFILE_AVPF: the Audio/Visual profile with feedback (RFC 4585) + * @GST_RTP_PROFILE_SAVPF: the secure Audio/Visual profile with feedback (RFC 5124) + * + * The transfer profile to use. + * + * Since: 1.6 + */ +typedef enum { + GST_RTP_PROFILE_UNKNOWN = 0, + GST_RTP_PROFILE_AVP, + GST_RTP_PROFILE_SAVP, + GST_RTP_PROFILE_AVPF, + GST_RTP_PROFILE_SAVPF +} GstRTPProfile; + +#endif /* __GST_RTPDEFS_H__ */ diff --git a/include/gst/rtp/gstrtphdrext.h b/include/gst/rtp/gstrtphdrext.h new file mode 100644 index 0000000000..442c27af60 --- /dev/null +++ b/include/gst/rtp/gstrtphdrext.h @@ -0,0 +1,294 @@ +/* GStreamer + * Copyright (C) <2012> Wim Taymans <wim.taymans@gmail.com> + * Copyright (C) <2020> Matthew Waters <matthew@centricular.com> + * + * gstrtphdrext.h: RTP header extensions + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __GST_RTPHDREXT_H__ +#define __GST_RTPHDREXT_H__ + +#include <gst/gst.h> +#include <gst/rtp/gstrtpbuffer.h> + +G_BEGIN_DECLS + +#define GST_RTP_HDREXT_BASE "urn:ietf:params:rtp-hdrext:" + +/* RFC 6051 */ +#define GST_RTP_HDREXT_NTP_64 "ntp-64" + +#define GST_RTP_HDREXT_NTP_64_SIZE 8 + +GST_RTP_API +gboolean gst_rtp_hdrext_set_ntp_64 (gpointer data, guint size, guint64 ntptime); + +GST_RTP_API +gboolean gst_rtp_hdrext_get_ntp_64 (gpointer data, guint size, guint64 *ntptime); + +#define GST_RTP_HDREXT_NTP_56 "ntp-56" + +#define GST_RTP_HDREXT_NTP_56_SIZE 7 + +GST_RTP_API +gboolean gst_rtp_hdrext_set_ntp_56 (gpointer data, guint size, guint64 ntptime); + +GST_RTP_API +gboolean gst_rtp_hdrext_get_ntp_56 (gpointer data, guint size, guint64 *ntptime); + +/** + * GST_RTP_HDREXT_ELEMENT_CLASS: + * + * Constant string used in element classification to signal that this element + * is a RTP header extension. + * + * Since: 1.20 + */ +#define GST_RTP_HDREXT_ELEMENT_CLASS "Network/Extension/RTPHeader" + +GST_RTP_API +GType gst_rtp_header_extension_get_type (void); +#define GST_TYPE_RTP_HEADER_EXTENSION (gst_rtp_header_extension_get_type()) +#define GST_RTP_HEADER_EXTENSION(obj) \ + (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtension)) +#define GST_RTP_HEADER_EXTENSION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtensionClass)) +#define GST_RTP_HEADER_EXTENSION_GET_CLASS(obj) \ + (G_TYPE_INSTANCE_GET_CLASS ((obj),GST_TYPE_RTP_HEADER_EXTENSION,GstRTPHeaderExtensionClass)) +#define GST_IS_RTP_HEADER_EXTENSION(obj) \ + (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_HEADER_EXTENSION)) +#define GST_IS_RTP_HEADER_EXTENSION_CLASS(klass) \ + (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_HEADER_EXTENSION)) +/** + * GST_RTP_HEADER_EXTENSION_CAST: + * + * Since: 1.20 + */ +#define GST_RTP_HEADER_EXTENSION_CAST(obj) ((GstRTPHeaderExtension *)(obj)) + +typedef struct _GstRTPHeaderExtension GstRTPHeaderExtension; +typedef struct _GstRTPHeaderExtensionClass GstRTPHeaderExtensionClass; + +/** + * GstRTPHeaderExtensionFlags: + * @GST_RTP_HEADER_EXTENSION_ONE_BYTE: The one byte rtp extension header. + * 1-16 data bytes per extension with a maximum of + * 14 extension ids in total. + * @GST_RTP_HEADER_EXTENSION_TWO_BYTE: The two byte rtp extension header. + * 256 data bytes per extension with a maximum of 255 (or 256 + * including appbits) extensions in total. + * + * Flags that apply to a RTP Audio/Video header extension. + * + * Since: 1.20 + */ +typedef enum /*< underscore_name=gst_rtp_header_extension_flags >*/ +{ + GST_RTP_HEADER_EXTENSION_ONE_BYTE = (1 << 0), + GST_RTP_HEADER_EXTENSION_TWO_BYTE = (1 << 1), +} GstRTPHeaderExtensionFlags; + +/** + * GstRTPHeaderExtensionDirection: + * @GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE: Neither send nor + * receive RTP Header Extensions + * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY: Only send RTP Header + * Extensions @GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY: Only + * receive RTP Header Extensions + * @GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV: Send and receive RTP + * Header Extensions ext + * @GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED: RTP header extension + * direction is inherited from the stream + * + * Direction to which to apply the RTP Header Extension + * + * Since: 1.20 + */ +typedef enum /*< underscore_name=gst_rtp_header_extension_direction >*/ +{ + GST_RTP_HEADER_EXTENSION_DIRECTION_INACTIVE = 0, + GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY = (1 << 0), + GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY = (1 << 1), + GST_RTP_HEADER_EXTENSION_DIRECTION_SENDRECV = ( + GST_RTP_HEADER_EXTENSION_DIRECTION_SENDONLY | + GST_RTP_HEADER_EXTENSION_DIRECTION_RECVONLY), + GST_RTP_HEADER_EXTENSION_DIRECTION_INHERITED = (1 << 2) +} GstRTPHeaderExtensionDirection; + +/** + * GstRTPHeaderExtension: + * @parent: the parent #GObject + * @ext_id: the configured extension id + * + * Instance struct for a RTP Audio/Video header extension. + * + * Since: 1.20 + */ +struct _GstRTPHeaderExtension +{ + GstElement parent; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +/** + * GstRTPHeaderExtensionClass: + * @parent_class: the parent class + * @get_uri: retrieve the RTP extension uri + * @get_supported_flags: retrieve the supported flags + * @get_max_size: retrieve the maximum size for this extension based on the + * information available from input_meta. Implementations should attempt + * to provide as accurate information as possible as the returned value + * will be used to control the amount of possible data in the payload. + * Implementations must return the maximum as the allocated size for + * writing the extension will be at least the size of the returned value. + * Return the amount of data read or <0 on failure. + * @write: write into @data the information for this extension. Various + * information is provided to help writing extensions in particular cases. + * @read: read from a rtp payloaded buffer and extract the extension + * information, optionally adding some meta onto the output buffer. + * @set_non_rtp_sink_caps: read any information from sink caps that the header + * extension needs for its function. + * @update_non_rtp_src_caps: update depayloader non-RTP (depayloaded) caps with + * the information parsed from RTP header. + * @set_attributes: set the necessary attributes that may be signaled e.g. with + * an SDP. + * @set_caps_from_attributes: write the necessary caps field/s for the configured + * attributes e.g. as signalled with SDP. + * + * Base class for RTP Header extensions. + * + * Since: 1.20 + */ + +struct _GstRTPHeaderExtensionClass +{ + GstElementClass parent_class; + + /*< public >*/ + GstRTPHeaderExtensionFlags (*get_supported_flags) (GstRTPHeaderExtension * ext); + + gsize (*get_max_size) (GstRTPHeaderExtension * ext, + const GstBuffer * input_meta); + + gssize (*write) (GstRTPHeaderExtension * ext, + const GstBuffer * input_meta, + GstRTPHeaderExtensionFlags write_flags, + GstBuffer * output, + guint8 * data, + gsize size); + + gboolean (*read) (GstRTPHeaderExtension * ext, + GstRTPHeaderExtensionFlags read_flags, + const guint8 * data, + gsize size, + GstBuffer * buffer); + gboolean (*set_non_rtp_sink_caps) (GstRTPHeaderExtension * ext, + const GstCaps * caps); + gboolean (*update_non_rtp_src_caps) (GstRTPHeaderExtension * ext, + GstCaps * caps); + gboolean (*set_attributes) (GstRTPHeaderExtension * ext, + GstRTPHeaderExtensionDirection direction, + const gchar * attributes); + gboolean (*set_caps_from_attributes) (GstRTPHeaderExtension * ext, + GstCaps * caps); + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING_LARGE]; +}; + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstRTPHeaderExtension, gst_object_unref) + +/** + * GST_RTP_HEADER_EXTENSION_URI_METADATA_KEY: + * + * Since: 1.20 + */ +#define GST_RTP_HEADER_EXTENSION_URI_METADATA_KEY "RTP-Header-Extension-URI" + +GST_RTP_API +void gst_rtp_header_extension_class_set_uri (GstRTPHeaderExtensionClass *klass, + const gchar * uri); + +GST_RTP_API +const gchar * gst_rtp_header_extension_get_uri (GstRTPHeaderExtension * ext); +GST_RTP_API +gsize gst_rtp_header_extension_get_max_size (GstRTPHeaderExtension * ext, + const GstBuffer * input_meta); +GST_RTP_API +GstRTPHeaderExtensionFlags gst_rtp_header_extension_get_supported_flags (GstRTPHeaderExtension * ext); +GST_RTP_API +guint gst_rtp_header_extension_get_id (GstRTPHeaderExtension * ext); +GST_RTP_API +void gst_rtp_header_extension_set_id (GstRTPHeaderExtension * ext, + guint ext_id); +GST_RTP_API +gssize gst_rtp_header_extension_write (GstRTPHeaderExtension * ext, + const GstBuffer * input_meta, + GstRTPHeaderExtensionFlags write_flags, + GstBuffer * output, + guint8 * data, + gsize size); +GST_RTP_API +gboolean gst_rtp_header_extension_read (GstRTPHeaderExtension * ext, + GstRTPHeaderExtensionFlags read_flags, + const guint8 * data, + gsize size, + GstBuffer * buffer); +GST_RTP_API +gboolean gst_rtp_header_extension_set_non_rtp_sink_caps (GstRTPHeaderExtension * ext, + const GstCaps * caps); +GST_RTP_API +gboolean gst_rtp_header_extension_wants_update_non_rtp_src_caps (GstRTPHeaderExtension * ext); +GST_RTP_API +void gst_rtp_header_extension_set_wants_update_non_rtp_src_caps (GstRTPHeaderExtension * ext, + gboolean state); +GST_RTP_API +gboolean gst_rtp_header_extension_update_non_rtp_src_caps (GstRTPHeaderExtension * ext, + GstCaps * caps); +GST_RTP_API +gboolean gst_rtp_header_extension_set_caps_from_attributes (GstRTPHeaderExtension * ext, + GstCaps * caps); +GST_RTP_API +gboolean gst_rtp_header_extension_set_attributes_from_caps (GstRTPHeaderExtension * ext, + const GstCaps * caps); + +GST_RTP_API +GList * gst_rtp_get_header_extension_list (void); +GST_RTP_API +GstRTPHeaderExtension * gst_rtp_header_extension_create_from_uri (const gchar * uri); + +GST_RTP_API +gchar * gst_rtp_header_extension_get_sdp_caps_field_name (GstRTPHeaderExtension * ext); + +GST_RTP_API +void gst_rtp_header_extension_set_direction (GstRTPHeaderExtension * ext, + GstRTPHeaderExtensionDirection direction); +GST_RTP_API +GstRTPHeaderExtensionDirection gst_rtp_header_extension_get_direction (GstRTPHeaderExtension * ext); + +GST_RTP_API +gboolean gst_rtp_header_extension_set_caps_from_attributes_helper (GstRTPHeaderExtension * ext, + GstCaps * caps, + const gchar * attributes); + +G_END_DECLS + +#endif /* __GST_RTPHDREXT_H__ */ + diff --git a/include/gst/rtp/gstrtpmeta.h b/include/gst/rtp/gstrtpmeta.h new file mode 100644 index 0000000000..f0611d36e3 --- /dev/null +++ b/include/gst/rtp/gstrtpmeta.h @@ -0,0 +1,79 @@ +/* GStreamer + * Copyright (C) <2016> Stian Selnes <stian@pexip.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_META_H__ +#define __GST_RTP_META_H__ + +#include <gst/gst.h> +#include <gst/rtp/rtp-prelude.h> + +G_BEGIN_DECLS + +#define GST_RTP_SOURCE_META_API_TYPE (gst_rtp_source_meta_api_get_type()) +#define GST_RTP_SOURCE_META_INFO (gst_rtp_source_meta_get_info()) +typedef struct _GstRTPSourceMeta GstRTPSourceMeta; + +#define GST_RTP_SOURCE_META_MAX_CSRC_COUNT 15 + +/** + * GstRTPSourceMeta: + * @meta: parent #GstMeta + * @ssrc: the SSRC + * @ssrc_valid: whether @ssrc is set and valid + * @csrc: (allow-none): pointer to the CSRCs + * @csrc_count: number of elements in @csrc + * + * Meta describing the source(s) of the buffer. + * + * Since: 1.16 + */ +struct _GstRTPSourceMeta +{ + GstMeta meta; + + guint32 ssrc; + gboolean ssrc_valid; + guint32 csrc[GST_RTP_SOURCE_META_MAX_CSRC_COUNT]; + guint csrc_count; +}; + +GST_RTP_API +GType gst_rtp_source_meta_api_get_type (void); + +GST_RTP_API +GstRTPSourceMeta * gst_buffer_add_rtp_source_meta (GstBuffer * buffer, const guint32 * ssrc, + const guint32 * csrc, guint csrc_count); +GST_RTP_API +GstRTPSourceMeta * gst_buffer_get_rtp_source_meta (GstBuffer * buffer); + +GST_RTP_API +guint gst_rtp_source_meta_get_source_count (const GstRTPSourceMeta * meta); + +GST_RTP_API +gboolean gst_rtp_source_meta_set_ssrc (GstRTPSourceMeta * meta, guint32 * ssrc); + +GST_RTP_API +gboolean gst_rtp_source_meta_append_csrc (GstRTPSourceMeta * meta, + const guint32 * csrc, guint csrc_count); +GST_RTP_API +const GstMetaInfo * gst_rtp_source_meta_get_info (void); + +G_END_DECLS + +#endif /* __GST_RTP_META_H__ */ diff --git a/include/gst/rtp/gstrtppayloads.h b/include/gst/rtp/gstrtppayloads.h new file mode 100644 index 0000000000..84f6c3cc3c --- /dev/null +++ b/include/gst/rtp/gstrtppayloads.h @@ -0,0 +1,199 @@ +/* GStreamer + * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com> + * + * gstrtppayloads.h: various helper functions to deal with RTP payload + * types. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTPPAYLOADS_H__ +#define __GST_RTPPAYLOADS_H__ + +#include <gst/gst.h> +#include <gst/rtp/rtp-prelude.h> + +G_BEGIN_DECLS + +/** + * GstRTPPayload: + * @GST_RTP_PAYLOAD_PCMU: ITU-T G.711. mu-law audio (RFC 3551) + * @GST_RTP_PAYLOAD_1016: RFC 3551 says reserved + * @GST_RTP_PAYLOAD_G721: RFC 3551 says reserved + * @GST_RTP_PAYLOAD_GSM: GSM audio + * @GST_RTP_PAYLOAD_G723: ITU G.723.1 audio + * @GST_RTP_PAYLOAD_DVI4_8000: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_16000: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_LPC: experimental linear predictive encoding + * @GST_RTP_PAYLOAD_PCMA: ITU-T G.711 A-law audio (RFC 3551) + * @GST_RTP_PAYLOAD_G722: ITU-T G.722 (RFC 3551) + * @GST_RTP_PAYLOAD_L16_STEREO: stereo PCM + * @GST_RTP_PAYLOAD_L16_MONO: mono PCM + * @GST_RTP_PAYLOAD_QCELP: EIA & TIA standard IS-733 + * @GST_RTP_PAYLOAD_CN: Comfort Noise (RFC 3389) + * @GST_RTP_PAYLOAD_MPA: Audio MPEG 1-3. + * @GST_RTP_PAYLOAD_G728: ITU-T G.728 Speech coder (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_11025: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_DVI4_22050: IMA ADPCM wave type (RFC 3551) + * @GST_RTP_PAYLOAD_G729: ITU-T G.729 Speech coder (RFC 3551) + * @GST_RTP_PAYLOAD_CELLB: See RFC 2029 + * @GST_RTP_PAYLOAD_JPEG: ISO Standards 10918-1 and 10918-2 (RFC 2435) + * @GST_RTP_PAYLOAD_NV: nv encoding by Ron Frederick + * @GST_RTP_PAYLOAD_H261: ITU-T Recommendation H.261 (RFC 2032) + * @GST_RTP_PAYLOAD_MPV: Video MPEG 1 & 2 (RFC 2250) + * @GST_RTP_PAYLOAD_MP2T: MPEG-2 transport stream (RFC 2250) + * @GST_RTP_PAYLOAD_H263: Video H263 (RFC 2190) + * + * Standard predefined fixed payload types. + * + * The official list is at: + * http://www.iana.org/assignments/rtp-parameters + * + * Audio: + * reserved: 19 + * unassigned: 20-23, + * + * Video: + * unassigned: 24, 27, 29, 30, 35-71, 77-95 + * Reserved for RTCP conflict avoidance: 72-76 + */ +typedef enum +{ + /* Audio: */ + GST_RTP_PAYLOAD_PCMU = 0, + GST_RTP_PAYLOAD_1016 = 1, /* RFC 3551 says reserved */ + GST_RTP_PAYLOAD_G721 = 2, /* RFC 3551 says reserved */ + GST_RTP_PAYLOAD_GSM = 3, + GST_RTP_PAYLOAD_G723 = 4, + GST_RTP_PAYLOAD_DVI4_8000 = 5, + GST_RTP_PAYLOAD_DVI4_16000 = 6, + GST_RTP_PAYLOAD_LPC = 7, + GST_RTP_PAYLOAD_PCMA = 8, + GST_RTP_PAYLOAD_G722 = 9, + GST_RTP_PAYLOAD_L16_STEREO = 10, + GST_RTP_PAYLOAD_L16_MONO = 11, + GST_RTP_PAYLOAD_QCELP = 12, + GST_RTP_PAYLOAD_CN = 13, + GST_RTP_PAYLOAD_MPA = 14, + GST_RTP_PAYLOAD_G728 = 15, + GST_RTP_PAYLOAD_DVI4_11025 = 16, + GST_RTP_PAYLOAD_DVI4_22050 = 17, + GST_RTP_PAYLOAD_G729 = 18, + + /* Video: */ + + GST_RTP_PAYLOAD_CELLB = 25, + GST_RTP_PAYLOAD_JPEG = 26, + GST_RTP_PAYLOAD_NV = 28, + GST_RTP_PAYLOAD_H261 = 31, + GST_RTP_PAYLOAD_MPV = 32, + GST_RTP_PAYLOAD_MP2T = 33, + GST_RTP_PAYLOAD_H263 = 34, + + /* BOTH */ +} GstRTPPayload; + +/* backward compatibility */ +#define GST_RTP_PAYLOAD_G723_63 16 +#define GST_RTP_PAYLOAD_G723_53 17 +#define GST_RTP_PAYLOAD_TS48 18 +#define GST_RTP_PAYLOAD_TS41 19 + +#define GST_RTP_PAYLOAD_G723_63_STRING "16" +#define GST_RTP_PAYLOAD_G723_53_STRING "17" +#define GST_RTP_PAYLOAD_TS48_STRING "18" +#define GST_RTP_PAYLOAD_TS41_STRING "19" + +/* Defining the above as strings, to make the declaration of pad_templates + * easier. So if please keep these synchronized with the above. + */ +#define GST_RTP_PAYLOAD_PCMU_STRING "0" +#define GST_RTP_PAYLOAD_1016_STRING "1" +#define GST_RTP_PAYLOAD_G721_STRING "2" +#define GST_RTP_PAYLOAD_GSM_STRING "3" +#define GST_RTP_PAYLOAD_G723_STRING "4" +#define GST_RTP_PAYLOAD_DVI4_8000_STRING "5" +#define GST_RTP_PAYLOAD_DVI4_16000_STRING "6" +#define GST_RTP_PAYLOAD_LPC_STRING "7" +#define GST_RTP_PAYLOAD_PCMA_STRING "8" +#define GST_RTP_PAYLOAD_G722_STRING "9" +#define GST_RTP_PAYLOAD_L16_STEREO_STRING "10" +#define GST_RTP_PAYLOAD_L16_MONO_STRING "11" +#define GST_RTP_PAYLOAD_QCELP_STRING "12" +#define GST_RTP_PAYLOAD_CN_STRING "13" +#define GST_RTP_PAYLOAD_MPA_STRING "14" +#define GST_RTP_PAYLOAD_G728_STRING "15" +#define GST_RTP_PAYLOAD_DVI4_11025_STRING "16" +#define GST_RTP_PAYLOAD_DVI4_22050_STRING "17" +#define GST_RTP_PAYLOAD_G729_STRING "18" + +#define GST_RTP_PAYLOAD_CELLB_STRING "25" +#define GST_RTP_PAYLOAD_JPEG_STRING "26" +#define GST_RTP_PAYLOAD_NV_STRING "28" + +#define GST_RTP_PAYLOAD_H261_STRING "31" +#define GST_RTP_PAYLOAD_MPV_STRING "32" +#define GST_RTP_PAYLOAD_MP2T_STRING "33" +#define GST_RTP_PAYLOAD_H263_STRING "34" + +#define GST_RTP_PAYLOAD_DYNAMIC_STRING "[96, 127]" + +/** + * GST_RTP_PAYLOAD_IS_DYNAMIC: + * @pt: a payload type + * + * Check if @pt is a dynamic payload type. + */ +#define GST_RTP_PAYLOAD_IS_DYNAMIC(pt) ((pt) >= 96 && (pt) <= 127) + +typedef struct _GstRTPPayloadInfo GstRTPPayloadInfo; + +/** + * GstRTPPayloadInfo: + * @payload_type: payload type, -1 means dynamic + * @media: the media type(s), usually "audio", "video", "application", "text", + * "message". + * @encoding_name: the encoding name of @pt + * @clock_rate: default clock rate, 0 = unknown/variable + * @encoding_parameters: encoding parameters. For audio this is the number of + * channels. NULL = not applicable. + * @bitrate: the bitrate of the media. 0 = unknown/variable. + * + * Structure holding default payload type information. + */ +struct _GstRTPPayloadInfo +{ + guint8 payload_type; + const gchar *media; + const gchar *encoding_name; + guint clock_rate; + const gchar *encoding_parameters; + guint bitrate; + + /*< private >*/ + gpointer _gst_reserved[GST_PADDING]; +}; + +GST_RTP_API +const GstRTPPayloadInfo * gst_rtp_payload_info_for_pt (guint8 payload_type); + +GST_RTP_API +const GstRTPPayloadInfo * gst_rtp_payload_info_for_name (const gchar *media, const gchar *encoding_name); + +G_END_DECLS + +#endif /* __GST_RTPPAYLOADS_H__ */ + diff --git a/include/gst/rtp/rtp-prelude.h b/include/gst/rtp/rtp-prelude.h new file mode 100644 index 0000000000..e130b8a476 --- /dev/null +++ b/include/gst/rtp/rtp-prelude.h @@ -0,0 +1,33 @@ +/* GStreamer RTP Library + * Copyright (C) 2018 GStreamer developers + * + * rtp-prelude.h: prelude include header for gst-rtp library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_PRELUDE_H__ +#define __GST_RTP_PRELUDE_H__ + +#include <gst/gst.h> + +#ifdef BUILDING_GST_RTP +#define GST_RTP_API GST_API_EXPORT /* from config.h */ +#else +#define GST_RTP_API GST_API_IMPORT +#endif + +#endif /* __GST_RTP_PRELUDE_H__ */ diff --git a/include/gst/rtp/rtp.h b/include/gst/rtp/rtp.h new file mode 100644 index 0000000000..0e6633bd81 --- /dev/null +++ b/include/gst/rtp/rtp.h @@ -0,0 +1,36 @@ +/* GStreamer + * Copyright (C) 2012 GStreamer developers + * + * gstrtp.h: single include header for gst-rtp library + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_RTP_H__ +#define __GST_RTP_H__ + +#include <gst/rtp/gstrtpdefs.h> +#include <gst/rtp/gstrtpbuffer.h> +#include <gst/rtp/gstrtcpbuffer.h> +#include <gst/rtp/gstrtppayloads.h> +#include <gst/rtp/gstrtphdrext.h> +#include <gst/rtp/gstrtpbaseaudiopayload.h> +#include <gst/rtp/gstrtpbasepayload.h> +#include <gst/rtp/gstrtpbasedepayload.h> +#include <gst/rtp/gstrtpmeta.h> +#include <gst/rtp/gstrtp-enumtypes.h> + +#endif /* __GST_RTP_H__ */ |