diff --git a/modules/demux/adaptive/playlist/CodecDescription.cpp b/modules/demux/adaptive/playlist/CodecDescription.cpp index 52f49a18921c4142be8ecaa81531b5bc99866c03..9261c2f24c2cad8e405f1681eafa0a0256c06a29 100644 --- a/modules/demux/adaptive/playlist/CodecDescription.cpp +++ b/modules/demux/adaptive/playlist/CodecDescription.cpp @@ -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() { diff --git a/modules/demux/adaptive/playlist/CodecDescription.hpp b/modules/demux/adaptive/playlist/CodecDescription.hpp index c6cd4c650fcc22dd2819925a1fa4a25aaf661e33..47fd6a0635173a72f17b4ff27b1b78bdced0fa81 100644 --- a/modules/demux/adaptive/playlist/CodecDescription.hpp +++ b/modules/demux/adaptive/playlist/CodecDescription.hpp @@ -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; diff --git a/modules/demux/adaptive/test/playlist/M3U8.cpp b/modules/demux/adaptive/test/playlist/M3U8.cpp index a863be79f088291ef26b7471c90fc2aeace4fd78..928becb764ff34631d90c9d567347071bb1df703 100644 --- a/modules/demux/adaptive/test/playlist/M3U8.cpp +++ b/modules/demux/adaptive/test/playlist/M3U8.cpp @@ -176,6 +176,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; } @@ -224,6 +225,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); } { diff --git a/modules/demux/hls/playlist/HLSRepresentation.cpp b/modules/demux/hls/playlist/HLSRepresentation.cpp index 238f5265666a13b2644e92936182f069ebc7b91f..09fe22d515ce6ebc0f163f0003aab2882f1c12ad 100644 --- a/modules/demux/hls/playlist/HLSRepresentation.cpp +++ b/modules/demux/hls/playlist/HLSRepresentation.cpp @@ -48,6 +48,7 @@ HLSRepresentation::HLSRepresentation ( BaseAdaptationSet *set ) : lastUpdateTime = 0; targetDuration = 0; streamFormat = StreamFormat::Type::Unknown; + channels = 0; } HLSRepresentation::~HLSRepresentation () @@ -178,6 +179,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) diff --git a/modules/demux/hls/playlist/HLSRepresentation.hpp b/modules/demux/hls/playlist/HLSRepresentation.hpp index f60113f0bebfe56fa3a50a083f50af15228f3b90..d3955841341fb8c8c1734389f6da033e050d52b0 100644 --- a/modules/demux/hls/playlist/HLSRepresentation.hpp +++ b/modules/demux/hls/playlist/HLSRepresentation.hpp @@ -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; mtime_t lastUpdateTime; + unsigned channels; }; } } diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp index c007286b5c46da4393ba4a5770b7553928785827..9d1dd5d5bd3c08f15ca27b4d4fa2d406ef2a58a0 100644 --- a/modules/demux/hls/playlist/Parser.cpp +++ b/modules/demux/hls/playlist/Parser.cpp @@ -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" && type != "SUBTITLES") { rep->streamFormat = StreamFormat(StreamFormat::Type::Unsupported);