Yixiao Luo | aaa5230 | 2022-08-11 18:44:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2022 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 | #pragma once |
| 18 | |
| 19 | #include <aidl/android/hardware/tv/input/BnTvInput.h> |
| 20 | #include <utils/KeyedVector.h> |
| 21 | |
| 22 | #include <map> |
| 23 | #include "TvInputDeviceInfoWrapper.h" |
| 24 | #include "TvStreamConfigWrapper.h" |
| 25 | |
| 26 | using namespace android; |
| 27 | using namespace std; |
| 28 | using ::aidl::android::hardware::common::NativeHandle; |
| 29 | |
| 30 | namespace aidl { |
| 31 | namespace android { |
| 32 | namespace hardware { |
| 33 | namespace tv { |
| 34 | namespace input { |
| 35 | |
| 36 | class TvInput : public BnTvInput { |
| 37 | public: |
| 38 | TvInput(); |
| 39 | |
| 40 | ::ndk::ScopedAStatus setCallback(const shared_ptr<ITvInputCallback>& in_callback) override; |
| 41 | ::ndk::ScopedAStatus getStreamConfigurations(int32_t in_deviceId, |
| 42 | vector<TvStreamConfig>* _aidl_return) override; |
| 43 | ::ndk::ScopedAStatus openStream(int32_t in_deviceId, int32_t in_streamId, |
| 44 | NativeHandle* _aidl_return) override; |
| 45 | ::ndk::ScopedAStatus closeStream(int32_t in_deviceId, int32_t in_streamId) override; |
| 46 | |
| 47 | void init(); |
| 48 | |
| 49 | private: |
| 50 | native_handle_t* createNativeHandle(int fd); |
| 51 | void releaseNativeHandle(native_handle_t* handle); |
| 52 | |
| 53 | shared_ptr<ITvInputCallback> mCallback; |
| 54 | map<int32_t, shared_ptr<TvInputDeviceInfoWrapper>> mDeviceInfos; |
| 55 | map<int32_t, map<int32_t, shared_ptr<TvStreamConfigWrapper>>> mStreamConfigs; |
| 56 | }; |
| 57 | |
| 58 | } // namespace input |
| 59 | } // namespace tv |
| 60 | } // namespace hardware |
| 61 | } // namespace android |
| 62 | } // namespace aidl |