|
| 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 */ |
0 commit comments