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 "GstPlayerTypes.h"
24 : #include "IMediaPipeline.h"
25 :
26 : #include <gst/app/gstappsrc.h>
27 : #include <gst/gst.h>
28 : #include <memory>
29 : #include <string>
30 : #include <vector>
31 :
32 : namespace firebolt::rialto::server
33 : {
34 : class IGstGenericPlayerPrivate
35 : {
36 : public:
37 522 : IGstGenericPlayerPrivate() = default;
38 522 : virtual ~IGstGenericPlayerPrivate() = default;
39 :
40 : IGstGenericPlayerPrivate(const IGstGenericPlayerPrivate &) = delete;
41 : IGstGenericPlayerPrivate &operator=(const IGstGenericPlayerPrivate &) = delete;
42 : IGstGenericPlayerPrivate(IGstGenericPlayerPrivate &&) = delete;
43 : IGstGenericPlayerPrivate &operator=(IGstGenericPlayerPrivate &&) = delete;
44 :
45 : /**
46 : * @brief Schedules need media data task. Called by the worker thread.
47 : */
48 : virtual void scheduleNeedMediaData(GstAppSrc *src) = 0;
49 :
50 : /**
51 : * @brief Schedules enough data task. Called by the worker thread.
52 : */
53 : virtual void scheduleEnoughData(GstAppSrc *src) = 0;
54 :
55 : /**
56 : * @brief Schedules audio underflow task. Called by the worker thread.
57 : */
58 : virtual void scheduleAudioUnderflow() = 0;
59 :
60 : /**
61 : * @brief Schedules video underflow task. Called by the worker thread.
62 : */
63 : virtual void scheduleVideoUnderflow() = 0;
64 :
65 : /**
66 : * @brief Schedules first video frame received task. Called by the worker thread.
67 : */
68 : virtual void scheduleFirstVideoFrameReceived() = 0;
69 :
70 : /**
71 : * @brief Schedules first audio frame received task. Called by the Gstreamer thread.
72 : */
73 : virtual void scheduleFirstAudioFrameReceived(AudioFirstFrameAction audioAction) = 0;
74 :
75 : /**
76 : * @brief Stores audio first-frame fallback probe state.
77 : *
78 : * @param[in] pad : sink pad with installed probe
79 : * @param[in] id : probe id
80 : */
81 : virtual void setAudioFirstFrameFallbackProbe(GstPad *pad, gulong id) = 0;
82 :
83 : /**
84 : * @brief Removes and clears audio first-frame fallback probe state.
85 : */
86 : virtual void clearAudioFirstFrameFallbackProbe() = 0;
87 :
88 : /**
89 : * @brief Clears audio first-frame fallback probe state without removing the probe.
90 : */
91 : virtual void clearAudioFirstFrameFallbackProbeState() = 0;
92 :
93 : /**
94 : * @brief Schedules all sources attached task. Called by the worker thread.
95 : */
96 : virtual void scheduleAllSourcesAttached() = 0;
97 :
98 : /**
99 : * @brief Sets video sink rectangle. Called by the worker thread.
100 : *
101 : * @retval true on success.
102 : */
103 : virtual bool setVideoSinkRectangle() = 0;
104 :
105 : /**
106 : * @brief Sets immediate output. Called by the worker thread.
107 : *
108 : * @retval true on success.
109 : */
110 : virtual bool setImmediateOutput() = 0;
111 :
112 : /**
113 : * @brief Sets report decode error. Called by the worker thread.
114 : *
115 : * @retval true on success.
116 : */
117 : virtual bool setReportDecodeErrors() = 0;
118 :
119 : /**
120 : * @brief Sets the low latency property. Called by the worker thread.
121 : *
122 : * @retval true on success.
123 : */
124 : virtual bool setLowLatency() = 0;
125 :
126 : /**
127 : * @brief Sets the sync property. Called by the worker thread.
128 : *
129 : * @retval true on success.
130 : */
131 : virtual bool setSync() = 0;
132 :
133 : /**
134 : * @brief Sets the sync off property. Called by the worker thread.
135 : *
136 : * @retval true on success.
137 : */
138 : virtual bool setSyncOff() = 0;
139 :
140 : /**
141 : * @brief Sets the stream sync mode property. Called by the worker thread.
142 : *
143 : * @retval true on success.
144 : */
145 : virtual bool setStreamSyncMode(const MediaSourceType &type) = 0;
146 :
147 : /**
148 : * @brief Sets frame rendering. Called by the worker thread.
149 : *
150 : * @retval true on success.
151 : */
152 : virtual bool setRenderFrame() = 0;
153 :
154 : /**
155 : * @brief Sets buffering limit. Called by the worker thread.
156 : *
157 : * @retval true on success.
158 : */
159 : virtual bool setBufferingLimit() = 0;
160 :
161 : /**
162 : * @brief Sets use buffering. Called by the worker thread.
163 : *
164 : * @retval true on success.
165 : */
166 : virtual bool setUseBuffering() = 0;
167 :
168 : /**
169 : * @brief Sets Show Video Window property. Called by the worker thread.
170 : *
171 : * @retval true on success.
172 : */
173 : virtual bool setShowVideoWindow() = 0;
174 :
175 : /**
176 : * @brief Sends NeedMediaData notification. Called by the worker thread.
177 : */
178 : virtual void notifyNeedMediaData(const MediaSourceType mediaSource) = 0;
179 :
180 : /**
181 : * @brief Sends NeedMediaData notification with a delay. Called by the worker thread.
182 : */
183 : virtual void notifyNeedMediaDataWithDelay(const MediaSourceType mediaSource) = 0;
184 :
185 : /**
186 : * @brief Constructs a new buffer with data from media segment. Does not perform decryption.
187 : * Called by the worker thread.
188 : */
189 : virtual GstBuffer *createBuffer(const IMediaPipeline::MediaSegment &mediaSegment) const = 0;
190 :
191 : virtual void attachData(const firebolt::rialto::MediaSourceType mediaType) = 0;
192 :
193 : /**
194 : * @brief Checks the new audio mediaSegment metadata and updates the caps accordingly.
195 : */
196 : virtual void updateAudioCaps(int32_t rate, int32_t channels, const std::shared_ptr<CodecData> &codecData) = 0;
197 :
198 : /**
199 : * @brief Checks the new video mediaSegment metadata and updates the caps accordingly.
200 : */
201 : virtual void updateVideoCaps(int32_t width, int32_t height, Fraction frameRate,
202 : const std::shared_ptr<CodecData> &codecData) = 0;
203 :
204 : /**
205 : * @brief Adds clipping meta to the audio buffer.
206 : *
207 : * @param buffer the buffer to add the clipping meta to
208 : * @param clippingStart the start of the clipping
209 : * @param clippingEnd the end of the clipping
210 : */
211 : virtual void addAudioClippingToBuffer(GstBuffer *buffer, uint64_t clippingStart, uint64_t clippingEnd) const = 0;
212 :
213 : /**
214 : * @brief Changes pipeline state.
215 : *
216 : * @param[in] newState : The desired state.
217 : *
218 : * @retval state change status
219 : */
220 : virtual GstStateChangeReturn changePipelineState(GstState newState) = 0;
221 :
222 : /**
223 : * @brief Gets the current position of the element
224 : *
225 : * @param[in] element : The GstElement to check.
226 : *
227 : * @retval position of the element; -1 in case of failure
228 : */
229 : virtual int64_t getPosition(GstElement *element) = 0;
230 :
231 : /**
232 : * @brief Starts position reporting and check audio underflow. Called by the worker thread.
233 : */
234 : virtual void startPositionReportingAndCheckAudioUnderflowTimer() = 0;
235 :
236 : /**
237 : * @brief Stops position reporting and check audio underflow. Called by the worker thread.
238 : */
239 : virtual void stopPositionReportingAndCheckAudioUnderflowTimer() = 0;
240 :
241 : /**
242 : * @brief Starts notify playback info timer. Called by the worker thread.
243 : */
244 : virtual void startNotifyPlaybackInfoTimer() = 0;
245 :
246 : /**
247 : * @brief Stops notify playback info timer. Called by the worker thread.
248 : */
249 : virtual void stopNotifyPlaybackInfoTimer() = 0;
250 :
251 : /**
252 : * @brief Starts subtitle clock resync. Called by the worker thread.
253 : */
254 : virtual void startSubtitleClockResyncTimer() = 0;
255 :
256 : /**
257 : * @brief Stops subtitle clock resync. Called by the worker thread.
258 : */
259 : virtual void stopSubtitleClockResyncTimer() = 0;
260 :
261 : /**
262 : * @brief Stops worker thread. Called by the worker thread.
263 : */
264 : virtual void stopWorkerThread() = 0;
265 :
266 : /**
267 : * @brief Restores playback after underflow. Called by the worker thread.
268 : *
269 : * @param[in] underflowFlag : The audio or video underflow flag to be cleared.
270 : */
271 : virtual void cancelUnderflow(firebolt::rialto::MediaSourceType mediaSource) = 0;
272 :
273 : /**
274 : * @brief Sets pending playback rate after reaching PLAYING state
275 : *
276 : */
277 : virtual void setPendingPlaybackRate() = 0;
278 :
279 : /**
280 : * @brief Updates Playback Group in PlayerContext.
281 : */
282 : virtual void updatePlaybackGroup(GstElement *typefind, const GstCaps *caps) = 0;
283 :
284 : /**
285 : * @brief Notification that a new child element has been added to the autovideosink.
286 : * Stores the child video sink in the player context.
287 : *
288 : * @param[in] object : Element added to the autovideosink.
289 : */
290 : virtual void addAutoVideoSinkChild(GObject *object) = 0;
291 :
292 : /**
293 : * @brief Notification that a new child element has been added to the autoaudiosink.
294 : * Stores the child audio sink in the player context.
295 : *
296 : * @param[in] object : Element added to the autoaudiosink.
297 : */
298 : virtual void addAutoAudioSinkChild(GObject *object) = 0;
299 :
300 : /**
301 : * @brief Notification that a child element has been removed from the autovideosink.
302 : * Removes the child video sink in the player context if it has been stored.
303 : *
304 : * @param[in] object : Element removed from the autovideosink.
305 : */
306 : virtual void removeAutoVideoSinkChild(GObject *object) = 0;
307 :
308 : /**
309 : * @brief Notification that a child element has been removed from the autoaudiosink.
310 : * Removes the child audio sink in the player context if it has been stored.
311 : *
312 : * @param[in] object : Element removed from the autoaudiosink.
313 : */
314 : virtual void removeAutoAudioSinkChild(GObject *object) = 0;
315 :
316 : /**
317 : * @brief Gets the sink element for source type.
318 : *
319 : * @param[in] mediaSourceType : the source type to obtain the sink for
320 : *
321 : * @retval The sink, NULL if not found. Please call getObjectUnref() if it's non-null
322 : */
323 : virtual GstElement *getSink(const MediaSourceType &mediaSourceType) const = 0;
324 :
325 : /**
326 : * @brief Reattaches source (or switches it)
327 : *
328 : * @param[in] source : The new media source
329 : *
330 : * @retval True on success
331 : */
332 : virtual bool reattachSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source) = 0;
333 :
334 : /**
335 : * @brief Checks if the player has a source of the given type.
336 : *
337 : * @param[in] mediaSourceType : The source type to check
338 : *
339 : * @retval True if the player has a source of the given type, false otherwise
340 : */
341 : virtual bool hasSourceType(const MediaSourceType &mediaSourceType) const = 0;
342 :
343 : /**
344 : * @brief Sets source state flushed
345 : *
346 : * @param[in] mediaSourceType : the source type that has been flushed
347 : */
348 : virtual void setSourceFlushed(const MediaSourceType &mediaSourceType) = 0;
349 :
350 : /**
351 : * @brief Sends PlaybackInfo notification. Called by the worker thread.
352 : */
353 : virtual void notifyPlaybackInfo() = 0;
354 : };
355 : } // namespace firebolt::rialto::server
356 :
357 : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_PRIVATE_H_
|