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_TUNERDVR_H 18 #define ANDROID_MEDIA_TUNERDVR_H 19 20 #include <aidl/android/hardware/tv/tuner/BnDvrCallback.h> 21 #include <aidl/android/hardware/tv/tuner/DvrSettings.h> 22 #include <aidl/android/hardware/tv/tuner/DvrType.h> 23 #include <aidl/android/hardware/tv/tuner/IDvr.h> 24 #include <aidl/android/hardware/tv/tuner/PlaybackStatus.h> 25 #include <aidl/android/hardware/tv/tuner/RecordStatus.h> 26 #include <aidl/android/media/tv/tuner/BnTunerDvr.h> 27 #include <aidl/android/media/tv/tuner/ITunerDvrCallback.h> 28 29 #include "TunerFilter.h" 30 31 using ::aidl::android::hardware::common::fmq::MQDescriptor; 32 using ::aidl::android::hardware::common::fmq::SynchronizedReadWrite; 33 using ::aidl::android::hardware::tv::tuner::BnDvrCallback; 34 using ::aidl::android::hardware::tv::tuner::DvrSettings; 35 using ::aidl::android::hardware::tv::tuner::DvrType; 36 using ::aidl::android::hardware::tv::tuner::IDvr; 37 using ::aidl::android::hardware::tv::tuner::PlaybackStatus; 38 using ::aidl::android::hardware::tv::tuner::RecordStatus; 39 40 using namespace std; 41 42 namespace aidl { 43 namespace android { 44 namespace media { 45 namespace tv { 46 namespace tuner { 47 48 using AidlMQDesc = MQDescriptor<int8_t, SynchronizedReadWrite>; 49 50 class TunerDvr : public BnTunerDvr { 51 52 public: 53 TunerDvr(shared_ptr<IDvr> dvr, DvrType type); 54 ~TunerDvr(); 55 56 ::ndk::ScopedAStatus getQueueDesc(AidlMQDesc* _aidl_return) override; 57 ::ndk::ScopedAStatus configure(const DvrSettings& in_settings) override; 58 ::ndk::ScopedAStatus attachFilter(const shared_ptr<ITunerFilter>& in_filter) override; 59 ::ndk::ScopedAStatus detachFilter(const shared_ptr<ITunerFilter>& in_filter) override; 60 ::ndk::ScopedAStatus start() override; 61 ::ndk::ScopedAStatus stop() override; 62 ::ndk::ScopedAStatus flush() override; 63 ::ndk::ScopedAStatus close() override; 64 ::ndk::ScopedAStatus setStatusCheckIntervalHint(int64_t in_milliseconds) override; 65 66 struct DvrCallback : public BnDvrCallback { DvrCallbackDvrCallback67 DvrCallback(const shared_ptr<ITunerDvrCallback> tunerDvrCallback) 68 : mTunerDvrCallback(tunerDvrCallback){}; 69 70 ::ndk::ScopedAStatus onRecordStatus(const RecordStatus status) override; 71 ::ndk::ScopedAStatus onPlaybackStatus(const PlaybackStatus status) override; 72 73 private: 74 shared_ptr<ITunerDvrCallback> mTunerDvrCallback; 75 }; 76 77 private: 78 shared_ptr<IDvr> mDvr; 79 DvrType mType; 80 bool isClosed = false; 81 }; 82 83 } // namespace tuner 84 } // namespace tv 85 } // namespace media 86 } // namespace android 87 } // namespace aidl 88 89 #endif // ANDROID_MEDIA_TUNERDVR_H 90