Skip to content

Commit 3746211

Browse files
authored
VPLAY-9274:[DASH] optimization: independent track downloads (#614)
VPLAY-9274:[DASH] optimization: independent track downloads Reason for change: Implementing independent track downloads in dash downloads Risks: Low Test Procedure: Test with all sort of DASH contents Priority: P1 Signed-off-by: Nandakishor Udiyannur Mana <[email protected]>
1 parent a017bf7 commit 3746211

File tree

72 files changed

+6166
-1892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+6166
-1892
lines changed

AampConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
447447
{0,"drmStallTimeout",eAAMPConfig_DrmStallTimeout,true,eCONFIG_RANGE_TIMEOUT},
448448
{0,"drmStartTimeout",eAAMPConfig_DrmStartTimeout,true,eCONFIG_RANGE_TIMEOUT},
449449
{0,"timeBasedBufferSeconds",eAAMPConfig_TimeBasedBufferSeconds,true,eCONFIG_RANGE_PLAYBACK_OFFSET},
450+
{DEFAULT_MAX_DOWNLOAD_BUFFER,"maxDownloadBuffer",eAAMPConfig_MaxDownloadBuffer,true,eCONFIG_RANGE_PLAYBACK_OFFSET},
450451
{DEFAULT_TELEMETRY_REPORT_INTERVAL,"telemetryInterval",eAAMPConfig_TelemetryInterval,true},
451452
{0,"rateCorrectionDelay", eAAMPConfig_RateCorrectionDelay,true},
452453
{-1,"harvestDuration",eAAMPConfig_HarvestDuration,false,eCONFIG_RANGE_HARVEST_DURATION},

AampConfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ typedef enum
290290
eAAMPConfig_DrmStallTimeout, /**< Stall Timeout for DRM license request*/
291291
eAAMPConfig_DrmStartTimeout, /**< Start Timeout for DRM license request*/
292292
eAAMPConfig_TimeBasedBufferSeconds,
293+
eAAMPConfig_MaxDownloadBuffer, /**< Max download buffer in seconds, this can be used to limit player download job scheduling for DASH*/
293294
eAAMPConfig_TelemetryInterval, /**< time interval for the telemetry reporting*/
294295
eAAMPConfig_RateCorrectionDelay, /**< Delay Rate Correction upon discontinuity in seconds */
295296
eAAMPConfig_HarvestDuration, /**< Harvest duration time */

AampDefine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#define MIN_MONITOR_AV_JUMP_THRESHOLD_MS 1 /**< minimum jump threshold to trigger MonitorAV reporting */
142142
#define MAX_MONITOR_AV_JUMP_THRESHOLD_MS 10000 /**< maximum jump threshold to trigger MonitorAV reporting */
143143
#define DEFAULT_MONITOR_AV_JUMP_THRESHOLD_MS 100 /**< default jump threshold to MonitorAV reporting */
144+
#define DEFAULT_MAX_DOWNLOAD_BUFFER 10 /**< Default maximum download buffer in seconds, this can be used to limit player download job scheduling for DASH */
144145
#define DEFAULT_MONITOR_AV_REPORTING_INTERVAL 1000 /**< time interval in ms for MonitorAV reporting */
145146

146147
// We can enable the following once we have a thread monitoring video PTS progress and triggering subtec clock fast update when we detect video freeze. Disabled it for now for brute force fast refresh..

AampDownloadInfo.hpp

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2025 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* @file AampDownloadInfo.hpp
22+
* @brief Download information for AAMP fragment downloads
23+
*/
24+
25+
#ifndef AAMP_DOWNLOAD_INFO_HPP
26+
#define AAMP_DOWNLOAD_INFO_HPP
27+
28+
#include <string>
29+
#include <map>
30+
#include <vector>
31+
#include <cstdint>
32+
#include <curl/curl.h>
33+
#include "AampConstants.h"
34+
#include "AampCurlDefine.h"
35+
#include "AampMediaType.h"
36+
#include "AampUtils.h"
37+
#include "AampConfig.h"
38+
#include "AampTime.h"
39+
#include "main_aamp.h"
40+
41+
struct URIInfo
42+
{
43+
std::string url; /**< URL of the fragment */
44+
std::string range; /**< Byte range of the fragment in the format "<start>-<end>" i.e. "0-511" for first 512 bytes from url. Empty string if no explicit range (downloads whole media segment) */
45+
46+
/**
47+
* @brief Default constructor
48+
*/
49+
URIInfo()
50+
: url(""),
51+
range("")
52+
{
53+
}
54+
55+
/**
56+
* @brief Parameterized constructor
57+
* @param url URL of the fragment
58+
* @param range Byte range of the fragment
59+
*/
60+
URIInfo(const std::string &url, const std::string &range)
61+
: url(url),
62+
range(range)
63+
{
64+
}
65+
66+
/**
67+
* @brief Parameterized constructor
68+
* @param url URL of the fragment
69+
*/
70+
URIInfo(const std::string &url)
71+
: url(url),
72+
range("")
73+
{
74+
}
75+
};
76+
77+
typedef std::map<uint32_t, URIInfo> URLBitrateMap;
78+
79+
/**
80+
* @struct DownloadInfo
81+
* @brief Stores information for downloading a fragment
82+
*/
83+
struct DownloadInfo
84+
{
85+
AampMediaType mediaType; /**< Media type of the fragment */
86+
AampCurlInstance curlInstance; /**< Curl instance to be used for download */
87+
double fragmentDurationSec; /**< Duration of the fragment in seconds */
88+
double absolutePosition; /**< Absolute position of the fragment in seconds as per manifest file. For live it will be in epoch time and for VOD, it will be resolved based on the position in period */
89+
std::string range; /**< Byte range of the fragment in the format "<start>-<end>" i.e. "0-511" for first 512 bytes from url. Empty string if no explicit range (downloads whole media segment) */
90+
int fragmentIndex; /**< Index of the byte range in the fragment */
91+
uint64_t fragmentOffset; /**< Offset of the fragment in byte range based stream */
92+
bool isInitSegment; /**< Flag indicating if the fragment is an initialization segment */
93+
bool isDiscontinuity; /**< Flag indicating if the fragment is discontinuous */
94+
bool isPlayingAd; /**< Flag indicating if an ad is playing */
95+
bool failoverContentSegment; /**< Flag indicating if the FCS content matched */
96+
double pts; /**< Scaled PTS value from the fragment */
97+
uint64_t fragmentNumber; /**< Fragment number, incremented with each new segment in track, corresponds to $Number& in segment template */
98+
uint32_t timeScale; /**< Fragment Time scale, divide fragment time or duration by timeScale to convert to seconds */
99+
std::string url; /**< URL of the fragment */
100+
uint32_t bandwidth; /**< Bandwidth of the fragment at the time of job submission */
101+
AampTime ptsOffset; /**< Period specific PTS offset used for restamping */
102+
URLBitrateMap uriList; /**< List of all possible URLs with their respective bitrates */
103+
104+
/**
105+
* @brief Default constructor
106+
*/
107+
DownloadInfo()
108+
: mediaType(eMEDIATYPE_DEFAULT),
109+
curlInstance(eCURLINSTANCE_MAX),
110+
fragmentDurationSec(0),
111+
absolutePosition(0),
112+
range(""),
113+
fragmentIndex(-1),
114+
fragmentOffset(0),
115+
isInitSegment(false),
116+
isDiscontinuity(false),
117+
isPlayingAd(false),
118+
failoverContentSegment(false),
119+
url(""),
120+
pts(0),
121+
fragmentNumber(0),
122+
timeScale(1),
123+
bandwidth(0),
124+
ptsOffset(0),
125+
uriList()
126+
{
127+
}
128+
129+
/**
130+
* @brief Parameterized constructor
131+
* @param mediaType Media type of the fragment
132+
* @param curlInstance Curl instance to be used for download
133+
* @param absolutePosition Absolute position of the fragment in seconds
134+
* @param fragmentDurationSec Duration of the fragment in seconds
135+
* @param range Range of the fragment
136+
* @param fragmentIndex Index of the byte range in the fragment
137+
* @param fragmentOffset Offset of the fragment in byte range based stream
138+
* @param isInitSegment Flag indicating if the fragment is an initialization segment
139+
* @param isDiscontinuity Flag indicating if the fragment is discontinuous
140+
* @param isPlayingAd Flag indicating if an ad is playing
141+
* @param failoverContentSegment Flag indicating if the FCS content
142+
* @param pts Scale PTS
143+
* @param fragmentNumber Fragment number
144+
* @param timeScale Time scale
145+
* @param bandwidth Bandwidth of the fragment
146+
* @param ptsOffset PTS offset
147+
* @param uriList List of all possible URLs with their respective bitrates
148+
*/
149+
DownloadInfo(AampMediaType mediaType, AampCurlInstance curlInstance, double absolutePosition, double fragmentDurationSec, std::string range, int fragmentIndex, uint64_t fragmentOffset, bool isInitSegment, bool isDiscontinuity, bool isPlayingAd, bool failoverContentSegment, double pts, uint64_t fragmentNumber, uint32_t timeScale, uint32_t bandwidth, AampTime ptsOffset, URLBitrateMap uriList)
150+
: mediaType(mediaType),
151+
curlInstance(curlInstance),
152+
absolutePosition(absolutePosition),
153+
fragmentDurationSec(fragmentDurationSec),
154+
range(std::move(range)),
155+
fragmentIndex(fragmentIndex),
156+
fragmentOffset(fragmentOffset),
157+
isInitSegment(isInitSegment),
158+
isDiscontinuity(isDiscontinuity),
159+
isPlayingAd(isPlayingAd),
160+
failoverContentSegment(failoverContentSegment),
161+
pts(pts),
162+
fragmentNumber(fragmentNumber),
163+
timeScale(timeScale),
164+
bandwidth(bandwidth),
165+
ptsOffset(ptsOffset),
166+
uriList(std::move(uriList)),
167+
url("")
168+
{
169+
}
170+
};
171+
172+
typedef std::shared_ptr<DownloadInfo> DownloadInfoPtr;
173+
174+
#endif /* AAMP_DOWNLOAD_INFO_HPP */

AampFragmentDescriptor.cpp

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
/*
2+
* If not stated otherwise in this file or this component's license file the
3+
* following copyright and licenses apply:
4+
*
5+
* Copyright 2025 RDK Management
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* @file AampFragmentDescriptor.cpp
22+
* @brief FragmentDescriptor implementation
23+
*/
24+
25+
26+
#include "AampUtils.h"
27+
#include "AampFragmentDescriptor.hpp"
28+
#include "AampLogManager.h"
29+
30+
FragmentDescriptor::FragmentDescriptor() : manifestUrl(""), Bandwidth(0), Number(0), Time(0), RepresentationID(""), matchingBaseURL(""), bUseMatchingBaseUrl(false), nextfragmentNum(-1), nextfragmentTime(0), TimeScale(1)
31+
{
32+
}
33+
34+
FragmentDescriptor::FragmentDescriptor(const FragmentDescriptor &p) : manifestUrl(p.manifestUrl), Bandwidth(p.Bandwidth), RepresentationID(p.RepresentationID), Number(p.Number), Time(p.Time), matchingBaseURL(p.matchingBaseURL), bUseMatchingBaseUrl(p.bUseMatchingBaseUrl), nextfragmentNum(p.nextfragmentNum), nextfragmentTime(p.nextfragmentTime), TimeScale(p.TimeScale)
35+
{
36+
}
37+
38+
FragmentDescriptor &FragmentDescriptor::operator=(const FragmentDescriptor &p)
39+
{
40+
manifestUrl = p.manifestUrl;
41+
RepresentationID.assign(p.RepresentationID);
42+
Bandwidth = p.Bandwidth;
43+
Number = p.Number;
44+
Time = p.Time;
45+
matchingBaseURL = p.matchingBaseURL;
46+
nextfragmentNum = p.nextfragmentNum;
47+
nextfragmentTime = p.nextfragmentTime;
48+
TimeScale = p.TimeScale;
49+
return *this;
50+
}
51+
52+
std::string FragmentDescriptor::GetMatchingBaseUrl() const
53+
{
54+
return matchingBaseURL;
55+
}
56+
57+
void FragmentDescriptor::ClearMatchingBaseUrl()
58+
{
59+
matchingBaseURL.clear();
60+
}
61+
62+
void FragmentDescriptor::AppendMatchingBaseUrl(const std::vector<IBaseUrl *> *baseUrls)
63+
{
64+
if (baseUrls && baseUrls->size() > 0)
65+
{
66+
const std::string &url = baseUrls->at(0)->GetUrl();
67+
if (url.empty())
68+
{
69+
}
70+
else if (aamp_IsAbsoluteURL(url))
71+
{
72+
if (bUseMatchingBaseUrl)
73+
{
74+
std::string prefHost = aamp_getHostFromURL(manifestUrl);
75+
for (auto &item : *baseUrls)
76+
{
77+
const std::string itemUrl = item->GetUrl();
78+
std::string host = aamp_getHostFromURL(itemUrl);
79+
if (0 == prefHost.compare(host))
80+
{
81+
matchingBaseURL = item->GetUrl();
82+
return;
83+
}
84+
}
85+
}
86+
matchingBaseURL = url;
87+
}
88+
else if (url.rfind("/", 0) == 0)
89+
{
90+
matchingBaseURL = aamp_getHostFromURL(matchingBaseURL);
91+
matchingBaseURL += url;
92+
AAMPLOG_WARN("baseURL with leading /");
93+
}
94+
else
95+
{
96+
if (!matchingBaseURL.empty() && matchingBaseURL.back() != '/')
97+
{ // add '/' delimiter only if parent baseUrl doesn't already end with one
98+
matchingBaseURL += "/";
99+
}
100+
matchingBaseURL += url;
101+
}
102+
}
103+
}
104+
105+
void FragmentDescriptor::AppendMatchingBaseUrl(const std::vector<std::string> &baseUrls)
106+
{
107+
if (!baseUrls.empty())
108+
{
109+
const std::string &url = baseUrls.at(0);
110+
if (url.empty())
111+
{
112+
// Do nothing if the URL is empty
113+
}
114+
else if (aamp_IsAbsoluteURL(url))
115+
{
116+
if (bUseMatchingBaseUrl)
117+
{
118+
std::string prefHost = aamp_getHostFromURL(manifestUrl);
119+
for (const auto &itemUrl : baseUrls)
120+
{
121+
std::string host = aamp_getHostFromURL(itemUrl);
122+
if (0 == prefHost.compare(host))
123+
{
124+
matchingBaseURL = itemUrl;
125+
return;
126+
}
127+
}
128+
}
129+
matchingBaseURL = url;
130+
}
131+
else if (url.rfind("/", 0) == 0)
132+
{
133+
matchingBaseURL = aamp_getHostFromURL(matchingBaseURL);
134+
matchingBaseURL += url;
135+
AAMPLOG_WARN("baseURL with leading /");
136+
}
137+
else
138+
{
139+
if (!matchingBaseURL.empty() && matchingBaseURL.back() != '/')
140+
{
141+
// Add '/' delimiter only if parent baseUrl doesn't already end with one
142+
matchingBaseURL += "/";
143+
}
144+
matchingBaseURL += url;
145+
}
146+
}
147+
}

0 commit comments

Comments
 (0)