Line data Source code
1 : /*
2 : * Copyright (C) 2022 Sky UK
3 : *
4 : * This library is free software; you can redistribute it and/or
5 : * modify it under the terms of the GNU Lesser General Public
6 : * License as published by the Free Software Foundation;
7 : * version 2.1 of the License.
8 : *
9 : * This library is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 : * Lesser General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public
15 : * License along with this library; if not, write to the Free Software
16 : * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 : */
18 :
19 : #pragma once
20 :
21 : #include <gst/gst.h>
22 :
23 : #include <string>
24 :
25 : #include "ControlBackendInterface.h"
26 : #include "MediaPlayerManager.h"
27 : #include "RialtoGStreamerMSEBaseSinkCallbacks.h"
28 : #include <atomic>
29 : #include <memory>
30 : #include <mutex>
31 : #include <optional>
32 : #include <queue>
33 :
34 : G_BEGIN_DECLS
35 :
36 : struct _RialtoMSEBaseSinkPrivate
37 : {
38 266 : _RialtoMSEBaseSinkPrivate() : m_sourceId(-1), m_isFlushOngoing(false), m_isStateCommitNeeded(false), m_hasDrm(true)
39 : {
40 : }
41 266 : ~_RialtoMSEBaseSinkPrivate()
42 : {
43 266 : if (m_caps)
44 131 : gst_caps_unref(m_caps);
45 266 : clearBuffersUnlocked();
46 : }
47 :
48 404 : void clearBuffersUnlocked()
49 : {
50 404 : m_isFlushOngoing = true;
51 404 : m_needDataCondVariable.notify_all();
52 430 : while (!m_samples.empty())
53 : {
54 26 : GstSample *sample = m_samples.front();
55 26 : m_samples.pop();
56 26 : gst_sample_unref(sample);
57 : }
58 404 : }
59 :
60 : GstPad *m_sinkPad = nullptr;
61 : GstSegment m_lastSegment;
62 : GstCaps *m_caps = nullptr;
63 :
64 : std::atomic<int32_t> m_sourceId;
65 : std::queue<GstSample *> m_samples;
66 : bool m_isEos = false;
67 : std::atomic<bool> m_isFlushOngoing;
68 : std::atomic<bool> m_isStateCommitNeeded;
69 : bool m_initialPositionSet{false};
70 : std::optional<int64_t> m_queuedOffset;
71 : std::mutex m_sinkMutex;
72 :
73 : std::condition_variable m_needDataCondVariable;
74 : std::condition_variable m_flushCondVariable;
75 : std::mutex m_flushMutex;
76 :
77 : RialtoGStreamerMSEBaseSinkCallbacks m_callbacks;
78 :
79 : MediaPlayerManager m_mediaPlayerManager;
80 : std::unique_ptr<firebolt::rialto::client::ControlBackendInterface> m_rialtoControlClient;
81 : std::atomic<bool> m_sourceAttached{false};
82 : bool m_isSinglePathStream = false;
83 : int32_t m_numOfStreams = 1;
84 : std::atomic<bool> m_hasDrm;
85 : std::atomic<bool> m_isAsync;
86 : firebolt::rialto::PlaybackState m_serverPlaybackState{firebolt::rialto::PlaybackState::UNKNOWN};
87 : firebolt::rialto::MediaSourceType m_mediaSourceType{firebolt::rialto::MediaSourceType::UNKNOWN};
88 : guint32 lastInstantRateChangeSeqnum{GST_SEQNUM_INVALID};
89 : std::atomic<guint32> currentInstantRateChangeSeqnum{GST_SEQNUM_INVALID};
90 : };
91 : G_END_DECLS
|