-
Notifications
You must be signed in to change notification settings - Fork 7
VPLAY-12359 suboptimal UTCTiming behavior #853
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
a8e0d9f
e57c144
63776aa
2721698
8f74660
e14c9ec
4c48ceb
7d42196
517d732
12f9951
0746e42
4301e0e
b2d00e2
e4cdd35
80af1c4
0d6425a
b3faaf0
79ac33a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -468,9 +469,13 @@ 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}, | ||
| // aliases, kept for backwards compatibility | ||
| {DEFAULT_UTC_SYNC_MIN_INTERVAL,"utcSyncMinIntervalSec",eAAMPConfig_UTCSyncMinIntervalSec,true }, | ||
|
|
||
| // Add new integer config entries above this line, before the aliases section. | ||
| // | ||
| // 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 } | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -495,7 +500,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} | ||
|
||
| }; | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4468,11 +4468,13 @@ void StreamAbstractionAAMP_MPD::FindPeriodGapsAndReport() | |
| } | ||
| } | ||
|
|
||
| TimeSyncClient::TimeSyncClient(): lastSync(aamp_GetCurrentTimeMS()), lastOffset(0), hasSynced(false) {} | ||
|
|
||
| /** | ||
| * @brief Read UTCTiming _element_ | ||
| * @retval Return true if UTCTiming _element_ is available in the manifest | ||
| */ | ||
| bool StreamAbstractionAAMP_MPD::FindServerUTCTime(Node* root) | ||
| bool StreamAbstractionAAMP_MPD::FindServerUTCTime(Node* root) | ||
| { | ||
| bool hasServerUtcTime = false; | ||
| if( root ) | ||
|
|
@@ -4505,16 +4507,40 @@ 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 ) | ||
| bool shouldSyncOnStartup = !mTimeSyncClient.hasSynced && ISCONFIGSET(eAAMPConfig_UTCSyncOnStartup); | ||
| bool intervalElapsed = false; | ||
|
||
| if( !shouldSyncOnStartup ) | ||
| { | ||
| double currentTime = (double)aamp_GetCurrentTimeMS() / 1000; | ||
| mDeltaTime = mLocalUtcTime - currentTime; | ||
| hasServerUtcTime = true; | ||
| const double elapsed = (double)(aamp_GetCurrentTimeMS() - mTimeSyncClient.lastSync) / 1000; | ||
|
||
| intervalElapsed = elapsed >= GETCONFIGVALUE(eAAMPConfig_UTCSyncMinIntervalSec); | ||
| } | ||
| else | ||
| if (shouldSyncOnStartup || intervalElapsed) | ||
| { | ||
| mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy()); | ||
| if(mLocalUtcTime > 0) | ||
| { | ||
| mTimeSyncClient.lastSync = aamp_GetCurrentTimeMS(); | ||
| mDeltaTime = mLocalUtcTime - (double)mTimeSyncClient.lastSync / 1000; | ||
|
||
| mTimeSyncClient.lastOffset = mDeltaTime; | ||
| mTimeSyncClient.hasSynced = true; | ||
| hasServerUtcTime = true; | ||
| } | ||
| else | ||
| { | ||
| if (!mTimeSyncClient.hasSynced) | ||
| { | ||
| AAMPLOG_ERR("Failed initial read of timeServer [%s] RetCode[%d]", ServerUrl.c_str(), http_error); | ||
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| else | ||
| { | ||
| AAMPLOG_WARN("Failed to refresh timeServer [%s] RetCode[%d]", ServerUrl.c_str(), http_error); | ||
| } | ||
| } | ||
|
Comment on lines
4528
to
4538
|
||
| } | ||
| else if(mTimeSyncClient.hasSynced) | ||
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| AAMPLOG_ERR("Failed to read timeServer [%s] RetCode[%d]",ServerUrl.c_str(),http_error); | ||
| mDeltaTime = mTimeSyncClient.lastOffset; | ||
| hasServerUtcTime = true; | ||
| } | ||
pstroffolino marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| break; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,6 +67,45 @@ struct ProfileInfo | |||||||||||||||
| int representationIndex; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * @struct TimeSyncClient | ||||||||||||||||
| * | ||||||||||||||||
| * @brief Maintains state for periodic synchronization of the local clock | ||||||||||||||||
| * with a remote UTC time server, used in DASH manifest processing. | ||||||||||||||||
| * | ||||||||||||||||
| * This struct tracks the last successful synchronization time and the | ||||||||||||||||
| * cached offset between the local system clock and the server's UTC time. | ||||||||||||||||
| * It supports logic to determine when a new synchronization request should | ||||||||||||||||
| * be made based on elapsed time and configuration. | ||||||||||||||||
| * | ||||||||||||||||
| * Members: | ||||||||||||||||
| * - lastSync: Timestamp (milliseconds since epoch) of the last successful sync. | ||||||||||||||||
| * - lastOffset: Cached time delta (in seconds) between local and server time. | ||||||||||||||||
| * - hasSynced: Flag indicating whether at least one successful sync has occurred. | ||||||||||||||||
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||
| */ | ||||||||||||||||
| struct TimeSyncClient | ||||||||||||||||
|
||||||||||||||||
| { | ||||||||||||||||
| /** | ||||||||||||||||
| * @brief UTC time in milliseconds since epoch when time was last synchronized with time server. | ||||||||||||||||
| */ | ||||||||||||||||
| long long lastSync; | ||||||||||||||||
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||
|
|
||||||||||||||||
pstroffolino marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||||||
| /** | ||||||||||||||||
| * @brief Current delta (seconds) between local and server time. | ||||||||||||||||
| */ | ||||||||||||||||
| double lastOffset; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * @brief True if time has been synchronized at least once. | ||||||||||||||||
| */ | ||||||||||||||||
| bool hasSynced; | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * @brief Constructor initializes lastSync with current time and resets other members. | ||||||||||||||||
|
||||||||||||||||
| * @brief Constructor initializes lastSync with current time and resets other members. | |
| * @brief Constructor initializes lastSync with current time and resets other members. | |
| * | |
| * This initialization obtains the current time via a call to | |
| * aamp_GetCurrentTimeMS(), which may perform a system call to | |
| * query the system clock. Callers should be aware that constructing | |
| * TimeSyncClient can therefore incur this side effect. |
Uh oh!
There was an error while loading. Please reload this page.