1 /* 2 * Copyright (c) 2021 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_CAMERA_SINK_SERVICE_H 17 #define OHOS_DISTRIBUTED_CAMERA_SINK_SERVICE_H 18 19 #include "system_ability.h" 20 #include "ipc_object_stub.h" 21 22 #include "dcamera_sink_dev.h" 23 #include "dcamera_sink_hidumper.h" 24 #include "distributed_camera_constants.h" 25 #include "distributed_camera_sink_stub.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 class DistributedCameraSinkService : public SystemAbility, public DistributedCameraSinkStub { 30 DECLARE_SYSTEM_ABILITY(DistributedCameraSinkService); 31 32 public: 33 DistributedCameraSinkService(int32_t saId, bool runOnCreate); 34 ~DistributedCameraSinkService() = default; 35 36 int32_t InitSink(const std::string& params) override; 37 int32_t ReleaseSink() override; 38 int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; 39 int32_t UnsubscribeLocalHardware(const std::string& dhId) override; 40 int32_t StopCapture(const std::string& dhId) override; 41 int32_t ChannelNeg(const std::string& dhId, std::string& channelInfo) override; 42 int32_t GetCameraInfo(const std::string& dhId, std::string& cameraInfo) override; 43 int32_t OpenChannel(const std::string& dhId, std::string& openInfo) override; 44 int32_t CloseChannel(const std::string& dhId) override; 45 int Dump(int32_t fd, const std::vector<std::u16string>& args) override; 46 static void GetCamDumpInfo(CameraDumpInfo& camDump); 47 48 protected: 49 void OnStart() override; 50 void OnStop() override; 51 DISALLOW_COPY_AND_MOVE(DistributedCameraSinkService); 52 53 private: 54 bool Init(); 55 void GetCamIds(); 56 bool registerToService_ = false; 57 DCameraServiceState state_ = DCameraServiceState::DCAMERA_SRV_STATE_NOT_START; 58 59 std::string sinkVer_; 60 std::map<std::string, std::shared_ptr<DCameraSinkDev>> camerasMap_; 61 static DistributedCameraSinkService* dcSinkService; 62 const size_t DUMP_MAX_SIZE = 10 * 1024; 63 }; 64 } // namespace DistributedHardware 65 } // namespace OHOS 66 #endif // OHOS_DISTRIBUTED_CAMERA_SINK_SERVICE_H