Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AampConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "PlayerRfc.h"
#include "PlayerExternalsInterface.h"
#include "PlayerSecInterface.h"
#include "abr.h"
#include <time.h>
#include <map>
//////////////// CAUTION !!!! STOP !!! Read this before you proceed !!!!!!! /////////////
Expand Down Expand Up @@ -470,7 +471,7 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
{DEFAULT_PROGRESS_LOGGING_DIVISOR,"progressLoggingDivisor",eAAMPConfig_ProgressLoggingDivisor,false},
{DEFAULT_MONITOR_AV_REPORTING_INTERVAL, "monitorAVReportingInterval", eAAMPConfig_MonitorAVReportingInterval, false},
{DEFAULT_UTC_SYNC_MIN_INTERVAL_SEC,"utcSyncMinIntervalSec",eAAMPConfig_UTCSyncMinIntervalSec,true },

{DEFAULT_ABR_BANDWIDTH_ESTIMATOR_TYPE, "abrBandwidthEstimator", eAAMPConfig_ABRBandwidthEstimator, false, eCONFIG_RANGE_ANY},
// Add new integer config entries above this line, before the aliases section.
//
// Aliases, kept for backwards compatibility
Expand Down
1 change: 1 addition & 0 deletions AampConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ typedef enum
eAAMPConfig_ProgressLoggingDivisor, /**< Divisor to avoid printing the progress report too frequently in the log */
eAAMPConfig_MonitorAVReportingInterval, /**< Timeout in milliseconds for reporting MonitorAV events */
eAAMPConfig_UTCSyncMinIntervalSec, /**< Minimum interval between sync attempts */
eAAMPConfig_ABRBandwidthEstimator, /**< Select ABR bandwidth estimator */
eAAMPConfig_IntMaxValue /**< Max value of int config always last element*/
} AAMPConfigSettingInt;
#define AAMPCONFIG_INT_COUNT (eAAMPConfig_IntMaxValue)
Expand Down
1 change: 1 addition & 0 deletions AampDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#define DEFAULT_BUFFER_HEALTH_MONITOR_INTERVAL 5
#define DEFAULT_ABR_CACHE_LENGTH 3 /**< Default ABR cache length */
#define DEFAULT_ABR_BUFFER_COUNTER 4 /**< Default ABR Buffer Counter */
#define DEFAULT_ABR_BANDWIDTH_ESTIMATOR_TYPE 0 /**< Default ABR Bandwidth Estimator Type */
#define DEFAULT_REPORT_PROGRESS_INTERVAL 1 /**< Progress event reporting interval: 1sec */
#define DEFAULT_PROGRESS_LOGGING_DIVISOR 4 /**< Divisor of progress logging frequency to print logging */
#define DEFAULT_LICENSE_REQ_RETRY_WAIT_TIME 500 /**< Wait time in milliseconds before retrying for DRM license */
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,9 @@ set(LIBAAMP_SOURCES
AampCMCDCollector.cpp AampCMCDCollector.h
downloader/AampCurlDownloader.cpp downloader/AampCurlDownloader.h
ID3Metadata.cpp ID3Metadata.hpp
abr/abr.cpp abr/abr.h abr/NetworkBandwidthEstimator.cpp abr/NetworkBandwidthEstimator.h
abr/abr.cpp abr/abr.h
abr/RMOBandwidthEstimator.cpp abr/RMOBandwidthEstimator.h
abr/HarmonicEWMAEstimator.cpp abr/HarmonicEWMAEstimator.h
dash/xml/DomDocument.cpp
dash/xml/DomElement.cpp
dash/xml/DomNode.cpp
Expand Down Expand Up @@ -586,6 +588,9 @@ install(FILES
LangCodePreference.h StreamOutputFormat.h VideoZoomMode.h StreamSink.h TimedMetadata.h
AampDemuxDataTypes.h
abr/abr.h
abr/RMOBandwidthEstimator.h
abr/HarmonicEWMAEstimator.h
abr/BandwidthEstimatorBase.h
DESTINATION include
)

Expand Down
155 changes: 155 additions & 0 deletions abr/BandwidthEstimatorBase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2026 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.
*/
#ifndef AAMP_ABR_BANDWIDTH_ESTIMATOR_BASE_H
#define AAMP_ABR_BANDWIDTH_ESTIMATOR_BASE_H

#include <cstddef>

#include "AampMediaType.h"

/**
* @brief Plain Old Data (POD) structure for profiling information from a
* given CURL instance.
*/
struct DownloadMetrics
{
std::size_t m_size_download_bytes; // CURLINFO_SIZE_DOWNLOAD
double m_total_time_seconds; // CURLINFO_TOTAL_TIME
double m_time_to_first_byte_seconds; // CURLINFO_STARTTRANSFER_TIME
};

/**
* @brief POD structure for in-flight progress updates (xferinfo-style).
*/
struct DownloadProgressInfo
{
double m_now_seconds;
std::size_t m_total_bytes;
std::size_t m_now_bytes;
};

/**
* @brief Optional configuration for bandwidth estimators.
*
* Not all estimators use every field. Estimators that do not support
* configuration should ignore it.
*/
struct BandwidthEstimatorConfig
{
int mAbrCacheLife;
int mAbrCacheLength;
int mAbrCacheOutlier;
std::size_t mLowLatencyCacheLength;

BandwidthEstimatorConfig()
: mAbrCacheLife(0),
mAbrCacheLength(0),
mAbrCacheOutlier(0),
mLowLatencyCacheLength(0)
{
}

BandwidthEstimatorConfig(
int abrCacheLife,
int abrCacheLength,
int abrCacheOutlier,
std::size_t lowLatencyCacheLength)
: mAbrCacheLife(abrCacheLife),
mAbrCacheLength(abrCacheLength),
mAbrCacheOutlier(abrCacheOutlier),
mLowLatencyCacheLength(lowLatencyCacheLength)
{
}
};

/**
* @brief Base interface for bandwidth estimation algorithms.
*/
class BandwidthEstimatorBase
{
public:
virtual ~BandwidthEstimatorBase() {}

/**
* @brief Human-readable algorithm name.
*/
virtual const char* GetNetworkEstimatorName() const = 0;

/**
* @brief Reset all internal state.
*/
virtual void Reset() = 0;

/**
* @brief Add a bandwidth sample (bits per second).
*/
virtual void AddBandwidthSample(BitsPerSecond downloadbps, bool lowLatencyMode) = 0;

/**
* @brief Add download metrics derived from curl (optional).
*/
virtual void UpdateDownloadMetrics(const DownloadMetrics &metrics ) = 0;

/**
* @brief Provide in-flight download progress updates (optional).
*/
virtual void UpdateDownloadProgress(const DownloadProgressInfo &progressInfo)
{
}

/**
* @brief Update estimator configuration (optional).
*
* Default implementation is a no-op.
*/
virtual void SetConfig(const BandwidthEstimatorConfig &config)
{
}

/**
* @brief Return current bandwidth estimate (bits per second).
*
* @return Estimated bandwidth in bits per second, or -1 if unavailable.
*/
virtual BitsPerSecond GetBandwidthBitsPerSecond() = 0;

/**
* @brief Return current robust throughput estimate (bytes/s).
*/
virtual double GetThroughputBytesPerSecond() = 0;

/**
* @brief Return current overhead (TTFB) estimate (seconds).
*/
virtual double GetTimeToFirstByteSeconds() = 0;

/**
* @brief Predict completion time for a new segment.
*/
virtual double GetPredictedDownloadTimeSeconds(std::size_t segment_size_bytes) = 0;

/**
* @brief Reset only the currently available bandwidth estimate.
*/
virtual void ResetCurrentlyAvailableBandwidth()
{
}
};

#endif
Loading