• 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;
OnSessionEvent(const std::string & deviceId,const EventCode eventCode)61     virtual void OnSessionEvent(const std::string &deviceId, const EventCode eventCode) {}
AddDevice(const CastInnerRemoteDevice & remoteDevice)62     virtual bool AddDevice(const CastInnerRemoteDevice &remoteDevice)
63     {
64         return false;
65     }
ReleaseSessionResources(pid_t pid)66     virtual bool ReleaseSessionResources(pid_t pid)
67     {
68         return false;
69     }
Stop()70     virtual void Stop() {}
GetSessionProtocolType(ProtocolType & protocolType)71     virtual int32_t GetSessionProtocolType(ProtocolType &protocolType)
72     {
73         return CAST_ENGINE_ERROR;
74     }
SetSessionProtocolType(ProtocolType protocolType)75     virtual void SetSessionProtocolType(ProtocolType protocolType) {}
76 
77 protected:
78     enum {
79         REGISTER_LISTENER = 1,
80         UNREGISTER_LISTENER,
81         ADD_DEVICE,
82         REMOVE_DEVICE,
83         START_AUTH,
84         GET_SESSION_ID,
85         GET_DEVICE_STATE,
86         SET_SESSION_PROPERTY,
87         CREAT_MIRROR_PLAYER,
88         CREAT_STREAM_PLAYER,
89         RELEASE,
90         NOTIFY_EVENT,
91         SET_CAST_MODE,
92     };
93 };
94 } // namespace CastEngine
95 } // namespace OHOS
96 
97 #endif
98