blob: 7b8eedeacf0e3d244a6c0f1abe92748b0877ca6e [file] [log] [blame]
Amy Zhang6bfeaa02020-11-30 15:16:39 -08001/*
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_DEMUX_CLIENT_H_
18#define _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_
19
20//#include <aidl/android/media/tv/tuner/ITunerDemux.h>
21#include <android/hardware/tv/tuner/1.0/IDemux.h>
22#include <android/hardware/tv/tuner/1.1/types.h>
23
Amy Zhang9a9ed602020-12-07 16:37:33 -080024#include "DvrClient.h"
25#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"
29
30//using ::aidl::android::media::tv::tuner::ITunerDemux;
31
Amy Zhangb74185b2020-12-07 16:37:33 -080032using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
Amy Zhang9a9ed602020-12-07 16:37:33 -080033using ::android::hardware::tv::tuner::V1_0::DvrType;
Amy Zhang6bfeaa02020-11-30 15:16:39 -080034using ::android::hardware::tv::tuner::V1_0::IDemux;
35
36using namespace std;
37
38namespace android {
39
40struct DemuxClient : public RefBase {
41
42public:
43 DemuxClient();
44 ~DemuxClient();
45
46 // TODO: remove after migration to Tuner Service is done.
47 void setHidlDemux(sp<IDemux> demux);
48
49 /**
50 * Set a frontend resource as data input of the demux.
51 */
Amy Zhangb74185b2020-12-07 16:37:33 -080052 Result setFrontendDataSource(sp<FrontendClient> frontendClient);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080053
54 /**
55 * Open a new filter client.
56 */
Amy Zhangb74185b2020-12-07 16:37:33 -080057 sp<FilterClient> openFilter(DemuxFilterType type, int bufferSize, sp<FilterClientCallback> cb);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080058
59 // TODO: handle TimeFilterClient
60
61 /**
62 * Get hardware sync ID for audio and video.
63 */
Amy Zhangb74185b2020-12-07 16:37:33 -080064 int getAvSyncHwId(sp<FilterClient> filterClient);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080065
66 /**
67 * Get current time stamp to use for A/V sync.
68 */
69 long getAvSyncTime(int avSyncHwId);
70
71 /**
72 * Open a DVR (Digital Video Record) client.
73 */
Amy Zhang9a9ed602020-12-07 16:37:33 -080074 sp<DvrClient> openDvr(DvrType dvbType, int bufferSize, sp<DvrClientCallback> cb);
Amy Zhang6bfeaa02020-11-30 15:16:39 -080075
76 /**
77 * Connect Conditional Access Modules (CAM) through Common Interface (CI).
78 */
79 Result connectCiCam(int ciCamId);
80
81 /**
82 * Disconnect Conditional Access Modules (CAM).
83 */
84 Result disconnectCiCam();
85
86 /**
87 * Release the Demux Client.
88 */
89 Result close();
90
Amy Zhang921fd432021-01-07 13:18:27 -080091 void setId(int id) { mId = id; }
92 int getId() { return mId; }
93
Amy Zhang6bfeaa02020-11-30 15:16:39 -080094private:
Amy Zhangb74185b2020-12-07 16:37:33 -080095 sp<IFilter> openHidlFilter(DemuxFilterType type, int bufferSize, sp<HidlFilterCallback> cb);
Amy Zhang9a9ed602020-12-07 16:37:33 -080096 sp<IDvr> openHidlDvr(DvrType type, int bufferSize, sp<HidlDvrCallback> cb);
Amy Zhangb74185b2020-12-07 16:37:33 -080097
Amy Zhang6bfeaa02020-11-30 15:16:39 -080098 /**
99 * An AIDL Tuner Demux Singleton assigned at the first time the Tuner Client
100 * opens a demux. Default null when demux is not opened.
101 */
102 // TODO: pending on aidl interface
103 //shared_ptr<ITunerDemux> mTunerDemux;
104
105 /**
106 * A Demux HAL interface that is ready before migrating to the TunerDemux.
107 * This is a temprary interface before Tuner Framework migrates to use TunerService.
108 * Default null when the HAL service does not exist.
109 */
110 sp<IDemux> mDemux;
Amy Zhang921fd432021-01-07 13:18:27 -0800111
112 int mId;
Amy Zhang6bfeaa02020-11-30 15:16:39 -0800113};
114} // namespace android
115
116#endif // _ANDROID_MEDIA_TV_DEMUX_CLIENT_H_