summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-10-01 11:55:24 -0500
committerDudemanguy <random342@airmail.cc>2023-10-07 02:41:27 +0000
commite22efe2d221ec668cb362c6ce4e4ebb974bf1ce7 (patch)
tree3ed8e4a52585737299b65458945bd836a5ab8cc1
parentef4a5101289b485ceafdcad599329437bf411b93 (diff)
downloadmpv-e22efe2d221ec668cb362c6ce4e4ebb974bf1ce7.tar.bz2
mpv-e22efe2d221ec668cb362c6ce4e4ebb974bf1ce7.tar.xz
stream_lavf: use metadata-codepage option for codepage conversion
a343666ab5121e7a3388be9aa2d8731d6d1f2f64 made demux options public, so we can take advantage of that here as well. This lets users guess the codepage if the stream doesn't use UTF-8 characters. Fixes #8844.
-rw-r--r--stream/stream_lavf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 0164ede388..08b61ab445 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -26,6 +26,8 @@
#include "common/msg.h"
#include "common/tags.h"
#include "common/av_common.h"
+#include "demux/demux.h"
+#include "misc/charset_conv.h"
#include "misc/thread_tools.h"
#include "stream.h"
#include "options/m_config.h"
@@ -403,7 +405,21 @@ static struct mp_tags *read_icy(stream_t *s)
packet = bstr_cut(packet, i + head.len);
int end = bstr_find(packet, bstr0("\';"));
packet = bstr_splice(packet, 0, end);
+
+ bool allocated = false;
+ struct demux_opts *opts = mp_get_config_group(NULL, s->global, &demux_conf);
+ const char *charset = mp_charset_guess(s, s->log, packet, opts->meta_cp, 0);
+ if (charset && !mp_charset_is_utf8(charset)) {
+ bstr conv = mp_iconv_to_utf8(s->log, packet, charset, 0);
+ if (conv.start && conv.start != packet.start) {
+ allocated = true;
+ packet = conv;
+ }
+ }
mp_tags_set_bstr(res, bstr0("icy-title"), packet);
+ talloc_free(opts);
+ if (allocated)
+ talloc_free(packet.start);
}
av_opt_set(avio, "icy_metadata_packet", "-", AV_OPT_SEARCH_CHILDREN);