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 65 struct DvrCallback : public BnDvrCallback { DvrCallbackDvrCallback66 DvrCallback(const shared_ptr<ITunerDvrCallback> tunerDvrCallback) 67 : mTunerDvrCallback(tunerDvrCallback){}; 68 69 ::ndk::ScopedAStatus onRecordStatus(const RecordStatus status) override; 70 ::ndk::ScopedAStatus onPlaybackStatus(const PlaybackStatus status) override; 71 72 private: 73 shared_ptr<ITunerDvrCallback> mTunerDvrCallback; 74 }; 75 76 private: 77 shared_ptr<IDvr> mDvr; 78 DvrType mType; 79 }; 80 81 } // namespace tuner 82 } // namespace tv 83 } // namespace media 84 } // namespace android 85 } // namespace aidl 86 87 #endif // ANDROID_MEDIA_TUNERDVR_H 88