• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <mutex>
20 #include <string>
21 #include "avsession_log.h"
22 #include "avsession_errors.h"
23 #include "collaboration_manager_utils.h"
24 #include "plugin_lib.h"
25 
26 namespace OHOS::AVSession {
27 class CollaborationManager {
28 public:
29     static CollaborationManager& GetInstance();
30     static void ReleaseInstance();
31     CollaborationManager();
32     virtual ~CollaborationManager();
33     void SendCollaborationApplyResult(const std::function<void(const int32_t code)>& callback);
34     void SendCollaborationOnStop(const std::function<void(void)>& callback);
35     int32_t ReadCollaborationManagerSo();
36     int32_t RegisterLifecycleCallback();
37     int32_t UnRegisterLifecycleCallback();
38     int32_t PublishServiceState(const char* peerNetworkId, ServiceCollaborationManagerBussinessStatus state);
39     int32_t ApplyAdvancedResource(const char* peerNetworkId);
40 
41     std::function<void(const int32_t code)> sendCollaborationApplyResult_;
42     std::function<void(void)> sendCollaborationOnStop_;
43 
44 private:
45     static std::shared_ptr<CollaborationManager> instance_;
46     static std::recursive_mutex instanceLock_;
47     const int32_t remoteHardwareListSize_ = 2;
48     const int32_t localHardwareListSize_ = 0;
49     const std::string serviceName_ = "URLCasting";
50     const std::string dataType_ = "DATA_TYPE_BYTES";
51     PluginLib pluginLib_ {"/system/lib64/libcfwk_allconnect_client.z.so"};
52     ServiceCollaborationManager_ResourceRequestInfoSets *resourceRequest_ =
53         new ServiceCollaborationManager_ResourceRequestInfoSets();
54     ServiceCollaborationManager_API exportapi_;
55 
56     using CollaborationManagerExportFunType = int32_t (*)(ServiceCollaborationManager_API *exportapi);
57     CollaborationManagerExportFunType collaborationManagerExportFun_;
58     ServiceCollaborationManager_HardwareRequestInfo localHardwareList_;
59     ServiceCollaborationManager_HardwareRequestInfo remoteHardwareList_[2];
60     ServiceCollaborationManager_CommunicationRequestInfo communicationRequest_;
61 };
62 }   // namespace OHOS::AVSession
63 #endif //COLLABORATION_MANAGER_H