Skip to content

Commit 891c446

Browse files
committed
[ChooserTest] Add switch segment test for audio
1 parent 53f0fed commit 891c446

File tree

6 files changed

+58
-17
lines changed

6 files changed

+58
-17
lines changed

inputstream.adaptive/resources/language/resource.language.en_gb/strings.po

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ msgctxt "#30234"
308308
msgid "Switch by segments"
309309
msgstr ""
310310

311-
#. Stand for stream segments, referred to setting with label #30234
311+
#. Stand for video stream segments, referred to setting with label #30234
312312
msgctxt "#30235"
313-
msgid "Segments"
313+
msgid "Video segments (set 0 to disable)"
314314
msgstr ""
315315

316316
#. Category group title
@@ -398,3 +398,8 @@ msgstr ""
398398
msgctxt "#30309"
399399
msgid "No audio/video stream can be played."
400400
msgstr ""
401+
402+
#. Stand for audio stream segments, referred to setting with label #30234
403+
msgctxt "#30350"
404+
msgid "Audio segments (set 0 to disable)"
405+
msgstr ""

inputstream.adaptive/resources/settings.xml.in

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@
164164
<heading>30233</heading>
165165
</control>
166166
</setting>
167-
<setting parent="adaptivestream.test.mode" id="adaptivestream.test.segments" type="integer" label="30235">
167+
<setting parent="adaptivestream.test.mode" id="adaptivestream.test.segments.video" type="integer" label="30235">
168168
<level>0</level>
169169
<default>2</default>
170170
<constraints>
171-
<minimum>1</minimum>
171+
<minimum>0</minimum>
172172
<step>1</step>
173173
<maximum>2000</maximum>
174174
</constraints>
@@ -184,6 +184,26 @@
184184
<heading>30235</heading>
185185
</control>
186186
</setting>
187+
<setting parent="adaptivestream.test.mode" id="adaptivestream.test.segments.audio" type="integer" label="30350">
188+
<level>0</level>
189+
<default>0</default>
190+
<constraints>
191+
<minimum>0</minimum>
192+
<step>1</step>
193+
<maximum>2000</maximum>
194+
</constraints>
195+
<dependencies>
196+
<dependency type="visible">
197+
<and>
198+
<condition setting="adaptivestream.type">test</condition>
199+
<condition setting="adaptivestream.test.mode">switch-segments</condition>
200+
</and>
201+
</dependency>
202+
</dependencies>
203+
<control type="edit" format="integer">
204+
<heading>30350</heading>
205+
</control>
206+
</setting>
187207
</group>
188208
</category>
189209
<category id="expert" label="30120">

src/CompSettings.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,14 @@ std::string ADP::SETTINGS::CCompSettings::GetChooserTestMode() const
112112
return kodi::addon::GetSettingString("adaptivestream.test.mode");
113113
}
114114

115-
int ADP::SETTINGS::CCompSettings::GetChooserTestSegs() const
115+
int ADP::SETTINGS::CCompSettings::GetChooserTestSegsVideo() const
116116
{
117-
return kodi::addon::GetSettingInt("adaptivestream.test.segments");
117+
return kodi::addon::GetSettingInt("adaptivestream.test.segments.video");
118+
}
119+
120+
int ADP::SETTINGS::CCompSettings::GetChooserTestSegsAudio() const
121+
{
122+
return kodi::addon::GetSettingInt("adaptivestream.test.segments.audio");
118123
}
119124

120125
int ADP::SETTINGS::CCompSettings::GetMediaType() const

src/CompSettings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ class ATTR_DLL_LOCAL CCompSettings
6363
bool IsIgnoreScreenResChange() const;
6464

6565
std::string GetChooserTestMode() const;
66-
int GetChooserTestSegs() const;
66+
int GetChooserTestSegsVideo() const;
67+
int GetChooserTestSegsAudio() const;
6768

6869
// Expert settings
6970

