• 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_AVROUTER_IMPL_H
17 #define OHOS_AVROUTER_IMPL_H
18 
19 #include "av_router.h"
20 #include "avcast_provider_manager.h"
21 
22 namespace OHOS::AVSession {
23 class AVRouterImpl : public AVRouter {
24 public:
25     AVRouterImpl();
26 
27     void Init(IAVSessionServiceListener *servicePtr) override;
28 
29     int32_t StartCastDiscovery(int32_t castDeviceCapability) override;
30 
31     int32_t StopCastDiscovery() override;
32 
33     int32_t SetDiscoverable(const bool enable) override;
34 
35     int32_t OnDeviceAvailable(OutputDeviceInfo& castOutputDeviceInfo) override;
36 
37     int32_t OnDeviceOffline(const std::string& deviceId) override;
38 
39     void ReleaseCurrentCastSession() override;
40 
41     int32_t OnCastSessionCreated(const int32_t castId) override;
42 
43     int32_t OnCastServerDied(int32_t providerNumber) override;
44 
45     std::shared_ptr<IAVCastControllerProxy> GetRemoteController(const int64_t castHandle) override;
46 
47     int64_t StartCast(const OutputDeviceInfo& outputDeviceInfo) override;
48 
49     int32_t AddDevice(const int32_t castId, const OutputDeviceInfo& outputDeviceInfo) override;
50 
51     int32_t StopCast(const int64_t castHandle) override;
52 
53     int32_t StopCastSession(const int64_t castHandle) override;
54 
55     int32_t RegisterCallback(int64_t castHandleconst,
56         std::shared_ptr<IAVCastSessionStateListener> callback) override;
57 
58     int32_t UnRegisterCallback(int64_t castHandleconst,
59         std::shared_ptr<IAVCastSessionStateListener> callback) override;
60 protected:
61 
62 private:
63     std::recursive_mutex servicePtrLock_;
64     IAVSessionServiceListener *servicePtr_;
65     std::recursive_mutex providerManagerLock_;
66     std::map<int32_t, std::shared_ptr<AVCastProviderManager>> providerManagerMap_;
67     int32_t providerNumber_ = 0;
68     std::map<int32_t, OutputDeviceInfo> castHandleToOutputDeviceMap_;
69 };
70 } // namespace OHOS::AVSession
71 #endif // OHOS_AVROUTER_IMPL_H
72