1 /*
2  * Copyright (c) 2023 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_I_AVCAST_CONTROLLER_PROXY_H
17 #define OHOS_I_AVCAST_CONTROLLER_PROXY_H
18 
19 #include <string>
20 #include "avplayback_state.h"
21 #include "media_info_holder.h"
22 #include "media_info.h"
23 #include "avcast_control_command.h"
24 #include "avsession_info.h"
25 
26 /**
27  * @brief Router is a part related to cast media
28  * @since 10
29  */
30 namespace OHOS::AVSession {
31 class IAVCastControllerProxy {
32 public:
33     /**
34      * @brief Construct IAVCastControllerProxy object.
35      *
36      * @since 10
37     */
38     IAVCastControllerProxy() = default;
39 
40     /**
41      * @brief Deconstruct IAVCastControllerProxy object.
42      *
43      * @since 10
44     */
45     virtual ~IAVCastControllerProxy() = default;
46 
47     /**
48      * @brief Release IAVCastControllerProxy object.
49      *
50      * @since 10
51     */
52     virtual void Release() = 0;
53 
54     /**
55      * @brief Register listener for AVCast controller callback event.
56      *
57      * @param { std::shared_ptr<IAVCastControllerProxyListener> } iAVCastControllerProxyListener - Register listener.
58      * @return { int32_t } Whether the operation was successful.
59      * @since 10
60     */
61     virtual int32_t RegisterControllerListener(
62         const std::shared_ptr<IAVCastControllerProxyListener> iAVCastControllerProxyListener) = 0;
63 
64     /**
65      * @brief Unregister listener for AVCast state callback event.
66      *
67      * @param { std::shared_ptr<IAVCastControllerProxyListener> }
68            iAVCastControllerProxyListener - Unregistered listener.
69      * @return { int32_t } Whether the operation was successful.
70      * @since 10
71     */
72     virtual int32_t UnRegisterControllerListener(
73         const std::shared_ptr<IAVCastControllerProxyListener> iAVCastControllerProxyListener) = 0;
74 
75     /**
76      * @brief Get current queue item.
77      *
78      * @return { AVQueueItem } current queue item.
79      * @since 10
80     */
81     virtual AVQueueItem GetCurrentItem() = 0;
82 
83     /**
84      * @brief Set media info (avQueueItem) to remote, and play immediately.
85      *
86      * @param { const AVQueueItem& } avQueueItem - AVQueueItem that need to be played.
87      * @return { int32_t } Whether the operation was successful.
88      * @since 10
89     */
90     virtual int32_t Start(const AVQueueItem& avQueueItem) = 0;
91 
92     /**
93      * @brief Set media info (avQueueItem) to remote, but won't play immediately.
94      *
95      * @param { const AVQueueItem& } avQueueItem - AVQueueItem that need to be played.
96      * @return { int32_t } Whether the operation was successful.
97      * @since 10
98     */
99     virtual int32_t Prepare(const AVQueueItem& avQueueItem) = 0;
100 
101     /**
102      * @brief Send control command to remote.
103      *
104      * @param { const AVCastControlCommand } cmd - Command to be executed at remote device.
105      * @since 10
106     */
107     virtual void SendControlCommand(const AVCastControlCommand cmd) = 0;
108 
109     /**
110      * @brief Obtain the duration of the current media.
111      *
112      * @param { int32_t& } duration - Duration of media.
113      * @return { int32_t } Whether the operation was successful.
114      * @since 10
115     */
116     virtual int32_t GetDuration(int32_t& duration) = 0;
117 
118     /**
119      * @brief Obtain the AVPlaybackState of the current media.
120      *
121      * @param { AVPlaybackState& } avPlaybackState - AVPlaybackState of media.
122      * @return { int32_t } Whether the operation was successful.
123      * @since 10
124     */
125     virtual int32_t GetCastAVPlaybackState(AVPlaybackState& avPlaybackState) = 0;
126 
127     /**
128      * @brief Set valid ability list for current cast session.
129      *
130      * @param { std::vector<int32_t> } validAbilityList - valid ability list for set.
131      * @return { int32_t } Whether the operation was successful.
132      * @since 10
133     */
134     virtual int32_t SetValidAbility(const std::vector<int32_t>& validAbilityList) = 0;
135 
136     /**
137      * @brief Get valid ability list for current cast session.
138      *
139      * @param { std::vector<int32_t> } validAbilityList - valid ability list for get.
140      * @return { int32_t } Whether the operation was successful.
141      * @since 10
142     */
143     virtual int32_t GetValidAbility(std::vector<int32_t> &validAbilityList) = 0;
144 
145     /**
146      * @brief Set display surface of the current media.
147      *
148      * @param { std::string& } surfaceId - Surface required for displaying images.
149      * @return { int32_t } Whether the operation was successful.
150      * @since 10
151     */
152     virtual int32_t SetDisplaySurface(std::string& surfaceId) = 0;
153 
154     /**
155      * @brief Provide key response for drm request.
156      *
157      * @param { std::string& } assetId - AssetId required for drm response.
158      * @param { std::vector<uint8_t> } response - Response required for drm request.
159      * @return { int32_t } Whether the operation was successful.
160      * @since 10
161     */
162     virtual int32_t ProcessMediaKeyResponse(const std::string& assetId, const std::vector<uint8_t>& response) = 0;
163 };
164 } // namespace OHOS::AVSession
165 #endif // OHOS_I_AVCAST_CONTROLLER_PROXY_H
166