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 255 : IGenericPlayerTaskFactory() = default;
45 255 : 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 an UpdatePlaybackGroup task.
394 : *
395 : * @param[in] context : The GstGenericPlayer context
396 : * @param[in] player : The GstGenericPlayer instance
397 : * @param[in] typefind : The typefind element.
398 : * @param[in] caps : The GstCaps of added element
399 : *
400 : * @retval the new UpdatePlaybackGroup task instance.
401 : */
402 : virtual std::unique_ptr<IPlayerTask> createUpdatePlaybackGroup(GenericPlayerContext &context,
403 : IGstGenericPlayerPrivate &player,
404 : GstElement *typefind, const GstCaps *caps) const = 0;
405 :
406 : /**
407 : * @brief Creates a RenderFrame task.
408 : *
409 : * @param[in] context : The GstGenericPlayer context
410 : * @param[in] player : The GstPlayer instance
411 : *
412 : * @retval the new RenderFrame task instance.
413 : */
414 : virtual std::unique_ptr<IPlayerTask> createRenderFrame(GenericPlayerContext &context,
415 : IGstGenericPlayerPrivate &player) const = 0;
416 :
417 : /**
418 : * @brief Creates a Ping task.
419 : *
420 : * @param[in] heartbeatHandler : The HeartbeatHandler instance
421 : *
422 : * @retval the new Ping task instance.
423 : */
424 : virtual std::unique_ptr<IPlayerTask> createPing(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) const = 0;
425 :
426 : /**
427 : * @brief Creates a Flush task.
428 : *
429 : * @param[in] context : The GstPlayer context
430 : * @param[in] type : The media source type to flush
431 : * @param[in] resetTime : True if time should be reset
432 : *
433 : * @retval the new Flush task instance.
434 : */
435 : virtual std::unique_ptr<IPlayerTask> createFlush(GenericPlayerContext &context, IGstGenericPlayerPrivate &player,
436 : const firebolt::rialto::MediaSourceType &type,
437 : bool resetTime) const = 0;
438 :
439 : /**
440 : * @brief Creates a SetSourcePosition task.
441 : *
442 : * @param[in] context : The GstPlayer context
443 : * @param[in] player : The GstGenericPlayer instance
444 : * @param[in] type : The media source type to set position
445 : * @param[in] position : The new source position
446 : * @param[in] resetTime : True if time should be reset
447 : * @param[in] appliedRate : The applied rate after seek
448 : * @param[in] stopPosition : The position of last pushed buffer
449 : *
450 : * @retval the new SetSourcePosition task instance.
451 : */
452 : virtual std::unique_ptr<IPlayerTask> createSetSourcePosition(GenericPlayerContext &context,
453 : IGstGenericPlayerPrivate &player,
454 : const firebolt::rialto::MediaSourceType &type,
455 : std::int64_t position, bool resetTime,
456 : double appliedRate, uint64_t stopPosition) const = 0;
457 :
458 : /**
459 : * @brief Creates a ProcessAudioGap task.
460 : *
461 : * @param[in] context : The GstPlayer context
462 : * @param[in] position : Audio pts fade position
463 : * @param[in] duration : Audio pts fade duration
464 : * @param[in] discontinuityGap : Audio discontinuity gap
465 : * @param[in] audioAac : True if audio codec is AAC
466 : *
467 : * @retval the new ProcessAudioGap task instance.
468 : */
469 : virtual std::unique_ptr<IPlayerTask> createProcessAudioGap(GenericPlayerContext &context, std::int64_t position,
470 : std::uint32_t duration, std::int64_t discontinuityGap,
471 : bool audioAac) const = 0;
472 :
473 : /**
474 : * @brief Creates a SetImmediateOutput task.
475 : *
476 : * @param[in] context : The GstPlayer context
477 : * @param[in] player : The GstPlayer instance
478 : * @param[in] type : The media source type
479 : * @param[in] immediateOutput : the value to set for immediate-output
480 : *
481 : * @retval the new ProcessAudioGap task instance.
482 : */
483 : virtual std::unique_ptr<IPlayerTask> createSetImmediateOutput(GenericPlayerContext &context,
484 : IGstGenericPlayerPrivate &player,
485 : const firebolt::rialto::MediaSourceType &type,
486 : bool immediateOutput) const = 0;
487 :
488 : /**
489 : * @brief Creates a SetBufferingLimit task.
490 : *
491 : * @param[in] context : The GstPlayer context
492 : * @param[in] player : The GstPlayer instance
493 : * @param[in] limit : the value to set for buffering limit
494 : *
495 : * @retval the new ProcessAudioGap task instance.
496 : */
497 : virtual std::unique_ptr<IPlayerTask> createSetBufferingLimit(GenericPlayerContext &context,
498 : IGstGenericPlayerPrivate &player,
499 : std::uint32_t limit) const = 0;
500 :
501 : /**
502 : * @brief Creates a SetUseBuffering task.
503 : *
504 : * @param[in] context : The GstPlayer context
505 : * @param[in] player : The GstPlayer instance
506 : * @param[in] useBuffering : the value to set for use buffering
507 : *
508 : * @retval the new ProcessAudioGap task instance.
509 : */
510 : virtual std::unique_ptr<IPlayerTask>
511 : createSetUseBuffering(GenericPlayerContext &context, IGstGenericPlayerPrivate &player, bool useBuffering) const = 0;
512 :
513 : /**
514 : * @brief Creates a SwitchSource task.
515 : *
516 : * @param[in] player : The GstGenericPlayer instance
517 : * @param[in] source : The source to switch.
518 : *
519 : * @retval the new SwitchSource task instance.
520 : */
521 : virtual std::unique_ptr<IPlayerTask>
522 : createSwitchSource(IGstGenericPlayerPrivate &player,
523 : const std::unique_ptr<IMediaPipeline::MediaSource> &source) const = 0;
524 : };
525 :
526 : } // namespace firebolt::rialto::server
527 :
528 : #endif // FIREBOLT_RIALTO_SERVER_I_GENERIC_PLAYER_TASK_FACTORY_H_
|