Commit 3a7ecded authored by François Cartegnie's avatar François Cartegnie 🤞

demux: hls: add basic support for init segments

parent b4b87526
......@@ -137,18 +137,6 @@ void HLSSegment::setEncryption(SegmentEncryption &enc)
encryption = enc;
}
void HLSSegment::debug(vlc_object_t *obj, int indent) const
{
std::stringstream ss;
ss.imbue(std::locale("C"));
ss << std::string(indent, ' ') << debugName <<
" #" << (getSequenceNumber() - Segment::SEQUENCE_FIRST) <<
" url=" << getUrlSegment().toString();
if(startByte!=endByte)
ss << " @" << startByte << ".." << endByte;
msg_Dbg(obj, "%s", ss.str().c_str());
}
int HLSSegment::compare(ISegment *segment) const
{
HLSSegment *hlssegment = dynamic_cast<HLSSegment *>(segment);
......
......@@ -55,7 +55,6 @@ namespace hls
virtual ~HLSSegment();
void setEncryption(SegmentEncryption &);
mtime_t getUTCTime() const;
void debug(vlc_object_t *, int) const; /* reimpl */
virtual int compare(ISegment *) const; /* reimpl */
protected:
......
......@@ -332,6 +332,29 @@ void M3U8Parser::parseSegments(vlc_object_t *p_obj, Representation *rep, const s
}
break;
case AttributesTag::EXTXMAP:
{
const AttributesTag *keytag = static_cast<const AttributesTag *>(tag);
const Attribute *uriAttr;
if(keytag && (uriAttr = keytag->getAttributeByName("URI")) &&
!segmentList->initialisationSegment.Get()) /* FIXME: handle discontinuities */
{
InitSegment *initSegment = new (std::nothrow) InitSegment(rep);
if(initSegment)
{
initSegment->setSourceUrl(uriAttr->quotedString());
const Attribute *byterangeAttr = keytag->getAttributeByName("BYTERANGE");
if(byterangeAttr)
{
const std::pair<std::size_t,std::size_t> range = byterangeAttr->unescapeQuotes().getByteRange();
initSegment->setByteRange(range.first, range.first + range.second - 1);
}
segmentList->initialisationSegment.Set(initSegment);
}
}
}
break;
case Tag::EXTXDISCONTINUITY:
discontinuity = true;
break;
......
......@@ -111,6 +111,11 @@ std::pair<int, int> Attribute::getResolution() const
return std::make_pair(w, h);
}
Attribute Attribute::unescapeQuotes() const
{
return Attribute(this->name, quotedString());
}
std::string Attribute::quotedString() const
{
if(value.length() < 2)
......
......@@ -38,6 +38,7 @@ namespace hls
public:
Attribute(const std::string &, const std::string &);
Attribute unescapeQuotes() const;
uint64_t decimal() const;
std::string quotedString() const;
double floatingPoint() 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