1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #define LOG_TAG "Camera-CaptureResult" 18 #include <utils/Log.h> 19 20 #include <camera/CaptureResult.h> 21 #include <binder/Parcel.h> 22 23 namespace android { 24 25 bool CaptureResultExtras::isValid() { 26 return requestId >= 0; 27 } 28 29 status_t CaptureResultExtras::readFromParcel(Parcel *parcel) { 30 if (parcel == NULL) { 31 ALOGE("%s: Null parcel", __FUNCTION__); 32 return BAD_VALUE; 33 } 34 35 parcel->readInt32(&requestId); 36 parcel->readInt32(&burstId); 37 parcel->readInt32(&afTriggerId); 38 parcel->readInt32(&precaptureTriggerId); 39 parcel->readInt64(&frameNumber); 40 parcel->readInt32(&partialResultCount); 41 42 return OK; 43 } 44 45 status_t CaptureResultExtras::writeToParcel(Parcel *parcel) const { 46 if (parcel == NULL) { 47 ALOGE("%s: Null parcel", __FUNCTION__); 48 return BAD_VALUE; 49 } 50 51 parcel->writeInt32(requestId); 52 parcel->writeInt32(burstId); 53 parcel->writeInt32(afTriggerId); 54 parcel->writeInt32(precaptureTriggerId); 55 parcel->writeInt64(frameNumber); 56 parcel->writeInt32(partialResultCount); 57 58 return OK; 59 } 60 61 CaptureResult::CaptureResult() : 62 mMetadata(), mResultExtras() { 63 } 64 65 CaptureResult::CaptureResult(const CaptureResult &otherResult) { 66 mResultExtras = otherResult.mResultExtras; 67 mMetadata = otherResult.mMetadata; 68 } 69 70 status_t CaptureResult::readFromParcel(Parcel *parcel) { 71 72 ALOGV("%s: parcel = %p", __FUNCTION__, parcel); 73 74 if (parcel == NULL) { 75 ALOGE("%s: parcel is null", __FUNCTION__); 76 return BAD_VALUE; 77 } 78 79 mMetadata.clear(); 80 81 status_t res = OK; 82 res = mMetadata.readFromParcel(parcel); 83 if (res != OK) { 84 ALOGE("%s: Failed to read metadata from parcel.", 85 __FUNCTION__); 86 return res; 87 } 88 ALOGV("%s: Read metadata from parcel", __FUNCTION__); 89 90 res = mResultExtras.readFromParcel(parcel); 91 if (res != OK) { 92 ALOGE("%s: Failed to read result extras from parcel.", 93 __FUNCTION__); 94 return res; 95 } 96 ALOGV("%s: Read result extras from parcel", __FUNCTION__); 97 98 return OK; 99 } 100 101 status_t CaptureResult::writeToParcel(Parcel *parcel) const { 102 103 ALOGV("%s: parcel = %p", __FUNCTION__, parcel); 104 105 if (parcel == NULL) { 106 ALOGE("%s: parcel is null", __FUNCTION__); 107 return BAD_VALUE; 108 } 109 110 status_t res; 111 112 res = mMetadata.writeToParcel(parcel); 113 if (res != OK) { 114 ALOGE("%s: Failed to write metadata to parcel", __FUNCTION__); 115 return res; 116 } 117 ALOGV("%s: Wrote metadata to parcel", __FUNCTION__); 118 119 res = mResultExtras.writeToParcel(parcel); 120 if (res != OK) { 121 ALOGE("%s: Failed to write result extras to parcel", __FUNCTION__); 122 return res; 123 } 124 ALOGV("%s: Wrote result extras to parcel", __FUNCTION__); 125 126 return OK; 127 } 128 129 } 130