@@ -46,24 +46,74 @@ std::string CovertFpsToString(float value)
4646 return str;
4747}
4848
49+ void ReplacePhValue (std::string& text,
50+ const std::string& phTextPart,
51+ const std::string& phName,
52+ const std::string& value)
53+ {
54+ std::string result;
55+ if (!value.empty ())
56+ {
57+ result = phTextPart;
58+ STRING::ReplaceFirst (result, phName, value);
59+ // Placeholder contained within other parentheses e.g.: {some text {ph} some text}
60+ if (result.front () == ' {' )
61+ result.erase (0 , 1 );
62+ if (result.back () == ' }' )
63+ result.pop_back ();
64+ }
65+ STRING::ReplaceFirst (text, phTextPart, result);
66+ }
67+
4968std::string CreateStreamName (const CRepresentation* repr)
5069{
5170 std::string streamName{kodi::addon::GetLocalizedString (30232 )};
52- STRING::ReplaceFirst (streamName, " {codec}" , CODEC::GetVideoDesc (repr->GetCodecs ()));
71+ const std::vector<std::string> phs = STRING::ExtractPlaceholders (streamName, ' {' , ' }' );
72+
73+ for (const std::string& ph : phs)
74+ {
75+ if (STRING::Contains (ph, " {codec}" , true ))
76+ {
77+ ReplacePhValue (streamName, ph, " {codec}" , CODEC::GetVideoDesc (repr->GetCodecs ()));
78+ }
79+ else if (STRING::Contains (ph, " {hdr-type}" , true ))
80+ {
81+ std::string hdrType;
82+ const ColorTRC colorTrc = repr->GetColorTRC ();
83+ if (colorTrc == ColorTRC::SMPTE2084)
84+ {
85+ if (CODEC::Contains (repr->GetCodecs (), CODEC::FOURCC_DVH1) ||
86+ CODEC::Contains (repr->GetCodecs (), CODEC::FOURCC_DVHE))
87+ {
88+ hdrType = " DV" ;
89+ }
90+ else
91+ {
92+ hdrType = " HDR10" ;
93+ }
94+ }
95+ if (colorTrc == ColorTRC::ARIB_STD_B67)
96+ hdrType = " HLG" ;
5397
54- float fps{static_cast <float >(repr->GetFrameRate ())};
55- if (fps > 0 && repr->GetFrameRateScale () > 0 )
56- fps /= repr->GetFrameRateScale ();
98+ ReplacePhValue (streamName, ph, " {hdr-type}" , hdrType);
99+ }
100+ else if (STRING::Contains (ph, " {quality}" , true ))
101+ {
102+ float fps{static_cast <float >(repr->GetFrameRate ())};
103+ if (fps > 0 && repr->GetFrameRateScale () > 0 )
104+ fps /= repr->GetFrameRateScale ();
57105
58- std::string quality = " (" ;
59- if (repr->GetWidth () > 0 && repr->GetHeight () > 0 )
60- quality += StringUtils::Format (" %ix%i, " , repr->GetWidth (), repr->GetHeight ());
61- if (fps > 0 )
62- quality += StringUtils::Format (" %s fps, " , CovertFpsToString (fps).c_str ());
106+ std::string quality = " (" ;
107+ if (repr->GetWidth () > 0 && repr->GetHeight () > 0 )
108+ quality += StringUtils::Format (" %ix%i, " , repr->GetWidth (), repr->GetHeight ());
109+ if (fps > 0 )
110+ quality += StringUtils::Format (" %s fps, " , CovertFpsToString (fps).c_str ());
63111
64- quality += StringUtils::Format (" %u Kbps)" , repr->GetBandwidth () / 1000 );
65- STRING::ReplaceFirst (streamName, " {quality}" , quality);
112+ quality += StringUtils::Format (" %u Kbps)" , repr->GetBandwidth () / 1000 );
66113
114+ ReplacePhValue (streamName, ph, " {quality}" , quality);
115+ }
116+ }
67117 return streamName;
68118}
69119} // unnamed namespace
0 commit comments