• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-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  * Description: supply cast session interface.
15  * Author: zhangge
16  * Create: 2022-06-15
17  */
18 
19 #ifndef I_CAST_SESSION_IMPL_H
20 #define I_CAST_SESSION_IMPL_H
21 
22 #include <string>
23 
24 #include "cast_engine_common.h"
25 #include "cast_service_common.h"
26 #include "cast_engine_errors.h"
27 #include "i_cast_session.h"
28 #include "i_cast_session_listener_impl.h"
29 #include "iremote_broker.h"
30 #include "oh_remote_control_event.h"
31 #include "surface_utils.h"
32 #include "i_stream_player_ipc.h"
33 #include "i_mirror_player_impl.h"
34 
35 namespace OHOS {
36 namespace CastEngine {
37 class ICastSessionImpl : public IRemoteBroker {
38 public:
39     DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.CastEngine.ICastSessionImpl");
40 
41     ICastSessionImpl() = default;
42     ICastSessionImpl(const ICastSessionImpl &) = delete;
43     ICastSessionImpl &operator=(const ICastSessionImpl &) = delete;
44     ICastSessionImpl(ICastSessionImpl &&) = delete;
45     ICastSessionImpl &operator=(ICastSessionImpl &&) = delete;
46     ~ICastSessionImpl() override = default;
47 
48     virtual int32_t RegisterListener(sptr<ICastSessionListenerImpl> listener) = 0;
49     virtual int32_t UnregisterListener() = 0;
50     virtual int32_t AddDevice(const CastRemoteDevice &remoteDevice) = 0;
51     virtual int32_t RemoveDevice(const std::string &deviceId) = 0;
52     virtual int32_t StartAuth(const AuthInfo &authInfo) = 0;
53     virtual int32_t GetSessionId(std::string &sessionId) = 0;
54     virtual int32_t GetDeviceState(const std::string &deviceId, DeviceState &deviceState) = 0;
55     virtual int32_t SetSessionProperty(const CastSessionProperty &property) = 0;
56     virtual int32_t CreateMirrorPlayer(sptr<IMirrorPlayerImpl> &mirrorPlayer) = 0;
57     virtual int32_t CreateStreamPlayer(sptr<IStreamPlayerIpc> &streamPlayer) = 0;
58     virtual int32_t Release() = 0;
59     virtual int32_t NotifyEvent(EventId eventId, std::string &jsonParam) = 0;
60     virtual int32_t SetCastMode(CastMode mode, std::string &jsonParam) = 0;
GetRemoteDeviceInfo(std::string deviceId,CastRemoteDevice & remoteDevice)61     virtual int32_t GetRemoteDeviceInfo(std::string deviceId, CastRemoteDevice &remoteDevice)
62     {
63         return 0;
64     }
AddDevice(const CastInnerRemoteDevice & remoteDevice)65     virtual bool AddDevice(const CastInnerRemoteDevice &remoteDevice)
66     {
67         return false;
68     }
ReleaseSessionResources(pid_t pid,uid_t uid)69     virtual bool ReleaseSessionResources(pid_t pid, uid_t uid)
70     {
71         return false;
72     }
Stop()73     virtual void Stop() {}
GetSessionProtocolType(ProtocolType & protocolType)74     virtual int32_t GetSessionProtocolType(ProtocolType &protocolType)
75     {
76         return CAST_ENGINE_ERROR;
77     }
SetSessionProtocolType(ProtocolType protocolType)78     virtual void SetSessionProtocolType(ProtocolType protocolType) {}
GetSessionState()79     virtual uint8_t GetSessionState()
80     {
81         return 0;
82     }
83 
84 protected:
85     enum {
86         REGISTER_LISTENER = 1,
87         UNREGISTER_LISTENER,
88         ADD_DEVICE,
89         REMOVE_DEVICE,
90         START_AUTH,
91         GET_SESSION_ID,
92         GET_DEVICE_STATE,
93         SET_SESSION_PROPERTY,
94         CREATE_MIRROR_PLAYER,
95         CREAT_STREAM_PLAYER,
96         RELEASE,
97         NOTIFY_EVENT,
98         SET_CAST_MODE,
99         GET_REMOTE_DEVICE_INFO,
100     };
101 };
102 } // namespace CastEngine
103 } // namespace OHOS
104 
105 #endif
106