Skip to content

Commit 4781ef1

Browse files
author
Anurag Krishnan
committed
VPLAY-12359 suboptimal UTCTiming behavior
Reason for change: Updates UTCTiming logic to skip sync if interval hasn’t elapsed. Add Configs to control the interval Test Procedure: updated in ticket Risks: Low Signed-off-by: Anurag Krishnan <[email protected]>
1 parent cf1c37f commit 4781ef1

File tree

5 files changed

+38
-5
lines changed

5 files changed

+38
-5
lines changed

AampConfig.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ static const ConfigLookupEntryBool mConfigLookupTableBool[AAMPCONFIG_BOOL_COUNT]
368368
{false, "curlThroughput", eAAMPConfig_CurlThroughput, false },
369369
{false, "useFireboltSDK", eAAMPConfig_UseFireboltSDK, false},
370370
{true, "enableChunkInjection", eAAMPConfig_EnableChunkInjection, true},
371-
{false, "debugChunkTransfer", eAAMPConfig_DebugChunkTransfer, false}
371+
{false, "debugChunkTransfer", eAAMPConfig_DebugChunkTransfer, false},
372+
{true, "utcSyncOnStartup", eAAMPConfig_UTCSyncOnStartup, true}
372373
};
373374

374375
#define CONFIG_INT_ALIAS_COUNT 2
@@ -471,6 +472,8 @@ static const ConfigLookupEntryInt mConfigLookupTableInt[AAMPCONFIG_INT_COUNT+CON
471472
// aliases, kept for backwards compatibility
472473
{DEFAULT_INIT_BITRATE,"defaultBitrate",eAAMPConfig_DefaultBitrate,true },
473474
{DEFAULT_INIT_BITRATE_4K,"defaultBitrate4K",eAAMPConfig_DefaultBitrate4K,true },
475+
{DEFAULT_UTC_SYNC_MIN_INTERVAL,"utcSyncMinIntervalSec",eAAMPConfig_UTCSyncMinIntervalSec,true },
476+
{DEFAULT_UTC_SYNC_ON_ERROR_RETRY,"utcSyncOnErrorRetrySec",eAAMPConfig_UTCSyncOnErrorRetrySec,true },
474477
};
475478

476479
/**

AampConfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ typedef enum
214214
eAAMPConfig_UseFireboltSDK, /**< Config to use Firebolt SDK for license Acquisition */
215215
eAAMPConfig_EnableChunkInjection, /**< Config to enable chunk injection for low latency DASH */
216216
eAAMPConfig_DebugChunkTransfer, /**< app-managed chunked transfer protocol */
217+
eAAMPConfig_UTCSyncOnStartup, /** Perform sync at startup */
217218
eAAMPConfig_BoolMaxValue /**< Max value of bool config always last element */
218219

219220
} AAMPConfigSettingBool;
@@ -311,6 +312,8 @@ typedef enum
311312
eAAMPConfig_MonitorAVJumpThreshold, /**< configures threshold aligned audio,video positions advancing together by unexpectedly large delta to be reported as jump in milliseconds*/
312313
eAAMPConfig_ProgressLoggingDivisor, /**< Divisor to avoid printing the progress report too frequently in the log */
313314
eAAMPConfig_MonitorAVReportingInterval, /**< Timeout in milliseconds for reporting MonitorAV events */
315+
eAAMPConfig_UTCSyncMinIntervalSec, /**< Minimum interval between sync attempts */
316+
eAAMPConfig_UTCSyncOnErrorRetrySec, /**< Backoff after error */
314317
eAAMPConfig_IntMaxValue /**< Max value of int config always last element*/
315318
} AAMPConfigSettingInt;
316319
#define AAMPCONFIG_INT_COUNT (eAAMPConfig_IntMaxValue)

AampDefine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@
143143
#define DEFAULT_MONITOR_AV_JUMP_THRESHOLD_MS 100 /**< default jump threshold to MonitorAV reporting */
144144
#define DEFAULT_MAX_DOWNLOAD_BUFFER 10 /**< Default maximum download buffer in seconds, this can be used to limit player download job scheduling for DASH */
145145
#define DEFAULT_MONITOR_AV_REPORTING_INTERVAL 1000 /**< time interval in ms for MonitorAV reporting */
146+
#define DEFAULT_UTC_SYNC_MIN_INTERVAL 60 /**< Minimum interval between sync attempts */
147+
#define DEFAULT_UTC_SYNC_ON_ERROR_RETRY 120 /**< Backoff after error */
148+
146149

147150
// 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..
148151
//#define SUBTEC_VARIABLE_CLOCK_UPDATE_RATE /* enable this to make the clock update rate dynamic*/

fragmentcollector_mpd.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4505,16 +4505,26 @@ bool StreamAbstractionAAMP_MPD::FindServerUTCTime(Node* root)
45054505
aamp_ResolveURL(ServerUrl, aamp->GetManifestUrl(), valueCopy.c_str(), false);
45064506
}
45074507

4508-
mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy());
4508+
double elapsed = (double)(aamp_GetCurrentTimeMS() - mSyncIfNeeded.lastSync) / 1000;
4509+
if ((!mSyncIfNeeded.hasSynced && ISCONFIGSET(eAAMPConfig_UTCSyncOnStartup)) || (elapsed >= GETCONFIGVALUE(eAAMPConfig_UTCSyncMinIntervalSec)))
4510+
{
4511+
mLocalUtcTime = GetNetworkTime(ServerUrl, &http_error, aamp->GetNetworkProxy());
4512+
}else
4513+
{
4514+
mLocalUtcTime = 0;
4515+
}
4516+
45094517
if(mLocalUtcTime > 0 )
45104518
{
4511-
double currentTime = (double)aamp_GetCurrentTimeMS() / 1000;
4512-
mDeltaTime = mLocalUtcTime - currentTime;
4519+
mSyncIfNeeded.lastSync = aamp_GetCurrentTimeMS();
4520+
mDeltaTime = mLocalUtcTime - (double)mSyncIfNeeded.lastSync / 1000;
4521+
mSyncIfNeeded.lastOffset = mDeltaTime;
4522+
mSyncIfNeeded.hasSynced = true;
45134523
hasServerUtcTime = true;
45144524
}
45154525
else
45164526
{
4517-
AAMPLOG_ERR("Failed to read timeServer [%s] RetCode[%d]",ServerUrl.c_str(),http_error);
4527+
AAMPLOG_WARN("UTCTiming sync skipped or failed; using cached offset. timeServer [%s] RetCode[%d]",ServerUrl.c_str(),http_error);
45184528
}
45194529
break;
45204530
}

fragmentcollector_mpd.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,19 @@ struct ProfileInfo
6767
int representationIndex;
6868
};
6969

70+
/**
71+
* @struct TimeSyncClient
72+
* @brief UTC time sync info
73+
*/
74+
struct TimeSyncClient
75+
{
76+
long long lastSync;
77+
double lastOffset;
78+
bool hasSynced;
79+
TimeSyncClient(): lastSync(0), lastOffset(0), hasSynced(false)
80+
{}
81+
};
82+
7083
class AampDashWorkerJob : public aamp::AampTrackWorkerJob
7184
{
7285
private:
@@ -1244,6 +1257,7 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
12441257
bool mShortAdOffsetCalc;
12451258
AampTime mNextPts; /*For PTS restamping*/
12461259
bool mIsFinalFirstPTS; /**< Flag to indicate if the first PTS is final or not */
1260+
TimeSyncClient mSyncIfNeeded;
12471261
};
12481262

12491263
#endif //FRAGMENTCOLLECTOR_MPD_H_

0 commit comments

Comments
 (0)