Commit 945f6e08 authored by François Cartegnie's avatar François Cartegnie 🤞

demux: dash: add Stream::Format

Not mandatory to be mp4
parent 697f59f9
......@@ -66,10 +66,10 @@ bool DASHManager::start(demux_t *demux)
const AdaptationSet *set = period->getAdaptationSet(type);
if(set)
{
streams[type] = new Streams::Stream(type);
streams[type] = new Streams::Stream(set->getMimeType());
try
{
streams[type]->init(demux, AdaptationLogicFactory::create( logicType, mpd ) );
streams[type]->create(demux, AdaptationLogicFactory::create( logicType, mpd ) );
} catch (int) {
delete streams[type];
streams[type] = NULL;
......
......@@ -30,17 +30,18 @@ using namespace dash::logic;
Stream::Stream(const std::string &mime)
{
init(mimeToType(mime));
init(mimeToType(mime), mimeToFormat(mime));
}
Stream::Stream(const Type type)
Stream::Stream(const Type type, const Format format)
{
init(type);
init(type, format);
}
void Stream::init(const Type type_)
void Stream::init(const Type type_, const Format format_)
{
type = type_;
format = format_;
output = NULL;
currentChunk = NULL;
eof = false;
......@@ -56,21 +57,42 @@ Stream::~Stream()
Type Stream::mimeToType(const std::string &mime)
{
Type mimetype;
if (mime == "video/mp4")
if (!mime.compare(0, 6, "video/"))
mimetype = Streams::VIDEO;
else if (mime == "audio/mp4")
else if (!mime.compare(0, 6, "audio/"))
mimetype = Streams::AUDIO;
else if (mime == "application/mp4")
else if (!mime.compare(0, 12, "application/"))
mimetype = Streams::APPLICATION;
else /* unknown of unsupported */
mimetype = Streams::UNKNOWN;
return mimetype;
}
void Stream::init(demux_t *demux, IAdaptationLogic *logic)
Format Stream::mimeToFormat(const std::string &mime)
{
Format format = Streams::UNSUPPORTED;
std::string::size_type pos = mime.find("/");
if(pos != std::string::npos)
{
std::string tail = mime.substr(pos + 1);
if(tail == "mp4")
format = Streams::MP4;
}
return format;
}
void Stream::create(demux_t *demux, IAdaptationLogic *logic)
{
output = new Streams::MP4StreamOutput(demux);
adaptationLogic = logic;
switch(format)
{
case Streams::MP4:
output = new MP4StreamOutput(demux);
break;
default:
throw VLC_EBADVAR;
break;
}
}
bool Stream::isEOF() const
......
......@@ -41,11 +41,12 @@ namespace dash
{
public:
Stream(const std::string &mime);
Stream(const Type);
Stream(const Type, const Format);
~Stream();
bool operator==(const Stream &) const;
static Type mimeToType(const std::string &mime);
void init(demux_t *, logic::IAdaptationLogic *);
static Format mimeToFormat(const std::string &mime);
void create(demux_t *, logic::IAdaptationLogic *);
bool isEOF() const;
mtime_t getPCR() const;
int getGroup() const;
......@@ -54,8 +55,9 @@ namespace dash
private:
http::Chunk *getChunk();
void init(const Type);
void init(const Type, const Format);
Type type;
Format format;
AbstractStreamOutput *output;
logic::IAdaptationLogic *adaptationLogic;
http::Chunk *currentChunk;
......
......@@ -32,6 +32,13 @@ namespace dash
APPLICATION
};
enum Format
{
UNSUPPORTED = 0,
MP4,
MPEG2TS
};
static const int count = APPLICATION + 1;
}
}
......
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