Loading media/java/android/media/tv/AdBuffer.aidl 0 → 100644 +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.tv; parcelable AdBuffer; media/java/android/media/tv/AdBuffer.java 0 → 100644 +163 −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.tv; import android.annotation.NonNull; import android.media.MediaCodec.BufferFlag; import android.os.Parcel; import android.os.Parcelable; import android.os.SharedMemory; /** * Buffer for advertisement data. * @hide */ public class AdBuffer implements Parcelable { private final int mId; @NonNull private final String mMimeType; @NonNull private final SharedMemory mBuffer; private final int mOffset; private final int mLength; private final long mPresentationTimeUs; private final int mFlags; public AdBuffer( int id, @NonNull String mimeType, @NonNull SharedMemory buffer, int offset, int length, long presentationTimeUs, @BufferFlag int flags) { this.mId = id; this.mMimeType = mimeType; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mimeType); this.mBuffer = buffer; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, buffer); this.mOffset = offset; this.mLength = length; this.mPresentationTimeUs = presentationTimeUs; this.mFlags = flags; } /** * Gets corresponding AD request ID. */ public int getId() { return mId; } /** * Gets the mime type of the data. */ @NonNull public String getMimeType() { return mMimeType; } /** * Gets the shared memory which stores the data. */ @NonNull public SharedMemory getSharedMemory() { return mBuffer; } /** * Gets the offset of the buffer. */ public int getOffset() { return mOffset; } /** * Gets the data length. */ public int getLength() { return mLength; } /** * Gets the presentation time in microseconds. */ public long getPresentationTimeUs() { return mPresentationTimeUs; } /** * Gets the flags. */ @BufferFlag public int getFlags() { return mFlags; } @Override public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { dest.writeInt(mId); dest.writeString(mMimeType); dest.writeTypedObject(mBuffer, flags); dest.writeInt(mOffset); dest.writeInt(mLength); dest.writeLong(mPresentationTimeUs); dest.writeInt(mFlags); } @Override public int describeContents() { return 0; } private AdBuffer(@NonNull Parcel in) { int id = in.readInt(); String mimeType = in.readString(); SharedMemory buffer = (SharedMemory) in.readTypedObject(SharedMemory.CREATOR); int offset = in.readInt(); int length = in.readInt(); long presentationTimeUs = in.readLong(); int flags = in.readInt(); this.mId = id; this.mMimeType = mimeType; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMimeType); this.mBuffer = buffer; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mBuffer); this.mOffset = offset; this.mLength = length; this.mPresentationTimeUs = presentationTimeUs; this.mFlags = flags; } public static final @NonNull Parcelable.Creator<AdBuffer> CREATOR = new Parcelable.Creator<AdBuffer>() { @Override public AdBuffer[] newArray(int size) { return new AdBuffer[size]; } @Override public AdBuffer createFromParcel(Parcel in) { return new AdBuffer(in); } }; } media/java/android/media/tv/AdRequest.java +42 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.media.tv; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.net.Uri; import android.os.Bundle; import android.os.Parcel; import android.os.ParcelFileDescriptor; Loading Loading @@ -69,10 +70,25 @@ public final class AdRequest implements Parcelable { private final long mEchoInterval; private final String mMediaFileType; private final Bundle mMetadata; private final Uri mUri; public AdRequest(int id, @RequestType int requestType, @Nullable ParcelFileDescriptor fileDescriptor, long startTime, long stopTime, long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) { this(id, requestType, fileDescriptor, null, startTime, stopTime, echoInterval, mediaFileType, metadata); } /** @hide */ public AdRequest(int id, @RequestType int requestType, @Nullable Uri uri, long startTime, long stopTime, long echoInterval, @NonNull Bundle metadata) { this(id, requestType, null, uri, startTime, stopTime, echoInterval, null, metadata); } private AdRequest(int id, @RequestType int requestType, @Nullable ParcelFileDescriptor fileDescriptor, @Nullable Uri uri, long startTime, long stopTime, long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) { mId = id; mRequestType = requestType; mFileDescriptor = fileDescriptor; Loading @@ -81,15 +97,23 @@ public final class AdRequest implements Parcelable { mEchoInterval = echoInterval; mMediaFileType = mediaFileType; mMetadata = metadata; mUri = uri; } private AdRequest(Parcel source) { mId = source.readInt(); mRequestType = source.readInt(); if (source.readInt() != 0) { int readInt = source.readInt(); if (readInt == 1) { mFileDescriptor = ParcelFileDescriptor.CREATOR.createFromParcel(source); mUri = null; } else if (readInt == 2) { String stringUri = source.readString(); mUri = stringUri == null ? null : Uri.parse(stringUri); mFileDescriptor = null; } else { mFileDescriptor = null; mUri = null; } mStartTime = source.readLong(); mStopTime = source.readLong(); Loading Loading @@ -117,13 +141,25 @@ public final class AdRequest implements Parcelable { * Gets the file descriptor of the AD media. * * @return The file descriptor of the AD media. Can be {@code null} for * {@link #REQUEST_TYPE_STOP} * {@link #REQUEST_TYPE_STOP} or a URI is used. */ @Nullable public ParcelFileDescriptor getFileDescriptor() { return mFileDescriptor; } /** * Gets the URI of the AD media. * * @return The URI of the AD media. Can be {@code null} for {@link #REQUEST_TYPE_STOP} or a file * descriptor is used. * @hide */ @Nullable public Uri getUri() { return mUri; } /** * Gets the start time of the AD media in milliseconds. * <p>0 means start immediately Loading Loading @@ -189,6 +225,10 @@ public final class AdRequest implements Parcelable { if (mFileDescriptor != null) { dest.writeInt(1); mFileDescriptor.writeToParcel(dest, flags); } else if (mUri != null) { dest.writeInt(2); String stringUri = mUri.toString(); dest.writeString(stringUri); } else { dest.writeInt(0); } Loading media/java/android/media/tv/AdResponse.java +4 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ public final class AdResponse implements Parcelable { RESPONSE_TYPE_PLAYING, RESPONSE_TYPE_FINISHED, RESPONSE_TYPE_STOPPED, RESPONSE_TYPE_ERROR RESPONSE_TYPE_ERROR, RESPONSE_TYPE_BUFFERING }) public @interface ResponseType {} Loading @@ -42,6 +43,8 @@ public final class AdResponse implements Parcelable { public static final int RESPONSE_TYPE_FINISHED = 2; public static final int RESPONSE_TYPE_STOPPED = 3; public static final int RESPONSE_TYPE_ERROR = 4; /** @hide */ public static final int RESPONSE_TYPE_BUFFERING = 5; public static final @NonNull Parcelable.Creator<AdResponse> CREATOR = new Parcelable.Creator<AdResponse>() { Loading media/java/android/media/tv/ITvInputClient.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media.tv; import android.content.ComponentName; import android.media.tv.AdBuffer; import android.media.tv.AdResponse; import android.media.tv.AitInfo; import android.media.tv.BroadcastInfoResponse; Loading Loading @@ -59,4 +60,5 @@ oneway interface ITvInputClient { // For ad response void onAdResponse(in AdResponse response, int seq); void onAdBufferConsumed(in AdBuffer buffer, int seq); } Loading
media/java/android/media/tv/AdBuffer.aidl 0 → 100644 +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.tv; parcelable AdBuffer;
media/java/android/media/tv/AdBuffer.java 0 → 100644 +163 −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.tv; import android.annotation.NonNull; import android.media.MediaCodec.BufferFlag; import android.os.Parcel; import android.os.Parcelable; import android.os.SharedMemory; /** * Buffer for advertisement data. * @hide */ public class AdBuffer implements Parcelable { private final int mId; @NonNull private final String mMimeType; @NonNull private final SharedMemory mBuffer; private final int mOffset; private final int mLength; private final long mPresentationTimeUs; private final int mFlags; public AdBuffer( int id, @NonNull String mimeType, @NonNull SharedMemory buffer, int offset, int length, long presentationTimeUs, @BufferFlag int flags) { this.mId = id; this.mMimeType = mimeType; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mimeType); this.mBuffer = buffer; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, buffer); this.mOffset = offset; this.mLength = length; this.mPresentationTimeUs = presentationTimeUs; this.mFlags = flags; } /** * Gets corresponding AD request ID. */ public int getId() { return mId; } /** * Gets the mime type of the data. */ @NonNull public String getMimeType() { return mMimeType; } /** * Gets the shared memory which stores the data. */ @NonNull public SharedMemory getSharedMemory() { return mBuffer; } /** * Gets the offset of the buffer. */ public int getOffset() { return mOffset; } /** * Gets the data length. */ public int getLength() { return mLength; } /** * Gets the presentation time in microseconds. */ public long getPresentationTimeUs() { return mPresentationTimeUs; } /** * Gets the flags. */ @BufferFlag public int getFlags() { return mFlags; } @Override public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { dest.writeInt(mId); dest.writeString(mMimeType); dest.writeTypedObject(mBuffer, flags); dest.writeInt(mOffset); dest.writeInt(mLength); dest.writeLong(mPresentationTimeUs); dest.writeInt(mFlags); } @Override public int describeContents() { return 0; } private AdBuffer(@NonNull Parcel in) { int id = in.readInt(); String mimeType = in.readString(); SharedMemory buffer = (SharedMemory) in.readTypedObject(SharedMemory.CREATOR); int offset = in.readInt(); int length = in.readInt(); long presentationTimeUs = in.readLong(); int flags = in.readInt(); this.mId = id; this.mMimeType = mimeType; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mMimeType); this.mBuffer = buffer; com.android.internal.util.AnnotationValidations.validate( NonNull.class, null, mBuffer); this.mOffset = offset; this.mLength = length; this.mPresentationTimeUs = presentationTimeUs; this.mFlags = flags; } public static final @NonNull Parcelable.Creator<AdBuffer> CREATOR = new Parcelable.Creator<AdBuffer>() { @Override public AdBuffer[] newArray(int size) { return new AdBuffer[size]; } @Override public AdBuffer createFromParcel(Parcel in) { return new AdBuffer(in); } }; }
media/java/android/media/tv/AdRequest.java +42 −2 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.media.tv; import android.annotation.IntDef; import android.annotation.NonNull; import android.annotation.Nullable; import android.net.Uri; import android.os.Bundle; import android.os.Parcel; import android.os.ParcelFileDescriptor; Loading Loading @@ -69,10 +70,25 @@ public final class AdRequest implements Parcelable { private final long mEchoInterval; private final String mMediaFileType; private final Bundle mMetadata; private final Uri mUri; public AdRequest(int id, @RequestType int requestType, @Nullable ParcelFileDescriptor fileDescriptor, long startTime, long stopTime, long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) { this(id, requestType, fileDescriptor, null, startTime, stopTime, echoInterval, mediaFileType, metadata); } /** @hide */ public AdRequest(int id, @RequestType int requestType, @Nullable Uri uri, long startTime, long stopTime, long echoInterval, @NonNull Bundle metadata) { this(id, requestType, null, uri, startTime, stopTime, echoInterval, null, metadata); } private AdRequest(int id, @RequestType int requestType, @Nullable ParcelFileDescriptor fileDescriptor, @Nullable Uri uri, long startTime, long stopTime, long echoInterval, @Nullable String mediaFileType, @NonNull Bundle metadata) { mId = id; mRequestType = requestType; mFileDescriptor = fileDescriptor; Loading @@ -81,15 +97,23 @@ public final class AdRequest implements Parcelable { mEchoInterval = echoInterval; mMediaFileType = mediaFileType; mMetadata = metadata; mUri = uri; } private AdRequest(Parcel source) { mId = source.readInt(); mRequestType = source.readInt(); if (source.readInt() != 0) { int readInt = source.readInt(); if (readInt == 1) { mFileDescriptor = ParcelFileDescriptor.CREATOR.createFromParcel(source); mUri = null; } else if (readInt == 2) { String stringUri = source.readString(); mUri = stringUri == null ? null : Uri.parse(stringUri); mFileDescriptor = null; } else { mFileDescriptor = null; mUri = null; } mStartTime = source.readLong(); mStopTime = source.readLong(); Loading Loading @@ -117,13 +141,25 @@ public final class AdRequest implements Parcelable { * Gets the file descriptor of the AD media. * * @return The file descriptor of the AD media. Can be {@code null} for * {@link #REQUEST_TYPE_STOP} * {@link #REQUEST_TYPE_STOP} or a URI is used. */ @Nullable public ParcelFileDescriptor getFileDescriptor() { return mFileDescriptor; } /** * Gets the URI of the AD media. * * @return The URI of the AD media. Can be {@code null} for {@link #REQUEST_TYPE_STOP} or a file * descriptor is used. * @hide */ @Nullable public Uri getUri() { return mUri; } /** * Gets the start time of the AD media in milliseconds. * <p>0 means start immediately Loading Loading @@ -189,6 +225,10 @@ public final class AdRequest implements Parcelable { if (mFileDescriptor != null) { dest.writeInt(1); mFileDescriptor.writeToParcel(dest, flags); } else if (mUri != null) { dest.writeInt(2); String stringUri = mUri.toString(); dest.writeString(stringUri); } else { dest.writeInt(0); } Loading
media/java/android/media/tv/AdResponse.java +4 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,8 @@ public final class AdResponse implements Parcelable { RESPONSE_TYPE_PLAYING, RESPONSE_TYPE_FINISHED, RESPONSE_TYPE_STOPPED, RESPONSE_TYPE_ERROR RESPONSE_TYPE_ERROR, RESPONSE_TYPE_BUFFERING }) public @interface ResponseType {} Loading @@ -42,6 +43,8 @@ public final class AdResponse implements Parcelable { public static final int RESPONSE_TYPE_FINISHED = 2; public static final int RESPONSE_TYPE_STOPPED = 3; public static final int RESPONSE_TYPE_ERROR = 4; /** @hide */ public static final int RESPONSE_TYPE_BUFFERING = 5; public static final @NonNull Parcelable.Creator<AdResponse> CREATOR = new Parcelable.Creator<AdResponse>() { Loading
media/java/android/media/tv/ITvInputClient.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package android.media.tv; import android.content.ComponentName; import android.media.tv.AdBuffer; import android.media.tv.AdResponse; import android.media.tv.AitInfo; import android.media.tv.BroadcastInfoResponse; Loading Loading @@ -59,4 +60,5 @@ oneway interface ITvInputClient { // For ad response void onAdResponse(in AdResponse response, int seq); void onAdBufferConsumed(in AdBuffer buffer, int seq); }