Skip to content

Feature/vplay 9633 #282

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

Open
wants to merge 11 commits into
base: dev_sprint_25_2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 14 additions & 1 deletion StreamAbstractionAAMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ class MediaTrack
* @fn ResetTrickModePtsRestamping
* @brief Reset trick mode PTS restamping
*/
void ResetTrickModePtsRestamping(void);
virtual void ResetTrickModePtsRestamping(void);

/**
* @fn IsInjectionFromCachedFragmentChunks
Expand Down Expand Up @@ -2069,6 +2069,19 @@ class StreamAbstractionAAMP : public AampLicenseFetcher

virtual bool SelectPreferredTextTrack(TextTrackInfo &selectedTextTrack) { return false; };

/**
* @fn clearFirstPTS
* @brief Clears the mFirstPTS value to trigger update of first PTS
*/
virtual void clearFirstPTS(void) {};

/**
* @fn ReinitializeInjection
* @brief Reintializes the injection logic
* @param[in] rate - play rate
*/
void ReinitializeInjection(double rate);

protected:
/**
* @brief Get stream information of a profile from subclass.
Expand Down
10 changes: 9 additions & 1 deletion fragmentcollector_mpd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14174,4 +14174,12 @@ bool StreamAbstractionAAMP_MPD::DoStreamSinkFlushOnDiscontinuity()
bool doFlush = (!ISCONFIGSET(eAAMPConfig_EnableMediaProcessor) || mIsSegmentTimelineEnabled);
AAMPLOG_INFO("doFlush=%d", doFlush);
return doFlush;
}
}
/**
* @fn clearFirstPTS
* @brief Clears the mFirstPTS value to trigger update of first PTS
*/
void StreamAbstractionAAMP_MPD::clearFirstPTS(void)
{
mFirstPTS = 0.0;
}
6 changes: 6 additions & 0 deletions fragmentcollector_mpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,12 @@ class StreamAbstractionAAMP_MPD : public StreamAbstractionAAMP
*/
virtual bool DoStreamSinkFlushOnDiscontinuity() override;

/**
* @fn clearFirstPTS
* @brief Clears the mFirstPTS value to trigger update of first PTS
*/
void clearFirstPTS(void) override;

protected:
/**
* @fn StartFromAampLocalTsb
Expand Down
12 changes: 6 additions & 6 deletions priv_aamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5216,12 +5216,7 @@ void PrivateInstanceAAMP::TuneHelper(TuneType tuneType, bool seekWhilePaused)
}
else
{
mpStreamAbstractionAAMP->SetTrickplayMode(rate);
mpStreamAbstractionAAMP->ResetTrickModePtsRestamping();
if (!GetLLDashChunkMode())
{
mpStreamAbstractionAAMP->SetVideoPlaybackRate(rate);
}
mpStreamAbstractionAAMP->ReinitializeInjection(rate);
}
}
else if (mMediaFormat == eMEDIAFORMAT_HLS || mMediaFormat == eMEDIAFORMAT_HLS_MP4)
Expand Down Expand Up @@ -13689,6 +13684,11 @@ void PrivateInstanceAAMP::SetLLDashChunkMode(bool enable)
}
}

bool PrivateInstanceAAMP::GetLLDashChunkMode()
{
return mIsChunkMode;
}

bool PrivateInstanceAAMP::GetLLDashAdjustSpeed(void)
{
return bLLDashAdjustPlayerSpeed;
Expand Down
2 changes: 1 addition & 1 deletion priv_aamp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3500,7 +3500,7 @@ class PrivateInstanceAAMP : public DrmCallbacks, public std::enable_shared_from_
*
* @return true if LL-DASH chunk mode is enabled, false otherwise.
*/
bool GetLLDashChunkMode() { return mIsChunkMode; }
bool GetLLDashChunkMode();

/**
* @brief Is iframe extraction enabled
Expand Down
15 changes: 15 additions & 0 deletions streamabstraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4610,3 +4610,18 @@ bool MediaTrack::IsInjectionFromCachedFragmentChunks()
name, isLLDashChunkMode, aampTsbEnabled, isInjectionFromCachedFragmentChunks);
return isInjectionFromCachedFragmentChunks;
}

/**
* @brief Reintializes the injection
* @param[in] rate - play rate
*/
void StreamAbstractionAAMP::ReinitializeInjection(double rate)
{
clearFirstPTS(); //Clears the mFirstPTS value to trigger update of first PTS
SetTrickplayMode(rate);
ResetTrickModePtsRestamping();
if (!aamp->GetLLDashChunkMode())
{
SetVideoPlaybackRate(rate);
}
}
5 changes: 5 additions & 0 deletions test/utests/fakes/FakeFragmentCollector_MPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,8 @@ bool StreamAbstractionAAMP_MPD::DoEarlyStreamSinkFlush(bool newTune, float rate)
return shouldFlush;
}
bool StreamAbstractionAAMP_MPD::DoStreamSinkFlushOnDiscontinuity() { return false; }

