Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 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 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 29 | status_t CaptureResultExtras::readFromParcel(const android::Parcel *parcel) { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 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); |
Zhijun He | 204e329 | 2014-07-14 17:09:23 -0700 | [diff] [blame] | 40 | parcel->readInt32(&partialResultCount); |
Eino-Ville Talvala | e95bb63 | 2016-03-06 19:55:44 -0800 | [diff] [blame] | 41 | parcel->readInt32(&errorStreamId); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 42 | |
| 43 | return OK; |
| 44 | } |
| 45 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 46 | status_t CaptureResultExtras::writeToParcel(android::Parcel *parcel) const { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 47 | if (parcel == NULL) { |
| 48 | ALOGE("%s: Null parcel", __FUNCTION__); |
| 49 | return BAD_VALUE; |
| 50 | } |
| 51 | |
| 52 | parcel->writeInt32(requestId); |
| 53 | parcel->writeInt32(burstId); |
| 54 | parcel->writeInt32(afTriggerId); |
| 55 | parcel->writeInt32(precaptureTriggerId); |
| 56 | parcel->writeInt64(frameNumber); |
Zhijun He | 204e329 | 2014-07-14 17:09:23 -0700 | [diff] [blame] | 57 | parcel->writeInt32(partialResultCount); |
Eino-Ville Talvala | e95bb63 | 2016-03-06 19:55:44 -0800 | [diff] [blame] | 58 | parcel->writeInt32(errorStreamId); |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 59 | |
| 60 | return OK; |
| 61 | } |
| 62 | |
| 63 | CaptureResult::CaptureResult() : |
| 64 | mMetadata(), mResultExtras() { |
| 65 | } |
| 66 | |
| 67 | CaptureResult::CaptureResult(const CaptureResult &otherResult) { |
| 68 | mResultExtras = otherResult.mResultExtras; |
| 69 | mMetadata = otherResult.mMetadata; |
| 70 | } |
| 71 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 72 | status_t CaptureResult::readFromParcel(android::Parcel *parcel) { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 73 | |
| 74 | ALOGV("%s: parcel = %p", __FUNCTION__, parcel); |
| 75 | |
| 76 | if (parcel == NULL) { |
| 77 | ALOGE("%s: parcel is null", __FUNCTION__); |
| 78 | return BAD_VALUE; |
| 79 | } |
| 80 | |
| 81 | mMetadata.clear(); |
| 82 | |
| 83 | status_t res = OK; |
| 84 | res = mMetadata.readFromParcel(parcel); |
| 85 | if (res != OK) { |
| 86 | ALOGE("%s: Failed to read metadata from parcel.", |
| 87 | __FUNCTION__); |
| 88 | return res; |
| 89 | } |
| 90 | ALOGV("%s: Read metadata from parcel", __FUNCTION__); |
| 91 | |
| 92 | res = mResultExtras.readFromParcel(parcel); |
| 93 | if (res != OK) { |
| 94 | ALOGE("%s: Failed to read result extras from parcel.", |
| 95 | __FUNCTION__); |
| 96 | return res; |
| 97 | } |
| 98 | ALOGV("%s: Read result extras from parcel", __FUNCTION__); |
| 99 | |
| 100 | return OK; |
| 101 | } |
| 102 | |
Eino-Ville Talvala | f51fca2 | 2016-12-13 11:25:55 -0800 | [diff] [blame] | 103 | status_t CaptureResult::writeToParcel(android::Parcel *parcel) const { |
Jianing Wei | cb0652e | 2014-03-12 18:29:36 -0700 | [diff] [blame] | 104 | |
| 105 | ALOGV("%s: parcel = %p", __FUNCTION__, parcel); |
| 106 | |
| 107 | if (parcel == NULL) { |
| 108 | ALOGE("%s: parcel is null", __FUNCTION__); |
| 109 | return BAD_VALUE; |
| 110 | } |
| 111 | |
| 112 | status_t res; |
| 113 | |
| 114 | res = mMetadata.writeToParcel(parcel); |
| 115 | if (res != OK) { |
| 116 | ALOGE("%s: Failed to write metadata to parcel", __FUNCTION__); |
| 117 | return res; |
| 118 | } |
| 119 | ALOGV("%s: Wrote metadata to parcel", __FUNCTION__); |
| 120 | |
| 121 | res = mResultExtras.writeToParcel(parcel); |
| 122 | if (res != OK) { |
| 123 | ALOGE("%s: Failed to write result extras to parcel", __FUNCTION__); |
| 124 | return res; |
| 125 | } |
| 126 | ALOGV("%s: Wrote result extras to parcel", __FUNCTION__); |
| 127 | |
| 128 | return OK; |
| 129 | } |
| 130 | |
| 131 | } |