Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4125db1 authored by Amy Zhang's avatar Amy Zhang Committed by Android (Google) Code Review
Browse files

Merge "Add Descrambler and Lnb Client interfaces"

parents e76dbfa1 b0f63abf
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -140,9 +140,11 @@ cc_library_shared {
    srcs: [
        "android_media_tv_Tuner.cpp",
        "tuner/DemuxClient.cpp",
        "tuner/DescramblerClient.cpp",
        "tuner/DvrClient.cpp",
        "tuner/FilterClient.cpp",
        "tuner/FrontendClient.cpp",
        "tuner/LnbClient.cpp",
        "tuner/TunerClient.cpp",
    ],

+67 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

#define LOG_TAG "DescramblerClient"

#include <android-base/logging.h>
#include <utils/Log.h>

#include "DescramblerClient.h"

using ::android::hardware::tv::tuner::V1_0::Result;

namespace android {

/////////////// DescramblerClient ///////////////////////

// TODO: pending aidl interface
DescramblerClient::DescramblerClient() {
    //mTunerDescrambler = tunerDescrambler;
}

DescramblerClient::~DescramblerClient() {
    //mTunerDescrambler = NULL;
    mDescrambler = NULL;
}

// TODO: remove after migration to Tuner Service is done.
void DescramblerClient::setHidlDescrambler(sp<IDescrambler> descrambler) {
    mDescrambler = descrambler;
}

Result DescramblerClient::setDemuxSource(sp<DemuxClient> /*demuxClient*/) {
    return Result::SUCCESS;
}

Result DescramblerClient::setKeyToken(vector<uint8_t> /*keyToken*/) {
    return Result::SUCCESS;
}

Result DescramblerClient::addPid(DemuxPid /*pid*/, sp<FilterClient> /*optionalSourceFilter*/) {
    return Result::SUCCESS;
}

Result DescramblerClient::removePid(DemuxPid /*pid*/, sp<FilterClient> /*optionalSourceFilter*/) {
    return Result::SUCCESS;
}

Result DescramblerClient::close() {
    return Result::SUCCESS;
}

/////////////// DescramblerClient Helper Methods ///////////////////////

}  // namespace android
+89 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 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_DESCRAMBLER_CLIENT_H_
#define _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_

//#include <aidl/android/media/tv/tuner/ITunerDescrambler.h>
#include <android/hardware/tv/tuner/1.0/IDescrambler.h>
#include <android/hardware/tv/tuner/1.1/types.h>

#include "DemuxClient.h"
#include "FilterClient.h"

//using ::aidl::android::media::tv::tuner::ITunerDescrambler;

using ::android::hardware::tv::tuner::V1_0::IDescrambler;
using ::android::hardware::tv::tuner::V1_0::Result;
using ::android::hardware::tv::tuner::V1_0::DemuxPid;

using namespace std;

namespace android {

struct DescramblerClient : public RefBase {

public:
    // TODO: pending hidl interface
    DescramblerClient();
    ~DescramblerClient();

    // TODO: remove after migration to Tuner Service is done.
    void setHidlDescrambler(sp<IDescrambler> descrambler);

     /**
     * Set a demux as source of the descrambler.
     */
    Result setDemuxSource(sp<DemuxClient> demuxClient);

    /**
     * Set a key token to link descrambler to a key slot.
     */
    Result setKeyToken(vector<uint8_t> keyToken);

    /**
     * Add packets' PID to the descrambler for descrambling.
     */
    Result addPid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);

    /**
     * Remove packets' PID from the descrambler.
     */
    Result removePid(DemuxPid pid, sp<FilterClient> optionalSourceFilter);

    /**
     * Close a new interface of ITunerDescrambler.
     */
    Result close();

private:
    /**
     * An AIDL Tuner Descrambler Singleton assigned at the first time the Tuner Client
     * opens a descrambler. Default null when descrambler is not opened.
     */
    // TODO: pending on aidl interface
    //shared_ptr<ITunerDescrambler> mTunerDescrambler;

    /**
     * A Descrambler HAL interface that is ready before migrating to the TunerDescrambler.
     * This is a temprary interface before Tuner Framework migrates to use TunerService.
     * Default null when the HAL service does not exist.
     */
    sp<IDescrambler> mDescrambler;
};
}  // namespace android

#endif  // _ANDROID_MEDIA_TV_DESCRAMBLER_CLIENT_H_
+90 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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.
 */

#define LOG_TAG "LnbClient"

#include <android-base/logging.h>
#include <utils/Log.h>

#include "LnbClient.h"

using ::android::hardware::tv::tuner::V1_0::Result;

