blob: a7ce6f37920f80b2e269dc5d5aa5f2a87589ef40 [file] [log] [blame]
Haoxiang Lifd727e22020-04-03 23:58:46 +00001/*
2 * Copyright 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#define LOG_TAG "SurroundViewService"
17
18#include <android-base/logging.h>
19#include <android/hardware/automotive/sv/1.0/ISurroundViewStream.h>
20#include <android/hardware_buffer.h>
21#include <hidl/HidlTransportSupport.h>
22#include <thread>
23#include <ui/GraphicBuffer.h>
24#include <utils/Errors.h>
25#include <utils/StrongPointer.h>
26#include <utils/SystemClock.h>
27
28#include "SurroundViewService.h"
29
30// libhidl:
31using android::hardware::configureRpcThreadpool;
32using android::hardware::joinRpcThreadpool;
33
34// implementation:
35using android::hardware::automotive::sv::V1_0::implementation::SurroundViewService;
36
37int main() {
38 LOG(INFO) << "ISurroundViewService default implementation is starting";
39 android::sp<ISurroundViewService> service = SurroundViewService::getInstance();
40
41 configureRpcThreadpool(1, true /* callerWillJoin */);
42
43 // Register our service -- if somebody is already registered by our name,
44 // they will be killed (their thread pool will throw an exception).
45 android::status_t status = service->registerAsService();
46
47 if (status != android::OK) {
48 LOG(ERROR) << "Could not register default Surround View Service. Status: "
49 << status;
50 }
51
52 joinRpcThreadpool();
53
54 // In normal operation, we don't expect the thread pool to exit
55 LOG(ERROR) << "Surround View Service is shutting down";
56 return 1;
57}