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 537 : IGstGenericPlayerPrivate() = default;
38 537 : 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 properties for low latency on audio decoder. Called by the worker thread.
114 : *
115 : * @retval true on success.
116 : */
117 : virtual bool setLowLatencyAudioDecoder() = 0;
118 :
119 : /**
120 : * @brief Sets properties for low latency on audio decoder. Called by the worker thread.
121 : *
122 : * @retval true on success.
123 : */
124 : virtual bool setLowLatencyAudioSink() = 0;
125 :
126 : /**
127 : * @brief Sets report decode error. Called by the worker thread.
128 : *
129 : * @retval true on success.
130 : */
131 : virtual bool setReportDecodeErrors() = 0;
132 :
133 : /**
134 : * @brief Sets the low latency property. Called by the worker thread.
135 : *
136 : * @retval true on success.
137 : */
138 : virtual bool setLowLatency() = 0;
139 :
140 : /**
141 : * @brief Sets the sync property. Called by the worker thread.
142 : *
143 : * @retval true on success.
144 : */
145 : virtual bool setSync() = 0;
146 :
147 : /**
148 : * @brief Sets the sync off property. Called by the worker thread.
149 : *
150 : * @retval true on success.
151 : */
152 : virtual bool setSyncOff() = 0;
153 :
154 : /**
155 : * @brief Sets the stream sync mode property. Called by the worker thread.
156 : *
157 : * @retval true on success.
158 : */
159 : virtual bool setStreamSyncMode(const MediaSourceType &type) = 0;
160 :
161 : /**
162 : * @brief Sets frame rendering. Called by the worker thread.
163 : *
164 : * @retval true on success.
165 : */
166 : virtual bool setRenderFrame() = 0;
167 :
168 : /**
169 : * @brief Sets buffering limit. Called by the worker thread.
170 : *
171 : * @retval true on success.
172 : */
173 : virtual bool setBufferingLimit() = 0;
174 :
175 : /**
176 : * @brief Sets use buffering. Called by the worker thread.
177 : *
178 : * @retval true on success.
179 : */
180 : virtual bool setUseBuffering() = 0;
181 :
182 : /**
183 : * @brief Sets Show Video Window property. Called by the worker thread.
184 : *
185 : * @retval true on success.
186 : */
187 : virtual bool setShowVideoWindow() = 0;
188 :
189 : /**
190 : * @brief Sends NeedMediaData notification. Called by the worker thread.
191 : */
192 : virtual void notifyNeedMediaData(const MediaSourceType mediaSource) = 0;
193 :
194 : /**
195 : * @brief Sends NeedMediaData notification with a delay. Called by the worker thread.
196 : */
197 : virtual void notifyNeedMediaDataWithDelay(const MediaSourceType mediaSource) = 0;
198 :
199 : /**
200 : * @brief Constructs a new buffer with data from media segment. Does not perform decryption.
201 : * Called by the worker thread.
202 : */
203 : virtual GstBuffer *createBuffer(const IMediaPipeline::MediaSegment &mediaSegment) const = 0;
204 :
205 : virtual void attachData(const firebolt::rialto::MediaSourceType mediaType) = 0;
206 :
207 : /**
208 : * @brief Checks the new audio mediaSegment metadata and updates the caps accordingly.
209 : */
210 : virtual void updateAudioCaps(int32_t rate, int32_t channels, const std::shared_ptr<CodecData> &codecData) = 0;
211 :
212 : /**
213 : * @brief Checks the new video mediaSegment metadata and updates the caps accordingly.
214 : */
215 : virtual void updateVideoCaps(int32_t width, int32_t height, Fraction frameRate,
216 : const std::shared_ptr<CodecData> &codecData) = 0;
217 :
218 : /**
219 : * @brief Adds clipping meta to the audio buffer.
220 : *
221 : * @param buffer the buffer to add the clipping meta to
222 : * @param clippingStart the start of the clipping
223 : * @param clippingEnd the end of the clipping
224 : */
225 : virtual void addAudioClippingToBuffer(GstBuffer *buffer, uint64_t clippingStart, uint64_t clippingEnd) const = 0;
226 :
227 : /**
228 : * @brief Changes pipeline state.
229 : *
230 : * @param[in] newState : The desired state.
231 : *
232 : * @retval state change status
233 : */
234 : virtual GstStateChangeReturn changePipelineState(GstState newState) = 0;
235 :
236 : /**
237 : * @brief Gets the current position of the element
238 : *
239 : * @param[in] element : The GstElement to check.
240 : *
241 : * @retval position of the element; -1 in case of failure
242 : */
243 : virtual int64_t getPosition(GstElement *element) = 0;
244 :
245 : /**
246 : * @brief Starts position reporting and check audio underflow. Called by the worker thread.
247 : */
248 : virtual void startPositionReportingAndCheckAudioUnderflowTimer() = 0;
249 :
250 : /**
251 : * @brief Stops position reporting and check audio underflow. Called by the worker thread.
252 : */
253 : virtual void stopPositionReportingAndCheckAudioUnderflowTimer() = 0;
254 :
255 : /**
256 : * @brief Starts notify playback info timer. Called by the worker thread.
257 : */
258 : virtual void startNotifyPlaybackInfoTimer() = 0;
259 :
260 : /**
261 : * @brief Stops notify playback info timer. Called by the worker thread.
262 : */
263 : virtual void stopNotifyPlaybackInfoTimer() = 0;
264 :
265 : /**
266 : * @brief Starts subtitle clock resync. Called by the worker thread.
267 : */
268 : virtual void startSubtitleClockResyncTimer() = 0;
269 :
270 : /**
271 : * @brief Stops subtitle clock resync. Called by the worker thread.
272 : */
273 : virtual void stopSubtitleClockResyncTimer() = 0;
274 :
275 : /**
276 : * @brief Stops worker thread. Called by the worker thread.
277 : */
278 : virtual void stopWorkerThread() = 0;
279 :
280 : /**
281 : * @brief Restores playback after underflow. Called by the worker thread.
282 : *
283 : * @param[in] underflowFlag : The audio or video underflow flag to be cleared.
284 : */
285 : virtual void cancelUnderflow(firebolt::rialto::MediaSourceType mediaSource) = 0;
286 :
287 : /**
288 : * @brief Sets pending playback rate after reaching PLAYING state
289 : *
290 : */
291 : virtual void setPendingPlaybackRate() = 0;
292 :
293 : /**
294 : * @brief Updates Playback Group in PlayerContext.
295 : */
296 : virtual void updatePlaybackGroup(GstElement *typefind, const GstCaps *caps) = 0;
297 :
298 : /**
299 : * @brief Notification that a new child element has been added to the autovideosink.
300 : * Stores the child video sink in the player context.
301 : *
302 : * @param[in] object : Element added to the autovideosink.
303 : */
304 : virtual void addAutoVideoSinkChild(GObject *object) = 0;
305 :
306 : /**
307 : * @brief Notification that a new child element has been added to the autoaudiosink.
308 : * Stores the child audio sink in the player context.
309 : *
310 : * @param[in] object : Element added to the autoaudiosink.
311 : */
312 : virtual void addAutoAudioSinkChild(GObject *object) = 0;
313 :
314 : /**
315 : * @brief Notification that a child element has been removed from the autovideosink.
316 : * Removes the child video sink in the player context if it has been stored.
317 : *
318 : * @param[in] object : Element removed from the autovideosink.
319 : */
320 : virtual void removeAutoVideoSinkChild(GObject *object) = 0;
321 :
322 : /**
323 : * @brief Notification that a child element has been removed from the autoaudiosink.
324 : * Removes the child audio sink in the player context if it has been stored.
325 : *
326 : * @param[in] object : Element removed from the autoaudiosink.
327 : */
328 : virtual void removeAutoAudioSinkChild(GObject *object) = 0;
329 :
330 : /**
331 : * @brief Gets the sink element for source type.
332 : *
333 : * @param[in] mediaSourceType : the source type to obtain the sink for
334 : *
335 : * @retval The sink, NULL if not found. Please call getObjectUnref() if it's non-null
336 : */
337 : virtual GstElement *getSink(const MediaSourceType &mediaSourceType) const = 0;
338 :
339 : /**
340 : * @brief Reattaches source (or switches it)
341 : *
342 : * @param[in] source : The new media source
343 : *
344 : * @retval True on success
345 : */
346 : virtual bool reattachSource(const std::unique_ptr<IMediaPipeline::MediaSource> &source) = 0;
347 :
348 : /**
349 : * @brief Checks if the player has a source of the given type.
350 : *
351 : * @param[in] mediaSourceType : The source type to check
352 : *
353 : * @retval True if the player has a source of the given type, false otherwise
354 : */
355 : virtual bool hasSourceType(const MediaSourceType &mediaSourceType) const = 0;
356 :
357 : /**
358 : * @brief Sets source state flushed
359 : *
360 : * @param[in] mediaSourceType : the source type that has been flushed
361 : */
362 : virtual void setSourceFlushed(const MediaSourceType &mediaSourceType) = 0;
363 :
364 : /**
365 : * @brief Sends PlaybackInfo notification. Called by the worker thread.
366 : */
367 : virtual void notifyPlaybackInfo() = 0;
368 : };
369 : } // namespace firebolt::rialto::server
370 :
371 : #endif // FIREBOLT_RIALTO_SERVER_I_GST_GENERIC_PLAYER_PRIVATE_H_
|