blob: bbea0b11ba828000af30920933921a4c845ed2ca [file] [log] [blame]
Hanumant Singhb0170002020-01-19 17:19:33 -08001// Copyright 2020 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14#include <android-base/logging.h>
15#include <android/binder_process.h>
16#include <utils/Errors.h>
17#include <utils/Log.h>
18
19#include <iostream>
20#include <memory>
21#include <thread>
22
23#include "ClientConfig.pb.h"
24#include "ClientInterface.h"
25#include "MemHandle.h"
26#include "Options.pb.h"
27#include "PrebuiltGraph.h"
28#include "RunnerEngine.h"
29#include "types/Status.h"
30
31using android::automotive::computepipe::Status;
32using android::automotive::computepipe::graph::PrebuiltGraph;
33using android::automotive::computepipe::proto::ClientConfig;
34using android::automotive::computepipe::proto::Options;
35using android::automotive::computepipe::runner::client_interface::ClientInterface;
36using android::automotive::computepipe::runner::client_interface::ClientInterfaceFactory;
37using android::automotive::computepipe::runner::engine::RunnerEngine;
38using android::automotive::computepipe::runner::engine::RunnerEngineFactory;
39
40namespace {
41RunnerEngineFactory sEngineFactory;
42ClientInterfaceFactory sClientFactory;
43} // namespace
44void terminate(bool isError, std::string msg) {
45 if (isError) {
46 LOG(ERROR) << "Error msg " << msg;
47 exit(2);
48 }
49 LOG(ERROR) << "Test complete";
50 exit(0);
51}
52
53int main(int /* argc */, char** /* argv */) {
54 std::shared_ptr<RunnerEngine> engine =
Yogeshwar Nagarajf8c8d182020-04-01 13:09:08 -070055 sEngineFactory.createRunnerEngine(RunnerEngineFactory::kDefault, "");
Hanumant Singhb0170002020-01-19 17:19:33 -080056
57 std::unique_ptr<PrebuiltGraph> graph;
Yogeshwar Nagarajf8c8d182020-04-01 13:09:08 -070058 graph.reset(android::automotive::computepipe::graph::GetLocalGraphFromLibrary("libfacegraph.so",
59 engine));
Hanumant Singhb0170002020-01-19 17:19:33 -080060
61 Options options = graph->GetSupportedGraphConfigs();
62 engine->setPrebuiltGraph(std::move(graph));
63
64 std::function<void(bool, std::string)> cb = terminate;
65 std::unique_ptr<ClientInterface> client =
66 sClientFactory.createClientInterface("aidl", options, engine);
67 if (!client) {
68 std::cerr << "Unable to allocate client";
69 return -1;
70 }
71 engine->setClientInterface(std::move(client));
72 ABinderProcess_startThreadPool();
73 engine->activate();
74 ABinderProcess_joinThreadPool();
75 return 0;
76}