blob: a72bca3806bec81314411d669d5f05a8cda6d776 [file] [log] [blame]
Yixiao Luoaaa52302022-08-11 18:44:50 -07001/*
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
26using namespace android;
27using namespace std;
28using ::aidl::android::hardware::common::NativeHandle;
29
30namespace aidl {
31namespace android {
32namespace hardware {
33namespace tv {
34namespace input {
35
36class 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