已合并
feat: add buffer handle sequenceable for idl #595
hobbycao创建于 2022年6月6日
feat: add buffer handle sequenceable for idl #595
已合并
从refs/pull/595/head合入到master
共 3 个文件变更+159-0
| @@ -0,0 +1,38 @@ | |||
| 1 | +# Copyright (c) 2022 Huawei Device Co., Ltd. | ||
| 2 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 3 | +# you may not use this file except in compliance with the License. | ||
| 4 | +# You may obtain a copy of the License at | ||
| 5 | +# | ||
| 6 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
| 7 | +# | ||
| 8 | +# Unless required by applicable law or agreed to in writing, software | ||
| 9 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
| 10 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 11 | +# See the License for the specific language governing permissions and | ||
| 12 | +# limitations under the License. | ||
| 13 | + | ||
| 14 | +import("//build/ohos.gni") | ||
| 15 | +import("//drivers/adapter/uhdf2/uhdf.gni") | ||
| 16 | + | ||
| 17 | +config("buffer_handle_sequenceable_config") { | ||
| 18 | + include_dirs = [ | ||
| 19 | + "./", | ||
| 20 | + "//drivers/peripheral/base", | ||
| 21 | + ] | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +ohos_shared_library("libbuffer_handle_sequenceable_1.0") { | ||
| 25 | + sources = [ "buffer_handle_sequenceable.cpp" ] | ||
| 26 | + | ||
| 27 | + public_configs = [ ":buffer_handle_sequenceable_config" ] | ||
| 28 | + | ||
| 29 | + external_deps = [ | ||
| 30 | + "graphic_chipsetsdk:buffer_handle", | ||
| 31 | + "ipc:ipc_single", | ||
| 32 | + "utils_base:utils", | ||
| 33 | + ] | ||
| 34 | + | ||
| 35 | + install_images = [ chipset_base_dir ] | ||
| 36 | + subsystem_name = "hdf" | ||
| 37 | + part_name = "distributed_camera_device_driver" | ||
| 38 | +} | ||
| @@ -0,0 +1,71 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2022 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +namespace OHOS { | ||
| 22 | +namespace HDI { | ||
| 23 | +namespace Sequenceable { | ||
| 24 | +namespace V1_0 { | ||
| 25 | +BufferHandleSequenceable::BufferHandleSequenceable() : bufferHandle_(nullptr) | ||
| 26 | +{ | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +BufferHandleSequenceable::BufferHandleSequenceable(BufferHandle *bufferHandle) | ||
| 30 | + : bufferHandle_(bufferHandle) | ||
| 31 | +{ | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +BufferHandleSequenceable::~BufferHandleSequenceable() | ||
| 35 | +{ | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +bool BufferHandleSequenceable::Marshalling(Parcel &parcel) const | ||
| 39 | +{ | ||
| 40 | + if (bufferHandle_ == nullptr) { | ||
| 41 | + return false; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + MessageParcel &reply = static_cast<MessageParcel&>(parcel); | ||
| 45 | + return WriteBufferHandle(reply, *bufferHandle_); | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +sptr<BufferHandleSequenceable> BufferHandleSequenceable::Unmarshalling(Parcel &parcel) | ||
| 49 | +{ | ||
| 50 | + MessageParcel &data = static_cast<MessageParcel&>(parcel); | ||
| 51 | + BufferHandle *bufferHandle = ReadBufferHandle(data); | ||
| 52 | + if (bufferHandle == nullptr) { | ||
| 53 | + return nullptr; | ||
| 54 | + } | ||
| 55 | + sptr<BufferHandleSequenceable> bufferHandleSeq = new BufferHandleSequenceable(bufferHandle); | ||
| 56 | + return bufferHandleSeq; | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +BufferHandle *BufferHandleSequenceable::GetBufferHandle() | ||
| 60 | +{ | ||
| 61 | + return bufferHandle_; | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +void BufferHandleSequenceable::SetBufferHandle(BufferHandle *bufferHandle) | ||
| 65 | +{ | ||
| 66 | + bufferHandle_ = bufferHandle; | ||
| 67 | +} | ||
| 68 | +} // namespace V1_0 | ||
| 69 | +} // namespace Sequenceable | ||
| 70 | +} // namespace HDI | ||
| 71 | +} // namespace OHOS | ||
| @@ -0,0 +1,50 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2022 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | +namespace OHOS { | ||
| 24 | +namespace HDI { | ||
| 25 | +namespace Sequenceable { | ||
| 26 | +namespace V1_0 { | ||
| 27 | +using OHOS::Parcelable; | ||
| 28 | +using OHOS::Parcel; | ||
| 29 | +using OHOS::sptr; | ||
| 30 | + | ||
| 31 | +class BufferHandleSequenceable : public Parcelable { | ||
| 32 | +public: | ||
| 33 | + BufferHandleSequenceable(); | ||
| 34 | + explicit BufferHandleSequenceable(BufferHandle *bufferHandle); | ||
| 35 | + virtual ~BufferHandleSequenceable(); | ||
| 36 | + | ||
| 37 | + bool Marshalling(Parcel &parcel) const override; | ||
| 38 | + static sptr<BufferHandleSequenceable> Unmarshalling(Parcel &parcel); | ||
| 39 | + | ||
| 40 | + BufferHandle *GetBufferHandle(); | ||
| 41 | + void SetBufferHandle(BufferHandle *bufferHandle); | ||
| 42 | + | ||
| 43 | +private: | ||
| 44 | + BufferHandle *bufferHandle_; | ||
| 45 | +}; | ||
| 46 | +} // namespace V1_0 | ||
| 47 | +} // namespace Sequenceable | ||
| 48 | +} // namespace HDI | ||
| 49 | +} // namespace OHOS | ||
| 50 | + | ||