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 2023 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_WEB_AUDIO_PLAYER_TASK_FACTORY_H_
21 : #define FIREBOLT_RIALTO_SERVER_I_WEB_AUDIO_PLAYER_TASK_FACTORY_H_
22 :
23 : #include "IGstWebAudioPlayerPrivate.h"
24 : #include "IHeartbeatHandler.h"
25 : #include "IPlayerTask.h"
26 : #include "WebAudioPlayerContext.h"
27 : #include <memory>
28 : #include <string>
29 :
30 : namespace firebolt::rialto::server
31 : {
32 : /**
33 : * @brief IWebAudioPlayerTaskFactory factory class, returns a concrete implementation of IPlayerTask
34 : */
35 : class IWebAudioPlayerTaskFactory
36 : {
37 : public:
38 42 : IWebAudioPlayerTaskFactory() = default;
39 42 : virtual ~IWebAudioPlayerTaskFactory() = default;
40 :
41 : /**
42 : * @brief Creates a Stop task.
43 : *
44 : * @param[in] player : The GstWebAudioPlayer instance
45 : *
46 : * @retval the new Stop task instance.
47 : */
48 : virtual std::unique_ptr<IPlayerTask> createStop(IGstWebAudioPlayerPrivate &player) const = 0;
49 :
50 : /**
51 : * @brief Creates a Play task.
52 : *
53 : * @param[in] player : The GstWebAudioPlayer instance
54 : *
55 : * @retval the new Play task instance.
56 : */
57 : virtual std::unique_ptr<IPlayerTask> createPlay(IGstWebAudioPlayerPrivate &player) const = 0;
58 :
59 : /**
60 : * @brief Creates a Pause task.
61 : *
62 : * @param[in] player : The GstWebAudioPlayer instance
63 : *
64 : * @retval the new Pause task instance.
65 : */
66 : virtual std::unique_ptr<IPlayerTask> createPause(IGstWebAudioPlayerPrivate &player) const = 0;
67 :
68 : /**
69 : * @brief Creates a SetCaps task.
70 : *
71 : * @param[in] context : The GstWebAudioPlayer context
72 : * @param[in] audioMimeType : The audio encoding format, currently only "audio/x-raw" (PCM)
73 : * @param[in] config : Additional type dependent configuration data or nullptr
74 : *
75 : * @retval the new SetCaps task instance.
76 : */
77 : virtual std::unique_ptr<IPlayerTask> createSetCaps(WebAudioPlayerContext &context, const std::string &audioMimeType,
78 : std::weak_ptr<const WebAudioConfig> config) const = 0;
79 :
80 : /**
81 : * @brief Creates a Eos task.
82 : *
83 : * @param[in] context : The GstWebAudioPlayer context
84 : *
85 : * @retval the new Eos task instance.
86 : */
87 : virtual std::unique_ptr<IPlayerTask> createEos(WebAudioPlayerContext &context) const = 0;
88 :
89 : /**
90 : * @brief Creates a SetVolume task.
91 : *
92 : * @param[in] context : The GstWebAudioPlayer context
93 : * @param[in] volume : The volume to set
94 : *
95 : * @retval the new SetVolume task instance.
96 : */
97 : virtual std::unique_ptr<IPlayerTask> createSetVolume(WebAudioPlayerContext &context, double volume) const = 0;
98 :
99 : /**
100 : * @brief Creates a WriteBuffer task.
101 : *
102 : * @param[in] context : The GstWebAudioPlayer context
103 : * @param[in] mainPtr : Pointer to the start of the data
104 : * @param[in] mainLength : Amount of bytes to write from the mainPtr
105 : * @param[in] wrapPtr : Pointer to the start of the wrapped data
106 : * @param[in] wrapLength : Amount of bytes to write from the wrapPtr
107 : *
108 : * @retval the new SetVolume task instance.
109 : */
110 : virtual std::unique_ptr<IPlayerTask> createWriteBuffer(WebAudioPlayerContext &context, uint8_t *mainPtr,
111 : uint32_t mainLength, uint8_t *wrapPtr,
112 : uint32_t wrapLength) const = 0;
113 :
114 : /**
115 : * @brief Creates a HandleBusMessage task.
116 : *
117 : * @param[in] context : The GstWebAudioPlayer context
118 : * @param[in] player : The GstWebAudioPlayer instance
119 : * @param[in] message : The message to be handled
120 : *
121 : * @retval the new HandleBusMessage task instance.
122 : */
123 : virtual std::unique_ptr<IPlayerTask> createHandleBusMessage(WebAudioPlayerContext &context,
124 : IGstWebAudioPlayerPrivate &player,
125 : GstMessage *message) const = 0;
126 :
127 : /**
128 : * @brief Creates a Ping task.
129 : *
130 : * @param[in] heartbeatHandler : The HeartbeatHandler instance
131 : *
132 : * @retval the new Ping task instance.
133 : */
134 : virtual std::unique_ptr<IPlayerTask> createPing(std::unique_ptr<IHeartbeatHandler> &&heartbeatHandler) const = 0;
135 : };
136 :
137 : } // namespace firebolt::rialto::server
138 :
139 : #endif // FIREBOLT_RIALTO_SERVER_I_WEB_AUDIO_PLAYER_TASK_FACTORY_H_
|