Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 1 | /* |
Hongguang | 56637e9 | 2021-07-28 17:32:55 -0700 | [diff] [blame] | 2 | * Copyright 2021 The Android Open Source Project |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 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 | |
Hongguang | 56637e9 | 2021-07-28 17:32:55 -0700 | [diff] [blame] | 20 | #include <aidl/android/hardware/tv/tuner/Result.h> |
Amy Zhang | 38261c3 | 2021-02-03 20:38:52 -0800 | [diff] [blame] | 21 | #include <aidl/android/media/tv/tuner/ITunerDescrambler.h> |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 22 | |
| 23 | #include "DemuxClient.h" |
| 24 | #include "FilterClient.h" |
| 25 | |
Hongguang | 56637e9 | 2021-07-28 17:32:55 -0700 | [diff] [blame] | 26 | using ::aidl::android::hardware::tv::tuner::DemuxPid; |
| 27 | using ::aidl::android::hardware::tv::tuner::Result; |
Amy Zhang | 38261c3 | 2021-02-03 20:38:52 -0800 | [diff] [blame] | 28 | using ::aidl::android::media::tv::tuner::ITunerDescrambler; |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 29 | |
| 30 | using namespace std; |
| 31 | |
| 32 | namespace android { |
| 33 | |
| 34 | struct DescramblerClient : public RefBase { |
| 35 | |
| 36 | public: |
Amy Zhang | 38261c3 | 2021-02-03 20:38:52 -0800 | [diff] [blame] | 37 | DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler); |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 38 | ~DescramblerClient(); |
| 39 | |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 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 | */ |
Amy Zhang | 38261c3 | 2021-02-03 20:38:52 -0800 | [diff] [blame] | 70 | shared_ptr<ITunerDescrambler> mTunerDescrambler; |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 71 | }; |
| 72 | } // namespace android |
| 73 | |
| 74 | #endif // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_ |