blob: d5f5f2ff0dbff3f236171a56a1d72a15e9f70555 [file] [log] [blame]
Amy Zhang6bfeaa02020-11-30 15:16:39 -08001/*
Hongguang56637e92021-07-28 17:32:55 -07002 * Copyright 2021 The Android Open Source Project
Amy Zhang6bfeaa02020-11-30 15:16:39 -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_DEMUX_CLIENT_H_
18#define _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
19
Hongguang56637e92021-07-28 17:32:55 -070020#include <aidl/android/hardware/tv/tuner/Result.h>
Amy Zhang4a07e802021-01-21 17:10:21 -080021#include <aidl/android/media/tv/tuner/ITunerDemux.h>
Amy Zhang6bfeaa02020-11-30 15:16:39 -080022
Amy Zhang2d7026b2021-01-22 18:07:51 -080023#include "ClientHelper.h"
Hongguang56637e92021-07-28 17:32:55 -070024#include "DvrClient.h"
Amy Zhang9a9ed602020-12-07 16:37:33 -080025#include "DvrClientCallback.h"
Amy Zhang6bfeaa02020-11-30 15:16:39 -080026#include "FilterClient.h"
Amy Zhangb74185b2020-12-07 16:37:33 -080027#include "FilterClientCallback.h"
Amy Zhang6bfeaa02020-11-30 15:16:39 -080028#include "FrontendClient.h"
Amy Zhang90a50b42021-01-11 16:58:59 -080029#include "TimeFilterClient.h"
Amy Zhang6bfeaa02020-11-30 15:16:39 -080030
Amy Zhang4a07e802021-01-21 17:10:21 -080031using Status = ::ndk::ScopedAStatus;
Hongguang56637e92021-07-28 17:32:55 -070032using ::aidl::android::hardware::tv::tuner::DemuxFilterType;
33using ::aidl::android::hardware::tv::tuner::DvrType;
34using ::aidl::android::hardware::tv::tuner::Result;
Amy Zhang4a07e802021-01-21 17:10:21 -080035using ::aidl::android::media::tv::tuner::ITunerDemux;
Amy Zhang952794662021-02-04 15:56:22 -080036using ::aidl::android::media::tv::tuner::ITunerTimeFilter;
Amy Zhang6bfeaa02020-11-30 15:16:39 -080037
Amy Zhang6bfeaa02020-11-30 15:16:39 -080038using namespace std;
39
40namespace android {
41
42struct DemuxClient : public RefBase {
43
44public:
Amy Zhang4a07e802021-01-21 17:10:21 -080045 DemuxClient(shared_ptr<ITunerDemux> tunerDemux);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080046 ~DemuxClient();
47
Amy Zhang6bfeaa02020-11-30 15:16:39 -080048 /**
49 * Set a frontend resource as data input of the demux.
50 */
Amy Zhangb74185b2020-12-07 16:37:33 -080051 Result setFrontendDataSource(sp<FrontendClient> frontendClient);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080052
53 /**
Kensuke Miyagi7a45c0a2021-07-30 17:40:52 -070054 * Set a frontend resource by handle as data input of the demux.
55 */
56 Result setFrontendDataSourceById(int frontendId);
57
58 /**
Amy Zhang6bfeaa02020-11-30 15:16:39 -080059 * Open a new filter client.
60 */
Hongguang56637e92021-07-28 17:32:55 -070061 sp<FilterClient> openFilter(const DemuxFilterType& type, int32_t bufferSize,
62 sp<FilterClientCallback> cb);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080063
Amy Zhang90a50b42021-01-11 16:58:59 -080064 /**
65 * Open time filter of the demux.
66 */
67 sp<TimeFilterClient> openTimeFilter();
Amy Zhang6bfeaa02020-11-30 15:16:39 -080068
69 /**
70 * Get hardware sync ID for audio and video.
71 */
Hongguang56637e92021-07-28 17:32:55 -070072 int32_t getAvSyncHwId(sp<FilterClient> filterClient);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080073
74 /**
75 * Get current time stamp to use for A/V sync.
76 */
Hongguang56637e92021-07-28 17:32:55 -070077 int64_t getAvSyncTime(int32_t avSyncHwId);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080078
79 /**
80 * Open a DVR (Digital Video Record) client.
81 */
Hongguang56637e92021-07-28 17:32:55 -070082 sp<DvrClient> openDvr(DvrType dvbType, int32_t bufferSize, sp<DvrClientCallback> cb);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080083
84 /**
85 * Connect Conditional Access Modules (CAM) through Common Interface (CI).
86 */
Hongguang56637e92021-07-28 17:32:55 -070087 Result connectCiCam(int32_t ciCamId);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080088
89 /**
90 * Disconnect Conditional Access Modules (CAM).
91 */
92 Result disconnectCiCam();
93
94 /**
95 * Release the Demux Client.
96 */
97 Result close();
98
Amy Zhang38261c32021-02-03 20:38:52 -080099 /**
100 * Get the Aidl demux to set as source.
101 */
102 shared_ptr<ITunerDemux> getAidlDemux() { return mTunerDemux; }
103
Amy Zhang6bfeaa02020-11-30 15:16:39 -0800104private:
Amy Zhang6bfeaa02020-11-30 15:16:39 -0800105 /**
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 */
Amy Zhang4a07e802021-01-21 17:10:21 -0800109 shared_ptr<ITunerDemux> mTunerDemux;
Amy Zhang6bfeaa02020-11-30 15:16:39 -0800110};
111} // namespace android
112
113#endif // _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_