flvmux: use version template in metadata creator properties

Avoids documentation churn when the version changes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5090>
This commit is contained in:
Tim-Philipp Müller 2023-08-05 17:27:31 +01:00 committed by GStreamer Marge Bot
parent e1d4b546c0
commit be2a3780c1
2 changed files with 23 additions and 13 deletions

View file

@ -7252,7 +7252,7 @@
"construct": false,
"construct-only": false,
"controllable": false,
"default": "GStreamer 1.23.0.1 FLV muxer",
"default": "GStreamer {VERSION} FLV muxer",
"mutable": "null",
"readable": true,
"type": "gchararray",
@ -7264,7 +7264,7 @@
"construct": false,
"construct-only": false,
"controllable": false,
"default": "GStreamer 1.23.0.1 FLV muxer",
"default": "GStreamer {VERSION} FLV muxer",
"mutable": "null",
"readable": true,
"type": "gchararray",

View file

@ -47,6 +47,8 @@
#include "gstflvmux.h"
#include "amfdefs.h"
#include <gst/glib-compat-private.h>
GST_DEBUG_CATEGORY_STATIC (flvmux_debug);
#define GST_CAT_DEFAULT flvmux_debug
@ -61,7 +63,7 @@ enum
#define DEFAULT_STREAMABLE FALSE
#define MAX_INDEX_ENTRIES 128
#define DEFAULT_METADATACREATOR "GStreamer " PACKAGE_VERSION " FLV muxer"
#define DEFAULT_METADATACREATOR "GStreamer {VERSION} FLV muxer"
#define DEFAULT_SKIP_BACKWARDS_STREAMS FALSE
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src",
@ -1125,30 +1127,38 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
tags_written++;
}
_gst_buffer_new_and_alloc (2 + 15 + 1 + 2 + strlen (mux->metadatacreator),
&tmp, &data);
GString *tag_string = g_string_new (mux->metadatacreator);
g_string_replace (tag_string, "{VERSION}", PACKAGE_VERSION, 0);
_gst_buffer_new_and_alloc (2 + 15 + 1 + 2 + tag_string->len, &tmp, &data);
data[0] = 0; /* 15 bytes name */
data[1] = 15;
memcpy (&data[2], "metadatacreator", 15);
data[17] = 2; /* string */
data[18] = (strlen (mux->metadatacreator) >> 8) & 0xff;
data[19] = (strlen (mux->metadatacreator)) & 0xff;
memcpy (&data[20], mux->metadatacreator, strlen (mux->metadatacreator));
data[18] = (tag_string->len >> 8) & 0xff;
data[19] = tag_string->len & 0xff;
memcpy (&data[20], tag_string->str, tag_string->len);
script_tag = gst_buffer_append (script_tag, tmp);
tags_written++;
_gst_buffer_new_and_alloc (2 + 7 + 1 + 2 + strlen (mux->encoder),
&tmp, &data);
g_string_truncate (tag_string, 0);
g_string_append (tag_string, mux->encoder);
g_string_replace (tag_string, "{VERSION}", PACKAGE_VERSION, 0);
_gst_buffer_new_and_alloc (2 + 7 + 1 + 2 + tag_string->len, &tmp, &data);
data[0] = 0; /* 7 bytes name */
data[1] = 7;
memcpy (&data[2], "encoder", 7);
data[9] = 2; /* string */
data[10] = (strlen (mux->encoder) >> 8) & 0xff;
data[11] = (strlen (mux->encoder)) & 0xff;
memcpy (&data[12], mux->encoder, strlen (mux->encoder));
data[10] = (tag_string->len >> 8) & 0xff;
data[11] = tag_string->len & 0xff;
memcpy (&data[12], tag_string->str, tag_string->len);
script_tag = gst_buffer_append (script_tag, tmp);
tags_written++;
g_string_free (tag_string, TRUE);
tag_string = NULL;
{
time_t secs;
struct tm tm;