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