Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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 | #ifndef CAR_LIB_EVS_SUPPORT_DISPLAY_USECASE_H |
| 17 | #define CAR_LIB_EVS_SUPPORT_DISPLAY_USECASE_H |
| 18 | |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 19 | #include <android/hardware/automotive/evs/1.0/IEvsDisplay.h> |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 20 | |
| 21 | #include <string> |
| 22 | #include <thread> |
| 23 | |
| 24 | #include "BaseRenderCallback.h" |
| 25 | #include "BaseUseCase.h" |
| 26 | #include "ConfigManager.h" |
| 27 | #include "RenderBase.h" |
Haoxiang Li | 5cb6905 | 2019-08-30 16:24:25 -0700 | [diff] [blame] | 28 | #include "StreamHandler.h" |
Haoxiang Li | c888859 | 2019-09-19 16:39:53 -0700 | [diff] [blame] | 29 | #include "ResourceManager.h" |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | namespace automotive { |
| 33 | namespace evs { |
| 34 | namespace support { |
| 35 | |
| 36 | using namespace ::android::hardware::automotive::evs::V1_0; |
| 37 | using ::android::sp; |
| 38 | using ::android::hardware::Return; |
| 39 | using ::std::string; |
| 40 | |
| 41 | // TODO(b/130246434): Think about multi-camera situation. |
| 42 | class DisplayUseCase : public BaseUseCase { |
| 43 | public: |
| 44 | ~DisplayUseCase(); |
Haoxiang Li | 2010d39 | 2019-09-04 14:06:20 -0700 | [diff] [blame] | 45 | bool startVideoStream() override; |
| 46 | void stopVideoStream() override; |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 47 | |
| 48 | // TODO(b/130246434): Add configuration class to create more use case. |
| 49 | static DisplayUseCase createDefaultUseCase(string cameraId, |
| 50 | BaseRenderCallback* cb = nullptr); |
| 51 | |
| 52 | private: |
| 53 | DisplayUseCase(string cameraId, BaseRenderCallback* renderCallback); |
| 54 | |
| 55 | // TODO(b/130246434): Think about whether we should make init public so |
| 56 | // users can call it. |
| 57 | bool initialize(); |
| 58 | bool streamFrame(); |
| 59 | |
| 60 | bool mIsInitialized = false; |
| 61 | BaseRenderCallback* mRenderCallback = nullptr; |
| 62 | std::unique_ptr<RenderBase> mCurrentRenderer; |
| 63 | |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 64 | sp<IEvsDisplay> mDisplay; |
Haoxiang Li | c888859 | 2019-09-19 16:39:53 -0700 | [diff] [blame] | 65 | sp<StreamHandler> mStreamHandler; |
| 66 | sp<ResourceManager> mResourceManager; |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 67 | bool mIsReadyToRun; |
| 68 | std::thread mWorkerThread; |
Haoxiang Li | 1709b37 | 2019-09-18 15:08:52 -0700 | [diff] [blame] | 69 | BufferDesc mImageBuffer; |
Haoxiang Li | d2454a5 | 2019-06-18 13:23:12 -0700 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } // namespace support |
| 73 | } // namespace evs |
| 74 | } // namespace automotive |
| 75 | } // namespace android |
| 76 | |
| 77 | #endif // CAR_LIB_EVS_SUPPORT_DISPLAY_USECASE_H |