[vlc-devel] [vlc-commits] m3u: remove HLS checks

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Sep 29 10:22:53 CEST 2020


On Mon, Sep 28, 2020, at 5:09 PM, Rémi Denis-Courmont wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 
> 27 12:37:53 2020 +0300| [0b67edc914a9678ad5ab74e3bc0bd5d68f4da46b] | 
> committer: Rémi Denis-Courmont
> 
> m3u: remove HLS checks
> 
> The M3U parser has lower priority than the adaptive module. If we get an
> M3U input here, it's either not HLS or HLS support is not installed.
> 
> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0b67edc914a9678ad5ab74e3bc0bd5d68f4da46b
> ---
> 
>  modules/demux/playlist/m3u.c | 58 ++++----------------------------------------
>  1 file changed, 5 insertions(+), 53 deletions(-)
> 
> diff --git a/modules/demux/playlist/m3u.c b/modules/demux/playlist/m3u.c
> index 73156cf3ed..038e2077d1 100644
> --- a/modules/demux/playlist/m3u.c
> +++ b/modules/demux/playlist/m3u.c
> @@ -52,24 +52,6 @@ static char *CheckUnicode (const char *str)
>      return IsUTF8 (str) ? strdup (str): NULL;
>  }
>  
> -static bool IsHLS(const unsigned char *buf, size_t length)
> -{
> -    static const char *const hlsexts[] =
> -    {
> -        "#EXT-X-MEDIA:",
> -        "#EXT-X-VERSION:",
> -        "#EXT-X-TARGETDURATION:",
> -        "#EXT-X-MEDIA-SEQUENCE:",
> -        "#EXT-X-STREAM-INF:",
> -    };
> -
> -    for (size_t i = 0; i < ARRAY_SIZE(hlsexts); i++)
> -        if (strnstr((const char *)buf, hlsexts[i], length) != NULL)
> -            return true;
> -
> -    return false;
> -}
> -
>  /*****************************************************************************
>   * Import_M3U: main import function
>   *****************************************************************************/
> @@ -101,41 +83,11 @@ int Import_M3U( vlc_object_t *p_this )
>          i_peek -= offset;
>      }
>  
> -    /* File type: playlist, or not (HLS manifest or whatever else) */
> -    char *type = stream_MimeType(p_stream->s);
> -    bool match;
> -
> -    if (p_stream->obj.force)
> -        match = true;
> -    else
> -    if (type != NULL
> -     && !vlc_ascii_strcasecmp(type, "application/vnd.apple.mpegurl")) /* HLS */
> -        match = false;
> -    else
> -    if (memcmp(p_peek, "#EXTM3U", 7 ) == 0
> -     || (type != NULL
> -      && (vlc_ascii_strcasecmp(type, "application/mpegurl") == 0
> -       || vlc_ascii_strcasecmp(type, "application/x-mpegurl") == 0
> -       || vlc_ascii_strcasecmp(type, "audio/mpegurl") == 0
> -       || vlc_ascii_strcasecmp(type, "vnd.apple.mpegURL") == 0
> -       || vlc_ascii_strcasecmp(type, "audio/x-mpegurl") == 0))
> -     || stream_HasExtension(p_stream, ".m3u8")
> -     || stream_HasExtension(p_stream, ".m3u"))
> -        match = !IsHLS(p_peek, i_peek);
> -    else
> -    if (stream_HasExtension(p_stream, ".vlc")
> -     || strncasecmp((const char *)p_peek, "RTSPtext", 8) == 0
> -     || ContainsURL(p_peek, i_peek))
> -        match = true;
> -    else
> -        match = false;
> -
> -    free(type);
> -
> -    if (!match)
> -        return VLC_EGENERIC;
> -
> -    if (offset != 0 && vlc_stream_Seek(p_stream->s, offset))
> +    if (!p_stream->obj.force
> +     && memcmp(p_peek, "#EXTM3U", 7 ) != 0
> +     && !stream_HasExtension(p_stream, ".vlc")
> +     && strncasecmp((const char *)p_peek, "RTSPtext", 8) != 0
> +     && !ContainsURL(p_peek, i_peek))
>          return VLC_EGENERIC;
>  
>      msg_Dbg( p_stream, "found valid M3U playlist" );
> 

Hi,

This appears to make m3u playlists not starting by '#EXTM3U' rejected by the playlist demux, while they were accepted before, most likely because .m3u extensions didn't require that directive.

Any objection about re-adding an explicit extension check in order to restore the previous behavior?

-- 
  Hugo Beauzée-Luyssen
  hugo at beauzee.fr


More information about the vlc-devel mailing list