1 /* 2 * Copyright (c) 2021-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_DISTRIBUTED_HARDWARE_SERVICE_H 17 #define OHOS_DISTRIBUTED_HARDWARE_SERVICE_H 18 19 #include "system_ability.h" 20 #include "ipc_object_stub.h" 21 22 #include "distributed_hardware_fwk_kit.h" 23 #include "distributed_hardware_fwk_kit_paras.h" 24 #include "distributed_hardware_stub.h" 25 #include "single_instance.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 enum class ServiceRunningState { 30 STATE_NOT_START, 31 STATE_RUNNING 32 }; 33 34 class DistributedHardwareService : public SystemAbility, public DistributedHardwareStub { 35 DECLARE_SYSTEM_ABILITY(DistributedHardwareService); 36 public: 37 DistributedHardwareService(int32_t saId, bool runOnCreate); 38 ~DistributedHardwareService() = default; 39 int32_t RegisterPublisherListener(const DHTopic topic, const sptr<IPublisherListener> &listener) override; 40 int32_t UnregisterPublisherListener(const DHTopic topic, const sptr<IPublisherListener> &listener) override; 41 int32_t PublishMessage(const DHTopic topic, const std::string &msg) override; 42 std::string QueryLocalSysSpec(const QueryLocalSysSpecType spec) override; 43 int Dump(int32_t fd, const std::vector<std::u16string>& args) override; 44 45 int32_t InitializeAVCenter(const TransRole &transRole, int32_t &engineId) override; 46 int32_t ReleaseAVCenter(int32_t engineId) override; 47 int32_t CreateControlChannel(int32_t engineId, const std::string &peerDevId) override; 48 int32_t NotifyAVCenter(int32_t engineId, const AVTransEvent &event) override; 49 int32_t RegisterCtlCenterCallback(int32_t engineId, const sptr<IAVTransControlCenterCallback> &callback) override; 50 int32_t NotifySourceRemoteSinkStarted(std::string &deviceId) override; 51 int32_t PauseDistributedHardware(DHType dhType, const std::string &networkId) override; 52 int32_t ResumeDistributedHardware(DHType dhType, const std::string &networkId) override; 53 int32_t StopDistributedHardware(DHType dhType, const std::string &networkId) override; 54 55 protected: 56 void OnStart() override; 57 void OnStop() override; 58 59 private: 60 bool Init(); 61 std::string QueryDhSysSpec(const std::string &targetKey, std::string &attrs); 62 63 private: 64 bool registerToService_ = false; 65 ServiceRunningState state_ = ServiceRunningState::STATE_NOT_START; 66 }; 67 } // namespace DistributedHardware 68 } // namespace OHOS 69 #endif