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

Commit 2a4b15a3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Split filter event classes to make them top-level"

parents 48c85489 a1209b58
Loading
Loading
Loading
Loading
+0 −118
Original line number Diff line number Diff line
/*
 * 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.
 */

package android.media.tv.tuner;

import android.os.NativeHandle;

/**
 * Demux filter event.
 *
 * @hide
 */
public abstract class FilterEvent {

    /**
     * Section event.
     */
    public static class SectionEvent extends FilterEvent {
        private int mTableId;
        private int mVersion;
        private int mSectionNum;
        private int mDataLength;
    }

    /**
     * Media event.
     */
    public static class MediaEvent extends FilterEvent {
        private int mStreamId;
        private boolean mIsPtsPresent;
        private long mPts;
        private int mDataLength;
        private NativeHandle mHandle;
        private boolean mIsSecureMemory;
        private int mMpuSequenceNumber;
        private boolean mIsPrivateData;
        private AudioExtraMetaData mExtraMetaData;
    }

    /**
     * PES event.
     */
    public static class PesEvent extends FilterEvent {
        private int mStreamId;
        private int mDataLength;
        private int mMpuSequenceNumber;
    }

    /**
     * TS record event.
     */
    public static class TsRecordEvent extends FilterEvent {
        private int mTpid;
        private int mIndexMask;
        private long mByteNumber;
    }

    /**
     * MMPT record event.
     */
    public static class MmtpRecordEvent extends FilterEvent {
        private int mScHevcIndexMask;
        private long mByteNumber;
    }

    /**
     * Download event.
     */
    public static class DownloadEvent extends FilterEvent {
        private int mItemId;
        private int mMpuSequenceNumber;
        private int mItemFragmentIndex;
        private int mLastItemFragmentIndex;
        private int mDataLength;
    }

    /**
     * IP payload event.
     */
    public static class IpPayloadEvent extends FilterEvent {
        private int mDataLength;
    }

    /**
     * TEMI event.
     */
    public static class TemiEvent extends FilterEvent {
        private long mPts;
        private byte mDescrTag;
        private byte[] mDescrData;
    }

    /**
     *  Extra Meta Data from AD (Audio Descriptor) according to
     *  ETSI TS 101 154 V2.1.1.
     */
    public static class AudioExtraMetaData {
        private byte mAdFade;
        private byte mAdPan;
        private byte mVersionTextTag;
        private byte mAdGainCenter;
        private byte mAdGainFront;
        private byte mAdGainSurround;
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -40,6 +40,10 @@ public abstract class FilterSettings {
    @FilterType
    public abstract int getType();

    public Settings getSettings() {
        return mSettings;
    }

    // TODO: more builders and getters

    /**
+5 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SystemApi;
import android.content.Context;
import android.media.tv.tuner.FilterSettings.Settings;
import android.media.tv.tuner.TunerConstants.DemuxPidType;
import android.media.tv.tuner.TunerConstants.FilterSubtype;
import android.media.tv.tuner.TunerConstants.FilterType;
@@ -29,6 +30,7 @@ import android.media.tv.tuner.TunerConstants.LnbPosition;
import android.media.tv.tuner.TunerConstants.LnbTone;
import android.media.tv.tuner.TunerConstants.LnbVoltage;
import android.media.tv.tuner.TunerConstants.Result;
import android.media.tv.tuner.filter.FilterEvent;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
@@ -488,8 +490,9 @@ public final class Tuner implements AutoCloseable {
         */
        public int configure(FilterSettings settings) {
            int subType = -1;
            if (settings.mSettings != null) {
                subType = settings.mSettings.getType();
            Settings s = settings.getSettings();
            if (s != null) {
                subType = s.getType();
            }
            return nativeConfigureFilter(settings.getType(), subType, settings);
        }
+14 −2
Original line number Diff line number Diff line
@@ -30,14 +30,26 @@ import android.media.tv.tuner.TunerConstants.FilterType;
public final class TunerUtils {
    private static final String PERMISSION = android.Manifest.permission.ACCESS_TV_TUNER;

    static void checkTunerPermission(Context context) {
    /**
     * Checks whether the caller has permission to access tuner.
     *
     * @param context context of the caller.
     * @throws SecurityException if the caller doesn't have the permission.
     */
    public static void checkTunerPermission(Context context) {
        if (context.checkCallingOrSelfPermission(PERMISSION)
                != PackageManager.PERMISSION_GRANTED) {
            throw new SecurityException("Caller must have " + PERMISSION + " permission.");
        }
    }

    static int getFilterSubtype(@FilterType int mainType, @FilterSubtype int subtype) {
    /**
     * Gets the corresponding filter subtype constant defined in tuner HAL.
     *
     * @param mainType filter main type.
     * @param subtype filter subtype.
     */
    public static int getFilterSubtype(@FilterType int mainType, @FilterSubtype int subtype) {
        if (mainType == TunerConstants.FILTER_TYPE_TS) {
            switch (subtype) {
                case TunerConstants.FILTER_SUBTYPE_UNDEFINED:
+31 −0
Original line number Diff line number Diff line
/*
 * 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.
 */

package android.media.tv.tuner.filter;

/**
 * Extra Meta Data from AD (Audio Descriptor) according to
 * ETSI TS 101 154 V2.1.1.
 * @hide
 */
public class AudioExtraMetaData {
    private byte mAdFade;
    private byte mAdPan;
    private byte mVersionTextTag;
    private byte mAdGainCenter;
    private byte mAdGainFront;
    private byte mAdGainSurround;
}
Loading