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