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 : #ifndef FIREBOLT_RIALTO_SERVER_GST_DISPATCHER_THREAD_H_
21 : #define FIREBOLT_RIALTO_SERVER_GST_DISPATCHER_THREAD_H_
22 :
23 : #include "IGstDispatcherThread.h"
24 : #include <atomic>
25 : #include <gst/gst.h>
26 : #include <memory>
27 : #include <thread>
28 :
29 : namespace firebolt::rialto::server
30 : {
31 : class GstDispatcherThreadFactory : public IGstDispatcherThreadFactory
32 : {
33 : public:
34 4 : ~GstDispatcherThreadFactory() override = default;
35 : std::unique_ptr<IGstDispatcherThread>
36 : createGstDispatcherThread(IGstDispatcherThreadClient &client, GstElement *pipeline,
37 : const std::shared_ptr<IFlushOnPrerollController> &flushOnPrerollController,
38 : const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper) const override;
39 : };
40 :
41 : class GstDispatcherThread : public IGstDispatcherThread
42 : {
43 : public:
44 : GstDispatcherThread(IGstDispatcherThreadClient &client, GstElement *pipeline,
45 : const std::shared_ptr<IFlushOnPrerollController> &flushOnPrerollController,
46 : const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper);
47 : ~GstDispatcherThread() override;
48 :
49 : private:
50 : /**
51 : * @brief For handling gst bus messages in Gstreamer dispatcher thread
52 : *
53 : * @param[in] pipeline : The pipeline
54 : */
55 : void gstBusEventHandler(GstElement *pipeline);
56 :
57 : private:
58 : /**
59 : * @brief The listening client.
60 : */
61 : IGstDispatcherThreadClient &m_client;
62 :
63 : /**
64 : * @brief The flush on preroll controller.
65 : */
66 : std::shared_ptr<IFlushOnPrerollController> m_flushOnPrerollController;
67 :
68 : /**
69 : * @brief The gstreamer wrapper object.
70 : */
71 : std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> m_gstWrapper;
72 :
73 : /**
74 : * @brief Flag used to check, if task thread is active
75 : */
76 : std::atomic<bool> m_isGstreamerDispatcherActive;
77 :
78 : /**
79 : * @brief Thread for handling gst bus callbacks
80 : */
81 : std::thread m_gstBusDispatcherThread;
82 : };
83 : } // namespace firebolt::rialto::server
84 :
85 : #endif // FIREBOLT_RIALTO_SERVER_GST_DISPATCHER_THREAD_H_
|