mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-03 05:05:52 +00:00
rtp: add helpers for header extensions
Add helpers and defines for the NTP-64 and NTP-56 header extensions.
This commit is contained in:
parent
6cbcca0bc5
commit
82d327fb91
|
@ -3,6 +3,7 @@ libgstrtpincludedir = $(includedir)/gstreamer-@GST_API_VERSION@/gst/rtp
|
||||||
libgstrtpinclude_HEADERS = gstrtpbuffer.h \
|
libgstrtpinclude_HEADERS = gstrtpbuffer.h \
|
||||||
gstrtcpbuffer.h \
|
gstrtcpbuffer.h \
|
||||||
gstrtppayloads.h \
|
gstrtppayloads.h \
|
||||||
|
gstrtphdrext.h \
|
||||||
gstrtpbaseaudiopayload.h \
|
gstrtpbaseaudiopayload.h \
|
||||||
gstrtpbasepayload.h \
|
gstrtpbasepayload.h \
|
||||||
gstrtpbasedepayload.h
|
gstrtpbasedepayload.h
|
||||||
|
@ -12,6 +13,7 @@ lib_LTLIBRARIES = libgstrtp-@GST_API_VERSION@.la
|
||||||
libgstrtp_@GST_API_VERSION@_la_SOURCES = gstrtpbuffer.c \
|
libgstrtp_@GST_API_VERSION@_la_SOURCES = gstrtpbuffer.c \
|
||||||
gstrtcpbuffer.c \
|
gstrtcpbuffer.c \
|
||||||
gstrtppayloads.c \
|
gstrtppayloads.c \
|
||||||
|
gstrtphdrext.c \
|
||||||
gstrtpbaseaudiopayload.c \
|
gstrtpbaseaudiopayload.c \
|
||||||
gstrtpbasepayload.c \
|
gstrtpbasepayload.c \
|
||||||
gstrtpbasedepayload.c
|
gstrtpbasedepayload.c
|
||||||
|
|
|
@ -66,6 +66,8 @@ typedef enum
|
||||||
* @GST_RTCP_RTPFB_TYPE_TMMBR: Temporary Maximum Media Stream Bit Rate Request
|
* @GST_RTCP_RTPFB_TYPE_TMMBR: Temporary Maximum Media Stream Bit Rate Request
|
||||||
* @GST_RTCP_RTPFB_TYPE_TMMBN: Temporary Maximum Media Stream Bit Rate
|
* @GST_RTCP_RTPFB_TYPE_TMMBN: Temporary Maximum Media Stream Bit Rate
|
||||||
* Notification
|
* Notification
|
||||||
|
* @GST_RTCP_RTPFB_TYPE_RTCP_SR_SEQ: Request an SR packet for early
|
||||||
|
* synchronization
|
||||||
* @GST_RTCP_PSFB_TYPE_PLI: Picture Loss Indication
|
* @GST_RTCP_PSFB_TYPE_PLI: Picture Loss Indication
|
||||||
* @GST_RTCP_PSFB_TYPE_SLI: Slice Loss Indication
|
* @GST_RTCP_PSFB_TYPE_SLI: Slice Loss Indication
|
||||||
* @GST_RTCP_PSFB_TYPE_RPSI: Reference Picture Selection Indication
|
* @GST_RTCP_PSFB_TYPE_RPSI: Reference Picture Selection Indication
|
||||||
|
@ -80,22 +82,24 @@ typedef enum
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
/* generic */
|
/* generic */
|
||||||
GST_RTCP_FB_TYPE_INVALID = 0,
|
GST_RTCP_FB_TYPE_INVALID = 0,
|
||||||
/* RTPFB types */
|
/* RTPFB types */
|
||||||
GST_RTCP_RTPFB_TYPE_NACK = 1,
|
GST_RTCP_RTPFB_TYPE_NACK = 1,
|
||||||
/* RTPFB types assigned in RFC 5104 */
|
/* RTPFB types assigned in RFC 5104 */
|
||||||
GST_RTCP_RTPFB_TYPE_TMMBR = 3,
|
GST_RTCP_RTPFB_TYPE_TMMBR = 3,
|
||||||
GST_RTCP_RTPFB_TYPE_TMMBN = 4,
|
GST_RTCP_RTPFB_TYPE_TMMBN = 4,
|
||||||
|
/* RTPFB types assigned in RFC 6051 */
|
||||||
|
GST_RTCP_RTPFB_TYPE_RCTP_SR_REQ = 5,
|
||||||
/* PSFB types */
|
/* PSFB types */
|
||||||
GST_RTCP_PSFB_TYPE_PLI = 1,
|
GST_RTCP_PSFB_TYPE_PLI = 1,
|
||||||
GST_RTCP_PSFB_TYPE_SLI = 2,
|
GST_RTCP_PSFB_TYPE_SLI = 2,
|
||||||
GST_RTCP_PSFB_TYPE_RPSI = 3,
|
GST_RTCP_PSFB_TYPE_RPSI = 3,
|
||||||
GST_RTCP_PSFB_TYPE_AFB = 15,
|
GST_RTCP_PSFB_TYPE_AFB = 15,
|
||||||
/* PSFB types assigned in RFC 5104 */
|
/* PSFB types assigned in RFC 5104 */
|
||||||
GST_RTCP_PSFB_TYPE_FIR = 4,
|
GST_RTCP_PSFB_TYPE_FIR = 4,
|
||||||
GST_RTCP_PSFB_TYPE_TSTR = 5,
|
GST_RTCP_PSFB_TYPE_TSTR = 5,
|
||||||
GST_RTCP_PSFB_TYPE_TSTN = 6,
|
GST_RTCP_PSFB_TYPE_TSTN = 6,
|
||||||
GST_RTCP_PSFB_TYPE_VBCN = 7,
|
GST_RTCP_PSFB_TYPE_VBCN = 7,
|
||||||
} GstRTCPFBType;
|
} GstRTCPFBType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
139
gst-libs/gst/rtp/gstrtphdrext.c
Normal file
139
gst-libs/gst/rtp/gstrtphdrext.c
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <2012> Wim Taymans <wim.taymans@gmail.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., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gstrtpexthdr
|
||||||
|
* @short_description: Helper methods for dealing with RTP header extensions
|
||||||
|
* @see_also: #GstRTPBasePayload, #GstRTPBaseDepayload, gstrtpbuffer
|
||||||
|
*
|
||||||
|
* <refsect2>
|
||||||
|
* <para>
|
||||||
|
* </para>
|
||||||
|
* </refsect2>
|
||||||
|
*
|
||||||
|
* Last reviewed on 2012-09-24 (1.0)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gstrtphdrext.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_hdrext_set_ntp_64:
|
||||||
|
* @data: the data to write to
|
||||||
|
* @size: the size of @data
|
||||||
|
* @ntptime: the NTP time
|
||||||
|
*
|
||||||
|
* Writes the NTP time in @ntptime to the format required for the NTP-64 header
|
||||||
|
* extension. @data must hold at least #GST_RTP_HDREXT_NTP_64_SIZE bytes.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtp_hdrext_set_ntp_64 (gpointer data, guint size, guint64 ntptime)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (size >= GST_RTP_HDREXT_NTP_64_SIZE, FALSE);
|
||||||
|
|
||||||
|
GST_WRITE_UINT64_BE (data, ntptime);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_hdrext_get_ntp_64:
|
||||||
|
* @data: the data to read from
|
||||||
|
* @size: the size of @data
|
||||||
|
* @ntptime: the result NTP time
|
||||||
|
*
|
||||||
|
* Reads the NTP time from the @size NTP-64 extension bytes in @data and store the
|
||||||
|
* result in @ntptime.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtp_hdrext_get_ntp_64 (gpointer data, guint size, guint64 * ntptime)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (size >= GST_RTP_HDREXT_NTP_64_SIZE, FALSE);
|
||||||
|
|
||||||
|
if (ntptime)
|
||||||
|
*ntptime = GST_READ_UINT64_BE (data);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_hdrext_set_ntp_56:
|
||||||
|
* @data: the data to write to
|
||||||
|
* @size: the size of @data
|
||||||
|
* @ntptime: the NTP time
|
||||||
|
*
|
||||||
|
* Writes the NTP time in @ntptime to the format required for the NTP-56 header
|
||||||
|
* extension. @data must hold at least #GST_RTP_HDREXT_NTP_56_SIZE bytes.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtp_hdrext_set_ntp_56 (gpointer data, guint size, guint64 ntptime)
|
||||||
|
{
|
||||||
|
guint8 *d = data;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (size >= GST_RTP_HDREXT_NTP_56_SIZE, FALSE);
|
||||||
|
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
d[6 - i] = ntptime & 0xff;
|
||||||
|
ntptime >>= 8;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_rtp_hdrext_get_ntp_56:
|
||||||
|
* @data: the data to read from
|
||||||
|
* @size: the size of @data
|
||||||
|
* @ntptime: the result NTP time
|
||||||
|
*
|
||||||
|
* Reads the NTP time from the @size NTP-56 extension bytes in @data and store the
|
||||||
|
* result in @ntptime.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gst_rtp_hdrext_get_ntp_56 (gpointer data, guint size, guint64 * ntptime)
|
||||||
|
{
|
||||||
|
guint8 *d = data;
|
||||||
|
|
||||||
|
g_return_val_if_fail (data != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (size >= GST_RTP_HDREXT_NTP_56_SIZE, FALSE);
|
||||||
|
|
||||||
|
if (ntptime) {
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
*ntptime = 0;
|
||||||
|
for (i = 0; i < 7; i++) {
|
||||||
|
*ntptime |= d[6 - i];
|
||||||
|
*ntptime <<= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
50
gst-libs/gst/rtp/gstrtphdrext.h
Normal file
50
gst-libs/gst/rtp/gstrtphdrext.h
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
/* GStreamer
|
||||||
|
* Copyright (C) <2012> Wim Taymans <wim.taymans@gmail.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
|
||||||
|
|
||||||
|
gboolean gst_rtp_hdrext_set_ntp_64 (gpointer data, guint size, guint64 ntptime);
|
||||||
|
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
|
||||||
|
|
||||||
|
gboolean gst_rtp_hdrext_set_ntp_56 (gpointer data, guint size, guint64 ntptime);
|
||||||
|
gboolean gst_rtp_hdrext_get_ntp_56 (gpointer data, guint size, guint64 *ntptime);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __GST_RTPHDREXT_H__ */
|
||||||
|
|
Loading…
Reference in a new issue