• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 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/media/tv/tuner/ITunerDescrambler.h>
21 #include <android/hardware/tv/tuner/1.0/IDescrambler.h>
22 #include <android/hardware/tv/tuner/1.1/types.h>
23 
24 #include "DemuxClient.h"
25 #include "FilterClient.h"
26 
27 using ::aidl::android::media::tv::tuner::ITunerDescrambler;
28 using ::aidl::android::media::tv::tuner::TunerDemuxPid;
29 
30 using ::android::hardware::tv::tuner::V1_0::IDescrambler;
31 using ::android::hardware::tv::tuner::V1_0::Result;
32 using ::android::hardware::tv::tuner::V1_0::DemuxPid;
33 
34 using namespace std;
35 
36 namespace android {
37 
38 struct DescramblerClient : public RefBase {
39 
40 public:
41     DescramblerClient(shared_ptr<ITunerDescrambler> tunerDescrambler);
42     ~DescramblerClient();
43 
44     // TODO: remove after migration to Tuner Service is done.
45     void setHidlDescrambler(sp<IDescrambler> descrambler);
46 
47      /**
48      * Set a demux as source of the descrambler.
49      */
50     Result setDemuxSource(sp<DemuxClient> demuxClient);
51 
52     /**
53      * Set a key token to link descrambler to a key slot.
54      */
55     Result setKeyToken(vector<uint8_t> keyToken);
56 
57     /**
58      * Add packets' PID to the descrambler for descrambling.
59      */
60     Result addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);
61 
62     /**
63      * Remove packets' PID from the descrambler.
64      */
65     Result removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);
66 
67     /**
68      * Close a new interface of ITunerDescrambler.
69      */
70     Result close();
71 
72 private:
73     TunerDemuxPid getAidlDemuxPid(DemuxPid& pid);
74 
75     /**
76      * An AIDL Tuner Descrambler Singleton assigned at the first time the Tuner Client
77      * opens a descrambler. Default null when descrambler is not opened.
78      */
79     shared_ptr<ITunerDescrambler> mTunerDescrambler;
80 
81     /**
82      * A Descrambler HAL interface that is ready before migrating to the TunerDescrambler.
83      * This is a temprary interface before Tuner Framework migrates to use TunerService.
84      * Default null when the HAL service does not exist.
85      */
86     sp<IDescrambler> mDescrambler;
87 };
88 }  // namespace android
89 
90 #endif  // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
91