3 ** Copyright 2013, The Android Open Source Project
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
9 ** http://www.apache.org/licenses/LICENSE-2.0
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
18 // #define LOG_NDEBUG 0
19 #define LOG_TAG "CameraRequest"
20 #include <utils/Log.h>
22 #include <camera/camera2/CaptureRequest.h>
24 #include <binder/Parcel.h>
25 #include <gui/Surface.h>
29 status_t CaptureRequest::readFromParcel(Parcel* parcel) {
31 ALOGE("%s: Null parcel", __FUNCTION__);
40 if ((err = mMetadata.readFromParcel(parcel)) != OK) {
41 ALOGE("%s: Failed to read metadata from parcel", __FUNCTION__);
44 ALOGV("%s: Read metadata from parcel", __FUNCTION__);
47 if ((err = parcel->readInt32(&size)) != OK) {
48 ALOGE("%s: Failed to read surface list size from parcel", __FUNCTION__);
51 ALOGV("%s: Read surface list size = %d", __FUNCTION__, size);
53 // Do not distinguish null arrays from 0-sized arrays.
54 for (int i = 0; i < size; ++i) {
55 // Parcel.writeParcelableArray
57 const char16_t* className = parcel->readString16Inplace(&len);
58 ALOGV("%s: Read surface class = %s", __FUNCTION__,
59 className != NULL ? String8(className).string() : "<null>");
61 if (className == NULL) {
65 // Surface.writeToParcel
66 const char16_t* name = parcel->readString16Inplace(&len);
67 ALOGV("%s: Read surface name = %s", __FUNCTION__,
68 name != NULL ? String8(name).string() : "<null>");
69 sp<IBinder> binder(parcel->readStrongBinder());
70 ALOGV("%s: Read surface binder = %p",
71 __FUNCTION__, binder.get());
76 sp<IGraphicBufferProducer> gbp =
77 interface_cast<IGraphicBufferProducer>(binder);
78 surface = new Surface(gbp);
81 mSurfaceList.push_back(surface);
87 status_t CaptureRequest::writeToParcel(Parcel* parcel) const {
89 ALOGE("%s: Null parcel", __FUNCTION__);
95 if ((err = mMetadata.writeToParcel(parcel)) != OK) {
99 int32_t size = static_cast<int32_t>(mSurfaceList.size());
101 // Send 0-sized arrays when it's empty. Do not send null arrays.
102 parcel->writeInt32(size);
104 for (int32_t i = 0; i < size; ++i) {
105 sp<Surface> surface = mSurfaceList[i];
109 binder = surface->getIGraphicBufferProducer()->asBinder();
112 // not sure if readParcelableArray does this, hard to tell from source
113 parcel->writeString16(String16("android.view.Surface"));
115 // Surface.writeToParcel
116 parcel->writeString16(String16("unknown_name"));
117 // Surface.nativeWriteToParcel
118 parcel->writeStrongBinder(binder);
124 }; // namespace android