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