vlc/vlc-3.0 | branch: master | Francois Cartegnie <[email protected]> | Tue Feb 20 22:38:05 2018 +0100| [66df1d290c76202b8ff446f2dc687b570f246dd0] | committer: Francois Cartegnie
demux: adaptive: expose content-type (cherry picked from commit 1fdf88d7ed5fd90b835d83652a32ad40daaa82fd) > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=66df1d290c76202b8ff446f2dc687b570f246dd0 --- modules/demux/adaptive/http/HTTPConnection.cpp | 18 ++++++++++++++++++ modules/demux/adaptive/http/HTTPConnection.hpp | 2 ++ 2 files changed, 20 insertions(+) diff --git a/modules/demux/adaptive/http/HTTPConnection.cpp b/modules/demux/adaptive/http/HTTPConnection.cpp index c324b257e3..b24eb87212 100644 --- a/modules/demux/adaptive/http/HTTPConnection.cpp +++ b/modules/demux/adaptive/http/HTTPConnection.cpp @@ -59,6 +59,11 @@ size_t AbstractConnection::getContentLength() const return contentLength; } +const std::string & AbstractConnection::getContentType() const +{ + return contentType; +} + HTTPConnection::HTTPConnection(vlc_object_t *p_object_, AuthStorage *auth, Socket *socket_, const ConnectionParams &proxy, bool persistent) : AbstractConnection( p_object_ ) @@ -123,6 +128,7 @@ void HTTPConnection::disconnect() chunked = false; chunkLength = 0; bytesRange = BytesRange(); + contentType = std::string(); socket->disconnect(); } @@ -380,6 +386,10 @@ void HTTPConnection::onHeader(const std::string &key, { chunked = true; } + else if(key == "Content-Type") + { + contentType = value; + } else if(key == "Location") { locationparams = ConnectionParams(); @@ -464,6 +474,7 @@ void StreamUrlConnection::reset() p_streamurl = NULL; bytesRead = 0; contentLength = 0; + contentType = std::string(); bytesRange = BytesRange(); } @@ -486,6 +497,13 @@ int StreamUrlConnection::request(const std::string &path, const BytesRange &rang if(!p_streamurl) return VLC_EGENERIC; + char *psz_type = stream_ContentType(p_streamurl); + if(psz_type) + { + contentType = std::string(psz_type); + free(psz_type); + } + stream_t *p_chain = vlc_stream_FilterNew( p_streamurl, "inflate" ); if( p_chain ) p_streamurl = p_chain; diff --git a/modules/demux/adaptive/http/HTTPConnection.hpp b/modules/demux/adaptive/http/HTTPConnection.hpp index ce19cb166d..c006a06808 100644 --- a/modules/demux/adaptive/http/HTTPConnection.hpp +++ b/modules/demux/adaptive/http/HTTPConnection.hpp @@ -50,6 +50,7 @@ namespace adaptive virtual ssize_t read (void *p_buffer, size_t len) = 0; virtual size_t getContentLength() const; + virtual const std::string & getContentType() const; virtual void setUsed( bool ) = 0; protected: @@ -57,6 +58,7 @@ namespace adaptive ConnectionParams params; bool available; size_t contentLength; + std::string contentType; BytesRange bytesRange; size_t bytesRead; }; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