void StreamAbstractionAAMP_MPD::clearFirstPTS(void)
{

}
15 changes: 14 additions & 1 deletion test/utests/fakes/FakePrivateInstanceAAMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1628,7 +1628,20 @@ void PrivateInstanceAAMP::ResetTrickStartUTCTime()

void PrivateInstanceAAMP::SetLLDashChunkMode(bool enable)
{
mIsChunkMode = enable;
if (g_mockPrivateInstanceAAMP)
{
g_mockPrivateInstanceAAMP->SetLLDashChunkMode(enable);
}
}

bool PrivateInstanceAAMP::GetLLDashChunkMode()
{
bool bIsChunkMode = false;
if (g_mockPrivateInstanceAAMP)
{
bIsChunkMode = g_mockPrivateInstanceAAMP->GetLLDashChunkMode();
}
return bIsChunkMode;
}

const char* PrivateInstanceAAMP::getStringForPlaybackError(PlaybackErrorType errorType)
Expand Down
14 changes: 13 additions & 1 deletion test/utests/fakes/FakeStreamAbstractionAamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,16 @@ bool MediaTrack::IsInjectionFromCachedFragmentChunks()

void MediaTrack::ClearMediaHeaderDuration(CachedFragment* cachedFragment)
{
}
}

void MediaTrack::ResetTrickModePtsRestamping()
{
}

void StreamAbstractionAAMP::ReinitializeInjection(double rate)
{
if (g_mockStreamAbstractionAAMP != nullptr)
{
g_mockStreamAbstractionAAMP->ReinitializeInjection(rate);
}
}
46 changes: 46 additions & 0 deletions test/utests/mocks/MockMediaProcessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* If not stated otherwise in this file or this component's license file the
* following copyright and licenses apply:
*
* Copyright 2025 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef AAMP_MOCK_MEDIA_PROCESSOR_H
#define AAMP_MOCK_MEDIA_PROCESSOR_H

#include <gmock/gmock.h>
#include "mediaprocessor.h"

class MockMediaProcessor : public MediaProcessor
{
public:
MockMediaProcessor() : MediaProcessor() {}
MOCK_METHOD(double, getFirstPts, (AampGrowableBuffer* pBuffer), (override));
MOCK_METHOD(void, setPtsOffset, (double ptsOffset), (override));
MOCK_METHOD(bool, sendSegment, (AampGrowableBuffer* pBuffer, double position, double duration, double fragmentPTSoffset, bool discontinuous, bool isInit, process_fcn_t processor, bool &ptsError), (override));
MOCK_METHOD(void, setRate, (double rate, PlayMode mode), (override));
MOCK_METHOD(void, setThrottleEnable, (bool enable), (override));
MOCK_METHOD(void, setFrameRateForTM, (int frameRate), (override));
MOCK_METHOD(void, abort, (), (override));
MOCK_METHOD(void, reset, (), (override));
MOCK_METHOD(void, ChangeMuxedAudioTrack, (unsigned char index), (override));
MOCK_METHOD(void, SetAudioGroupId, (std::string& id), (override));
MOCK_METHOD(void, setApplyOffsetFlag, (bool enable), (override));
MOCK_METHOD(void, abortInjectionWait, (), (override));
MOCK_METHOD(void, enable, (bool enable), (override));
MOCK_METHOD(void, setTrackOffset, (double offset), (override));
};

#endif /* AAMP_MOCK_MEDIA_PROCESSOR_H */
2 changes: 2 additions & 0 deletions test/utests/mocks/MockPrivateInstanceAAMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class MockPrivateInstanceAAMP
MOCK_METHOD(void, BlockUntilGstreamerWantsData, (void(*cb)(void), int , int ));
MOCK_METHOD(void, WaitForDiscontinuityProcessToComplete, ());
MOCK_METHOD(double, GetLivePlayPosition, ());
MOCK_METHOD(bool, GetLLDashChunkMode, ());
MOCK_METHOD(void, SetLLDashChunkMode, (bool enable));
};

