• 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 AV_CAST_PROVIDER_H
17 #define AV_CAST_PROVIDER_H
18 
19 #include "cast_engine_common.h"
20 #include "i_avcast_state_listener.h"
21 #include "avsession_descriptor.h"
22 #include "i_avcast_controller_proxy.h"
23 
24 namespace OHOS::AVSession {
25 class AVCastProvider {
26 public:
27     /**
28      * @brief Construct AVCastProvider object.
29      *
30      * @since 10
31     */
32     AVCastProvider() = default;
33 
34     /**
35      * @brief Deconstruct AVCastProvider object.
36      *
37      * @since 10
38     */
39     virtual ~AVCastProvider() = default;
40 
41     /**
42      * @brief Initialize AVCastProvider object.
43      *
44      * @since 10
45     */
46     virtual void Init() = 0;
47 
48     /**
49      * Transmission fd
50      *
51      * @param fd file descriptor
52      * @param maxSize file max size
53      * @return Returns whether the fd was transport successfully
54      * @since 13
55     */
56     virtual int32_t StartDeviceLogging(int32_t fd, uint32_t maxSize) = 0;
57 
58     /**
59      * Stop transmission fd
60      *
61      * @return Returns whether stop transport successfully
62      * @since 13
63     */
64     virtual int32_t StopDeviceLogging() = 0;
65 
66     /**
67      * @brief Start searching for sink end devices.
68      *
69      * @param { int } castCapability - The type of device want to discover.
70      * @return { bool } Whether the device discovery operation was successful.
71      * @since 10
72     */
73     virtual bool StartDiscovery(int castCapability, std::vector<std::string> drmSchemes) = 0;
74 
75     /**
76      * @brief Stop Discovering Devices
77      *
78      * @since 10
79     */
80     virtual void StopDiscovery() = 0;
81 
82     /**
83      * @brief Used on the Sink end to set whether it can be discovered or not.
84      *
85      * @param { const bool } enable - whether the sink device can be discovered or not.
86      * @return { int32_t } Whether the operation was successful
87      * @since 10
88     */
89     virtual int32_t SetDiscoverable(const bool enable) = 0;
90 
91     /**
92      * @brief Release AVCastProvider object.
93      *
94      * @since 10
95     */
96     virtual void Release() = 0;
97 
98     /**
99      * @brief Register listener for AVCast state callback event.
100      *
101      * @param { std::shared_ptr<IAVCastStateListener> } listener - Register the pointer.
102      * @return { bool } Whether the operation was successful.
103      * @since 10
104     */
105     virtual bool RegisterCastStateListener(std::shared_ptr<IAVCastStateListener> listener) = 0;
106 
107     /**
108      * @brief Unregister listener for AVCast state callback event.
109      *
110      * @param { std::shared_ptr<IAVCastSessionStateListener> } callback - The pointer want unregistered.
111      * @return { bool } Whether the operation was successful.
112      * @since 10
113     */
114     virtual bool UnRegisterCastStateListener(std::shared_ptr<IAVCastStateListener> listener) = 0;
115 
116     /**
117      * @brief Notify CastEngine to add (connect) remote devices.
118      *
119      * @param { int32_t } castId - Find the corresponding provider through this ID.
120      * @param { DeviceInfo } deviceInfo - Devices to be connected.
121      * @return { bool } Whether the operation was successful.
122      * @since 10
123     */
124     virtual bool AddCastDevice(int castId, DeviceInfo deviceInfo) = 0;
125 
126     /**
127      * @brief Notify CastEngine to remove (disconnect) remote devices.
128      *
129      * @param { int32_t } castId - Find the corresponding provider through this ID.
130      * @param { OutputDeviceInfo } outputDeviceInfo - Devices to be disconnected.
131      * @return { bool } Whether the operation was successful.
132      * @since 10
133     */
134     virtual bool RemoveCastDevice(int castId, DeviceInfo deviceInfo) = 0;
135 
136     /**
137      * @brief Start cast process.
138      *
139      * @return { int } Whether the operation was successful.
140      * @since 10
141     */
142     virtual int StartCastSession() = 0;
143 
144     /**
145      * @brief Stop cast process.
146      *
147      * @param { int } castId - The ID corresponding to the provider that needs to be stopped.
148      * @since 10
149     */
150     virtual void StopCastSession(int castId) = 0;
151 
152     /**
153      * @brief Get the cast controller specified by castHandle.
154      *
155      * @param { int } castId - castId corresponding to cast engine session.
156      * @return { std::shared_ptr<IAVCastControllerProxy> } Obtained cast controller.
157      * @since 10
158     */
159     virtual std::shared_ptr<IAVCastControllerProxy> GetRemoteController(int castId) = 0;
160 
161     /**
162      * @brief Register listener for AVCast session state callback event.
163      *
164      * @param { int } castId - The ID corresponding to the provider.
165      * @param { std::shared_ptr<IAVCastSessionStateListener> } callback - Callback function.
166      * @return { bool } Whether the operation was successful.
167      * @since 10
168     */
169     virtual bool RegisterCastSessionStateListener(int castId,
170         std::shared_ptr<IAVCastSessionStateListener> listener) = 0;
171 
172     /**
173      * @brief Unregister listener for AVCast session state callback event.
174      *
175      * @param { int } castId - The ID corresponding to the provider.
176      * @param { std::shared_ptr<IAVCastSessionStateListener> } callback - Callback function.
177      * @return { bool } Whether the operation was successful.
178      * @since 10
179     */
180     virtual bool UnRegisterCastSessionStateListener(int castId,
181         std::shared_ptr<IAVCastSessionStateListener> listener) = 0;
182 
183     /**
184      * @brief set allconnect state.
185      *
186      * @param { int64_t } castHandle const - The ID corresponding to the castprovider.
187      * @param { DeviceInfo } cast deviceinfo - The deviceinfo to the castprovider.
188      * @return { bool } Whether the operation was successful.
189      * @since 11
190     */
191     virtual bool SetStreamState(int32_t castId, DeviceInfo deviceInfo) = 0;
192 
193     /**
194      * @brief get mirror castid.
195      *
196      * @return { int } mirror castid.
197      * @since 11
198     */
199     virtual int GetMirrorCastId() = 0;
200 
201     /**
202      * @brief get remote networkId.
203      *
204      * @param { int32_t } castHandle const - The ID corresponding to the castprovider.
205      * @param { string } cast deviceId - The deviceId give cast+ to get remote networkId.
206      * @param { string } cast networkId - The networkId to transmit remote networkId.
207      * @return { bool } Whether the operation was successful.
208      * @since 11
209     */
210     virtual bool GetRemoteNetWorkId(int32_t castId, std::string deviceId, std::string &networkId) = 0;
211 };
212 } // namespace OHOS::AVSession
213 #endif
214