From f5e6395409e110adbcd12993aae738345bf9c2a6 Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Sun, 10 Jan 2021 21:12:45 +0100 Subject: [PATCH] Flatpak: fix parsing of matroska attachments mimetypes --- ...bad-assrender-fix-mimetype-detection.patch | 89 +++++++++++++++++++ .../gstreamer-1.0/gst-plugins-bad.json | 4 + ...ood-matroska-set-attachment-mimetype.patch | 36 ++++++++ .../gstreamer-1.0/gst-plugins-good.json | 4 + 4 files changed, 133 insertions(+) create mode 100644 pkgs/flatpak/gstreamer-1.0/gst-plugins-bad-assrender-fix-mimetype-detection.patch create mode 100644 pkgs/flatpak/gstreamer-1.0/gst-plugins-good-matroska-set-attachment-mimetype.patch diff --git a/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad-assrender-fix-mimetype-detection.patch b/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad-assrender-fix-mimetype-detection.patch new file mode 100644 index 00000000..661002e3 --- /dev/null +++ b/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad-assrender-fix-mimetype-detection.patch @@ -0,0 +1,89 @@ +From ab9ceccc8b7f0591f580abfa6901d27c49812a94 Mon Sep 17 00:00:00 2001 +From: Rafostar <40623528+Rafostar@users.noreply.github.com> +Date: Sun, 10 Jan 2021 20:22:43 +0100 +Subject: [PATCH 1/2] assrender: fix mimetype detection + +Previously gst_structure_has_name was used to get a string to compare with supported mimetypes. +This is incorrect as above function returns a user defined structure name which is +not the structure mimetype value. +--- + ext/assrender/gstassrender.c | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +diff --git a/ext/assrender/gstassrender.c b/ext/assrender/gstassrender.c +index e6d31985b..a69d3fe78 100644 +--- a/ext/assrender/gstassrender.c ++++ b/ext/assrender/gstassrender.c +@@ -1557,7 +1557,7 @@ gst_ass_render_handle_tag_sample (GstAssRender * render, GstSample * sample) + const GstStructure *structure; + gboolean valid_mimetype, valid_extension; + guint i; +- const gchar *filename; ++ const gchar *mimetype, *filename; + + buf = gst_sample_get_buffer (sample); + structure = gst_sample_get_info (sample); +@@ -1565,20 +1565,23 @@ gst_ass_render_handle_tag_sample (GstAssRender * render, GstSample * sample) + if (!buf || !structure) + return; + ++ filename = gst_structure_get_string (structure, "filename"); ++ if (!filename) ++ return; ++ + valid_mimetype = FALSE; + valid_extension = FALSE; + +- for (i = 0; i < G_N_ELEMENTS (mimetypes); i++) { +- if (gst_structure_has_name (structure, mimetypes[i])) { +- valid_mimetype = TRUE; +- break; ++ mimetype = gst_structure_get_string (structure, "mimetype"); ++ if (mimetype) { ++ for (i = 0; i < G_N_ELEMENTS (mimetypes); i++) { ++ if (strcmp (mimetype, mimetypes[i]) == 0) { ++ valid_mimetype = TRUE; ++ break; ++ } + } + } + +- filename = gst_structure_get_string (structure, "filename"); +- if (!filename) +- return; +- + if (!valid_mimetype) { + guint len = strlen (filename); + const gchar *extension = filename + len - 4; +-- +2.28.0 + + +From fd7d46171b2abcd3ac247491f01a91444e7b95b2 Mon Sep 17 00:00:00 2001 +From: Rafostar <40623528+Rafostar@users.noreply.github.com> +Date: Sun, 10 Jan 2021 20:26:58 +0100 +Subject: [PATCH 2/2] assrender: add "vnd.ms-opentype" to supported mimetypes + +The "application/vnd.ms-opentype" mimetype is commonly used mimetype +for fonts with .otf extension, handle it without checking the file extension. +--- + ext/assrender/gstassrender.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/ext/assrender/gstassrender.c b/ext/assrender/gstassrender.c +index a69d3fe78..96b062c50 100644 +--- a/ext/assrender/gstassrender.c ++++ b/ext/assrender/gstassrender.c +@@ -1546,7 +1546,8 @@ gst_ass_render_handle_tag_sample (GstAssRender * render, GstSample * sample) + static const gchar *mimetypes[] = { + "application/x-font-ttf", + "application/x-font-otf", +- "application/x-truetype-font" ++ "application/x-truetype-font", ++ "application/vnd.ms-opentype" + }; + static const gchar *extensions[] = { + ".otf", +-- +2.28.0 + diff --git a/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad.json b/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad.json index 1b4184fb..e9948710 100644 --- a/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad.json +++ b/pkgs/flatpak/gstreamer-1.0/gst-plugins-bad.json @@ -40,6 +40,10 @@ { "type": "patch", "path": "gst-plugins-bad-assrender-smooth-scaling.patch" + }, + { + "type": "patch", + "path": "gst-plugins-bad-assrender-fix-mimetype-detection.patch" } ] } diff --git a/pkgs/flatpak/gstreamer-1.0/gst-plugins-good-matroska-set-attachment-mimetype.patch b/pkgs/flatpak/gstreamer-1.0/gst-plugins-good-matroska-set-attachment-mimetype.patch new file mode 100644 index 00000000..4ab7e78b --- /dev/null +++ b/pkgs/flatpak/gstreamer-1.0/gst-plugins-good-matroska-set-attachment-mimetype.patch @@ -0,0 +1,36 @@ +From 4e5b2b0c3aeefffdd9613e33678cade25fac3fe4 Mon Sep 17 00:00:00 2001 +From: Rafostar +Date: Sun, 10 Jan 2021 19:55:31 +0100 +Subject: [PATCH] matroska: treat non-image structure as attachment and set + mimetype + +Otherwise each structure is named as GstTagImageInfo even if it does not contain any images +which is misleading. Also set the structure mimetype to fix assrender fonts detection. +--- + gst/matroska/matroska-read-common.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c +index 90d6e38e1..628e19669 100644 +--- a/gst/matroska/matroska-read-common.c ++++ b/gst/matroska/matroska-read-common.c +@@ -851,10 +851,13 @@ gst_matroska_read_common_parse_attached_file (GstMatroskaReadCommon * common, + } + + /* Set filename and description in the info */ +- if (info == NULL) +- info = gst_structure_new_empty ("GstTagImageInfo"); +- ++ if (info == NULL) { ++ const gchar *structure_name = (image_type != GST_TAG_IMAGE_TYPE_NONE) ? ++ "GstTagImageInfo" : "GstTagAttachmentInfo"; ++ info = gst_structure_new_empty (structure_name); ++ } + gst_structure_set (info, "filename", G_TYPE_STRING, filename, NULL); ++ gst_structure_set (info, "mimetype", G_TYPE_STRING, mimetype, NULL); + if (description) + gst_structure_set (info, "description", G_TYPE_STRING, description, NULL); + +-- +2.28.0 + diff --git a/pkgs/flatpak/gstreamer-1.0/gst-plugins-good.json b/pkgs/flatpak/gstreamer-1.0/gst-plugins-good.json index f50f69e0..d3090cb3 100644 --- a/pkgs/flatpak/gstreamer-1.0/gst-plugins-good.json +++ b/pkgs/flatpak/gstreamer-1.0/gst-plugins-good.json @@ -36,6 +36,10 @@ { "type": "patch", "path": "gst-plugins-good-matroska-fix-attachments-detection.patch" + }, + { + "type": "patch", + "path": "gst-plugins-good-matroska-set-attachment-mimetype.patch" } ] }