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

Commit bd2d5688 authored by Yixiao Luo's avatar Yixiao Luo Committed by Android (Google) Code Review
Browse files

Merge "Add Audio Presentation APIs to TIF"

parents 81592d73 2f838215
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -21369,7 +21369,8 @@ package android.media {
    field @NonNull public static final android.os.Parcelable.Creator<android.media.AudioPlaybackConfiguration> CREATOR;
  }
  public final class AudioPresentation {
  public final class AudioPresentation implements android.os.Parcelable {
    method public int describeContents();
    method public java.util.Map<java.util.Locale,java.lang.String> getLabels();
    method public java.util.Locale getLocale();
    method public int getMasteringIndication();
@@ -21378,6 +21379,7 @@ package android.media {
    method public boolean hasAudioDescription();
    method public boolean hasDialogueEnhancement();
    method public boolean hasSpokenSubtitles();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field public static final int CONTENT_COMMENTARY = 5; // 0x5
    field public static final int CONTENT_DIALOG = 4; // 0x4
    field public static final int CONTENT_EMERGENCY = 6; // 0x6
@@ -21387,11 +21389,14 @@ package android.media {
    field public static final int CONTENT_UNKNOWN = -1; // 0xffffffff
    field public static final int CONTENT_VISUALLY_IMPAIRED = 2; // 0x2
    field public static final int CONTENT_VOICEOVER = 7; // 0x7
    field @NonNull public static final android.os.Parcelable.Creator<android.media.AudioPresentation> CREATOR;
    field public static final int MASTERED_FOR_3D = 3; // 0x3
    field public static final int MASTERED_FOR_HEADPHONE = 4; // 0x4
    field public static final int MASTERED_FOR_STEREO = 1; // 0x1
    field public static final int MASTERED_FOR_SURROUND = 2; // 0x2
    field public static final int MASTERING_NOT_INDICATED = 0; // 0x0
    field public static final int PRESENTATION_ID_UNKNOWN = -1; // 0xffffffff
    field public static final int PROGRAM_ID_UNKNOWN = -1; // 0xffffffff
  }
  public static final class AudioPresentation.Builder {
@@ -27063,6 +27068,8 @@ package android.media.tv {
    method public void layoutSurface(int, int, int, int);
    method public void notifyAdResponse(@NonNull android.media.tv.AdResponse);
    method public void notifyAitInfoUpdated(@NonNull android.media.tv.AitInfo);
    method public void notifyAudioPresentationChanged(@NonNull java.util.List<android.media.AudioPresentation>);
    method public void notifyAudioPresentationSelected(int, int);
    method public void notifyBroadcastInfoResponse(@NonNull android.media.tv.BroadcastInfoResponse);
    method public void notifyChannelRetuned(android.net.Uri);
    method public void notifyContentAllowed();
@@ -27086,6 +27093,7 @@ package android.media.tv {
    method public void onRemoveBroadcastInfo(int);
    method public void onRequestAd(@NonNull android.media.tv.AdRequest);
    method public void onRequestBroadcastInfo(@NonNull android.media.tv.BroadcastInfoRequest);
    method public boolean onSelectAudioPresentation(int, int);
    method public boolean onSelectTrack(int, @Nullable String);
    method public abstract void onSetCaptionEnabled(boolean);
    method public void onSetInteractiveAppNotificationEnabled(boolean);
@@ -27215,11 +27223,13 @@ package android.media.tv {
    ctor public TvView(android.content.Context, android.util.AttributeSet);
    ctor public TvView(android.content.Context, android.util.AttributeSet, int);
    method public boolean dispatchUnhandledInputEvent(android.view.InputEvent);
    method @NonNull public java.util.List<android.media.AudioPresentation> getAudioPresentations();
    method public String getSelectedTrack(int);
    method public java.util.List<android.media.tv.TvTrackInfo> getTracks(int);
    method public boolean onUnhandledInputEvent(android.view.InputEvent);
    method public void overrideTvAppAttributionSource(@NonNull android.content.AttributionSource);
    method public void reset();
    method public void selectAudioPresentation(int, int);
    method public void selectTrack(int, String);
    method public void sendAppPrivateCommand(@NonNull String, android.os.Bundle);
    method public void setCallback(@Nullable android.media.tv.TvView.TvInputCallback);
@@ -27252,6 +27262,8 @@ package android.media.tv {
  public abstract static class TvView.TvInputCallback {
    ctor public TvView.TvInputCallback();
    method public void onAitInfoUpdated(@NonNull String, @NonNull android.media.tv.AitInfo);
    method public void onAudioPresentationSelected(@NonNull String, int, int);
    method public void onAudioPresentationsChanged(@NonNull String, @NonNull java.util.List<android.media.AudioPresentation>);
    method public void onChannelRetuned(String, android.net.Uri);
    method public void onConnectionFailed(String);
    method public void onContentAllowed(String);
+19 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 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;

parcelable AudioPresentation;
+66 −13
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 * Copyright (C) 2022 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.
@@ -19,6 +19,9 @@ package android.media;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.icu.util.ULocale;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -49,7 +52,7 @@ import java.util.Objects;
 * Applications that parse media streams and extract presentation information on their own
 * can create instances of AudioPresentation by using {@link AudioPresentation.Builder} class.
 */
public final class AudioPresentation {
public final class AudioPresentation implements Parcelable {
    private final int mPresentationId;
    private final int mProgramId;
    private final ULocale mLanguage;
@@ -126,7 +129,7 @@ public final class AudioPresentation {
    private final boolean mAudioDescriptionAvailable;
    private final boolean mSpokenSubtitlesAvailable;
    private final boolean mDialogueEnhancementAvailable;
    private final Map<ULocale, CharSequence> mLabels;
    private final HashMap<ULocale, String> mLabels;

    /**
     * No preferred reproduction channel layout.
@@ -160,9 +163,14 @@ public final class AudioPresentation {
    public static final int MASTERED_FOR_HEADPHONE          = 4;

    /**
     * This ID is reserved. No items can be explicitly assigned this ID.
     * Unknown audio presentation ID, this indicates audio presentation ID is not selected.
     */
    private static final int UNKNOWN_ID = -1;
    public static final int PRESENTATION_ID_UNKNOWN = -1;

    /**
     * Unknown audio program ID, this indicates audio program ID is not selected.
     */
    public static final int PROGRAM_ID_UNKNOWN = -1;

    /**
     * This allows an application developer to construct an AudioPresentation object with all the
@@ -191,7 +199,7 @@ public final class AudioPresentation {
                             boolean audioDescriptionAvailable,
                             boolean spokenSubtitlesAvailable,
                             boolean dialogueEnhancementAvailable,
                             @NonNull Map<ULocale, CharSequence> labels) {
                             @NonNull Map<ULocale, String> labels) {
        mPresentationId = presentationId;
        mProgramId = programId;
        mLanguage = language;
@@ -199,7 +207,18 @@ public final class AudioPresentation {
        mAudioDescriptionAvailable = audioDescriptionAvailable;
        mSpokenSubtitlesAvailable = spokenSubtitlesAvailable;
        mDialogueEnhancementAvailable = dialogueEnhancementAvailable;
        mLabels = new HashMap<ULocale, CharSequence>(labels);
        mLabels = new HashMap<ULocale, String>(labels);
    }

    private AudioPresentation(@NonNull Parcel in) {
        mPresentationId = in.readInt();
        mProgramId = in.readInt();
        mLanguage = in.readSerializable(ULocale.class.getClassLoader(), ULocale.class);
        mMasteringIndication = in.readInt();
        mAudioDescriptionAvailable = in.readBoolean();
        mSpokenSubtitlesAvailable = in.readBoolean();
        mDialogueEnhancementAvailable = in.readBoolean();
        mLabels = in.readSerializable(HashMap.class.getClassLoader(), HashMap.class);
    }

    /**
@@ -225,13 +244,13 @@ public final class AudioPresentation {
     */
    public Map<Locale, String> getLabels() {
        Map<Locale, String> localeLabels = new HashMap<Locale, String>(mLabels.size());
        for (Map.Entry<ULocale, CharSequence> entry : mLabels.entrySet()) {
            localeLabels.put(entry.getKey().toLocale(), entry.getValue().toString());
        for (Map.Entry<ULocale, String> entry : mLabels.entrySet()) {
            localeLabels.put(entry.getKey().toLocale(), entry.getValue());
        }
        return localeLabels;
    }

    private Map<ULocale, CharSequence> getULabels() {
    private Map<ULocale, String> getULabels() {
        return mLabels;
    }

@@ -335,13 +354,13 @@ public final class AudioPresentation {
     */
    public static final class Builder {
        private final int mPresentationId;
        private int mProgramId = UNKNOWN_ID;
        private int mProgramId = PROGRAM_ID_UNKNOWN;
        private ULocale mLanguage = new ULocale("");
        private int mMasteringIndication = MASTERING_NOT_INDICATED;
        private boolean mAudioDescriptionAvailable = false;
        private boolean mSpokenSubtitlesAvailable = false;
        private boolean mDialogueEnhancementAvailable = false;
        private Map<ULocale, CharSequence> mLabels = new HashMap<ULocale, CharSequence>();
        private HashMap<ULocale, String> mLabels = new HashMap<ULocale, String>();

        /**
         * Create a {@link Builder}. Any field that should be included in the
@@ -402,7 +421,10 @@ public final class AudioPresentation {
         * @param labels Text label indexed by its locale corresponding to the language code.
         */
        public @NonNull Builder setLabels(@NonNull Map<ULocale, CharSequence> labels) {
            mLabels = new HashMap<ULocale, CharSequence>(labels);
            mLabels.clear();
            for (Map.Entry<ULocale, CharSequence> entry : labels.entrySet()) {
                mLabels.put(entry.getKey(), entry.getValue().toString());
            }
            return this;
        }

@@ -448,4 +470,35 @@ public final class AudioPresentation {
                                           mDialogueEnhancementAvailable, mLabels);
        }
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeInt(getPresentationId());
        dest.writeInt(getProgramId());
        dest.writeSerializable(getULocale());
        dest.writeInt(getMasteringIndication());
        dest.writeBoolean(hasAudioDescription());
        dest.writeBoolean(hasSpokenSubtitles());
        dest.writeBoolean(hasDialogueEnhancement());
        dest.writeSerializable(mLabels);
    }

    @NonNull
    public static final Parcelable.Creator<AudioPresentation> CREATOR =
            new Parcelable.Creator<AudioPresentation>() {
            @Override
            public AudioPresentation createFromParcel(@NonNull Parcel in) {
                return new AudioPresentation(in);
            }

            @Override
            public AudioPresentation[] newArray(int size) {
                return new AudioPresentation[size];
            }
    };
}
+3 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.media.tv;

import android.content.ComponentName;
import android.media.AudioPresentation;
import android.media.tv.AdBuffer;
import android.media.tv.AdResponse;
import android.media.tv.AitInfo;
@@ -37,6 +38,8 @@ oneway interface ITvInputClient {
    void onSessionReleased(int seq);
    void onSessionEvent(in String name, in Bundle args, int seq);
    void onChannelRetuned(in Uri channelUri, int seq);
    void onAudioPresentationsChanged(in List<AudioPresentation> AudioPresentations, int seq);
    void onAudioPresentationSelected(int presentationId, int programId, int seq);
    void onTracksChanged(in List<TvTrackInfo> tracks, int seq);
    void onTrackSelected(int type, in String trackId, int seq);
    void onVideoAvailable(int seq);
+3 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.AttributionSource;
import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Rect;
import android.media.AudioPresentation;
import android.media.PlaybackParams;
import android.media.tv.AdBuffer;
import android.media.tv.AdRequest;
@@ -78,6 +79,8 @@ interface ITvInputManager {
    void tune(in IBinder sessionToken, in Uri channelUri, in Bundle params, int userId);
    void setCaptionEnabled(in IBinder sessionToken, boolean enabled, int userId);
    void selectTrack(in IBinder sessionToken, int type, in String trackId, int userId);
    void selectAudioPresentation(in IBinder sessionToken, int presentationId, int programId,
            int userId);

    void setInteractiveAppNotificationEnabled(in IBinder sessionToken, boolean enabled, int userId);

Loading