• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef COMPUTEPIPE_RUNNER_INPUT_MANAGER_INCLUDE_EVSINPUTMANAGER_H_
15 #define COMPUTEPIPE_RUNNER_INPUT_MANAGER_INCLUDE_EVSINPUTMANAGER_H_
16 
17 #include <memory>
18 #include <shared_mutex>
19 #include <unordered_map>
20 #include <vector>
21 
22 #include "AnalyzeUseCase.h"
23 #include "BaseAnalyzeCallback.h"
24 #include "InputConfig.pb.h"
25 #include "InputEngineInterface.h"
26 #include "InputManager.h"
27 #include "RunnerComponent.h"
28 #include "types/Status.h"
29 
30 namespace android {
31 namespace automotive {
32 namespace computepipe {
33 namespace runner {
34 namespace input_manager {
35 
36 // Class that is used as a callback for EVS camera streams.
37 class AnalyzeCallback : public ::android::automotive::evs::support::BaseAnalyzeCallback {
38   public:
AnalyzeCallback(int inputStreamId)39     AnalyzeCallback(int inputStreamId) : mInputStreamId(inputStreamId) {
40     }
41 
42     void analyze(const ::android::automotive::evs::support::Frame&) override;
43 
44     void setEngineInterface(std::shared_ptr<InputEngineInterface> inputEngineInterface);
45 
~AnalyzeCallback()46     virtual ~AnalyzeCallback(){};
47 
48   private:
49     std::shared_ptr<InputEngineInterface> mInputEngineInterface;
50     std::shared_mutex mEngineInterfaceLock;
51     const int mInputStreamId;
52 };
53 
54 class EvsInputManager : public InputManager {
55   public:
56     explicit EvsInputManager(const proto::InputConfig& inputConfig,
57                              std::shared_ptr<InputEngineInterface> inputEngineInterface);
58 
59     static std::unique_ptr<EvsInputManager> createEvsInputManager(
60             const proto::InputConfig& inputConfig, const proto::InputConfig& overrideConfig,
61             std::shared_ptr<InputEngineInterface> inputEngineInterface);
62 
63     Status initializeCameras();
64 
65     Status handleExecutionPhase(const RunnerEvent& e) override;
66 
67     Status handleStopImmediatePhase(const RunnerEvent& e) override;
68 
69     Status handleStopWithFlushPhase(const RunnerEvent& e) override;
70 
71     Status handleResetPhase(const RunnerEvent& e) override;
72 
73   private:
74     std::unordered_map<int, ::android::automotive::evs::support::AnalyzeUseCase> mEvsUseCases;
75     std::vector<std::unique_ptr<AnalyzeCallback>> mAnalyzeCallbacks;
76     std::shared_ptr<InputEngineInterface> mInputEngineInterface;
77     const proto::InputConfig mInputConfig;
78 };
79 
80 }  // namespace input_manager
81 }  // namespace runner
82 }  // namespace computepipe
83 }  // namespace automotive
84 }  // namespace android
85 
86 #endif  // COMPUTEPIPE_RUNNER_INPUT_MANAGER_INCLUDE_EVSINPUTMANAGER_H_
87