• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
isValid()25 bool CaptureResultExtras::isValid() {
26     return requestId >= 0;
27 }
28 
readFromParcel(const Parcel * parcel)29 status_t CaptureResultExtras::readFromParcel(const 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     parcel->readInt32(&errorStreamId);
42 
43     return OK;
44 }
45 
writeToParcel(Parcel * parcel) const46 status_t CaptureResultExtras::writeToParcel(Parcel *parcel) const {
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);
57     parcel->writeInt32(partialResultCount);
58     parcel->writeInt32(errorStreamId);
59 
60     return OK;
61 }
62 
CaptureResult()63 CaptureResult::CaptureResult() :
64         mMetadata(), mResultExtras() {
65 }
66 
CaptureResult(const CaptureResult & otherResult)67 CaptureResult::CaptureResult(const CaptureResult &otherResult) {
68     mResultExtras = otherResult.mResultExtras;
69     mMetadata = otherResult.mMetadata;
70 }
71 
readFromParcel(Parcel * parcel)72 status_t CaptureResult::readFromParcel(Parcel *parcel) {
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 
writeToParcel(Parcel * parcel) const103 status_t CaptureResult::writeToParcel(Parcel *parcel) const {
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 }
132