LCOV - code coverage report
Current view: top level - media/server/gstplayer/source/tasks/generic - RemoveSource.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 29 29
Test Date: 2026-06-17 06:35:35 Functions: 100.0 % 3 3

            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_context.audioSourceRemoved = true;
      49            3 :     if (m_gstPlayerClient)
      50              :     {
      51            3 :         m_gstPlayerClient->invalidateActiveRequests(m_type);
      52              :     }
      53            3 :     auto sourceElem = m_context.streamInfo.find(m_type);
      54            3 :     if (sourceElem == m_context.streamInfo.end())
      55              :     {
      56            1 :         RIALTO_SERVER_LOG_WARN("Failed to remove source - streamInfo not found");
      57            1 :         return;
      58              :     }
      59            2 :     StreamInfo &streamInfo = sourceElem->second;
      60            4 :     for (auto &buffer : streamInfo.buffers)
      61              :     {
      62            2 :         m_gstWrapper->gstBufferUnref(buffer);
      63              :     }
      64            2 :     streamInfo.buffers.clear();
      65            2 :     streamInfo.isDataNeeded = false;
      66            2 :     streamInfo.isNeedDataPending = false;
      67            2 :     m_context.initialPositions.erase(streamInfo.appSrc);
      68              : 
      69              :     // Reset Eos info
      70            2 :     m_context.endOfStreamInfo.erase(m_type);
      71            2 :     m_context.eosNotified = false;
      72              : 
      73            2 :     RIALTO_SERVER_LOG_MIL("%s source removed", common::convertMediaSourceType(m_type));
      74              : }
      75              : } // namespace firebolt::rialto::server::tasks::generic
        

Generated by: LCOV version 2.0-1