1 /*
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 #include "SurroundViewService.h"
18
19 #include <utils/Log.h>
20
21 namespace android {
22 namespace hardware {
23 namespace automotive {
24 namespace sv {
25 namespace V1_0 {
26 namespace implementation {
27
28 const std::string kCameraIds[] = {"0", "1", "2", "3"};
29
getCameraIds(getCameraIds_cb _hidl_cb)30 Return<void> SurroundViewService::getCameraIds(getCameraIds_cb _hidl_cb) {
31 std::vector<hidl_string> cameraIds = {kCameraIds[0], kCameraIds[1],
32 kCameraIds[2], kCameraIds[3]};
33 _hidl_cb(cameraIds);
34 return android::hardware::Void();
35 }
36
start2dSession(start2dSession_cb _hidl_cb)37 Return<void> SurroundViewService::start2dSession(start2dSession_cb _hidl_cb) {
38 ALOGD("SurroundViewService::start2dSession");
39 if (mSurroundView2dSession != nullptr) {
40 ALOGW("Only one 2d session is supported at the same time");
41 _hidl_cb(nullptr, SvResult::INTERNAL_ERROR);
42 } else {
43 mSurroundView2dSession = new SurroundView2dSession();
44 _hidl_cb(mSurroundView2dSession, SvResult::OK);
45 }
46 return android::hardware::Void();
47 }
48
stop2dSession(const sp<ISurroundView2dSession> & sv2dSession)49 Return<SvResult> SurroundViewService::stop2dSession(
50 const sp<ISurroundView2dSession>& sv2dSession) {
51 ALOGD("SurroundViewService::stop2dSession");
52 if (sv2dSession != nullptr && sv2dSession == mSurroundView2dSession) {
53 mSurroundView2dSession = nullptr;
54 return SvResult::OK;
55 } else {
56 ALOGE("Invalid arg for stop2dSession");
57 return SvResult::INVALID_ARG;
58 }
59 }
60
start3dSession(start3dSession_cb _hidl_cb)61 Return<void> SurroundViewService::start3dSession(start3dSession_cb _hidl_cb) {
62 ALOGD("SurroundViewService::start3dSession");
63 if (mSurroundView3dSession != nullptr) {
64 ALOGW("Only one 3d session is supported at the same time");
65 _hidl_cb(nullptr, SvResult::INTERNAL_ERROR);
66 } else {
67 mSurroundView3dSession = new SurroundView3dSession();
68 _hidl_cb(mSurroundView3dSession, SvResult::OK);
69 }
70 return android::hardware::Void();
71 }
72
stop3dSession(const sp<ISurroundView3dSession> & sv3dSession)73 Return<SvResult> SurroundViewService::stop3dSession(
74 const sp<ISurroundView3dSession>& sv3dSession) {
75 ALOGD("SurroundViewService::stop3dSession");
76 if (sv3dSession != nullptr && sv3dSession == mSurroundView3dSession) {
77 mSurroundView3dSession = nullptr;
78 return SvResult::OK;
79 } else {
80 ALOGE("Invalid arg for stop3dSession");
81 return SvResult::INVALID_ARG;
82 }
83 }
84
85 } // namespace implementation
86 } // namespace V1_0
87 } // namespace sv
88 } // namespace automotive
89 } // namespace hardware
90 } // namespace android
91
92