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