Line data Source code
1 : /*
2 : * If not stated otherwise in this file or this component's LICENSE file the
3 : * following copyright and licenses apply:
4 : *
5 : * Copyright 2023 Sky UK
6 : *
7 : * Licensed under the Apache License, Version 2.0 (the "License");
8 : * you may not use this file except in compliance with the License.
9 : * You may obtain a copy of the License at
10 : *
11 : * http://www.apache.org/licenses/LICENSE-2.0
12 : *
13 : * Unless required by applicable law or agreed to in writing, software
14 : * distributed under the License is distributed on an "AS IS" BASIS,
15 : * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 : * See the License for the specific language governing permissions and
17 : * limitations under the License.
18 : */
19 :
20 : #include "tasks/generic/RemoveSource.h"
21 : #include "RialtoServerLogging.h"
22 : #include "TypeConverters.h"
23 :
24 : namespace firebolt::rialto::server::tasks::generic
25 : {
26 5 : RemoveSource::RemoveSource(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
27 : IGstGenericPlayerClient *client,
28 : const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper,
29 5 : const MediaSourceType &type)
30 5 : : m_context{context}, m_player{player}, m_gstPlayerClient{client}, m_gstWrapper{gstWrapper}, m_type{type}
31 : {
32 5 : RIALTO_SERVER_LOG_DEBUG("Constructing RemoveSource");
33 : }
34 :
35 6 : RemoveSource::~RemoveSource()
36 : {
37 5 : RIALTO_SERVER_LOG_DEBUG("RemoveSource finished");
38 6 : }
39 :
40 4 : void RemoveSource::execute() const
41 : {
42 4 : RIALTO_SERVER_LOG_DEBUG("Executing RemoveSource for %s source", common::convertMediaSourceType(m_type));
43 4 : if (MediaSourceType::AUDIO != m_type)
44 : {
45 1 : RIALTO_SERVER_LOG_DEBUG("RemoveSource not supported for type != AUDIO");
46 2 : return;
47 : }
48 3 : m_player.clearAudioFirstFrameFallbackProbe();
49 3 : m_context.firstAudioFrameReceived = false;
50 3 : m_context.audioSourceRemoved = true;
51 3 : if (m_gstPlayerClient)
52 : {
53 3 : m_gstPlayerClient->invalidateActiveRequests(m_type);
54 : }
55 3 : auto sourceElem = m_context.streamInfo.find(m_type);
56 3 : if (sourceElem == m_context.streamInfo.end())
57 : {
58 1 : RIALTO_SERVER_LOG_WARN("Failed to remove source - streamInfo not found");
59 1 : return;
60 : }
61 2 : StreamInfo &streamInfo = sourceElem->second;
62 4 : for (auto &buffer : streamInfo.buffers)
63 : {
64 2 : m_gstWrapper->gstBufferUnref(buffer);
65 : }
66 2 : streamInfo.buffers.clear();
67 2 : streamInfo.isDataNeeded = false;
68 2 : streamInfo.isNeedDataPending = false;
69 2 : m_context.initialPositions.erase(streamInfo.appSrc);
70 :
71 : // Reset Eos info
72 2 : m_context.endOfStreamInfo.erase(m_type);
73 2 : m_context.eosNotified = false;
74 :
75 2 : RIALTO_SERVER_LOG_MIL("%s source removed", common::convertMediaSourceType(m_type));
76 : }
77 : } // namespace firebolt::rialto::server::tasks::generic
|