Skip to content

Commit c960761

Browse files
skywojciechowskimaczs
authored andcommitted
Allow to switch audio codec, when audio is re-attached (#448)
Summary: Allow to switch audio codec, when audio is re-attached Type: Fix Test Plan: UT/CT, Fullstack Jira: LLAMA-18057
1 parent 6a01b68 commit c960761

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

media/server/gstplayer/include/tasks/generic/AttachSource.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AttachSource : public IPlayerTask
4747

4848
private:
4949
void addSource() const;
50+
void reattachAudioSource() const;
5051

5152
GenericPlayerContext &m_context;
5253
std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> m_gstWrapper;

media/server/gstplayer/source/tasks/generic/AttachSource.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ void AttachSource::execute() const
5959
{
6060
addSource();
6161
}
62+
else if (m_attachedSource->getType() == MediaSourceType::AUDIO)
63+
{
64+
reattachAudioSource();
65+
}
6266
else
6367
{
6468
RIALTO_SERVER_LOG_ERROR("cannot update caps");
@@ -106,4 +110,14 @@ void AttachSource::addSource() const
106110
if (caps)
107111
m_gstWrapper->gstCapsUnref(caps);
108112
}
113+
114+
void AttachSource::reattachAudioSource() const
115+
{
116+
if (!m_player.reattachSource(m_attachedSource))
117+
{
118+
RIALTO_SERVER_LOG_ERROR("Reattaching source failed!");
119+
return;
120+
}
121+
RIALTO_SERVER_LOG_MIL("Audio source reattached");
122+
}
109123
} // namespace firebolt::rialto::server::tasks::generic

tests/unittests/media/server/gstplayer/genericPlayer/tasksTests/AttachSourceTest.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,17 @@ TEST_F(AttachSourceTest, shouldFailToAttachUnknownSource)
161161
triggerAttachUnknownSource();
162162
}
163163

164-
TEST_F(AttachSourceTest, shouldSkipSwitchAudioSourceWhenSourceIsNotRemoved)
164+
TEST_F(AttachSourceTest, shouldSwitchAudioSourceWhenSourceIsReattached)
165165
{
166166
setContextStreamInfo(firebolt::rialto::MediaSourceType::AUDIO);
167+
shouldReattachAudioSource();
168+
triggerReattachAudioSource();
169+
}
170+
171+
TEST_F(AttachSourceTest, shouldFailToSwitchAudioSourceWhenSourceIsReattached)
172+
{
173+
setContextStreamInfo(firebolt::rialto::MediaSourceType::AUDIO);
174+
shouldFailToReattachAudioSource();
167175
triggerReattachAudioSource();
168176
}
169177

0 commit comments

Comments
 (0)