blob: 979beeac6b3a32e32485c86e8b6f4b6afad3ab5a [file] [log] [blame]
Amy Zhangb0f63ab2021-01-06 17:19:27 -08001/*
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
24using ::android::hardware::tv::tuner::V1_0::Result;
25
26namespace android {
27
28/////////////// DescramblerClient ///////////////////////
29
30// TODO: pending aidl interface
31DescramblerClient::DescramblerClient() {
32 //mTunerDescrambler = tunerDescrambler;
33}
34
35DescramblerClient::~DescramblerClient() {
36 //mTunerDescrambler = NULL;
37 mDescrambler = NULL;
38}
39
40// TODO: remove after migration to Tuner Service is done.
41void DescramblerClient::setHidlDescrambler(sp<IDescrambler> descrambler) {
42 mDescrambler = descrambler;
43}
44
Amy Zhang921fd432021-01-07 13:18:27 -080045Result 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 Zhangb0f63ab2021-01-06 17:19:27 -080057}
58
Amy Zhang921fd432021-01-07 13:18:27 -080059Result 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 Zhangb0f63ab2021-01-06 17:19:27 -080067}
68
Amy Zhang921fd432021-01-07 13:18:27 -080069Result DescramblerClient::addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter) {
70 // TODO: pending aidl interface
Amy Zhangb0f63ab2021-01-06 17:19:27 -080071
Amy Zhang921fd432021-01-07 13:18:27 -080072 if (mDescrambler != NULL) {
73 return mDescrambler->addPid(pid, optionalSourceFilter->getHalFilter());
74 }
75
76 return Result::INVALID_STATE;}
77
78Result 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 Zhangb0f63ab2021-01-06 17:19:27 -080086
87Result DescramblerClient::close() {
Amy Zhang921fd432021-01-07 13:18:27 -080088 // TODO: pending aidl interface
89
90 if (mDescrambler != NULL) {
91 return mDescrambler->close();
92 }
93
94 return Result::INVALID_STATE;}
Amy Zhangb0f63ab2021-01-06 17:19:27 -080095
96/////////////// DescramblerClient Helper Methods ///////////////////////
97
98} // namespace android