1 /* 2 * Copyright (C) 2020 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 17 #ifndef SURROUND_VIEW_STREAM_HANDLER_H 18 #define SURROUND_VIEW_STREAM_HANDLER_H 19 20 #include <android/hardware/automotive/sv/1.0/types.h> 21 #include <android/hardware/automotive/sv/1.0/ISurroundViewStream.h> 22 #include <android/hardware/automotive/sv/1.0/ISurroundViewSession.h> 23 24 #include <thread> 25 #include <vector> 26 27 using std::vector; 28 using std::mutex; 29 using android::hardware::Return; 30 using android::sp; 31 using namespace ::android::hardware::automotive::sv::V1_0; 32 33 class SurroundViewServiceHandler : public ISurroundViewStream { 34 public: 35 SurroundViewServiceHandler(sp<ISurroundViewSession> session); 36 37 Return<void> notify(SvEvent svEvent) override; 38 Return<void> receiveFrames(const SvFramesDesc& svFramesDesc) override; 39 40 bool checkEventReceived(SvEvent svEvent); 41 SvFramesDesc getLastReceivedFrames(); 42 int getReceiveFramesCount(); 43 bool areAllFramesValid(); 44 void setDoNotReturnFrames(bool flag); 45 46 private: 47 mutex mLock; 48 49 vector<SvEvent> mReceivedEvents; 50 sp<ISurroundViewSession> mSession; 51 SvFramesDesc mLastReceivedFrames; // only use timestampNs and sequenceId 52 int mReceiveFramesCount; // TODO(haoxiangl): figure out a better name 53 bool mAllFramesValid = true; 54 bool mDoNotReturnFrames; 55 }; 56 57 #endif //SURROUND_VIEW_STREAM_HANDLER_H 58