google / ExoPlayer

This project is deprecated and stale. The latest ExoPlayer code is available in https://github.com/androidx/media
https://developer.android.com/media/media3/exoplayer
Apache License 2.0
21.75k stars 6.03k forks source link

Opportunity for passing IcyDecoder encoding as argument #9438

Open meh111 opened 3 years ago

meh111 commented 3 years ago

Looking into IcyDecoder class, two hardcoder charset decoders: private final CharsetDecoder utf8Decoder; private final CharsetDecoder iso88591Decoder;

please, provide customization for charset. I know many icecast streams that use other encodings. like this http://176.65.38.3:8000/blagovest provides metadata in windows-1251

ojw28 commented 3 years ago

I wonder if this should be handled similarly to https://github.com/google/ExoPlayer/issues/6753

meh111 commented 3 years ago

iso88591Decoder doesn't always throw CharacterCodingException. For example, it provides wrong decoded string from windows-1251 encoded bytes. So another try at the end won't work

icbaker commented 3 years ago

I think there's some overlap between this and the heuristic charset detection for SubRip subtitles discussion in https://github.com/google/ExoPlayer/issues/3644#issuecomment-423931864.

In both cases I suppose there are two situations:

  1. The app knows what charset to use and can pass it in directly.
  2. The app wants to enable heuristic detection (and all the additional deps that implies).

It seems likely that solving (1) (as requested here) is useful both in the ICY and SubRip case (and anywhere else we process text data with ambiguous or under-specced charset).

And equally if we did implement my CharsetDetector-based suggestion for SubRip in https://github.com/google/ExoPlayer/issues/3644#issuecomment-565503504 then we could use it for ICY as well.

For this specific change to IcyDecoder: We would accept a high-quality PR adding the ability to pass the CharsetDecoder into its constructor.