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 2022 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/NeedData.h"
21 : #include "GenericPlayerContext.h"
22 : #include "IGstGenericPlayerClient.h"
23 : #include "RialtoServerLogging.h"
24 : #include "TypeConverters.h"
25 : #include <gst/gst.h>
26 :
27 : namespace firebolt::rialto::server::tasks::generic
28 : {
29 19 : NeedData::NeedData(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, IGstGenericPlayerClient *client,
30 19 : GstAppSrc *src)
31 19 : : m_context{context}, m_player{player}, m_gstPlayerClient{client}, m_src{src}
32 : {
33 19 : RIALTO_SERVER_LOG_DEBUG("Constructing NeedData");
34 : }
35 :
36 20 : NeedData::~NeedData()
37 : {
38 19 : RIALTO_SERVER_LOG_DEBUG("NeedData finished");
39 20 : }
40 :
41 18 : void NeedData::execute() const
42 : {
43 18 : RIALTO_SERVER_LOG_DEBUG("Executing NeedData");
44 :
45 27 : for (auto &elem : m_context.streamInfo)
46 : {
47 24 : firebolt::rialto::MediaSourceType sourceType = elem.first;
48 24 : if (elem.second.appSrc == GST_ELEMENT(m_src))
49 : {
50 15 : RIALTO_SERVER_LOG_DEBUG("%s source needs data", common::convertMediaSourceType(sourceType));
51 :
52 15 : elem.second.isDataNeeded = true;
53 :
54 15 : if (!elem.second.buffers.empty())
55 : {
56 1 : RIALTO_SERVER_LOG_INFO("Attaching cached data for %s", common::convertMediaSourceType(sourceType));
57 1 : m_player.attachData(sourceType);
58 : }
59 :
60 15 : if (m_gstPlayerClient && !elem.second.isNeedDataPending)
61 : {
62 12 : if (sourceType == MediaSourceType::AUDIO && m_context.audioSourceRemoved)
63 : {
64 1 : RIALTO_SERVER_LOG_DEBUG("Audio source is removed, no need to request data");
65 15 : break;
66 : }
67 11 : elem.second.isNeedDataPending = m_gstPlayerClient->notifyNeedMediaData(sourceType);
68 : }
69 14 : break;
70 : }
71 : }
72 18 : }
73 : } // namespace firebolt::rialto::server::tasks::generic
|