blob: c851e841b2c0bb173e584f7ebfd1fc2edcccf029 [file] [log] [blame]
Amy Zhangb0f63ab2021-01-06 17:19:27 -08001/*
Hongguang56637e92021-07-28 17:32:55 -07002 * Copyright 2021 The Android Open Source Project
Amy Zhangb0f63ab2021-01-06 17:19:27 -08003 *
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
Hongguang56637e92021-07-28 17:32:55 -070020#include <aidl/android/hardware/tv/tuner/Result.h>
Amy Zhang38261c32021-02-03 20:38:52 -080021#include <aidl/android/media/tv/tuner/ITunerDescrambler.h>
Amy Zhangb0f63ab2021-01-06 17:19:27 -080022
23#include "DemuxClient.h"
24#include "FilterClient.h"
25
Hongguang56637e92021-07-28 17:32:55 -070026using ::aidl::android::hardware::tv::tuner::DemuxPid;
27using ::aidl::android::hardware::tv::tuner::Result;
Amy Zhang38261c32021-02-03 20:38:52 -080028using ::aidl::android::media::tv::tuner::ITunerDescrambler;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080029
30using namespace std;
31
32namespace android {
33
34struct DescramblerClient : public RefBase {
35
36public:
Amy Zhang38261c32021-02-03 20:38:52 -080037 DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler);
Amy Zhangb0f63ab2021-01-06 17:19:27 -080038 ~DescramblerClient();
39
Amy Zhangb0f63ab2021-01-06 17:19:27 -080040 /**
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
65private:
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 Zhang38261c32021-02-03 20:38:52 -080070 shared_ptr<ITunerDescrambler> mTunerDescrambler;
Amy Zhangb0f63ab2021-01-06 17:19:27 -080071};
72} // namespace android
73
74#endif // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_