Merge "Unhide Ad Insertion APIs"

This commit is contained in:
David Zhao
2023-02-04 09:43:32 +00:00
committed by Android (Google) Code Review
6 changed files with 64 additions and 20 deletions

View File

@@ -26330,8 +26330,23 @@ package android.media.session {
package android.media.tv {
public final class AdBuffer implements android.os.Parcelable {
ctor public AdBuffer(int, @NonNull String, @NonNull android.os.SharedMemory, int, int, long, int);
method public int describeContents();
method public int getFlags();
method public int getId();
method public int getLength();
method @NonNull public String getMimeType();
method public int getOffset();
method public long getPresentationTimeUs();
method @NonNull public android.os.SharedMemory getSharedMemory();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdBuffer> CREATOR;
}
public final class AdRequest implements android.os.Parcelable {
ctor public AdRequest(int, int, @Nullable android.os.ParcelFileDescriptor, long, long, long, @Nullable String, @NonNull android.os.Bundle);
ctor public AdRequest(int, int, @Nullable android.net.Uri, long, long, long, @NonNull android.os.Bundle);
method public int describeContents();
method public long getEchoIntervalMillis();
method @Nullable public android.os.ParcelFileDescriptor getFileDescriptor();
@@ -26341,6 +26356,7 @@ package android.media.tv {
method public int getRequestType();
method public long getStartTimeMillis();
method public long getStopTimeMillis();
method @Nullable public android.net.Uri getUri();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdRequest> CREATOR;
field public static final int REQUEST_TYPE_START = 1; // 0x1
@@ -26355,6 +26371,7 @@ package android.media.tv {
method public int getResponseType();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.media.tv.AdResponse> CREATOR;
field public static final int RESPONSE_TYPE_BUFFERING = 5; // 0x5
field public static final int RESPONSE_TYPE_ERROR = 4; // 0x4
field public static final int RESPONSE_TYPE_FINISHED = 2; // 0x2
field public static final int RESPONSE_TYPE_PLAYING = 1; // 0x1
@@ -27108,6 +27125,7 @@ package android.media.tv {
public abstract static class TvInputService.Session implements android.view.KeyEvent.Callback {
ctor public TvInputService.Session(android.content.Context);
method public void layoutSurface(int, int, int, int);
method public void notifyAdBufferConsumed(@NonNull android.media.tv.AdBuffer);
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>);
@@ -27123,6 +27141,7 @@ package android.media.tv {
method public void notifyTuned(@NonNull android.net.Uri);
method public void notifyVideoAvailable();
method public void notifyVideoUnavailable(int);
method public void onAdBuffer(@NonNull android.media.tv.AdBuffer);
method public void onAppPrivateCommand(@NonNull String, android.os.Bundle);
method public android.view.View onCreateOverlayView();
method public boolean onGenericMotionEvent(android.view.MotionEvent);
@@ -27409,9 +27428,11 @@ package android.media.tv.interactive {
ctor public TvInteractiveAppService.Session(@NonNull android.content.Context);
method public boolean isMediaViewEnabled();
method @CallSuper public void layoutSurface(int, int, int, int);
method @CallSuper public void notifyAdBuffer(@NonNull android.media.tv.AdBuffer);
method @CallSuper public final void notifyBiInteractiveAppCreated(@NonNull android.net.Uri, @Nullable String);
method @CallSuper public void notifySessionStateChanged(int, int);
method @CallSuper public final void notifyTeletextAppStateChanged(int);
method public void onAdBufferConsumed(@NonNull android.media.tv.AdBuffer);
method public void onAdResponse(@NonNull android.media.tv.AdResponse);
method public void onBroadcastInfoResponse(@NonNull android.media.tv.BroadcastInfoResponse);
method public void onContentAllowed();

View File

@@ -24,9 +24,8 @@ import android.os.SharedMemory;
/**
* Buffer for advertisement data.
* @hide
*/
public class AdBuffer implements Parcelable {
public final class AdBuffer implements Parcelable {
private final int mId;
@NonNull
private final String mMimeType;
@@ -60,6 +59,8 @@ public class AdBuffer implements Parcelable {
/**
* Gets corresponding AD request ID.
*
* @return The ID of the ad request
*/
public int getId() {
return mId;
@@ -67,6 +68,8 @@ public class AdBuffer implements Parcelable {
/**
* Gets the mime type of the data.
*
* @return The mime type of the data.
*/
@NonNull
public String getMimeType() {
@@ -74,7 +77,17 @@ public class AdBuffer implements Parcelable {
}
/**
* Gets the shared memory which stores the data.
* Gets the {@link SharedMemory} which stores the data.
*
* <p> Information on how the data in this buffer is formatted can be found using
* {@link AdRequest#getMetadata()}
* <p> This data lives in a {@link SharedMemory} instance because of the
* potentially large amount of data needed to store the ad. This optimizes the
* data communication between the ad data source and the service responsible for
* its display.
*
* @see SharedMemory#create(String, int)
* @return The {@link SharedMemory} that stores the data for this ad buffer.
*/
@NonNull
public SharedMemory getSharedMemory() {
@@ -82,28 +95,38 @@ public class AdBuffer implements Parcelable {
}
/**
* Gets the offset of the buffer.
* Gets the offset into the shared memory to begin mapping.
*
* @see SharedMemory#map(int, int, int)
* @return The offset of this ad buffer in the shared memory in bytes.
*/
public int getOffset() {
return mOffset;
}
/**
* Gets the data length.
* Gets the data length of this ad buffer.
*
* @return The data length of this ad buffer in bytes.
*/
public int getLength() {
return mLength;
}
/**
* Gets the presentation time in microseconds.
* Gets the presentation time.
*
* @return The presentation time in microseconds.
*/
public long getPresentationTimeUs() {
return mPresentationTimeUs;
}
/**
* Gets the flags.
* Gets the buffer flags for this ad buffer.
*
* @see android.media.MediaCodec
* @return The buffer flags for this ad buffer.
*/
@BufferFlag
public int getFlags() {

View File

@@ -79,7 +79,6 @@ public final class AdRequest implements Parcelable {
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);
@@ -153,7 +152,6 @@ public final class AdRequest implements Parcelable {
*
* @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() {

View File

@@ -43,7 +43,6 @@ 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 =

View File

@@ -1005,9 +1005,10 @@ public abstract class TvInputService extends Service {
/**
* Notifies the advertisement buffer is consumed.
* @hide
*
* @param buffer the {@link AdBuffer} that was consumed.
*/
public void notifyAdBufferConsumed(AdBuffer buffer) {
public void notifyAdBufferConsumed(@NonNull AdBuffer buffer) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
@@ -1320,10 +1321,11 @@ public abstract class TvInputService extends Service {
}
/**
* Called when advertisement buffer is ready.
* @hide
* Called when an advertisement buffer is ready for playback.
*
* @param buffer The {@link AdBuffer} that became ready for playback.
*/
public void onAdBuffer(AdBuffer buffer) {
public void onAdBuffer(@NonNull AdBuffer buffer) {
}
/**

View File

@@ -896,10 +896,10 @@ public abstract class TvInteractiveAppService extends Service {
/**
* Called when an advertisement buffer is consumed.
* @hide
*
* @param buffer The {@link AdBuffer} that was consumed.
*/
public void onAdBufferConsumed(AdBuffer buffer) {
public void onAdBufferConsumed(@NonNull AdBuffer buffer) {
}
/**
@@ -1919,10 +1919,11 @@ public abstract class TvInteractiveAppService extends Service {
/**
* Notifies when the advertisement buffer is filled and ready to be read.
* @hide
*
* @param buffer The {@link AdBuffer} to be received
*/
@CallSuper
public void notifyAdBuffer(AdBuffer buffer) {
public void notifyAdBuffer(@NonNull AdBuffer buffer) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override