Commit a047b31b authored by François Cartegnie's avatar François Cartegnie 🤞
Browse files

demux: hls: use probed format only

parent b21dbcde
......@@ -88,7 +88,7 @@ SegmentTracker::SegmentTracker(SharedResources *res,
curRepresentation = NULL;
setAdaptationLogic(logic_);
adaptationSet = adaptSet;
format = StreamFormat::UNSUPPORTED;
format = StreamFormat::UNKNOWN;
}
SegmentTracker::~SegmentTracker()
......@@ -134,7 +134,7 @@ void SegmentTracker::reset()
init_sent = false;
index_sent = false;
initializing = true;
format = StreamFormat::UNSUPPORTED;
format = StreamFormat::UNKNOWN;
}
SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
......@@ -201,7 +201,7 @@ SegmentChunk * SegmentTracker::getNextChunk(bool switch_allowed,
if(rep->getStreamFormat() != format)
{
/* Initial format ? */
if(format == StreamFormat(StreamFormat::UNSUPPORTED))
if(format == StreamFormat(StreamFormat::UNKNOWN))
{
format = rep->getStreamFormat();
}
......
......@@ -42,7 +42,7 @@ using namespace adaptive::http;
AbstractStream::AbstractStream(demux_t * demux_)
{
p_realdemux = demux_;
format = StreamFormat::UNSUPPORTED;
format = StreamFormat::UNKNOWN;
currentChunk = NULL;
eof = false;
valid = true;
......
......@@ -163,11 +163,11 @@ AbstractDemuxer *HLSStream::newDemux(demux_t *p_realdemux, const StreamFormat &f
return ret;
}
AbstractStream * HLSStreamFactory::create(demux_t *realdemux, const StreamFormat &,
AbstractStream * HLSStreamFactory::create(demux_t *realdemux, const StreamFormat &format,
SegmentTracker *tracker, AbstractConnectionManager *manager) const
{
HLSStream *stream = new (std::nothrow) HLSStream(realdemux);
if(stream && !stream->init(StreamFormat(StreamFormat::UNKNOWN), tracker, manager))
if(stream && !stream->init(format, tracker, manager))
{
delete stream;
return NULL;
......
......@@ -87,36 +87,6 @@ static void releaseTagsList(std::list<Tag *> &list)
list.clear();
}
void M3U8Parser::setFormatFromExtension(Representation *rep, const std::string &filename)
{
std::size_t pos = filename.find_last_of('.');
if(pos != std::string::npos)
{
std::string extension = Helper::getFileExtension(filename);
transform(extension.begin(), extension.end(), extension.begin(), (int (*)(int))std::tolower);
if(extension == "aac")
{
rep->streamFormat = StreamFormat(StreamFormat::PACKEDAAC);
}
else if(extension == "ts" || extension == "mp2t" || extension == "mpeg" || extension == "m2ts")
{
rep->streamFormat = StreamFormat(StreamFormat::MPEG2TS);
}
else if(extension == "mp4" || extension == "m4s" || extension == "mov" || extension == "m4v")
{
rep->streamFormat = StreamFormat(StreamFormat::MP4);
}
else if(extension == "vtt" || extension == "wvtt" || extension == "webvtt")
{
rep->streamFormat = StreamFormat(StreamFormat::WEBVTT);
}
else
{
rep->streamFormat = StreamFormat(StreamFormat::UNKNOWN);
}
}
}
Representation * M3U8Parser::createRepresentation(BaseAdaptationSet *adaptSet, const AttributesTag * tag)
{
const Attribute *uriAttr = tag->getAttributeByName("URI");
......@@ -293,8 +263,6 @@ void M3U8Parser::parseSegments(vlc_object_t *, Representation *rep, const std::l
break;
segment->setSourceUrl(uritag->getValue().value);
if((unsigned)rep->getStreamFormat() == StreamFormat::UNKNOWN)
setFormatFromExtension(rep, uritag->getValue().value);
/* Need to use EXTXTARGETDURATION as default as some can't properly set segment one */
double duration = rep->targetDuration;
......
......@@ -65,7 +65,6 @@ namespace hls
void createAndFillRepresentation(vlc_object_t *, BaseAdaptationSet *,
const AttributesTag *, const std::list<Tag *>&);
void parseSegments(vlc_object_t *, Representation *, const std::list<Tag *>&);
void setFormatFromExtension(Representation *rep, const std::string &);
std::list<Tag *> parseEntries(stream_t *);
adaptive::SharedResources *resources;
};
......
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