blob: aa86b14535095136895478c48a60ce49eab7eb22 [file] [log] [blame]
Hongguang093c5f32021-08-09 19:46:34 -07001/**
2 * Copyright 2021, 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 ANDROID_MEDIA_TUNERHIDLDVR_H
18#define ANDROID_MEDIA_TUNERHIDLDVR_H
19
20#include <aidl/android/hardware/tv/tuner/DvrSettings.h>
21#include <aidl/android/hardware/tv/tuner/DvrType.h>
22#include <aidl/android/media/tv/tuner/BnTunerDvr.h>
23#include <aidl/android/media/tv/tuner/ITunerDvrCallback.h>
24#include <android/hardware/tv/tuner/1.0/IDvr.h>
25#include <android/hardware/tv/tuner/1.0/IDvrCallback.h>
26
27#include "TunerHidlFilter.h"
28
29using ::aidl::android::hardware::common::fmq::MQDescriptor;
30using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
31using ::aidl::android::hardware::tv::tuner::DvrSettings;
32using ::aidl::android::hardware::tv::tuner::DvrType;
33using ::android::sp;
34using ::android::hardware::Return;
35using ::android::hardware::Void;
36using ::std::shared_ptr;
37using ::std::vector;
38
39using HidlDvrSettings = ::android::hardware::tv::tuner::V1_0::DvrSettings;
40using HidlIDvr = ::android::hardware::tv::tuner::V1_0::IDvr;
41using HidlIDvrCallback = ::android::hardware::tv::tuner::V1_0::IDvrCallback;
42using HidlPlaybackStatus = ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
43using HidlRecordStatus = ::android::hardware::tv::tuner::V1_0::RecordStatus;
44
45namespace aidl {
46namespace android {
47namespace media {
48namespace tv {
49namespace tuner {
50
51using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
52
53class TunerHidlDvr : public BnTunerDvr {
54public:
55 TunerHidlDvr(sp<HidlIDvr> dvr, DvrType type);
56 ~TunerHidlDvr();
57
58 ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override;
59 ::ndk::ScopedAStatus configure(const DvrSettings& in_settings) override;
60 ::ndk::ScopedAStatus attachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
61 ::ndk::ScopedAStatus detachFilter(const shared_ptr<ITunerFilter>& in_filter) override;
62 ::ndk::ScopedAStatus start() override;
63 ::ndk::ScopedAStatus stop() override;
64 ::ndk::ScopedAStatus flush() override;
65 ::ndk::ScopedAStatus close() override;
Ray Chin82f49232022-09-15 14:29:29 +080066 ::ndk::ScopedAStatus setStatusCheckIntervalHint(int64_t in_milliseconds) override;
Hongguang093c5f32021-08-09 19:46:34 -070067
68 struct DvrCallback : public HidlIDvrCallback {
69 DvrCallback(const shared_ptr<ITunerDvrCallback> tunerDvrCallback)
70 : mTunerDvrCallback(tunerDvrCallback){};
71
72 virtual Return<void> onRecordStatus(const HidlRecordStatus status);
73 virtual Return<void> onPlaybackStatus(const HidlPlaybackStatus status);
74
75 private:
76 shared_ptr<ITunerDvrCallback> mTunerDvrCallback;
77 };
78
79private:
80 HidlDvrSettings getHidlDvrSettings(const DvrSettings& settings);
81
82 sp<HidlIDvr> mDvr;
83 DvrType mType;
84};
85
86} // namespace tuner
87} // namespace tv
88} // namespace media
89} // namespace android
90} // namespace aidl
91
92#endif // ANDROID_MEDIA_TUNERHIDLDVR_H