Commit b4b58db6 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: adaptive: move mime to format conversion

(cherry picked from commit 8f095301)
parent 882083b7
......@@ -23,6 +23,7 @@
#endif
#include "StreamFormat.hpp"
#include <algorithm>
using namespace adaptive;
......@@ -58,6 +59,26 @@ StreamFormat::StreamFormat( unsigned formatid_ )
formatid = formatid_;
}
StreamFormat::StreamFormat( const std::string &mimetype )
{
std::string mime = mimetype;
std::transform(mime.begin(), mime.end(), mime.begin(), ::tolower);
std::string::size_type pos = mime.find("/");
formatid = UNSUPPORTED;
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
formatid = StreamFormat::MP4;
else if (tail == "mp2t")
formatid = StreamFormat::MPEG2TS;
else if (tail == "vtt")
formatid = StreamFormat::WEBVTT;
else if (tail == "ttml+xml")
formatid = StreamFormat::TTML;
}
}
StreamFormat::~StreamFormat()
{
......
......@@ -37,6 +37,7 @@ namespace adaptive
static const unsigned UNKNOWN = 0xFF; /* will probe */
StreamFormat( unsigned = UNSUPPORTED );
explicit StreamFormat( const std::string &mime );
~StreamFormat();
operator unsigned() const;
std::string str() const;
......
......@@ -27,6 +27,7 @@
#include <vlc_stream.h>
#include <vlc_demux.h>
#include "SourceStream.hpp"
#include "../StreamFormat.hpp"
#include "CommandsQueue.hpp"
#include "../ChunksSource.hpp"
......
......@@ -46,7 +46,7 @@ AdaptationSet::~AdaptationSet()
StreamFormat AdaptationSet::getStreamFormat() const
{
if(!getMimeType().empty())
return MPD::mimeToFormat(getMimeType());
return StreamFormat(getMimeType());
else
return BaseAdaptationSet::getStreamFormat();
}
......
......@@ -65,24 +65,6 @@ Profile MPD::getProfile() const
return profile;
}
StreamFormat MPD::mimeToFormat(const std::string &mime)
{
std::string::size_type pos = mime.find("/");
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
return StreamFormat(StreamFormat::MP4);
else if (tail == "mp2t")
return StreamFormat(StreamFormat::MPEG2TS);
else if (tail == "vtt")
return StreamFormat(StreamFormat::WEBVTT);
else if (tail == "ttml+xml")
return StreamFormat(StreamFormat::TTML);
}
return StreamFormat();
}
void MPD::debug()
{
msg_Dbg(p_object, "MPD profile=%s mediaPresentationDuration=%" PRId64
......
......@@ -48,8 +48,6 @@ namespace dash
virtual bool isLive() const;
virtual void debug();
static StreamFormat mimeToFormat(const std::string &);
Property<ProgramInformation *> programInfo;
private:
......
......@@ -51,9 +51,9 @@ Representation::~Representation ()
StreamFormat Representation::getStreamFormat() const
{
if(getMimeType().empty())
return MPD::mimeToFormat(adaptationSet->getMimeType());
return StreamFormat(adaptationSet->getMimeType());
else
return MPD::mimeToFormat(getMimeType());
return StreamFormat(getMimeType());
}
TrickModeType* Representation::getTrickModeType () const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment