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/UpdatePlaybackGroup.h"
21 : #include "RialtoServerLogging.h"
22 :
23 : namespace firebolt::rialto::server::tasks::generic
24 : {
25 10 : UpdatePlaybackGroup::UpdatePlaybackGroup(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
26 : const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper,
27 : const std::shared_ptr<firebolt::rialto::wrappers::IGlibWrapper> &glibWrapper,
28 10 : GstElement *typefind, const GstCaps *caps)
29 10 : : m_context{context}, m_player{player}, m_gstWrapper{gstWrapper}, m_glibWrapper{glibWrapper}, m_typefind{typefind},
30 10 : m_caps{caps}
31 : {
32 10 : RIALTO_SERVER_LOG_DEBUG("Constructing UpdatePlaybackGroup");
33 : }
34 :
35 11 : UpdatePlaybackGroup::~UpdatePlaybackGroup()
36 : {
37 10 : RIALTO_SERVER_LOG_DEBUG("UpdatePlaybackGroup finished");
38 11 : }
39 :
40 9 : void UpdatePlaybackGroup::execute() const
41 : {
42 9 : RIALTO_SERVER_LOG_DEBUG("Executing UpdatePlaybackGroup");
43 9 : if (nullptr == m_caps)
44 : {
45 1 : RIALTO_SERVER_LOG_DEBUG("Typefind SRC Pad Caps NULL");
46 1 : return;
47 : }
48 8 : gchar *typefindCaps = m_gstWrapper->gstCapsToString(m_caps);
49 8 : if (typefindCaps)
50 : {
51 7 : RIALTO_SERVER_LOG_DEBUG("Typefind SRC Pad Strm Parsed Caps %s", typefindCaps);
52 7 : if (m_glibWrapper->gStrrstr(typefindCaps, "audio/"))
53 : {
54 6 : GstElement *typeFindParent = reinterpret_cast<GstElement *>(m_gstWrapper->gstElementGetParent(m_typefind));
55 6 : if (typeFindParent)
56 : {
57 5 : gchar *elementName = m_gstWrapper->gstElementGetName(typeFindParent);
58 5 : RIALTO_SERVER_LOG_DEBUG("elementName %s", elementName);
59 5 : if (elementName && m_glibWrapper->gStrrstr(elementName, "decodebin"))
60 : {
61 4 : RIALTO_SERVER_LOG_DEBUG("m_context.playbackGroup.curAudioDecodeBin %s", elementName);
62 4 : m_context.playbackGroup.m_curAudioDecodeBin = typeFindParent;
63 4 : gchar *typefindName = m_gstWrapper->gstElementGetName(m_typefind);
64 4 : RIALTO_SERVER_LOG_DEBUG("onTypeFound(): m_context.playbackGroup.curAudioTypefind %s", typefindName);
65 4 : m_glibWrapper->gFree(typefindName);
66 4 : m_context.playbackGroup.m_curAudioTypefind = m_typefind;
67 4 : if (m_context.pendingUseBuffering.has_value())
68 : {
69 1 : m_player.setUseBuffering();
70 : }
71 4 : if (m_context.playbackGroup.m_linkTypefindParser && m_context.playbackGroup.m_curAudioTypefind &&
72 2 : m_context.playbackGroup.m_curAudioParse)
73 : {
74 4 : if (m_gstWrapper->gstElementLink(m_context.playbackGroup.m_curAudioTypefind,
75 2 : m_context.playbackGroup.m_curAudioParse))
76 : {
77 1 : RIALTO_SERVER_LOG_DEBUG("Linked typefind to parser");
78 1 : m_context.playbackGroup.m_linkTypefindParser = false;
79 : }
80 : else
81 : {
82 1 : RIALTO_SERVER_LOG_DEBUG("Failed to link typefind to parser");
83 : }
84 : }
85 : }
86 5 : m_glibWrapper->gFree(elementName);
87 5 : m_gstWrapper->gstObjectUnref(typeFindParent);
88 : }
89 : }
90 7 : m_glibWrapper->gFree(typefindCaps);
91 : }
92 : }
93 : } // namespace firebolt::rialto::server::tasks::generic
|