Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 7 additions & 3 deletions AampConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ static const ConfigLookupEntryBool mConfigLookupTableBool[AAMPCONFIG_BOOL_COUNT]
{false, "curlThroughput", eAAMPConfig_CurlThroughput, false },
{false, "useFireboltSDK", eAAMPConfig_UseFireboltSDK, false},
{true, "enableChunkInjection", eAAMPConfig_EnableChunkInjection, true},
{false, "debugChunkTransfer", eAAMPConfig_DebugChunkTransfer, false}
{false, "debugChunkTransfer", eAAMPConfig_DebugChunkTransfer, false},
{true, "utcSyncOnStartup", eAAMPConfig_UTCSyncOnStartup, true}
};

#define CONFIG_INT_ALIAS_COUNT 2
Expand Down Expand Up @@ -468,9 +469,12 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
{DEFAULT_MONITOR_AV_JUMP_THRESHOLD_MS,"monitorAVJumpThreshold",eAAMPConfig_MonitorAVJumpThreshold,true,eCONFIG_RANGE_MONITOR_AVSYNC_JUMP_THRESHOLD },
{DEFAULT_PROGRESS_LOGGING_DIVISOR,"progressLoggingDivisor",eAAMPConfig_ProgressLoggingDivisor,false},
{DEFAULT_MONITOR_AV_REPORTING_INTERVAL, "monitorAVReportingInterval", eAAMPConfig_MonitorAVReportingInterval, false},
{DEFAULT_UTC_SYNC_MIN_INTERVAL,"utcSyncMinIntervalSec",eAAMPConfig_UTCSyncMinIntervalSec,true },
// add new entries here

// aliases, kept for backwards compatibility
{DEFAULT_INIT_BITRATE,"defaultBitrate",eAAMPConfig_DefaultBitrate,true },
{DEFAULT_INIT_BITRATE_4K,"defaultBitrate4K",eAAMPConfig_DefaultBitrate4K,true },
{DEFAULT_INIT_BITRATE_4K,"defaultBitrate4K",eAAMPConfig_DefaultBitrate4K,true }
};

/**
Expand All @@ -495,7 +499,7 @@ static const ConfigLookupEntryFloat mConfigLookupTableFloat[AAMPCONFIG_FLOAT_COU
{DEFAULT_NORMAL_RATE_CORRECTION_SPEED,"normalLatencyCorrectionPlaybackRate",eAAMPConfig_NormalLatencyCorrectionPlaybackRate,false},
{DEFAULT_MIN_BUFFER_LOW_LATENCY,"lowLatencyMinBuffer",eAAMPConfig_LowLatencyMinBuffer,true, eCONFIG_RANGE_LLDBUFFER},
{DEFAULT_TARGET_BUFFER_LOW_LATENCY,"lowLatencyTargetBuffer",eAAMPConfig_LowLatencyTargetBuffer,true, eCONFIG_RANGE_LLDBUFFER},
{GST_BW_TO_BUFFER_FACTOR,"bandwidthToBufferFactor", eAAMPConfig_BWToGstBufferFactor,true},
{GST_BW_TO_BUFFER_FACTOR,"bandwidthToBufferFactor", eAAMPConfig_BWToGstBufferFactor,true}
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the trailing comma from the last entry in mConfigLookupTableFloat is inconsistent with C++11 best practices, which allow and encourage trailing commas in initializer lists for easier maintenance. Consider keeping the trailing comma to simplify future additions.

Copilot generated this review using guidance from repository custom instructions.
};

/**
Expand Down
2 changes: 2 additions & 0 deletions AampConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ typedef enum
eAAMPConfig_UseFireboltSDK, /**< Config to use Firebolt SDK for license Acquisition */
eAAMPConfig_EnableChunkInjection, /**< Config to enable chunk injection for low latency DASH */
eAAMPConfig_DebugChunkTransfer, /**< app-managed chunked transfer protocol */
eAAMPConfig_UTCSyncOnStartup, /** Perform sync at startup */
eAAMPConfig_BoolMaxValue /**< Max value of bool config always last element */

} AAMPConfigSettingBool;
Expand Down Expand Up @@ -311,6 +312,7 @@ typedef enum
eAAMPConfig_MonitorAVJumpThreshold, /**< configures threshold aligned audio,video positions advancing together by unexpectedly large delta to be reported as jump in milliseconds*/
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_IntMaxValue /**< Max value of int config always last element*/
} AAMPConfigSettingInt;
#define AAMPCONFIG_INT_COUNT (eAAMPConfig_IntMaxValue)
Expand Down
2 changes: 2 additions & 0 deletions AampDefine.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@
#define DEFAULT_MONITOR_AV_JUMP_THRESHOLD_MS 100 /**< default jump threshold to MonitorAV reporting */
#define DEFAULT_MAX_DOWNLOAD_BUFFER 10 /**< Default maximum download buffer in seconds, this can be used to limit player download job scheduling for DASH */
#define DEFAULT_MONITOR_AV_REPORTING_INTERVAL 1000 /**< time interval in ms for MonitorAV reporting */
#define DEFAULT_UTC_SYNC_MIN_INTERVAL 60 /**< Minimum interval between sync attempts */


