• 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 manager adaptor.
15  * Author: zhangge
16  * Create: 2022-5-29
17  */
18 
19 #ifndef CAST_SESSION_MANAGER_ADAPTOR_H
20 #define CAST_SESSION_MANAGER_ADAPTOR_H
21 
22 #include <memory>
23 #include <mutex>
24 #include <set>
25 
26 #include "cast_engine_common.h"
27 #include "cast_session_listener_impl_stub.h"
28 #include "cast_session_manager_service_proxy.h"
29 #include "i_cast_session_manager_adaptor.h"
30 
31 namespace OHOS {
32 namespace CastEngine {
33 namespace CastEngineClient {
34 class CastSessionManagerAdaptor : public ICastSessionManagerAdaptor,
35     public std::enable_shared_from_this<CastSessionManagerAdaptor> {
36 public:
CastSessionManagerAdaptor(sptr<CastSessionManagerServiceProxy> proxy)37     CastSessionManagerAdaptor(sptr<CastSessionManagerServiceProxy> proxy) : proxy_(proxy) {}
38     ~CastSessionManagerAdaptor() override;
39 
40     int32_t RegisterListener(std::shared_ptr<ICastSessionManagerListener> listener,
41         sptr<IRemoteObject::DeathRecipient> deathRecipient) override;
42     int32_t UnregisterListener() override;
43     int32_t Release() override;
44     int32_t SetLocalDevice(const CastLocalDevice &localDevice) override;
45     int32_t CreateCastSession(const CastSessionProperty &property, std::shared_ptr<ICastSession> &castSession) override;
46     int32_t SetSinkSessionCapacity(int sessionCapacity) override;
47     int32_t StartDiscovery(int protocols) override;
48     int32_t SetDiscoverable(bool enable) override;
49     int32_t StopDiscovery() override;
50     int32_t GetCastSession(std::string sessionId, std::shared_ptr<ICastSession> &castSession) override;
51 
52 private:
53     void UnsubscribeDeathRecipient();
54 
55     sptr<CastSessionManagerServiceProxy> proxy_;
56     std::mutex mutex_;
57     wptr<IRemoteObject> remote_;
58     sptr<IRemoteObject::DeathRecipient> deathRecipient_{ nullptr };
59 };
60 } // namespace CastEngineClient
61 } // namespace CastEngine
62 } // namespace OHOS
63 
64 #endif // CAST_SESSION_MANAGER_ADAPTOR_H