blob: 67aa8764a23d18eb1baeae104af180131660198d [file] [log] [blame]
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -08001/*
2 * Copyright (C) 2020 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_NDEBUG 0
18#define LOG_TAG "ConcurrentCamera"
19#include <utils/Log.h>
20#include <utils/String16.h>
21
22#include <camera/camera2/ConcurrentCamera.h>
Austin Borger1c1bee02023-06-01 16:51:35 -070023#include <camera/StringUtils.h>
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -080024
25#include <binder/Parcel.h>
26
27namespace android {
28namespace hardware {
29namespace camera2 {
30namespace utils {
31
32ConcurrentCameraIdCombination::ConcurrentCameraIdCombination() = default;
33
34ConcurrentCameraIdCombination::ConcurrentCameraIdCombination(
35 std::vector<std::string> &&combination) : mConcurrentCameraIds(std::move(combination)) { }
36
37ConcurrentCameraIdCombination::~ConcurrentCameraIdCombination() = default;
38
39status_t ConcurrentCameraIdCombination::readFromParcel(const android::Parcel* parcel) {
40 if (parcel == nullptr) {
41 ALOGE("%s: Null parcel", __FUNCTION__);
42 return BAD_VALUE;
43 }
44 status_t err = OK;
45 mConcurrentCameraIds.clear();
46 int32_t cameraIdCount = 0;
47 if ((err = parcel->readInt32(&cameraIdCount)) != OK) {
48 ALOGE("%s: Failed to read the camera id count from parcel: %d", __FUNCTION__, err);
49 return err;
50 }
51 for (int32_t i = 0; i < cameraIdCount; i++) {
52 String16 id;
53 if ((err = parcel->readString16(&id)) != OK) {
54 ALOGE("%s: Failed to read camera id!", __FUNCTION__);
55 return err;
56 }
Austin Borger1c1bee02023-06-01 16:51:35 -070057 mConcurrentCameraIds.push_back(toStdString(id));
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -080058 }
59 return OK;
60}
61
62status_t ConcurrentCameraIdCombination::writeToParcel(android::Parcel* parcel) const {
63
64 if (parcel == nullptr) {
65 ALOGE("%s: Null parcel", __FUNCTION__);
66 return BAD_VALUE;
67 }
68
69 status_t err = OK;
70
71 if ((err = parcel->writeInt32(mConcurrentCameraIds.size())) != OK) {
72 ALOGE("%s: Failed to write the camera id count to parcel: %d", __FUNCTION__, err);
73 return err;
74 }
75
76 for (const auto &it : mConcurrentCameraIds) {
Austin Borger1c1bee02023-06-01 16:51:35 -070077 if ((err = parcel->writeString16(toString16(it))) != OK) {
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -080078 ALOGE("%s: Failed to write the camera id string to parcel: %d", __FUNCTION__, err);
79 return err;
80 }
81 }
82 return OK;
83}
84
85CameraIdAndSessionConfiguration::CameraIdAndSessionConfiguration() = default;
86CameraIdAndSessionConfiguration::~CameraIdAndSessionConfiguration() = default;
87
88status_t CameraIdAndSessionConfiguration::readFromParcel(const android::Parcel* parcel) {
89 if (parcel == nullptr) {
90 ALOGE("%s: Null parcel", __FUNCTION__);
91 return BAD_VALUE;
92 }
93 status_t err = OK;
94 String16 id;
95 if ((err = parcel->readString16(&id)) != OK) {
96 ALOGE("%s: Failed to read camera id!", __FUNCTION__);
97 return err;
98 }
99 if ((err = mSessionConfiguration.readFromParcel(parcel)) != OK) {
100 ALOGE("%s: Failed to read sessionConfiguration!", __FUNCTION__);
101 return err;
102 }
Austin Borger1c1bee02023-06-01 16:51:35 -0700103 mCameraId = toStdString(id);
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800104 return OK;
105}
106
107status_t CameraIdAndSessionConfiguration::writeToParcel(android::Parcel* parcel) const {
108
109 if (parcel == nullptr) {
110 ALOGE("%s: Null parcel", __FUNCTION__);
111 return BAD_VALUE;
112 }
113
114 status_t err = OK;
Austin Borger1c1bee02023-06-01 16:51:35 -0700115 if ((err = parcel->writeString16(toString16(mCameraId))) != OK) {
Jayant Chowdhary2bbdce42020-01-12 14:55:41 -0800116 ALOGE("%s: Failed to write camera id!", __FUNCTION__);
117 return err;
118 }
119
120 if ((err = mSessionConfiguration.writeToParcel(parcel) != OK)) {
121 ALOGE("%s: Failed to write session configuration!", __FUNCTION__);
122 return err;
123 }
124 return OK;
125}
126
127} // namespace utils
128} // namespace camera2
129} // namespace hardware
130} // namespace android