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_TV_TIME_FILTER_CLIENT_H_ 18 #define _ANDROID_MEDIA_TV_TIME_FILTER_CLIENT_H_ 19 20 #include <aidl/android/media/tv/tuner/ITunerTimeFilter.h> 21 #include <android/hardware/tv/tuner/1.0/ITimeFilter.h> 22 #include <android/hardware/tv/tuner/1.1/types.h> 23 24 using ::aidl::android::media::tv::tuner::ITunerTimeFilter; 25 26 using Status = ::ndk::ScopedAStatus; 27 using ::android::hardware::Return; 28 using ::android::hardware::Void; 29 using ::android::hardware::hidl_vec; 30 using ::android::hardware::tv::tuner::V1_0::ITimeFilter; 31 using ::android::hardware::tv::tuner::V1_0::Result; 32 33 using namespace std; 34 35 namespace android { 36 37 struct TimeFilterClient : public RefBase { 38 39 public: 40 TimeFilterClient(shared_ptr<ITunerTimeFilter> tunerTimeFilter); 41 ~TimeFilterClient(); 42 43 // TODO: remove after migration to Tuner Service is done. 44 void setHidlTimeFilter(sp<ITimeFilter> timeFilter); 45 46 /** 47 * Set time stamp for time based filter. 48 */ 49 Result setTimeStamp(long timeStamp); 50 51 /** 52 * Clear the time stamp in the time filter. 53 */ 54 Result clearTimeStamp(); 55 56 /** 57 * Get the current time in the time filter. 58 */ 59 long getTimeStamp(); 60 61 /** 62 * Get the time from the beginning of current data source. 63 */ 64 long getSourceTime(); 65 66 /** 67 * Releases the Time Filter instance. 68 */ 69 Result close(); 70 71 private: 72 /** 73 * An AIDL Tuner TimeFilter Singleton assigned at the first time the Tuner Client 74 * opens an TimeFilter. Default null when time filter is not opened. 75 */ 76 shared_ptr<ITunerTimeFilter> mTunerTimeFilter; 77 78 /** 79 * A TimeFilter HAL interface that is ready before migrating to the TunerTimeFilter. 80 * This is a temprary interface before Tuner Framework migrates to use TunerService. 81 * Default null when the HAL service does not exist. 82 */ 83 sp<ITimeFilter> mTimeFilter; 84 }; 85 } // namespace android 86 87 #endif // _ANDROID_MEDIA_TV_TIME_FILTER_CLIENT_H_ 88