Hanumant Singh | b017000 | 2020-01-19 17:19:33 -0800 | [diff] [blame^] | 1 | // 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 | |
| 31 | using android::automotive::computepipe::Status; |
| 32 | using android::automotive::computepipe::graph::PrebuiltGraph; |
| 33 | using android::automotive::computepipe::proto::ClientConfig; |
| 34 | using android::automotive::computepipe::proto::Options; |
| 35 | using android::automotive::computepipe::runner::client_interface::ClientInterface; |
| 36 | using android::automotive::computepipe::runner::client_interface::ClientInterfaceFactory; |
| 37 | using android::automotive::computepipe::runner::engine::RunnerEngine; |
| 38 | using android::automotive::computepipe::runner::engine::RunnerEngineFactory; |
| 39 | |
| 40 | namespace { |
| 41 | RunnerEngineFactory sEngineFactory; |
| 42 | ClientInterfaceFactory sClientFactory; |
| 43 | } // namespace |
| 44 | void 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 | |
| 53 | int main(int /* argc */, char** /* argv */) { |
| 54 | std::shared_ptr<RunnerEngine> engine = |
| 55 | sEngineFactory.createRunnerEngine(RunnerEngineFactory::kDefault, ""); |
| 56 | |
| 57 | std::unique_ptr<PrebuiltGraph> graph; |
| 58 | graph.reset(PrebuiltGraph::GetPrebuiltGraphFromLibrary("libfacegraph.so", engine)); |
| 59 | |
| 60 | Options options = graph->GetSupportedGraphConfigs(); |
| 61 | engine->setPrebuiltGraph(std::move(graph)); |
| 62 | |
| 63 | std::function<void(bool, std::string)> cb = terminate; |
| 64 | std::unique_ptr<ClientInterface> client = |
| 65 | sClientFactory.createClientInterface("aidl", options, engine); |
| 66 | if (!client) { |
| 67 | std::cerr << "Unable to allocate client"; |
| 68 | return -1; |
| 69 | } |
| 70 | engine->setClientInterface(std::move(client)); |
| 71 | ABinderProcess_startThreadPool(); |
| 72 | engine->activate(); |
| 73 | ABinderProcess_joinThreadPool(); |
| 74 | return 0; |
| 75 | } |