LCOV - code coverage report
Current view: top level - media/server/gstplayer/source/tasks/generic - DeepElementAdded.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 45 45
Test Date: 2025-02-18 13:13:53 Functions: 100.0 % 4 4

            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/DeepElementAdded.h"
      21              : #include "RialtoServerLogging.h"
      22              : 
      23              : namespace
      24              : {
      25            1 : void onHaveType(GstElement *typefind, guint probability, const GstCaps *caps, gpointer data)
      26              : {
      27            1 :     firebolt::rialto::server::IGstGenericPlayerPrivate *player =
      28              :         static_cast<firebolt::rialto::server::IGstGenericPlayerPrivate *>(data);
      29            1 :     player->updatePlaybackGroup(typefind, caps);
      30              : }
      31              : } // namespace
      32              : 
      33              : namespace firebolt::rialto::server::tasks::generic
      34              : {
      35           14 : DeepElementAdded::DeepElementAdded(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
      36              :                                    const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper,
      37              :                                    const std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> &glibWrapper,
      38           14 :                                    GstBin *pipeline, GstBin *bin, GstElement *element)
      39           14 :     : m_context{context}, m_player{player}, m_gstWrapper{gstWrapper}, m_glibWrapper{glibWrapper},
      40           14 :       m_pipeline{pipeline}, m_bin{bin}, m_element{element}, m_elementName{nullptr}, m_callbackRegistered{false}
      41              : {
      42           14 :     RIALTO_SERVER_LOG_DEBUG("Constructing DeepElementAdded");
      43              :     // Signal connection has to happen immediately (we cannot wait for thread switch)
      44           14 :     if (m_gstWrapper->gstObjectParent(m_element) == m_gstWrapper->gstObjectCast(m_bin))
      45              :     {
      46           12 :         m_elementName = m_gstWrapper->gstElementGetName(m_element);
      47           12 :         if (m_elementName)
      48              :         {
      49           10 :             RIALTO_SERVER_LOG_DEBUG("Element Name = %s", m_elementName);
      50           10 :             if (m_glibWrapper->gStrrstr(m_elementName, "typefind"))
      51              :             {
      52            3 :                 RIALTO_SERVER_LOG_DEBUG("Registering onHaveType callback");
      53            3 :                 m_glibWrapper->gSignalConnect(G_OBJECT(m_element), "have-type", G_CALLBACK(onHaveType), &m_player);
      54            3 :                 m_callbackRegistered = true;
      55              :             }
      56              :         }
      57              :     }
      58           14 : }
      59              : 
      60           15 : DeepElementAdded::~DeepElementAdded()
      61              : {
      62           14 :     RIALTO_SERVER_LOG_DEBUG("DeepElementAdded finished");
      63           14 :     m_glibWrapper->gFree(m_elementName);
      64           15 : }
      65              : 
      66            8 : void DeepElementAdded::execute() const
      67              : {
      68            8 :     RIALTO_SERVER_LOG_DEBUG("Executing DeepElementAdded");
      69            8 :     m_context.playbackGroup.m_gstPipeline = GST_ELEMENT(m_pipeline);
      70              : 
      71            8 :     RIALTO_SERVER_LOG_DEBUG("Element = %p Bin = %p Pipeline = %p", m_element, m_bin, m_pipeline);
      72            8 :     if (m_callbackRegistered)
      73              :     {
      74            1 :         m_context.playbackGroup.m_curAudioTypefind = m_element;
      75              :     }
      76            8 :     if (m_elementName)
      77              :     {
      78            7 :         if (m_gstWrapper->gstObjectCast(m_bin) == m_gstWrapper->gstObjectCast(m_context.playbackGroup.m_curAudioDecodeBin))
      79              :         {
      80            2 :             if (m_glibWrapper->gStrrstr(m_elementName, "parse"))
      81              :             {
      82            1 :                 RIALTO_SERVER_LOG_DEBUG("curAudioParse = %s", m_elementName);
      83            1 :                 m_context.playbackGroup.m_curAudioParse = m_element;
      84              :             }
      85            1 :             else if (m_glibWrapper->gStrrstr(m_elementName, "dec"))
      86              :             {
      87            1 :                 RIALTO_SERVER_LOG_DEBUG("curAudioDecoder = %s", m_elementName);
      88            1 :                 m_context.playbackGroup.m_curAudioDecoder = m_element;
      89              :             }
      90              :         }
      91              :         else
      92              :         {
      93            5 :             if (m_glibWrapper->gStrrstr(m_elementName, "audiosink"))
      94              :             {
      95              :                 GstElement *audioSinkParent =
      96            3 :                     reinterpret_cast<GstElement *>(m_gstWrapper->gstElementGetParent(m_element));
      97            3 :                 if (audioSinkParent)
      98              :                 {
      99            3 :                     gchar *audioSinkParentName = m_gstWrapper->gstElementGetName(audioSinkParent);
     100            3 :                     RIALTO_SERVER_LOG_DEBUG("audioSinkParentName = %s", audioSinkParentName);
     101            3 :                     if (audioSinkParentName && m_glibWrapper->gStrrstr(audioSinkParentName, "bin"))
     102              :                     {
     103            1 :                         RIALTO_SERVER_LOG_DEBUG("curAudioPlaysinkBin = %s", audioSinkParentName);
     104            1 :                         m_context.playbackGroup.m_curAudioPlaysinkBin = audioSinkParent;
     105              :                     }
     106            3 :                     m_glibWrapper->gFree(audioSinkParentName);
     107              :                 }
     108              :             }
     109              :         }
     110              :     }
     111            8 : }
     112              : } // namespace firebolt::rialto::server::tasks::generic
        

Generated by: LCOV version 2.0-1