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_DESCRAMBLER_CLIENT_H_ 18 #define _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_ 19 20 #include <aidl/android/hardware/tv/tuner/Result.h> 21 #include <aidl/android/media/tv/tuner/ITunerDescrambler.h> 22 23 #include "DemuxClient.h" 24 #include "FilterClient.h" 25 26 using ::aidl::android::hardware::tv::tuner::DemuxPid; 27 using ::aidl::android::hardware::tv::tuner::Result; 28 using ::aidl::android::media::tv::tuner::ITunerDescrambler; 29 30 using namespace std; 31 32 namespace android { 33 34 struct DescramblerClient : public RefBase { 35 36 public: 37 DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler); 38 ~DescramblerClient(); 39 40 /** 41 * Set a demux as source of the descrambler. 42 */ 43 Result setDemuxSource(sp<DemuxClient> demuxClient); 44 45 /** 46 * Set a key token to link descrambler to a key slot. 47 */ 48 Result setKeyToken(vector<uint8_t> keyToken); 49 50 /** 51 * Add packets' PID to the descrambler for descrambling. 52 */ 53 Result addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter); 54 55 /** 56 * Remove packets' PID from the descrambler. 57 */ 58 Result removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter); 59 60 /** 61 * Close a new interface of ITunerDescrambler. 62 */ 63 Result close(); 64 65 private: 66 /** 67 * An AIDL Tuner Descrambler Singleton assigned at the first time the Tuner Client 68 * opens a descrambler. Default null when descrambler is not opened. 69 */ 70 shared_ptr<ITunerDescrambler> mTunerDescrambler; 71 }; 72 } // namespace android 73 74 #endif // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_ 75