• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2019 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 
15 #ifndef COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_AIDLCLIENT_H_
16 #define COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_AIDLCLIENT_H_
17 
18 #include <memory>
19 
20 #include "ClientInterface.h"
21 #include "AidlClientImpl.h"
22 #include "DebuggerImpl.h"
23 
24 namespace android {
25 namespace automotive {
26 namespace computepipe {
27 namespace runner {
28 namespace client_interface {
29 namespace aidl_client {
30 
31 class AidlClient : public ClientInterface {
32   public:
AidlClient(const proto::Options graphOptions,const std::shared_ptr<ClientEngineInterface> & engine)33     explicit AidlClient(const proto::Options graphOptions,
34                         const std::shared_ptr<ClientEngineInterface>& engine)
35             : mGraphOptions(graphOptions), mRunnerEngine(engine) {}
36     /**
37      * Override ClientInterface Functions
38      */
39     Status dispatchPacketToClient(int32_t streamId,
40                                   const std::shared_ptr<MemHandle> packet) override;
41     Status activate() override;
42     Status deliverGraphDebugInfo(const std::string& debugData) override;
43     /**
44      * Override RunnerComponentInterface function
45      */
46     Status handleResetPhase(const RunnerEvent& e) override;
47     Status handleConfigPhase(const ClientConfig& e) override;
48     Status handleExecutionPhase(const RunnerEvent& e) override;
49     Status handleStopWithFlushPhase(const RunnerEvent& e) override;
50     Status handleStopImmediatePhase(const RunnerEvent& e) override;
51 
52     void routerDied();
53 
54     virtual ~AidlClient() = default;
55 
56   private:
57     // Attempt to register pipe runner with router. Returns true on success.
58     // This is a blocking API, calling thread will be blocked until router connection is
59     // established or max attempts are made without success.
60     void tryRegisterPipeRunner();
61     const proto::Options mGraphOptions;
62     std::shared_ptr<AidlClientImpl> mPipeRunner = nullptr;
63     std::shared_ptr<DebuggerImpl> mPipeDebugger = nullptr;
64     std::shared_ptr<ClientEngineInterface> mRunnerEngine;
65 };
66 
67 }  // namespace aidl_client
68 }  // namespace client_interface
69 }  // namespace runner
70 }  // namespace computepipe
71 }  // namespace automotive
72 }  // namespace android
73 #endif  // COMPUTEPIPE_RUNNER_CLIENT_INTERFACE_AIDLCLIENT_H_
74