Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AdaptiveTree] On parsers use "und" language code for unknown cases #1731

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,13 @@ void SESSION::CSession::AddStream(PLAYLIST::CAdaptationSet* adp,

stream.m_info.SetFlags(flags);
stream.m_info.SetPhysicalIndex(uniqueId);
stream.m_info.SetLanguage(adp->GetLanguage());

std::string langCode = adp->GetLanguage();
if (langCode.empty() && stream.m_info.GetStreamType() != INPUTSTREAM_TYPE_VIDEO)
langCode = LANG_CODE::UNDETERMINED;

stream.m_info.SetLanguage(langCode);

stream.m_info.ClearExtraData();
stream.m_info.SetFeatures(0);

Expand Down
3 changes: 3 additions & 0 deletions src/parser/DASHTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,10 @@ void adaptive::CDashTree::ParseTagAdaptationSet(pugi::xml_node nodeAdp, PLAYLIST
}

adpSet->SetGroup(XML::GetAttrib(nodeAdp, "group"));

// Language code format IETF RFC 5646 (BCP-47)
adpSet->SetLanguage(XML::GetAttrib(nodeAdp, "lang"));

adpSet->SetName(XML::GetAttrib(nodeAdp, "name"));
adpSet->SetResWidth(XML::GetAttribInt(nodeAdp, "width"));
adpSet->SetResHeight(XML::GetAttribInt(nodeAdp, "height"));
Expand Down
8 changes: 4 additions & 4 deletions src/parser/HLSTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,7 @@ bool adaptive::CHLSTree::ParseRenditon(const Rendition& r,
return false;

adpSet->SetStreamType(streamType);
adpSet->SetLanguage(r.m_language.empty() ? "unk" : r.m_language);
adpSet->SetLanguage(r.m_language);
adpSet->SetName(r.m_name);
adpSet->SetIsDefault(r.m_isDefault);
adpSet->SetIsForced(r.m_isForced);
Expand Down Expand Up @@ -1479,7 +1479,7 @@ bool adaptive::CHLSTree::ParseMultivariantPlaylist(const std::string& data)
rend.m_type = attribs["TYPE"];
rend.m_groupId = attribs["GROUP-ID"];
rend.m_name = attribs["NAME"];
rend.m_language = attribs["LANGUAGE"];
rend.m_language = attribs["LANGUAGE"]; // Language code format IETF RFC 5646 (BCP-47)
if (streamType == StreamType::AUDIO)
{
rend.m_channels = STRING::ToUint32(attribs["CHANNELS"], 2);
Expand Down Expand Up @@ -1699,7 +1699,7 @@ bool adaptive::CHLSTree::ParseMultivariantPlaylist(const std::string& data)
// Initialize a rendition with generic info
Rendition r;
r.m_channels = 2;
r.m_language = "unk";
r.m_language = LANG_CODE::UNDETERMINED;
r.m_type = "AUDIO";

if (!var.m_groupIdAudio.empty())
Expand Down Expand Up @@ -1820,7 +1820,7 @@ void adaptive::CHLSTree::AddIncludedAudioStream(std::unique_ptr<PLAYLIST::CPerio
auto newAdpSet = CAdaptationSet::MakeUniquePtr(period.get());
newAdpSet->SetStreamType(StreamType::AUDIO);
newAdpSet->SetContainerType(ContainerType::MP4);
newAdpSet->SetLanguage("unk"); // Unknown
newAdpSet->SetLanguage(LANG_CODE::UNDETERMINED);

auto repr = CRepresentation::MakeUniquePtr(newAdpSet.get());
repr->SetTimescale(TIMESCALE);
Expand Down
1 change: 1 addition & 0 deletions src/parser/SmoothTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ void adaptive::CSmoothTree::ParseTagStreamIndex(pugi::xml_node nodeSI,
STRING::ToHexadecimal(protParser.GetKID()));
}

// Language code format ISO 639-2
adpSet->SetLanguage(XML::GetAttrib(nodeSI, "Language"));

// Default frequency 10000000 (10Khz)
Expand Down
5 changes: 5 additions & 0 deletions src/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ uint64_t GetTimestampMs();
*/
std::vector<uint8_t> ZeroPadding(const std::vector<uint8_t>& data, const size_t padSize);

namespace LANG_CODE
{
constexpr const char* UNDETERMINED = "und"; // Kodi language code for unknown language
}

namespace CODEC
{
constexpr const char* NAME_UNKNOWN = "unk"; // Kodi codec name for unknown codec
Expand Down
Loading