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