[vlc-devel] [PATCH 1/3] vlc_stream: add stream_MimeType

Filip Roséen filip at atch.se
Wed Mar 22 04:38:33 CET 2017


As there is quite common for stream-consumers to be interested in the
associated mime-type, if any, of a stream; this helper function allows
access to that directly (instead of consumers having to manually parse
the string returned by stream_ContentType).
---
 include/vlc_stream.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 3a6d6ccd0e..a2a84065f8 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -328,6 +328,22 @@ static inline char *stream_ContentType( stream_t *s )
 }
 
 /**
+ * Get the mime-type of a stream
+ *
+ * \warning the returned resource is to be freed by the caller
+ * \return the mime-type, or `NULL` if unknown
+ **/
+static inline char *stream_MimeType( stream_t *s )
+{
+    char* mime_type = stream_ContentType( s );
+
+    if( mime_type ) /* strip parameters */
+        mime_type[strcspn( mime_type, " ;" )] = '\0';
+
+    return mime_type;
+}
+
+/**
  * Create a stream from a memory buffer.
  *
  * \param obj parent VLC object
-- 
2.12.0


More information about the vlc-devel mailing list