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