Skip to content
Snippets Groups Projects
Commit c5b37cb4 authored by François Cartegnie's avatar François Cartegnie :fingers_crossed:
Browse files

demux: hls: set channels

parent a54d02b0
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,11 @@ void CodecDescription::setSampleRate(const Rate &r)
fmt.audio.i_rate = r.num();
}
void CodecDescription::setChannelsCount(unsigned c)
{
fmt.audio.i_channels = c;
}
CodecDescriptionList::CodecDescriptionList()
{
......
......@@ -44,6 +44,7 @@ namespace adaptive
void setAspectRatio(const AspectRatio &);
void setFrameRate(const Rate &);
void setSampleRate(const Rate &);
void setChannelsCount(unsigned);
protected:
es_format_t fmt;
......
......@@ -173,6 +173,7 @@ int M3U8MasterPlaylist_test()
Expect(fmt->i_codec == fns.getFmt()->i_codec);
Expect(fmt->i_profile == fns.getFmt()->i_profile);
Expect(fmt->i_cat == AUDIO_ES);
Expect(fmt->audio.i_channels == 2);
delete m3u;
}
......@@ -221,6 +222,7 @@ int M3U8MasterPlaylist_test()
Expect(fmt != nullptr);
Expect(fmt->i_codec == fns.getFmt()->i_codec);
Expect(fmt->i_cat == AUDIO_ES);
Expect(fmt->audio.i_channels == 2);
}
{
......
......@@ -45,6 +45,7 @@ HLSRepresentation::HLSRepresentation ( BaseAdaptationSet *set ) :
lastUpdateTime = 0;
targetDuration = 0;
streamFormat = StreamFormat::Type::Unknown;
channels = 0;
}
HLSRepresentation::~HLSRepresentation ()
......@@ -175,6 +176,21 @@ bool HLSRepresentation::canNoLongerUpdate() const
return updateFailureCount > MAX_UPDATE_FAILED_UPDATE_COUNT;
}
void HLSRepresentation::setChannelsCount(unsigned c)
{
channels = c;
}
CodecDescription * HLSRepresentation::makeCodecDescription(const std::string &s) const
{
CodecDescription *desc = BaseRepresentation::makeCodecDescription(s);
if(desc)
{
desc->setChannelsCount(channels);
}
return desc;
}
uint64_t HLSRepresentation::translateSegmentNumber(uint64_t num, const BaseRepresentation *from) const
{
if(targetDuration == static_cast<const HLSRepresentation *>(from)->targetDuration)
......
......@@ -54,6 +54,9 @@ namespace hls
virtual bool canNoLongerUpdate() const override;
virtual uint64_t translateSegmentNumber(uint64_t, const BaseRepresentation *) const override;
virtual CodecDescription * makeCodecDescription(const std::string &) const override;
void setChannelsCount(unsigned);
protected:
time_t targetDuration;
......@@ -66,6 +69,7 @@ namespace hls
bool b_loaded;
unsigned updateFailureCount;
vlc_tick_t lastUpdateTime;
unsigned channels;
};
}
}
......
......@@ -160,10 +160,17 @@ void M3U8Parser::createAndFillRepresentation(vlc_object_t *p_obj, BaseAdaptation
}
}
void M3U8Parser::fillRepresentationFromMediainfo(const AttributesTag *,
void M3U8Parser::fillRepresentationFromMediainfo(const AttributesTag *mediatag,
const std::string &type,
HLSRepresentation *rep)
{
if(type == "AUDIO")
{
const Attribute *channelsAttr = mediatag->getAttributeByName("CHANNELS");
if(channelsAttr)
rep->setChannelsCount(std::atoi(channelsAttr->quotedString().c_str()));
}
if(type != "AUDIO" && type != "VIDEO")
{
rep->streamFormat = StreamFormat(StreamFormat::Type::Unsupported);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment