Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2132>
#include "rtpsession.h"
#include "gstrtpsession.h"
#include "gstrtpjitterbuffer.h"
+#include "gstrtputils.h"
#include <gst/glib-compat-private.h>
if (bin->use_pipeline_clock) {
ntpns = rt;
/* add constant to convert from 1970 based time to 1900 based time */
- ntpns += (2208988800LL * GST_SECOND);
+ ntpns += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
} else {
switch (bin->ntp_time_source) {
case GST_RTP_NTP_TIME_SOURCE_NTP:
/* add constant to convert from 1970 based time to 1900 based time */
if (bin->ntp_time_source == GST_RTP_NTP_TIME_SOURCE_NTP)
- ntpns += (2208988800LL * GST_SECOND);
+ ntpns += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
break;
}
case GST_RTP_NTP_TIME_SOURCE_RUNNING_TIME:
#include <gst/rtp/gstrtphdrext.h>
#include "gstrtpfunnel.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY_STATIC (gst_rtp_funnel_debug);
#define GST_CAT_DEFAULT gst_rtp_funnel_debug
gst_rtp_header_extension_set_id (funnel->twcc_ext, twcc_ext_id);
}
-static guint8
-_get_extmap_id_for_attribute (const GstStructure * s, const gchar * ext_name)
-{
- guint i;
- guint8 extmap_id = 0;
- guint n_fields = gst_structure_n_fields (s);
-
- for (i = 0; i < n_fields; i++) {
- const gchar *field_name = gst_structure_nth_field_name (s, i);
- if (g_str_has_prefix (field_name, "extmap-")) {
- const gchar *str = gst_structure_get_string (s, field_name);
- if (str && g_strcmp0 (str, ext_name) == 0) {
- gint64 id = g_ascii_strtoll (field_name + 7, NULL, 10);
- if (id > 0 && id < 15) {
- extmap_id = id;
- break;
- }
- }
- }
- }
- return extmap_id;
-}
-
#define TWCC_EXTMAP_STR "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"
static gboolean
funnel->twcc_ext =
gst_rtp_header_extension_create_from_uri (TWCC_EXTMAP_STR);
- ext_id = _get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
+ ext_id = gst_rtp_get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
if (ext_id > 0) {
fpad->has_twcc = TRUE;
funnel->twcc_pads++;
#include "rtpjitterbuffer.h"
#include "rtpstats.h"
#include "rtptimerqueue.h"
+#include "gstrtputils.h"
#include <gst/glib-compat-private.h>
}
}
-static guint8
-_get_extmap_id_for_attribute (const GstStructure * s, const gchar * ext_name)
-{
- guint i;
- guint8 extmap_id = 0;
- guint n_fields = gst_structure_n_fields (s);
-
- for (i = 0; i < n_fields; i++) {
- const gchar *field_name = gst_structure_nth_field_name (s, i);
- if (g_str_has_prefix (field_name, "extmap-")) {
- const gchar *str = gst_structure_get_string (s, field_name);
- if (str && g_strcmp0 (str, ext_name) == 0) {
- gint64 id = g_ascii_strtoll (field_name + 7, NULL, 10);
- if (id > 0 && id < 15) {
- extmap_id = id;
- break;
- }
- }
- }
- }
- return extmap_id;
-}
-
/*
* Must be called with JBUF_LOCK held
*/
_get_cname_ssrc_mappings (jitterbuffer, caps_struct);
priv->ntp64_ext_id =
- _get_extmap_id_for_attribute (caps_struct,
+ gst_rtp_get_extmap_id_for_attribute (caps_struct,
GST_RTP_HDREXT_BASE GST_RTP_HDREXT_NTP_64);
return TRUE;
#include "gstrtpsession.h"
#include "rtpsession.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY_STATIC (gst_rtp_session_debug);
#define GST_CAT_DEFAULT gst_rtp_session_debug
if (rtpsession->priv->use_pipeline_clock) {
ntpns = rt;
/* add constant to convert from 1970 based time to 1900 based time */
- ntpns += (2208988800LL * GST_SECOND);
+ ntpns += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
} else {
switch (rtpsession->priv->ntp_time_source) {
case GST_RTP_NTP_TIME_SOURCE_NTP:
/* add constant to convert from 1970 based time to 1900 based time */
if (rtpsession->priv->ntp_time_source == GST_RTP_NTP_TIME_SOURCE_NTP)
- ntpns += (2208988800LL * GST_SECOND);
+ ntpns += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
break;
}
case GST_RTP_NTP_TIME_SOURCE_RUNNING_TIME:
if (rtpsession->priv->use_pipeline_clock) {
ntpnstime = running_time;
/* add constant to convert from 1970 based time to 1900 based time */
- ntpnstime += (2208988800LL * GST_SECOND);
+ ntpnstime += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
} else {
switch (rtpsession->priv->ntp_time_source) {
case GST_RTP_NTP_TIME_SOURCE_NTP:
if (ntpnstime != GST_CLOCK_TIME_NONE
&& rtpsession->priv->ntp_time_source ==
GST_RTP_NTP_TIME_SOURCE_NTP)
- ntpnstime += (2208988800LL * GST_SECOND);
+ ntpnstime += (GST_RTP_NTP_UNIX_OFFSET * GST_SECOND);
break;
}
case GST_RTP_NTP_TIME_SOURCE_RUNNING_TIME:
--- /dev/null
+/* GStreamer
+ * Copyright (C) 2022 Sebastian Dröge <sebastian@centricular.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.
+ */
+
+#include "gstrtputils.h"
+
+guint8
+gst_rtp_get_extmap_id_for_attribute (const GstStructure * s,
+ const gchar * ext_name)
+{
+ guint i;
+ guint8 extmap_id = 0;
+ guint n_fields = gst_structure_n_fields (s);
+
+ for (i = 0; i < n_fields; i++) {
+ const gchar *field_name = gst_structure_nth_field_name (s, i);
+ if (g_str_has_prefix (field_name, "extmap-")) {
+ const gchar *str = gst_structure_get_string (s, field_name);
+ if (str && g_strcmp0 (str, ext_name) == 0) {
+ gint64 id = g_ascii_strtoll (field_name + 7, NULL, 10);
+ if (id > 0 && id < 15) {
+ extmap_id = id;
+ break;
+ }
+ }
+ }
+ }
+ return extmap_id;
+}
--- /dev/null
+/* GStreamer
+ * Copyright (C) 2022 Sebastian Dröge <sebastian@centricular.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_UTILS_H__
+#define __GST_RTP_UTILS_H__
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+#define GST_RTP_NTP_UNIX_OFFSET (2208988800LL)
+
+G_GNUC_INTERNAL guint8
+gst_rtp_get_extmap_id_for_attribute (const GstStructure * s, const gchar * ext_name);
+
+G_END_DECLS
+
+#endif /* __GST_RTP_UTILS_H__ */
'gstrtpsession.c',
'gstrtpfunnel.c',
'gstrtpst2022-1-fecdec.c',
- 'gstrtpst2022-1-fecenc.c'
+ 'gstrtpst2022-1-fecenc.c',
+ 'gstrtputils.c'
]
gstrtpmanager = library('gstrtpmanager',
#include <gst/glib-compat-private.h>
#include "rtpsession.h"
+#include "gstrtputils.h"
GST_DEBUG_CATEGORY (rtp_session_debug);
#define GST_CAT_DEFAULT rtp_session_debug
}
}
-static guint8
-_get_extmap_id_for_attribute (const GstStructure * s, const gchar * ext_name)
-{
- guint i;
- guint8 extmap_id = 0;
- guint n_fields = gst_structure_n_fields (s);
-
- for (i = 0; i < n_fields; i++) {
- const gchar *field_name = gst_structure_nth_field_name (s, i);
- if (g_str_has_prefix (field_name, "extmap-")) {
- const gchar *str = gst_structure_get_string (s, field_name);
- if (str && g_strcmp0 (str, ext_name) == 0) {
- gint64 id = g_ascii_strtoll (field_name + 7, NULL, 10);
- if (id > 0 && id < 15) {
- extmap_id = id;
- break;
- }
- }
- }
- }
- return extmap_id;
-}
-
/**
* rtp_session_update_send_caps:
* @sess: an #RTPSession
}
sess->send_ntp64_ext_id =
- _get_extmap_id_for_attribute (s,
+ gst_rtp_get_extmap_id_for_attribute (s,
GST_RTP_HDREXT_BASE GST_RTP_HDREXT_NTP_64);
rtp_twcc_manager_parse_send_ext_id (sess->twcc, s);
#include <gst/base/gstbitreader.h>
#include <gst/base/gstbitwriter.h>
+#include "gstrtputils.h"
+
GST_DEBUG_CATEGORY_EXTERN (rtp_session_debug);
#define GST_CAT_DEFAULT rtp_session_debug
packet->ts = pinfo->current_time;
}
-static guint8
-_get_extmap_id_for_attribute (const GstStructure * s, const gchar * ext_name)
-{
- guint i;
- guint8 extmap_id = 0;
- guint n_fields = gst_structure_n_fields (s);
-
- for (i = 0; i < n_fields; i++) {
- const gchar *field_name = gst_structure_nth_field_name (s, i);
- if (g_str_has_prefix (field_name, "extmap-")) {
- const gchar *str = gst_structure_get_string (s, field_name);
- if (str && g_strcmp0 (str, ext_name) == 0) {
- gint64 id = g_ascii_strtoll (field_name + 7, NULL, 10);
- if (id > 0 && id < 15) {
- extmap_id = id;
- break;
- }
- }
- }
- }
- return extmap_id;
-}
-
void
rtp_twcc_manager_parse_recv_ext_id (RTPTWCCManager * twcc,
const GstStructure * s)
{
- guint8 recv_ext_id = _get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
+ guint8 recv_ext_id = gst_rtp_get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
if (recv_ext_id > 0) {
twcc->recv_ext_id = recv_ext_id;
GST_INFO ("TWCC enabled for recv using extension id: %u",
rtp_twcc_manager_parse_send_ext_id (RTPTWCCManager * twcc,
const GstStructure * s)
{
- guint8 send_ext_id = _get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
+ guint8 send_ext_id = gst_rtp_get_extmap_id_for_attribute (s, TWCC_EXTMAP_STR);
if (send_ext_id > 0) {
twcc->send_ext_id = send_ext_id;
GST_INFO ("TWCC enabled for send using extension id: %u",