// 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..
//#define SUBTEC_VARIABLE_CLOCK_UPDATE_RATE /* enable this to make the clock update rate dynamic*/
Expand Down
25 changes: 18 additions & 7 deletions fragmentcollector_mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4505,16 +4505,27 @@ bool StreamAbstractionAAMP_MPD::FindServerUTCTime(Node* root)
aamp_ResolveURL(ServerUrl, aamp->GetManifestUrl(), valueCopy.c_str(), false);
}

mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy());
if(mLocalUtcTime > 0 )
double elapsed = (double)(aamp_GetCurrentTimeMS() - mTimeSyncClient.lastSync) / 1000;
if ((!mTimeSyncClient.hasSynced && ISCONFIGSET(eAAMPConfig_UTCSyncOnStartup)) || (elapsed >= GETCONFIGVALUE(eAAMPConfig_UTCSyncMinIntervalSec)))
{
double currentTime = (double)aamp_GetCurrentTimeMS() / 1000;
mDeltaTime = mLocalUtcTime - currentTime;
hasServerUtcTime = true;
mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy());
if(mLocalUtcTime > 0)
{
mTimeSyncClient.lastSync = aamp_GetCurrentTimeMS();
mDeltaTime = mLocalUtcTime - (double)mTimeSyncClient.lastSync / 1000;
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use static_cast<double> instead of C-style cast (double) to follow C++ Core Guidelines and modern C++ best practices.

Copilot generated this review using guidance from repository custom instructions.
mTimeSyncClient.lastOffset = mDeltaTime;
mTimeSyncClient.hasSynced = true;
hasServerUtcTime = true;
}
else
{
AAMPLOG_WARN("Failed to read timeServer [%s] RetCode[%d]",ServerUrl.c_str(),http_error);
}
}
else
else if(mTimeSyncClient.hasSynced)
{
AAMPLOG_ERR("Failed to read timeServer [%s] RetCode[%d]",ServerUrl.c_str(),http_error);
mDeltaTime = mTimeSyncClient.lastOffset;
hasServerUtcTime = true;
}
break;
}
Expand Down
14 changes: 14 additions & 0 deletions fragmentcollector_mpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ struct ProfileInfo
int representationIndex;
};

/**
* @struct TimeSyncClient
* @brief UTC time sync client state
*/
struct TimeSyncClient
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing include directive for the fixed-width integer types. If the recommendation to use 'int64_t' instead of 'long long' is followed (as suggested in another comment), this header file should include '' to make those types available.

Add: #include

Copilot generated this review using guidance from repository custom instructions.
{
long long lastSync; // utcms time at which time was last synchronized with time server
double lastOffset; // current delta (seconds) between local and server time
bool hasSynced; // true if time has been synchronized at least once
TimeSyncClient(): lastSync(aamp_GetCurrentTimeMS()), lastOffset(0), hasSynced(false)
{}
};

class AampDashWorkerJob : public aamp::AampTrackWorkerJob
{
private:
Expand Down Expand Up @@ -1244,6 +1257,7 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
bool mShortAdOffsetCalc;
AampTime mNextPts; /*For PTS restamping*/
bool mIsFinalFirstPTS; /**< Flag to indicate if the first PTS is final or not */
TimeSyncClient mTimeSyncClient;
};

#endif //FRAGMENTCOLLECTOR_MPD_H_
Expand Down
Loading