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<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper) const override;
38 : };
39 :
40 : class GstDispatcherThread : public IGstDispatcherThread
41 : {
42 : public:
43 : GstDispatcherThread(IGstDispatcherThreadClient &client, GstElement *pipeline,
44 : const std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> &gstWrapper);
45 : ~GstDispatcherThread() override;
46 :
47 : private:
48 : /**
49 : * @brief For handling gst bus messages in Gstreamer dispatcher thread
50 : *
51 : * @param[in] pipeline : The pipeline
52 : */
53 : void gstBusEventHandler(GstElement *pipeline);
54 :
55 : private:
56 : /**
57 : * @brief The listening client.
58 : */
59 : IGstDispatcherThreadClient &m_client;
60 :
61 : /**
62 : * @brief The gstreamer wrapper object.
63 : */
64 : std::shared_ptr<firebolt::rialto::wrappers::IGstWrapper> m_gstWrapper;
65 :
66 : /**
67 : * @brief Flag used to check, if task thread is active
68 : */
69 : std::atomic<bool> m_isGstreamerDispatcherActive;
70 :
71 : /**
72 : * @brief Thread for handling gst bus callbacks
73 : */
74 : std::thread m_gstBusDispatcherThread;
75 : };
76 : } // namespace firebolt::rialto::server
77 :
78 : #endif // FIREBOLT_RIALTO_SERVER_GST_DISPATCHER_THREAD_H_
|