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 % 32 32
Test Date: 2025-02-18 13:13:53 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              :                            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 :     m_gstPlayerClient->invalidateActiveRequests(m_type);
      50            3 :     GstElement *source{nullptr};
      51            3 :     auto sourceElem = m_context.streamInfo.find(m_type);
      52            3 :     if (sourceElem != m_context.streamInfo.end())
      53              :     {
      54            2 :         source = sourceElem->second.appSrc;
      55              :     }
      56            3 :     if (!source)
      57              :     {
      58            1 :         RIALTO_SERVER_LOG_WARN("failed to flush - source is NULL");
      59            1 :         return;
      60              :     }
      61            2 :     sourceElem->second.buffers.clear();
      62            2 :     sourceElem->second.isDataNeeded = false;
      63            2 :     sourceElem->second.isNeedDataPending = false;
      64            2 :     m_player.stopPositionReportingAndCheckAudioUnderflowTimer();
      65            2 :     GstEvent *flushStart = m_gstWrapper->gstEventNewFlushStart();
      66            2 :     if (!m_gstWrapper->gstElementSendEvent(source, flushStart))
      67              :     {
      68            1 :         RIALTO_SERVER_LOG_WARN("failed to send flush-start event");
      69              :     }
      70            2 :     GstEvent *flushStop = m_gstWrapper->gstEventNewFlushStop(FALSE);
      71            2 :     if (!m_gstWrapper->gstElementSendEvent(source, flushStop))
      72              :     {
      73            1 :         RIALTO_SERVER_LOG_WARN("failed to send flush-stop event");
      74              :     }
      75              : 
      76              :     // Turn audio off, removing audio sink from playsink
      77            2 :     m_player.setPlaybinFlags(false);
      78              : }
      79              : } // namespace firebolt::rialto::server::tasks::generic
        

Generated by: LCOV version 2.0-1