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