-
Notifications
You must be signed in to change notification settings - Fork 7
VPLAY-12313: Implement notifyReservationComplete API #883
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
base: dev_sprint_25_2
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request implements the notifyReservationComplete API to notify AAMP when ad reservation is complete for a given reservation ID and time. The API is exposed through the JavaScript bindings and flows through the PlayerInstanceAAMP and PrivateInstanceAAMP layers down to the ad manager implementation.
Changes:
- Added
notifyReservationCompleteAPI across the public interface chain (JS bindings → PlayerInstanceAAMP → PrivateInstanceAAMP → PrivateCDAIObjectMPD) - Implemented reservation completion logic in PrivateCDAIObjectMPD to mark ad breaks as placed and resolved
- Added corresponding fake implementation for testing framework
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 17 comments.
Show a summary per file
| File | Description |
|---|---|
| jsbindings/jsmediaplayer.cpp | Added JavaScript binding to call notifyReservationComplete API with reservation ID and time parameters |
| main_aamp.h | Declared public API method in PlayerInstanceAAMP interface |
| main_aamp.cpp | Implemented forwarding wrapper from PlayerInstanceAAMP to PrivateInstanceAAMP |
| priv_aamp.h | Declared API method in PrivateInstanceAAMP class |
| priv_aamp.cpp | Implemented logging in PrivateInstanceAAMP (missing propagation to CDAI object) |
| admanager_mpd.h | Declared notifyReservationComplete in PrivateCDAIObjectMPD class |
| admanager_mpd.cpp | Implemented reservation completion logic with mutex protection, marking ad breaks as placed/resolved |
| test/utests/fakes/FakePlayerInstanceAamp.cpp | Added fake implementation stub for testing |
| void PlayerInstanceAAMP::SetContentProtectionDataUpdateTimeout(int timeout) { } | ||
| void PlayerInstanceAAMP::ProcessContentProtectionDataConfig(const char *jsonbuffer) { } | ||
| void PlayerInstanceAAMP::SetRuntimeDRMConfigSupport(bool DynamicDRMSupported) { } | ||
| void PlayerInstanceAAMP::notifyReservationComplete(const std::string& reservationId, long time) { } |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fixed-width integer type for cross-platform consistency: The parameter 'time' is declared as 'long', which has platform-dependent size. This should use a fixed-width type like int64_t or uint64_t from <cstdint> to ensure consistent memory layout across platforms and match the updated signature of the actual implementation.
| */ | ||
| void PrivateInstanceAAMP::notifyReservationComplete(const std::string& reservationId, long time) | ||
| { | ||
| AAMPLOG_INFO("[AAMP] Reservation complete for reservationId: %s at time: %ld", reservationId.c_str(), time); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing implementation - method only logs and does not propagate to the CDAI subsystem: The PrivateInstanceAAMP::notifyReservationComplete method only logs the reservation completion but does not forward the call to the mCdaiObject where the actual implementation exists (in PrivateCDAIObjectMPD::notifyReservationComplete at admanager_mpd.cpp line 1881). Following the existing pattern used by other methods like SetAlternateContents (see priv_aamp.cpp line 9771), this method should check if mCdaiObject exists and is of type CDAIObjectMPD, then call the corresponding method on the CDAI object to properly handle the reservation completion. Without this, the reservation state in the ad manager is never updated, making this API non-functional.
| AAMPLOG_INFO("[AAMP] Reservation complete for reservationId: %s at time: %ld", reservationId.c_str(), time); | |
| AAMPLOG_INFO("[AAMP] Reservation complete for reservationId: %s at time: %ld", reservationId.c_str(), time); | |
| // Forward reservation completion to CDAI subsystem for DASH streams | |
| if (mCdaiObject && (mMediaFormat == eMEDIAFORMAT_DASH)) | |
| { | |
| PrivateCDAIObjectMPD *cdaiObjectMpd = dynamic_cast<PrivateCDAIObjectMPD *>(mCdaiObject); | |
| if (cdaiObjectMpd) | |
| { | |
| cdaiObjectMpd->notifyReservationComplete(reservationId, time); | |
| } | |
| } |
| * @param[in] reservationId Ad break ID | ||
| * @param[in] time Time to mark the reservation complete | ||
| */ | ||
| void PrivateCDAIObjectMPD::notifyReservationComplete(const std::string& reservationId, long time) |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fixed-width integer type for cross-platform consistency: The parameter 'time' is declared as 'long', which has platform-dependent size. This should use a fixed-width type like int64_t or uint64_t from <cstdint> to ensure consistent memory layout across platforms. This applies to both the method signature and all logging statements using the %ld format specifier (which should be changed to the appropriate macro like PRId64 or PRIu64).
| * @brief Notify AAMP that ad reservation is complete for a given reservationId and time | ||
| * @param[in] reservationId The reservation identifier | ||
| * @param[in] time The Reservation complete time in milliseconds |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unclear parameter semantics: The documentation states the 'time' parameter is "The Reservation complete time in milliseconds", but it's unclear what this time represents. Is it a timestamp (e.g., epoch time), an offset from the start of the stream, a duration, or something else? The implementation logs it but doesn't use it for any logic. The documentation should clarify: (1) What is the base/origin of this time value? (2) How should it be used by the ad manager implementation? (3) What happens if the time parameter doesn't match expected boundaries (e.g., negative, zero, or beyond the ad break duration)?
| * @brief Notify AAMP that ad reservation is complete for a given reservationId and time | |
| * @param[in] reservationId The reservation identifier | |
| * @param[in] time The Reservation complete time in milliseconds | |
| * @brief Notify AAMP that an ad reservation has completed. | |
| * | |
| * This API is typically called by an external ad subsystem when playback | |
| * has reached the end of a reserved ad break. | |
| * | |
| * @param[in] reservationId Unique identifier of the reservation / ad break. | |
| * @param[in] time Playback position, in milliseconds, at which the | |
| * reservation completed. The value is an offset from the start | |
| * of the main content timeline (i.e., 0 = stream start) and is | |
| * expected to be monotonically increasing while the stream | |
| * plays. | |
| * | |
| * @note AAMP core currently uses this value only for logging and | |
| * diagnostics; it does not affect playback state or scheduling | |
| * logic. No validation is performed on the value, and negative, | |
| * zero, or out-of-range values are accepted but should be avoided | |
| * by callers. Ad manager implementations may use this value for | |
| * correlating with their own timelines or reporting, but should | |
| * treat obviously invalid values as unspecified. |
| AdBreakObject& abObj = mAdBreaks[reservationId]; | ||
| abObj.mAdBreakPlaced = true; | ||
| abObj.resolved = true; | ||
| AAMPLOG_INFO("[CDAI] Marked reservation complete for adBreakId: %s at time: %ld", reservationId.c_str(), time); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused parameter: The 'time' parameter is logged but not used in any logic within this method. The implementation sets mAdBreakPlaced and resolved flags, and potentially changes mAdState, but none of these operations use the time value. If the time parameter is meant to validate or constrain the reservation completion (e.g., to trim ads or verify timing), that logic is missing. Either implement the intended behavior using this parameter, or clarify in documentation why it's only logged and when/how it might be used in future.
| void PlayerInstanceAAMP::notifyReservationComplete(const std::string& reservationId, long time) | ||
| { | ||
| aamp->notifyReservationComplete(reservationId, time); | ||
| } |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage: The newly added public API PlayerInstanceAAMP::notifyReservationComplete lacks unit tests. According to the testing guidelines, all public functions require unit tests. Test cases should be added to verify that the call is properly forwarded from PlayerInstanceAAMP to the underlying PrivateInstanceAAMP (aamp) object. Tests should be placed in test/utests/tests/PlayerInstanceAAMP/ following the existing test pattern.
| void PrivateInstanceAAMP::notifyReservationComplete(const std::string& reservationId, long time) | ||
| { | ||
| AAMPLOG_INFO("[AAMP] Reservation complete for reservationId: %s at time: %ld", reservationId.c_str(), time); | ||
| } |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage: The newly added public API PrivateInstanceAAMP::notifyReservationComplete lacks unit tests. According to the testing guidelines, all public functions require unit tests. Once the implementation is fixed to properly forward to the CDAI object, test cases should be added to verify: (1) the call is properly forwarded to mCdaiObject when it exists and is a CDAIObjectMPD, (2) graceful handling when mCdaiObject is null, and (3) behavior when mCdaiObject is not a CDAIObjectMPD type. Tests should be placed in test/utests/tests/PrivAampTests/ following the existing test pattern.
| * @param[in] reservationId The reservation identifier | ||
| * @param[in] time The Reservation complete time in milliseconds | ||
| */ | ||
| void notifyReservationComplete(const std::string& reservationId, long time); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fixed-width integer type for cross-platform consistency: The parameter 'time' is declared as 'long', which has platform-dependent size (32 bits on some platforms, 64 bits on others). Since this API may be called from JavaScript bindings where ctypes is used, it should use a fixed-width type like int64_t or uint64_t from <cstdint> to ensure consistent memory layout across platforms. The documentation states this is in milliseconds, so int64_t would be appropriate if it can be negative, or uint64_t if it's always non-negative.
| /** | ||
| * @brief Notify AAMP that ad reservation is complete for a given reservationId and time | ||
| */ | ||
| void PlayerInstanceAAMP::notifyReservationComplete(const std::string& reservationId, long time) |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use fixed-width integer type for cross-platform consistency: The parameter 'time' is declared as 'long', which has platform-dependent size. Since this API is called from JavaScript bindings where ctypes is used, it should use a fixed-width type like int64_t or uint64_t from <cstdint> to ensure consistent memory layout across platforms. This applies to both the method signature and the corresponding forwarding call to aamp->notifyReservationComplete.
admanager_mpd.cpp
Outdated
| } | ||
| else | ||
| { | ||
| AAMPLOG_WARN("[CDAI] notifyReservationComplete: adBreakId %s not found", reservationId.c_str()); |
Copilot
AI
Jan 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent indentation: Line 1899 has excessive indentation (appears to have extra tabs/spaces) compared to the surrounding code at the same nesting level. The AAMPLOG_WARN line should be aligned with the opening brace on line 1898.
| AAMPLOG_WARN("[CDAI] notifyReservationComplete: adBreakId %s not found", reservationId.c_str()); | |
| AAMPLOG_WARN("[CDAI] notifyReservationComplete: adBreakId %s not found", reservationId.c_str()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
436371c to
8bf6ca1
Compare
…AAMP Reason for change: Added API and callbacks to aamp. Test Procedure: Refer jira ticket VPLAY-12313 Priority: P1 Signed-off-by: srikanthreddybijjam-comcast <srikanthreddybijjam.2000@gmail.com>
8bf6ca1 to
358ecd6
Compare
There was a problem hiding this 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 13 out of 13 changed files in this pull request and generated 7 comments.
| /** | ||
| * @brief Mark reservation as complete for a given reservationId and time | ||
| * @param[in] reservationId The reservation identifier | ||
| * @param[in] time The Reservation complete time in milliseconds | ||
| */ | ||
| virtual void notifyReservationComplete(const std::string& reservationId, long time) {} |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CDAIObject::notifyReservationComplete takes long time even though the doc says milliseconds. Since this method is part of the interface and is called across components (and from JS), using long can be non-portable. Prefer a fixed-width type (e.g., int64_t) to ensure consistent behavior on 32-bit and 64-bit platforms.
| /** | ||
| * @brief Notify AAMP that ad reservation is complete for a given reservationId and time | ||
| * @param[in] reservationId The reservation identifier | ||
| * @param[in] time The Reservation complete time in milliseconds | ||
| */ | ||
| void notifyReservationComplete(const std::string& reservationId, long time); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PlayerInstanceAAMP methods in this header use PascalCase (e.g., Tune, Stop, SetRate). The newly added notifyReservationComplete is lowerCamelCase, which is inconsistent with the existing public API naming and the project C++ naming guidelines. Consider renaming to NotifyReservationComplete (and updating callers) for consistency before this API becomes widely used.
| /** | ||
| * @brief Notify AAMP that ad reservation is complete for a given reservationId and time | ||
| * @param[in] reservationId The reservation identifier | ||
| * @param[in] time The Reservation complete time in milliseconds | ||
| */ | ||
| void notifyReservationComplete(const std::string& reservationId, long time); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrivateInstanceAAMP already exposes similar notification-style APIs with PascalCase (e.g., NotifySpeedChanged, NotifyOnEnteringLive). The new notifyReservationComplete deviates from that pattern. Consider renaming it to NotifyReservationComplete to keep notification APIs consistent and easier to discover.
| if (isAdBreakObjectExist(reservationId)) | ||
| { | ||
| AdBreakObject& abObj = mAdBreaks[reservationId]; | ||
| //abObj.mAdBreakPlaced = true; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid leaving commented-out code in new logic (//abObj.mAdBreakPlaced = true;). Either remove it or implement the intended behavior, so the reservation-complete semantics are unambiguous.
| //abObj.mAdBreakPlaced = true; |
| */ | ||
| void notifyReservationComplete(const std::string& reservationId, long time); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API uses long time for a millisecond timestamp. long is not a fixed-width type and can be 32-bit on some platforms, which risks truncation for large timestamps. Consider using a fixed-width integer (e.g., int64_t) consistently across PlayerInstanceAAMP/PrivateInstanceAAMP/CDAIObject interfaces and updating log formatting (PRId64) where needed.
| /** | ||
| * @brief Mark the reservation as complete for the ad break | ||
| * @param[in] reservationId Ad break ID | ||
| * @param[in] time Time to mark the reservation complete | ||
| */ | ||
| void PrivateCDAIObjectMPD::notifyReservationComplete(const std::string& reservationId, long time) | ||
| { | ||
| std::lock_guard<std::mutex> lock(mDaiMtx); | ||
| if (isAdBreakObjectExist(reservationId)) | ||
| { | ||
| AdBreakObject& abObj = mAdBreaks[reservationId]; | ||
| //abObj.mAdBreakPlaced = true; | ||
| abObj.resolved = true; | ||
| AAMPLOG_INFO("[CDAI] Marked reservation complete for adBreakId: %s at time: %ld", reservationId.c_str(), time); | ||
| if (!abObj.ads || abObj.ads->empty()) | ||
| { | ||
| AAMPLOG_INFO("[CDAI] Ad break %s is empty. No ads to play.", reservationId.c_str()); | ||
| AbortWaitForNextAdResolved(); | ||
| mAdFulfillCV.notify_all(); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| AAMPLOG_WARN("[CDAI] notifyReservationComplete: adBreakId %s not found", reservationId.c_str()); | ||
| } | ||
| } |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PrivateCDAIObjectMPD::notifyReservationComplete introduces new state transitions (marking ad break resolved, handling empty breaks, notifying condition variables). There are existing AdManagerMPD unit tests, but none cover this new path. Please add tests to validate: (1) resolved flag set when break exists, (2) no-op + warning when break is missing, and (3) empty-break path triggers the expected wake-ups.
Reason for change: Added notifyReservationAPI
Risks: Low
Test Procedure: Refer jira ticket VPLAY-12313
Priority: P1