mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
rtspsink: use version template in user-agent property
Avoids documentation churn when the version changes. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5090>
This commit is contained in:
parent
be2a3780c1
commit
e21242aba6
3 changed files with 94 additions and 5 deletions
|
@ -333,7 +333,7 @@
|
|||
"construct": false,
|
||||
"construct-only": false,
|
||||
"controllable": false,
|
||||
"default": "GStreamer/1.23.0.1",
|
||||
"default": "GStreamer/{VERSION}",
|
||||
"mutable": "null",
|
||||
"readable": true,
|
||||
"type": "gchararray",
|
||||
|
|
83
subprojects/gst-rtsp-server/gst/glib-compat-private.h
Normal file
83
subprojects/gst-rtsp-server/gst/glib-compat-private.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* glib-compat.c
|
||||
* Functions copied from glib 2.10
|
||||
*
|
||||
* Copyright 2005 David Schleef <ds@schleef.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 __GLIB_COMPAT_PRIVATE_H__
|
||||
#define __GLIB_COMPAT_PRIVATE_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* copies */
|
||||
|
||||
#if !GLIB_CHECK_VERSION(2,68,0)
|
||||
#ifndef g_string_replace
|
||||
#define g_string_replace gst_g_string_replace
|
||||
#endif
|
||||
|
||||
static inline guint
|
||||
gst_g_string_replace (GString *string,
|
||||
const gchar *find,
|
||||
const gchar *replace,
|
||||
guint limit)
|
||||
{
|
||||
gsize f_len, r_len, pos;
|
||||
gchar *cur, *next;
|
||||
guint n = 0;
|
||||
|
||||
g_return_val_if_fail (string != NULL, 0);
|
||||
g_return_val_if_fail (find != NULL, 0);
|
||||
g_return_val_if_fail (replace != NULL, 0);
|
||||
|
||||
f_len = strlen (find);
|
||||
r_len = strlen (replace);
|
||||
cur = string->str;
|
||||
|
||||
while ((next = strstr (cur, find)) != NULL)
|
||||
{
|
||||
pos = next - string->str;
|
||||
g_string_erase (string, pos, f_len);
|
||||
g_string_insert (string, pos, replace);
|
||||
cur = string->str + pos + r_len;
|
||||
n++;
|
||||
/* Only match the empty string once at any given position, to
|
||||
* avoid infinite loops */
|
||||
if (f_len == 0)
|
||||
{
|
||||
if (cur[0] == '\0')
|
||||
break;
|
||||
else
|
||||
cur++;
|
||||
}
|
||||
if (n == limit)
|
||||
break;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
#endif /* GLIB_CHECK_VERSION */
|
||||
|
||||
/* adaptations */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
|
@ -101,6 +101,8 @@
|
|||
|
||||
#include "gstrtspclientsink.h"
|
||||
|
||||
#include "../glib-compat-private.h"
|
||||
|
||||
typedef struct _GstRtspClientSinkPad GstRtspClientSinkPad;
|
||||
typedef GstGhostPadClass GstRtspClientSinkPadClass;
|
||||
|
||||
|
@ -301,7 +303,7 @@ gst_rtsp_client_sink_ntp_time_source_get_type (void)
|
|||
#define DEFAULT_TLS_DATABASE NULL
|
||||
#define DEFAULT_TLS_INTERACTION NULL
|
||||
#define DEFAULT_NTP_TIME_SOURCE NTP_TIME_SOURCE_NTP
|
||||
#define DEFAULT_USER_AGENT "GStreamer/" PACKAGE_VERSION
|
||||
#define DEFAULT_USER_AGENT "GStreamer/{VERSION}"
|
||||
#define DEFAULT_PROFILES GST_RTSP_PROFILE_AVP
|
||||
#define DEFAULT_RTX_TIME_MS 500
|
||||
#define DEFAULT_PUBLISH_CLOCK_MODE GST_RTSP_PUBLISH_CLOCK_MODE_CLOCK
|
||||
|
@ -2166,9 +2168,13 @@ gst_rtsp_client_sink_init_request (GstRTSPClientSink * sink,
|
|||
return res;
|
||||
|
||||
/* set user-agent */
|
||||
if (sink->user_agent)
|
||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_USER_AGENT,
|
||||
sink->user_agent);
|
||||
if (sink->user_agent) {
|
||||
GString *user_agent = g_string_new (sink->user_agent);
|
||||
|
||||
g_string_replace (user_agent, "{VERSION}", PACKAGE_VERSION, 0);
|
||||
gst_rtsp_message_add_header (msg, GST_RTSP_HDR_USER_AGENT, user_agent->str);
|
||||
g_string_free (user_agent, TRUE);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue