blob: 92e7d4ca6938523762a10dd21a8551a246b502c6 [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
David Zhao6bdbc5e2023-01-12 16:51:03 -080022#include <aidl/android/hardware/tv/input/TvMessageEventType.h>
23#include <fmq/AidlMessageQueue.h>
Yixiao Luoaaa52302022-08-11 18:44:50 -070024#include <map>
25#include "TvInputDeviceInfoWrapper.h"
26#include "TvStreamConfigWrapper.h"
27
28using namespace android;
29using namespace std;
30using ::aidl::android::hardware::common::NativeHandle;
David Zhao6bdbc5e2023-01-12 16:51:03 -080031using ::aidl::android::hardware::common::fmq::MQDescriptor;
32using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
33using ::android::AidlMessageQueue;
Yixiao Luoaaa52302022-08-11 18:44:50 -070034
35namespace aidl {
36namespace android {
37namespace hardware {
38namespace tv {
39namespace input {
40
41class TvInput : public BnTvInput {
42 public:
43 TvInput();
44
45 ::ndk::ScopedAStatus setCallback(const shared_ptr<ITvInputCallback>& in_callback) override;
David Zhao6bdbc5e2023-01-12 16:51:03 -080046 ::ndk::ScopedAStatus setTvMessageEnabled(int32_t deviceId, int32_t streamId,
47 TvMessageEventType in_type, bool enabled) override;
48 ::ndk::ScopedAStatus getTvMessageQueueDesc(
49 MQDescriptor<int8_t, SynchronizedReadWrite>* out_queue, int32_t in_deviceId,
50 int32_t in_streamId) override;
Yixiao Luoaaa52302022-08-11 18:44:50 -070051 ::ndk::ScopedAStatus getStreamConfigurations(int32_t in_deviceId,
52 vector<TvStreamConfig>* _aidl_return) override;
53 ::ndk::ScopedAStatus openStream(int32_t in_deviceId, int32_t in_streamId,
54 NativeHandle* _aidl_return) override;
55 ::ndk::ScopedAStatus closeStream(int32_t in_deviceId, int32_t in_streamId) override;
56
57 void init();
58
59 private:
60 native_handle_t* createNativeHandle(int fd);
Yixiao Luoaaa52302022-08-11 18:44:50 -070061
62 shared_ptr<ITvInputCallback> mCallback;
63 map<int32_t, shared_ptr<TvInputDeviceInfoWrapper>> mDeviceInfos;
64 map<int32_t, map<int32_t, shared_ptr<TvStreamConfigWrapper>>> mStreamConfigs;
65};
66
67} // namespace input
68} // namespace tv
69} // namespace hardware
70} // namespace android
71} // namespace aidl