Skip to content

VPLAY-12472 [CSAT][AAMP] Add logging for buffering start/end and buffering duration#1160

Merged
pstroffolino merged 6 commits intodev_sprint_25_2from
feature/VPLAY-12472_2
Mar 25, 2026
Merged

VPLAY-12472 [CSAT][AAMP] Add logging for buffering start/end and buffering duration#1160
pstroffolino merged 6 commits intodev_sprint_25_2from
feature/VPLAY-12472_2

Conversation

@lashmintha
Copy link
Contributor

Reason for change: Added buffering duration in the telementary along with buffer start and end
Risks: Low
Test Procedure: Refer jira ticket
Priority: P1

@lashmintha lashmintha requested a review from a team as a code owner March 10, 2026 13:39
Copilot AI review requested due to automatic review settings March 10, 2026 13:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds telemetry/logging to capture buffering start/end events along with buffering duration.

Changes:

  • Introduces a new member to track buffering start time for duration calculations.
  • Updates buffer change event handling to compute and log buffering duration.
  • Sends buffering duration (dur) as an int field in telemetry events.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
priv_aamp.h Adds member variable to store buffering start time.
priv_aamp.cpp Computes/logs buffering duration and includes it in telemetry payload.

Copilot AI review requested due to automatic review settings March 11, 2026 15:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings March 19, 2026 16:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

…ering duration

Reason for change: Added buffering duration in the telementary along with buffer start and end
Risks: Low
Test Procedure: Refer jira ticket
Priority: P1

Signed-off-by: lashminthaj <lashminthaj17@gmail.com>
@lashmintha lashmintha force-pushed the feature/VPLAY-12472_2 branch from 8f9f94f to 65786fd Compare March 23, 2026 15:51
Copilot AI review requested due to automatic review settings March 24, 2026 14:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

std::string telemetryName = bufferingStopped?"VideoBufferingStart":"VideoBufferingEnd";
at2.send(telemetryName,{/*int data*/},{/*string data*/},{/*float data*/});
std::map<std::string,int> intData;
intData["dur"] = static_cast<int>(bufferingDurationMs);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

bufferingDurationMs is cast from long long to int for telemetry without bounds checking. If the value is negative (time jump) or exceeds INT_MAX, this will wrap/truncate and emit incorrect telemetry. Consider clamping to a safe range before casting (e.g., 0..INT_MAX) or changing the telemetry schema to avoid narrowing if that’s supported.

Suggested change
intData["dur"] = static_cast<int>(bufferingDurationMs);
long long clampedDurationMs = bufferingDurationMs;
if (clampedDurationMs < 0)
{
clampedDurationMs = 0;
}
else if (clampedDurationMs > static_cast<long long>(INT_MAX))
{
clampedDurationMs = static_cast<long long>(INT_MAX);
}
intData["dur"] = static_cast<int>(clampedDurationMs);

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings March 24, 2026 18:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

// from GStreamer error callbacks (via ScheduleRetune), with no common lock held at the
// call site. The compound check-and-set operations in SendBufferChangeEvent use
// compare_exchange_strong / exchange to keep the read-modify-write sequences race-free.
std::atomic<long long> mBufferingStartTimeMS;
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

mBufferingStartTimeMS has no in-class initializer. There are alternate PrivateInstanceAAMP constructor definitions used by unit-test fakes/mocks (e.g. test/utests/drm/mocks/aampMocks.cpp, test/utests/fakes/FakePrivateInstanceAAMP.cpp) that don't initialize this new member, leaving the atomic's value indeterminate. That can yield undefined behavior / bogus buffering durations when SendBufferChangeEvent() does compare_exchange_strong/exchange. Prefer giving the member an in-class initializer (e.g., {-1}) or updating all constructors to initialize it.

Suggested change
std::atomic<long long> mBufferingStartTimeMS;
std::atomic<long long> mBufferingStartTimeMS{-1};

Copilot uses AI. Check for mistakes.
std::string telemetryName = bufferingStopped?"VideoBufferingStart":"VideoBufferingEnd";
at2.send(telemetryName,{/*int data*/},{/*string data*/},{/*float data*/});
std::map<std::string,int> intData;
intData["dur"] = static_cast<int>(bufferingDurationMs);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

bufferingDurationMs is a long long but is narrowed to int for telemetry. If the buffering episode (or an unpaired start/end due to an error path) exceeds INT_MAX milliseconds, the cast becomes implementation-defined and can produce incorrect/negative values. Consider clamping to std::numeric_limits<int>::max() (or sending duration via a wider telemetry field type if available).

Suggested change
intData["dur"] = static_cast<int>(bufferingDurationMs);
int durationForTelemetry;
if (bufferingDurationMs < 0)
{
durationForTelemetry = 0;
}
else if (bufferingDurationMs > INT_MAX)
{
durationForTelemetry = INT_MAX;
}
else
{
durationForTelemetry = static_cast<int>(bufferingDurationMs);
}
intData["dur"] = durationForTelemetry;

Copilot uses AI. Check for mistakes.
pstroffolino and others added 2 commits March 24, 2026 19:03
Signed-off-by: Philip Stroffolino <philip_stroffolino@cable.comcast.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings March 25, 2026 00:36
@pstroffolino pstroffolino merged commit 1284ce2 into dev_sprint_25_2 Mar 25, 2026
9 checks passed
@pstroffolino pstroffolino deleted the feature/VPLAY-12472_2 branch March 25, 2026 00:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment on lines +3282 to +3284
std::map<std::string,int> intData;
intData["dur"] = static_cast<int>(bufferingDurationMs);
at2.send(telemetryName, intData, {/*string data*/}, {/*float data*/});
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

bufferingDurationMs is a long long but is unconditionally narrowed to int for telemetry (static_cast<int>(bufferingDurationMs)). If a buffering episode is very long (or if the start timestamp is ever corrupted/uninitialized), this can overflow and send a negative/garbled duration. Clamp to INT_MAX (and 0) before casting, or extend the telemetry API usage to carry a 64-bit value if supported.

Copilot uses AI. Check for mistakes.
p_aamp->SendBufferChangeEvent(true);
long long t2 = p_aamp->GetBufferingStartTimeMS();
ASSERT_GE(t2, 0LL);
EXPECT_GT(t2, t1); // monotonic: second start must be later than first
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This test asserts EXPECT_GT(t2, t1) using NOW_STEADY_TS_MS, which is a millisecond-truncated steady-clock counter. On platforms with coarse clock resolution, t2 can legitimately equal t1 even when time advanced (still monotonic), making the test flaky. Consider relaxing to EXPECT_GE(t2, t1) or structuring the assertion to avoid requiring a strict 1ms tick boundary.

Suggested change
EXPECT_GT(t2, t1); // monotonic: second start must be later than first
EXPECT_GE(t2, t1); // monotonic: second start must not be earlier than first

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants