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