[vlc-commits] vlc_stream: add stream_MimeType

Filip Roséen git at videolan.org
Wed Mar 22 08:23:51 CET 2017


vlc | branch: master | Filip Roséen <filip at atch.se> | Wed Mar 22 04:38:33 2017 +0100| [56f202f9effc70a227a1295f20da6bda9c2d1d27] | committer: Rémi Denis-Courmont

vlc_stream: add stream_MimeType

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).

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=56f202f9effc70a227a1295f20da6bda9c2d1d27
---

 include/vlc_stream.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index 3a6d6cc..a2a8406 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



More information about the vlc-commits mailing list