• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
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 
29 using ::aidl::android::hardware::common::fmq::MQDescriptor;
30 using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite;
31 using ::aidl::android::hardware::tv::tuner::DvrSettings;
32 using ::aidl::android::hardware::tv::tuner::DvrType;
33 using ::android::sp;
34 using ::android::hardware::Return;
35 using ::android::hardware::Void;
36 using ::std::shared_ptr;
37 using ::std::vector;
38 
39 using HidlDvrSettings = ::android::hardware::tv::tuner::V1_0::DvrSettings;
40 using HidlIDvr = ::android::hardware::tv::tuner::V1_0::IDvr;
41 using HidlIDvrCallback = ::android::hardware::tv::tuner::V1_0::IDvrCallback;
42 using HidlPlaybackStatus = ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
43 using HidlRecordStatus = ::android::hardware::tv::tuner::V1_0::RecordStatus;
44 
45 namespace aidl {
46 namespace android {
47 namespace media {
48 namespace tv {
49 namespace tuner {
50 
51 using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>;
52 
53 class TunerHidlDvr : public BnTunerDvr {
54 public:
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;
66     ::ndk::ScopedAStatus setStatusCheckIntervalHint(int64_t in_milliseconds) override;
67 
68     struct DvrCallback : public HidlIDvrCallback {
DvrCallbackDvrCallback69         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 
79 private:
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
93