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 #include "buffer_producer_sequenceable.h" 17 18 #include "hdi_log.h" 19 #include <message_parcel.h> 20 21 namespace OHOS { 22 namespace HDI { 23 namespace Camera { 24 namespace V1_0 { Marshalling(Parcel & parcel) const25bool BufferProducerSequenceable::Marshalling(Parcel &parcel) const 26 { 27 if (producer_ == nullptr) { 28 return false; 29 } 30 31 OHOS::MessageParcel &dataParcel = static_cast<OHOS::MessageParcel &>(parcel); 32 33 if (!dataParcel.WriteRemoteObject(producer_->AsObject())) { 34 return false; 35 } 36 37 return true; 38 } 39 Unmarshalling(Parcel & parcel)40sptr<BufferProducerSequenceable> BufferProducerSequenceable::Unmarshalling(Parcel &parcel) 41 { 42 sptr<BufferProducerSequenceable> sequenceData(new BufferProducerSequenceable()); 43 44 OHOS::MessageParcel &dataParcel = static_cast<OHOS::MessageParcel &>(parcel); 45 46 sptr<IRemoteObject> remoteObj = dataParcel.ReadRemoteObject(); 47 if (remoteObj == nullptr) { 48 HDI_CAMERA_LOGE("Remote object is null."); 49 return nullptr; 50 } 51 sptr<OHOS::IBufferProducer> bufferProducer = OHOS::iface_cast<OHOS::IBufferProducer>(remoteObj); 52 sequenceData->producer_ = bufferProducer; 53 54 return sequenceData; 55 } 56 operator =(const BufferProducerSequenceable & other)57BufferProducerSequenceable &BufferProducerSequenceable::operator=(const BufferProducerSequenceable &other) 58 { 59 if (&other != this) { 60 producer_ = other.producer_; 61 } 62 return *this; 63 } 64 } // V1_0 65 } // Camera 66 } // HDI 67 } // OHOS 68