• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<IAVCastSessionStateListener> } iAVCastControllerProxyListener - Unregistered listener.
68      * @return { int32_t } Whether the operation was successful.
69      * @since 10
70     */
71     virtual int32_t UnRegisterControllerListener(
72         const std::shared_ptr<IAVCastControllerProxyListener> iAVCastControllerProxyListener) = 0;
73 
74     /**
75      * @brief Get current queue item.
76      *
77      * @return { AVQueueItem } current queue item.
78      * @since 10
79     */
80     virtual AVQueueItem GetCurrentItem() = 0;
81 
82     /**
83      * @brief Set media info (avQueueItem) to remote, and play immediately.
84      *
85      * @param { const AVQueueItem& } avQueueItem - AVQueueItem that need to be played.
86      * @return { int32_t } Whether the operation was successful.
87      * @since 10
88     */
89     virtual int32_t Start(const AVQueueItem& avQueueItem) = 0;
90 
91     /**
92      * @brief Set media info (avQueueItem) to remote, but won't play immediately.
93      *
94      * @param { const AVQueueItem& } avQueueItem - AVQueueItem that need to be played.
95      * @return { int32_t } Whether the operation was successful.
96      * @since 10
97     */
98     virtual int32_t Prepare(const AVQueueItem& avQueueItem) = 0;
99 
100     /**
101      * @brief Send control command to remote.
102      *
103      * @param { const AVCastControlCommand } cmd - Command to be executed at remote device.
104      * @since 10
105     */
106     virtual void SendControlCommand(const AVCastControlCommand cmd) = 0;
107 
108     /**
109      * @brief Obtain the duration of the current media.
110      *
111      * @param { int32_t& } duration - Duration of media.
112      * @return { int32_t } Whether the operation was successful.
113      * @since 10
114     */
115     virtual int32_t GetDuration(int32_t& duration) = 0;
116 
117     /**
118      * @brief Obtain the AVPlaybackState of the current media.
119      *
120      * @param { AVPlaybackState& } avPlaybackState - AVPlaybackState of media.
121      * @return { int32_t } Whether the operation was successful.
122      * @since 10
123     */
124     virtual int32_t GetCastAVPlaybackState(AVPlaybackState& avPlaybackState) = 0;
125 
126     /**
127      * @brief Set valid ability list for current cast session.
128      *
129      * @param { std::vector<int32_t> } validAbilityList - valid ability list for set.
130      * @return { int32_t } Whether the operation was successful.
131      * @since 10
132     */
133     virtual int32_t SetValidAbility(const std::vector<int32_t>& validAbilityList) = 0;
134 
135     /**
136      * @brief Get valid ability list for current cast session.
137      *
138      * @param { std::vector<int32_t> } validAbilityList - valid ability list for get.
139      * @return { int32_t } Whether the operation was successful.
140      * @since 10
141     */
142     virtual int32_t GetValidAbility(std::vector<int32_t> &validAbilityList) = 0;
143 
144     /**
145      * @brief Set display surface of the current media.
146      *
147      * @param { std::string& } surfaceId - Surface required for displaying images.
148      * @return { int32_t } Whether the operation was successful.
149      * @since 10
150     */
151     virtual int32_t SetDisplaySurface(std::string& surfaceId) = 0;
152 
153     /**
154      * @brief Provide key response for drm request.
155      *
156      * @param { std::string& } assetId - AssetId required for drm response.
157      * @param { std::vector<uint8_t> } response - Response required for drm request.
158      * @return { int32_t } Whether the operation was successful.
159      * @since 10
160     */
161     virtual int32_t ProcessMediaKeyResponse(const std::string& assetId, const std::vector<uint8_t>& response) = 0;
162 };
163 } // namespace OHOS::AVSession
164 #endif // OHOS_I_AVCAST_CONTROLLER_PROXY_H
165