Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 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 | #define LOG_TAG "DescramblerClient" |
| 18 | |
| 19 | #include <android-base/logging.h> |
| 20 | #include <utils/Log.h> |
| 21 | |
| 22 | #include "DescramblerClient.h" |
| 23 | |
| 24 | using ::android::hardware::tv::tuner::V1_0::Result; |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | /////////////// DescramblerClient /////////////////////// |
| 29 | |
| 30 | // TODO: pending aidl interface |
| 31 | DescramblerClient::DescramblerClient() { |
| 32 | //mTunerDescrambler = tunerDescrambler; |
| 33 | } |
| 34 | |
| 35 | DescramblerClient::~DescramblerClient() { |
| 36 | //mTunerDescrambler = NULL; |
| 37 | mDescrambler = NULL; |
| 38 | } |
| 39 | |
| 40 | // TODO: remove after migration to Tuner Service is done. |
| 41 | void DescramblerClient::setHidlDescrambler(sp<IDescrambler> descrambler) { |
| 42 | mDescrambler = descrambler; |
| 43 | } |
| 44 | |
Amy Zhang | 921fd43 | 2021-01-07 13:18:27 -0800 | [diff] [blame^] | 45 | Result DescramblerClient::setDemuxSource(sp<DemuxClient> demuxClient) { |
| 46 | if (demuxClient == NULL) { |
| 47 | return Result::INVALID_ARGUMENT; |
| 48 | } |
| 49 | |
| 50 | // TODO: pending aidl interface |
| 51 | |
| 52 | if (mDescrambler != NULL) { |
| 53 | return mDescrambler->setDemuxSource(demuxClient->getId()); |
| 54 | } |
| 55 | |
| 56 | return Result::INVALID_STATE; |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Amy Zhang | 921fd43 | 2021-01-07 13:18:27 -0800 | [diff] [blame^] | 59 | Result DescramblerClient::setKeyToken(vector<uint8_t> keyToken) { |
| 60 | // TODO: pending aidl interface |
| 61 | |
| 62 | if (mDescrambler != NULL) { |
| 63 | return mDescrambler->setKeyToken(keyToken); |
| 64 | } |
| 65 | |
| 66 | return Result::INVALID_STATE; |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 67 | } |
| 68 | |
Amy Zhang | 921fd43 | 2021-01-07 13:18:27 -0800 | [diff] [blame^] | 69 | Result DescramblerClient::addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter) { |
| 70 | // TODO: pending aidl interface |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 71 | |
Amy Zhang | 921fd43 | 2021-01-07 13:18:27 -0800 | [diff] [blame^] | 72 | if (mDescrambler != NULL) { |
| 73 | return mDescrambler->addPid(pid, optionalSourceFilter->getHalFilter()); |
| 74 | } |
| 75 | |
| 76 | return Result::INVALID_STATE;} |
| 77 | |
| 78 | Result DescramblerClient::removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter) { |
| 79 | // TODO: pending aidl interface |
| 80 | |
| 81 | if (mDescrambler != NULL) { |
| 82 | return mDescrambler->addPid(pid, optionalSourceFilter->getHalFilter()); |
| 83 | } |
| 84 | |
| 85 | return Result::INVALID_STATE;} |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 86 | |
| 87 | Result DescramblerClient::close() { |
Amy Zhang | 921fd43 | 2021-01-07 13:18:27 -0800 | [diff] [blame^] | 88 | // TODO: pending aidl interface |
| 89 | |
| 90 | if (mDescrambler != NULL) { |
| 91 | return mDescrambler->close(); |
| 92 | } |
| 93 | |
| 94 | return Result::INVALID_STATE;} |
Amy Zhang | b0f63ab | 2021-01-06 17:19:27 -0800 | [diff] [blame] | 95 | |
| 96 | /////////////// DescramblerClient Helper Methods /////////////////////// |
| 97 | |
| 98 | } // namespace android |