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