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_I_GST_GENERIC_PLAYER_PRIVATE_H_
21 : #define FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_PRIVATE_H_
22 :
23 : #include "IMediaPipeline.h"
24 :
25 : #include <gst/app/gstappsrc.h>
26 : #include <gst/gst.h>
27 : #include <memory>
28 : #include <string>
29 : #include <vector>
30 :
31 : namespace firebolt::rialto::server
32 : {
33 : class IGstGenericPlayerPrivate
34 : {
35 : public:
36 470 : IGstGenericPlayerPrivate() = default;
37 470 : virtual ~IGstGenericPlayerPrivate() = default;
38 :
39 : IGstGenericPlayerPrivate(const IGstGenericPlayerPrivate &) = delete;
40 : IGstGenericPlayerPrivate &operator=(const IGstGenericPlayerPrivate &) = delete;
41 : IGstGenericPlayerPrivate(IGstGenericPlayerPrivate &&) = delete;
42 : IGstGenericPlayerPrivate &operator=(IGstGenericPlayerPrivate &&) = delete;
43 :
44 : /**
45 : * @brief Schedules need media data task. Called by the worker thread.
46 : */
47 : virtual void scheduleNeedMediaData(GstAppSrc *src) = 0;
48 :
49 : /**
50 : * @brief Schedules enough data task. Called by the worker thread.
51 : */
52 : virtual void scheduleEnoughData(GstAppSrc *src) = 0;
53 :
54 : /**
55 : * @brief Schedules audio underflow task. Called by the worker thread.
56 : */
57 : virtual void scheduleAudioUnderflow() = 0;
58 :
59 : /**
60 : * @brief Schedules video underflow task. Called by the worker thread.
61 : */
62 : virtual void scheduleVideoUnderflow() = 0;
63 :
64 : /**
65 : * @brief Schedules all sources attached task. Called by the worker thread.
66 : */
67 : virtual void scheduleAllSourcesAttached() = 0;
68 :
69 : /**
70 : * @brief Sets video sink rectangle. Called by the worker thread.
71 : *
72 : * @retval true on success.
73 : */
74 : virtual bool setVideoSinkRectangle() = 0;
75 :
76 : /**
77 : * @brief Sets immediate output. Called by the worker thread.
78 : *
79 : * @retval true on success.
80 : */
81 : virtual bool setImmediateOutput() = 0;
82 :
83 : /**
84 : * @brief Sets the low latency property. Called by the worker thread.
85 : *
86 : * @retval true on success.
87 : */
88 : virtual bool setLowLatency() = 0;
89 :
90 : /**
91 : * @brief Sets the sync property. Called by the worker thread.
92 : *
93 : * @retval true on success.
94 : */
95 : virtual bool setSync() = 0;
96 :
97 : /**
98 : * @brief Sets the sync off property. Called by the worker thread.
99 : *
100 : * @retval true on success.
101 : */
102 : virtual bool setSyncOff() = 0;
103 :
104 : /**
105 : * @brief Sets the stream sync mode property. Called by the worker thread.
106 : *
107 : * @retval true on success.
108 : */
109 : virtual bool setStreamSyncMode(const MediaSourceType &type) = 0;
110 :
111 : /**
112 : * @brief Sets frame rendering. Called by the worker thread.
113 : *
114 : * @retval true on success.
115 : */
116 : virtual bool setRenderFrame() = 0;
117 :
118 : /**
119 : * @brief Sets buffering limit. Called by the worker thread.
120 : *
121 : * @retval true on success.
122 : */
123 : virtual bool setBufferingLimit() = 0;
124 :
125 : /**
126 : * @brief Sets use buffering. Called by the worker thread.
127 : *
128 : * @retval true on success.
129 : */
130 : virtual bool setUseBuffering() = 0;
131 :
132 : /**
133 : * @brief Sets Show Video Window property. Called by the worker thread.
134 : *
135 : * @retval true on success.
136 : */
137 : virtual bool setShowVideoWindow() = 0;
138 :
139 : /**
140 : * @brief Sends NeedMediaData notification. Called by the worker thread.
141 : */
142 : virtual void notifyNeedMediaData(const MediaSourceType mediaSource) = 0;
143 :
144 : /**
145 : * @brief Constructs a new buffer with data from media segment. Does not perform decryption.
146 : * Called by the worker thread.
147 : */
148 : virtual GstBuffer *createBuffer(const IMediaPipeline::MediaSegment &mediaSegment) const = 0;
149 :
150 : virtual void attachData(const firebolt::rialto::MediaSourceType mediaType) = 0;
151 :
152 : /**
153 : * @brief Checks the new audio mediaSegment metadata and updates the caps accordingly.
154 : */
155 : virtual void updateAudioCaps(int32_t rate, int32_t channels, const std::shared_ptr<CodecData> &codecData) = 0;
156 :
157 : /**
158 : * @brief Checks the new video mediaSegment metadata and updates the caps accordingly.
159 : */
160 : virtual void updateVideoCaps(int32_t width, int32_t height, Fraction frameRate,
161 : const std::shared_ptr<CodecData> &codecData) = 0;
162 :
163 : /**
164 : * @brief Adds clipping meta to the audio buffer.
165 : *
166 : * @param buffer the buffer to add the clipping meta to
167 : * @param clippingStart the start of the clipping
168 : * @param clippingEnd the end of the clipping
169 : */
170 : virtual void addAudioClippingToBuffer(GstBuffer *buffer, uint64_t clippingStart, uint64_t clippingEnd) const = 0;
171 :
172 : /**
173 : * @brief Changes pipeline state.
174 : *
175 : * @param[in] newState : The desired state.
176 : *
177 : * @retval true on success.
178 : */
179 : virtual bool changePipelineState(GstState newState) = 0;
180 :
181 : /**
182 : * @brief Starts position reporting and check audio underflow. Called by the worker thread.
183 : */
184 : virtual void startPositionReportingAndCheckAudioUnderflowTimer() = 0;
185 :
186 : /**
187 : * @brief Stops position reporting and check audio underflow. Called by the worker thread.
188 : */
189 : virtual void stopPositionReportingAndCheckAudioUnderflowTimer() = 0;
190 :
191 : /**
192 : * @brief Restores playback after underflow. Called by the worker thread.
193 : *
194 : * @param[in] underflowFlag : The audio or video underflow flag to be cleared.
195 : */
196 : virtual void cancelUnderflow(firebolt::rialto::MediaSourceType mediaSource) = 0;
197 :
198 : /**
199 : * @brief Sets pending playback rate after reaching PLAYING state
200 : *
201 : */
202 : virtual void setPendingPlaybackRate() = 0;
203 :
204 : /**
205 : * @brief Updates Playback Group in PlayerContext.
206 : */
207 : virtual void updatePlaybackGroup(GstElement *typefind, const GstCaps *caps) = 0;
208 :
209 : /**
210 : * @brief Notification that a new child element has been added to the autovideosink.
211 : * Stores the child video sink in the player context.
212 : *
213 : * @param[in] object : Element added to the autovideosink.
214 : */
215 : virtual void addAutoVideoSinkChild(GObject *object) = 0;
216 :
217 : /**
218 : * @brief Notification that a new child element has been added to the autoaudiosink.
219 : * Stores the child audio sink in the player context.
220 : *
221 : * @param[in] object : Element added to the autoaudiosink.
222 : */
223 : virtual void addAutoAudioSinkChild(GObject *object) = 0;
224 :
225 : /**
226 : * @brief Notification that a child element has been removed from the autovideosink.
227 : * Removes the child video sink in the player context if it has been stored.
228 : *
229 : * @param[in] object : Element removed from the autovideosink.
230 : */
231 : virtual void removeAutoVideoSinkChild(GObject *object) = 0;
232 :
233 : /**
234 : * @brief Notification that a child element has been removed from the autoaudiosink.
235 : * Removes the child audio sink in the player context if it has been stored.
236 : *
237 : * @param[in] object : Element removed from the autoaudiosink.
238 : */
239 : virtual void removeAutoAudioSinkChild(GObject *object) = 0;
240 :
241 : /**
242 : * @brief Gets the sink element for source type.
243 : *
244 : * @param[in] mediaSourceType : the source type to obtain the sink for
245 : *
246 : * @retval The sink, NULL if not found. Please call getObjectUnref() if it's non-null
247 : */
248 : virtual GstElement *getSink(const MediaSourceType &mediaSourceType) const = 0;
249 :
250 : /**
251 : * @brief Sets the audio and video flags on the pipeline based on the input.
252 : *
253 : * @param[in] enableAudio : Whether to enable audio flags.
254 : */
255 : virtual void setPlaybinFlags(bool enableAudio) = 0;
256 :
257 : /**
258 : * @brief Pushes GstSample if playback position has changed or new segment needs to be sent.
259 : *
260 : * @param[in] source : The Gst Source element, that should receive new sample
261 : * @param[in] typeStr : The media source type string
262 : */
263 : virtual void pushSampleIfRequired(GstElement *source, const std::string &typeStr) = 0;
264 :
265 : /**
266 : * @brief Reattaches source (or switches it)
267 : *
268 : * @param[in] source : The new media source
269 : *
270 : * @retval True on success
271 : */
272 : virtual bool reattachSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source) = 0;
273 :
274 : /**
275 : * @brief Sets source state flushed
276 : *
277 : * @param[in] mediaSourceType : the source type that has been flushed
278 : */
279 : virtual void setSourceFlushed(const MediaSourceType &mediaSourceType) = 0;
280 : };
281 : } // namespace firebolt::rialto::server
282 :
283 : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_PRIVATE_H_
|