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