blob: 24acaa0bdf2849be45ef7901aeb735c9601f472c [file] [log] [blame]
Yin-Chia Yehb97babb2015-03-12 13:42:44 -07001/*
2**
3** Copyright 2015, The Android Open Source Project
4**
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
8**
9** http://www.apache.org/licenses/LICENSE-2.0
10**
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.
16*/
17
18#define LOG_TAG "OutputConfiguration"
19#include <utils/Log.h>
20
21#include <camera/camera2/OutputConfiguration.h>
22#include <binder/Parcel.h>
23
24namespace android {
25
26
27const int OutputConfiguration::INVALID_ROTATION = -1;
28
29// Read empty strings without printing a false error message.
30String16 OutputConfiguration::readMaybeEmptyString16(const Parcel& parcel) {
31 size_t len;
32 const char16_t* str = parcel.readString16Inplace(&len);
33 if (str != NULL) {
34 return String16(str, len);
35 } else {
36 return String16();
37 }
38}
39
40sp<IGraphicBufferProducer> OutputConfiguration::getGraphicBufferProducer() const {
41 return mGbp;
42}
43
44int OutputConfiguration::getRotation() const {
45 return mRotation;
46}
47
48OutputConfiguration::OutputConfiguration(const Parcel& parcel) {
49 status_t err;
50 int rotation = 0;
51 if ((err = parcel.readInt32(&rotation)) != OK) {
52 ALOGE("%s: Failed to read rotation from parcel", __FUNCTION__);
53 mGbp = NULL;
54 mRotation = INVALID_ROTATION;
55 return;
56 }
57
58 String16 name = readMaybeEmptyString16(parcel);
59 const sp<IGraphicBufferProducer>& gbp =
60 interface_cast<IGraphicBufferProducer>(parcel.readStrongBinder());
61 mGbp = gbp;
62 mRotation = rotation;
63
64 ALOGV("%s: OutputConfiguration: bp = %p, name = %s", __FUNCTION__,
65 gbp.get(), String8(name).string());
66}
67
68status_t OutputConfiguration::writeToParcel(Parcel& parcel) const {
69
70 parcel.writeInt32(mRotation);
71 parcel.writeString16(String16("unknown_name")); // name of surface
72 sp<IBinder> b(IInterface::asBinder(mGbp));
73 parcel.writeStrongBinder(b);
74
75 return OK;
76}
77
78}; // namespace android
79