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/Underflow.h"
21 : #include "RialtoServerLogging.h"
22 : #include "TypeConverters.h"
23 :
24 : namespace firebolt::rialto::server::tasks::generic
25 : {
26 6 : Underflow::Underflow(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, IGstGenericPlayerClient *client,
27 6 : bool underflowEnabled, MediaSourceType sourceType)
28 6 : : m_context{context}, m_player{player}, m_gstPlayerClient{client}, m_underflowEnabled{underflowEnabled},
29 6 : m_sourceType{sourceType}
30 : {
31 6 : RIALTO_SERVER_LOG_DEBUG("Constructing Underflow");
32 : }
33 :
34 7 : Underflow::~Underflow()
35 : {
36 6 : RIALTO_SERVER_LOG_DEBUG("Underflow finished");
37 7 : }
38 :
39 5 : void Underflow::execute() const
40 : {
41 5 : RIALTO_SERVER_LOG_WARN("Executing Underflow for %s source", common::convertMediaSourceType(m_sourceType));
42 5 : if (!m_underflowEnabled)
43 : {
44 2 : return;
45 : }
46 :
47 4 : auto elem = m_context.streamInfo.find(m_sourceType);
48 4 : if (elem != m_context.streamInfo.end())
49 : {
50 3 : StreamInfo &streamInfo = elem->second;
51 3 : if (streamInfo.underflowOccured)
52 : {
53 1 : return;
54 : }
55 :
56 2 : streamInfo.underflowOccured = true;
57 :
58 2 : if (m_gstPlayerClient)
59 : {
60 2 : m_gstPlayerClient->notifyBufferUnderflow(m_sourceType);
61 : }
62 : }
63 : }
64 :
65 : } // namespace firebolt::rialto::server::tasks::generic
|