extern MockPrivateInstanceAAMP *g_mockPrivateInstanceAAMP;
Expand Down
3 changes: 3 additions & 0 deletions test/utests/mocks/MockStreamAbstractionAAMP.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MockMediaTrack : public MediaTrack
MOCK_METHOD(void, InjectFragmentInternal, (CachedFragment* cachedFragment, bool &fragmentDiscarded,bool isDiscontinuity), (override));

MOCK_METHOD(double, GetTotalInjectedDuration, (), (override));
MOCK_METHOD(void, ResetTrickModePtsRestamping, (), (override));
};

class MockStreamAbstractionAAMP : public StreamAbstractionAAMP
Expand Down Expand Up @@ -116,6 +117,8 @@ class MockStreamAbstractionAAMP : public StreamAbstractionAAMP
MOCK_METHOD(bool, IsEOSReached, (), (override));

MOCK_METHOD(bool, DoEarlyStreamSinkFlush, (bool newTune, float rate), (override));

MOCK_METHOD(void, ReinitializeInjection, (double rate));
};

extern MockStreamAbstractionAAMP *g_mockStreamAbstractionAAMP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class MediaStreamContextTest : public ::testing::TestWithParam<TestParams>
mMediaStreamContext->mTempFragment->AppendBytes(data, 12);
// The tests simulating EOS inject from the TSB, the rest of the tests inject from live
mMediaStreamContext->SetLocalTSBInjection(eos);
mPrivateInstanceAAMP->SetLLDashChunkMode(chunk);

AampTSBSessionManager *tsbSessionManager = nullptr;
if (tsb)
{
Expand All @@ -304,6 +304,7 @@ class MediaStreamContextTest : public ::testing::TestWithParam<TestParams>
}
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetTSBSessionManager()).WillOnce(Return(tsbSessionManager));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetFile(_, _, _, _, _, _, _, _, _, _, _, _, _, _)).WillOnce(Return(true));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(chunk));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ class AdSelectionTests : public ::testing::Test
}

EXPECT_CALL(*g_mockPrivateInstanceAAMP, DownloadsAreEnabled()).WillRepeatedly(Return(true));

EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(false));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, SetLLDashChunkMode(_));
/* Create MPD instance. */
mStreamAbstractionAAMP_MPD = new TestableStreamAbstractionAAMP_MPD(mPrivateInstanceAAMP, seekPos, rate);
mCdaiObj = new CDAIObjectMPD(mPrivateInstanceAAMP);
Expand Down
10 changes: 5 additions & 5 deletions test/utests/tests/MediaTrackTests/MediaTrackTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ class MediaTrackTests : public testing::Test
AampLLDashServiceData dashData{};
dashData.lowLatencyMode = isEnabled;
mPrivateInstanceAAMP->SetLLDashServiceData(dashData);
// In these tests, chunk mode is set for all low-latency tests
mPrivateInstanceAAMP->SetLLDashChunkMode(isEnabled);
}
};

Expand Down Expand Up @@ -231,6 +229,7 @@ TEST_P(MediaTrackDashPtsRestampNotConfiguredTests, PtsRestampNotConfiguredTest)
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
.WillRepeatedly(Return(1));
EXPECT_CALL(*g_mockIsoBmffBuffer, parseBuffer(_, _)).WillRepeatedly(Return(true));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(testParam.lowLatencyMode));

TestableMediaTrack mediaTrack{eTRACK_VIDEO, mPrivateInstanceAAMP, "media",
mStreamAbstractionAAMP_MPD};
Expand Down Expand Up @@ -288,6 +287,7 @@ TEST_P(MediaTrackDashQtDemuxOverrideConfiguredTests, QtDemuxOverrideConfiguredTe
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
.WillRepeatedly(Return(1));
EXPECT_CALL(*g_mockIsoBmffBuffer, parseBuffer(_, _)).WillRepeatedly(Return(true));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(testParam.lowLatencyMode));

TestableMediaTrack mediaTrack{eTRACK_VIDEO, mPrivateInstanceAAMP, "media",
mStreamAbstractionAAMP_MPD};
Expand Down Expand Up @@ -348,6 +348,7 @@ TEST_P(MediaTrackDashTrickModePtsRestampValidPlayRateTests, ValidPlayRateTest)
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
.WillRepeatedly(Return(1));
EXPECT_CALL(*g_mockIsoBmffBuffer, parseBuffer(_, _)).WillRepeatedly(Return(true));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(testParam.lowLatencyMode));

