• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
18 #define _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
19 
20 #include <aidl/android/hardware/tv/tuner/Result.h>
21 #include <aidl/android/media/tv/tuner/ITunerDemux.h>
22 
23 #include "ClientHelper.h"
24 #include "DvrClient.h"
25 #include "DvrClientCallback.h"
26 #include "FilterClient.h"
27 #include "FilterClientCallback.h"
28 #include "FrontendClient.h"
29 #include "TimeFilterClient.h"
30 
31 using Status = ::ndk::ScopedAStatus;
32 using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
33 using ::aidl::android::hardware::tv::tuner::DvrType;
34 using ::aidl::android::hardware::tv::tuner::Result;
35 using ::aidl::android::media::tv::tuner::ITunerDemux;
36 using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
37 
38 using namespace std;
39 
40 namespace android {
41 
42 struct DemuxClient : public RefBase {
43 
44 public:
45     DemuxClient(shared_ptr<ITunerDemux> tunerDemux);
46     ~DemuxClient();
47 
48     /**
49      * Set a frontend resource as data input of the demux.
50      */
51     Result setFrontendDataSource(sp<FrontendClient> frontendClient);
52 
53     /**
54      * Set a frontend resource by handle as data input of the demux.
55      */
56     Result setFrontendDataSourceById(int frontendId);
57 
58     /**
59      * Open a new filter client.
60      */
61     sp<FilterClient> openFilter(const DemuxFilterType& type, int32_t bufferSize,
62                                 sp<FilterClientCallback> cb);
63 
64     /**
65      * Open time filter of the demux.
66      */
67     sp<TimeFilterClient> openTimeFilter();
68 
69     /**
70      * Get hardware sync ID for audio and video.
71      */
72     int32_t getAvSyncHwId(sp<FilterClient> filterClient);
73 
74     /**
75      * Get current time stamp to use for A/V sync.
76      */
77     int64_t getAvSyncTime(int32_t avSyncHwId);
78 
79     /**
80      * Open a DVR (Digital Video Record) client.
81      */
82     sp<DvrClient> openDvr(DvrType dvbType, int32_t bufferSize, sp<DvrClientCallback> cb);
83 
84     /**
85      * Connect Conditional Access Modules (CAM) through Common Interface (CI).
86      */
87     Result connectCiCam(int32_t ciCamId);
88 
89     /**
90      * Disconnect Conditional Access Modules (CAM).
91      */
92     Result disconnectCiCam();
93 
94     /**
95      * Release the Demux Client.
96      */
97     Result close();
98 
99     /**
100      * Get the Aidl demux to set as source.
101      */
getAidlDemuxDemuxClient102     shared_ptr<ITunerDemux> getAidlDemux() { return mTunerDemux; }
103 
104 private:
105     /**
106      * An AIDL Tuner Demux Singleton assigned at the first time the Tuner Client
107      * opens a demux. Default null when demux is not opened.
108      */
109     shared_ptr<ITunerDemux> mTunerDemux;
110 };
111 }  // namespace android
112 
113 #endif  // _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
114