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_GENERIC_PLAYER_TASK_FACTORY_H_
21 : #define FIREBOLT_RIALTO_SERVER_I_GENERIC_PLAYER_TASK_FACTORY_H_
22 :
23 : #include "GenericPlayerContext.h"
24 : #include "IDataReader.h"
25 : #include "IFlushWatcher.h"
26 : #include "IGstGenericPlayerPrivate.h"
27 : #include "IHeartbeatHandler.h"
28 : #include "IMediaPipeline.h"
29 : #include "IPlayerTask.h"
30 : #include "MediaCommon.h"
31 : #include <cstdint>
32 : #include <gst/app/gstappsrc.h>
33 : #include <memory>
34 : #include <string>
35 :
36 : namespace firebolt::rialto::server
37 : {
38 : /**
39 : * @brief IGenericPlayerTaskFactory factory class, returns a concrete implementation of IPlayerTask
40 : */
41 : class IGenericPlayerTaskFactory
42 : {
43 : public:
44 264 : IGenericPlayerTaskFactory() = default;
45 264 : virtual ~IGenericPlayerTaskFactory() = default;
46 :
47 : /**
48 : * @brief Creates a AttachSamples task.
49 : *
50 : * @param[in] context : The GstGenericPlayer context
51 : * @param[in] player : The GstGenericPlayer instance
52 : * @param[in] mediaSegments : The media segments to attach
53 : *
54 : * @retval the new AttachSamples task instance.
55 : */
56 : virtual std::unique_ptr<IPlayerTask>
57 : createAttachSamples(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
58 : const IMediaPipeline::MediaSegmentVector &mediaSegments) const = 0;
59 :
60 : /**
61 : * @brief Creates a AttachSource task.
62 : *
63 : * @param[in] context : The GstGenericPlayer context
64 : * @param[in] player : The GstGenericPlayer instance
65 : * @param[in] source : The source to attach.
66 : *
67 : * @retval the new AttachSource task instance.
68 : */
69 : virtual std::unique_ptr<IPlayerTask>
70 : createAttachSource(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
71 : const std::unique_ptr<IMediaPipeline::MediaSource> &source) const = 0;
72 :
73 : /**
74 : * @brief Creates a DeepElementAdded task.
75 : *
76 : * @param[in] context : The GstPlayer context
77 : * @param[in] player : The GstGenericPlayer instance
78 : * @param[in] pipeline : The pipeline the signal was fired from.
79 : * @param[in] bin : the GstBin the element was added to
80 : * @param[in] element : an element that was added to the playbin hierarchy
81 : *
82 : * @retval the new DeepElementAdded task instance.
83 : */
84 : virtual std::unique_ptr<IPlayerTask> createDeepElementAdded(GenericPlayerContext &context,
85 : IGstGenericPlayerPrivate &player, GstBin *pipeline,
86 : GstBin *bin, GstElement *element) const = 0;
87 :
88 : /**
89 : * @brief Creates a EnoughData task.
90 : *
91 : * @param[in] context : The GstGenericPlayer context
92 : * @param[in] src : The source, which reports enough data.
93 : *
94 : * @retval the new EnoughData task instance.
95 : */
96 : virtual std::unique_ptr<IPlayerTask> createEnoughData(GenericPlayerContext &context, GstAppSrc *src) const = 0;
97 :
98 : /**
99 : * @brief Creates a Eos task.
100 : *
101 : * @param[in] context : The GstGenericPlayer context
102 : * @param[in] type : The media source type, which reports eos.
103 : *
104 : * @retval the new Eos task instance.
105 : */
106 : virtual std::unique_ptr<IPlayerTask> createEos(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
107 : const firebolt::rialto::MediaSourceType &type) const = 0;
108 :
109 : /**
110 : * @brief Creates a FinishSetupSource task.
111 : *
112 : * @param[in] context : The GstGenericPlayer context
113 : * @param[in] player : The GstGenericPlayer instance
114 : *
115 : * @retval the new FinishSetupSource task instance.
116 : */
117 : virtual std::unique_ptr<IPlayerTask> createFinishSetupSource(GenericPlayerContext &context,
118 : IGstGenericPlayerPrivate &player) const = 0;
119 :
120 : /**
121 : * @brief Creates a HandleBusMessage task.
122 : *
123 : * @param[in] context : The GstGenericPlayer context
124 : * @param[in] player : The GstGenericPlayer instance
125 : * @param[in] message : The message to be handled.
126 : * @param[in] flushWatcher : Flush watcher instance
127 : *
128 : * @retval the new HandleBusMessage task instance.
129 : */
130 : virtual std::unique_ptr<IPlayerTask> createHandleBusMessage(GenericPlayerContext &context,
131 : IGstGenericPlayerPrivate &player, GstMessage *message,
132 : const IFlushWatcher &flushWatcher) const = 0;
133 :
134 : /**
135 : * @brief Creates a NeedData task.
136 : *
137 : * @param[in] context : The GstGenericPlayer context
138 : * @param[in] player : The GstGenericPlayer instance
139 : * @param[in] src : The source, which reports need data.
140 : *
141 : * @retval the new NeedData task instance.
142 : */
143 : virtual std::unique_ptr<IPlayerTask> createNeedData(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
144 : GstAppSrc *src) const = 0;
145 :
146 : /**
147 : * @brief Creates a Pause task.
148 : *
149 : * @param[in] context : The GstGenericPlayer context
150 : * @param[in] player : The GstGenericPlayer instance
151 : *
152 : * @retval the new Pause task instance.
153 : */
154 : virtual std::unique_ptr<IPlayerTask> createPause(GenericPlayerContext &context,
155 : IGstGenericPlayerPrivate &player) const = 0;
156 :
157 : /**
158 : * @brief Creates a Play task.
159 : *
160 : * @param[in] player : The GstGenericPlayer instance
161 : *
162 : * @retval the new Play task instance.
163 : */
164 : virtual std::unique_ptr<IPlayerTask> createPlay(IGstGenericPlayerPrivate &player) const = 0;
165 :
166 : /**
167 : * @brief Creates a ReadShmDataAndAttachSamples task.
168 : *
169 : * @param[in] context : The GstGenericPlayer context
170 : * @param[in] player : The GstGenericPlayer instance
171 : * @param[in] dataReader : The shared memory data reader
172 : *
173 : * @retval the new ReadShmDataAndAttachSamples task instance.
174 : */
175 : virtual std::unique_ptr<IPlayerTask>
176 : createReadShmDataAndAttachSamples(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
177 : const std::shared_ptr<IDataReader> &dataReader) const = 0;
178 :
179 : /**
180 : * @brief Creates a ReportPosition task.
181 : *
182 : * @param[in] context : The GstGenericPlayer context
183 : * @param[in] player : The GstGenericPlayer instance
184 : *
185 : * @retval the new ReportPosition task instance.
186 : */
187 : virtual std::unique_ptr<IPlayerTask> createReportPosition(GenericPlayerContext &context,
188 : IGstGenericPlayerPrivate &player) const = 0;
189 :
190 : /**
191 : * @brief Creates a CheckAudioUnderflow task.
192 : *
193 : * @param[in] context : The GstGenericPlayer context
194 : * @param[in] player : The GstGenericPlayer instance
195 : *
196 : * @retval the new CheckAudioUnderflow task instance.
197 : */
198 : virtual std::unique_ptr<IPlayerTask> createCheckAudioUnderflow(GenericPlayerContext &context,
199 : IGstGenericPlayerPrivate &player) const = 0;
200 :
201 : /**
202 : * @brief Creates a SetPlaybackRate task.
203 : *
204 : * @param[in] context : The GstGenericPlayer context
205 : * @param[in] rate : The new playback rate.
206 : *
207 : * @retval the new SetPlaybackRate task instance.
208 : */
209 : virtual std::unique_ptr<IPlayerTask> createSetPlaybackRate(GenericPlayerContext &context, double rate) const = 0;
210 :
211 : /**
212 : * @brief Creates a SetPosition task.
213 : *
214 : * @param[in] context : The GstGenericPlayer context
215 : * @param[in] player : The GstGenericPlayer instance
216 : * @param[in] position : The position to be set
217 : *
218 : * @retval the new SetPosition task instance.
219 : */
220 : virtual std::unique_ptr<IPlayerTask>
221 : createSetPosition(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, std::int64_t position) const = 0;
222 :
223 : /**
224 : * @brief Creates a SetupElement task.
225 : *
226 : * @param[in] context : The GstGenericPlayer context
227 : * @param[in] player : The GstGenericPlayer instance
228 : * @param[in] element : The element to be setup.
229 : *
230 : * @retval the new SetupElement task instance.
231 : */
232 : virtual std::unique_ptr<IPlayerTask>
233 : createSetupElement(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, GstElement *element) const = 0;
234 :
235 : /**
236 : * @brief Creates a SetupSource task.
237 : *
238 : * @param[in] context : The GstGenericPlayer context
239 : * @param[in] player : The GstGenericPlayer instance
240 : * @param[in] source : The source to be setup.
241 : *
242 : * @retval the new SetupSource task instance.
243 : */
244 : virtual std::unique_ptr<IPlayerTask>
245 : createSetupSource(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, GstElement *source) const = 0;
246 :
247 : /**
248 : * @brief Creates a SetVideoGeometry task.
249 : *
250 : * @param[in] context : The GstGenericPlayer context
251 : * @param[in] player : The GstGenericPlayer instance
252 : * @param[in] rectangle : The video geometry data.
253 : *
254 : * @retval the new SetVideoGeometry task instance.
255 : */
256 : virtual std::unique_ptr<IPlayerTask> createSetVideoGeometry(GenericPlayerContext &context,
257 : IGstGenericPlayerPrivate &player,
258 : const Rectangle &rectangle) const = 0;
259 :
260 : /**
261 : * @brief Creates a SetVolume task.
262 : *
263 : * @param[in] context : The GstGenericPlayer context
264 : * @param[in] volume : The volume to be set
265 : *
266 : * @retval the new SetVolume task instance.
267 : */
268 : virtual std::unique_ptr<IPlayerTask> createSetVolume(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
269 : double targetVolume, uint32_t volumeDuration,
270 : firebolt::rialto::EaseType easeType) const = 0;
271 :
272 : /**
273 : * @brief Creates a SetMute task.
274 : *
275 : * @param[in] context : The GstGenericPlayer context
276 : * @param[in] player : The GstGenericPlayer instance
277 : * @param[in] mediaSourceType : The media source type to set mute
278 : * @param[in] mute : The mute state to be set
279 : *
280 : * @retval the new SetMute task instance.
281 : */
282 : virtual std::unique_ptr<IPlayerTask> createSetMute(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
283 : const MediaSourceType &mediaSourceType, bool mute) const = 0;
284 :
285 : /**
286 : * @brief Creates a SetTextTrackIdentifier task.
287 : *
288 : * @param[in] context : The GstGenericPlayer context
289 : * @param[in] textTrackIdentifier : The text track identifier to be set
290 : *
291 : * @retval the new SetTextTrackIdentifier task instance.
292 : */
293 : virtual std::unique_ptr<IPlayerTask> createSetTextTrackIdentifier(GenericPlayerContext &context,
294 : const std::string &textTrackIdentifier) const = 0;
295 :
296 : /**
297 : * @brief Creates a SetLowLatency task.
298 : *
299 : * @param[in] context : The GstGenericPlayer context
300 : * @param[in] player : The GstGenericPlayer instance
301 : * @param[in] lowLatency : The low latency value to set
302 : *
303 : * @retval the new SetLowLatency task instance.
304 : */
305 : virtual std::unique_ptr<IPlayerTask> createSetLowLatency(GenericPlayerContext &context,
306 : IGstGenericPlayerPrivate &player, bool lowLatency) const = 0;
307 :
308 : /**
309 : * @brief Creates a SetSync task.
310 : *
311 : * @param[in] context : The GstGenericPlayer context
312 : * @param[in] player : The GstGenericPlayer instance
313 : * @param[in] sync : The sync value to set
314 : *
315 : * @retval the new SetSync task instance.
316 : */
317 : virtual std::unique_ptr<IPlayerTask> createSetSync(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
318 : bool sync) const = 0;
319 :
320 : /**
321 : * @brief Creates a SetSyncOff task.
322 : *
323 : * @param[in] context : The GstGenericPlayer context
324 : * @param[in] player : The GstGenericPlayer instance
325 : * @param[in] syncOff : The syncOff value to set
326 : *
327 : * @retval the new SetSyncOff task instance.
328 : */
329 : virtual std::unique_ptr<IPlayerTask> createSetSyncOff(GenericPlayerContext &context,
330 : IGstGenericPlayerPrivate &player, bool syncOff) const = 0;
331 :
332 : /**
333 : * @brief Creates a SetStreamSyncMode task.
334 : *
335 : * @param[in] context : The GstGenericPlayer context
336 : * @param[in] player : The GstGenericPlayer instance
337 : * @param[in] type : The media source type to set stream sync mode
338 : * @param[in] streamSyncMode : The streamSyncMode value to set
339 : *
340 : * @retval the new SetStreamSyncMode task instance.
341 : */
342 : virtual std::unique_ptr<IPlayerTask> createSetStreamSyncMode(GenericPlayerContext &context,
343 : IGstGenericPlayerPrivate &player,
344 : const firebolt::rialto::MediaSourceType &type,
345 : int32_t streamSyncMode) const = 0;
346 :
347 : /**
348 : * @brief Creates a Shutdown task.
349 : *
350 : * @param[in] context : The GstGenericPlayer context
351 : *
352 : * @retval the new Shutdown task instance.
353 : */
354 : virtual std::unique_ptr<IPlayerTask> createShutdown(IGstGenericPlayerPrivate &player) const = 0;
355 :
356 : /**
357 : * @brief Creates a Stop task.
358 : *
359 : * @param[in] context : The GstGenericPlayer context
360 : * @param[in] player : The GstGenericPlayer instance
361 : *
362 : * @retval the new Stop task instance.
363 : */
364 : virtual std::unique_ptr<IPlayerTask> createStop(GenericPlayerContext &context,
365 : IGstGenericPlayerPrivate &player) const = 0;
366 :
367 : /**
368 : * @brief Creates an Underflow task.
369 : *
370 : * @param[in] context : The GstGenericPlayer context
371 : * @param[in] player : The GstPlayer instance
372 : * @param[in] underflowEnabled : The underflow enabled flag (audio or video).
373 : *
374 : * @retval the new Underflow task instance.
375 : */
376 : virtual std::unique_ptr<IPlayerTask> createUnderflow(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
377 : bool underflowEnabled, MediaSourceType sourceType) const = 0;
378 :
379 : /**
380 : * @brief Creates an UpdatePlaybackGroup task.
381 : *
382 : * @param[in] context : The GstGenericPlayer context
383 : * @param[in] player : The GstGenericPlayer instance
384 : * @param[in] typefind : The typefind element.
385 : * @param[in] caps : The GstCaps of added element
386 : *
387 : * @retval the new UpdatePlaybackGroup task instance.
388 : */
389 : virtual std::unique_ptr<IPlayerTask> createUpdatePlaybackGroup(GenericPlayerContext &context,
390 : IGstGenericPlayerPrivate &player,
391 : GstElement *typefind, const GstCaps *caps) const = 0;
392 :
393 : /**
394 : * @brief Creates a RenderFrame task.
395 : *
396 : * @param[in] context : The GstGenericPlayer context
397 : * @param[in] player : The GstPlayer instance
398 : *
399 : * @retval the new RenderFrame task instance.
400 : */
401 : virtual std::unique_ptr<IPlayerTask> createRenderFrame(GenericPlayerContext &context,
402 : IGstGenericPlayerPrivate &player) const = 0;
403 :
404 : /**
405 : * @brief Creates a Ping task.
406 : *
407 : * @param[in] heartbeatHandler : The HeartbeatHandler instance
408 : *
409 : * @retval the new Ping task instance.
410 : */
411 : virtual std::unique_ptr<IPlayerTask> createPing(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) const = 0;
412 :
413 : /**
414 : * @brief Creates a Flush task.
415 : *
416 : * @param[in] context : The GstPlayer context
417 : * @param[in] type : The media source type to flush
418 : * @param[in] resetTime : True if time should be reset
419 : * @param[in] isAsync : True if flushed source is asynchronous
420 : *
421 : * @retval the new Flush task instance.
422 : */
423 : virtual std::unique_ptr<IPlayerTask> createFlush(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
424 : const firebolt::rialto::MediaSourceType &type, bool resetTime,
425 : bool isAsync) const = 0;
426 :
427 : /**
428 : * @brief Creates a SetSourcePosition task.
429 : *
430 : * @param[in] context : The GstPlayer context
431 : * @param[in] type : The media source type to set position
432 : * @param[in] position : The new source position
433 : * @param[in] resetTime : True if time should be reset
434 : * @param[in] appliedRate : The applied rate after seek
435 : * @param[in] stopPosition : The position of last pushed buffer
436 : *
437 : * @retval the new SetSourcePosition task instance.
438 : */
439 : virtual std::unique_ptr<IPlayerTask> createSetSourcePosition(GenericPlayerContext &context,
440 : const firebolt::rialto::MediaSourceType &type,
441 : std::int64_t position, bool resetTime,
442 : double appliedRate, uint64_t stopPosition) const = 0;
443 :
444 : /**
445 : * @brief Creates a SetSubtitleOffset task.
446 : *
447 : * @param[in] context : The GstPlayer context
448 : * @param[in] position : The subtitle offset position in nanoseconds
449 : *
450 : * @retval the new SetSubtitleOffset task instance.
451 : */
452 : virtual std::unique_ptr<IPlayerTask> createSetSubtitleOffset(GenericPlayerContext &context,
453 : std::int64_t position) const = 0;
454 :
455 : /**
456 : * @brief Creates a ProcessAudioGap task.
457 : *
458 : * @param[in] context : The GstPlayer context
459 : * @param[in] position : Audio pts fade position
460 : * @param[in] duration : Audio pts fade duration
461 : * @param[in] discontinuityGap : Audio discontinuity gap
462 : * @param[in] audioAac : True if audio codec is AAC
463 : *
464 : * @retval the new ProcessAudioGap task instance.
465 : */
466 : virtual std::unique_ptr<IPlayerTask> createProcessAudioGap(GenericPlayerContext &context, std::int64_t position,
467 : std::uint32_t duration, std::int64_t discontinuityGap,
468 : bool audioAac) const = 0;
469 :
470 : /**
471 : * @brief Creates a SetImmediateOutput task.
472 : *
473 : * @param[in] context : The GstPlayer context
474 : * @param[in] player : The GstPlayer instance
475 : * @param[in] type : The media source type
476 : * @param[in] immediateOutput : the value to set for immediate-output
477 : *
478 : * @retval the new ProcessAudioGap task instance.
479 : */
480 : virtual std::unique_ptr<IPlayerTask> createSetImmediateOutput(GenericPlayerContext &context,
481 : IGstGenericPlayerPrivate &player,
482 : const firebolt::rialto::MediaSourceType &type,
483 : bool immediateOutput) const = 0;
484 :
485 : /**
486 : * @brief Creates a SetBufferingLimit task.
487 : *
488 : * @param[in] context : The GstPlayer context
489 : * @param[in] player : The GstPlayer instance
490 : * @param[in] limit : the value to set for buffering limit
491 : *
492 : * @retval the new ProcessAudioGap task instance.
493 : */
494 : virtual std::unique_ptr<IPlayerTask> createSetBufferingLimit(GenericPlayerContext &context,
495 : IGstGenericPlayerPrivate &player,
496 : std::uint32_t limit) const = 0;
497 :
498 : /**
499 : * @brief Creates a SetUseBuffering task.
500 : *
501 : * @param[in] context : The GstPlayer context
502 : * @param[in] player : The GstPlayer instance
503 : * @param[in] useBuffering : the value to set for use buffering
504 : *
505 : * @retval the new ProcessAudioGap task instance.
506 : */
507 : virtual std::unique_ptr<IPlayerTask>
508 : createSetUseBuffering(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, bool useBuffering) const = 0;
509 :
510 : /**
511 : * @brief Creates a SwitchSource task.
512 : *
513 : * @param[in] player : The GstGenericPlayer instance
514 : * @param[in] source : The source to switch.
515 : *
516 : * @retval the new SwitchSource task instance.
517 : */
518 : virtual std::unique_ptr<IPlayerTask>
519 : createSwitchSource(IGstGenericPlayerPrivate &player,
520 : const std::unique_ptr<IMediaPipeline::MediaSource> &source) const = 0;
521 :
522 : /**
523 : * @brief Creates a SynchroniseSubtitleClock task.
524 : *
525 : * @param[in] context : The GstGenericPlayer context
526 : * @param[in] player : The GstGenericPlayer instance
527 : *
528 : * @retval the new SynchroniseSubtitleClock task instance.
529 : */
530 : virtual std::unique_ptr<IPlayerTask> createSynchroniseSubtitleClock(GenericPlayerContext &context,
531 : IGstGenericPlayerPrivate &player) const = 0;
532 : };
533 :
534 : } // namespace firebolt::rialto::server
535 :
536 : #endif // FIREBOLT_RIALTO_SERVER_I_GENERIC_PLAYER_TASK_FACTORY_H_
|