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 273 : IGenericPlayerTaskFactory() = default;
45 273 : 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 Remove Source task.
181 : *
182 : * @param[in] context : The GstPlayer context
183 : * @param[in] player : The GstGenericPlayer instance
184 : * @param[in] type : The media source type to remove
185 : *
186 : * @retval the new Remove Source task instance.
187 : */
188 : virtual std::unique_ptr<IPlayerTask> createRemoveSource(GenericPlayerContext &context,
189 : IGstGenericPlayerPrivate &player,
190 : const firebolt::rialto::MediaSourceType &type) const = 0;
191 :
192 : /**
193 : * @brief Creates a ReportPosition task.
194 : *
195 : * @param[in] context : The GstGenericPlayer context
196 : * @param[in] player : The GstGenericPlayer instance
197 : *
198 : * @retval the new ReportPosition task instance.
199 : */
200 : virtual std::unique_ptr<IPlayerTask> createReportPosition(GenericPlayerContext &context,
201 : IGstGenericPlayerPrivate &player) const = 0;
202 :
203 : /**
204 : * @brief Creates a CheckAudioUnderflow task.
205 : *
206 : * @param[in] context : The GstGenericPlayer context
207 : * @param[in] player : The GstGenericPlayer instance
208 : *
209 : * @retval the new CheckAudioUnderflow task instance.
210 : */
211 : virtual std::unique_ptr<IPlayerTask> createCheckAudioUnderflow(GenericPlayerContext &context,
212 : IGstGenericPlayerPrivate &player) const = 0;
213 :
214 : /**
215 : * @brief Creates a SetPlaybackRate task.
216 : *
217 : * @param[in] context : The GstGenericPlayer context
218 : * @param[in] rate : The new playback rate.
219 : *
220 : * @retval the new SetPlaybackRate task instance.
221 : */
222 : virtual std::unique_ptr<IPlayerTask> createSetPlaybackRate(GenericPlayerContext &context, double rate) const = 0;
223 :
224 : /**
225 : * @brief Creates a SetPosition task.
226 : *
227 : * @param[in] context : The GstGenericPlayer context
228 : * @param[in] player : The GstGenericPlayer instance
229 : * @param[in] position : The position to be set
230 : *
231 : * @retval the new SetPosition task instance.
232 : */
233 : virtual std::unique_ptr<IPlayerTask>
234 : createSetPosition(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, std::int64_t position) const = 0;
235 :
236 : /**
237 : * @brief Creates a SetupElement task.
238 : *
239 : * @param[in] context : The GstGenericPlayer context
240 : * @param[in] player : The GstGenericPlayer instance
241 : * @param[in] element : The element to be setup.
242 : *
243 : * @retval the new SetupElement task instance.
244 : */
245 : virtual std::unique_ptr<IPlayerTask>
246 : createSetupElement(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, GstElement *element) const = 0;
247 :
248 : /**
249 : * @brief Creates a SetupSource task.
250 : *
251 : * @param[in] context : The GstGenericPlayer context
252 : * @param[in] player : The GstGenericPlayer instance
253 : * @param[in] source : The source to be setup.
254 : *
255 : * @retval the new SetupSource task instance.
256 : */
257 : virtual std::unique_ptr<IPlayerTask>
258 : createSetupSource(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, GstElement *source) const = 0;
259 :
260 : /**
261 : * @brief Creates a SetVideoGeometry task.
262 : *
263 : * @param[in] context : The GstGenericPlayer context
264 : * @param[in] player : The GstGenericPlayer instance
265 : * @param[in] rectangle : The video geometry data.
266 : *
267 : * @retval the new SetVideoGeometry task instance.
268 : */
269 : virtual std::unique_ptr<IPlayerTask> createSetVideoGeometry(GenericPlayerContext &context,
270 : IGstGenericPlayerPrivate &player,
271 : const Rectangle &rectangle) const = 0;
272 :
273 : /**
274 : * @brief Creates a SetVolume task.
275 : *
276 : * @param[in] context : The GstGenericPlayer context
277 : * @param[in] volume : The volume to be set
278 : *
279 : * @retval the new SetVolume task instance.
280 : */
281 : virtual std::unique_ptr<IPlayerTask> createSetVolume(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
282 : double targetVolume, uint32_t volumeDuration,
283 : firebolt::rialto::EaseType easeType) const = 0;
284 :
285 : /**
286 : * @brief Creates a SetMute task.
287 : *
288 : * @param[in] context : The GstGenericPlayer context
289 : * @param[in] player : The GstGenericPlayer instance
290 : * @param[in] mediaSourceType : The media source type to set mute
291 : * @param[in] mute : The mute state to be set
292 : *
293 : * @retval the new SetMute task instance.
294 : */
295 : virtual std::unique_ptr<IPlayerTask> createSetMute(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
296 : const MediaSourceType &mediaSourceType, bool mute) const = 0;
297 :
298 : /**
299 : * @brief Creates a SetTextTrackIdentifier task.
300 : *
301 : * @param[in] context : The GstGenericPlayer context
302 : * @param[in] textTrackIdentifier : The text track identifier to be set
303 : *
304 : * @retval the new SetTextTrackIdentifier task instance.
305 : */
306 : virtual std::unique_ptr<IPlayerTask> createSetTextTrackIdentifier(GenericPlayerContext &context,
307 : const std::string &textTrackIdentifier) const = 0;
308 :
309 : /**
310 : * @brief Creates a SetLowLatency task.
311 : *
312 : * @param[in] context : The GstGenericPlayer context
313 : * @param[in] player : The GstGenericPlayer instance
314 : * @param[in] lowLatency : The low latency value to set
315 : *
316 : * @retval the new SetLowLatency task instance.
317 : */
318 : virtual std::unique_ptr<IPlayerTask> createSetLowLatency(GenericPlayerContext &context,
319 : IGstGenericPlayerPrivate &player, bool lowLatency) const = 0;
320 :
321 : /**
322 : * @brief Creates a SetSync task.
323 : *
324 : * @param[in] context : The GstGenericPlayer context
325 : * @param[in] player : The GstGenericPlayer instance
326 : * @param[in] sync : The sync value to set
327 : *
328 : * @retval the new SetSync task instance.
329 : */
330 : virtual std::unique_ptr<IPlayerTask> createSetSync(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
331 : bool sync) const = 0;
332 :
333 : /**
334 : * @brief Creates a SetSyncOff task.
335 : *
336 : * @param[in] context : The GstGenericPlayer context
337 : * @param[in] player : The GstGenericPlayer instance
338 : * @param[in] syncOff : The syncOff value to set
339 : *
340 : * @retval the new SetSyncOff task instance.
341 : */
342 : virtual std::unique_ptr<IPlayerTask> createSetSyncOff(GenericPlayerContext &context,
343 : IGstGenericPlayerPrivate &player, bool syncOff) const = 0;
344 :
345 : /**
346 : * @brief Creates a SetStreamSyncMode task.
347 : *
348 : * @param[in] context : The GstGenericPlayer context
349 : * @param[in] player : The GstGenericPlayer instance
350 : * @param[in] type : The media source type to set stream sync mode
351 : * @param[in] streamSyncMode : The streamSyncMode value to set
352 : *
353 : * @retval the new SetStreamSyncMode task instance.
354 : */
355 : virtual std::unique_ptr<IPlayerTask> createSetStreamSyncMode(GenericPlayerContext &context,
356 : IGstGenericPlayerPrivate &player,
357 : const firebolt::rialto::MediaSourceType &type,
358 : int32_t streamSyncMode) const = 0;
359 :
360 : /**
361 : * @brief Creates a Shutdown task.
362 : *
363 : * @param[in] context : The GstGenericPlayer context
364 : *
365 : * @retval the new Shutdown task instance.
366 : */
367 : virtual std::unique_ptr<IPlayerTask> createShutdown(IGstGenericPlayerPrivate &player) const = 0;
368 :
369 : /**
370 : * @brief Creates a Stop task.
371 : *
372 : * @param[in] context : The GstGenericPlayer context
373 : * @param[in] player : The GstGenericPlayer instance
374 : *
375 : * @retval the new Stop task instance.
376 : */
377 : virtual std::unique_ptr<IPlayerTask> createStop(GenericPlayerContext &context,
378 : IGstGenericPlayerPrivate &player) const = 0;
379 :
380 : /**
381 : * @brief Creates an Underflow task.
382 : *
383 : * @param[in] context : The GstGenericPlayer context
384 : * @param[in] player : The GstPlayer instance
385 : * @param[in] underflowEnabled : The underflow enabled flag (audio or video).
386 : *
387 : * @retval the new Underflow task instance.
388 : */
389 : virtual std::unique_ptr<IPlayerTask> createUnderflow(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
390 : bool underflowEnabled, MediaSourceType sourceType) const = 0;
391 :
392 : /**
393 : * @brief Creates a FirstFrameReceived task.
394 : *
395 : * @param[in] context : The GstGenericPlayer context
396 : * @param[in] player : The GstPlayer instance
397 : * @param[in] sourceType : Source type (audio or video).
398 : *
399 : * @retval the new FirstFrameReceived task instance.
400 : */
401 : virtual std::unique_ptr<IPlayerTask> createFirstFrameReceived(GenericPlayerContext &context,
402 : IGstGenericPlayerPrivate &player,
403 : MediaSourceType sourceType) const = 0;
404 :
405 : /**
406 : * @brief Creates an UpdatePlaybackGroup task.
407 : *
408 : * @param[in] context : The GstGenericPlayer context
409 : * @param[in] player : The GstGenericPlayer instance
410 : * @param[in] typefind : The typefind element.
411 : * @param[in] caps : The GstCaps of added element
412 : *
413 : * @retval the new UpdatePlaybackGroup task instance.
414 : */
415 : virtual std::unique_ptr<IPlayerTask> createUpdatePlaybackGroup(GenericPlayerContext &context,
416 : IGstGenericPlayerPrivate &player,
417 : GstElement *typefind, const GstCaps *caps) const = 0;
418 :
419 : /**
420 : * @brief Creates a RenderFrame task.
421 : *
422 : * @param[in] context : The GstGenericPlayer context
423 : * @param[in] player : The GstPlayer instance
424 : *
425 : * @retval the new RenderFrame task instance.
426 : */
427 : virtual std::unique_ptr<IPlayerTask> createRenderFrame(GenericPlayerContext &context,
428 : IGstGenericPlayerPrivate &player) const = 0;
429 :
430 : /**
431 : * @brief Creates a Ping task.
432 : *
433 : * @param[in] heartbeatHandler : The HeartbeatHandler instance
434 : *
435 : * @retval the new Ping task instance.
436 : */
437 : virtual std::unique_ptr<IPlayerTask> createPing(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) const = 0;
438 :
439 : /**
440 : * @brief Creates a Flush task.
441 : *
442 : * @param[in] context : The GstPlayer context
443 : * @param[in] type : The media source type to flush
444 : * @param[in] resetTime : True if time should be reset
445 : * @param[in] isAsync : True if flushed source is asynchronous
446 : *
447 : * @retval the new Flush task instance.
448 : */
449 : virtual std::unique_ptr<IPlayerTask> createFlush(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
450 : const firebolt::rialto::MediaSourceType &type, bool resetTime,
451 : bool isAsync) const = 0;
452 :
453 : /**
454 : * @brief Creates a SetSourcePosition task.
455 : *
456 : * @param[in] context : The GstPlayer context
457 : * @param[in] type : The media source type to set position
458 : * @param[in] position : The new source position
459 : * @param[in] resetTime : True if time should be reset
460 : * @param[in] appliedRate : The applied rate after seek
461 : * @param[in] stopPosition : The position of last pushed buffer
462 : *
463 : * @retval the new SetSourcePosition task instance.
464 : */
465 : virtual std::unique_ptr<IPlayerTask> createSetSourcePosition(GenericPlayerContext &context,
466 : const firebolt::rialto::MediaSourceType &type,
467 : std::int64_t position, bool resetTime,
468 : double appliedRate, uint64_t stopPosition) const = 0;
469 :
470 : /**
471 : * @brief Creates a SetSubtitleOffset task.
472 : *
473 : * @param[in] context : The GstPlayer context
474 : * @param[in] position : The subtitle offset position in nanoseconds
475 : *
476 : * @retval the new SetSubtitleOffset task instance.
477 : */
478 : virtual std::unique_ptr<IPlayerTask> createSetSubtitleOffset(GenericPlayerContext &context,
479 : std::int64_t position) const = 0;
480 :
481 : /**
482 : * @brief Creates a ProcessAudioGap task.
483 : *
484 : * @param[in] context : The GstPlayer context
485 : * @param[in] position : Audio pts fade position
486 : * @param[in] duration : Audio pts fade duration
487 : * @param[in] discontinuityGap : Audio discontinuity gap
488 : * @param[in] audioAac : True if audio codec is AAC
489 : *
490 : * @retval the new ProcessAudioGap task instance.
491 : */
492 : virtual std::unique_ptr<IPlayerTask> createProcessAudioGap(GenericPlayerContext &context, std::int64_t position,
493 : std::uint32_t duration, std::int64_t discontinuityGap,
494 : bool audioAac) const = 0;
495 :
496 : /**
497 : * @brief Creates a SetImmediateOutput task.
498 : *
499 : * @param[in] context : The GstPlayer context
500 : * @param[in] player : The GstPlayer instance
501 : * @param[in] type : The media source type
502 : * @param[in] immediateOutput : the value to set for immediate-output
503 : *
504 : * @retval the new ProcessAudioGap task instance.
505 : */
506 : virtual std::unique_ptr<IPlayerTask> createSetImmediateOutput(GenericPlayerContext &context,
507 : IGstGenericPlayerPrivate &player,
508 : const firebolt::rialto::MediaSourceType &type,
509 : bool immediateOutput) const = 0;
510 :
511 : /**
512 : * @brief Creates a SetBufferingLimit task.
513 : *
514 : * @param[in] context : The GstPlayer context
515 : * @param[in] player : The GstPlayer instance
516 : * @param[in] limit : the value to set for buffering limit
517 : *
518 : * @retval the new ProcessAudioGap task instance.
519 : */
520 : virtual std::unique_ptr<IPlayerTask> createSetBufferingLimit(GenericPlayerContext &context,
521 : IGstGenericPlayerPrivate &player,
522 : std::uint32_t limit) const = 0;
523 :
524 : /**
525 : * @brief Creates a SetUseBuffering task.
526 : *
527 : * @param[in] context : The GstPlayer context
528 : * @param[in] player : The GstPlayer instance
529 : * @param[in] useBuffering : the value to set for use buffering
530 : *
531 : * @retval the new ProcessAudioGap task instance.
532 : */
533 : virtual std::unique_ptr<IPlayerTask>
534 : createSetUseBuffering(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, bool useBuffering) const = 0;
535 :
536 : /**
537 : * @brief Creates a SwitchSource task.
538 : *
539 : * @param[in] player : The GstGenericPlayer instance
540 : * @param[in] source : The source to switch.
541 : *
542 : * @retval the new SwitchSource task instance.
543 : */
544 : virtual std::unique_ptr<IPlayerTask>
545 : createSwitchSource(IGstGenericPlayerPrivate &player,
546 : const std::unique_ptr<IMediaPipeline::MediaSource> &source) const = 0;
547 :
548 : /**
549 : * @brief Creates a SynchroniseSubtitleClock task.
550 : *
551 : * @param[in] context : The GstGenericPlayer context
552 : * @param[in] player : The GstGenericPlayer instance
553 : *
554 : * @retval the new SynchroniseSubtitleClock task instance.
555 : */
556 : virtual std::unique_ptr<IPlayerTask> createSynchroniseSubtitleClock(GenericPlayerContext &context,
557 : IGstGenericPlayerPrivate &player) const = 0;
558 : };
559 :
560 : } // namespace firebolt::rialto::server
561 :
562 : #endif // FIREBOLT_RIALTO_SERVER_I_GENERIC_PLAYER_TASK_FACTORY_H_
|