diff --git a/bundle.json b/bundle.json index 1cf349b..05fe787 100644 --- a/bundle.json +++ b/bundle.json @@ -62,8 +62,6 @@ "//foundation/distributedhardware/distributed_camera/sa_profile:dcamera.cfg", "//foundation/distributedhardware/distributed_camera/services/channel:distributed_camera_channel", "//foundation/distributedhardware/distributed_camera/camera_hdf/interfaces/hdi_ipc/config/host:distributed_camera_host_config", - "//foundation/distributedhardware/distributed_camera/camera_hdf/interfaces/hdi_ipc/config/provider:distributed_camera_provider_config", - "//foundation/distributedhardware/distributed_camera/camera_hdf/interfaces/hdi_ipc/client:distributed_camera_hdf_client", "//foundation/distributedhardware/distributed_camera/camera_hdf/hdi_impl:distributed_camera_hdf" ], "inner_kits":[ diff --git a/camera_hdf/hdi_impl/BUILD.gn b/camera_hdf/hdi_impl/BUILD.gn index 000f3e0..1e61038 100644 --- a/camera_hdf/hdi_impl/BUILD.gn +++ b/camera_hdf/hdi_impl/BUILD.gn @@ -23,12 +23,10 @@ ohos_shared_library("distributed_camera_hdf") { "include/dcamera_provider", "include/dstream_operator", "include/utils", - "../interfaces/include", "../interfaces/hdi_ipc", "../interfaces/hdi_ipc/server/device", "../interfaces/hdi_ipc/server/host", "../interfaces/hdi_ipc/server/operator", - "../interfaces/hdi_ipc/server/provider", "//utils/native/base/include", "//utils/system/safwk/native/include", "${display_hdf_path}/interfaces/include", @@ -53,8 +51,6 @@ ohos_shared_library("distributed_camera_hdf") { "../interfaces/hdi_ipc/server/operator/doffline_stream_operator_stub.cpp", "../interfaces/hdi_ipc/server/operator/dstream_operator_callback_proxy.cpp", "../interfaces/hdi_ipc/server/operator/dstream_operator_stub.cpp", - "../interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp", - "../interfaces/hdi_ipc/server/provider/dcamera_provider_stub.cpp", "src/dcamera_device/dcamera_device.cpp", "src/dcamera_device/dmetadata_processor.cpp", "src/dcamera_host/dcamera_host.cpp", @@ -69,6 +65,8 @@ ohos_shared_library("distributed_camera_hdf") { "src/utils/dh_log.cpp", ] + public_deps = [ "//drivers/interface/distributed_camera/v1_0:libdistributed_camera_provider_stub_1.0" ] + deps = [ "//drivers/adapter/uhdf2/ipc:libhdf_ipc_adapter", "//drivers/peripheral/camera/interfaces/metadata:metadata", @@ -83,10 +81,12 @@ ohos_shared_library("distributed_camera_hdf") { ] external_deps = [ + "device_driver_framework:libhdf_utils", "graphic_chipsetsdk:buffer_handle", "graphic_chipsetsdk:surface", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_single", + "utils_base:utils", ] subsystem_name = "distributedhardware" diff --git a/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h b/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h index 2c3f0c4..ecf84d1 100644 --- a/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h +++ b/camera_hdf/hdi_impl/include/dcamera_device/dcamera_device.h @@ -22,14 +22,14 @@ #include "dmetadata_processor.h" #include "dstream_operator.h" #include "icamera_device_callback.h" -#include "idistributed_camera_provider_callback.h" #include "types.h" +#include "v1_0/id_camera_provider_callback.h" namespace OHOS { namespace DistributedHardware { class DCameraDevice : public DCameraDeviceStub { public: - DCameraDevice(const std::shared_ptr &dhBase, const std::string &abilityInfo); + DCameraDevice(const DHBase &dhBase, const std::string &abilityInfo); DCameraDevice() = default; virtual ~DCameraDevice() = default; DCameraDevice(const DCameraDevice &other) = delete; @@ -49,8 +49,8 @@ public: CamRetCode OpenDCamera(const OHOS::sptr &callback); CamRetCode GetDCameraAbility(std::shared_ptr &ability); - DCamRetCode AcquireBuffer(int streamId, std::shared_ptr &buffer); - DCamRetCode ShutterBuffer(int streamId, const std::shared_ptr &buffer); + DCamRetCode AcquireBuffer(int streamId, DCameraBuffer &buffer); + DCamRetCode ShutterBuffer(int streamId, const DCameraBuffer &buffer); DCamRetCode OnSettingsResult(const std::shared_ptr &result); DCamRetCode Notify(const std::shared_ptr &event); void SetProviderCallback(const OHOS::sptr &callback); @@ -61,13 +61,13 @@ public: private: void Init(const std::string &abilityInfo); DCamRetCode CreateDStreamOperator(); - std::string GenerateCameraId(const std::shared_ptr &dhBase); + std::string GenerateCameraId(const DHBase &dhBase); void NotifyStartCaptureError(); void NotifyCameraError(const std::shared_ptr &event); private: bool isOpened_; std::string dCameraId_; - std::shared_ptr dhBase_; + DHBase dhBase_; std::string dCameraAbilityInfo_; OHOS::sptr dCameraDeviceCallback_; OHOS::sptr dCameraProviderCallback_; diff --git a/camera_hdf/hdi_impl/include/dcamera_device/dmetadata_processor.h b/camera_hdf/hdi_impl/include/dcamera_device/dmetadata_processor.h index a230edd..4aa2c98 100644 --- a/camera_hdf/hdi_impl/include/dcamera_device/dmetadata_processor.h +++ b/camera_hdf/hdi_impl/include/dcamera_device/dmetadata_processor.h @@ -21,13 +21,14 @@ #include #include "constants.h" #include "dcamera.h" +#include "v1_0/dcamera_types.h" -#include #include namespace OHOS { namespace DistributedHardware { using namespace OHOS::Camera; +using namespace OHOS::HDI::DistributedCamera::V1_0; class DMetadataProcessor { public: DMetadataProcessor() = default; diff --git a/camera_hdf/hdi_impl/include/dcamera_host/dcamera_host.h b/camera_hdf/hdi_impl/include/dcamera_host/dcamera_host.h index 9432d1a..af435fe 100644 --- a/camera_hdf/hdi_impl/include/dcamera_host/dcamera_host.h +++ b/camera_hdf/hdi_impl/include/dcamera_host/dcamera_host.h @@ -17,16 +17,18 @@ #define DISTRIBUTED_CAMERA_HOST_H #include "dcamera.h" +#include "dcamera_base.h" #include "dcamera_device.h" #include "icamera_device.h" #include "icamera_host_callback.h" #include "icamera_device_callback.h" +#include "v1_0/dcamera_types.h" -#include #include namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraHost { public: DCameraHost() = default; @@ -45,15 +47,15 @@ public: OHOS::sptr &pDevice); CamRetCode SetFlashlight(const std::string &cameraId, bool &isEnable); - DCamRetCode AddDCameraDevice(const std::shared_ptr &dhBase, const std::string &abilityInfo, - const sptr &callback); - DCamRetCode RemoveDCameraDevice(const std::shared_ptr &dhBase); - OHOS::sptr GetDCameraDeviceByDHBase(const std::shared_ptr &dhBase); - void NotifyDCameraStatus(const std::shared_ptr &dhBase, int32_t result); + DCamRetCode AddDCameraDevice(const DHBase &dhBase, const std::string &abilityInfo, + const sptr &callback); + DCamRetCode RemoveDCameraDevice(const DHBase &dhBase); + OHOS::sptr GetDCameraDeviceByDHBase(const DHBase &dhBase); + void NotifyDCameraStatus(const DHBase &dhBase, int32_t result); private: bool IsCameraIdInvalid(const std::string &cameraId); - std::string GetCameraIdByDHBase(const std::shared_ptr &dhBase); + std::string GetCameraIdByDHBase(const DHBase &dhBase); private: class AutoRelease { @@ -70,7 +72,7 @@ private: static std::shared_ptr instance_; OHOS::sptr dCameraHostCallback_; - std::map dhBaseHashDCamIdMap_; + std::map dhBaseHashDCamIdMap_; std::map> dCameraDeviceMap_; }; } // namespace DistributedHardware diff --git a/camera_hdf/hdi_impl/include/dcamera_provider/dcamera_provider.h b/camera_hdf/hdi_impl/include/dcamera_provider/dcamera_provider.h index 21ad7a2..2bb093a 100644 --- a/camera_hdf/hdi_impl/include/dcamera_provider/dcamera_provider.h +++ b/camera_hdf/hdi_impl/include/dcamera_provider/dcamera_provider.h @@ -16,14 +16,14 @@ #ifndef DISTRIBUTED_CAMERA_PROVIDER_H #define DISTRIBUTED_CAMERA_PROVIDER_H -#include "dcamera.h" -#include "idistributed_camera_provider_callback.h" +#include "v1_0/id_camera_provider.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraHost; class DCameraDevice; -class DCameraProvider { +class DCameraProvider : public IDCameraProvider { public: DCameraProvider() = default; virtual ~DCameraProvider() = default; @@ -33,32 +33,27 @@ public: DCameraProvider& operator=(DCameraProvider &&other) = delete; public: - static std::shared_ptr GetInstance(); - DCamRetCode EnableDCameraDevice(const std::shared_ptr &dhBase, const std::string &abilitySet, - const sptr &callback); - DCamRetCode DisableDCameraDevice(const std::shared_ptr &dhBase); - DCamRetCode AcquireBuffer(const std::shared_ptr &dhBase, int streamId, - std::shared_ptr &buffer); - DCamRetCode ShutterBuffer(const std::shared_ptr &dhBase, int streamId, - const std::shared_ptr &buffer); - DCamRetCode OnSettingsResult(const std::shared_ptr &dhBase, const std::shared_ptr &result); - DCamRetCode Notify(const std::shared_ptr &dhBase, const std::shared_ptr &event); + static OHOS::sptr GetInstance(); + int32_t EnableDCameraDevice(const DHBase& dhBase, const std::string& abilityInfo, + const sptr& callbackObj) override; + int32_t DisableDCameraDevice(const DHBase& dhBase) override; + int32_t AcquireBuffer(const DHBase& dhBase, int32_t streamId, DCameraBuffer& buffer) override; + int32_t ShutterBuffer(const DHBase& dhBase, int32_t streamId, const DCameraBuffer& buffer) override; + int32_t OnSettingsResult(const DHBase& dhBase, const DCameraSettings& result) override; + int32_t Notify(const DHBase& dhBase, const DCameraHDFEvent& event) override; - DCamRetCode OpenSession(const std::shared_ptr &dhBase); - DCamRetCode CloseSession(const std::shared_ptr &dhBase); - DCamRetCode ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos); - DCamRetCode ReleaseStreams(const std::shared_ptr &dhBase, const std::vector &streamIds); - DCamRetCode StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos); - DCamRetCode StopCapture(const std::shared_ptr &dhBase, const std::vector &streamIds); - DCamRetCode UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings); + int32_t OpenSession(const DHBase &dhBase); + int32_t CloseSession(const DHBase &dhBase); + int32_t ConfigureStreams(const DHBase &dhBase, const std::vector &streamInfos); + int32_t ReleaseStreams(const DHBase &dhBase, const std::vector &streamIds); + int32_t StartCapture(const DHBase &dhBase, const std::vector &captureInfos); + int32_t StopCapture(const DHBase &dhBase, const std::vector &streamIds); + int32_t UpdateSettings(const DHBase &dhBase, const std::vector &settings); private: - bool IsDhBaseInfoInvalid(const std::shared_ptr &dhBase); - sptr GetCallbackBydhBase(const std::shared_ptr &dhBase); - OHOS::sptr GetDCameraDevice(const std::shared_ptr &dhBase); + bool IsDhBaseInfoInvalid(const DHBase &dhBase); + sptr GetCallbackBydhBase(const DHBase &dhBase); + OHOS::sptr GetDCameraDevice(const DHBase &dhBase); private: class AutoRelease { @@ -72,7 +67,7 @@ private: } }; static AutoRelease autoRelease_; - static std::shared_ptr instance_; + static OHOS::sptr instance_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/camera_hdf/hdi_impl/include/dstream_operator/dbuffer_manager.h b/camera_hdf/hdi_impl/include/dstream_operator/dbuffer_manager.h index a6c5a6c..9f7da90 100644 --- a/camera_hdf/hdi_impl/include/dstream_operator/dbuffer_manager.h +++ b/camera_hdf/hdi_impl/include/dstream_operator/dbuffer_manager.h @@ -24,8 +24,11 @@ #include "dimage_buffer.h" #include "surface.h" +#include "v1_0/dcamera_types.h" + namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DBufferManager { public: DBufferManager() = default; @@ -41,9 +44,9 @@ public: RetCode RemoveBuffer(std::shared_ptr& buffer); void NotifyStop(bool state); static RetCode SurfaceBufferToDImageBuffer(const OHOS::sptr &surfaceBuffer, - const std::shared_ptr &buffer); + const std::shared_ptr &buffer); static RetCode DImageBufferToDCameraBuffer(const std::shared_ptr &imageBuffer, - std::shared_ptr &buffer); + DCameraBuffer &buffer); static uint64_t CameraUsageToGrallocUsage(const uint64_t cameraUsage); static uint32_t PixelFormatToDCameraFormat(const PixelFormat format); diff --git a/camera_hdf/hdi_impl/include/dstream_operator/dcamera_steam.h b/camera_hdf/hdi_impl/include/dstream_operator/dcamera_steam.h index 59d56e2..961af88 100644 --- a/camera_hdf/hdi_impl/include/dstream_operator/dcamera_steam.h +++ b/camera_hdf/hdi_impl/include/dstream_operator/dcamera_steam.h @@ -19,14 +19,15 @@ #include "surface.h" #include "dimage_buffer.h" #include "dbuffer_manager.h" +#include "v1_0/dcamera_types.h" -#include #include namespace OHOS { namespace DistributedHardware { using namespace std; using namespace OHOS::Camera; +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraStream { public: DCameraStream() = default; @@ -42,8 +43,8 @@ public: DCamRetCode SetDCameraBufferQueue(const OHOS::sptr producer); DCamRetCode ReleaseDCameraBufferQueue(); DCamRetCode GetDCameraStreamAttribute(shared_ptr &attribute); - DCamRetCode GetDCameraBuffer(shared_ptr &buffer); - DCamRetCode ReturnDCameraBuffer(const shared_ptr &buffer); + DCamRetCode GetDCameraBuffer(DCameraBuffer &buffer); + DCamRetCode ReturnDCameraBuffer(const DCameraBuffer &buffer); DCamRetCode FlushDCameraBuffer(); DCamRetCode FinishCommitStream(); bool HasBufferQueue(); diff --git a/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h b/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h index 9b09988..5a7eea2 100644 --- a/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h +++ b/camera_hdf/hdi_impl/include/dstream_operator/dstream_operator.h @@ -27,6 +27,8 @@ #include "constants.h" #include "dcamera_steam.h" +#include "json/json.h" + namespace OHOS { namespace DistributedHardware { using namespace std; @@ -58,9 +60,9 @@ public: CamRetCode ChangeToOfflineStream(const std::vector& streamIds, OHOS::sptr& callback, OHOS::sptr& offlineOperator) override; - DCamRetCode InitOutputConfigurations(const std::shared_ptr &dhBase, const std::string &abilityInfo); - DCamRetCode AcquireBuffer(int streamId, std::shared_ptr &buffer); - DCamRetCode ShutterBuffer(int streamId, const std::shared_ptr &buffer); + DCamRetCode InitOutputConfigurations(const DHBase &dhBase, const std::string &abilityInfo); + DCamRetCode AcquireBuffer(int streamId, DCameraBuffer &buffer); + DCamRetCode ShutterBuffer(int streamId, const DCameraBuffer &buffer); DCamRetCode SetCallBack(OHOS::sptr const &callback); DCamRetCode SetDeviceCallback(function &errorCbk, function)> &resultCbk); @@ -85,6 +87,9 @@ private: std::vector> &srcStreamInfo); void SnapShotStreamOnCaptureEnded(int32_t captureId, int streamId); bool HasContinuousCaptureInfo(int captureId); + void ExtractStreamInfo(DCStreamInfo &dstStreamInfo, const std::shared_ptr &srcStreamInfo); + void ExtractCaptureInfo(std::vector &captureInfos); + void ExtractCameraAttr(Json::Value &rootValue, std::set &allFormats, std::vector &photoFormats); private: std::shared_ptr dMetadataProcessor_; @@ -92,7 +97,7 @@ private: function errorCallback_; function)> resultCallback_; - std::shared_ptr dhBase_; + DHBase dhBase_; std::vector dcSupportedCodecType_; std::map> dcSupportedFormatMap_; std::map> dcSupportedResolutionMap_; diff --git a/camera_hdf/hdi_impl/include/utils/dcamera.h b/camera_hdf/hdi_impl/include/utils/dcamera.h index 6d67907..e38ab85 100644 --- a/camera_hdf/hdi_impl/include/utils/dcamera.h +++ b/camera_hdf/hdi_impl/include/utils/dcamera.h @@ -16,12 +16,13 @@ #ifndef DISTRIBUTED_CAMERA_H #define DISTRIBUTED_CAMERA_H -#include #include +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { using namespace OHOS::Camera; +using namespace OHOS::HDI::DistributedCamera::V1_0; using RetCode = uint32_t; using MetaType = int32_t; const std::string BASE_64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.h b/camera_hdf/hdi_impl/include/utils/dcamera_base.h similarity index 53% rename from camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.h rename to camera_hdf/hdi_impl/include/utils/dcamera_base.h index e184331..5645d54 100644 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.h +++ b/camera_hdf/hdi_impl/include/utils/dcamera_base.h @@ -12,24 +12,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +#ifndef OHOS_DCAMERA_BASE_H +#define OHOS_DCAMERA_BASE_H -#ifndef DISTRIBUTED_CAMERA_DEVICE_CALLBACK_H -#define DISTRIBUTED_CAMERA_DEVICE_CALLBACK_H - -#include "dcamera_device_callback_stub.h" +#include namespace OHOS { namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraDeviceCallback : public DCameraDeviceCallbackStub { +class DCameraBase { public: - DCameraDeviceCallback() = default; - virtual ~DCameraDeviceCallback() = default; + DCameraBase() = default; + explicit DCameraBase(std::string deviceId, std::string dhId) : deviceId_(deviceId), dhId_(dhId) {} + ~DCameraBase() = default; -public: - virtual void OnError(ErrorType type, int32_t errorMsg) override; - virtual void OnResult(uint64_t timestamp, const std::shared_ptr &result) override; + bool operator == (const DCameraBase& index) const + { + return this->deviceId_ == index.deviceId_ && this->dhId_ == index.dhId_; + } + + bool operator < (const DCameraBase& index) const + { + return (this->deviceId_ + this->dhId_) < (index.deviceId_ + index.dhId_); + } + + std::string deviceId_; + std::string dhId_; }; } // namespace DistributedHardware } // namespace OHOS -#endif // DISTRIBUTED_CAMERA_DEVICE_CALLBACK_H \ No newline at end of file +#endif // OHOS_DCAMERA_BASE_H diff --git a/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp b/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp index c198d35..f1348a2 100644 --- a/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_device/dcamera_device.cpp @@ -17,6 +17,7 @@ #include #include #include + #include "anonymous_string.h" #include "constants.h" #include "dcamera.h" @@ -29,7 +30,7 @@ namespace OHOS { namespace DistributedHardware { using ErrorCallback = std::function; using ResultCallback = std::function)>; -DCameraDevice::DCameraDevice(const std::shared_ptr &dhBase, const std::string &abilityInfo) +DCameraDevice::DCameraDevice(const DHBase &dhBase, const std::string &abilityInfo) : isOpened_(false), dCameraId_(GenerateCameraId(dhBase)), dhBase_(dhBase), @@ -118,23 +119,23 @@ CamRetCode DCameraDevice::UpdateSettings(const std::shared_ptr &s return CamRetCode::CAMERA_CLOSED; } - std::shared_ptr dcSetting = std::make_shared(); + DCameraSettings dcSetting; - dcSetting->type_ = DCSettingsType::UPDATE_METADATA; + dcSetting.type_ = DCSettingsType::UPDATE_METADATA; std::string abilityStr = Camera::MetadataUtils::EncodeToString(settings); - dcSetting->value_ = Base64Encode(reinterpret_cast(abilityStr.c_str()), abilityStr.length()); + dcSetting.value_ = Base64Encode(reinterpret_cast(abilityStr.c_str()), abilityStr.length()); - std::vector> dcSettings; + std::vector dcSettings; dcSettings.push_back(dcSetting); - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Distributed camera provider instance is null."); return CamRetCode::DEVICE_ERROR; } - DCamRetCode ret = provider->UpdateSettings(dhBase_, dcSettings); + int32_t ret = provider->UpdateSettings(dhBase_, dcSettings); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(ret)); } CamRetCode DCameraDevice::SetResultMode(const ResultCallbackMode &mode) @@ -180,17 +181,19 @@ CamRetCode DCameraDevice::EnableResult(const std::vector &results) stringstream sstream; std::reverse_copy(results.begin(), results.end(), ostream_iterator(sstream, "")); - std::shared_ptr dcSetting = std::make_shared(); - dcSetting->type_ = DCSettingsType::ENABLE_METADATA; - dcSetting->value_ = sstream.str(); + DCameraSettings dcSetting; + dcSetting.type_ = DCSettingsType::ENABLE_METADATA; + dcSetting.value_ = sstream.str(); - std::shared_ptr provider = DCameraProvider::GetInstance(); - if (provider != nullptr) { - std::vector> dcSettings; - dcSettings.push_back(dcSetting); - ret = provider->UpdateSettings(dhBase_, dcSettings); + OHOS::sptr provider = DCameraProvider::GetInstance(); + if (provider == nullptr) { + DHLOGE("Enable metadata failed, provider is nullptr."); + return CamRetCode::DEVICE_ERROR; } - return MapToExternalRetCode(ret); + std::vector dcSettings; + dcSettings.push_back(dcSetting); + int32_t retProv = provider->UpdateSettings(dhBase_, dcSettings); + return MapToExternalRetCode(static_cast(retProv)); } CamRetCode DCameraDevice::DisableResult(const std::vector &results) @@ -208,24 +211,26 @@ CamRetCode DCameraDevice::DisableResult(const std::vector &results) stringstream sstream; std::reverse_copy(results.begin(), results.end(), ostream_iterator(sstream, "")); - std::shared_ptr dcSetting = std::make_shared(); - dcSetting->type_ = DCSettingsType::DISABLE_METADATA; - dcSetting->value_ = sstream.str(); + DCameraSettings dcSetting; + dcSetting.type_ = DCSettingsType::DISABLE_METADATA; + dcSetting.value_ = sstream.str(); - std::shared_ptr provider = DCameraProvider::GetInstance(); - if (provider != nullptr) { - std::vector> dcSettings; - dcSettings.push_back(dcSetting); - ret = provider->UpdateSettings(dhBase_, dcSettings); + OHOS::sptr provider = DCameraProvider::GetInstance(); + if (provider == nullptr) { + DHLOGE("Metadata processor provider is nullptr."); + return CamRetCode::DEVICE_ERROR; } - return MapToExternalRetCode(ret); + std::vector dcSettings; + dcSettings.push_back(dcSetting); + int32_t retProv = provider->UpdateSettings(dhBase_, dcSettings); + return MapToExternalRetCode(static_cast(retProv)); } void DCameraDevice::Close() { DHLOGI("DCameraDevice::Close distributed camera: %s", GetAnonyString(dCameraId_).c_str()); - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) { std::vector streamIds = dCameraStreamOperator_->GetStreamIds(); provider->StopCapture(dhBase_, streamIds); @@ -253,15 +258,15 @@ CamRetCode DCameraDevice::OpenDCamera(const OHOS::sptr &c } dCameraDeviceCallback_ = callback; - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Get distributed camera provider instance is null."); return CamRetCode::DEVICE_ERROR; } - DCamRetCode ret = provider->OpenSession(dhBase_); + int32_t ret = provider->OpenSession(dhBase_); if (ret != DCamRetCode::SUCCESS) { DHLOGE("Open distributed camera control session failed, ret = %d.", ret); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(ret)); } unique_lock lock(openSesslock_); @@ -278,14 +283,14 @@ CamRetCode DCameraDevice::OpenDCamera(const OHOS::sptr &c } } - ret = CreateDStreamOperator(); + DCamRetCode retDCode = CreateDStreamOperator(); if (ret != SUCCESS) { DHLOGE("Create distributed camera stream operator failed."); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(retDCode); } isOpened_ = true; - return MapToExternalRetCode(ret); + return MapToExternalRetCode(retDCode); } CamRetCode DCameraDevice::GetDCameraAbility(std::shared_ptr &ability) @@ -302,7 +307,7 @@ CamRetCode DCameraDevice::GetDCameraAbility(std::shared_ptr &abil return MapToExternalRetCode(ret); } -DCamRetCode DCameraDevice::AcquireBuffer(int streamId, std::shared_ptr &buffer) +DCamRetCode DCameraDevice::AcquireBuffer(int streamId, DCameraBuffer &buffer) { if (dCameraStreamOperator_ == nullptr) { DHLOGE("Stream operator not init."); @@ -316,7 +321,7 @@ DCamRetCode DCameraDevice::AcquireBuffer(int streamId, std::shared_ptr &buffer) +DCamRetCode DCameraDevice::ShutterBuffer(int streamId, const DCameraBuffer &buffer) { if (dCameraStreamOperator_ == nullptr) { DHLOGE("Stream operator not init."); @@ -334,25 +339,25 @@ DCamRetCode DCameraDevice::OnSettingsResult(const std::shared_ptrtype_ != DCSettingsType::METADATA_RESULT) { DHLOGE("Invalid camera setting type = %d.", result->type_); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } if ((result->value_).empty()) { DHLOGE("Camera settings result is empty."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } DCamRetCode ret = dMetadataProcessor_->SaveResultMetadata(result->value_); - if (ret != SUCCESS) { + if (ret != DCamRetCode::SUCCESS) { DHLOGE("Save result metadata failed, ret = %d", ret); } return ret; @@ -364,7 +369,7 @@ DCamRetCode DCameraDevice::Notify(const std::shared_ptr &event) event->content_.c_str()); if ((event->type_ != DCameraEventType::DCAMERA_MESSAGE) && (event->type_ != DCameraEventType::DCAMERA_OPERATION)) { DHLOGE("Invalid distributed camera event type = %d.", event->type_); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } switch (event->result_) { case DCameraEventResult::DCAMERA_EVENT_CHANNEL_CONNECTED: { @@ -410,7 +415,7 @@ void DCameraDevice::NotifyStartCaptureError() if (dCameraDeviceCallback_ != nullptr) { dCameraDeviceCallback_->OnError(ErrorType::REQUEST_TIMEOUT, 0); } - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if ((provider != nullptr) && (dCameraStreamOperator_ != nullptr)) { std::vector streamIds = dCameraStreamOperator_->GetStreamIds(); provider->StopCapture(dhBase_, streamIds); @@ -442,9 +447,9 @@ OHOS::sptr DCameraDevice::GetProviderCallback() return dCameraProviderCallback_; } -std::string DCameraDevice::GenerateCameraId(const std::shared_ptr &dhBase) +std::string DCameraDevice::GenerateCameraId(const DHBase &dhBase) { - return dhBase->deviceId_ + "__" + dhBase->dhId_; + return dhBase.deviceId_ + "__" + dhBase.dhId_; } std::string DCameraDevice::GetDCameraId() diff --git a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp index 89e1b6e..9fd16c9 100644 --- a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp @@ -248,7 +248,7 @@ DCamRetCode DMetadataProcessor::AddAbilityEntry(uint32_t tag, const void *data, { if (dCameraAbility_ == nullptr) { DHLOGE("Distributed camera abilily is null."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } camera_metadata_item_t item; @@ -266,7 +266,7 @@ DCamRetCode DMetadataProcessor::UpdateAbilityEntry(uint32_t tag, const void *dat { if (dCameraAbility_ == nullptr) { DHLOGE("Distributed camera abilily is null."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } camera_metadata_item_t item; @@ -295,7 +295,7 @@ DCamRetCode DMetadataProcessor::SetMetadataResultMode(const ResultCallbackMode & { if (mode < ResultCallbackMode::PER_FRAME || mode > ResultCallbackMode::ON_CHANGED) { DHLOGE("Invalid result callback mode."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } metaResultMode_ = mode; return SUCCESS; @@ -429,18 +429,18 @@ DCamRetCode DMetadataProcessor::SaveResultMetadata(std::string resultStr) { if (resultStr.empty()) { DHLOGE("Input result string is null."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } latestProducerResultMetadata_ = Camera::MetadataUtils::DecodeFromString(resultStr)->get(); if (latestProducerResultMetadata_ == nullptr) { DHLOGE("Failed to decode metadata setting from string."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } if (!Camera::GetCameraMetadataItemCount(latestProducerResultMetadata_)) { DHLOGE("Input result metadata item is empty."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } return SUCCESS; diff --git a/camera_hdf/hdi_impl/src/dcamera_host/dcamera_host.cpp b/camera_hdf/hdi_impl/src/dcamera_host/dcamera_host.cpp index e7fc272..363acba 100644 --- a/camera_hdf/hdi_impl/src/dcamera_host/dcamera_host.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_host/dcamera_host.cpp @@ -118,11 +118,11 @@ CamRetCode DCameraHost::SetFlashlight(const std::string &cameraId, bool &isEnab return CamRetCode::METHOD_NOT_SUPPORTED; } -DCamRetCode DCameraHost::AddDCameraDevice(const std::shared_ptr &dhBase, const std::string &abilityInfo, +DCamRetCode DCameraHost::AddDCameraDevice(const DHBase &dhBase, const std::string &abilityInfo, const sptr &callback) { DHLOGI("DCameraHost::AddDCameraDevice for {devId: %s, dhId: %s}", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); OHOS::sptr dcameraDevice = new (std::nothrow) DCameraDevice(dhBase, abilityInfo); if (dcameraDevice == nullptr) { @@ -132,8 +132,8 @@ DCamRetCode DCameraHost::AddDCameraDevice(const std::shared_ptr &dhBase, std::string dCameraId = dcameraDevice->GetDCameraId(); dCameraDeviceMap_[dCameraId] = dcameraDevice; - DHBase dhBaseKey(dhBase->deviceId_, dhBase->dhId_); - dhBaseHashDCamIdMap_.emplace(dhBaseKey, dCameraId); + DCameraBase dcameraBase(dhBase.deviceId_, dhBase.dhId_); + dhBaseHashDCamIdMap_.emplace(dcameraBase, dCameraId); dcameraDevice->SetProviderCallback(callback); if (dCameraHostCallback_ != nullptr) { @@ -145,10 +145,10 @@ DCamRetCode DCameraHost::AddDCameraDevice(const std::shared_ptr &dhBase, return DCamRetCode::SUCCESS; } -DCamRetCode DCameraHost::RemoveDCameraDevice(const std::shared_ptr &dhBase) +DCamRetCode DCameraHost::RemoveDCameraDevice(const DHBase &dhBase) { DHLOGI("DCameraHost::RemoveDCameraDevice for {devId: %s, dhId: %s}", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); std::string dCameraId = GetCameraIdByDHBase(dhBase); if (dCameraId.empty()) { @@ -164,8 +164,8 @@ DCamRetCode DCameraHost::RemoveDCameraDevice(const std::shared_ptr &dhBa dcameraDevice->SetProviderCallback(nullptr); } - DHBase dhBaseKey(dhBase->deviceId_, dhBase->dhId_); - dhBaseHashDCamIdMap_.erase(dhBaseKey); + DCameraBase dcameraBase(dhBase.deviceId_, dhBase.dhId_); + dhBaseHashDCamIdMap_.erase(dcameraBase); dCameraDeviceMap_.erase(dCameraId); if (dCameraHostCallback_ != nullptr) { @@ -193,17 +193,17 @@ bool DCameraHost::IsCameraIdInvalid(const std::string &cameraId) return true; } -std::string DCameraHost::GetCameraIdByDHBase(const std::shared_ptr &dhBase) +std::string DCameraHost::GetCameraIdByDHBase(const DHBase &dhBase) { - DHBase dhBaseKey(dhBase->deviceId_, dhBase->dhId_); - auto iter = dhBaseHashDCamIdMap_.find(dhBaseKey); + DCameraBase dcameraBase(dhBase.deviceId_, dhBase.dhId_); + auto iter = dhBaseHashDCamIdMap_.find(dcameraBase); if (iter == dhBaseHashDCamIdMap_.end()) { return ""; } return iter->second; } -OHOS::sptr DCameraHost::GetDCameraDeviceByDHBase(const std::shared_ptr &dhBase) +OHOS::sptr DCameraHost::GetDCameraDeviceByDHBase(const DHBase &dhBase) { std::string dCameraId = GetCameraIdByDHBase(dhBase); if (dCameraId.empty()) { @@ -219,7 +219,7 @@ OHOS::sptr DCameraHost::GetDCameraDeviceByDHBase(const std::share return iter->second; } -void DCameraHost::NotifyDCameraStatus(const std::shared_ptr &dhBase, int32_t result) +void DCameraHost::NotifyDCameraStatus(const DHBase &dhBase, int32_t result) { std::string dCameraId = GetCameraIdByDHBase(dhBase); if (dCameraId.empty()) { diff --git a/camera_hdf/hdi_impl/src/dcamera_provider/dcamera_provider.cpp b/camera_hdf/hdi_impl/src/dcamera_provider/dcamera_provider.cpp index 149ec43..4e586ca 100644 --- a/camera_hdf/hdi_impl/src/dcamera_provider/dcamera_provider.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_provider/dcamera_provider.cpp @@ -22,13 +22,18 @@ namespace OHOS { namespace DistributedHardware { -std::shared_ptr DCameraProvider::instance_ = nullptr; +OHOS::sptr DCameraProvider::instance_ = nullptr; DCameraProvider::AutoRelease DCameraProvider::autoRelease_; -std::shared_ptr DCameraProvider::GetInstance() +extern "C" IDCameraProvider *HdiImplGetInstance(void) +{ + return static_cast(DCameraProvider::GetInstance().GetRefPtr()); +} + +OHOS::sptr DCameraProvider::GetInstance() { if (instance_ == nullptr) { - instance_ = std::make_shared(); + instance_ = new DCameraProvider(); if (instance_ == nullptr) { DHLOGE("Get distributed camera provider instance failed."); return nullptr; @@ -37,15 +42,11 @@ std::shared_ptr DCameraProvider::GetInstance() return instance_; } -DCamRetCode DCameraProvider::EnableDCameraDevice(const std::shared_ptr &dhBase, - const std::string &abilityInfo, const sptr &callback) +int32_t DCameraProvider::EnableDCameraDevice(const DHBase& dhBase, const std::string& abilityInfo, + const sptr& callbackObj) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::EnableDCameraDevice, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::EnableDCameraDevice for {devId: %s, dhId: %s, abilityInfo length: %d}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str(), abilityInfo.length()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str(), abilityInfo.length()); if (IsDhBaseInfoInvalid(dhBase)) { DHLOGE("DCameraProvider::EnableDCameraDevice, devId or dhId is invalid."); @@ -55,8 +56,8 @@ DCamRetCode DCameraProvider::EnableDCameraDevice(const std::shared_ptr & DHLOGE("DCameraProvider::EnableDCameraDevice, dcamera ability is empty."); return DCamRetCode::INVALID_ARGUMENT; } - if (callback == nullptr) { - DHLOGE("DCameraProvider::EnableDCameraDevice, dcamera provider callback is null."); + if (callbackObj == nullptr) { + DHLOGE("DCameraProvider::EnableDCameraDevice, dcamera provider callbackObj is null."); return DCamRetCode::INVALID_ARGUMENT; } @@ -65,7 +66,7 @@ DCamRetCode DCameraProvider::EnableDCameraDevice(const std::shared_ptr & DHLOGE("DCameraProvider::EnableDCameraDevice, dcamera host is null."); return DCamRetCode::DEVICE_NOT_INIT; } - DCamRetCode ret = dCameraHost->AddDCameraDevice(dhBase, abilityInfo, callback); + DCamRetCode ret = dCameraHost->AddDCameraDevice(dhBase, abilityInfo, callbackObj); if (ret != DCamRetCode::SUCCESS) { DHLOGE("DCameraProvider::EnableDCameraDevice failed, ret = %d.", ret); } @@ -73,14 +74,10 @@ DCamRetCode DCameraProvider::EnableDCameraDevice(const std::shared_ptr & return ret; } -DCamRetCode DCameraProvider::DisableDCameraDevice(const std::shared_ptr &dhBase) +int32_t DCameraProvider::DisableDCameraDevice(const DHBase& dhBase) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::DisableDCameraDevice, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::DisableDCameraDevice for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); if (IsDhBaseInfoInvalid(dhBase)) { DHLOGE("DCameraProvider::DisableDCameraDevice, devId or dhId is invalid."); @@ -101,15 +98,10 @@ DCamRetCode DCameraProvider::DisableDCameraDevice(const std::shared_ptr return DCamRetCode::SUCCESS; } -DCamRetCode DCameraProvider::AcquireBuffer(const std::shared_ptr &dhBase, int streamId, - std::shared_ptr &buffer) +int32_t DCameraProvider::AcquireBuffer(const DHBase& dhBase, int32_t streamId, DCameraBuffer& buffer) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::AcquireBuffer, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::AcquireBuffer for {devId: %s, dhId: %s}, streamId: %d.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str(), streamId); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str(), streamId); OHOS::sptr device = GetDCameraDevice(dhBase); if (device == nullptr) { @@ -117,41 +109,35 @@ DCamRetCode DCameraProvider::AcquireBuffer(const std::shared_ptr &dhBase return DCamRetCode::INVALID_ARGUMENT; } - return device->AcquireBuffer(streamId, buffer); + DCamRetCode ret = device->AcquireBuffer(streamId, buffer); + if (ret != DCamRetCode::SUCCESS) { + DHLOGE("DCameraProvider::AcquireBuffer failed, ret = %d.", ret); + return ret; + } + return DCamRetCode::SUCCESS; } -DCamRetCode DCameraProvider::ShutterBuffer(const std::shared_ptr &dhBase, int streamId, - const std::shared_ptr &buffer) +int32_t DCameraProvider::ShutterBuffer(const DHBase& dhBase, int32_t streamId, const DCameraBuffer& buffer) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::ShutterBuffer, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } - if (buffer == nullptr) { - DHLOGE("DCameraProvider::ShutterBuffer, input distributed camera buffer is null."); - return DCamRetCode::INVALID_ARGUMENT; - } - DHLOGI("DCameraProvider::ShutterBuffer for {devId: %s, dhId: %s}, streamId = %d, buffer index = %d.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str(), streamId, buffer->index_); + DHLOGD("DCameraProvider::ShutterBuffer for {devId: %s, dhId: %s}, streamId = %d, buffer index = %d.", + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str(), streamId, buffer.index_); + /* ShutterBuffer don't need buffer handle */ + if (buffer.bufferHandle_ != nullptr) { + FreeBufferHandle(buffer.bufferHandle_->GetBufferHandle()); + } OHOS::sptr device = GetDCameraDevice(dhBase); if (device == nullptr) { DHLOGE("DCameraProvider::ShutterBuffer failed, dcamera device not found."); return DCamRetCode::INVALID_ARGUMENT; } - return device->ShutterBuffer(streamId, buffer); } -DCamRetCode DCameraProvider::OnSettingsResult(const std::shared_ptr &dhBase, - const std::shared_ptr &result) +int32_t DCameraProvider::OnSettingsResult(const DHBase& dhBase, const DCameraSettings& result) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::OnSettingsResult, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::OnSettingsResult for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); OHOS::sptr device = GetDCameraDevice(dhBase); if (device == nullptr) { @@ -159,18 +145,16 @@ DCamRetCode DCameraProvider::OnSettingsResult(const std::shared_ptr &dhB return DCamRetCode::INVALID_ARGUMENT; } - return device->OnSettingsResult(result); + std::shared_ptr dCameraResult = std::make_shared(); + dCameraResult->type_ = result.type_; + dCameraResult->value_ = result.value_; + return device->OnSettingsResult(dCameraResult); } -DCamRetCode DCameraProvider::Notify(const std::shared_ptr &dhBase, - const std::shared_ptr &event) +int32_t DCameraProvider::Notify(const DHBase& dhBase, const DCameraHDFEvent& event) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::Notify, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::Notify for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); OHOS::sptr device = GetDCameraDevice(dhBase); if (device == nullptr) { @@ -178,17 +162,17 @@ DCamRetCode DCameraProvider::Notify(const std::shared_ptr &dhBase, return DCamRetCode::INVALID_ARGUMENT; } - return device->Notify(event); + std::shared_ptr dCameraEvent = std::make_shared(); + dCameraEvent->type_ = event.type_; + dCameraEvent->result_ = event.result_; + dCameraEvent->content_ = event.content_; + return device->Notify(dCameraEvent); } -DCamRetCode DCameraProvider::OpenSession(const std::shared_ptr &dhBase) +int32_t DCameraProvider::OpenSession(const DHBase &dhBase) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::OpenSession, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::OpenSession for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -199,14 +183,10 @@ DCamRetCode DCameraProvider::OpenSession(const std::shared_ptr &dhBase) return callback->OpenSession(dhBase); } -DCamRetCode DCameraProvider::CloseSession(const std::shared_ptr &dhBase) +int32_t DCameraProvider::CloseSession(const DHBase &dhBase) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::CloseSession, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::CloseSession for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -217,15 +197,10 @@ DCamRetCode DCameraProvider::CloseSession(const std::shared_ptr &dhBase) return callback->CloseSession(dhBase); } -DCamRetCode DCameraProvider::ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos) +int32_t DCameraProvider::ConfigureStreams(const DHBase &dhBase, const std::vector &streamInfos) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::ConfigureStreams, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::ConfigureStreams for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -233,22 +208,17 @@ DCamRetCode DCameraProvider::ConfigureStreams(const std::shared_ptr &dhB return DCamRetCode::INVALID_ARGUMENT; } - for (auto info : streamInfos) { + for (auto info = streamInfos.begin(); info != streamInfos.end(); info++) { DHLOGI("ConfigureStreams: id=%d, width=%d, height=%d, format=%d, " + "type=%d.", info->streamId_, info->width_, info->height_, info->format_, info->type_); } return callback->ConfigureStreams(dhBase, streamInfos); } -DCamRetCode DCameraProvider::ReleaseStreams(const std::shared_ptr &dhBase, - const std::vector &streamIds) +int32_t DCameraProvider::ReleaseStreams(const DHBase &dhBase, const std::vector &streamIds) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::ReleaseStreams, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::ReleaseStreams for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -264,15 +234,10 @@ DCamRetCode DCameraProvider::ReleaseStreams(const std::shared_ptr &dhBas return callback->ReleaseStreams(dhBase, streamIds); } -DCamRetCode DCameraProvider::StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos) +int32_t DCameraProvider::StartCapture(const DHBase &dhBase, const std::vector &captureInfos) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::StartCapture, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::StartCapture for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -280,7 +245,7 @@ DCamRetCode DCameraProvider::StartCapture(const std::shared_ptr &dhBase, return DCamRetCode::INVALID_ARGUMENT; } - for (auto info : captureInfos) { + for (auto info = captureInfos.begin(); info != captureInfos.end(); info++) { std::string idString = ""; for (int id : info->streamIds_) { idString += (std::to_string(id) + ", "); @@ -292,15 +257,10 @@ DCamRetCode DCameraProvider::StartCapture(const std::shared_ptr &dhBase, return callback->StartCapture(dhBase, captureInfos); } -DCamRetCode DCameraProvider::StopCapture(const std::shared_ptr &dhBase, - const std::vector &streamIds) +int32_t DCameraProvider::StopCapture(const DHBase &dhBase, const std::vector &streamIds) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::StopCapture, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::StopCapture for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -317,15 +277,10 @@ DCamRetCode DCameraProvider::StopCapture(const std::shared_ptr &dhBase, return callback->StopCapture(dhBase, streamIds); } -DCamRetCode DCameraProvider::UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings) +int32_t DCameraProvider::UpdateSettings(const DHBase &dhBase, const std::vector &settings) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::UpdateSettings, dhBase is null."); - return DCamRetCode::INVALID_ARGUMENT; - } DHLOGI("DCameraProvider::UpdateSettings for {devId: %s, dhId: %s}.", - GetAnonyString(dhBase->deviceId_).c_str(), GetAnonyString(dhBase->dhId_).c_str()); + GetAnonyString(dhBase.deviceId_).c_str(), GetAnonyString(dhBase.dhId_).c_str()); sptr callback = GetCallbackBydhBase(dhBase); if (callback == nullptr) { @@ -336,18 +291,14 @@ DCamRetCode DCameraProvider::UpdateSettings(const std::shared_ptr &dhBas return callback->UpdateSettings(dhBase, settings); } -bool DCameraProvider::IsDhBaseInfoInvalid(const std::shared_ptr &dhBase) +bool DCameraProvider::IsDhBaseInfoInvalid(const DHBase &dhBase) { - return dhBase == nullptr || dhBase->deviceId_.empty() || (dhBase->deviceId_.size() > DEVID_MAX_LENGTH) || - dhBase->dhId_.empty() || (dhBase->dhId_.size() > DHID_MAX_LENGTH); + return dhBase.deviceId_.empty() || (dhBase.deviceId_.size() > DEVID_MAX_LENGTH) || + dhBase.dhId_.empty() || (dhBase.dhId_.size() > DHID_MAX_LENGTH); } -sptr DCameraProvider::GetCallbackBydhBase(const std::shared_ptr &dhBase) +sptr DCameraProvider::GetCallbackBydhBase(const DHBase &dhBase) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::GetCallbackBydhBase, dhBase is null."); - return nullptr; - } OHOS::sptr device = GetDCameraDevice(dhBase); if (device == nullptr) { DHLOGE("DCameraProvider::GetCallbackBydhBase failed, dcamera device not found."); @@ -356,12 +307,8 @@ sptr DCameraProvider::GetCallbackBydhBase(const std::s return device->GetProviderCallback(); } -OHOS::sptr DCameraProvider::GetDCameraDevice(const std::shared_ptr &dhBase) +OHOS::sptr DCameraProvider::GetDCameraDevice(const DHBase &dhBase) { - if (dhBase == nullptr) { - DHLOGE("DCameraProvider::GetDCameraDevice, dhBase is null."); - return nullptr; - } std::shared_ptr dCameraHost = DCameraHost::GetInstance(); if (dCameraHost == nullptr) { DHLOGE("DCameraProvider::GetDCameraDevice, dcamera host is null."); diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dbuffer_manager.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dbuffer_manager.cpp index 0ab0ef8..ff607b5 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dbuffer_manager.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dbuffer_manager.cpp @@ -26,7 +26,7 @@ std::shared_ptr DBufferManager::AcquireBuffer() if (!idleList_.empty()) { auto it = idleList_.begin(); busyList_.splice(busyList_.begin(), idleList_, it); - DHLOGI("Acquire buffer success, index = %d", (*it)->GetIndex()); + DHLOGD("Acquire buffer success, index = %d", (*it)->GetIndex()); return *it; } return nullptr; @@ -140,7 +140,7 @@ uint32_t DBufferManager::PixelFormatToDCameraFormat(const PixelFormat format) } RetCode DBufferManager::DImageBufferToDCameraBuffer(const std::shared_ptr &imageBuffer, - std::shared_ptr &buffer) + DCameraBuffer &buffer) { BufferHandle *bufHandle = imageBuffer->GetBufferHandle(); if (bufHandle == nullptr) { @@ -151,10 +151,9 @@ RetCode DBufferManager::DImageBufferToDCameraBuffer(const std::shared_ptrindex_ = imageBuffer->GetIndex(); - buffer->size_ = imageBuffer->GetSize(); - buffer->bufferHandle_ = bufHandle; - + buffer.index_ = imageBuffer->GetIndex(); + buffer.size_ = imageBuffer->GetSize(); + buffer.bufferHandle_ = new BufferHandleSequenceable(bufHandle); return RC_OK; } } // namespace DistributedHardware diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp index d42f5ad..678ba0d 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp @@ -210,7 +210,7 @@ DCamRetCode DCameraStream::GetNextRequest() DHLOGE("Add buffer to buffer manager failed. [streamId = %d]", dcStreamInfo_->streamId_); return DCamRetCode::EXCEED_MAX_NUMBER; } - DHLOGI("Add new image buffer success: index = %d, fence = %d", imageBuffer->GetIndex(), fence); + DHLOGD("Add new image buffer success: index = %d, fence = %d", imageBuffer->GetIndex(), fence); auto itr = bufferConfigMap_.find(imageBuffer); if (itr == bufferConfigMap_.end()) { @@ -221,7 +221,7 @@ DCamRetCode DCameraStream::GetNextRequest() return DCamRetCode::SUCCESS; } -DCamRetCode DCameraStream::GetDCameraBuffer(shared_ptr &buffer) +DCamRetCode DCameraStream::GetDCameraBuffer(DCameraBuffer &buffer) { DCamRetCode retCode = GetNextRequest(); if (retCode != DCamRetCode::SUCCESS && retCode != DCamRetCode::EXCEED_MAX_NUMBER) { @@ -242,28 +242,23 @@ DCamRetCode DCameraStream::GetDCameraBuffer(shared_ptr &buffer) } captureBufferCount_++; - DHLOGI("Get buffer success. address = %p, index = %d, size = %d", buffer->bufferHandle_->virAddr, - buffer->index_, buffer->size_); + DHLOGD("Get buffer success. address = %p, index = %d, size = %d", buffer.bufferHandle_->GetBufferHandle()->virAddr, + buffer.index_, buffer.size_); return DCamRetCode::SUCCESS; } -DCamRetCode DCameraStream::ReturnDCameraBuffer(const shared_ptr &buffer) +DCamRetCode DCameraStream::ReturnDCameraBuffer(const DCameraBuffer &buffer) { - if (buffer == nullptr) { - DHLOGE("result buffer is null. [streamId = %d]", dcStreamInfo_->streamId_); - return DCamRetCode::INVALID_ARGUMENT; - } - shared_ptr imageBuffer = nullptr; map, tuple, int, int>>::iterator iter; for (iter = bufferConfigMap_.begin(); iter != bufferConfigMap_.end(); ++iter) { - if (buffer->index_ == iter->first->GetIndex()) { + if (buffer.index_ == iter->first->GetIndex()) { imageBuffer = iter->first; break; } } if (imageBuffer == nullptr) { - DHLOGE("Cannot found image buffer, buffer index = %d.", buffer->index_); + DHLOGE("Cannot found image buffer, buffer index = %d.", buffer.index_); return DCamRetCode::INVALID_ARGUMENT; } @@ -275,7 +270,7 @@ DCamRetCode DCameraStream::ReturnDCameraBuffer(const shared_ptr & auto bufCfg = bufferConfigMap_.find(imageBuffer); if (bufCfg == bufferConfigMap_.end()) { DHLOGE("Cannot get bufferConfig."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } auto surfaceBuffer = std::get<0>(bufCfg->second); int32_t fence = std::get<1>(bufCfg->second); diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp index 2d6bbca..735359e 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp @@ -18,7 +18,6 @@ #include "dcamera_provider.h" #include "dcamera.h" #include "distributed_hardware_log.h" -#include "json/json.h" #include "metadata_utils.h" namespace OHOS { @@ -120,21 +119,34 @@ CamRetCode DStreamOperator::ReleaseStreams(const std::vector& streamIds) } } - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Distributed camera provider not init."); return CamRetCode::DEVICE_ERROR; } - DCamRetCode ret = provider->ReleaseStreams(dhBase_, streamIds); + int32_t ret = provider->ReleaseStreams(dhBase_, streamIds); if (ret != SUCCESS) { DHLOGE("Release distributed camera streams failed."); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(ret)); } DHLOGI("DStreamOperator::Release distributed camera streams success."); return CamRetCode::NO_ERROR; } +void DStreamOperator::ExtractStreamInfo(DCStreamInfo &dstStreamInfo, + const std::shared_ptr &srcStreamInfo) +{ + dstStreamInfo.streamId_ = srcStreamInfo->streamId_; + dstStreamInfo.width_ = srcStreamInfo->width_; + dstStreamInfo.height_ = srcStreamInfo->height_; + dstStreamInfo.stride_ = srcStreamInfo->stride_; + dstStreamInfo.format_ = srcStreamInfo->format_; + dstStreamInfo.dataspace_ = srcStreamInfo->dataspace_; + dstStreamInfo.encodeType_ = srcStreamInfo->encodeType_; + dstStreamInfo.type_ = srcStreamInfo->type_; +} + CamRetCode DStreamOperator::CommitStreams(OperationMode mode, const std::shared_ptr& modeSetting) { @@ -157,30 +169,32 @@ CamRetCode DStreamOperator::CommitStreams(OperationMode mode, DHLOGE("No stream to commit."); return CamRetCode::INVALID_ARGUMENT; } - std::vector> dCameraStreams; + std::vector dCameraStreams; for (auto streamInfo : dcStreamInfoMap_) { - dCameraStreams.push_back(streamInfo.second); + DCStreamInfo stream; + ExtractStreamInfo(stream, streamInfo.second); + dCameraStreams.push_back(stream); } - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Distributed camera provider not init."); return CamRetCode::DEVICE_ERROR; } - DCamRetCode ret = provider->ConfigureStreams(dhBase_, dCameraStreams); + int32_t ret = provider->ConfigureStreams(dhBase_, dCameraStreams); if (ret != DCamRetCode::SUCCESS) { DHLOGE("Commit distributed camera streams failed."); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(ret)); } for (size_t i = 0; i < dCameraStreams.size(); i++) { auto streamInfo = dCameraStreams[i]; for (auto halStream : halStreamMap_) { - if (streamInfo->streamId_ == halStream.first) { + if (streamInfo.streamId_ == halStream.first) { ret = halStream.second->FinishCommitStream(); if (ret != DCamRetCode::SUCCESS) { - DHLOGE("Stream %d cannot init.", streamInfo->streamId_); - return MapToExternalRetCode(ret); + DHLOGE("Stream %d cannot init.", streamInfo.streamId_); + return MapToExternalRetCode(static_cast(ret)); } } } @@ -245,6 +259,24 @@ CamRetCode DStreamOperator::DetachBufferQueue(int streamId) } } +void DStreamOperator::ExtractCaptureInfo(std::vector &captureInfos) +{ + for (auto &captureInfo : cachedDCaptureInfoList_) { + DCCaptureInfo capture; + capture.streamIds_.assign(captureInfo->streamIds_.begin(), captureInfo->streamIds_.end()); + capture.width_ = captureInfo->width_; + capture.height_ = captureInfo->height_; + capture.stride_ = captureInfo->stride_; + capture.format_ = captureInfo->format_; + capture.dataspace_ = captureInfo->dataspace_; + capture.isCapture_ = captureInfo->isCapture_; + capture.encodeType_ = captureInfo->encodeType_; + capture.type_ = captureInfo->type_; + capture.captureSettings_.assign(captureInfo->captureSettings_.begin(), captureInfo->captureSettings_.end()); + captureInfos.emplace_back(capture); + } +} + CamRetCode DStreamOperator::Capture(int captureId, const std::shared_ptr& captureInfo, bool isStreaming) { if (captureId < 0 || halCaptureInfoMap_.find(captureId) != halCaptureInfoMap_.end()) { @@ -277,15 +309,17 @@ CamRetCode DStreamOperator::Capture(int captureId, const std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Distributed camera provider not init."); return CamRetCode::DEVICE_ERROR; } - ret = provider->StartCapture(dhBase_, cachedDCaptureInfoList_); - if (ret != SUCCESS) { + std::vector captureInfos; + ExtractCaptureInfo(captureInfos); + int32_t retProv = provider->StartCapture(dhBase_, captureInfos); + if (retProv != SUCCESS) { DHLOGE("Start distributed camera capture failed."); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(retProv)); } halCaptureInfoMap_[captureId] = captureInfo; @@ -308,17 +342,17 @@ CamRetCode DStreamOperator::CancelCapture(int captureId) return CamRetCode::INVALID_ARGUMENT; } - std::shared_ptr provider = DCameraProvider::GetInstance(); + OHOS::sptr provider = DCameraProvider::GetInstance(); if (provider == nullptr) { DHLOGE("Distributed camera provider not init."); return CamRetCode::DEVICE_ERROR; } std::vector streamIds = halCaptureInfoMap_[captureId]->streamIds_; - DCamRetCode ret = provider->StopCapture(dhBase_, streamIds); + int32_t ret = provider->StopCapture(dhBase_, streamIds); if (ret != SUCCESS) { DHLOGE("Cancel distributed camera capture failed."); - return MapToExternalRetCode(ret); + return MapToExternalRetCode(static_cast(ret)); } std::vector> info; @@ -378,22 +412,9 @@ CamRetCode DStreamOperator::ChangeToOfflineStream(const std::vector& stream return CamRetCode::METHOD_NOT_SUPPORTED; } -DCamRetCode DStreamOperator::InitOutputConfigurations(const std::shared_ptr &dhBase, - const std::string &abilityInfo) +void DStreamOperator::ExtractCameraAttr(Json::Value &rootValue, std::set &allFormats, + std::vector &photoFormats) { - dhBase_ = dhBase; - - JSONCPP_STRING errs; - Json::CharReaderBuilder readerBuilder; - Json::Value rootValue; - - std::unique_ptr const jsonReader(readerBuilder.newCharReader()); - if (!jsonReader->parse(abilityInfo.c_str(), abilityInfo.c_str() + abilityInfo.length(), &rootValue, &errs) || - !rootValue.isObject()) { - DHLOGE("Input ablity info is not json object."); - return INVALID_ARGUMENT; - } - if (rootValue["CodecType"].isArray()) { uint32_t size = rootValue["CodecType"].size(); for (uint32_t i = 0; i < size; i++) { @@ -402,7 +423,6 @@ DCamRetCode DStreamOperator::InitOutputConfigurations(const std::shared_ptr allFormats; if (rootValue["OutputFormat"]["Preview"].isArray() && (rootValue["OutputFormat"]["Preview"].size() > 0)) { std::vector previewFormats; uint32_t size = rootValue["OutputFormat"]["Preview"].size(); @@ -423,7 +443,6 @@ DCamRetCode DStreamOperator::InitOutputConfigurations(const std::shared_ptr photoFormats; if (rootValue["OutputFormat"]["Photo"].isArray() && (rootValue["OutputFormat"]["Photo"].size() > 0)) { uint32_t size = rootValue["OutputFormat"]["Photo"].size(); for (uint32_t i = 0; i < size; i++) { @@ -432,6 +451,26 @@ DCamRetCode DStreamOperator::InitOutputConfigurations(const std::shared_ptr const jsonReader(readerBuilder.newCharReader()); + if (!jsonReader->parse(abilityInfo.c_str(), abilityInfo.c_str() + abilityInfo.length(), &rootValue, &errs) || + !rootValue.isObject()) { + DHLOGE("Input ablity info is not json object."); + return DCamRetCode::INVALID_ARGUMENT; + } + + std::set allFormats; + std::vector photoFormats; + ExtractCameraAttr(rootValue, allFormats, photoFormats); for (const auto &format : allFormats) { bool isPhotoFormat = count(photoFormats.begin(), photoFormats.end(), format); @@ -471,7 +510,7 @@ DCamRetCode DStreamOperator::InitOutputConfigurations(const std::shared_ptr &buffer) +DCamRetCode DStreamOperator::AcquireBuffer(int streamId, DCameraBuffer &buffer) { std::unique_lock lock(requestLock_); if (!IsCapturing()) { @@ -494,9 +533,9 @@ DCamRetCode DStreamOperator::AcquireBuffer(int streamId, std::shared_ptr &buffer) +DCamRetCode DStreamOperator::ShutterBuffer(int streamId, const DCameraBuffer &buffer) { - DHLOGI("DStreamOperator::ShutterBuffer begin shutter buffer for streamId = %d", streamId); + DHLOGD("DStreamOperator::ShutterBuffer begin shutter buffer for streamId = %d", streamId); int32_t captureId = -1; for (auto iter = halCaptureInfoMap_.begin(); iter != halCaptureInfoMap_.end(); iter++) { @@ -644,9 +683,9 @@ void DStreamOperator::ConvertStreamInfo(std::shared_ptr &srcInfo, st if ((srcInfo->intent_ == STILL_CAPTURE) || (srcInfo->intent_ == POST_VIEW)) { dstInfo->type_ = DCStreamType::SNAPSHOT_FRAME; - if (dstInfo->encodeType_ == ENCODE_TYPE_JPEG) { + if (dstInfo->encodeType_ == DCEncodeType::ENCODE_TYPE_JPEG) { dstInfo->format_ = OHOS_CAMERA_FORMAT_JPEG; - } else if (dstInfo->encodeType_ == ENCODE_TYPE_NULL) { + } else if (dstInfo->encodeType_ == DCEncodeType::ENCODE_TYPE_NULL) { dstInfo->format_ = OHOS_CAMERA_FORMAT_YCRCB_420_SP; } } else { @@ -668,7 +707,7 @@ DCamRetCode DStreamOperator::NegotiateSuitableCaptureInfo(const std::shared_ptr< } if (srcStreamInfo.empty()) { DHLOGE("Input source stream info vector is empty."); - return INVALID_ARGUMENT; + return DCamRetCode::INVALID_ARGUMENT; } std::shared_ptr inputCaptureInfo = BuildSuitableCaptureInfo(srcCaptureInfo, srcStreamInfo); @@ -722,10 +761,10 @@ std::shared_ptr DStreamOperator::BuildSuitableCaptureInfo(const s ChooseSuitableDataSpace(srcStreamInfo, captureInfo); ChooseSuitableEncodeType(srcStreamInfo, captureInfo); - std::shared_ptr dcSetting = std::make_shared(); - dcSetting->type_ = DCSettingsType::UPDATE_METADATA; + DCameraSettings dcSetting; + dcSetting.type_ = DCSettingsType::UPDATE_METADATA; std::string settingStr = Camera::MetadataUtils::EncodeToString(srcCaptureInfo->captureSetting_); - dcSetting->value_ = Base64Encode(reinterpret_cast(settingStr.c_str()), settingStr.length()); + dcSetting.value_ = Base64Encode(reinterpret_cast(settingStr.c_str()), settingStr.length()); captureInfo->captureSettings_.push_back(dcSetting); diff --git a/camera_hdf/hdi_impl/test/BUILD.gn b/camera_hdf/hdi_impl/test/BUILD.gn index dfef6b5..bcd3bb3 100644 --- a/camera_hdf/hdi_impl/test/BUILD.gn +++ b/camera_hdf/hdi_impl/test/BUILD.gn @@ -24,15 +24,12 @@ ohos_executable("dcamera_hdi_sample") { ] include_dirs = [ - "${distributedcamera_hdf_path}/interfaces/include", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/device", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/host", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/operator", - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/provider", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/device", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/host", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/operator", - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/provider", "${distributedcamera_hdf_path}/hdi_impl/include/dcamera_device", "${distributedcamera_hdf_path}/hdi_impl/include/dcamera_host", "${distributedcamera_hdf_path}/hdi_impl/include/dcamera_provider", @@ -62,7 +59,6 @@ ohos_executable("dcamera_hdi_sample") { ] deps = [ - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client:distributed_camera_hdf_client", "${fwk_utils_path}:distributedhardwareutils", "${fwk_utils_path}:distributedhardwareutils", "${hdf_uhdf_path}/hdi:libhdi", @@ -72,6 +68,7 @@ ohos_executable("dcamera_hdi_sample") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_single", "samgr_standard:samgr_proxy", diff --git a/camera_hdf/hdi_impl/test/common.h b/camera_hdf/hdi_impl/test/common.h index 03ebfda..29333e7 100644 --- a/camera_hdf/hdi_impl/test/common.h +++ b/camera_hdf/hdi_impl/test/common.h @@ -34,7 +34,6 @@ #include "display_type.h" #include "distributed_hardware_log.h" #include "drivers/peripheral/camera/interfaces/include/types.h" -#include "foundation/distributedhardware/distributed_camera/camera_hdf/interfaces/include/types.h" #include "icamera_device.h" #include "icamera_host.h" #include "idistributed_hardware_source.h" @@ -51,9 +50,11 @@ #include "dcamera_host_callback.h" #include "dcamera_host_proxy.h" #include "dstream_operator_callback.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class Test { public: void Init(); diff --git a/camera_hdf/interfaces/hdi_ipc/client/BUILD.gn b/camera_hdf/interfaces/hdi_ipc/client/BUILD.gn deleted file mode 100644 index 6558bdd..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/BUILD.gn +++ /dev/null @@ -1,83 +0,0 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//drivers/adapter/uhdf2/uhdf.gni") -import( - "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") - -ohos_shared_library("distributed_camera_hdf_client") { - include_dirs = [ - "../", - "../../include", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "${camera_hdf_path}/camera/interfaces/include", - "${camera_hdf_path}/camera/interfaces/hdi_ipc", - "${distributedcamera_hdf_path}/hdi_impl/include/utils", - "${hdf_framework_path}/include/utils", - "${hdf_uhdf_path}/include/hdi", - "${hdf_uhdf_path}/osal/include", - "//drivers/peripheral/base", - "//drivers/peripheral/camera/interfaces/metadata/include", - ] - - cflags = [ - "-fPIC", - "-Wall", - ] - - if ("${product_name}" == "m40") { - cflags += [ "-DPRODUCT_M40" ] - } - - sources = [ - "device/dcamera_device_callback.cpp", - "device/dcamera_device_callback_stub.cpp", - "device/dcamera_device_proxy.cpp", - "host/dcamera_host_callback.cpp", - "host/dcamera_host_callback_stub.cpp", - "host/dcamera_host_proxy.cpp", - "operator/doffline_stream_operator_proxy.cpp", - "operator/dstream_operator_callback.cpp", - "operator/dstream_operator_callback_stub.cpp", - "operator/dstream_operator_proxy.cpp", - "provider/dcamera_provider_callback.cpp", - "provider/dcamera_provider_callback_stub.cpp", - "provider/dcamera_provider_proxy.cpp", - ] - - deps = [ - "${distributedcamera_hdf_path}/hdi_impl:distributed_camera_hdf", - "${hdf_uhdf_path}/hdi:libhdi", - "//drivers/peripheral/camera/interfaces/metadata:metadata", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"distributedcamerahdf\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "graphic_chipsetsdk:buffer_handle", - "graphic_chipsetsdk:surface", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - - cflags_cc = cflags - subsystem_name = "distributedhardware" - part_name = "distributed_camera" -} diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.cpp b/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.cpp deleted file mode 100644 index 882f567..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_device_callback_stub.h" - -#include - -#include "cmd_common.h" -#include "dcamera_device_callback.h" -#include "distributed_hardware_log.h" -#include "ipc_data_utils.h" -#include "metadata_utils.h" - -namespace OHOS { -namespace DistributedHardware { -int32_t DCameraDeviceCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - switch (code) { - case CMD_CAMERA_DEVICE_CALLBACK_ON_ERROR: { - if (data.ReadInterfaceToken() != DCameraDeviceCallbackStub::GetDescriptor()) { - DHLOGI("DCameraDeviceCallbackStub::OnError token failed."); - return HDF_FAILURE; - } - - ErrorType type = static_cast(data.ReadUint32()); - int32_t errorMsg = data.ReadInt32(); - DHLOGI("DCameraDeviceCallbackStub::OnError entry."); - OnError(type, errorMsg); - break; - } - case CMD_CAMERA_DEVICE_CALLBACK_ON_RESULT: { - if (data.ReadInterfaceToken() != DCameraDeviceCallbackStub::GetDescriptor()) { - DHLOGI("DCameraDeviceCallbackStub::OnResult token failed."); - return HDF_FAILURE; - } - - uint64_t timestamp = data.ReadUint64(); - std::shared_ptr result = nullptr; - Camera::MetadataUtils::DecodeCameraMetadata(data, result); - DHLOGI("DCameraDeviceCallbackStub::OnResult entry."); - OnResult(timestamp, result); - break; - } - default: { - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } - return 0; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.h b/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.h deleted file mode 100644 index 6ddad5a..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback_stub.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_DEVICE_CALLBACK_CLIENT_STUB_H -#define DISTRIBUTED_CAMERA_DEVICE_CALLBACK_CLIENT_STUB_H - -#include "icamera_device_callback.h" -#include "iremote_stub.h" -#include "message_parcel.h" -#include "parcel.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraDeviceCallbackStub : public IRemoteStub { -public: - virtual ~DCameraDeviceCallbackStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_DEVICE_CALLBACK_CLIENT_STUB_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.cpp deleted file mode 100644 index 5a79cce..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_device_proxy.h" - -#include -#include - -#include "cmd_common.h" -#include "distributed_hardware_log.h" -#include "ipc_data_utils.h" -#include "istream_operator.h" -#include "istream_operator_callback.h" -#include "metadata_utils.h" - -namespace OHOS { -namespace DistributedHardware { -CamRetCode DCameraDeviceProxy::GetStreamOperator( - const OHOS::sptr &callback, - OHOS::sptr &streamOperator) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool nullFlag = (callback != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write stream operator callback flag failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (nullFlag && !data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("Write stream operator object failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_GET_STREAM_OPERATOR, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - bool flag = reply.ReadBool(); - if (flag) { - sptr remoteStreamOperator = reply.ReadRemoteObject(); - streamOperator = OHOS::iface_cast(remoteStreamOperator); - } - return retCode; -} - -CamRetCode DCameraDeviceProxy::UpdateSettings(const std::shared_ptr &settings) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool bRet = Camera::MetadataUtils::EncodeCameraMetadata(settings, data); - if (!bRet) { - DHLOGE("Write update settings metadata failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_UPDATE_SETTINGS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DCameraDeviceProxy::SetResultMode(const ResultCallbackMode &mode) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(mode))) { - DHLOGE("Write result callback mode failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_SET_RESULT_MODE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DCameraDeviceProxy::GetEnabledResults(std::vector &results) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_GET_ENABLED_RESULTS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - if (!reply.ReadInt32Vector(&results)) { - DHLOGE("Read results failed."); - return CamRetCode::INVALID_ARGUMENT; - } - return retCode; -} - -CamRetCode DCameraDeviceProxy::EnableResult(const std::vector &results) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32Vector(results)) { - DHLOGE("Write results failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_ENABLE_RESULT, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DCameraDeviceProxy::DisableResult(const std::vector &results) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32Vector(results)) { - DHLOGE("Write results failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_DISABLE_RESULT, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -void DCameraDeviceProxy::Close() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraDeviceProxy::GetDescriptor())) { - DHLOGE("Write stream operator descriptor failed."); - return; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_DEVICE_REMOTE_CLOSE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - } -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.h b/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.h deleted file mode 100644 index 077c8ae..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_proxy.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_DEVICE_CLIENT_PROXY_H -#define DISTRIBUTED_CAMERA_DEVICE_CLIENT_PROXY_H - -#include "iremote_proxy.h" -#include "icamera_device.h" -#include "istream_operator_callback.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraDeviceProxy : public IRemoteProxy { -public: - explicit DCameraDeviceProxy(const sptr &impl) : IRemoteProxy(impl) {} - virtual ~DCameraDeviceProxy() = default; - - virtual CamRetCode GetStreamOperator(const OHOS::sptr &callback, - OHOS::sptr &streamOperator) override; - virtual CamRetCode UpdateSettings(const std::shared_ptr &settings) override; - virtual CamRetCode SetResultMode(const ResultCallbackMode &mode) override; - virtual CamRetCode GetEnabledResults(std::vector &results) override; - virtual CamRetCode EnableResult(const std::vector &results) override; - virtual CamRetCode DisableResult(const std::vector &results) override; - virtual void Close() override; - -private: - static constexpr int CMD_CAMERA_DEVICE_REMOTE_GET_STREAM_OPERATOR = 0; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_UPDATE_SERTTINGS = 1; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_SET_RESULT_MODE = 2; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_GET_ENABLED_RESULTS = 3; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_ENABLE_RESULT = 4; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_DISABLE_RESULT = 5; - static constexpr int CMD_CAMERA_DEVICE_REMOTE_CLOSE = 6; - - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_DEVICE_CLIENT_PROXY_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.cpp b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.cpp deleted file mode 100644 index c748e2e..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_host_callback.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -void DCameraHostCallback::OnCameraStatus(const std::string &cameraId, CameraStatus status) -{ - DHLOGW("DCameraHostCallback::OnCameraStatus enter."); -} - -void DCameraHostCallback::OnFlashlightStatus(const std::string &cameraId, FlashlightStatus status) -{ - DHLOGW("DCameraHostCallback::OnFlashlightStatus enter."); -} - -void DCameraHostCallback::OnCameraEvent(const std::string &cameraId, CameraEvent event) -{ - DHLOGW("DCameraHostCallback::OnCameraEvent enter."); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.h b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.h deleted file mode 100644 index 913f7c0..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_HOST_CALLBACK_H -#define DISTRIBUTED_CAMERA_HOST_CALLBACK_H - -#include "dcamera_host_callback_stub.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraHostCallback : public DCameraHostCallbackStub { -public: - DCameraHostCallback() = default; - virtual ~DCameraHostCallback() = default; - -public: - virtual void OnCameraStatus(const std::string &cameraId, CameraStatus status) override; - virtual void OnFlashlightStatus(const std::string &cameraId, FlashlightStatus status) override; - virtual void OnCameraEvent(const std::string &cameraId, CameraEvent event) override; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_HOST_CALLBACK_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.cpp b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.cpp deleted file mode 100644 index 58fc24c..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_host_callback_stub.h" - -#include - -#include "cmd_common.h" -#include "dcamera_host_callback.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -int32_t DCameraHostCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - switch (code) { - case CMD_CAMERA_HOST_CALLBACK_ON_STATUS: { - DHLOGI("DCameraHostCallbackStub::OnCameraStatus entry."); - if (data.ReadInterfaceToken() != DCameraHostCallbackStub::GetDescriptor()) { - DHLOGI("DCameraDeviceCallbackStub::OnCameraStatus token failed."); - return HDF_FAILURE; - } - - std::string cameraId = data.ReadString(); - CameraStatus status = static_cast(data.ReadInt32()); - OnCameraStatus(cameraId, status); - break; - } - case CMD_CAMERA_HOST_CALLBACK_ON_FLASHLIGHT_STATUS: { - DHLOGI("DCameraHostCallbackStub::OnFlashlightStatus entry."); - if (data.ReadInterfaceToken() != DCameraHostCallbackStub::GetDescriptor()) { - DHLOGI("DCameraDeviceCallbackStub::OnFlashlightStatus token failed."); - return HDF_FAILURE; - } - - std::string cameraId = data.ReadString(); - FlashlightStatus status = static_cast(data.ReadInt32()); - OnFlashlightStatus(cameraId, status); - break; - } - case CMD_CAMERA_HOST_CALLBACK_ON_CAMERA_EVENT: { - DHLOGI("DCameraHostCallbackStub::OnCameraEvent entry."); - if (data.ReadInterfaceToken() != DCameraHostCallbackStub::GetDescriptor()) { - DHLOGI("DCameraDeviceCallbackStub::OnCameraEvent token failed."); - return HDF_FAILURE; - } - - std::string cameraId = data.ReadString(); - CameraEvent event = static_cast(data.ReadInt32()); - OnCameraEvent(cameraId, event); - break; - } - default: { - return IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } - return 0; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.h b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.h deleted file mode 100644 index b9ff473..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_callback_stub.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_HOST_CALLBACK_CLIENT_STUB_H -#define DISTRIBUTED_CAMERA_HOST_CALLBACK_CLIENT_STUB_H - -#include "icamera_host_callback.h" -#include "iremote_stub.h" -#include "message_parcel.h" -#include "parcel.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraHostCallbackStub : public IRemoteStub { -public: - virtual ~DCameraHostCallbackStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_HOST_CALLBACK_CLIENT_STUB_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.cpp deleted file mode 100644 index 5c8f275..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_host_proxy.h" - -#include -#include -#include - -#include "cmd_common.h" -#include "distributed_hardware_log.h" -#include "icamera_device.h" -#include "icamera_device_callback.h" -#include "icamera_host_callback.h" -#include "ipc_data_utils.h" -#include "metadata_utils.h" - -OHOS::sptr OHOS::Camera::ICameraHost::Get(const char *serviceName) -{ - using namespace OHOS::HDI::ServiceManager::V1_0; - OHOS::sptr serviceMgr = IServiceManager::Get(); - if (serviceMgr == nullptr) { - HDF_LOGE("%{public}s: IServiceManager failed!", __func__); - return nullptr; - } - - OHOS::sptr remote = serviceMgr->GetService(serviceName); - if (remote == nullptr) { - HDF_LOGE("%{public}s: get %{public}s failed!", __func__, serviceName); - return nullptr; - } - - return iface_cast(remote); -} - -namespace OHOS { -namespace DistributedHardware { -CamRetCode DCameraHostProxy::SetCallback(const OHOS::sptr &callback) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraHostProxy::GetDescriptor())) { - DHLOGE("Write remote token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool callbackFlag = (callback != nullptr); - if (!data.WriteBool(callbackFlag)) { - DHLOGE("Set callback flag failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (callbackFlag && !data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("Write remote callback object failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_SET_CALLBACK, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DCameraHostProxy::GetCameraIds(std::vector &cameraIds) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraHostProxy::GetDescriptor())) { - DHLOGE("Write remote token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_GET_CAMERAID, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - if (retCode == CamRetCode::NO_ERROR && !reply.ReadStringVector(&cameraIds)) { - DHLOGE("Read camera ids failed."); - return CamRetCode::INVALID_ARGUMENT; - } - return retCode; -} - -CamRetCode DCameraHostProxy::GetCameraAbility(const std::string &cameraId, - std::shared_ptr &ability) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraHostProxy::GetDescriptor())) { - DHLOGE("Write remote token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(cameraId)) { - DHLOGE("Write cameraId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_GET_CAMERA_ABILITY, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - if (retCode == CamRetCode::NO_ERROR) { - Camera::MetadataUtils::DecodeCameraMetadata(reply, ability); - } - return retCode; -} - -CamRetCode DCameraHostProxy::OpenCamera(const std::string &cameraId, - const OHOS::sptr &callback, OHOS::sptr &pDevice) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraHostProxy::GetDescriptor())) { - DHLOGE("Write remote token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(cameraId)) { - DHLOGE("Write cameraId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool callbackFlag = (callback != nullptr); - if (!data.WriteBool(callbackFlag)) { - DHLOGE("Write camera callback flag failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (callbackFlag && !data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("Write camera device callback failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_OPEN_CAMERA, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - bool flag = reply.ReadBool(); - if (flag) { - sptr remoteCameraDevice = reply.ReadRemoteObject(); - if (remoteCameraDevice == nullptr) { - DHLOGE("Read remote camera device is null."); - } - pDevice = OHOS::iface_cast(remoteCameraDevice); - } - return retCode; -} - -CamRetCode DCameraHostProxy::SetFlashlight(const std::string &cameraId, bool &isEnable) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraHostProxy::GetDescriptor())) { - DHLOGE("Write remote token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(cameraId)) { - DHLOGE("Write cameraId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteBool(isEnable)) { - DHLOGE("Write isEnable failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_CAMERA_HOST_REMOTE_SET_FLASH_LIGHT, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.h b/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.h deleted file mode 100644 index 42ad99b..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/host/dcamera_host_proxy.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_HOST_CLIENT_PROXY_H -#define DISTRIBUTED_CAMERA_HOST_CLIENT_PROXY_H - -#include "iremote_proxy.h" -#include "icamera_host.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DCameraHostProxy : public IRemoteProxy { -public: - explicit DCameraHostProxy(const sptr &impl) : IRemoteProxy(impl) {} - virtual ~DCameraHostProxy() {} - - virtual CamRetCode SetCallback(const OHOS::sptr &callback) override; - virtual CamRetCode GetCameraIds(std::vector &cameraIds) override; - virtual CamRetCode GetCameraAbility(const std::string &cameraId, - std::shared_ptr &ability) override; - virtual CamRetCode OpenCamera(const std::string &cameraId, - const OHOS::sptr &callback, - OHOS::sptr &pDevice) override; - virtual CamRetCode SetFlashlight(const std::string &cameraId, bool &isEnable) override; - -private: - static constexpr int CMD_CAMERA_HOST_REMOTE_SET_CALLBACK = 0; - static constexpr int CMD_CAMERA_HOST_REMOTE_GET_CAMERAID = 1; - static constexpr int CMD_CAMERA_HOST_REMOTE_GET_CAMERA_ABILITY = 2; - static constexpr int CMD_CAMERA_HOST_REMOTE_OPEN_CAMERA = 3; - static constexpr int CMD_CAMERA_HOST_REMOTE_SET_FLASH_LIGHT = 4; - - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_HOST_CLIENT_PROXY_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.cpp deleted file mode 100644 index 0310e86..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "doffline_stream_operator_proxy.h" -#include -#include -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -CamRetCode DOfflineStreamOperatorProxy::CancelCapture(int captureId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DOfflineStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(captureId))) { - DHLOGE("Write captureId object failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_CANCEL_CAPTURE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DOfflineStreamOperatorProxy::ReleaseStreams(const std::vector &streamIds) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DOfflineStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = streamIds; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamIds object failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_RELEASE_STREAMS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DOfflineStreamOperatorProxy::Release() -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DOfflineStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_OFFLINE_STREAM_OPERATOR_RELEASE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.h b/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.h deleted file mode 100644 index 3dde7a6..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/doffline_stream_operator_proxy.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_OFFLINE_STREAM_OPERATOR_CLIENT_PROXY_H -#define DISTRIBUTED_OFFLINE_STREAM_OPERATOR_CLIENT_PROXY_H - -#include "iremote_proxy.h" -#include "ioffline_stream_operator.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DOfflineStreamOperatorProxy : public IRemoteProxy { -public: - explicit DOfflineStreamOperatorProxy(const sptr& impl) - : IRemoteProxy(impl) {} - virtual ~DOfflineStreamOperatorProxy() {} - - virtual CamRetCode CancelCapture(int captureId) override; - virtual CamRetCode ReleaseStreams(const std::vector& streamIds) override; - virtual CamRetCode Release() override; - -private: - static constexpr int CMD_OFFLINE_STREAM_OPERATOR_CANCEL_CAPTURE = 0; - static constexpr int CMD_OFFLINE_STREAM_OPERATOR_RELEASE_STREAMS = 1; - static constexpr int CMD_OFFLINE_STREAM_OPERATOR_RELEASE = 2; - - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_OFFLINE_STREAM_OPERATOR_CLIENT_PROXY_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.cpp b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.cpp deleted file mode 100644 index cf1c3c9..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dstream_operator_callback.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -void DStreamOperatorCallback::OnCaptureStarted(int32_t captureId, const std::vector &streamId) -{ - DHLOGW("DStreamOperatorCallback::OnCaptureStarted enter."); -} - -void DStreamOperatorCallback::OnCaptureEnded(int32_t captureId, - const std::vector> &info) -{ - DHLOGW("DStreamOperatorCallback::OnCaptureEnded enter."); -} - -void DStreamOperatorCallback::OnCaptureError(int32_t captureId, - const std::vector> &info) -{ - DHLOGW("DStreamOperatorCallback::OnCaptureError enter."); -} - -void DStreamOperatorCallback::OnFrameShutter(int32_t captureId, const std::vector &streamId, - uint64_t timestamp) -{ - DHLOGW("DStreamOperatorCallback::OnFrameShutter enter."); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.h b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.h deleted file mode 100644 index 0780fd9..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_STREAM_OPERATOR_CALLBACK_H -#define DISTRIBUTED_STREAM_OPERATOR_CALLBACK_H - -#include "dstream_operator_callback_stub.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DStreamOperatorCallback : public DStreamOperatorCallbackStub { -public: - DStreamOperatorCallback() = default; - virtual ~DStreamOperatorCallback() = default; - -public: - virtual void OnCaptureStarted(int32_t captureId, const std::vector &streamId) override; - virtual void OnCaptureEnded(int32_t captureId, - const std::vector> &info) override; - virtual void OnCaptureError(int32_t captureId, - const std::vector> &info) override; - virtual void OnFrameShutter(int32_t captureId, - const std::vector &streamId, uint64_t timestamp) override; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_STREAM_OPERATOR_CALLBACK_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.cpp b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.cpp deleted file mode 100644 index ea65105..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dstream_operator_callback_stub.h" - -#include -#include - -#include "cmd_common.h" -#include "distributed_hardware_log.h" -#include "dstream_operator_callback.h" - -namespace OHOS { -namespace DistributedHardware { -int32_t DStreamOperatorCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - int32_t ret = HDF_SUCCESS; - switch (code) { - case CMD_STREAM_OPERATOR_CALLBACK_ON_CAPTURE_STARTED: { - ret = OnCaptureStartedStub(data, reply, option); - break; - } - case CMD_STREAM_OPERATOR_CALLBACK_ON_CAPTURE_ENDED: { - ret = OnCaptureEndedStub(data, reply, option); - break; - } - case CMD_STREAM_OPERATOR_CALLBACK_ON_CAPTURE_ERROR: { - ret = OnCaptureErrorStub(data, reply, option); - break; - } - case CMD_STREAM_OPERATOR_CALLBACK_ON_FRAME_SHUTTER: { - ret = OnFrameShutterStub(data, reply, option); - break; - } - default: { - ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } - return ret; -} - -int32_t DStreamOperatorCallbackStub::OnCaptureStartedStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - DHLOGI("DStreamOperatorCallbackStub::OnCaptureStartedStub entry."); - if (data.ReadInterfaceToken() != DStreamOperatorCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - int32_t captureId = data.ReadInt32(); - std::vector streamIds; - if (!data.ReadInt32Vector(&streamIds)) { - DHLOGE("OnCaptureStarted read streamIds failed."); - return HDF_FAILURE; - } - OnCaptureStarted(captureId, streamIds); - return HDF_SUCCESS; -} - -int32_t DStreamOperatorCallbackStub::OnCaptureEndedStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - DHLOGI("DStreamOperatorCallbackStub::OnCaptureEndedStub entry."); - if (data.ReadInterfaceToken() != DStreamOperatorCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - int32_t captureId = data.ReadInt32(); - int32_t count = data.ReadInt32(); - std::vector> info; - for (int32_t i = 0; i < count; i++) { - const CaptureEndedInfo *pInfo = reinterpret_cast( - data.ReadBuffer(sizeof(CaptureEndedInfo))); - if (pInfo == nullptr) { - DHLOGE("Read ended info failed."); - return HDF_FAILURE; - } - std::shared_ptr captureEndedInfo = std::make_shared(); - captureEndedInfo->streamId_ = pInfo->streamId_; - captureEndedInfo->frameCount_ = pInfo->frameCount_; - info.push_back(captureEndedInfo); - } - OnCaptureEnded(captureId, info); - return HDF_SUCCESS; -} - -int32_t DStreamOperatorCallbackStub::OnCaptureErrorStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - DHLOGI("DStreamOperatorCallbackStub::OnCaptureErrorStub entry."); - if (data.ReadInterfaceToken() != DStreamOperatorCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - int32_t captureId = data.ReadInt32(); - int32_t count = data.ReadInt32(); - std::vector> info; - for (int32_t i = 0; i < count; i++) { - const CaptureErrorInfo *pInfo = reinterpret_cast( - data.ReadBuffer(sizeof(CaptureErrorInfo))); - if (pInfo == nullptr) { - DHLOGE("Read error info failed."); - return HDF_FAILURE; - } - std::shared_ptr captureErrorInfo = std::make_shared(); - captureErrorInfo->streamId_ = pInfo->streamId_; - captureErrorInfo->error_ = pInfo->error_; - info.push_back(captureErrorInfo); - } - - OnCaptureError(captureId, info); - return HDF_SUCCESS; -} - -int32_t DStreamOperatorCallbackStub::OnFrameShutterStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - DHLOGI("DStreamOperatorCallbackStub::OnFrameShutterStub entry."); - if (data.ReadInterfaceToken() != DStreamOperatorCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - int32_t captureId = data.ReadInt32(); - std::vector streamIds; - if (!data.ReadInt32Vector(&streamIds)) { - DHLOGE("Read streamIds failed."); - return HDF_FAILURE; - } - uint64_t timestamp = data.ReadUint64(); - OnFrameShutter(captureId, streamIds, timestamp); - return HDF_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.h b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.h deleted file mode 100644 index de70093..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_callback_stub.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_STREAM_OPERATOR_CALLBACK_CLIENT_STUB_H -#define DISTRIBUTED_STREAM_OPERATOR_CALLBACK_CLIENT_STUB_H - -#include "iremote_stub.h" -#include "istream_operator_callback.h" -#include "message_parcel.h" -#include "parcel.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DStreamOperatorCallbackStub : public IRemoteStub { -public: - virtual ~DStreamOperatorCallbackStub() = default; - -private: - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; - int32_t OnCaptureStartedStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t OnCaptureEndedStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t OnCaptureErrorStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t OnFrameShutterStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_STREAM_OPERATOR_CALLBACK_CLIENT_STUB_H diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.cpp deleted file mode 100644 index 5fcad6d..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.cpp +++ /dev/null @@ -1,387 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dstream_operator_proxy.h" - -#include -#include -#include - -#include "cmd_common.h" -#include "distributed_hardware_log.h" -#include "ioffline_stream_operator.h" -#include "ipc_data_utils.h" -#include "istream_operator_callback.h" -#include "metadata_utils.h" - -namespace OHOS { -namespace DistributedHardware { -CamRetCode DStreamOperatorProxy::IsStreamsSupported(OperationMode mode, - const std::shared_ptr &modeSetting, - const std::vector> &info, - StreamSupportType &type) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(mode)) { - DHLOGE("Write operation mode failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool nullFlag = (modeSetting != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write mode null flag failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (nullFlag && !Camera::MetadataUtils::EncodeCameraMetadata(modeSetting, data)) { - DHLOGE("Write metadata failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - nullFlag = info.size(); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write streaminfo null flag failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - size_t count = info.size(); - if (!data.WriteInt32(static_cast(count))) { - HDF_LOGE("%s: write info count failed", __func__); - return CamRetCode::INVALID_ARGUMENT; - } - - for (size_t i = 0; i < count; i++) { - std::shared_ptr streamInfo = info.at(i); - bool ret = IpcDataUtils::EncodeStreamInfo(streamInfo, data); - if (!ret) { - HDF_LOGE("%s: write streamInfo failed. index = %zu", __func__, i); - return CamRetCode::INVALID_ARGUMENT; - } - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_IS_STREAMS_SUPPORTED, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - type = static_cast(reply.ReadInt32()); - return retCode; -} - -CamRetCode DStreamOperatorProxy::CreateStreams(const std::vector> &streamInfos) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - size_t count = streamInfos.size(); - if (!data.WriteInt32(static_cast(count))) { - DHLOGE("Write streamInfos count failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - for (size_t i = 0; i < count; i++) { - std::shared_ptr streamInfo = streamInfos.at(i); - bool bRet = IpcDataUtils::EncodeStreamInfo(streamInfo, data); - if (!bRet) { - DHLOGE("Write streamInfo failed. index = %zu", i); - return CamRetCode::INVALID_ARGUMENT; - } - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_CREATE_STREAMS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::ReleaseStreams(const std::vector &streamIds) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = streamIds; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamIds failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_RELEASE_STREAMS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::CommitStreams(OperationMode mode, - const std::shared_ptr &modeSetting) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(mode)) { - DHLOGE("Write operation mode failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool bRet = Camera::MetadataUtils::EncodeCameraMetadata(modeSetting, data); - if (!bRet) { - DHLOGE("Write metadata failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_COMMIT_STREAMS, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::GetStreamAttributes(std::vector> &attributes) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_GET_STREAM_ATTRIBUTES, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t retCode = reply.ReadInt32(); - int32_t count = reply.ReadInt32(); - for (int i = 0; i < count; i++) { - const uint8_t *buffer = data.ReadBuffer(sizeof(StreamAttribute)); - std::shared_ptr attribute = std::shared_ptr( - reinterpret_cast( - const_cast(buffer))); - attributes.push_back(attribute); - } - return static_cast(retCode); -} - -CamRetCode DStreamOperatorProxy::AttachBufferQueue(int streamId, const OHOS::sptr &producer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (producer == nullptr) { - DHLOGE("Input producer is NULL."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(streamId))) { - DHLOGE("Write streamId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteRemoteObject(producer->AsObject())) { - DHLOGE("Write buffer producer failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_ATTACH_BUFFER_QUEUE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::DetachBufferQueue(int streamId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(streamId))) { - DHLOGE("Write streamId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_DETACH_BUFFER_QUEUE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::Capture(int captureId, - const std::shared_ptr &info, bool isStreaming) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (info == nullptr) { - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(captureId))) { - DHLOGE("Write captureId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = info->streamIds_; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamIds failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - bool bRet = Camera::MetadataUtils::EncodeCameraMetadata(info->captureSetting_, data); - if (!bRet) { - DHLOGE("Write metadata failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteBool(info->enableShutterCallback_)) { - DHLOGE("Write enableShutterCallback_ failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteBool(isStreaming)) { - DHLOGE("Write isStreaming failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_CAPTURE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::CancelCapture(int captureId) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(captureId))) { - DHLOGE("Write captureId failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest( - CMD_STREAM_OPERATOR_CANCEL_CAPTURE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -CamRetCode DStreamOperatorProxy::ChangeToOfflineStream( - const std::vector &streamIds, - OHOS::sptr &callback, - OHOS::sptr &offlineOperator) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DStreamOperatorProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (callback == nullptr) { - return CamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = streamIds; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamIds failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("Write offline stream operator callback failed."); - return CamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_STREAM_OPERATOR_CHANGE_TO_OFFLINE_STREAM, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code = %d.", ret); - return CamRetCode::INVALID_ARGUMENT; - } - - CamRetCode retCode = static_cast(reply.ReadInt32()); - sptr remoteObj = reply.ReadRemoteObject(); - offlineOperator = OHOS::iface_cast(remoteObj); - return retCode; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.h b/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.h deleted file mode 100644 index 8c46737..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/operator/dstream_operator_proxy.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_STREAM_OPERATOR_CLIENT_PROXY_H -#define DISTRIBUTED_STREAM_OPERATOR_CLIENT_PROXY_H - -#include "iremote_proxy.h" -#include "istream_operator.h" - -namespace OHOS { -namespace DistributedHardware { -using namespace OHOS::Camera; -class DStreamOperatorProxy : public IRemoteProxy { -public: - explicit DStreamOperatorProxy(const sptr &impl) : IRemoteProxy(impl) {} - virtual ~DStreamOperatorProxy() = default; - - virtual CamRetCode IsStreamsSupported(OperationMode mode, - const std::shared_ptr &modeSetting, - const std::vector> &info, - StreamSupportType &type) override; - virtual CamRetCode CreateStreams(const std::vector> &streamInfos) override; - virtual CamRetCode ReleaseStreams(const std::vector &streamIds) override; - virtual CamRetCode CommitStreams(OperationMode mode, - const std::shared_ptr &modeSetting) override; - virtual CamRetCode GetStreamAttributes(std::vector> &attributes) override; - virtual CamRetCode AttachBufferQueue(int streamId, - const OHOS::sptr &producer) override; - virtual CamRetCode DetachBufferQueue(int streamId) override; - virtual CamRetCode Capture(int captureId, - const std::shared_ptr &info, bool isStreaming) override; - virtual CamRetCode CancelCapture(int captureId) override; - virtual CamRetCode ChangeToOfflineStream(const std::vector &streamIds, - OHOS::sptr &callback, - OHOS::sptr &offlineOperator) override; - -private: - static constexpr int CMD_STREAM_OPERATOR_IS_STREAMS_SUPPORTED = 0; - static constexpr int CMD_STREAM_OPERATOR_CREATE_STREAMS = 1; - static constexpr int CMD_STREAM_OPERATOR_RELEASE_STREAMS = 2; - static constexpr int CMD_STREAM_OPERATOR_COMMIT_STREAMS = 3; - static constexpr int CMD_STREAM_OPERATOR_GET_STREAM_ATTRIBUTES = 4; - static constexpr int CMD_STREAM_OPERATOR_ATTACH_BUFFER_QUEUE = 5; - static constexpr int CMD_STREAM_OPERATOR_DETACH_BUFFER_QUEUE = 6; - static constexpr int CMD_STREAM_OPERATOR_CAPTURE = 7; - static constexpr int CMD_STREAM_OPERATOR_CANCEL_CAPTURE = 8; - static constexpr int CMD_STREAM_OPERATOR_CHANGE_TO_OFFLINE_STREAM = 9; - - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_STREAM_OPERATOR_CLIENT_PROXY_H diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.cpp b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.cpp deleted file mode 100644 index b822feb..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_callback.h" -#include "distributed_hardware_log.h" - -namespace OHOS { -namespace DistributedHardware { -DCamRetCode DCameraProviderCallback::OpenSession(const std::shared_ptr &dhBase) -{ - DHLOGW("DCameraProviderCallback::OpenSession enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::CloseSession(const std::shared_ptr &dhBase) -{ - DHLOGW("DCameraProviderCallback::CloseSession enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos) -{ - DHLOGW("DCameraProviderCallback::ConfigureStreams enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::ReleaseStreams(const std::shared_ptr &dhBase, - const std::vector &streamIds) -{ - DHLOGW("DCameraProviderCallback::ReleaseStreams enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos) -{ - DHLOGW("DCameraProviderCallback::StartCapture enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::StopCapture(const std::shared_ptr &dhBase, - const std::vector &streamIds) -{ - DHLOGW("DCameraProviderCallback::StopCapture enter."); - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderCallback::UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings) -{ - DHLOGW("DCameraProviderCallback::UpdateSettings enter."); - return DCamRetCode::SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.h b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.h deleted file mode 100644 index d560267..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H -#define DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H - -#include "dcamera_provider_callback_stub.h" - -namespace OHOS { -namespace DistributedHardware { -class DCameraProviderCallback : public DCameraProviderCallbackStub { -public: - DCameraProviderCallback() = default; - virtual ~DCameraProviderCallback() = default; - -public: - virtual DCamRetCode OpenSession(const std::shared_ptr &dhBase) override; - virtual DCamRetCode CloseSession(const std::shared_ptr &dhBase) override; - virtual DCamRetCode ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos) override; - virtual DCamRetCode ReleaseStreams(const std::shared_ptr &dhBase, - const std::vector &streamIds) override; - virtual DCamRetCode StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos) override; - virtual DCamRetCode StopCapture(const std::shared_ptr &dhBase, - const std::vector &streamIds) override; - virtual DCamRetCode UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings) override; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.cpp b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.cpp deleted file mode 100644 index da4f979..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.cpp +++ /dev/null @@ -1,261 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_callback_stub.h" -#include -#include "dcamera_provider_callback.h" -#include "distributed_hardware_log.h" -#include "ipc_data_utils.h" - -namespace OHOS { -namespace DistributedHardware { -int32_t DCameraProviderCallbackStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - int32_t ret = HDF_SUCCESS; - switch (code) { - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_OPEN_SESSION: { - ret = DCProviderOpenSessionStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLOSE_SESSION: { - ret = DCProviderCloseSessionStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CONFIGURE_STREAMS: { - ret = DCProviderConfigureStreamsStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_RELEASE_STREAMS: { - ret = DCProviderReleaseStreamsStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_START_CAPTURE: { - ret = DCProviderStartCaptureStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_STOP_CAPTURE: { - ret = DCProviderStopCaptureStub(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_UPDATE_SETTINGS: { - ret = DCProviderUpdateSettingsStub(data, reply, option); - break; - } - default: { - ret = IPCObjectStub::OnRemoteRequest(code, data, reply, option); - } - } - return ret; -} - -int32_t DCameraProviderCallbackStub::DCProviderOpenSessionStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - DCamRetCode ret = OpenSession(dhBase); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderCloseSessionStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - DCamRetCode ret = CloseSession(dhBase); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderConfigureStreamsStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - int32_t count = data.ReadInt32(); - std::vector> streamInfos; - for (int32_t i = 0; i < count; i++) { - const DCStreamInfo *pInfo = reinterpret_cast( - data.ReadBuffer(sizeof(DCStreamInfo))); - if (pInfo == nullptr) { - DHLOGE("Read distributed camera stream info failed."); - return HDF_FAILURE; - } - std::shared_ptr streamInfo = std::make_shared(); - streamInfo->streamId_ = pInfo->streamId_; - streamInfo->width_ = pInfo->width_; - streamInfo->height_ = pInfo->height_; - streamInfo->stride_ = pInfo->stride_; - streamInfo->format_ = pInfo->format_; - streamInfo->dataspace_ = pInfo->dataspace_; - streamInfo->encodeType_ = pInfo->encodeType_; - streamInfo->type_ = pInfo->type_; - streamInfos.push_back(streamInfo); - } - - DCamRetCode ret = ConfigureStreams(dhBase, streamInfos); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderReleaseStreamsStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - std::vector streamIds; - if (!data.ReadInt32Vector(&streamIds)) { - DHLOGE("Read streamIds failed."); - return HDF_FAILURE; - } - - DCamRetCode ret = ReleaseStreams(dhBase, streamIds); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderStartCaptureStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - int32_t count = data.ReadInt32(); - std::vector> captureInfos; - for (int32_t i = 0; i < count; i++) { - std::shared_ptr captureInfo = std::make_shared(); - std::vector streamIds; - if (!data.ReadInt32Vector(&streamIds)) { - DHLOGE("Read streamIds failed."); - return HDF_FAILURE; - } - captureInfo->streamIds_ = streamIds; - captureInfo->width_ = static_cast(data.ReadInt32()); - captureInfo->height_ = static_cast(data.ReadInt32()); - captureInfo->stride_ = static_cast(data.ReadInt32()); - captureInfo->format_ = static_cast(data.ReadInt32()); - captureInfo->dataspace_ = static_cast(data.ReadInt32()); - captureInfo->isCapture_ = data.ReadBool(); - captureInfo->encodeType_ = static_cast(data.ReadInt32()); - captureInfo->type_ = static_cast(data.ReadInt32()); - - int32_t settingsSize = data.ReadInt32(); - std::vector> capSettings; - for (int32_t k = 0; k < settingsSize; k++) { - std::shared_ptr metadata = std::make_shared(); - IpcDataUtils::DecodeDCameraSettings(data, metadata); - capSettings.push_back(metadata); - } - captureInfo->captureSettings_ = capSettings; - captureInfos.push_back(captureInfo); - } - - DCamRetCode ret = StartCapture(dhBase, captureInfos); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderStopCaptureStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - std::vector streamIds; - if (!data.ReadInt32Vector(&streamIds)) { - DHLOGE("Read streamIds failed."); - return HDF_FAILURE; - } - - DCamRetCode ret = StopCapture(dhBase, streamIds); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderCallbackStub::DCProviderUpdateSettingsStub(MessageParcel &data, MessageParcel &reply, - MessageOption &option) -{ - if (data.ReadInterfaceToken() != DCameraProviderCallbackStub::GetDescriptor()) { - DHLOGE("OnCaptureStarted invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - int32_t count = data.ReadInt32(); - std::vector> settings; - for (int32_t i = 0; i < count; i++) { - std::shared_ptr metadata = std::make_shared(); - IpcDataUtils::DecodeDCameraSettings(data, metadata); - settings.push_back(metadata); - } - - DCamRetCode ret = UpdateSettings(dhBase, settings); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.h b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.h deleted file mode 100644 index 769555d..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_callback_stub.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLIENT_STUB_H -#define DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLIENT_STUB_H - -#include "idistributed_camera_provider_callback.h" -#include "iremote_stub.h" -#include "message_parcel.h" -#include "parcel.h" - -namespace OHOS { -namespace DistributedHardware { -class DCameraProviderCallbackStub : public IRemoteStub { -public: - virtual ~DCameraProviderCallbackStub() = default; - - int32_t OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, - MessageOption &option) override; - -private: - int32_t DCProviderOpenSessionStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderCloseSessionStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderConfigureStreamsStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderReleaseStreamsStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderStartCaptureStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderStopCaptureStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); - int32_t DCProviderUpdateSettingsStub(MessageParcel &data, MessageParcel &reply, MessageOption &option); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLIENT_STUB_H diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp deleted file mode 100644 index 150c5bb..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_proxy.h" -#include -#include -#include -#include -#include -#include "distributed_hardware_log.h" -#include "ipc_data_utils.h" -#include "iservmgr_hdi.h" - -namespace OHOS { -namespace DistributedHardware { -const std::string DC_PROVIDER_HDI_SERVER_NAME = "distributed_camera_provider_service"; - -sptr IDCameraProvider::Get() -{ - using namespace OHOS::HDI::ServiceManager::V1_0; - OHOS::sptr serviceMgr = IServiceManager::Get(); - if (serviceMgr == nullptr) { - DHLOGE("Get IServiceManager failed."); - return nullptr; - } - - OHOS::sptr remote = serviceMgr->GetService(DC_PROVIDER_HDI_SERVER_NAME.c_str()); - if (remote == nullptr) { - DHLOGE("GetService failed! serviceName = %s", DC_PROVIDER_HDI_SERVER_NAME.c_str()); - return nullptr; - } - - return iface_cast(remote); -} - -DCamRetCode DCameraProviderProxy::EnableDCameraDevice(const std::shared_ptr &dhBase, - const std::string &abilityInfo, const sptr &callback) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_) || !data.WriteString(abilityInfo)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - bool nullFlag = (callback != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write distributed camera provider callback null flag failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - if (nullFlag && !data.WriteRemoteObject(callback->AsObject())) { - DHLOGE("Set callback write remote obj failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_ENABLE_DEVICE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d", ret); - return DCamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderProxy::DisableDCameraDevice(const std::shared_ptr &dhBase) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_DISABLE_DEVICE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return DCamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderProxy::AcquireBuffer(const std::shared_ptr &dhBase, int streamId, - std::shared_ptr &buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteInt32(static_cast(streamId))) { - DHLOGE("Write streamId failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_ACQUIRE_BUFFER, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return DCamRetCode::INVALID_ARGUMENT; - } - int32_t retCode = reply.ReadInt32(); - if (retCode != DCamRetCode::SUCCESS) { - DHLOGE("Acquire available buffer from stub failed."); - return static_cast(retCode); - } - - buffer = std::make_shared(); - buffer->index_ = reply.ReadInt32(); - buffer->size_ = reply.ReadInt32(); - - BufferHandle* retHandle = ReadBufferHandle(reply); - if (retHandle == nullptr) { - DHLOGE("Read return buffer handle failed."); - FreeBufferHandle(buffer->bufferHandle_); - return DCamRetCode::INVALID_ARGUMENT; - } - retHandle->virAddr = DCameraMemoryMap(retHandle); - buffer->bufferHandle_ = retHandle; - - return DCamRetCode::SUCCESS; -} - -DCamRetCode DCameraProviderProxy::ShutterBuffer(const std::shared_ptr &dhBase, int streamId, - const std::shared_ptr &buffer) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - DCamRetCode ret = DCamRetCode::SUCCESS; - do { - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - ret = DCamRetCode::INVALID_ARGUMENT; - break; - } - - if (!data.WriteInt32(static_cast(streamId))) { - DHLOGE("Write streamId failed."); - ret = DCamRetCode::INVALID_ARGUMENT; - break; - } - - bool nullFlag = (buffer != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write distributed camera buffer null flag failed."); - ret = DCamRetCode::INVALID_ARGUMENT; - break; - } - - if (!data.WriteInt32(buffer->index_) || !data.WriteInt32(buffer->size_)) { - DHLOGE("write buffer index and size parameter failed."); - ret = DCamRetCode::INVALID_ARGUMENT; - break; - } - - int32_t retCode = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_SHUTTER_BUFFER, data, reply, option); - if (retCode != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", retCode); - ret = DCamRetCode::FAILED; - } - } while (0); - - DCameraMemoryUnmap(buffer->bufferHandle_); - if (ret != DCamRetCode::SUCCESS) { - return ret; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderProxy::OnSettingsResult(const std::shared_ptr &dhBase, - const std::shared_ptr &result) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - bool nullFlag = (result != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write distributed camera settings null flag failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - if (nullFlag && !IpcDataUtils::EncodeDCameraSettings(result, data)) { - DHLOGE("Write distributed camera settings failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_ON_SETTINGS_RESULT, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return DCamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderProxy::Notify(const std::shared_ptr &dhBase, - const std::shared_ptr &event) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - bool nullFlag = (event != nullptr); - if (!data.WriteBool(nullFlag)) { - DHLOGE("Write distributed camera hdf event null flag failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - if (nullFlag && !IpcDataUtils::EncodeDCameraHDFEvent(event, data)) { - DHLOGE("Write distributed camera hdf event failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_NOTIFY, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return DCamRetCode::INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -#ifdef PRODUCT_M40 -void* DCameraProviderProxy::DCameraMemoryMap(const BufferHandle *buffer) -{ - if (buffer == nullptr) { - DHLOGE("mmap the buffer handle is NULL"); - return nullptr; - } - if (buffer->reserveFds <= 0) { - DHLOGE("invalid file descriptor num : %d", buffer->reserveFds); - return nullptr; - } - void* virAddr = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, buffer->reserve[0], 0); - if (virAddr == MAP_FAILED) { - DHLOGE("mmap failed errno %s, fd : %d", strerror(errno), buffer->fd); - return nullptr; - } - return virAddr; -} -#else -void* DCameraProviderProxy::DCameraMemoryMap(const BufferHandle *buffer) -{ - if (buffer == nullptr) { - DHLOGE("mmap the buffer handle is NULL"); - return nullptr; - } - - void* virAddr = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0); - if (virAddr == MAP_FAILED) { - DHLOGE("mmap failed errno %s, fd : %d", strerror(errno), buffer->fd); - return nullptr; - } - return virAddr; -} -#endif - -void DCameraProviderProxy::DCameraMemoryUnmap(BufferHandle *buffer) -{ - if (buffer == nullptr) { - DHLOGE("unmmap the buffer handle is NULL"); - return; - } - if (buffer->virAddr == nullptr) { - DHLOGE("virAddr is NULL , has not map the buffer"); - return; - } - int ret = munmap(buffer->virAddr, buffer->size); - if (ret != 0) { - DHLOGE("munmap failed err: %s", strerror(errno)); - } - buffer->virAddr = nullptr; - FreeBufferHandle(buffer); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.h b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.h deleted file mode 100644 index 393e7e9..0000000 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_CLIENT_PROXY_H -#define DISTRIBUTED_CAMERA_PROVIDER_CLIENT_PROXY_H - -#include "iremote_proxy.h" -#include "buffer_handle.h" -#include "idistributed_camera_provider.h" - -namespace OHOS { -namespace DistributedHardware { -class DCameraProviderProxy : public IRemoteProxy { -public: - explicit DCameraProviderProxy(const sptr &impl) : IRemoteProxy(impl) {} - virtual ~DCameraProviderProxy() = default; - - virtual DCamRetCode EnableDCameraDevice(const std::shared_ptr &dhBase, - const std::string &abilityInfo, - const sptr &callback) override; - virtual DCamRetCode DisableDCameraDevice(const std::shared_ptr &dhBase) override; - virtual DCamRetCode AcquireBuffer(const std::shared_ptr &dhBase, int streamId, - std::shared_ptr &buffer) override; - virtual DCamRetCode ShutterBuffer(const std::shared_ptr &dhBase, int streamId, - const std::shared_ptr &buffer) override; - virtual DCamRetCode OnSettingsResult(const std::shared_ptr &dhBase, - const std::shared_ptr &result) override; - virtual DCamRetCode Notify(const std::shared_ptr &dhBase, - const std::shared_ptr &event) override; - -private: - static void* DCameraMemoryMap(const BufferHandle *buffer); - static void DCameraMemoryUnmap(BufferHandle *buffer); - -private: - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_ENABLE_DEVICE = 0; - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_DISABLE_DEVICE = 1; - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_ACQUIRE_BUFFER = 2; - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_SHUTTER_BUFFER = 3; - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_ON_SETTINGS_RESULT = 4; - static constexpr int CMD_DISTRIBUTED_CAMERA_PROVIDER_NOTIFY = 5; - - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_PROVIDER_CLIENT_PROXY_H \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn b/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn index 49703c2..a07590a 100644 --- a/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn +++ b/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn @@ -18,7 +18,6 @@ import( ohos_shared_library("distributed_camera_host_config") { include_dirs = [ - "${distributedcamera_hdf_path}/interfaces/include", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/host", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/device", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/operator", @@ -39,6 +38,7 @@ ohos_shared_library("distributed_camera_host_config") { "${hdf_uhdf_path}/ipc/include", "${hdf_uhdf_path}/include/host", "//drivers/peripheral/camera/interfaces/metadata/include", + "//third_party/jsoncpp/include", ] sources = [ "dcamera_host_config.cpp" ] @@ -48,6 +48,8 @@ ohos_shared_library("distributed_camera_host_config") { "//utils/native/base:utils", ] + public_deps = [ "//drivers/interface/distributed_camera/v1_0:libdistributed_camera_provider_stub_1.0" ] + defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"distributedcamerahdf\"", diff --git a/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn b/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn deleted file mode 100644 index fa2528d..0000000 --- a/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("//drivers/adapter/uhdf2/uhdf.gni") -import( - "//foundation/distributedhardware/distributed_camera/distributedcamera.gni") - -ohos_shared_library("distributed_camera_provider_config") { - include_dirs = [ - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/server/provider", - "${distributedcamera_hdf_path}/interfaces/include", - "${distributedcamera_hdf_path}/hdi_impl/include/dcamera_provider", - "${distributedcamera_hdf_path}/hdi_impl/include/utils", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "${camera_hdf_path}/camera/interfaces/include", - "${camera_hdf_path}/camera/interfaces/hdi_ipc", - "${hdf_framework_path}/include/utils", - "${hdf_framework_path}/include/core", - "${hdf_framework_path}/include/osal", - "${hdf_uhdf_path}/include/hdi", - "${hdf_uhdf_path}/osal/include", - "${hdf_uhdf_path}/ipc/include", - "${hdf_uhdf_path}/include/host", - "//drivers/peripheral/camera/interfaces/metadata/include", - ] - - sources = [ "dcamera_provider_config.cpp" ] - - deps = [ - "${distributedcamera_hdf_path}/hdi_impl:distributed_camera_hdf", - "//utils/native/base:utils", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"distributedcamerahdf\"", - "LOG_DOMAIN=0xD004100", - ] - - external_deps = [ - "device_driver_framework:libhdf_host", - "graphic_chipsetsdk:buffer_handle", - "graphic_chipsetsdk:surface", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - install_images = [ chipset_base_dir ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_camera" -} diff --git a/camera_hdf/interfaces/hdi_ipc/config/provider/dcamera_provider_config.cpp b/camera_hdf/interfaces/hdi_ipc/config/provider/dcamera_provider_config.cpp deleted file mode 100644 index 8e49f3f..0000000 --- a/camera_hdf/interfaces/hdi_ipc/config/provider/dcamera_provider_config.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_stub.h" -#include -#include -#include -#include - -struct HdfDCameraProviderService { - struct IDeviceIoService ioservice; - void *instance; -}; - -static int32_t DCameraProviderServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, - struct HdfSBuf *data, struct HdfSBuf *reply) -{ - HdfDCameraProviderService *service = CONTAINER_OF(client->device->service, HdfDCameraProviderService, ioservice); - return DCProviderServiceOnRemoteRequest(service->instance, cmdId, data, reply); -} - -int HdfDCameraProviderConfigInit(struct HdfDeviceObject *deviceObject) -{ - if (deviceObject == nullptr) { - HDF_LOGE("HdfDCameraProviderConfigInit: HdfDeviceObject is NULL !"); - return HDF_FAILURE; - } - - if (!HdfDeviceSetClass(deviceObject, DEVICE_CLASS_CAMERA)) { - HDF_LOGE("HdfDCameraProviderConfigInit set camera class failed"); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int HdfDCameraProviderConfigBind(HdfDeviceObject *deviceObject) -{ - HDF_LOGI("HdfDCameraProviderConfigBind enter!"); - if (deviceObject == nullptr) { - HDF_LOGE("HdfDCameraProviderConfigBind: HdfDeviceObject is NULL !"); - return HDF_FAILURE; - } - - HdfDCameraProviderService *service = - reinterpret_cast(malloc(sizeof(HdfDCameraProviderService))); - if (service == nullptr) { - HDF_LOGE("HdfDCameraProviderConfigBind malloc HdfDCameraProviderService failed!"); - return HDF_FAILURE; - } - - service->ioservice.Dispatch = DCameraProviderServiceDispatch; - service->ioservice.Open = nullptr; - service->ioservice.Release = nullptr; - service->instance = DCameraProviderStubInstance(); - - deviceObject->service = &service->ioservice; - return HDF_SUCCESS; -} - -void HdfDCameraProviderConfigRelease(HdfDeviceObject *deviceObject) -{ - if (deviceObject == nullptr || deviceObject->service == nullptr) { - HDF_LOGE("HdfDCameraProviderConfigRelease: deviceObject or deviceObject->service is NULL!"); - return; - } - HdfDCameraProviderService *service = CONTAINER_OF(deviceObject->service, HdfDCameraProviderService, ioservice); - if (service == nullptr) { - HDF_LOGE("HdfDCameraProviderConfigRelease: service is NULL!"); - return; - } - free(service); -} - -struct HdfDriverEntry g_dCameraProviderConfigEntry = { - .moduleVersion = 1, - .moduleName = "distributed_camera_provider_service", - .Bind = HdfDCameraProviderConfigBind, - .Init = HdfDCameraProviderConfigInit, - .Release = HdfDCameraProviderConfigRelease, -}; - -#ifndef __cplusplus -extern "C" { -#endif // __cplusplus - -HDF_INIT(g_dCameraProviderConfigEntry); - -#ifndef __cplusplus -} -#endif // __cplusplus diff --git a/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h b/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h index ee8b9e1..9b09435 100644 --- a/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h +++ b/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h @@ -23,12 +23,13 @@ #include #include #include "camera_metadata_info.h" +#include "v1_0/dcamera_types.h" -#include #include namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class IpcDataUtils { static const uint32_t RATIONAL_TYPE_STEP = 2; public: diff --git a/camera_hdf/interfaces/hdi_ipc/server/device/dcamera_device_stub.cpp b/camera_hdf/interfaces/hdi_ipc/server/device/dcamera_device_stub.cpp index a1964d1..9315851 100644 --- a/camera_hdf/interfaces/hdi_ipc/server/device/dcamera_device_stub.cpp +++ b/camera_hdf/interfaces/hdi_ipc/server/device/dcamera_device_stub.cpp @@ -97,7 +97,7 @@ int32_t DCameraDeviceStub::DCDeviceStubGetStreamOperator(MessageParcel& data, Me bool nullFlag = (streamOperator != nullptr); if (!reply.WriteBool(nullFlag)) { DHLOGE("Write stream operator flag failed."); - return INVALID_ARGUMENT; + return HDF_FAILURE; } if (nullFlag && !reply.WriteRemoteObject(streamOperator->AsObject())) { diff --git a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp deleted file mode 100644 index f49c7d3..0000000 --- a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp +++ /dev/null @@ -1,274 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_callback_proxy.h" -#include -#include -#include "distributed_hardware_log.h" -#include "ipc_data_utils.h" - -namespace OHOS { -namespace DistributedHardware { -DCamRetCode DCameraProviderCallbackProxy::OpenSession(const std::shared_ptr &dhBase) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_OPEN_SESSION, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::CloseSession(const std::shared_ptr &dhBase) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLOSE_SESSION, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - size_t size = streamInfos.size(); - if (!data.WriteInt32(static_cast(size))) { - DHLOGE("Write stream info size failed."); - return INVALID_ARGUMENT; - } - for (size_t i = 0; i < size; i++) { - auto streamInfo = streamInfos.at(i); - bool bRet = data.WriteBuffer((void *)streamInfo.get(), sizeof(DCStreamInfo)); - if (!bRet) { - DHLOGE("Write stream info index = %d failed.", i); - return INVALID_ARGUMENT; - } - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CONFIGURE_STREAMS, - data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::ReleaseStreams(const std::shared_ptr &dhBase, - const std::vector &streamIds) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = streamIds; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamId failed."); - return INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_RELEASE_STREAMS, - data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - size_t size = captureInfos.size(); - if (!data.WriteInt32(static_cast(size))) { - DHLOGE("Write distributed camera capture info size failed."); - return INVALID_ARGUMENT; - } - for (size_t i = 0; i < size; i++) { - auto captureInfo = captureInfos.at(i); - if (!data.WriteInt32Vector(captureInfo->streamIds_)) { - DHLOGE("Write streamIds vector failed."); - return INVALID_ARGUMENT; - } - data.WriteInt32(static_cast(captureInfo->width_)); - data.WriteInt32(static_cast(captureInfo->height_)); - data.WriteInt32(static_cast(captureInfo->stride_)); - data.WriteInt32(static_cast(captureInfo->format_)); - data.WriteInt32(static_cast(captureInfo->dataspace_)); - data.WriteBool(static_cast(captureInfo->isCapture_)); - data.WriteInt32(static_cast(captureInfo->encodeType_)); - data.WriteInt32(static_cast(captureInfo->type_)); - - std::vector> capSettings = captureInfo->captureSettings_; - size_t settingsSize = capSettings.size(); - if (!data.WriteInt32(static_cast(settingsSize))) { - DHLOGE("Write distributed camera capture settings size failed."); - return INVALID_ARGUMENT; - } - for (size_t k = 0; k < settingsSize; k++) { - bool bRet = IpcDataUtils::EncodeDCameraSettings(capSettings.at(k), data); - if (!bRet) { - DHLOGE("Write distributed camera capture settings failed."); - return INVALID_ARGUMENT; - } - } - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_START_CAPTURE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::StopCapture(const std::shared_ptr &dhBase, - const std::vector &streamIds) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - std::vector pxyStreamIds = streamIds; - if (!data.WriteInt32Vector(pxyStreamIds)) { - DHLOGE("Write streamId failed."); - return INVALID_ARGUMENT; - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_STOP_CAPTURE, data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} - -DCamRetCode DCameraProviderCallbackProxy::UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings) -{ - MessageParcel data; - MessageParcel reply; - MessageOption option; - - if (!data.WriteInterfaceToken(DCameraProviderCallbackProxy::GetDescriptor())) { - DHLOGE("Write token failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - if (!data.WriteString(dhBase->deviceId_) || !data.WriteString(dhBase->dhId_)) { - DHLOGE("Write distributed camera base info or ability info failed."); - return DCamRetCode::INVALID_ARGUMENT; - } - - size_t size = settings.size(); - if (!data.WriteInt32(static_cast(size))) { - DHLOGE("Write distributed camera settings size failed."); - return INVALID_ARGUMENT; - } - for (size_t i = 0; i < size; i++) { - bool bRet = IpcDataUtils::EncodeDCameraSettings(settings.at(i), data); - if (!bRet) { - DHLOGE("Write distributed camera settings index = %zu failed.", i); - return INVALID_ARGUMENT; - } - } - - int32_t ret = Remote()->SendRequest(CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_UPDATE_SETTINGS, - data, reply, option); - if (ret != HDF_SUCCESS) { - DHLOGE("SendRequest failed, error code is %d.", ret); - return INVALID_ARGUMENT; - } - return static_cast(reply.ReadInt32()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.h b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.h deleted file mode 100644 index d83c735..0000000 --- a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_PROXY_H -#define DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_PROXY_H - -#include "iremote_proxy.h" -#include "idistributed_camera_provider_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class DCameraProviderCallbackProxy : public IRemoteProxy { -public: - explicit DCameraProviderCallbackProxy(const sptr &impl) - : IRemoteProxy(impl) {} - - virtual ~DCameraProviderCallbackProxy() = default; - - virtual DCamRetCode OpenSession(const std::shared_ptr &dhBase); - virtual DCamRetCode CloseSession(const std::shared_ptr &dhBase); - virtual DCamRetCode ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos); - virtual DCamRetCode ReleaseStreams(const std::shared_ptr &dhBase, - const std::vector &streamIds); - virtual DCamRetCode StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos); - virtual DCamRetCode StopCapture(const std::shared_ptr &dhBase, - const std::vector &streamIds); - virtual DCamRetCode UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings); - -private: - static inline BrokerDelegator delegator_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_PROXY_H diff --git a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.cpp b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.cpp deleted file mode 100644 index c98d3f9..0000000 --- a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "dcamera_provider_stub.h" - -#include -#include -#include -#include -#include "distributed_hardware_log.h" -#include "idistributed_camera_provider.h" -#include "ipc_data_utils.h" - -namespace OHOS { -namespace DistributedHardware { -DCameraProviderStub::DCameraProviderStub() -{ -} - -int32_t DCameraProviderStub::Init() -{ - dcameraProvider_ = DCameraProvider::GetInstance(); - if (dcameraProvider_ == nullptr) { - DHLOGE("Get distributed camera provider instance failed."); - return HDF_FAILURE; - } - DHLOGI("Get distributed camera provider instance success."); - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubEnableDCameraDevice(MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - const std::string abilitySet = data.ReadString(); - if (abilitySet.empty()) { - DHLOGE("Read input param is empty."); - return HDF_ERR_INVALID_PARAM; - } - - sptr dcProviderCallback = nullptr; - bool flag = data.ReadBool(); - if (flag) { - sptr remoteObj = data.ReadRemoteObject(); - if (remoteObj == nullptr) { - DHLOGE("Read distributed camera provider callback failed."); - return HDF_FAILURE; - } - dcProviderCallback = OHOS::iface_cast(remoteObj); - } - - DCamRetCode ret = dcameraProvider_->EnableDCameraDevice(dhBase, abilitySet, dcProviderCallback); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubDisableDCameraDevice(MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - DCamRetCode ret = dcameraProvider_->DisableDCameraDevice(dhBase); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubAcquireBuffer(MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - int32_t streamId = data.ReadInt32(); - - std::shared_ptr dCamerabuffer = std::make_shared(); - DCamRetCode ret = dcameraProvider_->AcquireBuffer(dhBase, streamId, dCamerabuffer); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - if (ret != DCamRetCode::SUCCESS) { - DHLOGE("Acquire available buffer failed."); - return HDF_SUCCESS; - } - if (!reply.WriteInt32(dCamerabuffer->index_) || !reply.WriteInt32(dCamerabuffer->size_)) { - DHLOGE("write buffer index and size parameter failed."); - return HDF_FAILURE; - } - - BufferHandle* bufferHandle = dCamerabuffer->bufferHandle_; - if (!WriteBufferHandle(reply, *bufferHandle)) { - DHLOGE("Write buffer handle failed."); - FreeBufferHandle(bufferHandle); - return HDF_ERR_INVALID_PARAM; - } - - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubShutterBuffer(MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - int32_t streamId = data.ReadInt32(); - - std::shared_ptr buffer = nullptr; - bool flag = data.ReadBool(); - if (flag) { - buffer = std::make_shared(); - buffer->index_ = data.ReadInt32(); - buffer->size_ = data.ReadInt32(); - buffer->bufferHandle_ = nullptr; - } - DCamRetCode ret = dcameraProvider_->ShutterBuffer(dhBase, streamId, buffer); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubOnSettingsResult(MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - std::shared_ptr dCameraSettings = std::make_shared(); - bool flag = data.ReadBool(); - if (flag) { - if (dCameraSettings == nullptr) { - DHLOGE("Read distributed camera settings failed, dCameraSettings is null."); - return HDF_FAILURE; - } - IpcDataUtils::DecodeDCameraSettings(data, dCameraSettings); - } - DCamRetCode ret = dcameraProvider_->OnSettingsResult(dhBase, dCameraSettings); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::DCProviderStubNotify(MessageParcel& data, MessageParcel& reply, MessageOption& option) -{ - if (data.ReadInterfaceToken() != DCameraProviderStub::GetDescriptor()) { - DHLOGE("invalid token."); - return HDF_FAILURE; - } - - std::shared_ptr dhBase = std::make_shared(data.ReadString(), data.ReadString()); - - std::shared_ptr dCameraEvent = std::make_shared(); - bool flag = data.ReadBool(); - if (flag) { - if (dCameraEvent == nullptr) { - DHLOGE("Read distributed camera hdf event failed, dCameraEvent is null."); - return HDF_FAILURE; - } - IpcDataUtils::DecodeDCameraHDFEvent(data, dCameraEvent); - } - DCamRetCode ret = dcameraProvider_->Notify(dhBase, dCameraEvent); - if (!reply.WriteInt32(static_cast(ret))) { - DHLOGE("Write retcode failed."); - return HDF_FAILURE; - } - return HDF_SUCCESS; -} - -int32_t DCameraProviderStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option) -{ - int32_t ret = HDF_SUCCESS; - switch (code) { - case CMD_DISTRIBUTED_CAMERA_PROVIDER_ENABLE_DEVICE: { - ret = DCProviderStubEnableDCameraDevice(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_DISABLE_DEVICE: { - ret = DCProviderStubDisableDCameraDevice(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_ACQUIRE_BUFFER: { - ret = DCProviderStubAcquireBuffer(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_SHUTTER_BUFFER: { - ret = DCProviderStubShutterBuffer(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_ON_SETTINGS_RESULT: { - ret = DCProviderStubOnSettingsResult(data, reply, option); - break; - } - case CMD_DISTRIBUTED_CAMERA_PROVIDER_NOTIFY: { - ret = DCProviderStubNotify(data, reply, option); - break; - } - default: { - DHLOGE("Unknown remote request code=%d.", code); - } - } - return ret; -} -} // namespace DistributedHardware -} // namespace OHOS - -void *DCameraProviderStubInstance() -{ - OHOS::DistributedHardware::DCameraProviderStub *stub = - new (std::nothrow) OHOS::DistributedHardware::DCameraProviderStub(); - if (stub == nullptr) { - HDF_LOGE("%{public}s: camera provider stub create failed.", __func__); - return nullptr; - } - - int32_t ret = stub->Init(); - if (ret != HDF_SUCCESS) { - delete stub; - stub = nullptr; - return nullptr; - } - return reinterpret_cast(stub); -} - -void DestroyDCameraProviderStub(void *stubObj) -{ - delete reinterpret_cast(stubObj); -} - -int32_t DCProviderServiceOnRemoteRequest(void *stub, int cmdId, struct HdfSBuf *data, struct HdfSBuf *reply) -{ - if (stub == nullptr) { - HDF_LOGE("%{public}s:stub is null", __func__); - return HDF_FAILURE; - } - - OHOS::DistributedHardware::DCameraProviderStub *providerStub = - reinterpret_cast(stub); - OHOS::MessageParcel *dataParcel = nullptr; - OHOS::MessageParcel *replyParcel = nullptr; - - if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - OHOS::MessageOption option; - return providerStub->OnRemoteRequest(cmdId, *dataParcel, *replyParcel, option); -} \ No newline at end of file diff --git a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.h b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.h deleted file mode 100644 index 4756446..0000000 --- a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_stub.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_SERVER_STUB_H -#define DISTRIBUTED_CAMERA_PROVIDER_SERVER_STUB_H - -#include -#include -#include -#include "dcamera_provider.h" -#include "iremote_stub.h" - -namespace OHOS { -namespace DistributedHardware { -class DCameraProviderStub { -public: - DCameraProviderStub(); - virtual ~DCameraProviderStub() {} - int32_t Init(); - int32_t OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, - MessageOption& option); - -private: - int32_t DCProviderStubEnableDCameraDevice(MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t DCProviderStubDisableDCameraDevice(MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t DCProviderStubAcquireBuffer(MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t DCProviderStubShutterBuffer(MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t DCProviderStubOnSettingsResult(MessageParcel& data, MessageParcel& reply, MessageOption& option); - int32_t DCProviderStubNotify(MessageParcel& data, MessageParcel& reply, MessageOption& option); - static inline const std::u16string metaDescriptor_ = u"HDI.DCamera.V1_0.Provider"; - static inline const std::u16string &GetDescriptor() - { - return metaDescriptor_; - } - -private: - std::shared_ptr dcameraProvider_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS - -void* DCameraProviderStubInstance(); - -void DestroyDCameraProviderStub(void* stubObj); - -int32_t DCProviderServiceOnRemoteRequest(void* stub, int cmdId, struct HdfSBuf* data, struct HdfSBuf* reply); - -#endif // DISTRIBUTED_CAMERA_PROVIDER_SERVER_STUB_H \ No newline at end of file diff --git a/camera_hdf/interfaces/include/idistributed_camera_provider.h b/camera_hdf/interfaces/include/idistributed_camera_provider.h deleted file mode 100644 index 61e4127..0000000 --- a/camera_hdf/interfaces/include/idistributed_camera_provider.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file idistributed_camera_provider.h - * - * @brief Transfer interfaces call between distributed camera SA service and distributed camera HDF service, - * and provide Hardware Driver Interfaces (HDIs) for the upper layer. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef HDI_DISTRIBUTED_CAMERA_PROVIDER_H -#define HDI_DISTRIBUTED_CAMERA_PROVIDER_H - -#include "idistributed_camera_provider_callback.h" - -namespace OHOS { -namespace DistributedHardware { -enum { - CMD_DISTRIBUTED_CAMERA_PROVIDER_ENABLE_DEVICE = 0, - CMD_DISTRIBUTED_CAMERA_PROVIDER_DISABLE_DEVICE, - CMD_DISTRIBUTED_CAMERA_PROVIDER_ACQUIRE_BUFFER, - CMD_DISTRIBUTED_CAMERA_PROVIDER_SHUTTER_BUFFER, - CMD_DISTRIBUTED_CAMERA_PROVIDER_ON_SETTINGS_RESULT, - CMD_DISTRIBUTED_CAMERA_PROVIDER_NOTIFY, -}; - -class IDCameraProvider : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"HDI.DCamera.V1_0.Provider"); - virtual ~IDCameraProvider() {} - -public: - /** - * @brief Obtains an IDCameraProvider instance. - * This function provides the entry to the distributed camera SA service. - * You must use this function to obtain an IDCameraProvider instance before performing other operations. - * - * @return Returns the IDCameraProvider instance if the operation is successful, - * returns nullptr otherwise. - * - * @since 1.0 - * @version 1.0 - */ - static sptr Get(); - - /** - * @brief Enable distributed camera device and set callback. For details about the callbacks, - * see {@link IDCameraProviderCallback}. - * - * @param dhBase [in] Distributed hardware device base info. - * - * @param abilityInfo [in] The static capability info of the distributed camera device to be enabled. - * - * @param callback [in] Indicates the callbacks to set. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode EnableDCameraDevice(const std::shared_ptr &dhBase, - const std::string &abilityInfo, const sptr &callback) = 0; - - /** - * @brief Disable distributed camera device. - * - * @param dhBase [in] Distributed hardware device base info - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode DisableDCameraDevice(const std::shared_ptr &dhBase) = 0; - - /** - * @brief Acquire a frame buffer from the procedure handle which attached to the streamId. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param streamId [in] Indicates the ID of the stream to which the procedure handle is to be attached. - * - * @param buffer [out] A frame buffer - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode AcquireBuffer(const std::shared_ptr &dhBase, int streamId, - std::shared_ptr &buffer) = 0; - - /** - * @brief Notify distributed camera HDF service when a frame buffer has been filled. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param streamId [in] Indicates the ID of the stream to which the frame buffer is to be attached. - * - * @param buffer [out] output frame buffer - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode ShutterBuffer(const std::shared_ptr &dhBase, int streamId, - const std::shared_ptr &buffer) = 0; - - /** - * @brief Called to report metadata related to the distributed camera device. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param result Indicates the metadata reported. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode OnSettingsResult(const std::shared_ptr &dhBase, - const std::shared_ptr &result) = 0; - - /** - * @brief Called to notify some events from distributed camera SA service to distributed camera HDF service. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param event [in] Detail event contents - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode Notify(const std::shared_ptr &dhBase, - const std::shared_ptr &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDI_DISTRIBUTED_CAMERA_PROVIDER_H \ No newline at end of file diff --git a/camera_hdf/interfaces/include/idistributed_camera_provider_callback.h b/camera_hdf/interfaces/include/idistributed_camera_provider_callback.h deleted file mode 100644 index bce2bc4..0000000 --- a/camera_hdf/interfaces/include/idistributed_camera_provider_callback.h +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file idistributed_camera_provider_callback.h - * - * @brief Declares callbacks for distributed camera SA service. The caller needs to implement the callbacks. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef HDI_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H -#define HDI_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H - -#include -#include -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -enum { - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_OPEN_SESSION = 0, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CLOSE_SESSION, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_CONFIGURE_STREAMS, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_RELEASE_STREAMS, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_START_CAPTURE, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_STOP_CAPTURE, - CMD_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_UPDATE_SETTINGS, -}; - -class IDCameraProviderCallback : public IRemoteBroker { -public: - DECLARE_INTERFACE_DESCRIPTOR(u"HDI.DCamera.V1_0.ProviderCallback"); - virtual ~IDCameraProviderCallback() {} - -public: - /** - * @brief Create the transmission channel between the source device and the sink device. - * Open and initialize the distributed camera session. - * - * @param dhBase [in] Distributed hardware device base info - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode OpenSession(const std::shared_ptr &dhBase) = 0; - - /** - * @brief Close the distributed camera session, and destroy the transmission channel between - * the source device and the sink device. - * - * @param dhBase [in] Distributed hardware device base info - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode CloseSession(const std::shared_ptr &dhBase) = 0; - - /** - * @brief Configures streams. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param streamInfos [in] Indicates the list of stream information, which is defined by {@link DCStreamInfo}. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode ConfigureStreams(const std::shared_ptr &dhBase, - const std::vector> &streamInfos) = 0; - - /** - * @brief Releases streams. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param streamIds [IN] Indicates the IDs of the streams to release. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode ReleaseStreams(const std::shared_ptr &dhBase, const std::vector &streamIds) = 0; - - /** - * @brief Start capture images. - * This function must be called after {@link ConfigStreams}. - * There are two image capture modes: continuous capture and single capture. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param captureInfos [in] Indicates the capture request configuration information. - * For details, see {@link DCCaptureInfo}. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode StartCapture(const std::shared_ptr &dhBase, - const std::vector> &captureInfos) = 0; - - /** - * @brief Stop capture images. - * - * @param dhBase [in] Distributed hardware device base info - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode StopCapture(const std::shared_ptr &dhBase, const std::vector &streamIds) = 0; - - /** - * @brief Updates distributed camera device control parameters. - * - * @param dhBase [in] Distributed hardware device base info - * - * @param settings [in] Indicates the camera parameters, including the sensor frame rate and 3A parameters. - * For details about the settings, see {@link DCameraSettings}. - * - * @return Returns NO_ERROR if the operation is successful, - * returns an error code defined in {@link DCamRetCode} otherwise. - * - * @since 1.0 - * @version 1.0 - */ - virtual DCamRetCode UpdateSettings(const std::shared_ptr &dhBase, - const std::vector> &settings) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDI_DISTRIBUTED_CAMERA_PROVIDER_CALLBACK_H \ No newline at end of file diff --git a/camera_hdf/interfaces/include/types.h b/camera_hdf/interfaces/include/types.h deleted file mode 100644 index 3bb2d6b..0000000 --- a/camera_hdf/interfaces/include/types.h +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file types.h - * - * @brief Declares data types used by the Hardware Driver Interfaces (HDIs) of this module. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef DISTRIBUTED_CAMERA_PROVIDER_TYPES_H -#define DISTRIBUTED_CAMERA_PROVIDER_TYPES_H - -#include -#include -#include "buffer_handle.h" - -namespace OHOS { -namespace DistributedHardware { -/** - * @brief Enumerates distributed camera metadata updating types. - */ -using DCSettingsType = enum _DCSettingsType : int32_t { - /** - * Set the whole package metadata. - */ - UPDATE_METADATA = 0, - /** - * Enable metadata. - */ - ENABLE_METADATA = 1, - /** - * Disable metadata. - */ - DISABLE_METADATA = 2, - /** - * Metadata result. - */ - METADATA_RESULT = 3, - /** - * Set flash light. - */ - SET_FLASH_LIGHT = 4, - /** - * Set fps range. - */ - FPS_RANGE = 5 -}; - -/** - * @brief Enumerates return values of the HDIs. - */ -using DCamRetCode = enum _DCamRetCode : int32_t { - /** - * Successful call. - */ - SUCCESS = 0, - /** - * The camera device is busy. - */ - CAMERA_BUSY = 1, - /** - * Invalid parameters. - */ - INVALID_ARGUMENT = 2, - /** - * Unsupported function. - */ - METHOD_NOT_SUPPORTED = 3, - /** - * The camera device is offlined. - */ - CAMERA_OFFLINE = 4, - /** - * The number of distributed camera devices enabled exceeds the limit. - */ - EXCEED_MAX_NUMBER = 5, - /** - * The device is not initialized. - */ - DEVICE_NOT_INIT = 6, - /** - * Failed call. - */ - FAILED = -1, -}; - - /** - * @brief Enumerates encoding types of stream data. - */ -using DCEncodeType = enum _DCEncodeType : int32_t { - /** - * Unspecified - */ - ENCODE_TYPE_NULL = 0, - - /** - * H.264 - */ - ENCODE_TYPE_H264 = 1, - - /** - * H.265 - */ - ENCODE_TYPE_H265 = 2, - - /** - * JPEG - */ - ENCODE_TYPE_JPEG = 3, -}; - -/** - * @brief Enumerates distributed camera inner stream types. - */ -using DCStreamType = enum _DCStreamType : int32_t { - /** - * Continuous capture stream. For example preview streams, video streams. - */ - CONTINUOUS_FRAME = 0, - /** - * Single capture stream. For example photographing streams. - */ - SNAPSHOT_FRAME = 1 -}; - -/** - * @brief Distributed hardware device base info. - */ -using DHBase = struct _DHBase { - /** - * The device id. - */ - std::string deviceId_; - /** - * The distributed hardware id. - */ - std::string dhId_; - - _DHBase() : deviceId_(""), dhId_("") {} - - _DHBase(const std::string &deviceId, const std::string &dhId) : deviceId_(deviceId), dhId_(dhId) {} - - bool operator ==(const _DHBase& others) const - { - return this->deviceId_ == others.deviceId_ && this->dhId_ == others.dhId_; - } - - bool operator < (const _DHBase& others) const - { - return (this->deviceId_ + this->dhId_) < (others.deviceId_ + others.dhId_); - } -}; - -/** - * @brief The control settings of the distributed camera device. - */ -using DCameraSettings = struct _DCameraSettings { - /** - * Settings type. - */ - DCSettingsType type_; - /** - * Settings value. Serialized from bool, array, structure, etc. - */ - std::string value_; -}; - -/** - * @brief Defines the inner stream information of the distributed camera, - * which is used to pass configuration parameters during stream creation. - */ -using DCStreamInfo = struct _DCStreamInfo { - /** - * Stream ID, which uniquely identifies a stream on a camera device. - */ - int streamId_; - /** - * Image width. - */ - int width_; - /** - * Image height. - */ - int height_; - /** - * Image stride. - */ - int stride_; - /** - * Image format. - */ - int format_; - /** - * Image color space. - */ - int dataspace_; - /** - * Encoding type. - */ - DCEncodeType encodeType_; - /** - * Stream type. - */ - DCStreamType type_; -}; - -/** - * @brief Defines the information about a inner capture request of the distributed camera. - */ -using DCCaptureInfo = struct _DCCaptureInfo { - /** - * IDs of captured streams. - */ - std::vector streamIds_; - /** - * Image width. - */ - int width_; - /** - * Image height. - */ - int height_; - /** - * Image stride. - */ - int stride_; - /** - * Image format. - */ - int format_; - /** - * Image color space. - */ - int dataspace_; - /** - * Capture Info - */ - bool isCapture_; - /** - * Encoding type. - */ - DCEncodeType encodeType_; - /** - * Stream type. - */ - DCStreamType type_; - /** - * Stream settings. - */ - std::vector> captureSettings_; -}; - -/** - * @brief Defines the inner buffer of the distributed camera, - * which is used to acquire buffer during processing capture requests. - */ -using DCameraBuffer = struct _DCameraBuffer { - /** - * Buffer index. - */ - int32_t index_; - /** - * Buffer size. - */ - uint32_t size_; - /** - * Buffer handle. - */ - BufferHandle* bufferHandle_; -}; - -/** - * @brief Notification event of the distributed camera. - */ -using DCameraHDFEvent = struct _DCameraHDFEvent { - /** - * Event type. - */ - int32_t type_; - /** - * Event result. - */ - int32_t result_; - /** - * Extended content (optional). - */ - std::string content_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // DISTRIBUTED_CAMERA_PROVIDER_TYPES_H \ No newline at end of file diff --git a/common/BUILD.gn b/common/BUILD.gn index c8fdcf7..4e2e6eb 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -30,8 +30,18 @@ ohos_shared_library("distributed_camera_utils") { "include/utils", ] + cflags = [ + "-fPIC", + "-Wall", + ] + + if ("${product_name}" == "m40") { + cflags += [ "-DPRODUCT_M40" ] + } + sources = [ "src/utils/data_buffer.cpp", + "src/utils/dcamera_buffer_handle.cpp", "src/utils/dcamera_hisysevent_adapter.cpp", "src/utils/dcamera_sa_process_state.cpp", "src/utils/dcamera_utils_tools.cpp", @@ -50,10 +60,13 @@ ohos_shared_library("distributed_camera_utils") { external_deps = [ "dsoftbus_standard:softbus_client", + "graphic_chipsetsdk:buffer_handle", "hisysevent_native:libhisysevent", "hiviewdfx_hilog_native:libhilog", ] + cflags_cc = cflags + subsystem_name = "distributedhardware" part_name = "distributed_camera" diff --git a/common/include/constants/distributed_camera_constants.h b/common/include/constants/distributed_camera_constants.h index 5c60ea7..eddb2f5 100644 --- a/common/include/constants/distributed_camera_constants.h +++ b/common/include/constants/distributed_camera_constants.h @@ -94,6 +94,7 @@ const std::string CAMERA_FORMAT_VIDEO = "Video"; const std::string CAMERA_FORMAT_PHOTO = "Photo"; const std::string CAMERA_RESOLUTION_KEY = "Resolution"; const std::string CAMERA_SURFACE_FORMAT = "CAMERA_SURFACE_FORMAT"; +const std::string HDF_DCAMERA_EXT_SERVICE = "distributed_camera_provider_service"; const int32_t RESOLUTION_MAX_WIDTH_SNAPSHOT = 4096; const int32_t RESOLUTION_MAX_HEIGHT_SNAPSHOT = 3072; diff --git a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.cpp b/common/include/utils/dcamera_buffer_handle.h similarity index 61% rename from camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.cpp rename to common/include/utils/dcamera_buffer_handle.h index 27a10ac..d7e8957 100644 --- a/camera_hdf/interfaces/hdi_ipc/client/device/dcamera_device_callback.cpp +++ b/common/include/utils/dcamera_buffer_handle.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -13,19 +13,15 @@ * limitations under the License. */ -#include "dcamera_device_callback.h" -#include "distributed_hardware_log.h" +#ifndef OHOS_DCAMERA_BUFFER_HANDLE_H +#define OHOS_DCAMERA_BUFFER_HANDLE_H + +#include "buffer_handle.h" namespace OHOS { namespace DistributedHardware { -void DCameraDeviceCallback::OnError(ErrorType type, int32_t errorMsg) -{ - DHLOGW("DCameraDeviceCallback::OnError enter."); -} - -void DCameraDeviceCallback::OnResult(uint64_t timestamp, const std::shared_ptr &result) -{ - DHLOGW("DCameraDeviceCallback::OnResult enter."); -} +void* DCameraMemoryMap(const BufferHandle *buffer); +void DCameraMemoryUnmap(BufferHandle *buffer); } // namespace DistributedHardware } // namespace OHOS +#endif // OHOS_DCAMERA_BUFFER_HANDLE_H \ No newline at end of file diff --git a/common/src/utils/dcamera_buffer_handle.cpp b/common/src/utils/dcamera_buffer_handle.cpp new file mode 100644 index 0000000..7a1627f --- /dev/null +++ b/common/src/utils/dcamera_buffer_handle.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "dcamera_buffer_handle.h" + +#include +#include + +#include "buffer_handle_utils.h" +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +#ifdef PRODUCT_M40 +void* DCameraMemoryMap(const BufferHandle *buffer) +{ + if (buffer == nullptr) { + DHLOGE("mmap the buffer handle is NULL"); + return nullptr; + } + if (buffer->reserveFds <= 0) { + DHLOGE("invalid file descriptor num : %d", buffer->reserveFds); + return nullptr; + } + void* virAddr = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, buffer->reserve[0], 0); + if (virAddr == MAP_FAILED) { + DHLOGE("mmap failed errno %s, fd : %d", strerror(errno), buffer->fd); + return nullptr; + } + return virAddr; +} +#else +void* DCameraMemoryMap(const BufferHandle *buffer) +{ + if (buffer == nullptr) { + DHLOGE("mmap the buffer handle is NULL"); + return nullptr; + } + + void* virAddr = mmap(NULL, buffer->size, PROT_READ | PROT_WRITE, MAP_SHARED, buffer->fd, 0); + if (virAddr == MAP_FAILED) { + DHLOGE("mmap failed errno %s, fd : %d", strerror(errno), buffer->fd); + return nullptr; + } + return virAddr; +} +#endif + +void DCameraMemoryUnmap(BufferHandle *buffer) +{ + if (buffer == nullptr) { + DHLOGE("unmmap the buffer handle is NULL"); + return; + } + if (buffer->virAddr != nullptr) { + int ret = munmap(buffer->virAddr, buffer->size); + if (ret != 0) { + DHLOGE("munmap failed err: %s", strerror(errno)); + } + } + buffer->virAddr = nullptr; + FreeBufferHandle(buffer); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/cameraservice/base/include/dcamera_capture_info_cmd.h b/services/cameraservice/base/include/dcamera_capture_info_cmd.h index ce04fe5..99b0158 100644 --- a/services/cameraservice/base/include/dcamera_capture_info_cmd.h +++ b/services/cameraservice/base/include/dcamera_capture_info_cmd.h @@ -18,10 +18,11 @@ #include "distributed_camera_constants.h" #include "json/json.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraCaptureInfo { public: int32_t width_; diff --git a/services/cameraservice/base/include/dcamera_channel_info_cmd.h b/services/cameraservice/base/include/dcamera_channel_info_cmd.h index 5c8e548..deedd33 100644 --- a/services/cameraservice/base/include/dcamera_channel_info_cmd.h +++ b/services/cameraservice/base/include/dcamera_channel_info_cmd.h @@ -20,10 +20,11 @@ #include #include -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraChannelDetail { public: DCameraChannelDetail() = default; diff --git a/services/cameraservice/base/include/dcamera_metadata_setting_cmd.h b/services/cameraservice/base/include/dcamera_metadata_setting_cmd.h index c2b571d..acfbcbc 100644 --- a/services/cameraservice/base/include/dcamera_metadata_setting_cmd.h +++ b/services/cameraservice/base/include/dcamera_metadata_setting_cmd.h @@ -16,10 +16,11 @@ #ifndef OHOS_DCAMERA_METADATA_SETTING_H #define OHOS_DCAMERA_METADATA_SETTING_H -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraMetadataSettingCmd { public: std::string type_; diff --git a/services/cameraservice/base/test/unittest/common/dcameraprotocol/BUILD.gn b/services/cameraservice/base/test/unittest/common/dcameraprotocol/BUILD.gn index 48ab6a8..ead923a 100644 --- a/services/cameraservice/base/test/unittest/common/dcameraprotocol/BUILD.gn +++ b/services/cameraservice/base/test/unittest/common/dcameraprotocol/BUILD.gn @@ -36,7 +36,6 @@ config("module_private_config") { "${services_path}/cameraservice/base/include", "${common_path}/include/constants", "${common_path}/include/utils", - "${distributedcamera_hdf_path}/interfaces/include", ] } @@ -57,6 +56,7 @@ ohos_unittest("DCameraProtocolTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "dsoftbus_standard:softbus_client", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/cameraoperator/client/BUILD.gn b/services/cameraservice/cameraoperator/client/BUILD.gn index edbe2c5..f897ca2 100644 --- a/services/cameraservice/cameraoperator/client/BUILD.gn +++ b/services/cameraservice/cameraoperator/client/BUILD.gn @@ -42,7 +42,6 @@ ohos_shared_library("distributed_camera_client") { "include/listener", "${common_path}/include/constants", "${common_path}/include/utils", - "${distributedcamera_hdf_path}/interfaces/include", "${services_path}/cameraservice/base/include", "//third_party/jsoncpp/include", ] @@ -87,6 +86,7 @@ ohos_shared_library("distributed_camera_client") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "hiviewdfx_hilog_native:libhilog", "multimedia_media_standard:media_client", ] diff --git a/services/cameraservice/cameraoperator/client/include/icamera_operator.h b/services/cameraservice/cameraoperator/client/include/icamera_operator.h index e349339..fe0ea19 100644 --- a/services/cameraservice/cameraoperator/client/include/icamera_operator.h +++ b/services/cameraservice/cameraoperator/client/include/icamera_operator.h @@ -24,10 +24,11 @@ #include "data_buffer.h" #include "dcamera_capture_info_cmd.h" #include "dcamera_event_cmd.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class StateCallback { public: StateCallback() = default; diff --git a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/BUILD.gn b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/BUILD.gn index 2d7e086..9b5b450 100644 --- a/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/BUILD.gn +++ b/services/cameraservice/cameraoperator/client/test/unittest/common/cameraoperator/BUILD.gn @@ -40,7 +40,6 @@ config("module_private_config") { ] include_dirs += [ - "${distributedcamera_hdf_path}/interfaces/include", "${common_path}/include/constants", "${common_path}/include/utils", "${services_path}/cameraservice/base/include", @@ -73,6 +72,7 @@ ohos_unittest("DCameraClientTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/cameraoperator/handler/BUILD.gn b/services/cameraservice/cameraoperator/handler/BUILD.gn index 097e0a0..bdd959e 100644 --- a/services/cameraservice/cameraoperator/handler/BUILD.gn +++ b/services/cameraservice/cameraoperator/handler/BUILD.gn @@ -42,7 +42,6 @@ ohos_shared_library("distributed_camera_handler") { "include", "${common_path}/include/constants", "${common_path}/include/utils", - "${distributedcamera_hdf_path}/interfaces/include", "${services_path}/cameraservice/cameraoperator/client/include/callback", ] @@ -71,6 +70,7 @@ ohos_shared_library("distributed_camera_handler") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "hiviewdfx_hilog_native:libhilog", "multimedia_media_standard:media_client", ] diff --git a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h index 9faebc4..83a7707 100644 --- a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h +++ b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h @@ -25,10 +25,11 @@ #include "camera_manager.h" #include "json/json.h" #include "single_instance.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; struct ConfigInfo { DCStreamType type; std::string formatKey; diff --git a/services/cameraservice/cameraoperator/handler/test/unittest/common/dcamerahandler/BUILD.gn b/services/cameraservice/cameraoperator/handler/test/unittest/common/dcamerahandler/BUILD.gn index 26c041c..86b83d1 100644 --- a/services/cameraservice/cameraoperator/handler/test/unittest/common/dcamerahandler/BUILD.gn +++ b/services/cameraservice/cameraoperator/handler/test/unittest/common/dcamerahandler/BUILD.gn @@ -39,7 +39,6 @@ config("module_private_config") { ] include_dirs += [ - "${distributedcamera_hdf_path}/interfaces/include", "${common_path}/include/constants", "${common_path}/include/utils", "${services_path}/cameraservice/base/include", @@ -68,6 +67,7 @@ ohos_unittest("DCameraHandlerTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 0d81af9..fc9000c 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -50,7 +50,6 @@ ohos_shared_library("distributed_camera_sink") { "${innerkits_path}/native_cpp/camera_sink/include", "${innerkits_path}/native_cpp/camera_source/include", "${innerkits_path}/native_cpp/camera_source/include/callback", - "${distributedcamera_hdf_path}/interfaces/include", "${services_path}/cameraservice/base/include", "${services_path}/cameraservice/cameraoperator/client/include", "${services_path}/cameraservice/cameraoperator/client/include/callback", @@ -118,6 +117,7 @@ ohos_shared_library("distributed_camera_sink") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn index 4f10a42..4305abe 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcamera/BUILD.gn @@ -42,7 +42,6 @@ config("module_private_config") { include_dirs += [ "${common_path}/include/constants", "${common_path}/include/utils", - "${distributedcamera_hdf_path}/interfaces/include", "${innerkits_path}/native_cpp/camera_sink/include", "${services_path}/cameraservice/base/include", "${services_path}/cameraservice/cameraoperator/handler/include", @@ -70,6 +69,7 @@ ohos_unittest("DistributedCameraSinkServiceTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/BUILD.gn b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/BUILD.gn index 6bfd966..9db8a0f 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/BUILD.gn +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/BUILD.gn @@ -44,7 +44,6 @@ config("module_private_config") { "${services_path}/data_process/include/utils", "${common_path}/include/constants", "${common_path}/include/utils", - "${distributedcamera_hdf_path}/interfaces/include", "${innerkits_path}/native_cpp/camera_source/include", "${innerkits_path}/native_cpp/camera_source/include/callback", @@ -86,6 +85,7 @@ ohos_unittest("DCameraSinkMgrTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "ipc:ipc_core", "multimedia_media_standard:media_client", diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 0449bf6..7a98b0b 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -42,8 +42,6 @@ ohos_shared_library("distributed_camera_source") { "${innerkits_path}/native_cpp/camera_source/include", "${innerkits_path}/native_cpp/camera_sink/include", "${innerkits_path}/native_cpp/camera_source/include/callback", - "${distributedcamera_hdf_path}/interfaces/include", - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/provider", "${services_path}/cameraservice/base/include", "${services_path}/channel/include", "${services_path}/data_process/include/eventbus", @@ -89,7 +87,6 @@ ohos_shared_library("distributed_camera_source") { deps = [ "${common_path}:distributed_camera_utils", - "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client:distributed_camera_hdf_client", "${fwk_utils_path}:distributedhardwareutils", "${services_path}/channel:distributed_camera_channel", "${services_path}/data_process:distributed_camera_data_process", @@ -106,6 +103,7 @@ ohos_shared_library("distributed_camera_source") { external_deps = [ "device_driver_framework:libhdf_utils", "device_driver_framework:libhdi", + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h index 6ffe705..f6ae5e9 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_dev.h @@ -24,8 +24,8 @@ #include "icamera_state_listener.h" #include "icamera_input.h" -#include "idistributed_camera_provider_callback.h" -#include "idistributed_camera_provider.h" +#include "v1_0/id_camera_provider_callback.h" +#include "v1_0/id_camera_provider.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_event.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_event.h index b928541..f0d15aa 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_event.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamera_source_event.h @@ -19,13 +19,14 @@ #include #include "event.h" -#include "types.h" +#include "v1_0/dcamera_types.h" #include "dcamera_event_cmd.h" #include "dcamera_index.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; typedef enum { DCAMERA_EVENT_REGIST = 0, DCAMERA_EVENT_UNREGIST = 1, diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h index 27d3b1d..1879f33 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameracontrol/dcamera_source_controller.h @@ -24,7 +24,7 @@ #include "event_bus.h" #include "icamera_channel.h" -#include "idistributed_camera_provider.h" +#include "v1_0/id_camera_provider.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_data_process.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_data_process.h index e466886..eab2afe 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_data_process.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_data_process.h @@ -23,10 +23,11 @@ #include "dcamera_stream_data_process.h" #include "icamera_source_data_process.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraSourceDataProcess : public ICameraSourceDataProcess { public: DCameraSourceDataProcess(std::string devId, std::string dhId, DCStreamType streamType); diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_input_channel_listener.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_input_channel_listener.h index 69bb930..8fa6143 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_input_channel_listener.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_source_input_channel_listener.h @@ -19,10 +19,11 @@ #include #include "icamera_channel_listener.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraSourceInput; class DCameraSourceInputChannelListener : public ICameraChannelListener { public: diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process.h index a687196..10bd221 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process.h @@ -23,12 +23,13 @@ #include "icamera_source_data_process.h" #include "idata_process_pipeline.h" #include "image_common_type.h" -#include "types.h" +#include "v1_0/dcamera_types.h" #include "dcamera_stream_data_process_producer.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraStreamDataProcess : public std::enable_shared_from_this { public: DCameraStreamDataProcess(std::string devId, std::string dhId, DCStreamType streamType); diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.h index 529d670..083aba5 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.h @@ -23,10 +23,11 @@ #include "data_buffer.h" #include "event_handler.h" -#include "idistributed_camera_provider.h" +#include "v1_0/id_camera_provider.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraStreamDataProcessProducer { public: typedef enum { @@ -45,7 +46,8 @@ private: void StartEvent(); void LooperContinue(); void LooperSnapShot(); - int32_t FeedStreamToDriver(const std::shared_ptr& dhBase, const std::shared_ptr& buffer); + int32_t FeedStreamToDriver(const DHBase& dhBase, const std::shared_ptr& buffer); + int32_t CheckSharedMemory(const DCameraBuffer& sharedMemory, const std::shared_ptr& buffer); const uint32_t DCAMERA_PRODUCER_MAX_BUFFER_SIZE = 30; const uint32_t DCAMERA_PRODUCER_RETRY_SLEEP_MS = 500; diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.h index f0d1c2b..a373ee6 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.h @@ -16,26 +16,24 @@ #ifndef OHOS_DCAMERA_PROVIDER_CALLBACK_IMPL_H #define OHOS_DCAMERA_PROVIDER_CALLBACK_IMPL_H -#include "dcamera_provider_callback.h" +#include "v1_0/id_camera_provider_callback.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraSourceDev; -class DCameraProviderCallbackImpl : public DCameraProviderCallback { +class DCameraProviderCallbackImpl : public IDCameraProviderCallback { public: DCameraProviderCallbackImpl(std::string devId, std::string dhId, std::shared_ptr& sourceDev); ~DCameraProviderCallbackImpl(); - DCamRetCode OpenSession(const std::shared_ptr& dhBase) override; - DCamRetCode CloseSession(const std::shared_ptr& dhBase) override; - DCamRetCode ConfigureStreams(const std::shared_ptr& dhBase, - const std::vector>& streamInfos) override; - DCamRetCode ReleaseStreams(const std::shared_ptr& dhBase, const std::vector& streamIds) override; - DCamRetCode StartCapture(const std::shared_ptr& dhBase, - const std::vector>& captureInfos) override; - DCamRetCode StopCapture(const std::shared_ptr& dhBase, const std::vector& streamIds) override; - DCamRetCode UpdateSettings(const std::shared_ptr& dhBase, - const std::vector>& settings) override; + int32_t OpenSession(const DHBase& dhBase) override; + int32_t CloseSession(const DHBase& dhBase) override; + int32_t ConfigureStreams(const DHBase& dhBase, const std::vector& streamInfos) override; + int32_t ReleaseStreams(const DHBase& dhBase, const std::vector& streamIds) override; + int32_t StartCapture(const DHBase& dhBase, const std::vector& captureInfos) override; + int32_t StopCapture(const DHBase& dhBase, const std::vector& streamIds) override; + int32_t UpdateSettings(const DHBase& dhBase, const std::vector& settings) override; private: std::string devId_; diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_input.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_input.h index 30b851c..516b32d 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_input.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_input.h @@ -16,10 +16,11 @@ #ifndef OHOS_ICAMERA_INPUT_H #define OHOS_ICAMERA_INPUT_H -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class ICameraInput { public: virtual ~ICameraInput() = default; diff --git a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_source_data_process.h b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_source_data_process.h index 95e3a61..1359dba 100644 --- a/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_source_data_process.h +++ b/services/cameraservice/sourceservice/include/distributedcameramgr/dcamerainterface/icamera_source_data_process.h @@ -19,10 +19,11 @@ #include #include "data_buffer.h" -#include "types.h" +#include "v1_0/dcamera_types.h" namespace OHOS { namespace DistributedHardware { +using namespace OHOS::HDI::DistributedCamera::V1_0; class DCameraStreamConfig { public: DCameraStreamConfig(int32_t width, int32_t height, int32_t format, int32_t dataspace, diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp index b8ce763..8cdaf4a 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamera_source_dev.cpp @@ -235,7 +235,7 @@ int32_t DCameraSourceDev::ExecuteRegister(std::shared_ptr& p return ret; } - sptr camHdiProvider = IDCameraProvider::Get(); + sptr camHdiProvider = IDCameraProvider::Get(HDF_DCAMERA_EXT_SERVICE); if (camHdiProvider == nullptr) { DHLOGI("ExecuteRegister camHdiProvider is nullptr devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -243,10 +243,10 @@ int32_t DCameraSourceDev::ExecuteRegister(std::shared_ptr& p input_->UnInit(); return DCAMERA_BAD_OPERATE; } - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = param->devId_; - dhBase->dhId_ = param->dhId_; - DCamRetCode retHdi = camHdiProvider->EnableDCameraDevice(dhBase, param->param_, hdiCallback_); + DHBase dhBase; + dhBase.deviceId_ = param->devId_; + dhBase.dhId_ = param->dhId_; + int32_t retHdi = camHdiProvider->EnableDCameraDevice(dhBase, param->param_, hdiCallback_); DHLOGI("DCameraSourceDev Execute Register register hal, ret: %d, devId: %s dhId: %s", retHdi, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); if (retHdi != SUCCESS) { @@ -275,17 +275,17 @@ int32_t DCameraSourceDev::ExecuteUnRegister(std::shared_ptr& GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); } - sptr camHdiProvider = IDCameraProvider::Get(); + sptr camHdiProvider = IDCameraProvider::Get(HDF_DCAMERA_EXT_SERVICE); if (camHdiProvider == nullptr) { DHLOGI("ExecuteUnRegister camHdiProvider is nullptr devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); return DCAMERA_BAD_OPERATE; } - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = param->devId_; - dhBase->dhId_ = param->dhId_; - DCamRetCode retHdi = camHdiProvider->DisableDCameraDevice(dhBase); + DHBase dhBase; + dhBase.deviceId_ = param->devId_; + dhBase.dhId_ = param->dhId_; + int32_t retHdi = camHdiProvider->DisableDCameraDevice(dhBase); DHLOGI("DCameraSourceDev Execute UnRegister unregister hal, ret: %d, devId: %s dhId: %s", retHdi, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); if (retHdi != SUCCESS) { @@ -437,8 +437,8 @@ int32_t DCameraSourceDev::ExecuteStartCapture(std::vectorcaptureSettings_.begin(); settingIter != (*iter)->captureSettings_.end(); settingIter++) { std::shared_ptr setting = std::make_shared(); - setting->type_ = (*settingIter)->type_; - setting->value_ = (*settingIter)->value_; + setting->type_ = settingIter->type_; + setting->value_ = settingIter->value_; capture->captureSettings_.push_back(setting); } captures.push_back(capture); diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp index 9bc9f9c..20b417c 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp @@ -165,20 +165,20 @@ int32_t DCameraSourceController::ChannelNeg(std::shared_ptr& int32_t DCameraSourceController::DCameraNotify(std::shared_ptr& events) { - sptr camHdiProvider = IDCameraProvider::Get(); + sptr camHdiProvider = IDCameraProvider::Get(HDF_DCAMERA_EXT_SERVICE); if (camHdiProvider == nullptr) { DHLOGI("DCameraNotify camHdiProvider is nullptr devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); return DCAMERA_BAD_OPERATE; } - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = devId_; - dhBase->dhId_ = dhId_; - std::shared_ptr hdiEvent = std::make_shared(); - hdiEvent->type_ = events->eventType_; - hdiEvent->result_ = events->eventResult_; - hdiEvent->content_ = events->eventContent_; - DCamRetCode retHdi = camHdiProvider->Notify(dhBase, hdiEvent); + DHBase dhBase; + dhBase.deviceId_ = devId_; + dhBase.dhId_ = dhId_; + DCameraHDFEvent hdiEvent; + hdiEvent.type_ = events->eventType_; + hdiEvent.result_ = events->eventResult_; + hdiEvent.content_ = events->eventContent_; + int32_t retHdi = camHdiProvider->Notify(dhBase, hdiEvent); DHLOGI("Nofify hal, ret: %d, devId: %s dhId: %s, type: %d, result: %d, content: %s", retHdi, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), events->eventType_, events->eventResult_, events->eventContent_.c_str()); @@ -446,7 +446,7 @@ void DCameraSourceController::OnDataReceived(std::vector camHdiProvider = IDCameraProvider::Get(); + sptr camHdiProvider = IDCameraProvider::Get(HDF_DCAMERA_EXT_SERVICE); if (camHdiProvider == nullptr) { DHLOGI("DCameraSourceController HandleMetaDataResult camHdiProvider is null, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -459,11 +459,14 @@ void DCameraSourceController::HandleMetaDataResult(std::string& jsonStr) GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); return; } - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = devId_; - dhBase->dhId_ = dhId_; + DHBase dhBase; + dhBase.deviceId_ = devId_; + dhBase.dhId_ = dhId_; for (auto iter = cmd.value_.begin(); iter != cmd.value_.end(); iter++) { - DCamRetCode retHdi = camHdiProvider->OnSettingsResult(dhBase, (*iter)); + DCameraSettings setting; + setting.type_ = (*iter)->type_; + setting.value_ = (*iter)->value_; + int32_t retHdi = camHdiProvider->OnSettingsResult(dhBase, setting); DHLOGI("OnSettingsResult hal, ret: %d, devId: %s dhId: %s, type: %d, result: %d, content: %s", retHdi, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); } diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp index 3e5a683..0e13b19 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/dcamera_stream_data_process_producer.cpp @@ -19,6 +19,7 @@ #include #include "anonymous_string.h" +#include "dcamera_buffer_handle.h" #include "distributed_camera_constants.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" @@ -111,9 +112,9 @@ void DCameraStreamDataProcessProducer::LooperContinue() { DHLOGI("LooperContinue producer devId: %s dhId: %s streamType: %d streamId: %d state: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamType_, streamId_, state_); - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = devId_; - dhBase->dhId_ = dhId_; + DHBase dhBase; + dhBase.deviceId_ = devId_; + dhBase.dhId_ = dhId_; while (state_ == DCAMERA_PRODUCER_STATE_START) { std::shared_ptr buffer = nullptr; @@ -154,9 +155,9 @@ void DCameraStreamDataProcessProducer::LooperSnapShot() { DHLOGI("LooperSnapShot producer devId: %s dhId: %s streamType: %d streamId: %d state: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamType_, streamId_, state_); - std::shared_ptr dhBase = std::make_shared(); - dhBase->deviceId_ = devId_; - dhBase->dhId_ = dhId_; + DHBase dhBase; + dhBase.deviceId_ = devId_; + dhBase.dhId_ = dhId_; while (state_ == DCAMERA_PRODUCER_STATE_START) { std::shared_ptr buffer = nullptr; @@ -195,61 +196,79 @@ void DCameraStreamDataProcessProducer::LooperSnapShot() GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamType_, streamId_, state_); } -int32_t DCameraStreamDataProcessProducer::FeedStreamToDriver(const std::shared_ptr& dhBase, +int32_t DCameraStreamDataProcessProducer::FeedStreamToDriver(const DHBase& dhBase, const std::shared_ptr& buffer) { DHLOGD("LooperFeed devId %s dhId %s streamSize: %d streamType: %d, streamId: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), buffer->Size(), streamType_, streamId_); - sptr camHdiProvider = IDCameraProvider::Get(); + sptr camHdiProvider = IDCameraProvider::Get(HDF_DCAMERA_EXT_SERVICE); if (camHdiProvider == nullptr) { DHLOGI("camHdiProvider is nullptr"); return DCAMERA_BAD_VALUE; } - std::shared_ptr sharedMemory; - DCamRetCode retHdi = camHdiProvider->AcquireBuffer(dhBase, streamId_, sharedMemory); - if (retHdi != SUCCESS) { + DCameraBuffer sharedMemory; + int32_t ret = camHdiProvider->AcquireBuffer(dhBase, streamId_, sharedMemory); + if (ret != SUCCESS) { DHLOGE("AcquireBuffer devId: %s dhId: %s streamId: %d ret: %d", - GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, retHdi); + GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, ret); return DCAMERA_BAD_OPERATE; } - int32_t ret = DCAMERA_OK; do { - if (sharedMemory == nullptr) { - DHLOGE("sharedMemory devId: %s dhId: %s streamId: %d, sharedMemory is null", - GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_); + ret = CheckSharedMemory(sharedMemory, buffer); + if (ret != DCAMERA_OK) { + DHLOGE("CheckSharedMemory failed devId: %s dhId: %s", GetAnonyString(devId_).c_str(), + GetAnonyString(dhId_).c_str()); + break; + } + sharedMemory.bufferHandle_->GetBufferHandle()->virAddr = + DCameraMemoryMap(sharedMemory.bufferHandle_->GetBufferHandle()); + if (sharedMemory.bufferHandle_->GetBufferHandle()->virAddr == nullptr) { + DHLOGE("mmap failed devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); ret = DCAMERA_MEMORY_OPT_ERROR; break; } - - if (buffer->Size() > sharedMemory->size_) { - DHLOGE("sharedMemory devId: %s dhId: %s streamId: %d bufSize: %d, addressSize: %d", - GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, buffer->Size(), - sharedMemory->size_); - ret = DCAMERA_MEMORY_OPT_ERROR; - break; - } - ret = memcpy_s(sharedMemory->bufferHandle_->virAddr, sharedMemory->size_, buffer->Data(), + ret = memcpy_s(sharedMemory.bufferHandle_->GetBufferHandle()->virAddr, sharedMemory.size_, buffer->Data(), buffer->Size()); if (ret != EOK) { DHLOGE("memcpy_s devId: %s dhId: %s streamId: %d bufSize: %d, addressSize: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, buffer->Size(), - sharedMemory->size_); + sharedMemory.size_); ret = DCAMERA_MEMORY_OPT_ERROR; break; } - sharedMemory->size_ = buffer->Size(); + sharedMemory.size_ = buffer->Size(); } while (0); - retHdi = camHdiProvider->ShutterBuffer(dhBase, streamId_, sharedMemory); - if (retHdi != SUCCESS) { + ret = camHdiProvider->ShutterBuffer(dhBase, streamId_, sharedMemory); + DCameraMemoryUnmap(sharedMemory.bufferHandle_->GetBufferHandle()); + if (ret != SUCCESS) { DHLOGE("ShutterBuffer devId: %s dhId: %s streamId: %d ret: %d", - GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, retHdi); + GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, ret); return DCAMERA_BAD_OPERATE; } DHLOGD("LooperFeed end devId %s dhId %s streamSize: %d streamType: %d, streamId: %d", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), buffer->Size(), streamType_, streamId_); return ret; } + +int32_t DCameraStreamDataProcessProducer::CheckSharedMemory(const DCameraBuffer& sharedMemory, + const std::shared_ptr& buffer) +{ + if (sharedMemory.bufferHandle_ == nullptr || sharedMemory.bufferHandle_->GetBufferHandle() == nullptr) { + DHLOGE("bufferHandle read failed devId: %s dhId: %s", GetAnonyString(devId_).c_str(), + GetAnonyString(dhId_).c_str()); + return DCAMERA_MEMORY_OPT_ERROR; + } + + if (buffer->Size() > sharedMemory.size_) { + DHLOGE("sharedMemory devId: %s dhId: %s streamId: %d bufSize: %d, addressSize: %d", + GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamId_, buffer->Size(), + sharedMemory.size_); + return DCAMERA_MEMORY_OPT_ERROR; + } + + return DCAMERA_OK; +} } // namespace DistributedHardware } // namespace OHOS diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_hdf_operate.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_hdf_operate.cpp index 5d43b97..97f84ab 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_hdf_operate.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_hdf_operate.cpp @@ -20,7 +20,6 @@ #include "anonymous_string.h" #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" -#include "types.h" namespace OHOS { namespace DistributedHardware { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.cpp index 20d7f30..47cafff 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcamerahdf/dcamera_provider_callback_impl.cpp @@ -22,8 +22,6 @@ #include "distributed_camera_errno.h" #include "distributed_hardware_log.h" -#include "types.h" - namespace OHOS { namespace DistributedHardware { DCameraProviderCallbackImpl::DCameraProviderCallbackImpl(std::string devId, std::string dhId, @@ -39,7 +37,7 @@ DCameraProviderCallbackImpl::~DCameraProviderCallbackImpl() GetAnonyString(dhId_).c_str()); } -DCamRetCode DCameraProviderCallbackImpl::OpenSession(const std::shared_ptr& dhBase) +int32_t DCameraProviderCallbackImpl::OpenSession(const DHBase& dhBase) { DHLOGI("DCameraProviderCallbackImpl OpenSession devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -59,7 +57,7 @@ DCamRetCode DCameraProviderCallbackImpl::OpenSession(const std::shared_ptr& dhBase) +int32_t DCameraProviderCallbackImpl::CloseSession(const DHBase& dhBase) { DHLOGI("DCameraProviderCallbackImpl CloseSession devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -79,8 +77,8 @@ DCamRetCode DCameraProviderCallbackImpl::CloseSession(const std::shared_ptr& dhBase, - const std::vector>& streamInfos) +int32_t DCameraProviderCallbackImpl::ConfigureStreams(const DHBase& dhBase, + const std::vector& streamInfos) { DHLOGI("DCameraProviderCallbackImpl ConfigStreams devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -90,7 +88,20 @@ DCamRetCode DCameraProviderCallbackImpl::ConfigureStreams(const std::shared_ptr< GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); return FAILED; } - int32_t ret = sourceDev->ConfigStreams(streamInfos); + std::vector> streams; + for (auto iter = streamInfos.begin(); iter != streamInfos.end(); iter++) { + std::shared_ptr stream = std::make_shared(); + stream->streamId_ = iter->streamId_; + stream->width_ = iter->width_; + stream->height_ = iter->height_; + stream->stride_ = iter->stride_; + stream->format_ = iter->format_; + stream->dataspace_ = iter->dataspace_; + stream->encodeType_ = iter->encodeType_; + stream->type_ = iter->type_; + streams.push_back(stream); + } + int32_t ret = sourceDev->ConfigStreams(streams); if (ret != DCAMERA_OK) { DHLOGE("DCameraProviderCallbackImpl CloseSession failed, ret: %d, devId: %s, dhId: %s", ret, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -99,8 +110,7 @@ DCamRetCode DCameraProviderCallbackImpl::ConfigureStreams(const std::shared_ptr< return SUCCESS; } -DCamRetCode DCameraProviderCallbackImpl::ReleaseStreams(const std::shared_ptr& dhBase, - const std::vector& streamIds) +int32_t DCameraProviderCallbackImpl::ReleaseStreams(const DHBase& dhBase, const std::vector& streamIds) { DHLOGI("DCameraProviderCallbackImpl ReleaseStreams devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -119,8 +129,7 @@ DCamRetCode DCameraProviderCallbackImpl::ReleaseStreams(const std::shared_ptr& dhBase, - const std::vector>& captureInfos) +int32_t DCameraProviderCallbackImpl::StartCapture(const DHBase& dhBase, const std::vector& captureInfos) { DHLOGI("DCameraProviderCallbackImpl StartCapture devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -130,7 +139,23 @@ DCamRetCode DCameraProviderCallbackImpl::StartCapture(const std::shared_ptrStartCapture(captureInfos); + + std::vector> captures; + for (auto iter = captureInfos.begin(); iter != captureInfos.end(); iter++) { + std::shared_ptr capture = std::make_shared(); + capture->streamIds_.assign(iter->streamIds_.begin(), iter->streamIds_.end()); + capture->width_ = iter->width_; + capture->height_ = iter->height_; + capture->stride_ = iter->stride_; + capture->format_ = iter->format_; + capture->dataspace_ = iter->dataspace_; + capture->isCapture_ = iter->isCapture_; + capture->encodeType_ = iter->encodeType_; + capture->type_ = iter->type_; + capture->captureSettings_.assign(iter->captureSettings_.begin(), iter->captureSettings_.end()); + captures.push_back(capture); + } + int32_t ret = sourceDev->StartCapture(captures); if (ret != DCAMERA_OK) { DHLOGE("DCameraProviderCallbackImpl StartCapture failed, ret: %d, devId: %s, dhId: %s", ret, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -139,8 +164,7 @@ DCamRetCode DCameraProviderCallbackImpl::StartCapture(const std::shared_ptr& dhBase, - const std::vector& streamIds) +int32_t DCameraProviderCallbackImpl::StopCapture(const DHBase& dhBase, const std::vector& streamIds) { DHLOGI("DCameraProviderCallbackImpl StopCapture devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -159,8 +183,7 @@ DCamRetCode DCameraProviderCallbackImpl::StopCapture(const std::shared_ptr& dhBase, - const std::vector>& settings) +int32_t DCameraProviderCallbackImpl::UpdateSettings(const DHBase& dhBase, const std::vector& settings) { DHLOGI("DCameraProviderCallbackImpl UpdateSettings devId: %s dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); @@ -170,7 +193,15 @@ DCamRetCode DCameraProviderCallbackImpl::UpdateSettings(const std::shared_ptrUpdateCameraSettings(settings); + + std::vector> settingInfos; + for (auto iter = settings.begin(); iter != settings.end(); iter++) { + std::shared_ptr settingInfo = std::make_shared(); + settingInfo->type_ = iter->type_; + settingInfo->value_ = iter->value_; + settingInfos.push_back(settingInfo); + } + int32_t ret = sourceDev->UpdateCameraSettings(settingInfos); if (ret != DCAMERA_OK) { DHLOGE("DCameraProviderCallbackImpl UpdateSettings failed, ret: %d, devId: %s, dhId: %s", ret, GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); diff --git a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/BUILD.gn b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/BUILD.gn index 8cf06cf..d35c5f7 100644 --- a/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/BUILD.gn +++ b/services/cameraservice/sourceservice/test/unittest/common/distributedcameramgr/BUILD.gn @@ -46,7 +46,6 @@ config("module_private_config") { "${fwk_utils_path}/include/eventbus", "${fwk_common_path}/utils/include", "${fwk_common_path}/log/include", - "${distributedcamera_hdf_path}/interfaces/include", "${distributedcamera_hdf_path}/interfaces/hdi_ipc/client/provider", "//utils/native/base/include", "//utils/system/safwk/native/include", @@ -73,6 +72,7 @@ ohos_unittest("DCameraSourceMgrTest") { ] external_deps = [ + "distributed_camera_device_driver_interface:libdistributed_camera_provider_proxy_1.0", "dsoftbus_standard:softbus_client", "eventhandler:libeventhandler", "hiviewdfx_hilog_native:libhilog",