• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_AVSESSION_CONTROLLER_H
17 #define OHOS_AVSESSION_CONTROLLER_H
18 
19 #include <bitset>
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "avcontrol_command.h"
25 #include "avsession_info.h"
26 #include "avsession_errors.h"
27 #include "key_event.h"
28 #include "want_agent.h"
29 
30 /**
31  * @brief Session controller instance.
32  * @since 9
33  */
34 namespace OHOS::AVSession {
35 class AVSessionController {
36 public:
37     /**
38      * @brief Get current avcall status infos.
39      *
40      * @param state Current avcall status infos {@link AVCallState}.
41      * @return Returns check whether the system permissions are supported
42      * @since 11
43     */
44     virtual int32_t GetAVCallState(AVCallState& avCallState) = 0;
45 
46     /**
47      * @brief Get current avcall meta data infos.
48      *
49      * @param state Current avcall meta data infos {@link AVCallMetaData}.
50      * @return Returns check whether the system permissions are supported
51      * @since 11
52     */
53     virtual int32_t GetAVCallMetaData(AVCallMetaData& avCallMetaData) = 0;
54     /**
55      * @brief Get current playing status infos.
56      *
57      * @param state Current playing status infos {@link AVPlaybackState}.
58      * @return Returns check whether the system permissions are supported
59      * @since 9
60     */
61     virtual int32_t GetAVPlaybackState(AVPlaybackState& state) = 0;
62 
63     /**
64      * @brief Get current playing status infos.
65      *
66      * @param state Current playing status infos {@link AVPlaybackState}.
67      * @return Returns check whether the system permissions are supported
68      * @since 9
69     */
70     virtual int32_t GetAVMetaData(AVMetaData& data) = 0;
71 
72     /**
73      * Send key events to the corresponding session of the controller.
74      *
75      * @param keyEvent key event.
76      * @return int32_t Return whether sending succeeded.
77      * @since 9
78     */
79     virtual int32_t SendAVKeyEvent(const MMI::KeyEvent& keyEvent) = 0;
80 
81     /**
82      * Get the WantAgent object saved by the application in the session.
83      *
84      * @param ability Objects saved in setLaunchAbility.
85      * @return int32_t Successfully obtained.
86      * @since 9
87     */
88     virtual int32_t GetLaunchAbility(AbilityRuntime::WantAgent::WantAgent& ability) = 0;
89 
90     /**
91      * Get the WantAgent object saved by the application in the session.
92      *
93      * @param ability Objects saved in setLaunchAbility.
94      * @return int32_t Successfully obtained.
95      * @since 9
96     */
97     virtual int32_t GetLaunchAbilityInner(AbilityRuntime::WantAgent::WantAgent*& ability) = 0;
98 
99     /**
100      * Get valid commands supported by the session.
101      *
102      * @param cmds Returns a collection of valid commands.
103      * @return int32_t Whether the valid commands supported by the session are obtained successfully.
104      * @since 9
105     */
106     virtual int32_t GetValidCommands(std::vector<int32_t>& cmds) = 0;
107 
108     /**
109      * Whether the session is active.
110      *
111      * @param isActive Whether the session is active.
112      * @return int32_t Returns whether the status was obtained successfully.
113      * @since 9
114     */
115     virtual int32_t IsSessionActive(bool& isActive) = 0;
116 
117     /**
118      * Send commands to its corresponding session through the controller.
119      *
120      * @param cmd Commands and parameters related to the session {@link AVControlCommand}.
121      * @return int32_t Return whether sending succeeded.
122      * @since 9
123     */
124     virtual int32_t SendControlCommand(const AVControlCommand& cmd) = 0;
125 
126     /**
127      * Send common commands to its corresponding session through the controller.
128      *
129      * @param commonCommand The name of the command to be sent.
130      * @param commandArgs Command packets to be sent
131      * @return int32_t Return whether sending succeeded.
132      * @since 10
133     */
134     virtual int32_t SendCommonCommand(const std::string& commonCommand, const AAFwk::WantParams& commandArgs) = 0;
135 
136     /**
137      * @brief Listen for AVController Callback event.
138      *
139      * @param callback Listen for AVController Callback event{@link AVControllerCallback}.
140      * @return Returns whether the return is successful.
141      * @since 9
142     */
143     virtual int32_t RegisterCallback(const std::shared_ptr<AVControllerCallback>& callback) = 0;
144 
145     /**
146      * @brief Set avcall meta filter.
147      *
148      * @param filter AVCall Meta filter{@link AVCallMetaMaskType}.
149      * @return Returns whether set successful.
150      * @since 9
151     */
152     virtual int32_t SetAVCallMetaFilter(const AVCallMetaData::AVCallMetaMaskType& filter) = 0;
153 
154     /**
155      * @brief Set avcall state filter.
156      *
157      * @param filter AVCall State {@link AVCallStateMaskType}.
158      * @return Returns whether set successful.
159      * @since 9
160     */
161     virtual int32_t SetAVCallStateFilter(const AVCallState::AVCallStateMaskType& filter) = 0;
162 
163     /**
164      * @brief Set meta filter.
165      *
166      * @param filter Meta filter{@link MetaMaskType}.
167      * @return Returns whether set successful.
168      * @since 9
169     */
170     virtual int32_t SetMetaFilter(const AVMetaData::MetaMaskType& filter) = 0;
171 
172     /**
173      * @brief Set Playback filter.
174      *
175      * @param filter Playback State {@link MetaMaskType}.
176      * @return Returns whether set successful.
177      * @since 9
178     */
179     virtual int32_t SetPlaybackFilter(const AVPlaybackState::PlaybackStateMaskType& filter) = 0;
180 
181     /**
182      * @brief Get the playlist. Which is the content of the playlist presented by this session.
183      *
184      * @param items An array of the AVQueueItem.
185      * @return Return whether the obtain is successful.
186      * @since 10
187     */
188     virtual int32_t GetAVQueueItems(std::vector<AVQueueItem>& items) = 0;
189 
190     /**
191      * @brief Get the name of the playlist presented by this session.
192      *
193      * @param title The name of the playlist.
194      * @return Return whether the get is successful.
195      * @since 10
196      */
197     virtual int32_t GetAVQueueTitle(std::string& title) = 0;
198 
199     /**
200      * @brief Set the item in the playlist to be played.
201      *
202      * @param itemId The serial number of the item to be played.
203      * @return Return whether the operation is successful.
204      * @since 10
205      */
206     virtual int32_t SkipToQueueItem(int32_t& itemId) = 0;
207 
208     /**
209      * @brief Get custom media packet.
210      *
211      * @param extras Custom media packet key-value pairs
212      * @return Return whether the operation is successful
213      * @since 10
214     */
215     virtual int32_t GetExtras(AAFwk::WantParams& extras) = 0;
216 
217     /**
218      * @brief Get extra information for remote device, such as volume level, connected devices.
219      *
220      * @param extraEvent The event name to get
221      * @param extras Custom media packet key-value pairs
222      * @return Return whether the operation is successful
223      * @since 16
224     */
225     virtual int32_t GetExtrasWithEvent(const std::string& extraEvent, AAFwk::WantParams& extras) = 0;
226 
227     /**
228      * @brief Destroy session.
229      *
230      * @return Returns whether destroy successful.
231      * @since 9
232     */
233     virtual int32_t Destroy() = 0;
234 
235     /**
236      * @brief Get session id.
237      *
238      * @return Returns session id.
239      * @since 9
240     */
241     virtual std::string GetSessionId() = 0;
242 
243     /**
244      * @brief Get current playback position.
245      *
246      * @return Returns current playback position.
247      * @since 9
248     */
249     virtual int64_t GetRealPlaybackPosition() = 0;
250 
251     /**
252      * @brief Send custom data for 4k.
253      *
254      * @return Returns whether the operation is successful.
255      * @since 9
256     */
SendCustomData(const AAFwk::WantParams & data)257     virtual int32_t SendCustomData(const AAFwk::WantParams& data) { return AVSESSION_SUCCESS; };
258 
259     /**
260      * @brief Controller is or not destroy.
261      *
262      * @return Returns controller is or not destroy.
263      * @since 9
264     */
265     virtual bool IsDestroy() = 0;
266 
267     /**
268      * @brief Deconstruct AVSessionController.
269      * @since 9
270     */
271     virtual ~AVSessionController() = default;
272 };
273 } // namespace OHOS::AVSession
274 
275 #endif // OHOS_AVSESSION_CONTROLLER_H
276