namespace android {

/////////////// LnbClient ///////////////////////

// TODO: pending aidl interface
LnbClient::LnbClient() {
    //mTunerLnb = tunerLnb;
}

LnbClient::~LnbClient() {
    //mTunerLnb = NULL;
    mLnb = NULL;
}

// TODO: remove after migration to Tuner Service is done.
void LnbClient::setHidlLnb(sp<ILnb> lnb) {
    mLnb = lnb;
}

Result LnbClient::setCallback(sp<LnbClientCallback> /*cb*/) {
    return Result::SUCCESS;
}

Result LnbClient::setVoltage(int /*voltage*/) {
    return Result::SUCCESS;
}

Result LnbClient::setTone(int /*tone*/) {
    return Result::SUCCESS;
}

Result LnbClient::setSatellitePosition(int /*position*/) {
    return Result::SUCCESS;
}

Result LnbClient::sendDiseqcMessage(vector<uint8_t> /*diseqcMessage*/) {
    return Result::SUCCESS;
}

Result LnbClient::close() {
    return Result::SUCCESS;
}

/////////////// ILnbCallback ///////////////////////

HidlLnbCallback::HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback)
        : mLnbClientCallback(lnbClientCallback) {}

Return<void> HidlLnbCallback::onEvent(const LnbEventType lnbEventType) {
    if (mLnbClientCallback != NULL) {
        mLnbClientCallback->onEvent(lnbEventType);
    }
    return Void();
}

Return<void> HidlLnbCallback::onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage) {
    if (mLnbClientCallback != NULL) {
        mLnbClientCallback->onDiseqcMessage(diseqcMessage);
    }
    return Void();
}

/////////////// LnbClient Helper Methods ///////////////////////

}  // namespace android
+121 −0
Original line number Diff line number Diff line
/*
 * Copyright 2021 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_LNB_CLIENT_H_
#define _ANDROID_MEDIA_TV_LNB_CLIENT_H_

//#include <aidl/android/media/tv/tuner/ITunerLnb.h>
#include <android/hardware/tv/tuner/1.0/ILnb.h>
#include <android/hardware/tv/tuner/1.0/ILnbCallback.h>
#include <android/hardware/tv/tuner/1.1/types.h>

#include "LnbClientCallback.h"

//using ::aidl::android::media::tv::tuner::ITunerLnb;

using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::tv::tuner::V1_0::ILnb;
using ::android::hardware::tv::tuner::V1_0::ILnbCallback;
using ::android::hardware::tv::tuner::V1_0::Result;

using namespace std;

namespace android {

// TODO: pending aidl interface
/*class TunerLnbCallback : public BnTunerLnbCallback {

public:
    TunerLnbCallback(sp<LnbClientCallback> lnbClientCallback);

    Status onEvent(int lnbEventType);
    Status onDiseqcMessage(vector<uint8_t> diseqcMessage);

private:
    sp<LnbClientCallback> mLnbClientCallback;
};*/

struct HidlLnbCallback : public ILnbCallback {

public:
    HidlLnbCallback(sp<LnbClientCallback> lnbClientCallback);
    virtual Return<void> onEvent(const LnbEventType lnbEventType);
    virtual Return<void> onDiseqcMessage(const hidl_vec<uint8_t>& diseqcMessage);

private:
    sp<LnbClientCallback> mLnbClientCallback;
};

struct LnbClient : public RefBase {

public:
    // TODO: add TunerLnb as parameter.
    LnbClient();
    ~LnbClient();

    // TODO: remove after migration to Tuner Service is done.
    void setHidlLnb(sp<ILnb> lnb);

    /**
     * Set the lnb callback.
     */
    Result setCallback(sp<LnbClientCallback> cb);

    /**
     * Set the lnb's power voltage.
     */
    Result setVoltage(int voltage);

    /**
     * Set the lnb's tone mode.
     */
    Result setTone(int tone);

    /**
     * Select the lnb's position.
     */
    Result setSatellitePosition(int position);

    /**
     * Sends DiSEqC (Digital Satellite Equipment Control) message.
     */
    Result sendDiseqcMessage(vector<uint8_t> diseqcMessage);

    /**
     * Releases the LNB instance.
     */
    Result close();

private:
    /**
     * An AIDL Tuner Lnb Singleton assigned at the first time the Tuner Client
     * opens an Lnb. Default null when lnb is not opened.
     */
    // TODO: pending on aidl interface
    //shared_ptr<ITunerLnb> mTunerLnb;

    /**
     * A Lnb HAL interface that is ready before migrating to the TunerLnb.
     * This is a temprary interface before Tuner Framework migrates to use TunerService.
     * Default null when the HAL service does not exist.
     */
    sp<ILnb> mLnb;
};
}  // namespace android

#endif  // _ANDROID_MEDIA_TV_LNB_CLIENT_H_
Loading