src/common/ChooserTest.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,11 @@ void CRepresentationChooserTest::Initialize(const ADP::KODI_PROPS::ChooserProps&
4747

4848
if (m_testMode == TestMode::SWITCH_SEGMENTS)
4949
{
50-
m_segmentsLimit = settings.GetChooserTestSegs();
51-
logDetails = kodi::tools::StringUtils::Format("Segments: %i", m_segmentsLimit);
50+
m_segmentsCountByType[StreamType::VIDEO] = settings.GetChooserTestSegsVideo();
51+
m_segmentsCountByType[StreamType::AUDIO] = settings.GetChooserTestSegsAudio();
52+
logDetails = kodi::tools::StringUtils::Format(
53+
"Segments count video: %i, Segments count audio: %i",
54+
m_segmentsCountByType[StreamType::VIDEO], m_segmentsCountByType[StreamType::AUDIO]);
5255
}
5356

5457
LOG::Log(LOGDEBUG,
@@ -66,10 +69,12 @@ PLAYLIST::CRepresentation* CRepresentationChooserTest::GetNextRepresentation(
6669
{
6770
CRepresentationSelector selector(m_screenCurrentWidth, m_screenCurrentHeight);
6871
CRepresentation* nextRep{currentRep};
72+
const StreamType streamType{adp->GetStreamType()};
73+
const int maxSegCount{m_segmentsCountByType[streamType]};
6974

7075
if (!currentRep) // Startup or new period
7176
{
72-
m_segmentsElapsed = 1;
77+
m_segmentsElapsedByType[streamType] = 1;
7378

7479
if (m_testMode == TestMode::SWITCH_SEGMENTS)
7580
{
@@ -84,13 +89,14 @@ PLAYLIST::CRepresentation* CRepresentationChooserTest::GetNextRepresentation(
8489
{
8590
if (m_testMode == TestMode::SWITCH_SEGMENTS)
8691
{
87-
if (adp->GetStreamType() != StreamType::VIDEO)
92+
if (maxSegCount == 0 || (streamType != StreamType::VIDEO && streamType != StreamType::AUDIO))
8893
return currentRep;
8994

90-
m_segmentsElapsed += 1;
91-
if (m_segmentsElapsed > m_segmentsLimit)
95+
++m_segmentsElapsedByType[streamType];
96+
97+
if (m_segmentsElapsedByType[streamType] > maxSegCount)
9298
{
93-
m_segmentsElapsed = 1;
99+
m_segmentsElapsedByType[streamType] = 1;
94100
nextRep = selector.Higher(adp, currentRep);
95101
// If there are no next representations, start again from the lowest
96102
if (nextRep == currentRep)
@@ -99,7 +105,7 @@ PLAYLIST::CRepresentation* CRepresentationChooserTest::GetNextRepresentation(
99105
}
100106
}
101107

102-
if (adp->GetStreamType() == StreamType::VIDEO && currentRep)
108+
if (currentRep && maxSegCount != 0)
103109
LogDetails(currentRep, nextRep);
104110

105111
return nextRep;

src/common/ChooserTest.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
#pragma once
1010

11+
#include "AdaptiveUtils.h"
1112
#include "Chooser.h"
1213

14+
#include <unordered_map>
15+
1316
namespace CHOOSER
1417
{
1518
/*!
@@ -39,8 +42,9 @@ namespace CHOOSER
3942

4043
TestMode m_testMode{TestMode::NONE};
4144
StreamSelection m_streamSelectionMode = StreamSelection::AUTO;
42-
int m_segmentsElapsed{1};
43-
int m_segmentsLimit{1};
45+
46+
std::unordered_map<PLAYLIST::StreamType, int> m_segmentsCountByType;
47+
std::unordered_map<PLAYLIST::StreamType, int> m_segmentsElapsedByType;
4448
};
4549

4650
} // namespace CHOOSER

0 commit comments

Comments
 (0)