CaptureResult.cpp revision cb0652e5a850b2fcd919e977247e87239efaf70e
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 23namespace android { 24 25bool CaptureResultExtras::isValid() { 26 return requestId >= 0; 27} 28 29status_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 41 return OK; 42} 43 44status_t CaptureResultExtras::writeToParcel(Parcel *parcel) const { 45 if (parcel == NULL) { 46 ALOGE("%s: Null parcel", __FUNCTION__); 47 return BAD_VALUE; 48 } 49 50 parcel->writeInt32(requestId); 51 parcel->writeInt32(burstId); 52 parcel->writeInt32(afTriggerId); 53 parcel->writeInt32(precaptureTriggerId); 54 parcel->writeInt64(frameNumber); 55 56 return OK; 57} 58 59CaptureResult::CaptureResult() : 60 mMetadata(), mResultExtras() { 61} 62 63CaptureResult::CaptureResult(const CaptureResult &otherResult) { 64 mResultExtras = otherResult.mResultExtras; 65 mMetadata = otherResult.mMetadata; 66} 67 68status_t CaptureResult::readFromParcel(Parcel *parcel) { 69 70 ALOGV("%s: parcel = %p", __FUNCTION__, parcel); 71 72 if (parcel == NULL) { 73 ALOGE("%s: parcel is null", __FUNCTION__); 74 return BAD_VALUE; 75 } 76 77 mMetadata.clear(); 78 79 status_t res = OK; 80 res = mMetadata.readFromParcel(parcel); 81 if (res != OK) { 82 ALOGE("%s: Failed to read metadata from parcel.", 83 __FUNCTION__); 84 return res; 85 } 86 ALOGV("%s: Read metadata from parcel", __FUNCTION__); 87 88 res = mResultExtras.readFromParcel(parcel); 89 if (res != OK) { 90 ALOGE("%s: Failed to read result extras from parcel.", 91 __FUNCTION__); 92 return res; 93 } 94 ALOGV("%s: Read result extras from parcel", __FUNCTION__); 95 96 return OK; 97} 98 99status_t CaptureResult::writeToParcel(Parcel *parcel) const { 100 101 ALOGV("%s: parcel = %p", __FUNCTION__, parcel); 102 103 if (parcel == NULL) { 104 ALOGE("%s: parcel is null", __FUNCTION__); 105 return BAD_VALUE; 106 } 107 108 status_t res; 109 110 res = mMetadata.writeToParcel(parcel); 111 if (res != OK) { 112 ALOGE("%s: Failed to write metadata to parcel", __FUNCTION__); 113 return res; 114 } 115 ALOGV("%s: Wrote metadata to parcel", __FUNCTION__); 116 117 res = mResultExtras.writeToParcel(parcel); 118 if (res != OK) { 119 ALOGE("%s: Failed to write result extras to parcel", __FUNCTION__); 120 return res; 121 } 122 ALOGV("%s: Wrote result extras to parcel", __FUNCTION__); 123 124 return OK; 125} 126 127} 128