2019-10-18 15:55:55 -07:00
|
|
|
/*
|
|
|
|
* Copyright 2019 The Android Open Source Project
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ANDROID_MEDIA_TV_TUNER_H_
|
|
|
|
#define _ANDROID_MEDIA_TV_TUNER_H_
|
|
|
|
|
2020-07-27 14:50:10 -07:00
|
|
|
#include <android/hardware/tv/tuner/1.1/types.h>
|
|
|
|
|
2020-04-01 16:51:04 -07:00
|
|
|
#include <C2BlockInternal.h>
|
|
|
|
#include <C2HandleIonInternal.h>
|
|
|
|
#include <C2ParamDef.h>
|
2019-11-26 15:05:22 -08:00
|
|
|
#include <fmq/MessageQueue.h>
|
2019-12-05 16:58:55 -08:00
|
|
|
#include <fstream>
|
|
|
|
#include <string>
|
2019-11-01 15:42:21 -07:00
|
|
|
#include <unordered_map>
|
2020-04-01 16:51:04 -07:00
|
|
|
#include <utils/Mutex.h>
|
2019-10-18 15:55:55 -07:00
|
|
|
#include <utils/RefBase.h>
|
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
#include "tuner/DemuxClient.h"
|
2021-01-07 11:14:43 -08:00
|
|
|
#include "tuner/DescramblerClient.h"
|
2020-12-09 21:13:58 -08:00
|
|
|
#include "tuner/FilterClient.h"
|
|
|
|
#include "tuner/FilterClientCallback.h"
|
|
|
|
#include "tuner/FrontendClient.h"
|
|
|
|
#include "tuner/FrontendClientCallback.h"
|
2021-01-07 11:14:43 -08:00
|
|
|
#include "tuner/LnbClient.h"
|
|
|
|
#include "tuner/LnbClientCallback.h"
|
2021-01-11 16:58:59 -08:00
|
|
|
#include "tuner/TimeFilterClient.h"
|
2020-11-23 17:42:40 -08:00
|
|
|
#include "tuner/TunerClient.h"
|
2019-10-18 15:55:55 -07:00
|
|
|
#include "jni.h"
|
|
|
|
|
2019-11-26 15:05:22 -08:00
|
|
|
using ::android::hardware::EventFlag;
|
|
|
|
using ::android::hardware::MQDescriptorSync;
|
|
|
|
using ::android::hardware::MessageQueue;
|
2019-11-01 15:42:21 -07:00
|
|
|
using ::android::hardware::Return;
|
2020-04-01 16:51:04 -07:00
|
|
|
using ::android::hardware::hidl_handle;
|
2019-10-24 17:49:53 -07:00
|
|
|
using ::android::hardware::hidl_vec;
|
2019-11-26 15:05:22 -08:00
|
|
|
using ::android::hardware::kSynchronizedReadWrite;
|
2019-11-01 15:42:21 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::DemuxFilterEvent;
|
|
|
|
using ::android::hardware::tv::tuner::V1_0::DemuxFilterStatus;
|
|
|
|
using ::android::hardware::tv::tuner::V1_0::DemuxFilterType;
|
2019-11-04 17:51:02 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::DemuxPid;
|
2019-11-08 17:10:18 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::DvrType;
|
2019-10-24 17:49:53 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendEventType;
|
2019-10-18 19:36:25 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendId;
|
2020-01-28 18:00:22 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendInfo;
|
2019-10-24 17:49:53 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendScanMessage;
|
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendScanMessageType;
|
2019-12-11 15:29:09 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendScanType;
|
2019-10-29 19:10:22 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::FrontendSettings;
|
2020-08-07 13:37:51 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_1::FrontendSettingsExt1_1;
|
2019-11-12 17:11:28 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::LnbEventType;
|
|
|
|
using ::android::hardware::tv::tuner::V1_0::LnbId;
|
2019-11-08 17:10:18 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::PlaybackStatus;
|
|
|
|
using ::android::hardware::tv::tuner::V1_0::RecordStatus;
|
2020-02-07 17:48:02 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_0::Result;
|
2020-11-12 17:37:51 -08:00
|
|
|
using ::android::hardware::tv::tuner::V1_1::DemuxFilterEventExt;
|
|
|
|
using ::android::hardware::tv::tuner::V1_1::DemuxFilterMonitorEvent;
|
2020-09-25 18:59:12 -07:00
|
|
|
using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageExt1_1;
|
|
|
|
using ::android::hardware::tv::tuner::V1_1::FrontendScanMessageTypeExt1_1;
|
2019-10-18 15:55:55 -07:00
|
|
|
|
2020-03-30 21:24:56 -07:00
|
|
|
using MQ = MessageQueue<uint8_t, kSynchronizedReadWrite>;
|
2019-11-26 15:05:22 -08:00
|
|
|
|
2019-10-18 15:55:55 -07:00
|
|
|
namespace android {
|
|
|
|
|
2021-01-07 11:14:43 -08:00
|
|
|
struct LnbClientCallbackImpl : public LnbClientCallback {
|
|
|
|
~LnbClientCallbackImpl();
|
|
|
|
virtual void onEvent(LnbEventType lnbEventType);
|
|
|
|
virtual void onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);
|
|
|
|
|
|
|
|
void setLnb(jweak lnbObj);
|
|
|
|
private:
|
|
|
|
jweak mLnbObj;
|
2019-11-12 17:11:28 -08:00
|
|
|
};
|
|
|
|
|
2020-12-07 16:37:33 -08:00
|
|
|
struct DvrClientCallbackImpl : public DvrClientCallback {
|
|
|
|
~DvrClientCallbackImpl();
|
|
|
|
virtual void onRecordStatus(RecordStatus status);
|
|
|
|
virtual void onPlaybackStatus(PlaybackStatus status);
|
2019-11-08 17:10:18 -08:00
|
|
|
|
2020-12-07 16:37:33 -08:00
|
|
|
void setDvr(jweak dvrObj);
|
2019-11-08 17:10:18 -08:00
|
|
|
private:
|
2019-12-04 16:26:51 -08:00
|
|
|
jweak mDvrObj;
|
|
|
|
};
|
|
|
|
|
2020-04-01 16:51:04 -07:00
|
|
|
struct MediaEvent : public RefBase {
|
2020-12-09 21:13:58 -08:00
|
|
|
MediaEvent(sp<FilterClient> filterClient, hidl_handle avHandle, uint64_t dataId,
|
2020-09-09 13:49:10 -07:00
|
|
|
uint64_t dataSize, jobject obj);
|
2020-04-01 16:51:04 -07:00
|
|
|
~MediaEvent();
|
|
|
|
jobject getLinearBlock();
|
|
|
|
uint64_t getAudioHandle();
|
|
|
|
void finalize();
|
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
sp<FilterClient> mFilterClient;
|
2020-04-01 16:51:04 -07:00
|
|
|
native_handle_t* mAvHandle;
|
|
|
|
uint64_t mDataId;
|
2020-09-09 13:49:10 -07:00
|
|
|
uint64_t mDataSize;
|
2020-04-01 16:51:04 -07:00
|
|
|
uint8_t* mBuffer;
|
|
|
|
android::Mutex mLock;
|
|
|
|
int mDataIdRefCnt;
|
|
|
|
int mAvHandleRefCnt;
|
|
|
|
jweak mMediaEventObj;
|
|
|
|
jweak mLinearBlockObj;
|
|
|
|
C2HandleIon* mIonHandle;
|
2020-06-17 11:00:11 -07:00
|
|
|
std::weak_ptr<C2Buffer> mC2Buffer;
|
2020-04-01 16:51:04 -07:00
|
|
|
};
|
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
struct FilterClientCallbackImpl : public FilterClientCallback {
|
|
|
|
virtual void onFilterEvent_1_1(const DemuxFilterEvent& filterEvent,
|
2020-07-27 14:50:10 -07:00
|
|
|
const DemuxFilterEventExt& filterEventExt);
|
2020-12-09 21:13:58 -08:00
|
|
|
virtual void onFilterEvent(const DemuxFilterEvent& filterEvent);
|
|
|
|
virtual void onFilterStatus(const DemuxFilterStatus status);
|
2019-11-06 17:28:38 -08:00
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
void setFilter(jweak filterObj, sp<FilterClient> filterClient);
|
2019-11-06 17:28:38 -08:00
|
|
|
private:
|
2020-12-09 21:13:58 -08:00
|
|
|
jweak mFilterObj;
|
|
|
|
sp<FilterClient> mFilterClient;
|
2020-02-19 19:09:10 -08:00
|
|
|
jobjectArray getSectionEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
|
|
|
jobjectArray getMediaEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
|
|
|
jobjectArray getPesEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
|
|
|
jobjectArray getTsRecordEvent(
|
2020-07-27 14:50:10 -07:00
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>&events,
|
|
|
|
const std::vector<DemuxFilterEventExt::Event>& eventsExt);
|
2020-02-19 19:09:10 -08:00
|
|
|
jobjectArray getMmtpRecordEvent(
|
2020-07-27 14:50:10 -07:00
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>&events,
|
|
|
|
const std::vector<DemuxFilterEventExt::Event>& eventsExt);
|
2020-02-19 19:09:10 -08:00
|
|
|
jobjectArray getDownloadEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
|
|
|
jobjectArray getIpPayloadEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
|
|
|
jobjectArray getTemiEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEvent::Event>& events);
|
2020-11-11 20:22:40 -08:00
|
|
|
jobjectArray getScramblingStatusEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEventExt::Event>& eventsExt);
|
2020-11-12 17:37:51 -08:00
|
|
|
jobjectArray getIpCidChangeEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEventExt::Event>& eventsExt);
|
2020-11-11 20:22:40 -08:00
|
|
|
jobjectArray getRestartEvent(
|
|
|
|
jobjectArray& arr, const std::vector<DemuxFilterEventExt::Event>& eventsExt);
|
2019-11-01 15:42:21 -07:00
|
|
|
};
|
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
struct FrontendClientCallbackImpl : public FrontendClientCallback {
|
2021-01-08 17:22:59 -08:00
|
|
|
FrontendClientCallbackImpl(jweak tunerObj);
|
2019-10-24 17:49:53 -07:00
|
|
|
|
2020-12-09 21:13:58 -08:00
|
|
|
virtual void onEvent(FrontendEventType frontendEventType);
|
|
|
|
virtual void onScanMessage(
|
2019-10-24 17:49:53 -07:00
|
|
|
FrontendScanMessageType type, const FrontendScanMessage& message);
|
2020-12-09 21:13:58 -08:00
|
|
|
virtual void onScanMessageExt1_1(
|
2020-09-25 18:59:12 -07:00
|
|
|
FrontendScanMessageTypeExt1_1 type, const FrontendScanMessageExt1_1& messageExt);
|
2019-10-24 17:49:53 -07:00
|
|
|
|
|
|
|
jweak mObject;
|
|
|
|
};
|
|
|
|
|
2019-10-18 15:55:55 -07:00
|
|
|
struct JTuner : public RefBase {
|
|
|
|
JTuner(JNIEnv *env, jobject thiz);
|
2020-08-05 20:15:31 -07:00
|
|
|
int getTunerVersion();
|
2020-12-09 21:13:58 -08:00
|
|
|
jobject getAvSyncHwId(sp<FilterClient> filter);
|
2020-02-07 17:48:02 -08:00
|
|
|
jobject getAvSyncTime(jint id);
|
|
|
|
int connectCiCam(jint id);
|
2020-08-18 12:29:54 -07:00
|
|
|
int linkCiCam(jint id);
|
2020-02-07 17:48:02 -08:00
|
|
|
int disconnectCiCam();
|
2020-08-18 12:29:54 -07:00
|
|
|
int unlinkCiCam(jint id);
|
2019-10-18 19:36:25 -07:00
|
|
|
jobject getFrontendIds();
|
2020-12-09 21:13:58 -08:00
|
|
|
jobject openFrontendByHandle(int feHandle);
|
2020-04-10 18:00:56 -07:00
|
|
|
jint closeFrontendById(int id);
|
2020-01-28 18:00:22 -08:00
|
|
|
jobject getFrontendInfo(int id);
|
2020-08-07 13:37:51 -07:00
|
|
|
int tune(const FrontendSettings& settings, const FrontendSettingsExt1_1& settingsExt1_1);
|
2020-01-28 14:53:05 -08:00
|
|
|
int stopTune();
|
2020-08-07 13:37:51 -07:00
|
|
|
int scan(const FrontendSettings& settings, FrontendScanType scanType,
|
|
|
|
const FrontendSettingsExt1_1& settingsExt1_1);
|
2020-01-28 14:53:05 -08:00
|
|
|
int stopScan();
|
2021-01-07 11:14:43 -08:00
|
|
|
int setLnb(sp<LnbClient> lnbClient);
|
2020-01-28 14:53:05 -08:00
|
|
|
int setLna(bool enable);
|
2021-01-07 11:14:43 -08:00
|
|
|
jobject openLnbByHandle(int handle);
|
2020-03-06 15:23:41 -08:00
|
|
|
jobject openLnbByName(jstring name);
|
2019-11-01 15:42:21 -07:00
|
|
|
jobject openFilter(DemuxFilterType type, int bufferSize);
|
2020-02-05 16:27:06 -08:00
|
|
|
jobject openTimeFilter();
|
2019-11-04 17:51:02 -08:00
|
|
|
jobject openDescrambler();
|
2020-02-27 18:06:21 -08:00
|
|
|
jobject openDvr(DvrType type, jlong bufferSize);
|
2020-03-23 18:48:12 -07:00
|
|
|
jobject getDemuxCaps();
|
2020-03-24 18:04:35 -07:00
|
|
|
jobject getFrontendStatus(jintArray types);
|
2021-01-11 16:58:59 -08:00
|
|
|
Result openDemux(int handle);
|
2020-04-10 18:00:56 -07:00
|
|
|
jint close();
|
2020-03-26 17:44:31 -07:00
|
|
|
jint closeFrontend();
|
|
|
|
jint closeDemux();
|
2019-11-12 17:11:28 -08:00
|
|
|
|
2019-10-18 15:55:55 -07:00
|
|
|
protected:
|
|
|
|
virtual ~JTuner();
|
|
|
|
|
|
|
|
private:
|
|
|
|
jclass mClass;
|
|
|
|
jweak mObject;
|
2020-11-23 17:42:40 -08:00
|
|
|
static sp<TunerClient> mTunerClient;
|
2020-12-09 21:13:58 -08:00
|
|
|
sp<FrontendClient> mFeClient;
|
2020-03-27 17:08:11 -07:00
|
|
|
int mFeId;
|
2021-01-07 11:14:43 -08:00
|
|
|
sp<LnbClient> mLnbClient;
|
2020-12-09 21:13:58 -08:00
|
|
|
sp<DemuxClient> mDemuxClient;
|
2020-04-06 17:10:01 -07:00
|
|
|
static jobject getAnalogFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getAtsc3FrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getAtscFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getDvbcFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getDvbsFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getDvbtFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getIsdbs3FrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getIsdbsFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
|
|
|
static jobject getIsdbtFrontendCaps(JNIEnv *env, FrontendInfo::FrontendCapabilities& caps);
|
2020-08-28 00:13:42 -07:00
|
|
|
static jobject getDtmbFrontendCaps(JNIEnv *env, int id);
|
2020-09-16 17:46:03 -07:00
|
|
|
|
|
|
|
bool isV1_1ExtendedStatusType(jint type);
|
2019-10-18 15:55:55 -07:00
|
|
|
};
|
|
|
|
|
2020-04-01 16:51:04 -07:00
|
|
|
class C2DataIdInfo : public C2Param {
|
|
|
|
public:
|
|
|
|
C2DataIdInfo(uint32_t index, uint64_t value);
|
|
|
|
private:
|
2020-08-03 15:25:09 -07:00
|
|
|
typedef C2GlobalParam<C2Info, C2Int64Value, 0> StubInfo;
|
|
|
|
StubInfo mInfo;
|
|
|
|
static const size_t kParamSize = sizeof(StubInfo);
|
2020-04-01 16:51:04 -07:00
|
|
|
};
|
|
|
|
|
2019-10-18 15:55:55 -07:00
|
|
|
} // namespace android
|
|
|
|
|
|
|
|
#endif // _ANDROID_MEDIA_TV_TUNER_H_
|