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

demux: hls: EXTINF as modifier tag, and add URI

Otherwise breaks if modifiers between EXTINF and
uri value line.
parent cc0304ca
......@@ -192,6 +192,7 @@ void Parser::parseSegments(Representation *rep, const std::list<Tag *> &tagslist
std::size_t prevbyterangeoffset = 0;
const SingleValueTag *ctx_byterange = NULL;
SegmentEncryption encryption;
const ValuesListTag *ctx_extinf = NULL;
std::list<Tag *>::const_iterator it;
for(it = tagslist.begin(); it != tagslist.end(); ++it)
......@@ -206,22 +207,38 @@ void Parser::parseSegments(Representation *rep, const std::list<Tag *> &tagslist
}
break;
case URITag::EXTINF:
case ValuesListTag::EXTINF:
{
const URITag *uritag = static_cast<const URITag *>(tag);
ctx_extinf = static_cast<const ValuesListTag *>(tag);
}
break;
case SingleValueTag::URI:
{
const SingleValueTag *uritag = static_cast<const SingleValueTag *>(tag);
if(uritag->getValue().value.empty())
{
ctx_extinf = NULL;
ctx_byterange = NULL;
break;
}
HLSSegment *segment = new (std::nothrow) HLSSegment(rep, sequenceNumber++);
if(!segment)
break;
if(uritag->getAttributeByName("URI"))
segment->setSourceUrl(uritag->getAttributeByName("URI")->value);
segment->setSourceUrl(uritag->getValue().value);
if(uritag->getAttributeByName("DURATION"))
if(ctx_extinf)
{
segment->duration.Set(uritag->getAttributeByName("DURATION")->floatingPoint() * rep->timescale.Get());
segment->startTime.Set(nzStartTime);
nzStartTime += segment->duration.Get();
totalduration += segment->duration.Get();
if(ctx_extinf->getAttributeByName("DURATION"))
{
segment->duration.Set(ctx_extinf->getAttributeByName("DURATION")->floatingPoint() * rep->timescale.Get());
segment->startTime.Set(nzStartTime);
nzStartTime += segment->duration.Get();
totalduration += segment->duration.Get();
}
ctx_extinf = NULL;
}
segmentList->addSegment(segment);
......@@ -453,14 +470,22 @@ std::list<Tag *> Parser::parseEntries(stream_t *stream)
}
}
}
else if(*psz_line && lastTag)
else if(*psz_line)
{
AttributesTag *attrTag = dynamic_cast<AttributesTag *>(lastTag);
if(attrTag)
/* URI */
if(lastTag && lastTag->getType() == AttributesTag::EXTXSTREAMINF)
{
AttributesTag *streaminftag = static_cast<AttributesTag *>(lastTag);
/* master playlist uri, merge as attribute */
Attribute *uriAttr = new (std::nothrow) Attribute("URI", std::string(psz_line));
if(uriAttr)
attrTag->addAttribute(uriAttr);
streaminftag->addAttribute(uriAttr);
}
else /* playlist tag, will take modifiers */
{
Tag *tag = TagFactory::createTagByName("", std::string(psz_line));
if(tag)
entrieslist.push_back(tag);
}
lastTag = NULL;
}
......
......@@ -245,16 +245,16 @@ void AttributesTag::parseAttributes(const std::string &field)
}
URITag::URITag(const std::string &v) : AttributesTag(URITag::EXTINF, v)
ValuesListTag::ValuesListTag(int type, const std::string &v) : AttributesTag(type, v)
{
parseAttributes(v);
}
URITag::~URITag()
ValuesListTag::~ValuesListTag()
{
}
void URITag::parseAttributes(const std::string &field)
void ValuesListTag::parseAttributes(const std::string &field)
{
std::size_t pos = field.find(',');
if(pos != std::string::npos)
......@@ -289,7 +289,8 @@ Tag * TagFactory::createTagByName(const std::string &name, const std::string &va
{"EXT-X-I-FRAMES-ONLY", Tag::EXTXIFRAMESONLY},
{"EXT-X-MEDIA", AttributesTag::EXTXMEDIA},
{"EXT-X-STREAM-INF", AttributesTag::EXTXSTREAMINF},
{"EXTINF", URITag::EXTINF},
{"EXTINF", ValuesListTag::EXTINF},
{"", SingleValueTag::URI},
{NULL, 0},
};
......@@ -306,6 +307,7 @@ Tag * TagFactory::createTagByName(const std::string &name, const std::string &va
case Tag::EXTXIFRAMESONLY:
return new (std::nothrow) Tag(exttagmapping[i].i);
case SingleValueTag::URI:
case SingleValueTag::EXTXVERSION:
case SingleValueTag::EXTXBYTERANGE:
case SingleValueTag::EXTXPROGRAMDATETIME:
......@@ -315,14 +317,14 @@ Tag * TagFactory::createTagByName(const std::string &name, const std::string &va
case SingleValueTag::EXTXPLAYLISTTYPE:
return new (std::nothrow) SingleValueTag(exttagmapping[i].i, value);
case ValuesListTag::EXTINF:
return new (std::nothrow) ValuesListTag(exttagmapping[i].i, value);
case AttributesTag::EXTXKEY:
case AttributesTag::EXTXMAP:
case AttributesTag::EXTXMEDIA:
case AttributesTag::EXTXSTREAMINF:
return new (std::nothrow) AttributesTag(exttagmapping[i].i, value);
case URITag::EXTINF:
return new URITag(value);
}
}
......
......@@ -75,7 +75,8 @@ namespace hls
public:
enum
{
EXTXVERSION = 10,
URI = 10,
EXTXVERSION,
EXTXBYTERANGE,
EXTXPROGRAMDATETIME,
EXTXTARGETDURATION,
......@@ -110,15 +111,15 @@ namespace hls
std::list<Attribute *> attributes;
};
class URITag : public AttributesTag
class ValuesListTag : public AttributesTag
{
public:
enum
{
EXTINF = 30
};
URITag(const std::string &);
virtual ~URITag();
ValuesListTag(int, const std::string &);
virtual ~ValuesListTag();
protected:
virtual void parseAttributes(const std::string &);
......
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