1 /*
2  * Copyright (c) 2024 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 COLLABORATION_MANAGER_H
17 #define COLLABORATION_MANAGER_H
18 
19 #include <string>
20 #include "avsession_log.h"
21 #include "avsession_errors.h"
22 #include "collaboration_manager_utils.h"
23 #include "plugin_lib.h"
24 
25 namespace OHOS::AVSession {
26 class CollaborationManager {
27 public:
28     static CollaborationManager& GetInstance();
29     CollaborationManager();
30     virtual ~CollaborationManager();
31     void SendRejectStateToStopCast(const std::function<void(const int32_t code)>& callback);
32     int32_t ReadCollaborationManagerSo();
33     int32_t RegisterLifecycleCallback();
34     int32_t UnRegisterLifecycleCallback();
35     int32_t PublishServiceState(const char* peerNetworkId, ServiceCollaborationManagerBussinessStatus state);
36     int32_t ApplyAdvancedResource(const char* peerNetworkId);
37 
38     std::function<void(const int32_t code)> sendRejectStateToStopCast_;
39 
40 private:
41     const int32_t remoteHardwareListSize_ = 2;
42     const int32_t localHardwareListSize_ = 0;
43     const std::string serviceName_ = "URLCasting";
44     const std::string dataType_ = "DATA_TYPE_BYTES";
45     PluginLib pluginLib_ {"/system/lib64/libcfwk_allconnect_client.z.so"};
46     ServiceCollaborationManager_ResourceRequestInfoSets *resourceRequest_ =
47         new ServiceCollaborationManager_ResourceRequestInfoSets();
48     ServiceCollaborationManager_API exportapi_;
49 
50     using CollaborationManagerExportFunType = int32_t (*)(ServiceCollaborationManager_API *exportapi);
51     CollaborationManagerExportFunType collaborationManagerExportFun_;
52     ServiceCollaborationManager_HardwareRequestInfo localHardwareList_;
53     ServiceCollaborationManager_HardwareRequestInfo remoteHardwareList_[2];
54     ServiceCollaborationManager_CommunicationRequestInfo communicationRequest_;
55 };
56 }   // namespace OHOS::AVSession
57 #endif //COLLABORATION_MANAGER_H