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