TestableMediaTrack iframeTrack{eTRACK_VIDEO, mPrivateInstanceAAMP, "iframe",
mStreamAbstractionAAMP_MPD};
Expand Down Expand Up @@ -514,6 +515,7 @@ TEST_P(MediaTrackDashPlaybackPtsRestampTests, PlaybackTest)
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
.WillRepeatedly(Return(1));
EXPECT_CALL(*g_mockIsoBmffBuffer, parseBuffer(_, _)).WillRepeatedly(Return(true));
EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillRepeatedly(Return(lowLatencyMode));

TestableMediaTrack videoTrack{eTRACK_VIDEO, mPrivateInstanceAAMP, "video",
mStreamAbstractionAAMP_MPD};
Expand Down Expand Up @@ -796,7 +798,6 @@ TEST_F(MediaTrackTests, MediaTrackConstructorTest)
constexpr int kMaxFragmentCached{4};
constexpr int kMaxFragmentChunkCached{20};

mPrivateInstanceAAMP->SetLLDashChunkMode(false);
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentCached))
.WillRepeatedly(Return(kMaxFragmentCached));
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
Expand All @@ -811,12 +812,11 @@ TEST_F(MediaTrackTests, MediaTrackConstructorChunkModeTest)
constexpr int kMaxFragmentCached{4};
constexpr int kMaxFragmentChunkCached{20};

mPrivateInstanceAAMP->SetLLDashChunkMode(true);
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentCached))
.WillRepeatedly(Return(kMaxFragmentCached));
EXPECT_CALL(*g_mockAampConfig, GetConfigValue(eAAMPConfig_MaxFragmentChunkCached))
.WillRepeatedly(Return(kMaxFragmentChunkCached));

EXPECT_CALL(*g_mockPrivateInstanceAAMP, GetLLDashChunkMode()).WillOnce(Return(true));
TestableMediaTrack videoTrack{eTRACK_VIDEO, mPrivateInstanceAAMP, "video", mStreamAbstractionAAMP_MPD};
EXPECT_EQ(videoTrack.GetCachedFragmentChunksSize(), kMaxFragmentChunkCached);
}
7 changes: 3 additions & 4 deletions test/utests/tests/PrivAampTests/PrivAampTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4322,11 +4322,10 @@ TEST_F(PrivAampTests, TuneHelperWithAampTsbInjection)
EXPECT_FALSE(p_aamp->mpStreamAbstractionAAMP->trickplayMode);
// Verify that the StreamAbstraction seek position is updated to the expected value
EXPECT_CALL(*g_mockStreamAbstractionAAMP_MPD, SeekPosUpdate(SEEK_POS)).Times(2);
/* We only expect SetVideoPlaybackRate() to be called when not in LLD mode, so only one of the TuneHelper() calls
will trigger the call*/
EXPECT_CALL(*g_mockStreamAbstractionAAMP, SetVideoPlaybackRate(AAMP_RATE_PAUSE)).Times(1);

EXPECT_CALL(*g_mockStreamAbstractionAAMP, ReinitializeInjection(AAMP_RATE_PAUSE)).Times(2);
p_aamp->TuneHelper(eTUNETYPE_SEEK);
EXPECT_TRUE(p_aamp->mpStreamAbstractionAAMP->trickplayMode);

// Verify that the StreamAbstraction object is not recreated
EXPECT_EQ(savedStreamAbstractionAAMP, p_aamp->mpStreamAbstractionAAMP);

Expand Down
2 changes: 1 addition & 1 deletion test/utests/tests/StreamAbstractionAAMP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ set (DASH_PARSER_SOURCES ${AAMP_ROOT}/dash/xml/DomDocument.cpp
set(TEST_SOURCES FunctionalTests.cpp
StreamAbstractionAAMP.cpp)

set(AAMP_SOURCES ${AAMP_ROOT}/streamabstraction.cpp ${AAMP_ROOT}/fragmentcollector_mpd.cpp ${AAMP_ROOT}/AampMPDParseHelper.cpp ${AAMP_ROOT}/AampMPDUtils.cpp ${AAMP_ROOT}/AampTrackWorker.cpp ${DASH_PARSER_SOURCES})
set(AAMP_SOURCES ${AAMP_ROOT}/streamabstraction.cpp )

add_executable(${EXEC_NAME}
${TEST_SOURCES}
Expand Down
Loading