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 7ed74bc169549b0922411dd30f2c74fd3ec205d2..ec1776ca1226232251e50f2c3fb99a789396e77e 100644 --- a/modules/demux/adaptive/test/playlist/M3U8.cpp +++ b/modules/demux/adaptive/test/playlist/M3U8.cpp @@ -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); } { diff --git a/modules/demux/hls/playlist/HLSRepresentation.cpp b/modules/demux/hls/playlist/HLSRepresentation.cpp index ce48b9f4b77d5cd592256dc9e4ed406f05a1551c..fb2e01bcc4a55a5633f7b7666fda0fc8f3602207 100644 --- a/modules/demux/hls/playlist/HLSRepresentation.cpp +++ b/modules/demux/hls/playlist/HLSRepresentation.cpp @@ -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) diff --git a/modules/demux/hls/playlist/HLSRepresentation.hpp b/modules/demux/hls/playlist/HLSRepresentation.hpp index 888277ddae509f28e695667490db6286dde92231..e3064078f7211ac7cea8f4cabf3a8b8b5f1b8821 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; vlc_tick_t lastUpdateTime; + unsigned channels; }; } } diff --git a/modules/demux/hls/playlist/Parser.cpp b/modules/demux/hls/playlist/Parser.cpp index 6ed7fccebe8927733127761c983286bdf9873156..c4b1f26682c0b9dc70e2613ca15ecc7b8bfead40 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") { rep->streamFormat = StreamFormat(StreamFormat::Type::Unsupported);