[vlc-devel] [vlc-commits] stream: add stream_IsMimeType()
Steve Lhomme
robux4 at gmail.com
Tue Apr 25 11:27:37 CEST 2017
On Tue, Apr 18, 2017 at 8:41 PM, Rémi Denis-Courmont <git at videolan.org> wrote:
> vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 17 23:02:51 2017 +0300| [5bd39f0fa1aab9608e2236e2ae17f223f4bea331] | committer: Rémi Denis-Courmont
>
> stream: add stream_IsMimeType()
>
>> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5bd39f0fa1aab9608e2236e2ae17f223f4bea331
> ---
>
> include/vlc_demux.h | 11 +----------
> include/vlc_stream.h | 17 +++++++++++++++++
> 2 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/include/vlc_demux.h b/include/vlc_demux.h
> index 3f7f139d48..5c89b30324 100644
> --- a/include/vlc_demux.h
> +++ b/include/vlc_demux.h
> @@ -399,16 +399,7 @@ static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_exte
> VLC_USED
> static inline bool demux_IsContentType(demux_t *demux, const char *type)
> {
> - char *mime = stream_ContentType(demux->s);
> - if (mime == NULL)
> - return false;
> -
> - size_t len = strlen(type);
> - bool ok = strncasecmp(mime, type, len) == 0
> - && memchr("\t ;", (unsigned char)mime[len], 4) != NULL;
> -
> - free(mime);
> - return ok;
> + return stream_IsMimeType(demux->s, type);
> }
>
> VLC_USED
> diff --git a/include/vlc_stream.h b/include/vlc_stream.h
> index 6960260291..36cb9cddd0 100644
> --- a/include/vlc_stream.h
> +++ b/include/vlc_stream.h
> @@ -345,6 +345,23 @@ static inline char *stream_MimeType( stream_t *s )
> }
>
> /**
> + * Checks for a MIME type.
> + *
> + * Checks if the stream has a specific MIME type.
> + */
> +VLC_USED
> +static inline bool stream_IsMimeType(stream_t *s, const char *type)
> +{
> + char *mime = stream_MimeType(s);
> + if (mime == NULL)
> + return false;
> +
> + bool ok = strcasecmp(mime, type);
Is it ok to call strcasecmp from a public header ? Do externally built
modules have to include compat ?
> + free(mime);
> + return ok;
> +}
> +
> +/**
> * Create a stream from a memory buffer.
> *
> * \param obj parent VLC object
>
> _______________________________________________
> vlc-commits mailing list
> vlc-commits at videolan.org
> https://mailman.videolan.org/listinfo/vlc-commits
More information about the vlc-devel
mailing list