[vlc-commits] stream: add stream_IsMimeType()
Rémi Denis-Courmont
git at videolan.org
Tue Apr 18 20:56:14 CEST 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Apr 17 23:02:51 2017 +0300| [7c8871b13d8095f6f141f3f172f414c8775abef9] | committer: Rémi Denis-Courmont
stream: add stream_IsMimeType()
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7c8871b13d8095f6f141f3f172f414c8775abef9
---
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);
+ free(mime);
+ return ok;
+}
+
+/**
* Create a stream from a memory buffer.
*
* \param obj parent VLC object
More information about the vlc-commits
mailing list