Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -395,13 +395,13 @@ class IGenericPlayerTaskFactory
* @param[in] context : The GstGenericPlayer context
* @param[in] player : The GstGenericPlayer instance
* @param[in] typefind : The typefind element.
* @param[in] caps : The GstCaps of added element
* @param[in] caps : The GstCaps of added element.
*
Comment on lines 395 to 399
* @retval the new UpdatePlaybackGroup task instance.
*/
virtual std::unique_ptr<IPlayerTask> createUpdatePlaybackGroup(GenericPlayerContext &context,
IGstGenericPlayerPrivate &player,
GstElement *typefind, const GstCaps *caps) const = 0;
GstElement *typefind, GstCaps *caps) const = 0;

/**
* @brief Creates a RenderFrame task.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GenericPlayerTaskFactory : public IGenericPlayerTaskFactory
bool underflowEnable, MediaSourceType sourceType) const override;
std::unique_ptr<IPlayerTask> createUpdatePlaybackGroup(GenericPlayerContext &context,
IGstGenericPlayerPrivate &player, GstElement *typefind,
const GstCaps *caps) const override;
GstCaps *caps) const override;
std::unique_ptr<IPlayerTask> createRenderFrame(GenericPlayerContext &context,
IGstGenericPlayerPrivate &player) const override;
std::unique_ptr<IPlayerTask> createPing(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UpdatePlaybackGroup : public IPlayerTask
UpdatePlaybackGroup(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper, GstElement *typefind,
const GstCaps *caps);
GstCaps *caps);
~UpdatePlaybackGroup() override;
void execute() const override;

Expand All @@ -46,7 +46,7 @@ class UpdatePlaybackGroup : public IPlayerTask
std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> m_gstWrapper;
std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> m_glibWrapper;
GstElement *m_typefind;
const GstCaps *m_caps;
GstCaps *m_caps;
Comment on lines 48 to +49
};
} // namespace firebolt::rialto::server::tasks::generic

Expand Down
8 changes: 7 additions & 1 deletion media/server/gstplayer/source/GstGenericPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ void GstGenericPlayer::deepElementAdded(GstBin *pipeline, GstBin *bin, GstElemen
RIALTO_SERVER_LOG_DEBUG("Deep element %s added to the pipeline", GST_ELEMENT_NAME(element));
if (self->m_workerThread)
{
self->m_gstWrapper->gstObjectRef(element);
self->m_workerThread->enqueueTask(
self->m_taskFactory->createDeepElementAdded(self->m_context, *self, pipeline, bin, element));
}
Expand Down Expand Up @@ -2646,7 +2647,12 @@ void GstGenericPlayer::handleBusMessage(GstMessage *message)

void GstGenericPlayer::updatePlaybackGroup(GstElement *typefind, const GstCaps *caps)
{
m_workerThread->enqueueTask(m_taskFactory->createUpdatePlaybackGroup(m_context, *this, typefind, caps));
if (m_workerThread)
{
m_gstWrapper->gstObjectRef(typefind);
GstCaps *ownedCaps{caps ? m_gstWrapper->gstCapsCopy(caps) : nullptr};
m_workerThread->enqueueTask(m_taskFactory->createUpdatePlaybackGroup(m_context, *this, typefind, ownedCaps));
}
}

void GstGenericPlayer::addAutoVideoSinkChild(GObject *object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ DeepElementAdded::~DeepElementAdded()
{
RIALTO_SERVER_LOG_DEBUG("DeepElementAdded finished");
m_glibWrapper->gFree(m_elementName);
m_gstWrapper->gstObjectUnref(m_element);
}

void DeepElementAdded::execute() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ std::unique_ptr<IPlayerTask> GenericPlayerTaskFactory::createUnderflow(GenericPl

std::unique_ptr<IPlayerTask> GenericPlayerTaskFactory::createUpdatePlaybackGroup(GenericPlayerContext &context,
IGstGenericPlayerPrivate &player,
GstElement *typefind,
const GstCaps *caps) const
GstElement *typefind, GstCaps *caps) const
{
return std::make_unique<tasks::generic::UpdatePlaybackGroup>(context, player, m_gstWrapper, m_glibWrapper, typefind,
caps);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace firebolt::rialto::server::tasks::generic
UpdatePlaybackGroup::UpdatePlaybackGroup(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> gstWrapper,
std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> glibWrapper,
GstElement *typefind, const GstCaps *caps)
GstElement *typefind, GstCaps *caps)
: m_context{context}, m_player{player}, m_gstWrapper{gstWrapper}, m_glibWrapper{glibWrapper}, m_typefind{typefind},
m_caps{caps}
{
Expand All @@ -35,6 +35,11 @@ UpdatePlaybackGroup::UpdatePlaybackGroup(GenericPlayerContext &context, IGstGene
UpdatePlaybackGroup::~UpdatePlaybackGroup()
{
RIALTO_SERVER_LOG_DEBUG("UpdatePlaybackGroup finished");
m_gstWrapper->gstObjectUnref(m_typefind);
if (m_caps)
{
m_gstWrapper->gstCapsUnref(m_caps);
}
Comment on lines +38 to +42
}

void UpdatePlaybackGroup::execute() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1757,14 +1757,29 @@ TEST_F(GstGenericPlayerPrivateTest, shouldUpdatePlaybackGroup)
{
GstElement typefind;
GstCaps caps;
GstCaps copiedCaps;
std::unique_ptr<IPlayerTask> task{std::make_unique<StrictMock<PlayerTaskMock>>()};
EXPECT_CALL(dynamic_cast<StrictMock<PlayerTaskMock> &>(*task), execute());
EXPECT_CALL(m_taskFactoryMock, createUpdatePlaybackGroup(_, _, &typefind, &caps))
EXPECT_CALL(*m_gstWrapperMock, gstObjectRef(&typefind));
EXPECT_CALL(*m_gstWrapperMock, gstCapsCopy(&caps)).WillOnce(Return(&copiedCaps));
EXPECT_CALL(m_taskFactoryMock, createUpdatePlaybackGroup(_, _, &typefind, &copiedCaps))
.WillOnce(Return(ByMove(std::move(task))));

m_sut->updatePlaybackGroup(&typefind, &caps);
}

TEST_F(GstGenericPlayerPrivateTest, shouldUpdatePlaybackGroupWithNullCaps)
{
GstElement typefind;
std::unique_ptr<IPlayerTask> task{std::make_unique<StrictMock<PlayerTaskMock>>()};
EXPECT_CALL(dynamic_cast<StrictMock<PlayerTaskMock> &>(*task), execute());
EXPECT_CALL(*m_gstWrapperMock, gstObjectRef(&typefind));
EXPECT_CALL(m_taskFactoryMock, createUpdatePlaybackGroup(_, _, &typefind, nullptr))
.WillOnce(Return(ByMove(std::move(task))));

m_sut->updatePlaybackGroup(&typefind, nullptr);
}

TEST_F(GstGenericPlayerPrivateTest, shouldAddAutoVideoSinkChildSink)
{
const GenericPlayerContext *context = getPlayerContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ TEST_F(GstGenericPlayerTest, shouldAddDeepElement)
GstElement element{};
std::unique_ptr<IPlayerTask> task{std::make_unique<StrictMock<PlayerTaskMock>>()};
EXPECT_CALL(dynamic_cast<StrictMock<PlayerTaskMock> &>(*task), execute());
EXPECT_CALL(*m_gstWrapperMock, gstObjectRef(&element));
EXPECT_CALL(m_taskFactoryMock, createDeepElementAdded(_, _, _, _, &element)).WillOnce(Return(ByMove(std::move(task))));

triggerDeepElementAdded(&element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1951,6 +1951,8 @@ void GenericTasksTestsBase::shouldNotRegisterCallbackWhenPtrsAreNotEqual()

void GenericTasksTestsBase::constructDeepElementAdded()
{
// The element reference taken in GstGenericPlayer::deepElementAdded is released in the task destructor.
EXPECT_CALL(*testContext->m_gstWrapper, gstObjectUnref(testContext->m_element));
firebolt::rialto::server::tasks::generic::DeepElementAdded task{testContext->m_context,
testContext->m_gstPlayer,
testContext->m_gstWrapper,
Expand Down Expand Up @@ -2033,6 +2035,8 @@ void GenericTasksTestsBase::shouldSetTypefindElement()

void GenericTasksTestsBase::triggerDeepElementAdded()
{
// The element reference taken in GstGenericPlayer::deepElementAdded is released in the task destructor.
EXPECT_CALL(*testContext->m_gstWrapper, gstObjectUnref(testContext->m_element));
firebolt::rialto::server::tasks::generic::DeepElementAdded task{testContext->m_context,
testContext->m_gstPlayer,
testContext->m_gstWrapper,
Expand Down Expand Up @@ -2197,6 +2201,8 @@ void GenericTasksTestsBase::checkAudioSinkPlaybackGroupAdded()

void GenericTasksTestsBase::triggerUpdatePlaybackGroupNoCaps()
{
// The typefind reference taken in GstGenericPlayer::updatePlaybackGroup is released in the task destructor.
EXPECT_CALL(*testContext->m_gstWrapper, gstObjectUnref(testContext->m_element));
firebolt::rialto::server::tasks::generic::UpdatePlaybackGroup task{testContext->m_context,
testContext->m_gstPlayer,
testContext->m_gstWrapper,
Expand All @@ -2219,6 +2225,10 @@ void GenericTasksTestsBase::shouldReturnNullCaps()

void GenericTasksTestsBase::triggerUpdatePlaybackGroup()
{
// The typefind and caps references (owned copy) taken in GstGenericPlayer::updatePlaybackGroup are released in the
// task destructor.
EXPECT_CALL(*testContext->m_gstWrapper, gstObjectUnref(testContext->m_element));
EXPECT_CALL(*testContext->m_gstWrapper, gstCapsUnref(&testContext->m_gstCaps1));
firebolt::rialto::server::tasks::generic::UpdatePlaybackGroup task{testContext->m_context,
testContext->m_gstPlayer,
testContext->m_gstWrapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ TEST_F(GenericPlayerTaskFactoryTest, ShouldCreateAttachSource)

TEST_F(GenericPlayerTaskFactoryTest, ShouldCreateDeepElementAdded)
{
GstElement element{};
EXPECT_CALL(*m_gstWrapper, gstObjectParent(_)).WillOnce(Return(nullptr));
EXPECT_CALL(*m_gstWrapper, gstObjectCast(_)).WillOnce(Return(nullptr));
EXPECT_CALL(*m_gstWrapper, gstElementGetName(_)).WillOnce(Return(nullptr));
EXPECT_CALL(*m_glibWrapper, gFree(nullptr));
auto task = m_sut.createDeepElementAdded(m_context, m_gstPlayer, nullptr, nullptr, nullptr);
// The task destructor releases the element reference taken when the task is scheduled.
EXPECT_CALL(*m_gstWrapper, gstObjectUnref(&element));
auto task = m_sut.createDeepElementAdded(m_context, m_gstPlayer, nullptr, nullptr, &element);
EXPECT_NE(task, nullptr);
EXPECT_NO_THROW(dynamic_cast<firebolt::rialto::server::tasks::generic::DeepElementAdded &>(*task));
}
Expand Down Expand Up @@ -312,7 +315,10 @@ TEST_F(GenericPlayerTaskFactoryTest, ShouldCreateSetPlaybackRate)

TEST_F(GenericPlayerTaskFactoryTest, ShouldCreateUpdatePlaybackGroup)
{
auto task = m_sut.createUpdatePlaybackGroup(m_context, m_gstPlayer, nullptr, nullptr);
GstElement typefind{};
// The task destructor releases the typefind reference taken when the task is scheduled.
EXPECT_CALL(*m_gstWrapper, gstObjectUnref(&typefind));
auto task = m_sut.createUpdatePlaybackGroup(m_context, m_gstPlayer, &typefind, nullptr);
EXPECT_NE(task, nullptr);
EXPECT_NO_THROW(dynamic_cast<firebolt::rialto::server::tasks::generic::UpdatePlaybackGroup &>(*task));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ class GenericPlayerTaskFactoryMock : public IGenericPlayerTaskFactory
MediaSourceType sourceType),
(const, override));
MOCK_METHOD(std::unique_ptr<IPlayerTask>, createUpdatePlaybackGroup,
(GenericPlayerContext & context, IGstGenericPlayerPrivate &player, GstElement *typefind,
const GstCaps *caps),
(GenericPlayerContext & context, IGstGenericPlayerPrivate &player, GstElement *typefind, GstCaps *caps),
(const, override));
MOCK_METHOD(std::unique_ptr<IPlayerTask>, createRenderFrame,
(GenericPlayerContext & context, IGstGenericPlayerPrivate &player), (const, override));
Expand Down
Loading