Do not trim audio samples by changing their timestamp

MP4 edit lists sometimes ask to start playback between two samples.
If this happens, we currently change the timestamp of the first
sample to zero to trim it (e.g. to display the first frame for a
slightly shorter period of time). However, we can't do this to audio
samples are they have an inherent duration and trimming them this
way is not possible.

#minor-release

PiperOrigin-RevId: 543420218
This commit is contained in:
tonihei 2023-06-26 13:26:35 +00:00 committed by Tianyi Feng
parent 7996766b22
commit 2322462404
308 changed files with 1920 additions and 3 deletions

View File

@ -726,6 +726,7 @@ public final class CastPlayer extends BasePlayer {
/** This method is not supported and does nothing. */
@Override
public void setVideoTextureView(@Nullable TextureView textureView) {}
/** This method is not supported and does nothing. */
@Override
public void clearVideoTextureView(@Nullable TextureView textureView) {}

View File

@ -43,14 +43,18 @@ import java.util.Arrays;
/** The duration of the item in microseconds, or {@link C#TIME_UNSET} if unknown. */
public final long durationUs;
/**
* The default start position of the item in microseconds, or {@link C#TIME_UNSET} if unknown.
*/
public final long defaultPositionUs;
/** Whether the item is live content, or {@code false} if unknown. */
public final boolean isLive;
/** The original media item that has been set or added to the playlist. */
public final MediaItem mediaItem;
/** The {@linkplain MediaInfo#getContentId() content ID} of the cast media queue item. */
public final String contentId;

View File

@ -45,12 +45,16 @@ public final class AdOverlayInfo {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({PURPOSE_CONTROLS, PURPOSE_CLOSE_AD, PURPOSE_OTHER, PURPOSE_NOT_VISIBLE})
public @interface Purpose {}
/** Purpose for playback controls overlaying the player. */
public static final int PURPOSE_CONTROLS = 1;
/** Purpose for ad close buttons overlaying the player. */
public static final int PURPOSE_CLOSE_AD = 2;
/** Purpose for other overlays. */
public static final int PURPOSE_OTHER = 3;
/** Purpose for overlays that are not visible. */
public static final int PURPOSE_NOT_VISIBLE = 4;
@ -94,8 +98,10 @@ public final class AdOverlayInfo {
/** The overlay view. */
public final View view;
/** The purpose of the overlay view. */
public final @Purpose int purpose;
/** An optional, detailed reason that the overlay view is needed. */
@Nullable public final String reasonDetail;

View File

@ -62,8 +62,10 @@ public final class AdPlaybackState implements Bundleable {
* C#TIME_END_OF_SOURCE} to indicate a postroll ad.
*/
public final long timeUs;
/** The number of ads in the ad group, or {@link C#LENGTH_UNSET} if unknown. */
public final int count;
/**
* The original number of ads in the ad group in case the ad group is only partially available,
* or {@link C#LENGTH_UNSET} if unknown. An ad can be partially available when a server side
@ -71,17 +73,22 @@ public final class AdPlaybackState implements Bundleable {
* missing.
*/
public final int originalCount;
/** The URI of each ad in the ad group. */
public final @NullableType Uri[] uris;
/** The state of each ad in the ad group. */
public final @AdState int[] states;
/** The durations of each ad in the ad group, in microseconds. */
public final long[] durationsUs;
/**
* The offset in microseconds which should be added to the content stream when resuming playback
* after the ad group.
*/
public final long contentResumeOffsetUs;
/** Whether this ad group is server-side inserted and part of the content stream. */
public final boolean isServerSideInserted;
@ -535,14 +542,19 @@ public final class AdPlaybackState implements Bundleable {
AD_STATE_ERROR,
})
public @interface AdState {}
/** State for an ad that does not yet have a URL. */
public static final int AD_STATE_UNAVAILABLE = 0;
/** State for an ad that has a URL but has not yet been played. */
public static final int AD_STATE_AVAILABLE = 1;
/** State for an ad that was skipped. */
public static final int AD_STATE_SKIPPED = 2;
/** State for an ad that was played in full. */
public static final int AD_STATE_PLAYED = 3;
/** State for an ad that could not be loaded. */
public static final int AD_STATE_ERROR = 4;
@ -564,12 +576,15 @@ public final class AdPlaybackState implements Bundleable {
/** The number of ad groups. */
public final int adGroupCount;
/** The position offset in the first unplayed ad at which to begin playback, in microseconds. */
public final long adResumePositionUs;
/**
* The duration of the content period in microseconds, if known. {@link C#TIME_UNSET} otherwise.
*/
public final long contentDurationUs;
/**
* The number of ad groups that have been removed. Ad groups with indices between {@code 0}
* (inclusive) and {@code removedAdGroupCount} (exclusive) will be empty and must not be modified

View File

@ -131,12 +131,16 @@ public final class AudioAttributes implements Bundleable {
/** The {@link C.AudioContentType}. */
public final @C.AudioContentType int contentType;
/** The {@link C.AudioFlags}. */
public final @C.AudioFlags int flags;
/** The {@link C.AudioUsage}. */
public final @C.AudioUsage int usage;
/** The {@link C.AudioAllowedCapturePolicy}. */
public final @C.AudioAllowedCapturePolicy int allowedCapturePolicy;
/** The {@link C.SpatializationBehavior}. */
public final @C.SpatializationBehavior int spatializationBehavior;

View File

@ -41,6 +41,7 @@ public final class AuxEffectInfo {
* @see android.media.AudioTrack#attachAuxEffect(int)
*/
public final int effectId;
/**
* The send level for the effect.
*

View File

@ -120,12 +120,16 @@ public final class C {
CRYPTO_TYPE_FRAMEWORK,
})
public @interface CryptoType {}
/** No crypto. */
public static final int CRYPTO_TYPE_NONE = 0;
/** An unsupported crypto type. */
public static final int CRYPTO_TYPE_UNSUPPORTED = 1;
/** Framework crypto in which a {@link MediaCodec} is configured with a {@link MediaCrypto}. */
public static final int CRYPTO_TYPE_FRAMEWORK = 2;
/**
* Applications or extensions may define custom {@code CRYPTO_TYPE_*} constants greater than or
* equal to this value.
@ -142,10 +146,13 @@ public final class C {
@IntDef({CRYPTO_MODE_UNENCRYPTED, CRYPTO_MODE_AES_CTR, CRYPTO_MODE_AES_CBC})
@UnstableApi
public @interface CryptoMode {}
/** See {@link MediaCodec#CRYPTO_MODE_UNENCRYPTED}. */
@UnstableApi public static final int CRYPTO_MODE_UNENCRYPTED = MediaCodec.CRYPTO_MODE_UNENCRYPTED;
/** See {@link MediaCodec#CRYPTO_MODE_AES_CTR}. */
@UnstableApi public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
/** See {@link MediaCodec#CRYPTO_MODE_AES_CBC}. */
@UnstableApi public static final int CRYPTO_MODE_AES_CBC = MediaCodec.CRYPTO_MODE_AES_CBC;
@ -217,50 +224,73 @@ public final class C {
ENCODING_PCM_FLOAT
})
public @interface PcmEncoding {}
/** See {@link AudioFormat#ENCODING_INVALID}. */
@UnstableApi public static final int ENCODING_INVALID = AudioFormat.ENCODING_INVALID;
/** See {@link AudioFormat#ENCODING_PCM_8BIT}. */
@UnstableApi public static final int ENCODING_PCM_8BIT = AudioFormat.ENCODING_PCM_8BIT;
/** See {@link AudioFormat#ENCODING_PCM_16BIT}. */
@UnstableApi public static final int ENCODING_PCM_16BIT = AudioFormat.ENCODING_PCM_16BIT;
/** Like {@link #ENCODING_PCM_16BIT}, but with the bytes in big endian order. */
@UnstableApi public static final int ENCODING_PCM_16BIT_BIG_ENDIAN = 0x10000000;
/** PCM encoding with 24 bits per sample. */
@UnstableApi public static final int ENCODING_PCM_24BIT = 0x20000000;
/** PCM encoding with 32 bits per sample. */
@UnstableApi public static final int ENCODING_PCM_32BIT = 0x30000000;
/** See {@link AudioFormat#ENCODING_PCM_FLOAT}. */
@UnstableApi public static final int ENCODING_PCM_FLOAT = AudioFormat.ENCODING_PCM_FLOAT;
/** See {@link AudioFormat#ENCODING_MP3}. */
@UnstableApi public static final int ENCODING_MP3 = AudioFormat.ENCODING_MP3;
/** See {@link AudioFormat#ENCODING_AAC_LC}. */
@UnstableApi public static final int ENCODING_AAC_LC = AudioFormat.ENCODING_AAC_LC;
/** See {@link AudioFormat#ENCODING_AAC_HE_V1}. */
@UnstableApi public static final int ENCODING_AAC_HE_V1 = AudioFormat.ENCODING_AAC_HE_V1;
/** See {@link AudioFormat#ENCODING_AAC_HE_V2}. */
@UnstableApi public static final int ENCODING_AAC_HE_V2 = AudioFormat.ENCODING_AAC_HE_V2;
/** See {@link AudioFormat#ENCODING_AAC_XHE}. */
@UnstableApi public static final int ENCODING_AAC_XHE = AudioFormat.ENCODING_AAC_XHE;
/** See {@link AudioFormat#ENCODING_AAC_ELD}. */
@UnstableApi public static final int ENCODING_AAC_ELD = AudioFormat.ENCODING_AAC_ELD;
/** AAC Error Resilient Bit-Sliced Arithmetic Coding. */
@UnstableApi public static final int ENCODING_AAC_ER_BSAC = 0x40000000;
/** See {@link AudioFormat#ENCODING_AC3}. */
@UnstableApi public static final int ENCODING_AC3 = AudioFormat.ENCODING_AC3;
/** See {@link AudioFormat#ENCODING_E_AC3}. */
@UnstableApi public static final int ENCODING_E_AC3 = AudioFormat.ENCODING_E_AC3;
/** See {@link AudioFormat#ENCODING_E_AC3_JOC}. */
@UnstableApi public static final int ENCODING_E_AC3_JOC = AudioFormat.ENCODING_E_AC3_JOC;
/** See {@link AudioFormat#ENCODING_AC4}. */
@UnstableApi public static final int ENCODING_AC4 = AudioFormat.ENCODING_AC4;
/** See {@link AudioFormat#ENCODING_DTS}. */
@UnstableApi public static final int ENCODING_DTS = AudioFormat.ENCODING_DTS;
/** See {@link AudioFormat#ENCODING_DTS_HD}. */
@UnstableApi public static final int ENCODING_DTS_HD = AudioFormat.ENCODING_DTS_HD;
// TODO(internal b/283949283): Use AudioFormat.ENCODING_DTS_UHD_P2 when Android 14 is released.
@UnstableApi public static final int ENCODING_DTS_UHD_P2 = 0x0000001e;
/** See {@link AudioFormat#ENCODING_DOLBY_TRUEHD}. */
@UnstableApi public static final int ENCODING_DOLBY_TRUEHD = AudioFormat.ENCODING_DOLBY_TRUEHD;
/** See {@link AudioFormat#ENCODING_OPUS}. */
@UnstableApi public static final int ENCODING_OPUS = AudioFormat.ENCODING_OPUS;
@ -277,6 +307,7 @@ public final class C {
/** See {@link AudioAttributes#SPATIALIZATION_BEHAVIOR_AUTO}. */
public static final int SPATIALIZATION_BEHAVIOR_AUTO =
AudioAttributes.SPATIALIZATION_BEHAVIOR_AUTO;
/** See {@link AudioAttributes#SPATIALIZATION_BEHAVIOR_NEVER}. */
public static final int SPATIALIZATION_BEHAVIOR_NEVER =
AudioAttributes.SPATIALIZATION_BEHAVIOR_NEVER;
@ -305,20 +336,28 @@ public final class C {
STREAM_TYPE_DEFAULT
})
public @interface StreamType {}
/** See {@link AudioManager#STREAM_ALARM}. */
@UnstableApi public static final int STREAM_TYPE_ALARM = AudioManager.STREAM_ALARM;
/** See {@link AudioManager#STREAM_DTMF}. */
@UnstableApi public static final int STREAM_TYPE_DTMF = AudioManager.STREAM_DTMF;
/** See {@link AudioManager#STREAM_MUSIC}. */
@UnstableApi public static final int STREAM_TYPE_MUSIC = AudioManager.STREAM_MUSIC;
/** See {@link AudioManager#STREAM_NOTIFICATION}. */
@UnstableApi public static final int STREAM_TYPE_NOTIFICATION = AudioManager.STREAM_NOTIFICATION;
/** See {@link AudioManager#STREAM_RING}. */
@UnstableApi public static final int STREAM_TYPE_RING = AudioManager.STREAM_RING;
/** See {@link AudioManager#STREAM_SYSTEM}. */
@UnstableApi public static final int STREAM_TYPE_SYSTEM = AudioManager.STREAM_SYSTEM;
/** See {@link AudioManager#STREAM_VOICE_CALL}. */
@UnstableApi public static final int STREAM_TYPE_VOICE_CALL = AudioManager.STREAM_VOICE_CALL;
/** The default stream type used by audio renderers. Equal to {@link #STREAM_TYPE_MUSIC}. */
@UnstableApi public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC;
@ -341,15 +380,20 @@ public final class C {
VOLUME_FLAG_VIBRATE,
})
public @interface VolumeFlags {}
/** See {@link AudioManager#FLAG_SHOW_UI}. */
public static final int VOLUME_FLAG_SHOW_UI = AudioManager.FLAG_SHOW_UI;
/** See {@link AudioManager#FLAG_ALLOW_RINGER_MODES}. */
public static final int VOLUME_FLAG_ALLOW_RINGER_MODES = AudioManager.FLAG_ALLOW_RINGER_MODES;
/** See {@link AudioManager#FLAG_PLAY_SOUND}. */
public static final int VOLUME_FLAG_PLAY_SOUND = AudioManager.FLAG_PLAY_SOUND;
/** See {@link AudioManager#FLAG_REMOVE_SOUND_AND_VIBRATE}. */
public static final int VOLUME_FLAG_REMOVE_SOUND_AND_VIBRATE =
AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE;
/** See {@link AudioManager#FLAG_VIBRATE}. */
public static final int VOLUME_FLAG_VIBRATE = AudioManager.FLAG_VIBRATE;
@ -377,34 +421,44 @@ public final class C {
AUDIO_CONTENT_TYPE_UNKNOWN
})
public @interface AudioContentType {}
/** See {@link AudioAttributes#CONTENT_TYPE_MOVIE}. */
public static final int AUDIO_CONTENT_TYPE_MOVIE = AudioAttributes.CONTENT_TYPE_MOVIE;
/**
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_MOVIE} instead.
*/
@UnstableApi @Deprecated public static final int CONTENT_TYPE_MOVIE = AUDIO_CONTENT_TYPE_MOVIE;
/** See {@link AudioAttributes#CONTENT_TYPE_MUSIC}. */
public static final int AUDIO_CONTENT_TYPE_MUSIC = AudioAttributes.CONTENT_TYPE_MUSIC;
/**
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_MUSIC} instead.
*/
@UnstableApi @Deprecated public static final int CONTENT_TYPE_MUSIC = AUDIO_CONTENT_TYPE_MUSIC;
/** See {@link AudioAttributes#CONTENT_TYPE_SONIFICATION}. */
public static final int AUDIO_CONTENT_TYPE_SONIFICATION =
AudioAttributes.CONTENT_TYPE_SONIFICATION;
/**
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_SONIFICATION} instead.
*/
@UnstableApi @Deprecated
public static final int CONTENT_TYPE_SONIFICATION = AUDIO_CONTENT_TYPE_SONIFICATION;
/** See {@link AudioAttributes#CONTENT_TYPE_SPEECH}. */
public static final int AUDIO_CONTENT_TYPE_SPEECH = AudioAttributes.CONTENT_TYPE_SPEECH;
/**
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_SPEECH} instead.
*/
@UnstableApi @Deprecated public static final int CONTENT_TYPE_SPEECH = AUDIO_CONTENT_TYPE_SPEECH;
/** See {@link AudioAttributes#CONTENT_TYPE_UNKNOWN}. */
public static final int AUDIO_CONTENT_TYPE_UNKNOWN = AudioAttributes.CONTENT_TYPE_UNKNOWN;
/**
* @deprecated Use {@link #AUDIO_CONTENT_TYPE_UNKNOWN} instead.
*/
@ -426,6 +480,7 @@ public final class C {
flag = true,
value = {FLAG_AUDIBILITY_ENFORCED})
public @interface AudioFlags {}
/** See {@link android.media.AudioAttributes#FLAG_AUDIBILITY_ENFORCED}. */
public static final int FLAG_AUDIBILITY_ENFORCED =
android.media.AudioAttributes.FLAG_AUDIBILITY_ENFORCED;
@ -464,45 +519,61 @@ public final class C {
USAGE_VOICE_COMMUNICATION_SIGNALLING
})
public @interface AudioUsage {}
/** See {@link android.media.AudioAttributes#USAGE_ALARM}. */
public static final int USAGE_ALARM = android.media.AudioAttributes.USAGE_ALARM;
/** See {@link android.media.AudioAttributes#USAGE_ASSISTANCE_ACCESSIBILITY}. */
public static final int USAGE_ASSISTANCE_ACCESSIBILITY =
android.media.AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY;
/** See {@link android.media.AudioAttributes#USAGE_ASSISTANCE_NAVIGATION_GUIDANCE}. */
public static final int USAGE_ASSISTANCE_NAVIGATION_GUIDANCE =
android.media.AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE;
/** See {@link android.media.AudioAttributes#USAGE_ASSISTANCE_SONIFICATION}. */
public static final int USAGE_ASSISTANCE_SONIFICATION =
android.media.AudioAttributes.USAGE_ASSISTANCE_SONIFICATION;
/** See {@link android.media.AudioAttributes#USAGE_ASSISTANT}. */
public static final int USAGE_ASSISTANT = android.media.AudioAttributes.USAGE_ASSISTANT;
/** See {@link android.media.AudioAttributes#USAGE_GAME}. */
public static final int USAGE_GAME = android.media.AudioAttributes.USAGE_GAME;
/** See {@link android.media.AudioAttributes#USAGE_MEDIA}. */
public static final int USAGE_MEDIA = android.media.AudioAttributes.USAGE_MEDIA;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION}. */
public static final int USAGE_NOTIFICATION = android.media.AudioAttributes.USAGE_NOTIFICATION;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_DELAYED}. */
public static final int USAGE_NOTIFICATION_COMMUNICATION_DELAYED =
android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_DELAYED;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_INSTANT}. */
public static final int USAGE_NOTIFICATION_COMMUNICATION_INSTANT =
android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_REQUEST}. */
public static final int USAGE_NOTIFICATION_COMMUNICATION_REQUEST =
android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION_EVENT}. */
public static final int USAGE_NOTIFICATION_EVENT =
android.media.AudioAttributes.USAGE_NOTIFICATION_EVENT;
/** See {@link android.media.AudioAttributes#USAGE_NOTIFICATION_RINGTONE}. */
public static final int USAGE_NOTIFICATION_RINGTONE =
android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE;
/** See {@link android.media.AudioAttributes#USAGE_UNKNOWN}. */
public static final int USAGE_UNKNOWN = android.media.AudioAttributes.USAGE_UNKNOWN;
/** See {@link android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION}. */
public static final int USAGE_VOICE_COMMUNICATION =
android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION;
/** See {@link android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION_SIGNALLING}. */
public static final int USAGE_VOICE_COMMUNICATION_SIGNALLING =
android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING;
@ -518,10 +589,13 @@ public final class C {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({ALLOW_CAPTURE_BY_ALL, ALLOW_CAPTURE_BY_NONE, ALLOW_CAPTURE_BY_SYSTEM})
public @interface AudioAllowedCapturePolicy {}
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_ALL}. */
public static final int ALLOW_CAPTURE_BY_ALL = AudioAttributes.ALLOW_CAPTURE_BY_ALL;
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_NONE}. */
public static final int ALLOW_CAPTURE_BY_NONE = AudioAttributes.ALLOW_CAPTURE_BY_NONE;
/** See {@link android.media.AudioAttributes#ALLOW_CAPTURE_BY_SYSTEM}. */
public static final int ALLOW_CAPTURE_BY_SYSTEM = AudioAttributes.ALLOW_CAPTURE_BY_SYSTEM;
@ -547,19 +621,26 @@ public final class C {
BUFFER_FLAG_DECODE_ONLY
})
public @interface BufferFlags {}
/** Indicates that a buffer holds a synchronization sample. */
@UnstableApi public static final int BUFFER_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME;
/** Flag for empty buffers that signal that the end of the stream was reached. */
@UnstableApi
public static final int BUFFER_FLAG_END_OF_STREAM = MediaCodec.BUFFER_FLAG_END_OF_STREAM;
/** Indicates that a buffer is known to contain the first media sample of the stream. */
@UnstableApi public static final int BUFFER_FLAG_FIRST_SAMPLE = 1 << 27; // 0x08000000
/** Indicates that a buffer has supplemental data. */
@UnstableApi public static final int BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28; // 0x10000000
/** Indicates that a buffer is known to contain the last media sample of the stream. */
@UnstableApi public static final int BUFFER_FLAG_LAST_SAMPLE = 1 << 29; // 0x20000000
/** Indicates that a buffer is (at least partially) encrypted. */
@UnstableApi public static final int BUFFER_FLAG_ENCRYPTED = 1 << 30; // 0x40000000
/** Indicates that a buffer should be decoded but not rendered. */
@UnstableApi public static final int BUFFER_FLAG_DECODE_ONLY = 1 << 31; // 0x80000000
@ -573,10 +654,13 @@ public final class C {
@Target(TYPE_USE)
@IntDef(value = {VIDEO_OUTPUT_MODE_NONE, VIDEO_OUTPUT_MODE_YUV, VIDEO_OUTPUT_MODE_SURFACE_YUV})
public @interface VideoOutputMode {}
/** Video decoder output mode is not set. */
@UnstableApi public static final int VIDEO_OUTPUT_MODE_NONE = -1;
/** Video decoder output mode that outputs raw 4:2:0 YUV planes. */
@UnstableApi public static final int VIDEO_OUTPUT_MODE_YUV = 0;
/** Video decoder output mode that renders 4:2:0 YUV planes directly to a surface. */
@UnstableApi public static final int VIDEO_OUTPUT_MODE_SURFACE_YUV = 1;
@ -598,14 +682,17 @@ public final class C {
VIDEO_SCALING_MODE_DEFAULT
})
public @interface VideoScalingMode {}
/** See {@link MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT}. */
@UnstableApi
public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT =
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT;
/** See {@link MediaCodec#VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING}. */
@UnstableApi
public static final int VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING =
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT_WITH_CROPPING;
/** A default video scaling mode for {@link MediaCodec}-based renderers. */
@UnstableApi public static final int VIDEO_SCALING_MODE_DEFAULT = VIDEO_SCALING_MODE_SCALE_TO_FIT;
@ -618,11 +705,13 @@ public final class C {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF, VIDEO_CHANGE_FRAME_RATE_STRATEGY_ONLY_IF_SEAMLESS})
public @interface VideoChangeFrameRateStrategy {}
/**
* Strategy to never call {@link Surface#setFrameRate}. Use this strategy if you prefer to call
* {@link Surface#setFrameRate} directly from application code.
*/
@UnstableApi public static final int VIDEO_CHANGE_FRAME_RATE_STRATEGY_OFF = Integer.MIN_VALUE;
/**
* Strategy to call {@link Surface#setFrameRate} with {@link
* Surface#CHANGE_FRAME_RATE_ONLY_IF_SEAMLESS} when the output frame rate is known.
@ -644,9 +733,11 @@ public final class C {
flag = true,
value = {SELECTION_FLAG_DEFAULT, SELECTION_FLAG_FORCED, SELECTION_FLAG_AUTOSELECT})
public @interface SelectionFlags {}
// LINT.IfChange(selection_flags)
/** Indicates that the track should be selected if user preferences do not state otherwise. */
public static final int SELECTION_FLAG_DEFAULT = 1;
/**
* Indicates that the track should be selected if its language matches the language of the
* selected audio track and user preferences do not state otherwise. Only applies to text tracks.
@ -657,6 +748,7 @@ public final class C {
* for more info.
*/
public static final int SELECTION_FLAG_FORCED = 1 << 1; // 2
/**
* Indicates that the player may choose to play the track in absence of an explicit user
* preference.
@ -690,32 +782,42 @@ public final class C {
CONTENT_TYPE_OTHER
})
public @interface ContentType {}
/** Value representing a DASH manifest. */
public static final int CONTENT_TYPE_DASH = 0;
/**
* @deprecated Use {@link #CONTENT_TYPE_DASH} instead.
*/
@Deprecated @UnstableApi public static final int TYPE_DASH = CONTENT_TYPE_DASH;
/** Value representing a Smooth Streaming manifest. */
public static final int CONTENT_TYPE_SS = 1;
/**
* @deprecated Use {@link #CONTENT_TYPE_SS} instead.
*/
@Deprecated @UnstableApi public static final int TYPE_SS = CONTENT_TYPE_SS;
/** Value representing an HLS manifest. */
public static final int CONTENT_TYPE_HLS = 2;
/**
* @deprecated Use {@link #CONTENT_TYPE_HLS} instead.
*/
@Deprecated @UnstableApi public static final int TYPE_HLS = CONTENT_TYPE_HLS;
/** Value representing an RTSP stream. */
public static final int CONTENT_TYPE_RTSP = 3;
/**
* @deprecated Use {@link #CONTENT_TYPE_RTSP} instead.
*/
@Deprecated @UnstableApi public static final int TYPE_RTSP = CONTENT_TYPE_RTSP;
/** Value representing files other than DASH, HLS or Smooth Streaming manifests, or RTSP URIs. */
public static final int CONTENT_TYPE_OTHER = 4;
/**
* @deprecated Use {@link #CONTENT_TYPE_OTHER} instead.
*/
@ -723,14 +825,18 @@ public final class C {
/** A return value for methods where the end of an input was encountered. */
@UnstableApi public static final int RESULT_END_OF_INPUT = -1;
/**
* A return value for methods where the length of parsed data exceeds the maximum length allowed.
*/
@UnstableApi public static final int RESULT_MAX_LENGTH_EXCEEDED = -2;
/** A return value for methods where nothing was read. */
@UnstableApi public static final int RESULT_NOTHING_READ = -3;
/** A return value for methods where a buffer was read. */
@UnstableApi public static final int RESULT_BUFFER_READ = -4;
/** A return value for methods where a format was read. */
@UnstableApi public static final int RESULT_FORMAT_READ = -5;
@ -758,24 +864,33 @@ public final class C {
DATA_TYPE_MEDIA_PROGRESSIVE_LIVE
})
public @interface DataType {}
/** A data type constant for data of unknown or unspecified type. */
@UnstableApi public static final int DATA_TYPE_UNKNOWN = 0;
/** A data type constant for media, typically containing media samples. */
@UnstableApi public static final int DATA_TYPE_MEDIA = 1;
/** A data type constant for media, typically containing only initialization data. */
@UnstableApi public static final int DATA_TYPE_MEDIA_INITIALIZATION = 2;
/** A data type constant for drm or encryption data. */
@UnstableApi public static final int DATA_TYPE_DRM = 3;
/** A data type constant for a manifest file. */
@UnstableApi public static final int DATA_TYPE_MANIFEST = 4;
/** A data type constant for time synchronization data. */
@UnstableApi public static final int DATA_TYPE_TIME_SYNCHRONIZATION = 5;
/** A data type constant for ads loader data. */
@UnstableApi public static final int DATA_TYPE_AD = 6;
/**
* A data type constant for live progressive media streams, typically containing media samples.
*/
@UnstableApi public static final int DATA_TYPE_MEDIA_PROGRESSIVE_LIVE = 7;
/**
* Applications or extensions may define custom {@code DATA_TYPE_*} constants greater than or
* equal to this value.
@ -806,24 +921,34 @@ public final class C {
TRACK_TYPE_NONE,
})
public @interface TrackType {}
/** A type constant for a fake or empty track. */
public static final int TRACK_TYPE_NONE = -2;
/** A type constant for tracks of unknown type. */
public static final int TRACK_TYPE_UNKNOWN = -1;
/** A type constant for tracks of some default type, where the type itself is unknown. */
public static final int TRACK_TYPE_DEFAULT = 0;
/** A type constant for audio tracks. */
public static final int TRACK_TYPE_AUDIO = 1;
/** A type constant for video tracks. */
public static final int TRACK_TYPE_VIDEO = 2;
/** A type constant for text tracks. */
public static final int TRACK_TYPE_TEXT = 3;
/** A type constant for image tracks. */
public static final int TRACK_TYPE_IMAGE = 4;
/** A type constant for metadata tracks. */
public static final int TRACK_TYPE_METADATA = 5;
/** A type constant for camera motion tracks. */
public static final int TRACK_TYPE_CAMERA_MOTION = 6;
/**
* Applications or extensions may define custom {@code TRACK_TYPE_*} constants greater than or
* equal to this value.
@ -850,16 +975,22 @@ public final class C {
SELECTION_REASON_TRICK_PLAY
})
public @interface SelectionReason {}
/** A selection reason constant for selections whose reasons are unknown or unspecified. */
@UnstableApi public static final int SELECTION_REASON_UNKNOWN = 0;
/** A selection reason constant for an initial track selection. */
@UnstableApi public static final int SELECTION_REASON_INITIAL = 1;
/** A selection reason constant for an manual (i.e. user initiated) track selection. */
@UnstableApi public static final int SELECTION_REASON_MANUAL = 2;
/** A selection reason constant for an adaptive track selection. */
@UnstableApi public static final int SELECTION_REASON_ADAPTIVE = 3;
/** A selection reason constant for a trick play track selection. */
@UnstableApi public static final int SELECTION_REASON_TRICK_PLAY = 4;
/**
* Applications or extensions may define custom {@code SELECTION_REASON_*} constants greater than
* or equal to this value.
@ -871,6 +1002,7 @@ public final class C {
/** A default seek back increment, in milliseconds. */
public static final long DEFAULT_SEEK_BACK_INCREMENT_MS = 5_000;
/** A default seek forward increment, in milliseconds. */
public static final long DEFAULT_SEEK_FORWARD_INCREMENT_MS = 15_000;
@ -952,12 +1084,16 @@ public final class C {
STEREO_MODE_STEREO_MESH
})
public @interface StereoMode {}
/** Indicates Monoscopic stereo layout, used with 360/3D/VR videos. */
@UnstableApi public static final int STEREO_MODE_MONO = 0;
/** Indicates Top-Bottom stereo layout, used with 360/3D/VR videos. */
@UnstableApi public static final int STEREO_MODE_TOP_BOTTOM = 1;
/** Indicates Left-Right stereo layout, used with 360/3D/VR videos. */
@UnstableApi public static final int STEREO_MODE_LEFT_RIGHT = 2;
/**
* Indicates a stereo layout where the left and right eyes have separate meshes, used with
* 360/3D/VR videos.
@ -975,10 +1111,13 @@ public final class C {
@Target(TYPE_USE)
@IntDef({Format.NO_VALUE, COLOR_SPACE_BT601, COLOR_SPACE_BT709, COLOR_SPACE_BT2020})
public @interface ColorSpace {}
/** See {@link MediaFormat#COLOR_STANDARD_BT601_PAL}. */
@UnstableApi public static final int COLOR_SPACE_BT601 = MediaFormat.COLOR_STANDARD_BT601_PAL;
/** See {@link MediaFormat#COLOR_STANDARD_BT709}. */
@UnstableApi public static final int COLOR_SPACE_BT709 = MediaFormat.COLOR_STANDARD_BT709;
/** See {@link MediaFormat#COLOR_STANDARD_BT2020}. */
@UnstableApi public static final int COLOR_SPACE_BT2020 = MediaFormat.COLOR_STANDARD_BT2020;
@ -1002,10 +1141,13 @@ public final class C {
COLOR_TRANSFER_HLG
})
public @interface ColorTransfer {}
/** See {@link MediaFormat#COLOR_TRANSFER_LINEAR}. */
@UnstableApi public static final int COLOR_TRANSFER_LINEAR = MediaFormat.COLOR_TRANSFER_LINEAR;
/** See {@link MediaFormat#COLOR_TRANSFER_SDR_VIDEO}. The SMPTE 170M transfer function. */
@UnstableApi public static final int COLOR_TRANSFER_SDR = MediaFormat.COLOR_TRANSFER_SDR_VIDEO;
/**
* See {@link android.hardware.DataSpace#TRANSFER_SRGB}. The standard RGB transfer function, used
* for some SDR use-cases like image input.
@ -1013,13 +1155,16 @@ public final class C {
// Value sourced from ordering here:
// https://cs.android.com/android/platform/superproject/+/master:frameworks/native/headers/media_plugin/media/hardware/VideoAPI.h;drc=55e9bd7c487ee235631f302ab8626776547ac913;l=138.
@UnstableApi public static final int COLOR_TRANSFER_SRGB = 2;
/**
* See {@link android.hardware.DataSpace#TRANSFER_GAMMA2_2}. The Gamma 2.2 transfer function, used
* for some SDR use-cases like tone-mapping.
*/
@UnstableApi public static final int COLOR_TRANSFER_GAMMA_2_2 = 10;
/** See {@link MediaFormat#COLOR_TRANSFER_ST2084}. */
@UnstableApi public static final int COLOR_TRANSFER_ST2084 = MediaFormat.COLOR_TRANSFER_ST2084;
/** See {@link MediaFormat#COLOR_TRANSFER_HLG}. */
@UnstableApi public static final int COLOR_TRANSFER_HLG = MediaFormat.COLOR_TRANSFER_HLG;
@ -1034,8 +1179,10 @@ public final class C {
@Target(TYPE_USE)
@IntDef({Format.NO_VALUE, COLOR_RANGE_LIMITED, COLOR_RANGE_FULL})
public @interface ColorRange {}
/** See {@link MediaFormat#COLOR_RANGE_LIMITED}. */
@UnstableApi public static final int COLOR_RANGE_LIMITED = MediaFormat.COLOR_RANGE_LIMITED;
/** See {@link MediaFormat#COLOR_RANGE_FULL}. */
@UnstableApi public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL;
@ -1052,12 +1199,16 @@ public final class C {
PROJECTION_MESH
})
public @interface Projection {}
/** Conventional rectangular projection. */
@UnstableApi public static final int PROJECTION_RECTANGULAR = 0;
/** Equirectangular spherical projection. */
@UnstableApi public static final int PROJECTION_EQUIRECTANGULAR = 1;
/** Cube map projection. */
@UnstableApi public static final int PROJECTION_CUBEMAP = 2;
/** 3-D mesh projection. */
@UnstableApi public static final int PROJECTION_MESH = 3;
@ -1101,29 +1252,40 @@ public final class C {
NETWORK_TYPE_OTHER
})
public @interface NetworkType {}
/** Unknown network type. */
@UnstableApi public static final int NETWORK_TYPE_UNKNOWN = 0;
/** No network connection. */
@UnstableApi public static final int NETWORK_TYPE_OFFLINE = 1;
/** Network type for a Wifi connection. */
@UnstableApi public static final int NETWORK_TYPE_WIFI = 2;
/** Network type for a 2G cellular connection. */
@UnstableApi public static final int NETWORK_TYPE_2G = 3;
/** Network type for a 3G cellular connection. */
@UnstableApi public static final int NETWORK_TYPE_3G = 4;
/** Network type for a 4G cellular connection. */
@UnstableApi public static final int NETWORK_TYPE_4G = 5;
/** Network type for a 5G stand-alone (SA) cellular connection. */
@UnstableApi public static final int NETWORK_TYPE_5G_SA = 9;
/** Network type for a 5G non-stand-alone (NSA) cellular connection. */
@UnstableApi public static final int NETWORK_TYPE_5G_NSA = 10;
/**
* Network type for cellular connections which cannot be mapped to one of {@link
* #NETWORK_TYPE_2G}, {@link #NETWORK_TYPE_3G}, or {@link #NETWORK_TYPE_4G}.
*/
@UnstableApi public static final int NETWORK_TYPE_CELLULAR_UNKNOWN = 6;
/** Network type for an Ethernet connection. */
@UnstableApi public static final int NETWORK_TYPE_ETHERNET = 7;
/** Network type for other connections which are not Wifi or cellular (e.g. VPN, Bluetooth). */
@UnstableApi public static final int NETWORK_TYPE_OTHER = 8;
@ -1138,12 +1300,14 @@ public final class C {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({WAKE_MODE_NONE, WAKE_MODE_LOCAL, WAKE_MODE_NETWORK})
public @interface WakeMode {}
/**
* A wake mode that will not cause the player to hold any locks.
*
* <p>This is suitable for applications that do not play media with the screen off.
*/
public static final int WAKE_MODE_NONE = 0;
/**
* A wake mode that will cause the player to hold a {@link android.os.PowerManager.WakeLock}
* during playback.
@ -1152,6 +1316,7 @@ public final class C {
* over wifi.
*/
public static final int WAKE_MODE_LOCAL = 1;
/**
* A wake mode that will cause the player to hold a {@link android.os.PowerManager.WakeLock} and a
* {@link android.net.wifi.WifiManager.WifiLock} during playback.
@ -1195,50 +1360,65 @@ public final class C {
ROLE_FLAG_TRICK_PLAY
})
public @interface RoleFlags {}
// LINT.IfChange(role_flags)
/** Indicates a main track. */
public static final int ROLE_FLAG_MAIN = 1;
/**
* Indicates an alternate track. For example a video track recorded from an different view point
* than the main track(s).
*/
public static final int ROLE_FLAG_ALTERNATE = 1 << 1;
/**
* Indicates a supplementary track, meaning the track has lower importance than the main track(s).
* For example a video track that provides a visual accompaniment to a main audio track.
*/
public static final int ROLE_FLAG_SUPPLEMENTARY = 1 << 2;
/** Indicates the track contains commentary, for example from the director. */
public static final int ROLE_FLAG_COMMENTARY = 1 << 3;
/**
* Indicates the track is in a different language from the original, for example dubbed audio or
* translated captions.
*/
public static final int ROLE_FLAG_DUB = 1 << 4;
/** Indicates the track contains information about a current emergency. */
public static final int ROLE_FLAG_EMERGENCY = 1 << 5;
/**
* Indicates the track contains captions. This flag may be set on video tracks to indicate the
* presence of burned in captions.
*/
public static final int ROLE_FLAG_CAPTION = 1 << 6;
/**
* Indicates the track contains subtitles. This flag may be set on video tracks to indicate the
* presence of burned in subtitles.
*/
public static final int ROLE_FLAG_SUBTITLE = 1 << 7;
/** Indicates the track contains a visual sign-language interpretation of an audio track. */
public static final int ROLE_FLAG_SIGN = 1 << 8;
/** Indicates the track contains an audio or textual description of a video track. */
public static final int ROLE_FLAG_DESCRIBES_VIDEO = 1 << 9;
/** Indicates the track contains a textual description of music and sound. */
public static final int ROLE_FLAG_DESCRIBES_MUSIC_AND_SOUND = 1 << 10;
/** Indicates the track is designed for improved intelligibility of dialogue. */
public static final int ROLE_FLAG_ENHANCED_DIALOG_INTELLIGIBILITY = 1 << 11;
/** Indicates the track contains a transcription of spoken dialog. */
public static final int ROLE_FLAG_TRANSCRIBES_DIALOG = 1 << 12;
/** Indicates the track contains a text that has been edited for ease of reading. */
public static final int ROLE_FLAG_EASY_TO_READ = 1 << 13;
/** Indicates the track is intended for trick play. */
public static final int ROLE_FLAG_TRICK_PLAY = 1 << 14;
@ -1261,9 +1441,11 @@ public final class C {
FORMAT_UNSUPPORTED_TYPE
})
public @interface FormatSupport {}
// TODO(b/172315872) Renderer was a link. Link to equivalent concept or remove @code.
/** The {@code Renderer} is capable of rendering the format. */
@UnstableApi public static final int FORMAT_HANDLED = 0b100;
/**
* The {@code Renderer} is capable of rendering formats with the same MIME type, but the
* properties of the format exceed the renderer's capabilities. There is a chance the renderer
@ -1275,6 +1457,7 @@ public final class C {
* by the underlying H264 decoder.
*/
@UnstableApi public static final int FORMAT_EXCEEDS_CAPABILITIES = 0b011;
/**
* The {@code Renderer} is capable of rendering formats with the same MIME type, but is not
* capable of rendering the format because the format's drm protection is not supported.
@ -1284,6 +1467,7 @@ public final class C {
* renderer only supports Widevine.
*/
@UnstableApi public static final int FORMAT_UNSUPPORTED_DRM = 0b010;
/**
* The {@code Renderer} is a general purpose renderer for formats of the same top-level type, but
* is not capable of rendering the format or any other format with the same MIME type because the
@ -1293,6 +1477,7 @@ public final class C {
* matches audio/[subtype], but there does not exist a suitable decoder for [subtype].
*/
@UnstableApi public static final int FORMAT_UNSUPPORTED_SUBTYPE = 0b001;
/**
* The {@code Renderer} is not capable of rendering the format, either because it does not support
* the format's top-level type, or because it's a specialized renderer for a different MIME type.

View File

@ -43,8 +43,10 @@ public final class DeviceInfo implements Bundleable {
PLAYBACK_TYPE_REMOTE,
})
public @interface PlaybackType {}
/** Playback happens on the local device (e.g. phone). */
public static final int PLAYBACK_TYPE_LOCAL = 0;
/** Playback happens outside of the device (e.g. a cast device). */
public static final int PLAYBACK_TYPE_REMOTE = 1;
@ -126,12 +128,15 @@ public final class DeviceInfo implements Bundleable {
/** The type of playback. */
public final @PlaybackType int playbackType;
/** The minimum volume that the device supports. */
@IntRange(from = 0)
public final int minVolume;
/** The maximum volume that the device supports, or {@code 0} if unspecified. */
@IntRange(from = 0)
public final int maxVolume;
/**
* The {@linkplain MediaRouter2.RoutingController#getId() routing controller id} of the associated
* {@link MediaRouter2.RoutingController}, or null if unset or {@link #playbackType} is {@link

View File

@ -265,10 +265,13 @@ public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
* applies to all schemes).
*/
public final UUID uuid;
/** The URL of the server to which license requests should be made. May be null if unknown. */
@Nullable public final String licenseServerUrl;
/** The mimeType of {@link #data}. */
public final String mimeType;
/** The initialization data. May be null for scheme support checks only. */
@Nullable public final byte[] data;

View File

@ -47,40 +47,58 @@ public final class FileTypes {
MIDI, AVI
})
public @interface Type {}
/** Unknown file type. */
public static final int UNKNOWN = -1;
/** File type for the AC-3 and E-AC-3 formats. */
public static final int AC3 = 0;
/** File type for the AC-4 format. */
public static final int AC4 = 1;
/** File type for the ADTS format. */
public static final int ADTS = 2;
/** File type for the AMR format. */
public static final int AMR = 3;
/** File type for the FLAC format. */
public static final int FLAC = 4;
/** File type for the FLV format. */
public static final int FLV = 5;
/** File type for the Matroska and WebM formats. */
public static final int MATROSKA = 6;
/** File type for the MP3 format. */
public static final int MP3 = 7;
/** File type for the MP4 format. */
public static final int MP4 = 8;
/** File type for the Ogg format. */
public static final int OGG = 9;
/** File type for the MPEG-PS format. */
public static final int PS = 10;
/** File type for the MPEG-TS format. */
public static final int TS = 11;
/** File type for the WAV format. */
public static final int WAV = 12;
/** File type for the WebVTT format. */
public static final int WEBVTT = 13;
/** File type for the JPEG format. */
public static final int JPEG = 14;
/** File type for the MIDI format. */
public static final int MIDI = 15;
/** File type for the AVI format. */
public static final int AVI = 16;

View File

@ -686,14 +686,19 @@ public final class Format implements Bundleable {
/** An identifier for the format, or null if unknown or not applicable. */
@Nullable public final String id;
/** The human readable label, or null if unknown or not applicable. */
@Nullable public final String label;
/** The language as an IETF BCP 47 conformant tag, or null if unknown or not applicable. */
@Nullable public final String language;
/** Track selection flags. */
public final @C.SelectionFlags int selectionFlags;
/** Track role flags. */
public final @C.RoleFlags int roleFlags;
/**
* The average bitrate in bits per second, or {@link #NO_VALUE} if unknown or not applicable. The
* way in which this field is populated depends on the type of media to which the format
@ -716,6 +721,7 @@ public final class Format implements Bundleable {
* </ul>
*/
@UnstableApi public final int averageBitrate;
/**
* The peak bitrate in bits per second, or {@link #NO_VALUE} if unknown or not applicable. The way
* in which this field is populated depends on the type of media to which the format corresponds:
@ -735,14 +741,17 @@ public final class Format implements Bundleable {
* </ul>
*/
@UnstableApi public final int peakBitrate;
/**
* The bitrate in bits per second. This is the peak bitrate if known, or else the average bitrate
* if known, or else {@link Format#NO_VALUE}. Equivalent to: {@code peakBitrate != NO_VALUE ?
* peakBitrate : averageBitrate}.
*/
@UnstableApi public final int bitrate;
/** Codecs of the format as described in RFC 6381, or null if unknown or not applicable. */
@Nullable public final String codecs;
/** Metadata, or null if unknown or not applicable. */
@UnstableApi @Nullable public final Metadata metadata;
@ -755,16 +764,19 @@ public final class Format implements Bundleable {
/** The sample MIME type, or null if unknown or not applicable. */
@Nullable public final String sampleMimeType;
/**
* The maximum size of a buffer of data (typically one sample), or {@link #NO_VALUE} if unknown or
* not applicable.
*/
@UnstableApi public final int maxInputSize;
/**
* Initialization data that must be provided to the decoder. Will not be null, but may be empty if
* initialization data is not required.
*/
@UnstableApi public final List<byte[]> initializationData;
/** DRM initialization data if the stream is protected, or null otherwise. */
@UnstableApi @Nullable public final DrmInitData drmInitData;
@ -779,25 +791,32 @@ public final class Format implements Bundleable {
/** The width of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. */
public final int width;
/** The height of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. */
public final int height;
/** The frame rate in frames per second, or {@link #NO_VALUE} if unknown or not applicable. */
public final float frameRate;
/**
* The clockwise rotation that should be applied to the video for it to be rendered in the correct
* orientation, or 0 if unknown or not applicable. Only 0, 90, 180 and 270 are supported.
*/
@UnstableApi public final int rotationDegrees;
/** The width to height ratio of pixels in the video, or 1.0 if unknown or not applicable. */
public final float pixelWidthHeightRatio;
/** The projection data for 360/VR video, or null if not applicable. */
@UnstableApi @Nullable public final byte[] projectionData;
/**
* The stereo layout for 360/3D/VR video, or {@link #NO_VALUE} if not applicable. Valid stereo
* modes are {@link C#STEREO_MODE_MONO}, {@link C#STEREO_MODE_TOP_BOTTOM}, {@link
* C#STEREO_MODE_LEFT_RIGHT}, {@link C#STEREO_MODE_STEREO_MESH}.
*/
@UnstableApi public final @C.StereoMode int stereoMode;
/** The color metadata associated with the video, or null if not applicable. */
@UnstableApi @Nullable public final ColorInfo colorInfo;
@ -805,15 +824,19 @@ public final class Format implements Bundleable {
/** The number of audio channels, or {@link #NO_VALUE} if unknown or not applicable. */
public final int channelCount;
/** The audio sampling rate in Hz, or {@link #NO_VALUE} if unknown or not applicable. */
public final int sampleRate;
/** The {@link C.PcmEncoding} for PCM audio. Set to {@link #NO_VALUE} for other media types. */
@UnstableApi public final @C.PcmEncoding int pcmEncoding;
/**
* The number of frames to trim from the start of the decoded audio stream, or 0 if not
* applicable.
*/
@UnstableApi public final int encoderDelay;
/**
* The number of frames to trim from the end of the decoded audio stream, or 0 if not applicable.
*/
@ -830,6 +853,7 @@ public final class Format implements Bundleable {
* The number of horizontal tiles in an image, or {@link #NO_VALUE} if not known or applicable.
*/
@UnstableApi public final int tileCountHorizontal;
/** The number of vertical tiles in an image, or {@link #NO_VALUE} if not known or applicable. */
@UnstableApi public final int tileCountVertical;

View File

@ -97,10 +97,13 @@ public class FrameInfo {
/** The width of the frame, in pixels. */
public final int width;
/** The height of the frame, in pixels. */
public final int height;
/** The ratio of width over height for each pixel. */
public final float pixelWidthHeightRatio;
/**
* The offset that must be added to the frame presentation timestamp, in microseconds.
*

View File

@ -26,8 +26,10 @@ public final class IllegalSeekPositionException extends IllegalStateException {
/** The {@link Timeline} in which the seek was attempted. */
public final Timeline timeline;
/** The index of the window being seeked to. */
public final int windowIndex;
/** The seek position in the specified window. */
public final long positionMs;

View File

@ -818,6 +818,7 @@ public final class MediaItem implements Bundleable {
* @deprecated Use {@link #forcedSessionTrackTypes}.
*/
@UnstableApi @Deprecated public final ImmutableList<@C.TrackType Integer> sessionForClearTypes;
/**
* The types of tracks for which to always use a DRM session even if the content is unencrypted.
*/
@ -1114,6 +1115,7 @@ public final class MediaItem implements Bundleable {
/** Optional subtitles to be sideloaded. */
public final ImmutableList<SubtitleConfiguration> subtitleConfigurations;
/**
* @deprecated Use {@link #subtitleConfigurations} instead.
*/
@ -1593,16 +1595,22 @@ public final class MediaItem implements Bundleable {
/** The {@link Uri} to the subtitle file. */
public final Uri uri;
/** The optional MIME type of the subtitle file, or {@code null} if unspecified. */
@Nullable public final String mimeType;
/** The language. */
@Nullable public final String language;
/** The selection flags. */
public final @C.SelectionFlags int selectionFlags;
/** The role flags. */
public final @C.RoleFlags int roleFlags;
/** The label. */
@Nullable public final String label;
/**
* The ID of the subtitles. This will be propagated to the {@link Format#id} of the subtitle
* track created from this configuration.
@ -2165,6 +2173,7 @@ public final class MediaItem implements Bundleable {
* boundaries.
*/
@Nullable public final LocalConfiguration localConfiguration;
/**
* @deprecated Use {@link #localConfiguration} instead.
*/
@ -2178,6 +2187,7 @@ public final class MediaItem implements Bundleable {
/** The clipping properties. */
public final ClippingConfiguration clippingConfiguration;
/**
* @deprecated Use {@link #clippingConfiguration} instead.
*/

View File

@ -643,108 +643,143 @@ public final class MediaMetadata implements Bundleable {
/** Media of undetermined type or a mix of multiple {@linkplain MediaType media types}. */
public static final int MEDIA_TYPE_MIXED = 0;
/** {@link MediaType} for music. */
public static final int MEDIA_TYPE_MUSIC = 1;
/** {@link MediaType} for an audio book chapter. */
public static final int MEDIA_TYPE_AUDIO_BOOK_CHAPTER = 2;
/** {@link MediaType} for a podcast episode. */
public static final int MEDIA_TYPE_PODCAST_EPISODE = 3;
/** {@link MediaType} for a radio station. */
public static final int MEDIA_TYPE_RADIO_STATION = 4;
/** {@link MediaType} for news. */
public static final int MEDIA_TYPE_NEWS = 5;
/** {@link MediaType} for a video. */
public static final int MEDIA_TYPE_VIDEO = 6;
/** {@link MediaType} for a movie trailer. */
public static final int MEDIA_TYPE_TRAILER = 7;
/** {@link MediaType} for a movie. */
public static final int MEDIA_TYPE_MOVIE = 8;
/** {@link MediaType} for a TV show. */
public static final int MEDIA_TYPE_TV_SHOW = 9;
/**
* {@link MediaType} for a group of items (e.g., {@link #MEDIA_TYPE_MUSIC music}) belonging to an
* album.
*/
public static final int MEDIA_TYPE_ALBUM = 10;
/**
* {@link MediaType} for a group of items (e.g., {@link #MEDIA_TYPE_MUSIC music}) from the same
* artist.
*/
public static final int MEDIA_TYPE_ARTIST = 11;
/**
* {@link MediaType} for a group of items (e.g., {@link #MEDIA_TYPE_MUSIC music}) of the same
* genre.
*/
public static final int MEDIA_TYPE_GENRE = 12;
/**
* {@link MediaType} for a group of items (e.g., {@link #MEDIA_TYPE_MUSIC music}) forming a
* playlist.
*/
public static final int MEDIA_TYPE_PLAYLIST = 13;
/**
* {@link MediaType} for a group of items (e.g., {@link #MEDIA_TYPE_MUSIC music}) from the same
* year.
*/
public static final int MEDIA_TYPE_YEAR = 14;
/**
* {@link MediaType} for a group of items forming an audio book. Items in this group are typically
* of type {@link #MEDIA_TYPE_AUDIO_BOOK_CHAPTER}.
*/
public static final int MEDIA_TYPE_AUDIO_BOOK = 15;
/**
* {@link MediaType} for a group of items belonging to a podcast. Items in this group are
* typically of type {@link #MEDIA_TYPE_PODCAST_EPISODE}.
*/
public static final int MEDIA_TYPE_PODCAST = 16;
/**
* {@link MediaType} for a group of items that are part of a TV channel. Items in this group are
* typically of type {@link #MEDIA_TYPE_TV_SHOW}, {@link #MEDIA_TYPE_TV_SERIES} or {@link
* #MEDIA_TYPE_MOVIE}.
*/
public static final int MEDIA_TYPE_TV_CHANNEL = 17;
/**
* {@link MediaType} for a group of items that are part of a TV series. Items in this group are
* typically of type {@link #MEDIA_TYPE_TV_SHOW} or {@link #MEDIA_TYPE_TV_SEASON}.
*/
public static final int MEDIA_TYPE_TV_SERIES = 18;
/**
* {@link MediaType} for a group of items that are part of a TV series. Items in this group are
* typically of type {@link #MEDIA_TYPE_TV_SHOW}.
*/
public static final int MEDIA_TYPE_TV_SEASON = 19;
/** {@link MediaType} for a folder with mixed or undetermined content. */
public static final int MEDIA_TYPE_FOLDER_MIXED = 20;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_ALBUM albums}. */
public static final int MEDIA_TYPE_FOLDER_ALBUMS = 21;
/** {@link MediaType} for a folder containing {@linkplain #FIELD_ARTIST artists}. */
public static final int MEDIA_TYPE_FOLDER_ARTISTS = 22;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_GENRE genres}. */
public static final int MEDIA_TYPE_FOLDER_GENRES = 23;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_PLAYLIST playlists}. */
public static final int MEDIA_TYPE_FOLDER_PLAYLISTS = 24;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_YEAR years}. */
public static final int MEDIA_TYPE_FOLDER_YEARS = 25;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_AUDIO_BOOK audio books}. */
public static final int MEDIA_TYPE_FOLDER_AUDIO_BOOKS = 26;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_PODCAST podcasts}. */
public static final int MEDIA_TYPE_FOLDER_PODCASTS = 27;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_TV_CHANNEL TV channels}. */
public static final int MEDIA_TYPE_FOLDER_TV_CHANNELS = 28;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_TV_SERIES TV series}. */
public static final int MEDIA_TYPE_FOLDER_TV_SERIES = 29;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_TV_SHOW TV shows}. */
public static final int MEDIA_TYPE_FOLDER_TV_SHOWS = 30;
/**
* {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_RADIO_STATION radio
* stations}.
*/
public static final int MEDIA_TYPE_FOLDER_RADIO_STATIONS = 31;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_NEWS news}. */
public static final int MEDIA_TYPE_FOLDER_NEWS = 32;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_VIDEO videos}. */
public static final int MEDIA_TYPE_FOLDER_VIDEOS = 33;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_TRAILER movie trailers}. */
public static final int MEDIA_TYPE_FOLDER_TRAILERS = 34;
/** {@link MediaType} for a folder containing {@linkplain #MEDIA_TYPE_MOVIE movies}. */
public static final int MEDIA_TYPE_FOLDER_MOVIES = 35;
@ -787,6 +822,7 @@ public final class MediaMetadata implements Bundleable {
* @deprecated Use {@link #isBrowsable} set to false instead.
*/
@Deprecated public static final int FOLDER_TYPE_NONE = -1;
/**
* Type for a folder containing media of mixed types.
*
@ -794,12 +830,14 @@ public final class MediaMetadata implements Bundleable {
* #MEDIA_TYPE_FOLDER_MIXED} instead.
*/
@Deprecated public static final int FOLDER_TYPE_MIXED = 0;
/**
* Type for a folder containing only playable media.
*
* @deprecated Use {@link #isBrowsable} set to true instead.
*/
@Deprecated public static final int FOLDER_TYPE_TITLES = 1;
/**
* Type for a folder containing media categorized by album.
*
@ -807,6 +845,7 @@ public final class MediaMetadata implements Bundleable {
* #MEDIA_TYPE_FOLDER_ALBUMS} instead.
*/
@Deprecated public static final int FOLDER_TYPE_ALBUMS = 2;
/**
* Type for a folder containing media categorized by artist.
*
@ -814,6 +853,7 @@ public final class MediaMetadata implements Bundleable {
* #MEDIA_TYPE_FOLDER_ARTISTS} instead.
*/
@Deprecated public static final int FOLDER_TYPE_ARTISTS = 3;
/**
* Type for a folder containing media categorized by genre.
*
@ -821,6 +861,7 @@ public final class MediaMetadata implements Bundleable {
* #MEDIA_TYPE_FOLDER_GENRES} instead.
*/
@Deprecated public static final int FOLDER_TYPE_GENRES = 4;
/**
* Type for a folder containing a playlist.
*
@ -828,6 +869,7 @@ public final class MediaMetadata implements Bundleable {
* #MEDIA_TYPE_FOLDER_PLAYLISTS} instead.
*/
@Deprecated public static final int FOLDER_TYPE_PLAYLISTS = 5;
/**
* Type for a folder containing media categorized by year.
*
@ -910,36 +952,50 @@ public final class MediaMetadata implements Bundleable {
/** Optional title. */
@Nullable public final CharSequence title;
/** Optional artist. */
@Nullable public final CharSequence artist;
/** Optional album title. */
@Nullable public final CharSequence albumTitle;
/** Optional album artist. */
@Nullable public final CharSequence albumArtist;
/** Optional display title. */
@Nullable public final CharSequence displayTitle;
/**
* Optional subtitle.
*
* <p>This is the secondary title of the media, unrelated to closed captions.
*/
@Nullable public final CharSequence subtitle;
/** Optional description. */
@Nullable public final CharSequence description;
/** Optional user {@link Rating}. */
@Nullable public final Rating userRating;
/** Optional overall {@link Rating}. */
@Nullable public final Rating overallRating;
/** Optional artwork data as a compressed byte array. */
@Nullable public final byte[] artworkData;
/** Optional {@link PictureType} of the artwork data. */
@Nullable public final @PictureType Integer artworkDataType;
/** Optional artwork {@link Uri}. */
@Nullable public final Uri artworkUri;
/** Optional track number. */
@Nullable public final Integer trackNumber;
/** Optional total number of tracks. */
@Nullable public final Integer totalTrackCount;
/**
* Optional {@link FolderType}.
*
@ -950,22 +1006,28 @@ public final class MediaMetadata implements Bundleable {
@Deprecated
@Nullable
public final @FolderType Integer folderType;
/** Optional boolean to indicate that the media is a browsable folder. */
@Nullable public final Boolean isBrowsable;
/** Optional boolean to indicate that the media is playable. */
@Nullable public final Boolean isPlayable;
/**
* @deprecated Use {@link #recordingYear} instead.
*/
@UnstableApi @Deprecated @Nullable public final Integer year;
/** Optional year of the recording date. */
@Nullable public final Integer recordingYear;
/**
* Optional month of the recording date.
*
* <p>Note that there is no guarantee that the month and day are a valid combination.
*/
@Nullable public final Integer recordingMonth;
/**
* Optional day of the recording date.
*
@ -975,34 +1037,45 @@ public final class MediaMetadata implements Bundleable {
/** Optional year of the release date. */
@Nullable public final Integer releaseYear;
/**
* Optional month of the release date.
*
* <p>Note that there is no guarantee that the month and day are a valid combination.
*/
@Nullable public final Integer releaseMonth;
/**
* Optional day of the release date.
*
* <p>Note that there is no guarantee that the month and day are a valid combination.
*/
@Nullable public final Integer releaseDay;
/** Optional writer. */
@Nullable public final CharSequence writer;
/** Optional composer. */
@Nullable public final CharSequence composer;
/** Optional conductor. */
@Nullable public final CharSequence conductor;
/** Optional disc number. */
@Nullable public final Integer discNumber;
/** Optional total number of discs. */
@Nullable public final Integer totalDiscCount;
/** Optional genre. */
@Nullable public final CharSequence genre;
/** Optional compilation. */
@Nullable public final CharSequence compilation;
/** Optional name of the station streaming the media. */
@Nullable public final CharSequence station;
/** Optional {@link MediaType}. */
@Nullable public final @MediaType Integer mediaType;

View File

@ -59,6 +59,7 @@ public final class Metadata implements Parcelable {
}
private final Entry[] entries;
/**
* The presentation time of the metadata, in microseconds.
*

View File

@ -131,6 +131,7 @@ public final class MimeTypes {
public static final String APPLICATION_TX3G = BASE_TYPE_APPLICATION + "/x-quicktime-tx3g";
public static final String APPLICATION_MP4VTT = BASE_TYPE_APPLICATION + "/x-mp4-vtt";
public static final String APPLICATION_MP4CEA608 = BASE_TYPE_APPLICATION + "/x-mp4-cea-608";
/**
* @deprecated RawCC is a Google-internal subtitle format that isn't supported by this version of
* Media3. There is no replacement for this value.
@ -738,6 +739,7 @@ public final class MimeTypes {
/* package */ static final class Mp4aObjectType {
/** The Object Type Indication of the MP4A codec. */
public final int objectTypeIndication;
/** The Audio Object Type Indication of the MP4A codec, or 0 if it is absent. */
public final int audioObjectTypeIndication;

View File

@ -95,6 +95,7 @@ public class ParserException extends IOException {
* false when a parser encounters a legal condition which it does not support.
*/
public final boolean contentIsMalformed;
/** The {@link DataType data type} of the parsed bitstream. */
public final int dataType;

View File

@ -95,15 +95,19 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by an error whose cause could not be identified. */
public static final int ERROR_CODE_UNSPECIFIED = 1000;
/**
* Caused by an unidentified error in a remote Player, which is a Player that runs on a different
* host or process.
*/
public static final int ERROR_CODE_REMOTE_ERROR = 1001;
/** Caused by the loading position falling behind the sliding window of available live content. */
public static final int ERROR_CODE_BEHIND_LIVE_WINDOW = 1002;
/** Caused by a generic timeout. */
public static final int ERROR_CODE_TIMEOUT = 1003;
/**
* Caused by a failed runtime check.
*
@ -116,6 +120,7 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by an Input/Output error which could not be identified. */
public static final int ERROR_CODE_IO_UNSPECIFIED = 2000;
/**
* Caused by a network connection failure.
*
@ -130,8 +135,10 @@ public class PlaybackException extends Exception implements Bundleable {
* </ul>
*/
public static final int ERROR_CODE_IO_NETWORK_CONNECTION_FAILED = 2001;
/** Caused by a network timeout, meaning the server is taking too long to fulfill a request. */
public static final int ERROR_CODE_IO_NETWORK_CONNECTION_TIMEOUT = 2002;
/**
* Caused by a server returning a resource with an invalid "Content-Type" HTTP header value.
*
@ -139,15 +146,19 @@ public class PlaybackException extends Exception implements Bundleable {
* returns a paywall HTML page, with content type "text/html".
*/
public static final int ERROR_CODE_IO_INVALID_HTTP_CONTENT_TYPE = 2003;
/** Caused by an HTTP server returning an unexpected HTTP response status code. */
public static final int ERROR_CODE_IO_BAD_HTTP_STATUS = 2004;
/** Caused by a non-existent file. */
public static final int ERROR_CODE_IO_FILE_NOT_FOUND = 2005;
/**
* Caused by lack of permission to perform an IO operation. For example, lack of permission to
* access internet or external storage.
*/
public static final int ERROR_CODE_IO_NO_PERMISSION = 2006;
/**
* Caused by the player trying to access cleartext HTTP traffic (meaning http:// rather than
* https://) when the app's Network Security Configuration does not permit it.
@ -157,6 +168,7 @@ public class PlaybackException extends Exception implements Bundleable {
* corresponding troubleshooting topic</a>.
*/
public static final int ERROR_CODE_IO_CLEARTEXT_NOT_PERMITTED = 2007;
/** Caused by reading data out of the data bound. */
public static final int ERROR_CODE_IO_READ_POSITION_OUT_OF_RANGE = 2008;
@ -164,16 +176,19 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by a parsing error associated with a media container format bitstream. */
public static final int ERROR_CODE_PARSING_CONTAINER_MALFORMED = 3001;
/**
* Caused by a parsing error associated with a media manifest. Examples of a media manifest are a
* DASH or a SmoothStreaming manifest, or an HLS playlist.
*/
public static final int ERROR_CODE_PARSING_MANIFEST_MALFORMED = 3002;
/**
* Caused by attempting to extract a file with an unsupported media container format, or an
* unsupported media container feature.
*/
public static final int ERROR_CODE_PARSING_CONTAINER_UNSUPPORTED = 3003;
/**
* Caused by an unsupported feature in a media manifest. Examples of a media manifest are a DASH
* or a SmoothStreaming manifest, or an HLS playlist.
@ -184,12 +199,16 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by a decoder initialization failure. */
public static final int ERROR_CODE_DECODER_INIT_FAILED = 4001;
/** Caused by a decoder query failure. */
public static final int ERROR_CODE_DECODER_QUERY_FAILED = 4002;
/** Caused by a failure while trying to decode media samples. */
public static final int ERROR_CODE_DECODING_FAILED = 4003;
/** Caused by trying to decode content whose format exceeds the capabilities of the device. */
public static final int ERROR_CODE_DECODING_FORMAT_EXCEEDS_CAPABILITIES = 4004;
/** Caused by trying to decode content whose format is not supported. */
public static final int ERROR_CODE_DECODING_FORMAT_UNSUPPORTED = 4005;
@ -197,6 +216,7 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by an AudioTrack initialization failure. */
public static final int ERROR_CODE_AUDIO_TRACK_INIT_FAILED = 5001;
/** Caused by an AudioTrack write operation failure. */
public static final int ERROR_CODE_AUDIO_TRACK_WRITE_FAILED = 5002;
@ -204,13 +224,16 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by an unspecified error related to DRM protection. */
public static final int ERROR_CODE_DRM_UNSPECIFIED = 6000;
/**
* Caused by a chosen DRM protection scheme not being supported by the device. Examples of DRM
* protection schemes are ClearKey and Widevine.
*/
public static final int ERROR_CODE_DRM_SCHEME_UNSUPPORTED = 6001;
/** Caused by a failure while provisioning the device. */
public static final int ERROR_CODE_DRM_PROVISIONING_FAILED = 6002;
/**
* Caused by attempting to play incompatible DRM-protected content.
*
@ -218,14 +241,19 @@ public class PlaybackException extends Exception implements Bundleable {
* (like Widevine) for which there is no corresponding license acquisition data (like a pssh box).
*/
public static final int ERROR_CODE_DRM_CONTENT_ERROR = 6003;
/** Caused by a failure while trying to obtain a license. */
public static final int ERROR_CODE_DRM_LICENSE_ACQUISITION_FAILED = 6004;
/** Caused by an operation being disallowed by a license policy. */
public static final int ERROR_CODE_DRM_DISALLOWED_OPERATION = 6005;
/** Caused by an error in the DRM system. */
public static final int ERROR_CODE_DRM_SYSTEM_ERROR = 6006;
/** Caused by the device having revoked DRM privileges. */
public static final int ERROR_CODE_DRM_DEVICE_REVOKED = 6007;
/** Caused by an expired DRM license being loaded into an open DRM session. */
public static final int ERROR_CODE_DRM_LICENSE_EXPIRED = 6008;
@ -233,6 +261,7 @@ public class PlaybackException extends Exception implements Bundleable {
/** Caused by a failure when initializing a {@link VideoFrameProcessor}. */
@UnstableApi public static final int ERROR_CODE_VIDEO_FRAME_PROCESSOR_INIT_FAILED = 7000;
/** Caused by a failure when processing a video frame. */
@UnstableApi public static final int ERROR_CODE_VIDEO_FRAME_PROCESSING_FAILED = 7001;

View File

@ -247,22 +247,29 @@ public interface Player {
* The UID of the window, or {@code null} if the timeline is {@link Timeline#isEmpty() empty}.
*/
@Nullable public final Object windowUid;
/**
* @deprecated Use {@link #mediaItemIndex} instead.
*/
@UnstableApi @Deprecated public final int windowIndex;
/** The media item index. */
public final int mediaItemIndex;
/** The media item, or {@code null} if the timeline is {@link Timeline#isEmpty() empty}. */
@UnstableApi @Nullable public final MediaItem mediaItem;
/**
* The UID of the period, or {@code null} if the timeline is {@link Timeline#isEmpty() empty}.
*/
@Nullable public final Object periodUid;
/** The period index. */
public final int periodIndex;
/** The playback position, in milliseconds. */
public final long positionMs;
/**
* The content position, in milliseconds.
*
@ -270,10 +277,12 @@ public interface Player {
* #positionMs}.
*/
public final long contentPositionMs;
/**
* The ad group index if the playback position is within an ad, {@link C#INDEX_UNSET} otherwise.
*/
public final int adGroupIndex;
/**
* The index of the ad within the ad group if the playback position is within an ad, {@link
* C#INDEX_UNSET} otherwise.
@ -1160,22 +1169,26 @@ public interface Player {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({STATE_IDLE, STATE_BUFFERING, STATE_READY, STATE_ENDED})
@interface State {}
/**
* The player is idle, meaning it holds only limited resources. The player must be {@link
* #prepare() prepared} before it will play the media.
*/
int STATE_IDLE = 1;
/**
* The player is not able to immediately play the media, but is doing work toward being able to do
* so. This state typically occurs when the player needs to buffer more data before playback can
* start.
*/
int STATE_BUFFERING = 2;
/**
* The player is able to immediately play from its current position. The player will be playing if
* {@link #getPlayWhenReady()} is true, and paused otherwise.
*/
int STATE_READY = 3;
/** The player has finished playing the media. */
int STATE_ENDED = 4;
@ -1202,16 +1215,22 @@ public interface Player {
PLAY_WHEN_READY_CHANGE_REASON_SUPPRESSED_TOO_LONG
})
@interface PlayWhenReadyChangeReason {}
/** Playback has been started or paused by a call to {@link #setPlayWhenReady(boolean)}. */
int PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST = 1;
/** Playback has been paused because of a loss of audio focus. */
int PLAY_WHEN_READY_CHANGE_REASON_AUDIO_FOCUS_LOSS = 2;
/** Playback has been paused to avoid becoming noisy. */
int PLAY_WHEN_READY_CHANGE_REASON_AUDIO_BECOMING_NOISY = 3;
/** Playback has been started or paused because of a remote change. */
int PLAY_WHEN_READY_CHANGE_REASON_REMOTE = 4;
/** Playback has been paused at the end of a media item. */
int PLAY_WHEN_READY_CHANGE_REASON_END_OF_MEDIA_ITEM = 5;
/**
* Playback has been paused because playback has been {@linkplain #getPlaybackSuppressionReason()
* suppressed} too long.
@ -1237,14 +1256,18 @@ public interface Player {
PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT
})
@interface PlaybackSuppressionReason {}
/** Playback is not suppressed. */
int PLAYBACK_SUPPRESSION_REASON_NONE = 0;
/** Playback is suppressed due to transient audio focus loss. */
int PLAYBACK_SUPPRESSION_REASON_TRANSIENT_AUDIO_FOCUS_LOSS = 1;
/**
* @deprecated Use {@link #PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_OUTPUT} instead.
*/
@Deprecated int PLAYBACK_SUPPRESSION_REASON_UNSUITABLE_AUDIO_ROUTE = 2;
/**
* Playback is suppressed due to attempt to play on an unsuitable audio output (e.g. attempt to
* play on built-in speaker on a Wear OS device).
@ -1262,12 +1285,14 @@ public interface Player {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL})
@interface RepeatMode {}
/**
* Normal playback without repetition. "Previous" and "Next" actions move to the previous and next
* {@link MediaItem} respectively, and do nothing when there is no previous or next {@link
* MediaItem} to move to.
*/
int REPEAT_MODE_OFF = 0;
/**
* Repeats the currently playing {@link MediaItem} infinitely during ongoing playback. "Previous"
* and "Next" actions behave as they do in {@link #REPEAT_MODE_OFF}, moving to the previous and
@ -1275,6 +1300,7 @@ public interface Player {
* MediaItem} to move to.
*/
int REPEAT_MODE_ONE = 1;
/**
* Repeats the entire timeline infinitely. "Previous" and "Next" actions behave as they do in
* {@link #REPEAT_MODE_OFF}, but with looping at the ends so that "Previous" when playing the
@ -1303,6 +1329,7 @@ public interface Player {
DISCONTINUITY_REASON_INTERNAL
})
@interface DiscontinuityReason {}
/**
* Automatic playback transition from one period in the timeline to the next. The period index may
* be the same as it was before the discontinuity in case the current period is repeated.
@ -1312,17 +1339,22 @@ public interface Player {
* control the same playback on a remote device).
*/
int DISCONTINUITY_REASON_AUTO_TRANSITION = 0;
/** Seek within the current period or to another period. */
int DISCONTINUITY_REASON_SEEK = 1;
/**
* Seek adjustment due to being unable to seek to the requested position or because the seek was
* permitted to be inexact.
*/
int DISCONTINUITY_REASON_SEEK_ADJUSTMENT = 2;
/** Discontinuity introduced by a skipped period (for instance a skipped ad). */
int DISCONTINUITY_REASON_SKIP = 3;
/** Discontinuity caused by the removal of the current period from the {@link Timeline}. */
int DISCONTINUITY_REASON_REMOVE = 4;
/** Discontinuity introduced internally (e.g. by the source). */
int DISCONTINUITY_REASON_INTERNAL = 5;
@ -1337,8 +1369,10 @@ public interface Player {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED, TIMELINE_CHANGE_REASON_SOURCE_UPDATE})
@interface TimelineChangeReason {}
/** Timeline changed as a result of a change of the playlist items or the order of the items. */
int TIMELINE_CHANGE_REASON_PLAYLIST_CHANGED = 0;
/**
* Timeline changed as a result of a source update (e.g. result of a dynamic update by the played
* media).
@ -1365,8 +1399,10 @@ public interface Player {
MEDIA_ITEM_TRANSITION_REASON_PLAYLIST_CHANGED
})
@interface MediaItemTransitionReason {}
/** The media item has been repeated. */
int MEDIA_ITEM_TRANSITION_REASON_REPEAT = 0;
/**
* Playback has automatically transitioned to the next media item.
*
@ -1374,8 +1410,10 @@ public interface Player {
* can control the same playback on a remote device).
*/
int MEDIA_ITEM_TRANSITION_REASON_AUTO = 1;
/** A seek to another media item has occurred. */
int MEDIA_ITEM_TRANSITION_REASON_SEEK = 2;
/**
* The current media item has changed because of a change in the playlist. This can either be if
* the media item previously being played has been removed, or when the playlist becomes non-empty
@ -1427,72 +1465,103 @@ public interface Player {
EVENT_DEVICE_VOLUME_CHANGED
})
@interface Event {}
/** {@link #getCurrentTimeline()} changed. */
int EVENT_TIMELINE_CHANGED = 0;
/** {@link #getCurrentMediaItem()} changed or the player started repeating the current item. */
int EVENT_MEDIA_ITEM_TRANSITION = 1;
/** {@link #getCurrentTracks()} changed. */
int EVENT_TRACKS_CHANGED = 2;
/** {@link #isLoading()} ()} changed. */
int EVENT_IS_LOADING_CHANGED = 3;
/** {@link #getPlaybackState()} changed. */
int EVENT_PLAYBACK_STATE_CHANGED = 4;
/** {@link #getPlayWhenReady()} changed. */
int EVENT_PLAY_WHEN_READY_CHANGED = 5;
/** {@link #getPlaybackSuppressionReason()} changed. */
int EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED = 6;
/** {@link #isPlaying()} changed. */
int EVENT_IS_PLAYING_CHANGED = 7;
/** {@link #getRepeatMode()} changed. */
int EVENT_REPEAT_MODE_CHANGED = 8;
/** {@link #getShuffleModeEnabled()} changed. */
int EVENT_SHUFFLE_MODE_ENABLED_CHANGED = 9;
/** {@link #getPlayerError()} changed. */
int EVENT_PLAYER_ERROR = 10;
/**
* A position discontinuity occurred. See {@link Listener#onPositionDiscontinuity(PositionInfo,
* PositionInfo, int)}.
*/
int EVENT_POSITION_DISCONTINUITY = 11;
/** {@link #getPlaybackParameters()} changed. */
int EVENT_PLAYBACK_PARAMETERS_CHANGED = 12;
/** {@link #isCommandAvailable(int)} changed for at least one {@link Command}. */
int EVENT_AVAILABLE_COMMANDS_CHANGED = 13;
/** {@link #getMediaMetadata()} changed. */
int EVENT_MEDIA_METADATA_CHANGED = 14;
/** {@link #getPlaylistMetadata()} changed. */
int EVENT_PLAYLIST_METADATA_CHANGED = 15;
/** {@link #getSeekBackIncrement()} changed. */
int EVENT_SEEK_BACK_INCREMENT_CHANGED = 16;
/** {@link #getSeekForwardIncrement()} changed. */
int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = 17;
/** {@link #getMaxSeekToPreviousPosition()} changed. */
int EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED = 18;
/** {@link #getTrackSelectionParameters()} changed. */
int EVENT_TRACK_SELECTION_PARAMETERS_CHANGED = 19;
/** {@link #getAudioAttributes()} changed. */
int EVENT_AUDIO_ATTRIBUTES_CHANGED = 20;
/** The audio session id was set. */
int EVENT_AUDIO_SESSION_ID = 21;
/** {@link #getVolume()} changed. */
int EVENT_VOLUME_CHANGED = 22;
/** Skipping silences in the audio stream is enabled or disabled. */
int EVENT_SKIP_SILENCE_ENABLED_CHANGED = 23;
/** The size of the surface onto which the video is being rendered changed. */
int EVENT_SURFACE_SIZE_CHANGED = 24;
/** {@link #getVideoSize()} changed. */
int EVENT_VIDEO_SIZE_CHANGED = 25;
/**
* A frame is rendered for the first time since setting the surface, or since the renderer was
* reset, or since the stream being rendered was changed.
*/
int EVENT_RENDERED_FIRST_FRAME = 26;
/** {@link #getCurrentCues()} changed. */
int EVENT_CUES = 27;
/** Metadata associated with the current playback time changed. */
int EVENT_METADATA = 28;
/** {@link #getDeviceInfo()} changed. */
int EVENT_DEVICE_INFO_CHANGED = 29;
/** {@link #getDeviceVolume()} changed. */
int EVENT_DEVICE_VOLUME_CHANGED = 30;
@ -1591,6 +1660,7 @@ public interface Player {
COMMAND_RELEASE,
})
@interface Command {}
/**
* Command to start, pause or resume playback.
*
@ -1636,6 +1706,7 @@ public interface Player {
* #isCommandAvailable(int) available}.
*/
int COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM = 5;
/**
* @deprecated Use {@link #COMMAND_SEEK_IN_CURRENT_MEDIA_ITEM} instead.
*/
@ -1648,11 +1719,13 @@ public interface Player {
* {@linkplain #isCommandAvailable(int) available}.
*/
int COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM = 6;
/**
* @deprecated Use {@link #COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM} instead.
*/
@UnstableApi @Deprecated
int COMMAND_SEEK_TO_PREVIOUS_WINDOW = COMMAND_SEEK_TO_PREVIOUS_MEDIA_ITEM;
/**
* Command to seek to an earlier position in the current {@link MediaItem} or the default position
* of the previous {@link MediaItem}.
@ -1661,6 +1734,7 @@ public interface Player {
* #isCommandAvailable(int) available}.
*/
int COMMAND_SEEK_TO_PREVIOUS = 7;
/**
* Command to seek to the default position of the next {@link MediaItem}.
*
@ -1668,10 +1742,12 @@ public interface Player {
* #isCommandAvailable(int) available}.
*/
int COMMAND_SEEK_TO_NEXT_MEDIA_ITEM = 8;
/**
* @deprecated Use {@link #COMMAND_SEEK_TO_NEXT_MEDIA_ITEM} instead.
*/
@UnstableApi @Deprecated int COMMAND_SEEK_TO_NEXT_WINDOW = COMMAND_SEEK_TO_NEXT_MEDIA_ITEM;
/**
* Command to seek to a later position in the current {@link MediaItem} or the default position of
* the next {@link MediaItem}.
@ -1693,10 +1769,12 @@ public interface Player {
* </ul>
*/
int COMMAND_SEEK_TO_MEDIA_ITEM = 10;
/**
* @deprecated Use {@link #COMMAND_SEEK_TO_MEDIA_ITEM} instead.
*/
@UnstableApi @Deprecated int COMMAND_SEEK_TO_WINDOW = COMMAND_SEEK_TO_MEDIA_ITEM;
/**
* Command to seek back by a fixed increment inside the current {@link MediaItem}.
*
@ -1704,6 +1782,7 @@ public interface Player {
* #isCommandAvailable(int) available}.
*/
int COMMAND_SEEK_BACK = 11;
/**
* Command to seek forward by a fixed increment inside the current {@link MediaItem}.
*
@ -1831,6 +1910,7 @@ public interface Player {
* </ul>
*/
int COMMAND_SET_MEDIA_ITEM = 31;
/**
* Command to change the {@linkplain MediaItem media items} in the playlist.
*
@ -1897,6 +1977,7 @@ public interface Player {
* @deprecated Use {@link #COMMAND_SET_DEVICE_VOLUME_WITH_FLAGS} instead.
*/
@Deprecated int COMMAND_SET_DEVICE_VOLUME = 25;
/**
* Command to set the device volume with volume flags.
*
@ -1909,6 +1990,7 @@ public interface Player {
* @deprecated Use {@link #COMMAND_ADJUST_DEVICE_VOLUME_WITH_FLAGS} instead.
*/
@Deprecated int COMMAND_ADJUST_DEVICE_VOLUME = 26;
/**
* Command to increase and decrease the device volume and mute it with volume flags.
*
@ -1964,6 +2046,7 @@ public interface Player {
* #isCommandAvailable(int) available}.
*/
int COMMAND_GET_TRACKS = 30;
/**
* Command to release the player.
*

View File

@ -772,105 +772,142 @@ public abstract class SimpleBasePlayer extends BasePlayer {
/** The available {@link Commands}. */
public final Commands availableCommands;
/** Whether playback should proceed when ready and not suppressed. */
public final boolean playWhenReady;
/** The last reason for changing {@link #playWhenReady}. */
public final @PlayWhenReadyChangeReason int playWhenReadyChangeReason;
/** The {@linkplain Player.State state} of the player. */
public final @Player.State int playbackState;
/** The reason why playback is suppressed even if {@link #getPlayWhenReady()} is true. */
public final @PlaybackSuppressionReason int playbackSuppressionReason;
/** The last error that caused playback to fail, or null if there was no error. */
@Nullable public final PlaybackException playerError;
/** The {@link RepeatMode} used for playback. */
public final @RepeatMode int repeatMode;
/** Whether shuffling of media items is enabled. */
public final boolean shuffleModeEnabled;
/** Whether the player is currently loading its source. */
public final boolean isLoading;
/** The {@link Player#seekBack()} increment in milliseconds. */
public final long seekBackIncrementMs;
/** The {@link Player#seekForward()} increment in milliseconds. */
public final long seekForwardIncrementMs;
/**
* The maximum position for which {@link #seekToPrevious()} seeks to the previous item, in
* milliseconds.
*/
public final long maxSeekToPreviousPositionMs;
/** The currently active {@link PlaybackParameters}. */
public final PlaybackParameters playbackParameters;
/** The currently active {@link TrackSelectionParameters}. */
public final TrackSelectionParameters trackSelectionParameters;
/** The current {@link AudioAttributes}. */
public final AudioAttributes audioAttributes;
/** The current audio volume, with 0 being silence and 1 being unity gain (signal unchanged). */
@FloatRange(from = 0, to = 1.0)
public final float volume;
/** The current video size. */
public final VideoSize videoSize;
/** The current {@linkplain CueGroup cues}. */
public final CueGroup currentCues;
/** The {@link DeviceInfo}. */
public final DeviceInfo deviceInfo;
/** The current device volume. */
@IntRange(from = 0)
public final int deviceVolume;
/** Whether the device is muted. */
public final boolean isDeviceMuted;
/** The size of the surface onto which the video is being rendered. */
public final Size surfaceSize;
/**
* Whether a frame has been rendered for the first time since setting the surface, a rendering
* reset, or since the stream being rendered was changed.
*/
public final boolean newlyRenderedFirstFrame;
/** The most recent timed metadata. */
public final Metadata timedMetadata;
/** The media items in the playlist. */
public final ImmutableList<MediaItemData> playlist;
/** The {@link Timeline} derived from the {@link #playlist}. */
public final Timeline timeline;
/** The playlist {@link MediaMetadata}. */
public final MediaMetadata playlistMetadata;
/**
* The current media item index, or {@link C#INDEX_UNSET} to assume the default first item of
* the playlist is played.
*/
public final int currentMediaItemIndex;
/** The current ad group index, or {@link C#INDEX_UNSET} if no ad is playing. */
public final int currentAdGroupIndex;
/** The current ad index in the ad group, or {@link C#INDEX_UNSET} if no ad is playing. */
public final int currentAdIndexInAdGroup;
/**
* The {@link PositionSupplier} for the current content playback position in milliseconds, or
* {@link C#TIME_UNSET} to indicate the default start position.
*/
public final PositionSupplier contentPositionMsSupplier;
/**
* The {@link PositionSupplier} for the current ad playback position in milliseconds. The value
* is unused if no ad is playing.
*/
public final PositionSupplier adPositionMsSupplier;
/**
* The {@link PositionSupplier} for the estimated position up to which the currently playing
* content is buffered, in milliseconds, or {@link C#TIME_UNSET} to indicate the default start
* position.
*/
public final PositionSupplier contentBufferedPositionMsSupplier;
/**
* The {@link PositionSupplier} for the estimated position up to which the currently playing ad
* is buffered, in milliseconds. The value is unused if no ad is playing.
*/
public final PositionSupplier adBufferedPositionMsSupplier;
/** The {@link PositionSupplier} for the estimated total buffered duration in milliseconds. */
public final PositionSupplier totalBufferedDurationMsSupplier;
/** Signals that a position discontinuity happened since the last update to the player. */
public final boolean hasPositionDiscontinuity;
/**
* The {@linkplain Player.DiscontinuityReason reason} for the last position discontinuity. The
* value is unused if {@link #hasPositionDiscontinuity} is {@code false}.
*/
public final @Player.DiscontinuityReason int positionDiscontinuityReason;
/**
* The position, in milliseconds, in the current content or ad from which playback continued
* after the discontinuity. The value is unused if {@link #hasPositionDiscontinuity} is {@code
@ -1524,10 +1561,13 @@ public abstract class SimpleBasePlayer extends BasePlayer {
/** The unique identifier of this media item. */
public final Object uid;
/** The {@link Tracks} of this media item. */
public final Tracks tracks;
/** The {@link MediaItem}. */
public final MediaItem mediaItem;
/**
* The {@link MediaMetadata}, including static data from the {@link MediaItem#mediaMetadata
* MediaItem} and the media's {@link Format#metadata Format}, as well any dynamic metadata that
@ -1536,47 +1576,59 @@ public abstract class SimpleBasePlayer extends BasePlayer {
* {@link Format#metadata Formats}.
*/
@Nullable public final MediaMetadata mediaMetadata;
/** The manifest of the media item, or null if not applicable. */
@Nullable public final Object manifest;
/** The active {@link MediaItem.LiveConfiguration}, or null if the media item is not live. */
@Nullable public final MediaItem.LiveConfiguration liveConfiguration;
/**
* The start time of the live presentation, in milliseconds since the Unix epoch, or {@link
* C#TIME_UNSET} if unknown or not applicable.
*/
public final long presentationStartTimeMs;
/**
* The start time of the live window, in milliseconds since the Unix epoch, or {@link
* C#TIME_UNSET} if unknown or not applicable.
*/
public final long windowStartTimeMs;
/**
* The offset between {@link SystemClock#elapsedRealtime()} and the time since the Unix epoch
* according to the clock of the media origin server, or {@link C#TIME_UNSET} if unknown or not
* applicable.
*/
public final long elapsedRealtimeEpochOffsetMs;
/** Whether it's possible to seek within this media item. */
public final boolean isSeekable;
/** Whether this media item may change over time, for example a moving live window. */
public final boolean isDynamic;
/**
* The default position relative to the start of the media item at which to begin playback, in
* microseconds.
*/
public final long defaultPositionUs;
/** The duration of the media item, in microseconds, or {@link C#TIME_UNSET} if unknown. */
public final long durationUs;
/**
* The position of the start of this media item relative to the start of the first period
* belonging to it, in microseconds.
*/
public final long positionInFirstPeriodUs;
/**
* Whether this media item contains placeholder information because the real information has yet
* to be loaded.
*/
public final boolean isPlaceholder;
/**
* The list of {@linkplain PeriodData periods} in this media item, or an empty list to assume a
* single period without ads and the same duration as the media item.
@ -1861,16 +1913,19 @@ public abstract class SimpleBasePlayer extends BasePlayer {
/** The unique identifier of the period within its media item. */
public final Object uid;
/**
* The total duration of the period, in microseconds, or {@link C#TIME_UNSET} if unknown. Only
* the last period in a media item can have an unknown duration.
*/
public final long durationUs;
/**
* The {@link AdPlaybackState} of the period, or {@link AdPlaybackState#NONE} if there are no
* ads.
*/
public final AdPlaybackState adPlaybackState;
/**
* Whether this period contains placeholder information because the real information has yet to
* be loaded.

View File

@ -41,8 +41,10 @@ public final class StreamKey implements Comparable<StreamKey>, Parcelable, Bundl
/** The period index. */
public final int periodIndex;
/** The group index. */
public final int groupIndex;
/** The stream index. */
public final int streamIndex;

View File

@ -27,10 +27,13 @@ public final class SurfaceInfo {
/** The {@link Surface}. */
public final Surface surface;
/** The width of frames rendered to the {@link #surface}, in pixels. */
public final int width;
/** The height of frames rendered to the {@link #surface}, in pixels. */
public final int height;
/**
* A counter-clockwise rotation to apply to frames before rendering them to the {@link #surface}.
*

View File

@ -1188,6 +1188,7 @@ public abstract class Timeline implements Bundleable {
Window window, Period period, int windowIndex, long windowPositionUs) {
return getPeriodPositionUs(window, period, windowIndex, windowPositionUs);
}
/**
* @deprecated Use {@link #getPeriodPositionUs(Window, Period, int, long, long)} instead.
*/

View File

@ -54,8 +54,10 @@ public final class TrackGroup implements Bundleable {
/** The number of tracks in the group. */
@UnstableApi public final int length;
/** An identifier for the track group. */
@UnstableApi public final String id;
/** The type of tracks in the group. */
@UnstableApi public final @C.TrackType int type;

View File

@ -48,6 +48,7 @@ public final class TrackSelectionOverride implements Bundleable {
/** The media {@link TrackGroup} whose {@link #trackIndices} are forced to be selected. */
public final TrackGroup mediaTrackGroup;
/** The indices of tracks in a {@link TrackGroup} to be selected. */
public final ImmutableList<Integer> trackIndices;

View File

@ -93,11 +93,13 @@ public class TrackSelectionParameters implements Bundleable {
* selection, then no tracks will be selected.
*/
@UnstableApi public static final int AUDIO_OFFLOAD_MODE_PREFERENCE_REQUIRED = 2;
/**
* The track selector will enable audio offload if the selected tracks and renderer capabilities
* are compatible.
*/
@UnstableApi public static final int AUDIO_OFFLOAD_MODE_PREFERENCE_ENABLED = 1;
/**
* The track selector will disable audio offload on the audio sink. Track selection will not take
* into consideration whether or not a track is offload compatible.
@ -887,6 +889,7 @@ public class TrackSelectionParameters implements Bundleable {
@UnstableApi
@SuppressWarnings("deprecation")
public static final TrackSelectionParameters DEFAULT_WITHOUT_CONTEXT = new Builder().build();
/**
* @deprecated This instance is not configured using {@link Context} constraints. Use {@link
* #getDefaults(Context)} instead.
@ -909,6 +912,7 @@ public class TrackSelectionParameters implements Bundleable {
* #viewportHeight} and {@link #viewportOrientationMayChange}) instead.
*/
public final int maxVideoWidth;
/**
* Maximum allowed video height in pixels. The default value is {@link Integer#MAX_VALUE} (i.e. no
* constraint).
@ -918,54 +922,66 @@ public class TrackSelectionParameters implements Bundleable {
* #viewportHeight} and {@link #viewportOrientationMayChange}) instead.
*/
public final int maxVideoHeight;
/**
* Maximum allowed video frame rate in hertz. The default value is {@link Integer#MAX_VALUE} (i.e.
* no constraint).
*/
public final int maxVideoFrameRate;
/**
* Maximum allowed video bitrate in bits per second. The default value is {@link
* Integer#MAX_VALUE} (i.e. no constraint).
*/
public final int maxVideoBitrate;
/** Minimum allowed video width in pixels. The default value is 0 (i.e. no constraint). */
public final int minVideoWidth;
/** Minimum allowed video height in pixels. The default value is 0 (i.e. no constraint). */
public final int minVideoHeight;
/** Minimum allowed video frame rate in hertz. The default value is 0 (i.e. no constraint). */
public final int minVideoFrameRate;
/**
* Minimum allowed video bitrate in bits per second. The default value is 0 (i.e. no constraint).
*/
public final int minVideoBitrate;
/**
* Viewport width in pixels. Constrains video track selections for adaptive content so that only
* tracks suitable for the viewport are selected. The default value is the physical width of the
* primary display, in pixels.
*/
public final int viewportWidth;
/**
* Viewport height in pixels. Constrains video track selections for adaptive content so that only
* tracks suitable for the viewport are selected. The default value is the physical height of the
* primary display, in pixels.
*/
public final int viewportHeight;
/**
* Whether the viewport orientation may change during playback. Constrains video track selections
* for adaptive content so that only tracks suitable for the viewport are selected. The default
* value is {@code true}.
*/
public final boolean viewportOrientationMayChange;
/**
* The preferred sample MIME types for video tracks in order of preference, or an empty list for
* no preference. The default is an empty list.
*/
public final ImmutableList<String> preferredVideoMimeTypes;
/**
* The preferred {@link C.RoleFlags} for video tracks. {@code 0} selects the default track if
* there is one, or the first track if there's no default. The default value is {@code 0}.
*/
public final @C.RoleFlags int preferredVideoRoleFlags;
// Audio
/**
* The preferred languages for audio and forced text tracks as IETF BCP 47 conformant tags in
@ -973,21 +989,25 @@ public class TrackSelectionParameters implements Bundleable {
* default. The default value is an empty list.
*/
public final ImmutableList<String> preferredAudioLanguages;
/**
* The preferred {@link C.RoleFlags} for audio tracks. {@code 0} selects the default track if
* there is one, or the first track if there's no default. The default value is {@code 0}.
*/
public final @C.RoleFlags int preferredAudioRoleFlags;
/**
* Maximum allowed audio channel count. The default value is {@link Integer#MAX_VALUE} (i.e. no
* constraint).
*/
public final int maxAudioChannelCount;
/**
* Maximum allowed audio bitrate in bits per second. The default value is {@link
* Integer#MAX_VALUE} (i.e. no constraint).
*/
public final int maxAudioBitrate;
/**
* The preferred sample MIME types for audio tracks in order of preference, or an empty list for
* no preference. The default is an empty list.
@ -999,12 +1019,14 @@ public class TrackSelectionParameters implements Bundleable {
* #AUDIO_OFFLOAD_MODE_PREFERENCE_DISABLED}.
*/
public final @AudioOffloadModePreference int audioOffloadModePreference;
/**
* A constraint on enabling offload. If {@code isGaplessSupportRequired}, then audio offload will
* be enabled only if the device supports gapless transitions during offload or the selected audio
* is not gapless.
*/
public final boolean isGaplessSupportRequired;
/**
* A constraint on enabling offload. If {@code isSpeedChangeSupportRequired}, then audio offload
* will be enabled only if the device supports changing playback speed during offload.
@ -1019,6 +1041,7 @@ public class TrackSelectionParameters implements Bundleable {
* enabled.
*/
public final ImmutableList<String> preferredTextLanguages;
/**
* The preferred {@link C.RoleFlags} for text tracks. {@code 0} selects the default track if there
* is one, or no track otherwise. The default value is {@code 0}, or {@link C#ROLE_FLAG_SUBTITLE}
@ -1026,23 +1049,27 @@ public class TrackSelectionParameters implements Bundleable {
* is enabled.
*/
public final @C.RoleFlags int preferredTextRoleFlags;
/**
* Bitmask of selection flags that are ignored for text track selections. See {@link
* C.SelectionFlags}. The default value is {@code 0} (i.e., no flags are ignored).
*/
public final @C.SelectionFlags int ignoredTextSelectionFlags;
/**
* Whether a text track with undetermined language should be selected if no track with {@link
* #preferredTextLanguages} is available, or if {@link #preferredTextLanguages} is unset. The
* default value is {@code false}.
*/
public final boolean selectUndeterminedTextLanguage;
// General
/**
* Whether to force selection of the single lowest bitrate audio and video tracks that comply with
* all other constraints. The default value is {@code false}.
*/
public final boolean forceLowestBitrate;
/**
* Whether to force selection of the highest bitrate audio and video tracks that comply with all
* other constraints. The default value is {@code false}.

View File

@ -374,6 +374,7 @@ public final class Tracks implements Bundleable {
public int hashCode() {
return groups.hashCode();
}
// Bundleable implementation.
private static final String FIELD_TRACK_GROUPS = Util.intToStringMaxRadix(0);

View File

@ -56,10 +56,13 @@ public interface VideoFrameProcessor {
@Target(TYPE_USE)
@IntDef({INPUT_TYPE_SURFACE, INPUT_TYPE_BITMAP, INPUT_TYPE_TEXTURE_ID})
@interface InputType {}
/** Input frames come from a {@link #getInputSurface surface}. */
int INPUT_TYPE_SURFACE = 1;
/** Input frames come from a {@link Bitmap}. */
int INPUT_TYPE_BITMAP = 2;
/**
* Input frames come from a {@linkplain android.opengl.GLES10#GL_TEXTURE_2D traditional GLES
* texture}.

View File

@ -71,6 +71,7 @@ public final class AudioProcessingPipeline {
/** The {@link AudioProcessor} instances passed to {@link AudioProcessingPipeline}. */
private final ImmutableList<AudioProcessor> audioProcessors;
/**
* The processors that are {@linkplain AudioProcessor#isActive() active} based on the current
* configuration.
@ -82,10 +83,13 @@ public final class AudioProcessingPipeline {
* as {@link #activeAudioProcessors}.
*/
private ByteBuffer[] outputBuffers;
/** The {@link AudioFormat} currently being output by the pipeline. */
private AudioFormat outputAudioFormat;
/** The {@link AudioFormat} that will be output following a {@link #flush()}. */
private AudioFormat pendingOutputAudioFormat;
/** Whether input has ended, either due to configuration change or end of stream. */
private boolean inputEnded;

View File

@ -52,10 +52,13 @@ public interface AudioProcessor {
/** The sample rate in Hertz. */
public final int sampleRate;
/** The number of interleaved channels. */
public final int channelCount;
/** The type of linear PCM encoding. */
public final @C.PcmEncoding int encoding;
/** The number of bytes used to represent one audio frame. */
public final int bytesPerFrame;

View File

@ -31,6 +31,7 @@ public abstract class BaseAudioProcessor implements AudioProcessor {
/** The current input audio format. */
protected AudioFormat inputAudioFormat;
/** The current output audio format. */
protected AudioFormat outputAudioFormat;

View File

@ -34,6 +34,7 @@ public final class SpeedChangingAudioProcessor extends BaseAudioProcessor {
/** The speed provider that provides the speed for each timestamp. */
private final SpeedProvider speedProvider;
/**
* The {@link SonicAudioProcessor} used to change the speed, when needed. If there is no speed
* change required, the input buffer is copied to the output buffer and this processor is not

View File

@ -44,6 +44,7 @@ public final class CueGroup implements Bundleable {
* <p>This list may be empty if the group represents a state with no cues.
*/
public final ImmutableList<Cue> cues;
/**
* The presentation time of the {@link #cues}, in microseconds.
*

View File

@ -56,8 +56,10 @@ public final class EGLSurfaceTexture implements SurfaceTexture.OnFrameAvailableL
/** No secure EGL surface and context required. */
public static final int SECURE_MODE_NONE = 0;
/** Creating a surfaceless, secured EGL context. */
public static final int SECURE_MODE_SURFACELESS_CONTEXT = 1;
/** Creating a secure surface backed by a pixel buffer. */
public static final int SECURE_MODE_PROTECTED_PBUFFER = 2;

View File

@ -38,6 +38,7 @@ public final class GlProgram {
// https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_YUV_target.txt
private static final int GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT = 0x8BE7;
/** The identifier of a compiled and linked GLSL shader program. */
private final int programId;
@ -367,6 +368,7 @@ public final class GlProgram {
this.texIdValue = texId;
this.texUnitIndex = texUnitIndex;
}
/** Configures {@link #bind()} to use the specified {@code int} {@code value}. */
public void setInt(int value) {
this.intValue = value;

View File

@ -45,14 +45,19 @@ public final class Log {
@Target(TYPE_USE)
@IntDef({LOG_LEVEL_ALL, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, LOG_LEVEL_OFF})
public @interface LogLevel {}
/** Log level to log all messages. */
public static final int LOG_LEVEL_ALL = 0;
/** Log level to only log informative, warning and error messages. */
public static final int LOG_LEVEL_INFO = 1;
/** Log level to only log warning and error messages. */
public static final int LOG_LEVEL_WARNING = 2;
/** Log level to only log error messages. */
public static final int LOG_LEVEL_ERROR = 3;
/** Log level to disable all logging. */
public static final int LOG_LEVEL_OFF = Integer.MAX_VALUE;

View File

@ -54,26 +54,32 @@ public final class NotificationUtil {
IMPORTANCE_HIGH
})
public @interface Importance {}
/**
* @see NotificationManager#IMPORTANCE_UNSPECIFIED
*/
public static final int IMPORTANCE_UNSPECIFIED = NotificationManager.IMPORTANCE_UNSPECIFIED;
/**
* @see NotificationManager#IMPORTANCE_NONE
*/
public static final int IMPORTANCE_NONE = NotificationManager.IMPORTANCE_NONE;
/**
* @see NotificationManager#IMPORTANCE_MIN
*/
public static final int IMPORTANCE_MIN = NotificationManager.IMPORTANCE_MIN;
/**
* @see NotificationManager#IMPORTANCE_LOW
*/
public static final int IMPORTANCE_LOW = NotificationManager.IMPORTANCE_LOW;
/**
* @see NotificationManager#IMPORTANCE_DEFAULT
*/
public static final int IMPORTANCE_DEFAULT = NotificationManager.IMPORTANCE_DEFAULT;
/**
* @see NotificationManager#IMPORTANCE_HIGH
*/

View File

@ -46,10 +46,13 @@ public final class RepeatModeUtil {
flag = true,
value = {REPEAT_TOGGLE_MODE_NONE, REPEAT_TOGGLE_MODE_ONE, REPEAT_TOGGLE_MODE_ALL})
public @interface RepeatToggleModes {}
/** All repeat mode buttons disabled. */
public static final int REPEAT_TOGGLE_MODE_NONE = 0;
/** "Repeat One" button enabled. */
public static final int REPEAT_TOGGLE_MODE_ONE = 1;
/** "Repeat All" button enabled. */
public static final int REPEAT_TOGGLE_MODE_ALL = 1 << 1; // 2

View File

@ -25,6 +25,7 @@ public final class UriUtil {
/** The length of arrays returned by {@link #getUriIndices(String)}. */
private static final int INDEX_COUNT = 4;
/**
* An index into an array returned by {@link #getUriIndices(String)}.
*
@ -33,6 +34,7 @@ public final class UriUtil {
* including when the URI has no scheme.
*/
private static final int SCHEME_COLON = 0;
/**
* An index into an array returned by {@link #getUriIndices(String)}.
*
@ -42,6 +44,7 @@ public final class UriUtil {
* authority part is non-empty (in this case the double-slash means the first segment is empty).
*/
private static final int PATH = 1;
/**
* An index into an array returned by {@link #getUriIndices(String)}.
*
@ -50,6 +53,7 @@ public final class UriUtil {
* single '?' with no data.
*/
private static final int QUERY = 2;
/**
* An index into an array returned by {@link #getUriIndices(String)}.
*

View File

@ -35,17 +35,22 @@ public final class MdtaMetadataEntry implements Metadata.Entry {
/** The type indicator for UTF-8 string. */
public static final int TYPE_INDICATOR_STRING = 1;
/** The type indicator for Float32. */
public static final int TYPE_INDICATOR_FLOAT32 = 23;
/** The type indicator for 32-bit signed integer. */
public static final int TYPE_INDICATOR_INT32 = 67;
/** The metadata key name. */
public final String key;
/** The payload. The interpretation of the value depends on {@link #typeIndicator}. */
public final byte[] value;
/** The four byte locale indicator. */
public final int localeIndicator;
/** The four byte type indicator. */
public final int typeIndicator;

View File

@ -31,8 +31,10 @@ public final class Mp4TimestampData implements Metadata.Entry {
/** The creation timestamp. */
public final long creationTimestampSeconds;
/** The modification timestamp. */
public final long modificationTimestampSeconds;
/** The timescale of the movie. */
public final long timescale;

View File

@ -36,16 +36,22 @@ public final class NalUnitUtil {
/** Coded slice of a non-IDR picture. */
public static final int NAL_UNIT_TYPE_NON_IDR = 1;
/** Coded slice data partition A. */
public static final int NAL_UNIT_TYPE_PARTITION_A = 2;
/** Coded slice of an IDR picture. */
public static final int NAL_UNIT_TYPE_IDR = 5;
/** Supplemental enhancement information. */
public static final int NAL_UNIT_TYPE_SEI = 6;
/** Sequence parameter set. */
public static final int NAL_UNIT_TYPE_SPS = 7;
/** Picture parameter set. */
public static final int NAL_UNIT_TYPE_PPS = 8;
/** Access unit delimiter. */
public static final int NAL_UNIT_TYPE_AUD = 9;
@ -186,6 +192,7 @@ public final class NalUnitUtil {
/** Value for aspect_ratio_idc indicating an extended aspect ratio, in H.264 and H.265 SPSs. */
public static final int EXTENDED_SAR = 0xFF;
/** Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs. */
public static final float[] ASPECT_RATIO_IDC_VALUES =
new float[] {

View File

@ -43,12 +43,16 @@ public final class VersionTable {
/** Returned by {@link #getVersion(SQLiteDatabase, int, String)} if the version is unset. */
public static final int VERSION_UNSET = -1;
/** Version of tables used for offline functionality. */
public static final int FEATURE_OFFLINE = 0;
/** Version of tables used for cache content metadata. */
public static final int FEATURE_CACHE_CONTENT_METADATA = 1;
/** Version of tables used for cache file metadata. */
public static final int FEATURE_CACHE_FILE_METADATA = 2;
/** Version of tables used from external features. */
public static final int FEATURE_EXTERNAL = 1000;

View File

@ -259,6 +259,7 @@ public final class DataSpec {
FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED
})
public @interface Flags {}
/**
* Allows an underlying network stack to request that the server use gzip compression.
*
@ -271,8 +272,10 @@ public final class DataSpec {
* DataSource#read(byte[], int, int)} will be the decompressed data.
*/
public static final int FLAG_ALLOW_GZIP = 1;
/** Prevents caching if the length cannot be resolved when the {@link DataSource} is opened. */
public static final int FLAG_DONT_CACHE_IF_LENGTH_UNKNOWN = 1 << 1;
/**
* Allows fragmentation of this request into multiple cache files, meaning a cache eviction policy
* will be able to evict individual fragments of the data. Depending on the cache implementation,
@ -280,6 +283,7 @@ public final class DataSpec {
* whilst writing another).
*/
public static final int FLAG_ALLOW_CACHE_FRAGMENTATION = 1 << 2;
/**
* Indicates there are known external factors that might prevent the data from being loaded at
* full network speed (e.g. server throttling or unfinished live media chunks).
@ -295,10 +299,13 @@ public final class DataSpec {
@Target(TYPE_USE)
@IntDef({HTTP_METHOD_GET, HTTP_METHOD_POST, HTTP_METHOD_HEAD})
public @interface HttpMethod {}
/** HTTP GET method. */
public static final int HTTP_METHOD_GET = 1;
/** HTTP POST method. */
public static final int HTTP_METHOD_POST = 2;
/** HTTP HEAD method. */
public static final int HTTP_METHOD_HEAD = 3;

View File

@ -220,6 +220,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
/** The default connection timeout, in milliseconds. */
@UnstableApi public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 8 * 1000;
/** The default read timeout, in milliseconds. */
@UnstableApi public static final int DEFAULT_READ_TIMEOUT_MILLIS = 8 * 1000;

View File

@ -204,8 +204,10 @@ public interface HttpDataSource extends DataSource {
/** The error occurred reading data from a {@code HttpDataSource}. */
public static final int TYPE_OPEN = 1;
/** The error occurred in opening a {@code HttpDataSource}. */
public static final int TYPE_READ = 2;
/** The error occurred in closing a {@code HttpDataSource}. */
public static final int TYPE_CLOSE = 3;

View File

@ -122,6 +122,7 @@ public final class CacheDataSink implements DataSink {
/** Default {@code fragmentSize} recommended for caching use cases. */
public static final long DEFAULT_FRAGMENT_SIZE = 5 * 1024 * 1024;
/** Default buffer size in bytes. */
public static final int DEFAULT_BUFFER_SIZE = 20 * 1024;

View File

@ -355,6 +355,7 @@ public final class CacheDataSource implements DataSource {
FLAG_IGNORE_CACHE_FOR_UNSET_LENGTH_REQUESTS
})
public @interface Flags {}
/**
* A flag indicating whether we will block reads if the cache key is locked. If unset then data is
* read from upstream if the cache key is locked, regardless of whether the data is cached.

View File

@ -26,16 +26,21 @@ public class CacheSpan implements Comparable<CacheSpan> {
/** The cache key that uniquely identifies the resource. */
public final String key;
/** The position of the {@link CacheSpan} in the resource. */
public final long position;
/**
* The length of the {@link CacheSpan}, or {@link C#LENGTH_UNSET} if this is an open-ended hole.
*/
public final long length;
/** Whether the {@link CacheSpan} is cached. */
public final boolean isCached;
/** The file corresponding to this {@link CacheSpan}, or null if {@link #isCached} is false. */
@Nullable public final File file;
/** The last touch timestamp, or {@link C#TIME_UNSET} if {@link #isCached} is false. */
public final long lastTouchTimestamp;

View File

@ -35,10 +35,13 @@ import java.util.TreeSet;
/** The cache id that uniquely identifies the resource. */
public final int id;
/** The cache key that uniquely identifies the resource. */
public final String key;
/** The cached spans of this content. */
private final TreeSet<SimpleCacheSpan> cachedSpans;
/** Currently locked ranges. */
private final ArrayList<Range> lockedRanges;
@ -280,6 +283,7 @@ import java.util.TreeSet;
/** The starting position of the range. */
public final long position;
/** The length of the range, or {@link C#LENGTH_UNSET} if unbounded. */
public final long length;

View File

@ -74,6 +74,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private static final int INCREMENTAL_METADATA_READ_LENGTH = 10 * 1024 * 1024;
private final HashMap<String, CachedContent> keyToContent;
/**
* Maps assigned ids to their corresponding keys. Also contains (id -> null) entries for ids that
* have been removed from the index since it was last stored. This prevents reuse of these ids,
@ -92,11 +93,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* reuse.
*/
private final SparseArray<@NullableType String> idToKey;
/**
* Tracks ids for which (id -> null) entries are present in idToKey, so that they can be removed
* efficiently when the index is next stored.
*/
private final SparseBooleanArray removedIds;
/** Tracks ids that are new since the index was last stored. */
private final SparseBooleanArray newIds;

View File

@ -30,8 +30,10 @@ public interface ContentMetadata {
*/
@SuppressWarnings("unused")
String KEY_CUSTOM_PREFIX = "custom_";
/** Key for redirected uri (type: String). */
String KEY_REDIRECTED_URI = "exo_redir";
/** Key for content length in bytes (type: long). */
String KEY_CONTENT_LENGTH = "exo_len";

View File

@ -51,6 +51,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
public final class SimpleCache implements Cache {
private static final String TAG = "SimpleCache";
/**
* Cache files are distributed between a number of subdirectories. This helps to avoid poor
* performance in cases where the performance of the underlying file system (e.g. FAT32) scales

View File

@ -415,6 +415,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource {
/** The default connection timeout, in milliseconds. */
@UnstableApi public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 8 * 1000;
/** The default read timeout, in milliseconds. */
@UnstableApi public static final int DEFAULT_READ_TIMEOUT_MILLIS = 8 * 1000;

View File

@ -37,18 +37,21 @@ public final class CryptoInfo {
* @see android.media.MediaCodec.CryptoInfo#iv
*/
@Nullable public byte[] iv;
/**
* The 16 byte key id.
*
* @see android.media.MediaCodec.CryptoInfo#key
*/
@Nullable public byte[] key;
/**
* The type of encryption that has been applied. Must be one of the {@link C.CryptoMode} values.
*
* @see android.media.MediaCodec.CryptoInfo#mode
*/
public @C.CryptoMode int mode;
/**
* The number of leading unencrypted bytes in each sub-sample. If null, all bytes are treated as
* encrypted and {@link #numBytesOfEncryptedData} must be specified.
@ -56,6 +59,7 @@ public final class CryptoInfo {
* @see android.media.MediaCodec.CryptoInfo#numBytesOfClearData
*/
@Nullable public int[] numBytesOfClearData;
/**
* The number of trailing encrypted bytes in each sub-sample. If null, all bytes are treated as
* clear and {@link #numBytesOfClearData} must be specified.
@ -63,16 +67,19 @@ public final class CryptoInfo {
* @see android.media.MediaCodec.CryptoInfo#numBytesOfEncryptedData
*/
@Nullable public int[] numBytesOfEncryptedData;
/**
* The number of subSamples that make up the buffer's contents.
*
* @see android.media.MediaCodec.CryptoInfo#numSubSamples
*/
public int numSubSamples;
/**
* @see android.media.MediaCodec.CryptoInfo.Pattern
*/
public int encryptedBlocks;
/**
* @see android.media.MediaCodec.CryptoInfo.Pattern
*/

View File

@ -47,6 +47,7 @@ public class DecoderInputBuffer extends Buffer {
/** The current capacity of the buffer. */
public final int currentCapacity;
/** The required capacity of the buffer. */
public final int requiredCapacity;
@ -78,10 +79,13 @@ public class DecoderInputBuffer extends Buffer {
BUFFER_REPLACEMENT_MODE_DIRECT
})
public @interface BufferReplacementMode {}
/** Disallows buffer replacement. */
public static final int BUFFER_REPLACEMENT_MODE_DISABLED = 0;
/** Allows buffer replacement using {@link ByteBuffer#allocate(int)}. */
public static final int BUFFER_REPLACEMENT_MODE_NORMAL = 1;
/** Allows buffer replacement using {@link ByteBuffer#allocateDirect(int)}. */
public static final int BUFFER_REPLACEMENT_MODE_DIRECT = 2;

View File

@ -35,11 +35,13 @@ public class VideoDecoderOutputBuffer extends DecoderOutputBuffer {
/** Output mode. */
public @C.VideoOutputMode int mode;
/** RGB buffer for RGB mode. */
@Nullable public ByteBuffer data;
public int width;
public int height;
/** The format of the input from which this output buffer was decoded. */
@Nullable public Format format;

View File

@ -47,6 +47,7 @@ public class Libgav1VideoRenderer extends DecoderVideoRenderer {
private static final String TAG = "Libgav1VideoRenderer";
private static final int DEFAULT_NUM_OF_INPUT_BUFFERS = 4;
private static final int DEFAULT_NUM_OF_OUTPUT_BUFFERS = 4;
/**
* Default input buffer size in bytes, based on 720p resolution video compressed by a factor of
* two.
@ -56,6 +57,7 @@ public class Libgav1VideoRenderer extends DecoderVideoRenderer {
/** The number of input buffers. */
private final int numInputBuffers;
/**
* The number of output buffers. The renderer may limit the minimum possible value due to
* requiring multiple output buffers to be dequeued at a time for it to make progress.

View File

@ -44,6 +44,7 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer<FfmpegAudioD
/** The number of input and output buffers. */
private static final int NUM_BUFFERS = 16;
/** The default input buffer size. */
private static final int DEFAULT_INPUT_BUFFER_SIZE = 960 * 6;

View File

@ -41,12 +41,16 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
/** The number of channels output by the decoder. */
public static final int NUM_OUTPUT_CHANNELS = 2;
/** The default input buffer count. */
public static final int DEFAULT_INPUT_BUFFER_COUNT = 16;
/** The default output buffer count. */
public static final int DEFAULT_OUTPUT_BUFFER_COUNT = 16;
/** The standard number of MIDI channels. */
public static final int CHANNEL_COUNT = 16;
/** The default sample rate, measured in Hertz. */
public static final int DEFAULT_SAMPLE_RATE = 44100;

View File

@ -63,6 +63,7 @@ public final class MidiRenderer extends DecoderAudioRenderer<MidiDecoder> {
throws MidiDecoderException {
return new MidiDecoder(context);
}
/**
* {@inheritDoc}
*

View File

@ -32,6 +32,7 @@ import androidx.media3.common.util.UnstableApi;
/** The length of a MIDI event message in bytes. */
public static final int MIDI_MESSAGE_LENGTH_BYTES = 3;
/** A default or unset data value. */
public static final int DATA_FIELD_UNSET = Integer.MIN_VALUE;

View File

@ -35,8 +35,10 @@ import androidx.media3.exoplayer.audio.DecoderAudioRenderer;
public class LibopusAudioRenderer extends DecoderAudioRenderer<OpusDecoder> {
private static final String TAG = "LibopusAudioRenderer";
/** The number of input and output buffers. */
private static final int NUM_BUFFERS = 16;
/** The default input buffer size. */
private static final int DEFAULT_INPUT_BUFFER_SIZE = 960 * 6;

View File

@ -41,11 +41,13 @@ public class LibvpxVideoRenderer extends DecoderVideoRenderer {
/** The number of input buffers. */
private final int numInputBuffers;
/**
* The number of output buffers. The renderer may limit the minimum possible value due to
* requiring multiple output buffers to be dequeued at a time for it to make progress.
*/
private final int numOutputBuffers;
/**
* The default input buffer size. The value is based on <a
* href="https://android.googlesource.com/platform/frameworks/av/+/d42b90c5183fbd9d6a28d9baee613fddbf8131d6/media/libstagefright/codecs/on2/dec/SoftVPX.cpp">SoftVPX.cpp</a>.

View File

@ -60,11 +60,13 @@ public final class DefaultVideoFrameProcessorVideoFrameRenderingTest {
private static final int WIDTH = 200;
private static final int HEIGHT = 100;
/**
* Time to wait between rendering frames to avoid frame drops between GL and the {@link
* ImageReader}.
*/
private static final long PER_FRAME_RENDERING_WAIT_TIME_MS = 1000L;
/** Maximum time to wait for each rendered frame to be notified. */
private static final long PER_FRAME_TIMEOUT_MS = 5000L;

View File

@ -101,27 +101,34 @@ import java.util.List;
/** The {@link MatrixTransformation MatrixTransformations} to apply. */
private final ImmutableList<GlMatrixTransformation> matrixTransformations;
/** The {@link RgbMatrix RgbMatrices} to apply. */
private final ImmutableList<RgbMatrix> rgbMatrices;
/** Whether the frame is in HDR or not. */
private final boolean useHdr;
/**
* The transformation matrices provided by the {@link MatrixTransformation MatrixTransformations}
* for the most recent frame.
*/
private final float[][] transformationMatrixCache;
/** The RGB matrices provided by the {@link RgbMatrix RgbMatrices} for the most recent frame. */
private final float[][] rgbMatrixCache;
/**
* The product of the {@link #transformationMatrixCache} for the most recent frame, to be applied
* in the vertex shader.
*/
private final float[] compositeTransformationMatrixArray;
/**
* The product of the {@link #rgbMatrixCache} for the most recent frame, to be applied in the
* fragment shader.
*/
private final float[] compositeRgbMatrixArray;
/** Matrix for storing an intermediate calculation result. */
private final float[] tempResultMatrix;

View File

@ -297,6 +297,7 @@ public final class DefaultVideoFrameProcessor implements VideoFrameProcessor {
// Shader programs that apply Effects.
private final List<GlShaderProgram> intermediateGlShaderPrograms;
// Whether DefaultVideoFrameProcessor is currently processing an input stream.
@GuardedBy("lock")
private boolean processingInput;

View File

@ -44,6 +44,7 @@ import java.util.concurrent.atomic.AtomicInteger;
private static final String TAG = "ExtTexMgr";
private static final String TIMER_THREAD_NAME = "ExtTexMgr:Timer";
/**
* The time out in milliseconds after calling signalEndOfCurrentInputStream after which the input
* stream is considered to have ended, even if not all expected frames have been received from the

View File

@ -101,8 +101,10 @@ public class HslAdjustment implements GlEffect {
/** Indicates the hue adjustment in degrees. */
public final float hueAdjustmentDegrees;
/** Indicates the saturation adjustment. */
public final float saturationAdjustment;
/** Indicates the lightness adjustment. */
public final float lightnessAdjustment;

View File

@ -1,4 +1,5 @@
package androidx.media3.effect;
/*
* Copyright 2022 The Android Open Source Project
*

View File

@ -55,6 +55,7 @@ public final class Presentation implements MatrixTransformation {
@Target(TYPE_USE)
@IntDef({LAYOUT_SCALE_TO_FIT, LAYOUT_SCALE_TO_FIT_WITH_CROP, LAYOUT_STRETCH_TO_FIT})
public @interface Layout {}
/**
* Empty pixels added above and below the input frame (for letterboxing), or to the left and right
* of the input frame (for pillarboxing), until the desired aspect ratio is achieved. All input
@ -70,6 +71,7 @@ public final class Presentation implements MatrixTransformation {
* </ul>
*/
public static final int LAYOUT_SCALE_TO_FIT = 0;
/**
* Pixels cropped from the input frame, until the desired aspect ratio is achieved. Pixels may be
* cropped either from the bottom and top, or from the left and right sides, of the input frame.
@ -84,6 +86,7 @@ public final class Presentation implements MatrixTransformation {
* </ul>
*/
public static final int LAYOUT_SCALE_TO_FIT_WITH_CROP = 1;
/**
* Frame stretched larger on the x or y axes to fit the desired aspect ratio.
*

View File

@ -48,6 +48,7 @@ public class RgbFilter implements RgbMatrix {
};
private final int colorFilter;
/**
* Ensures that the usage of HDR is consistent. {@code null} indicates that HDR has not yet been
* set.

View File

@ -97,8 +97,10 @@ public final class ScaleAndRotateTransformation implements MatrixTransformation
/** The multiplier by which the frame will scale horizontally, along the x-axis. */
public final float scaleX;
/** The multiplier by which the frame will scale vertically, along the y-axis. */
public final float scaleY;
/**
* The counterclockwise rotation, in degrees. The value should always be between 0 (included) and
* 360 degrees (excluded).

View File

@ -71,10 +71,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
PLAYER_COMMAND_PLAY_WHEN_READY,
})
public @interface PlayerCommand {}
/** Do not play. */
public static final int PLAYER_COMMAND_DO_NOT_PLAY = -1;
/** Do not play now. Wait for callback to play. */
public static final int PLAYER_COMMAND_WAIT_FOR_CALLBACK = 0;
/** Play freely. */
public static final int PLAYER_COMMAND_PLAY_WHEN_READY = 1;
@ -89,12 +92,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
AUDIO_FOCUS_STATE_LOSS_TRANSIENT_DUCK
})
private @interface AudioFocusState {}
/** No audio focus is currently being held. */
private static final int AUDIO_FOCUS_STATE_NO_FOCUS = 0;
/** The requested audio focus is currently held. */
private static final int AUDIO_FOCUS_STATE_HAVE_FOCUS = 1;
/** Audio focus has been temporarily lost. */
private static final int AUDIO_FOCUS_STATE_LOSS_TRANSIENT = 2;
/** Audio focus has been temporarily lost, but playback may continue with reduced volume. */
private static final int AUDIO_FOCUS_STATE_LOSS_TRANSIENT_DUCK = 3;
@ -114,24 +121,29 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
})
private @interface AudioFocusGain {}
/**
* @see AudioManager#AUDIOFOCUS_NONE
*/
@SuppressWarnings("InlinedApi")
private static final int AUDIOFOCUS_NONE = AudioManager.AUDIOFOCUS_NONE;
/**
* @see AudioManager#AUDIOFOCUS_GAIN
*/
private static final int AUDIOFOCUS_GAIN = AudioManager.AUDIOFOCUS_GAIN;
/**
* @see AudioManager#AUDIOFOCUS_GAIN_TRANSIENT
*/
private static final int AUDIOFOCUS_GAIN_TRANSIENT = AudioManager.AUDIOFOCUS_GAIN_TRANSIENT;
/**
* @see AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK
*/
private static final int AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK =
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK;
/**
* @see AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE
*/

View File

@ -32,18 +32,23 @@ public final class DecoderCounters {
/** The number of times a decoder has been initialized. */
public int decoderInitCount;
/** The number of times a decoder has been released. */
public int decoderReleaseCount;
/** The number of input buffers queued to the decoder. */
public int queuedInputBufferCount;
/**
* The number of skipped input buffers.
*
* <p>A skipped input buffer is an input buffer that was deliberately not queued to the decoder.
*/
public int skippedInputBufferCount;
/** The number of rendered output buffers. */
public int renderedOutputBufferCount;
/**
* The number of skipped output buffers.
*
@ -52,6 +57,7 @@ public final class DecoderCounters {
* the codec due to a flush.
*/
public int skippedOutputBufferCount;
/**
* The number of dropped buffers.
*
@ -62,6 +68,7 @@ public final class DecoderCounters {
* being queued to the decoder.
*/
public int droppedBufferCount;
/**
* The number of input buffers dropped.
*
@ -69,12 +76,14 @@ public final class DecoderCounters {
* be rendered in time.
*/
public int droppedInputBufferCount;
/**
* The maximum number of dropped buffers without an interleaving rendered output buffer.
*
* <p>Skipped buffers are ignored for the purposes of calculating this value.
*/
public int maxConsecutiveDroppedBufferCount;
/**
* The number of times all buffers to a keyframe were dropped.
*
@ -90,6 +99,7 @@ public final class DecoderCounters {
* </ul>
*/
public int droppedToKeyframeCount;
/**
* The sum of the video frame processing offsets in microseconds.
*
@ -103,6 +113,7 @@ public final class DecoderCounters {
* updating it directly.
*/
public long totalVideoFrameProcessingOffsetUs;
/**
* The number of video frame processing offsets added.
*

View File

@ -47,15 +47,19 @@ public final class DecoderReuseEvaluation {
REUSE_RESULT_YES_WITHOUT_RECONFIGURATION
})
public @interface DecoderReuseResult {}
/** The decoder cannot be reused. */
public static final int REUSE_RESULT_NO = 0;
/** The decoder can be reused, but must be flushed. */
public static final int REUSE_RESULT_YES_WITH_FLUSH = 1;
/**
* The decoder can be reused. It does not need to be flushed, but must be reconfigured by
* prefixing the next input buffer with the new format's configuration data.
*/
public static final int REUSE_RESULT_YES_WITH_RECONFIGURATION = 2;
/** The decoder can be kept. It does not need to be flushed and no reconfiguration is required. */
public static final int REUSE_RESULT_YES_WITHOUT_RECONFIGURATION = 3;
@ -87,34 +91,49 @@ public final class DecoderReuseEvaluation {
/** Decoder reuse is not implemented. */
public static final int DISCARD_REASON_REUSE_NOT_IMPLEMENTED = 1 << 0;
/** Decoder reuse is disabled by a workaround. */
public static final int DISCARD_REASON_WORKAROUND = 1 << 1;
/** Decoder reuse is disabled by overriding behavior in application code. */
public static final int DISCARD_REASON_APP_OVERRIDE = 1 << 2;
/** The sample MIME type is changing. */
public static final int DISCARD_REASON_MIME_TYPE_CHANGED = 1 << 3;
/** The codec's operating rate is changing. */
public static final int DISCARD_REASON_OPERATING_RATE_CHANGED = 1 << 4;
/** The format initialization data is changing. */
public static final int DISCARD_REASON_INITIALIZATION_DATA_CHANGED = 1 << 5;
/** The new format may exceed the decoder's configured maximum sample size, in bytes. */
public static final int DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED = 1 << 6;
/** The DRM session is changing. */
public static final int DISCARD_REASON_DRM_SESSION_CHANGED = 1 << 7;
/** The new format may exceed the decoder's configured maximum resolution. */
public static final int DISCARD_REASON_VIDEO_MAX_RESOLUTION_EXCEEDED = 1 << 8;
/** The video resolution is changing. */
public static final int DISCARD_REASON_VIDEO_RESOLUTION_CHANGED = 1 << 9;
/** The video rotation is changing. */
public static final int DISCARD_REASON_VIDEO_ROTATION_CHANGED = 1 << 10;
/** The video {@link ColorInfo} is changing. */
public static final int DISCARD_REASON_VIDEO_COLOR_INFO_CHANGED = 1 << 11;
/** The audio channel count is changing. */
public static final int DISCARD_REASON_AUDIO_CHANNEL_COUNT_CHANGED = 1 << 12;
/** The audio sample rate is changing. */
public static final int DISCARD_REASON_AUDIO_SAMPLE_RATE_CHANGED = 1 << 13;
/** The audio encoding is changing. */
public static final int DISCARD_REASON_AUDIO_ENCODING_CHANGED = 1 << 14;
/** The audio bypass mode is possible. */
public static final int DISCARD_REASON_AUDIO_BYPASS_POSSIBLE = 1 << 15;

View File

@ -68,8 +68,10 @@ public class DefaultRenderersFactory implements RenderersFactory {
@Target(TYPE_USE)
@IntDef({EXTENSION_RENDERER_MODE_OFF, EXTENSION_RENDERER_MODE_ON, EXTENSION_RENDERER_MODE_PREFER})
public @interface ExtensionRendererMode {}
/** Do not allow use of extension renderers. */
public static final int EXTENSION_RENDERER_MODE_OFF = 0;
/**
* Allow use of extension renderers. Extension renderers are indexed after core renderers of the
* same type. A {@link TrackSelector} that prefers the first suitable renderer will therefore
@ -77,6 +79,7 @@ public class DefaultRenderersFactory implements RenderersFactory {
* given track.
*/
public static final int EXTENSION_RENDERER_MODE_ON = 1;
/**
* Allow use of extension renderers. Extension renderers are indexed before core renderers of the
* same type. A {@link TrackSelector} that prefers the first suitable renderer will therefore

View File

@ -58,24 +58,28 @@ public final class ExoPlaybackException extends PlaybackException {
@Target({FIELD, METHOD, PARAMETER, LOCAL_VARIABLE, TYPE_USE})
@IntDef({TYPE_SOURCE, TYPE_RENDERER, TYPE_UNEXPECTED, TYPE_REMOTE})
public @interface Type {}
/**
* The error occurred loading data from a {@link MediaSource}.
*
* <p>Call {@link #getSourceException()} to retrieve the underlying cause.
*/
@UnstableApi public static final int TYPE_SOURCE = 0;
/**
* The error occurred in a {@link Renderer}.
*
* <p>Call {@link #getRendererException()} to retrieve the underlying cause.
*/
@UnstableApi public static final int TYPE_RENDERER = 1;
/**
* The error was an unexpected {@link RuntimeException}.
*
* <p>Call {@link #getUnexpectedException()} to retrieve the underlying cause.
*/
@UnstableApi public static final int TYPE_UNEXPECTED = 2;
/**
* The error occurred in a remote component.
*

View File

@ -143,6 +143,7 @@ import java.util.concurrent.TimeoutException;
* operation.
*/
/* package */ final TrackSelectorResult emptyTrackSelectorResult;
/* package */ final Commands permanentAvailableCommands;
private final ConditionVariable constructorFinished;

View File

@ -169,6 +169,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
private static final int ACTIVE_INTERVAL_MS = 10;
private static final int IDLE_INTERVAL_MS = 1000;
/**
* Duration for which the player needs to appear stuck before the playback is failed on the
* assumption that no further progress will be made. To appear stuck, the player's renderers must
@ -176,6 +177,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* to load it.
*/
private static final long PLAYBACK_STUCK_AFTER_MS = 4000;
/**
* Threshold under which a buffered duration is assumed to be empty. We cannot use zero to account
* for buffers currently hold but not played by the renderer.

View File

@ -54,10 +54,13 @@ public final class ExoTimeoutException extends RuntimeException {
/** The operation where this error occurred is not defined. */
public static final int TIMEOUT_OPERATION_UNDEFINED = 0;
/** The error occurred in {@link Player#release}. */
public static final int TIMEOUT_OPERATION_RELEASE = 1;
/** The error occurred in {@link ExoPlayer#setForegroundMode}. */
public static final int TIMEOUT_OPERATION_SET_FOREGROUND_MODE = 2;
/** The error occurred while detaching a surface from the player. */
public static final int TIMEOUT_OPERATION_DETACH_SURFACE = 3;

View File

@ -42,8 +42,10 @@ import androidx.media3.exoplayer.upstream.Allocator;
/** The {@link MediaPeriod} wrapped by this class. */
public final MediaPeriod mediaPeriod;
/** The unique timeline period identifier the media period belongs to. */
public final Object uid;
/**
* The sample streams for each renderer associated with this period. May contain null elements.
*/
@ -51,10 +53,13 @@ import androidx.media3.exoplayer.upstream.Allocator;
/** Whether the media period has finished preparing. */
public boolean prepared;
/** Whether any of the tracks of this media period are enabled. */
public boolean hasEnabledTracks;
/** {@link MediaPeriodInfo} about this media period. */
public MediaPeriodInfo info;
/**
* Whether all renderers are in the correct state for this {@link #mediaPeriod}.
*

View File

@ -27,8 +27,10 @@ import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
/** The media period's identifier. */
public final MediaPeriodId id;
/** The start position of the media to play within the media period, in microseconds. */
public final long startPositionUs;
/**
* The requested next start position for the current timeline period, in microseconds, or {@link
* C#TIME_UNSET} if the period was requested to start at its default position.
@ -37,6 +39,7 @@ import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
* suspended content.
*/
public final long requestedContentPositionUs;
/**
* The end position to which the media period's content is clipped in order to play a following ad
* group or to terminate a server side ad inserted stream before a played postroll, in
@ -45,25 +48,30 @@ import androidx.media3.exoplayer.source.MediaSource.MediaPeriodId;
* of this content media period.
*/
public final long endPositionUs;
/**
* The duration of the media period, like {@link #endPositionUs} but with {@link
* C#TIME_END_OF_SOURCE} and {@link C#TIME_UNSET} resolved to the timeline period duration if
* known.
*/
public final long durationUs;
/**
* Whether this media period is followed by a transition to another media period of the same
* server-side inserted ad stream. If true, {@link #isLastInTimelinePeriod}, {@link
* #isLastInTimelineWindow} and {@link #isFinal} will all be false.
*/
public final boolean isFollowedByTransitionToSameStream;
/**
* Whether this is the last media period in its timeline period (e.g., a postroll ad, or a media
* period corresponding to a timeline period without ads).
*/
public final boolean isLastInTimelinePeriod;
/** Whether this is the last media period in its timeline window. */
public final boolean isLastInTimelineWindow;
/**
* Whether this is the last media period in the entire timeline. If true, {@link
* #isLastInTimelinePeriod} will also be true.

View File

@ -43,8 +43,10 @@ import java.util.List;
/** The current {@link Timeline}. */
public final Timeline timeline;
/** The {@link MediaPeriodId} of the currently playing media period in the {@link #timeline}. */
public final MediaPeriodId periodId;
/**
* The requested next start position for the current period in the {@link #timeline}, in
* microseconds, or {@link C#TIME_UNSET} if the period was requested to start at its default
@ -54,28 +56,40 @@ import java.util.List;
* suspended content.
*/
public final long requestedContentPositionUs;
/** The start position after a reported position discontinuity, in microseconds. */
public final long discontinuityStartPositionUs;
/** The current playback state. One of the {@link Player}.STATE_ constants. */
public final @Player.State int playbackState;
/** The current playback error, or null if this is not an error state. */
@Nullable public final ExoPlaybackException playbackError;
/** Whether the player is currently loading. */
public final boolean isLoading;
/** The currently available track groups. */
public final TrackGroupArray trackGroups;
/** The result of the current track selection. */
public final TrackSelectorResult trackSelectorResult;
/** The current static metadata of the track selections. */
public final List<Metadata> staticMetadata;
/** The {@link MediaPeriodId} of the currently loading media period in the {@link #timeline}. */
public final MediaPeriodId loadingMediaPeriodId;
/** Whether playback should proceed when {@link #playbackState} == {@link Player#STATE_READY}. */
public final boolean playWhenReady;
/** Reason why playback is suppressed even though {@link #playWhenReady} is {@code true}. */
public final @PlaybackSuppressionReason int playbackSuppressionReason;
/** The playback parameters. */
public final PlaybackParameters playbackParameters;
/** Whether the main player loop is sleeping, while using offload scheduling. */
public final boolean sleepingForOffload;
@ -84,16 +98,19 @@ import java.util.List;
* of the associated period in the {@link #timeline}, in microseconds.
*/
public volatile long bufferedPositionUs;
/**
* Total duration of buffered media from {@link #positionUs} to {@link #bufferedPositionUs}
* including all ads.
*/
public volatile long totalBufferedDurationUs;
/**
* Current playback position in {@link #periodId} relative to the start of the associated period
* in the {@link #timeline}, in microseconds.
*/
public volatile long positionUs;
/**
* The value of {@link SystemClock#elapsedRealtime()} when {@link #positionUs} was updated, in
* milliseconds.

View File

@ -115,6 +115,7 @@ public interface Renderer extends PlayerMessage.Target {
MSG_SET_VIDEO_OUTPUT_RESOLUTION
})
public @interface MessageType {}
/**
* The type of a message that can be passed to a video renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload is normally a {@link
@ -125,12 +126,14 @@ public interface Renderer extends PlayerMessage.Target {
* any existing output that it has.
*/
int MSG_SET_VIDEO_OUTPUT = 1;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be a {@link Float}
* with 0 being silence and 1 being unity gain.
*/
int MSG_SET_VOLUME = 2;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be an {@link
@ -152,6 +155,7 @@ public interface Renderer extends PlayerMessage.Target {
* an audio attributes instance.
*/
int MSG_SET_AUDIO_ATTRIBUTES = 3;
/**
* The type of a message that can be passed to a {@link MediaCodec}-based video renderer via
* {@link ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be one of the
@ -161,36 +165,42 @@ public interface Renderer extends PlayerMessage.Target {
* owned by a {@link android.view.SurfaceView}.
*/
int MSG_SET_SCALING_MODE = 4;
/**
* The type of a message that can be passed to a video renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be one of the
* integer strategy constants in {@link C.VideoChangeFrameRateStrategy}.
*/
int MSG_SET_CHANGE_FRAME_RATE_STRATEGY = 5;
/**
* A type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be an {@link
* AuxEffectInfo} instance representing an auxiliary audio effect for the underlying audio track.
*/
int MSG_SET_AUX_EFFECT_INFO = 6;
/**
* The type of a message that can be passed to a video renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be a {@link
* VideoFrameMetadataListener} instance, or null.
*/
int MSG_SET_VIDEO_FRAME_METADATA_LISTENER = 7;
/**
* The type of a message that can be passed to a camera motion renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be a {@link
* CameraMotionListener} instance, or null.
*/
int MSG_SET_CAMERA_MOTION_LISTENER = 8;
/**
* The type of a message that can be passed to an audio renderer via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be a {@link Boolean}
* instance telling whether to enable or disable skipping silences in the audio stream.
*/
int MSG_SET_SKIP_SILENCE_ENABLED = 9;
/**
* The type of a message that can be passed to audio and video renderers via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be an {@link
@ -199,6 +209,7 @@ public interface Renderer extends PlayerMessage.Target {
* tunneling is enabled.
*/
int MSG_SET_AUDIO_SESSION_ID = 10;
/**
* The type of a message that can be passed to a {@link Renderer} via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}, to inform the renderer that it can schedule
@ -207,6 +218,7 @@ public interface Renderer extends PlayerMessage.Target {
* <p>The message payload must be a {@link WakeupListener} instance.
*/
int MSG_SET_WAKEUP_LISTENER = 11;
/**
* The type of a message that can be passed to audio renderers via {@link
* ExoPlayer#createMessage(PlayerMessage.Target)}. The message payload should be an {@link
@ -214,17 +226,20 @@ public interface Renderer extends PlayerMessage.Target {
* restore the default.
*/
int MSG_SET_PREFERRED_AUDIO_DEVICE = 12;
/**
* The type of a message that can be passed to a video renderer. The message payload should be a
* {@link List} containing {@linkplain Effect video effects}.
*/
int MSG_SET_VIDEO_EFFECTS = 13;
/**
* The type of a message that can be passed to a video renderer to set the desired output
* resolution. The message payload should be a {@link Size} of the desired output width and
* height. Use this method only when playing with video {@linkplain Effect effects}.
*/
int MSG_SET_VIDEO_OUTPUT_RESOLUTION = 14;
/**
* Applications or extensions may define custom {@code MSG_*} constants that can be passed to
* renderers. These custom constants must be greater than or equal to this value.
@ -240,12 +255,14 @@ public interface Renderer extends PlayerMessage.Target {
@Target(TYPE_USE)
@IntDef({STATE_DISABLED, STATE_ENABLED, STATE_STARTED})
@interface State {}
/**
* The renderer is disabled. A renderer in this state will not proactively acquire resources that
* it requires for rendering (e.g., media decoders), but may continue to hold any that it already
* has. {@link #reset()} can be called to force the renderer to release such resources.
*/
int STATE_DISABLED = 0;
/**
* The renderer is enabled but not started. A renderer in this state may render media at the
* current position (e.g. an initial video frame), but the position will not advance. A renderer
@ -253,6 +270,7 @@ public interface Renderer extends PlayerMessage.Target {
* decoders).
*/
int STATE_ENABLED = 1;
/**
* The renderer is started. Calls to {@link #render(long, long)} will cause media to be rendered.
*/

View File

@ -60,24 +60,30 @@ public interface RendererCapabilities {
})
@Deprecated
@interface FormatSupport {}
/** A mask to apply to {@link Capabilities} to obtain the {@link C.FormatSupport} only. */
int FORMAT_SUPPORT_MASK = 0b111;
/**
* @deprecated Use {@link C#FORMAT_HANDLED} instead.
*/
@Deprecated int FORMAT_HANDLED = C.FORMAT_HANDLED;
/**
* @deprecated Use {@link C#FORMAT_EXCEEDS_CAPABILITIES} instead.
*/
@Deprecated int FORMAT_EXCEEDS_CAPABILITIES = C.FORMAT_EXCEEDS_CAPABILITIES;
/**
* @deprecated Use {@link C#FORMAT_UNSUPPORTED_DRM} instead.
*/
@Deprecated int FORMAT_UNSUPPORTED_DRM = C.FORMAT_UNSUPPORTED_DRM;
/**
* @deprecated Use {@link C#FORMAT_UNSUPPORTED_SUBTYPE} instead.
*/
@Deprecated int FORMAT_UNSUPPORTED_SUBTYPE = C.FORMAT_UNSUPPORTED_SUBTYPE;
/**
* @deprecated Use {@link C#FORMAT_UNSUPPORTED_TYPE} instead.
*/
@ -95,13 +101,16 @@ public interface RendererCapabilities {
/** A mask to apply to {@link Capabilities} to obtain the {@link AdaptiveSupport} only. */
int ADAPTIVE_SUPPORT_MASK = 0b11 << 3;
/** The {@link Renderer} can seamlessly adapt between formats. */
int ADAPTIVE_SEAMLESS = 0b10 << 3;
/**
* The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity
* (~50-100ms) when adaptation occurs.
*/
int ADAPTIVE_NOT_SEAMLESS = 0b01 << 3;
/** The {@link Renderer} does not support adaptation between formats. */
int ADAPTIVE_NOT_SUPPORTED = 0;
@ -117,8 +126,10 @@ public interface RendererCapabilities {
/** A mask to apply to {@link Capabilities} to obtain {@link TunnelingSupport} only. */
int TUNNELING_SUPPORT_MASK = 0b1 << 5;
/** The {@link Renderer} supports tunneled output. */
int TUNNELING_SUPPORTED = 0b1 << 5;
/** The {@link Renderer} does not support tunneled output. */
int TUNNELING_NOT_SUPPORTED = 0;
@ -136,10 +147,13 @@ public interface RendererCapabilities {
HARDWARE_ACCELERATION_NOT_SUPPORTED,
})
@interface HardwareAccelerationSupport {}
/** A mask to apply to {@link Capabilities} to obtain {@link HardwareAccelerationSupport} only. */
int HARDWARE_ACCELERATION_SUPPORT_MASK = 0b1 << 6;
/** The renderer is able to use hardware acceleration. */
int HARDWARE_ACCELERATION_SUPPORTED = 0b1 << 6;
/** The renderer is not able to use hardware acceleration. */
int HARDWARE_ACCELERATION_NOT_SUPPORTED = 0;
@ -154,15 +168,19 @@ public interface RendererCapabilities {
@Target(TYPE_USE)
@IntDef({DECODER_SUPPORT_FALLBACK_MIMETYPE, DECODER_SUPPORT_PRIMARY, DECODER_SUPPORT_FALLBACK})
@interface DecoderSupport {}
/** A mask to apply to {@link Capabilities} to obtain {@link DecoderSupport} only. */
int DECODER_SUPPORT_MASK = 0b11 << 7;
/**
* The format's MIME type is unsupported and the renderer may use a decoder for a fallback MIME
* type.
*/
int DECODER_SUPPORT_FALLBACK_MIMETYPE = 0b10 << 7;
/** The renderer is able to use the primary decoder for the format's MIME type. */
int DECODER_SUPPORT_PRIMARY = 0b1 << 7;
/** The format exceeds the primary decoder's capabilities but is supported by fallback decoder */
int DECODER_SUPPORT_FALLBACK = 0;
@ -187,15 +205,19 @@ public interface RendererCapabilities {
AUDIO_OFFLOAD_NOT_SUPPORTED
})
@interface AudioOffloadSupport {}
/** A mask to apply to {@link Capabilities} to obtain {@link AudioOffloadSupport} only. */
int AUDIO_OFFLOAD_SUPPORT_MASK = 0b111 << 9;
/** The renderer supports audio offload and speed changes with this format. */
int AUDIO_OFFLOAD_SPEED_CHANGE_SUPPORTED = 0b100 << 9;
/** The renderer supports audio offload and gapless transitions with this format. */
int AUDIO_OFFLOAD_GAPLESS_SUPPORTED = 0b10 << 9;
/** The renderer supports audio offload with this format. */
int AUDIO_OFFLOAD_SUPPORTED = 0b1 << 9;
/** Audio offload is not supported with this format. */
int AUDIO_OFFLOAD_NOT_SUPPORTED = 0;

View File

@ -40,13 +40,17 @@ public final class SeekParameters {
/** Parameters for exact seeking. */
public static final SeekParameters EXACT = new SeekParameters(0, 0);
/** Parameters for seeking to the closest sync point. */
public static final SeekParameters CLOSEST_SYNC =
new SeekParameters(Long.MAX_VALUE, Long.MAX_VALUE);
/** Parameters for seeking to the sync point immediately before a requested seek position. */
public static final SeekParameters PREVIOUS_SYNC = new SeekParameters(Long.MAX_VALUE, 0);
/** Parameters for seeking to the sync point immediately after a requested seek position. */
public static final SeekParameters NEXT_SYNC = new SeekParameters(0, Long.MAX_VALUE);
/** Default parameters. */
public static final SeekParameters DEFAULT = EXACT;
@ -55,6 +59,7 @@ public final class SeekParameters {
* microseconds.
*/
public final long toleranceBeforeUs;
/**
* The maximum time that the actual position seeked to may exceed the requested seek position, in
* microseconds.

View File

@ -234,142 +234,204 @@ public interface AnalyticsListener {
EVENT_VIDEO_CODEC_ERROR,
})
@interface EventFlags {}
/** {@link Player#getCurrentTimeline()} changed. */
@UnstableApi int EVENT_TIMELINE_CHANGED = Player.EVENT_TIMELINE_CHANGED;
/**
* {@link Player#getCurrentMediaItem()} changed or the player started repeating the current item.
*/
@UnstableApi int EVENT_MEDIA_ITEM_TRANSITION = Player.EVENT_MEDIA_ITEM_TRANSITION;
/** {@link Player#getCurrentTracks()} changed. */
@UnstableApi int EVENT_TRACKS_CHANGED = Player.EVENT_TRACKS_CHANGED;
/** {@link Player#isLoading()} ()} changed. */
@UnstableApi int EVENT_IS_LOADING_CHANGED = Player.EVENT_IS_LOADING_CHANGED;
/** {@link Player#getPlaybackState()} changed. */
@UnstableApi int EVENT_PLAYBACK_STATE_CHANGED = Player.EVENT_PLAYBACK_STATE_CHANGED;
/** {@link Player#getPlayWhenReady()} changed. */
@UnstableApi int EVENT_PLAY_WHEN_READY_CHANGED = Player.EVENT_PLAY_WHEN_READY_CHANGED;
/** {@link Player#getPlaybackSuppressionReason()} changed. */
@UnstableApi
int EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED = Player.EVENT_PLAYBACK_SUPPRESSION_REASON_CHANGED;
/** {@link Player#isPlaying()} changed. */
@UnstableApi int EVENT_IS_PLAYING_CHANGED = Player.EVENT_IS_PLAYING_CHANGED;
/** {@link Player#getRepeatMode()} changed. */
@UnstableApi int EVENT_REPEAT_MODE_CHANGED = Player.EVENT_REPEAT_MODE_CHANGED;
/** {@link Player#getShuffleModeEnabled()} changed. */
@UnstableApi int EVENT_SHUFFLE_MODE_ENABLED_CHANGED = Player.EVENT_SHUFFLE_MODE_ENABLED_CHANGED;
/** {@link Player#getPlayerError()} changed. */
@UnstableApi int EVENT_PLAYER_ERROR = Player.EVENT_PLAYER_ERROR;
/**
* A position discontinuity occurred. See {@link
* Player.Listener#onPositionDiscontinuity(Player.PositionInfo, Player.PositionInfo, int)}.
*/
@UnstableApi int EVENT_POSITION_DISCONTINUITY = Player.EVENT_POSITION_DISCONTINUITY;
/** {@link Player#getPlaybackParameters()} changed. */
@UnstableApi int EVENT_PLAYBACK_PARAMETERS_CHANGED = Player.EVENT_PLAYBACK_PARAMETERS_CHANGED;
/** {@link Player#getAvailableCommands()} changed. */
@UnstableApi int EVENT_AVAILABLE_COMMANDS_CHANGED = Player.EVENT_AVAILABLE_COMMANDS_CHANGED;
/** {@link Player#getMediaMetadata()} changed. */
@UnstableApi int EVENT_MEDIA_METADATA_CHANGED = Player.EVENT_MEDIA_METADATA_CHANGED;
/** {@link Player#getPlaylistMetadata()} changed. */
@UnstableApi int EVENT_PLAYLIST_METADATA_CHANGED = Player.EVENT_PLAYLIST_METADATA_CHANGED;
/** {@link Player#getSeekBackIncrement()} changed. */
@UnstableApi int EVENT_SEEK_BACK_INCREMENT_CHANGED = Player.EVENT_SEEK_BACK_INCREMENT_CHANGED;
/** {@link Player#getSeekForwardIncrement()} changed. */
@UnstableApi
int EVENT_SEEK_FORWARD_INCREMENT_CHANGED = Player.EVENT_SEEK_FORWARD_INCREMENT_CHANGED;
/** {@link Player#getMaxSeekToPreviousPosition()} changed. */
@UnstableApi
int EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED =
Player.EVENT_MAX_SEEK_TO_PREVIOUS_POSITION_CHANGED;
/** {@link Player#getTrackSelectionParameters()} changed. */
@UnstableApi
int EVENT_TRACK_SELECTION_PARAMETERS_CHANGED = Player.EVENT_TRACK_SELECTION_PARAMETERS_CHANGED;
/** Audio attributes changed. */
@UnstableApi int EVENT_AUDIO_ATTRIBUTES_CHANGED = Player.EVENT_AUDIO_ATTRIBUTES_CHANGED;
/** An audio session id was set. */
@UnstableApi int EVENT_AUDIO_SESSION_ID = Player.EVENT_AUDIO_SESSION_ID;
/** The volume changed. */
@UnstableApi int EVENT_VOLUME_CHANGED = Player.EVENT_VOLUME_CHANGED;
/** Skipping silences was enabled or disabled in the audio stream. */
@UnstableApi int EVENT_SKIP_SILENCE_ENABLED_CHANGED = Player.EVENT_SKIP_SILENCE_ENABLED_CHANGED;
/** The surface size changed. */
@UnstableApi int EVENT_SURFACE_SIZE_CHANGED = Player.EVENT_SURFACE_SIZE_CHANGED;
/** The video size changed. */
@UnstableApi int EVENT_VIDEO_SIZE_CHANGED = Player.EVENT_VIDEO_SIZE_CHANGED;
/**
* The first frame has been rendered since setting the surface, since the renderer was reset or
* since the stream changed.
*/
@UnstableApi int EVENT_RENDERED_FIRST_FRAME = Player.EVENT_RENDERED_FIRST_FRAME;
/** Metadata associated with the current playback time was reported. */
@UnstableApi int EVENT_METADATA = Player.EVENT_METADATA;
/** {@link Player#getCurrentCues()} changed. */
@UnstableApi int EVENT_CUES = Player.EVENT_CUES;
/** {@link Player#getDeviceInfo()} changed. */
@UnstableApi int EVENT_DEVICE_INFO_CHANGED = Player.EVENT_DEVICE_INFO_CHANGED;
/** {@link Player#getDeviceVolume()} changed. */
@UnstableApi int EVENT_DEVICE_VOLUME_CHANGED = Player.EVENT_DEVICE_VOLUME_CHANGED;
/** A source started loading data. */
@UnstableApi
int EVENT_LOAD_STARTED = 1000; // Intentional gap to leave space for new Player events
/** A source started completed loading data. */
@UnstableApi int EVENT_LOAD_COMPLETED = 1001;
/** A source canceled loading data. */
@UnstableApi int EVENT_LOAD_CANCELED = 1002;
/** A source had a non-fatal error loading data. */
@UnstableApi int EVENT_LOAD_ERROR = 1003;
/** The downstream format sent to renderers changed. */
@UnstableApi int EVENT_DOWNSTREAM_FORMAT_CHANGED = 1004;
/** Data was removed from the end of the media buffer. */
@UnstableApi int EVENT_UPSTREAM_DISCARDED = 1005;
/** The bandwidth estimate has been updated. */
@UnstableApi int EVENT_BANDWIDTH_ESTIMATE = 1006;
/** An audio renderer was enabled. */
@UnstableApi int EVENT_AUDIO_ENABLED = 1007;
/** An audio renderer created a decoder. */
@UnstableApi int EVENT_AUDIO_DECODER_INITIALIZED = 1008;
/** The format consumed by an audio renderer changed. */
@UnstableApi int EVENT_AUDIO_INPUT_FORMAT_CHANGED = 1009;
/** The audio position has increased for the first time since the last pause or position reset. */
@UnstableApi int EVENT_AUDIO_POSITION_ADVANCING = 1010;
/** An audio underrun occurred. */
@UnstableApi int EVENT_AUDIO_UNDERRUN = 1011;
/** An audio renderer released a decoder. */
@UnstableApi int EVENT_AUDIO_DECODER_RELEASED = 1012;
/** An audio renderer was disabled. */
@UnstableApi int EVENT_AUDIO_DISABLED = 1013;
/** The audio sink encountered a non-fatal error. */
@UnstableApi int EVENT_AUDIO_SINK_ERROR = 1014;
/** A video renderer was enabled. */
@UnstableApi int EVENT_VIDEO_ENABLED = 1015;
/** A video renderer created a decoder. */
@UnstableApi int EVENT_VIDEO_DECODER_INITIALIZED = 1016;
/** The format consumed by a video renderer changed. */
@UnstableApi int EVENT_VIDEO_INPUT_FORMAT_CHANGED = 1017;
/** Video frames have been dropped. */
@UnstableApi int EVENT_DROPPED_VIDEO_FRAMES = 1018;
/** A video renderer released a decoder. */
@UnstableApi int EVENT_VIDEO_DECODER_RELEASED = 1019;
/** A video renderer was disabled. */
@UnstableApi int EVENT_VIDEO_DISABLED = 1020;
/** Video frame processing offset data has been reported. */
@UnstableApi int EVENT_VIDEO_FRAME_PROCESSING_OFFSET = 1021;
/** A DRM session has been acquired. */
@UnstableApi int EVENT_DRM_SESSION_ACQUIRED = 1022;
/** DRM keys were loaded. */
@UnstableApi int EVENT_DRM_KEYS_LOADED = 1023;
/** A non-fatal DRM session manager error occurred. */
@UnstableApi int EVENT_DRM_SESSION_MANAGER_ERROR = 1024;
/** DRM keys were restored. */
@UnstableApi int EVENT_DRM_KEYS_RESTORED = 1025;
/** DRM keys were removed. */
@UnstableApi int EVENT_DRM_KEYS_REMOVED = 1026;
/** A DRM session has been released. */
@UnstableApi int EVENT_DRM_SESSION_RELEASED = 1027;
/** The player was released. */
@UnstableApi int EVENT_PLAYER_RELEASED = 1028;
/** The audio codec encountered an error. */
@UnstableApi int EVENT_AUDIO_CODEC_ERROR = 1029;
/** The video codec encountered an error. */
@UnstableApi int EVENT_VIDEO_CODEC_ERROR = 1030;

View File

@ -41,6 +41,7 @@ public final class PlaybackStats {
public static final class EventTimeAndPlaybackState {
/** The event time at which the playback state became active. */
public final EventTime eventTime;
/** The playback state that became active. */
public final @PlaybackState int playbackState;
@ -85,6 +86,7 @@ public final class PlaybackStats {
public static final class EventTimeAndFormat {
/** The event time associated with {@link #format}. */
public final EventTime eventTime;
/** The format that started being used, or {@code null} if no format was used. */
@Nullable public final Format format;
@ -126,6 +128,7 @@ public final class PlaybackStats {
public static final class EventTimeAndException {
/** The event time at which the exception occurred. */
public final EventTime eventTime;
/** The exception that was thrown. */
public final Exception exception;
@ -193,36 +196,52 @@ public final class PlaybackStats {
PLAYBACK_STATE_ABANDONED
})
@interface PlaybackState {}
/** Playback has not started (initial state). */
public static final int PLAYBACK_STATE_NOT_STARTED = 0;
/** Playback is buffering in the background for initial playback start. */
public static final int PLAYBACK_STATE_JOINING_BACKGROUND = 1;
/** Playback is buffering in the foreground for initial playback start. */
public static final int PLAYBACK_STATE_JOINING_FOREGROUND = 2;
/** Playback is actively playing. */
public static final int PLAYBACK_STATE_PLAYING = 3;
/** Playback is paused but ready to play. */
public static final int PLAYBACK_STATE_PAUSED = 4;
/** Playback is handling a seek. */
public static final int PLAYBACK_STATE_SEEKING = 5;
/** Playback is buffering to resume active playback. */
public static final int PLAYBACK_STATE_BUFFERING = 6;
/** Playback is buffering while paused. */
public static final int PLAYBACK_STATE_PAUSED_BUFFERING = 7;
/** Playback is suppressed (e.g. due to audio focus loss). */
public static final int PLAYBACK_STATE_SUPPRESSED = 9;
/** Playback is suppressed (e.g. due to audio focus loss) while buffering to resume a playback. */
public static final int PLAYBACK_STATE_SUPPRESSED_BUFFERING = 10;
/** Playback has reached the end of the media. */
public static final int PLAYBACK_STATE_ENDED = 11;
/** Playback is stopped and can be restarted. */
public static final int PLAYBACK_STATE_STOPPED = 12;
/** Playback is stopped due a fatal error and can be retried. */
public static final int PLAYBACK_STATE_FAILED = 13;
/** Playback is interrupted by an ad. */
public static final int PLAYBACK_STATE_INTERRUPTED_BY_AD = 14;
/** Playback is abandoned before reaching the end of the media. */
public static final int PLAYBACK_STATE_ABANDONED = 15;
/** Total number of playback states. */
/* package */ static final int PLAYBACK_STATE_COUNT = 16;
@ -388,25 +407,32 @@ public final class PlaybackStats {
* ordered by {@code EventTime.realTimeMs}.
*/
public final List<EventTimeAndPlaybackState> playbackStateHistory;
/**
* The media time history as an ordered list of long[2] arrays with [0] being the realtime as
* returned by {@code SystemClock.elapsedRealtime()} and [1] being the media time at this
* realtime, in milliseconds.
*/
public final List<long[]> mediaTimeHistory;
/**
* The elapsed real-time as returned by {@code SystemClock.elapsedRealtime()} of the first
* reported playback event, or {@link C#TIME_UNSET} if no event has been reported.
*/
public final long firstReportedTimeMs;
/** The number of playbacks which were the active foreground playback at some point. */
public final int foregroundPlaybackCount;
/** The number of playbacks which were abandoned before they were ready to play. */
public final int abandonedBeforeReadyCount;
/** The number of playbacks which reached the ended state at least once. */
public final int endedCount;
/** The number of playbacks which were pre-buffered in the background. */
public final int backgroundJoiningCount;
/**
* The total time spent joining the playback, in milliseconds, or {@link C#TIME_UNSET} if no valid
* join time could be determined.
@ -416,29 +442,36 @@ public final class PlaybackStats {
* joining was interrupted by a seek, stop, or error state.
*/
public final long totalValidJoinTimeMs;
/**
* The number of playbacks with a valid join time as documented in {@link #totalValidJoinTimeMs}.
*/
public final int validJoinTimeCount;
/** The total number of times a playback has been paused. */
public final int totalPauseCount;
/** The total number of times a playback has been paused while rebuffering. */
public final int totalPauseBufferCount;
/**
* The total number of times a seek occurred. This includes seeks happening before playback
* resumed after another seek.
*/
public final int totalSeekCount;
/**
* The total number of times a rebuffer occurred. This excludes initial joining and buffering
* after seek.
*/
public final int totalRebufferCount;
/**
* The maximum time spent during a single rebuffer, in milliseconds, or {@link C#TIME_UNSET} if no
* rebuffer occurred.
*/
public final long maxRebufferTimeMs;
/** The number of ad playbacks. */
public final int adPlaybackCount;
@ -449,48 +482,61 @@ public final class PlaybackStats {
* EventTime.realTimeMs}. The {@link Format} may be null if no video format was used.
*/
public final List<EventTimeAndFormat> videoFormatHistory;
/**
* The audio format history as {@link EventTimeAndFormat EventTimeAndFormats} ordered by {@code
* EventTime.realTimeMs}. The {@link Format} may be null if no audio format was used.
*/
public final List<EventTimeAndFormat> audioFormatHistory;
/** The total media time for which video format height data is available, in milliseconds. */
public final long totalVideoFormatHeightTimeMs;
/**
* The accumulated sum of all video format heights, in pixels, times the time the format was used
* for playback, in milliseconds.
*/
public final long totalVideoFormatHeightTimeProduct;
/** The total media time for which video format bitrate data is available, in milliseconds. */
public final long totalVideoFormatBitrateTimeMs;
/**
* The accumulated sum of all video format bitrates, in bits per second, times the time the format
* was used for playback, in milliseconds.
*/
public final long totalVideoFormatBitrateTimeProduct;
/** The total media time for which audio format data is available, in milliseconds. */
public final long totalAudioFormatTimeMs;
/**
* The accumulated sum of all audio format bitrates, in bits per second, times the time the format
* was used for playback, in milliseconds.
*/
public final long totalAudioFormatBitrateTimeProduct;
/** The number of playbacks with initial video format height data. */
public final int initialVideoFormatHeightCount;
/** The number of playbacks with initial video format bitrate data. */
public final int initialVideoFormatBitrateCount;
/**
* The total initial video format height for all playbacks, in pixels, or {@link C#LENGTH_UNSET}
* if no initial video format data is available.
*/
public final int totalInitialVideoFormatHeight;
/**
* The total initial video format bitrate for all playbacks, in bits per second, or {@link
* C#LENGTH_UNSET} if no initial video format data is available.
*/
public final long totalInitialVideoFormatBitrate;
/** The number of playbacks with initial audio format bitrate data. */
public final int initialAudioFormatBitrateCount;
/**
* The total initial audio format bitrate for all playbacks, in bits per second, or {@link
* C#LENGTH_UNSET} if no initial audio format data is available.
@ -501,6 +547,7 @@ public final class PlaybackStats {
/** The total time for which bandwidth measurement data is available, in milliseconds. */
public final long totalBandwidthTimeMs;
/** The total bytes transferred during {@link #totalBandwidthTimeMs}. */
public final long totalBandwidthBytes;
@ -508,6 +555,7 @@ public final class PlaybackStats {
/** The total number of dropped video frames. */
public final long totalDroppedFrames;
/** The total number of audio underruns. */
public final long totalAudioUnderruns;
@ -518,18 +566,22 @@ public final class PlaybackStats {
* stopped due to this error.
*/
public final int fatalErrorPlaybackCount;
/** The total number of fatal errors. Errors are fatal if playback stopped due to this error. */
public final int fatalErrorCount;
/**
* The total number of non-fatal errors. Error are non-fatal if playback can recover from the
* error without stopping.
*/
public final int nonFatalErrorCount;
/**
* The history of fatal errors as {@link EventTimeAndException EventTimeAndExceptions} ordered by
* {@code EventTime.realTimeMs}. Errors are fatal if playback stopped due to this error.
*/
public final List<EventTimeAndException> fatalErrorHistory;
/**
* The history of non-fatal errors as {@link EventTimeAndException EventTimeAndExceptions} ordered
* by {@code EventTime.realTimeMs}. Errors are non-fatal if playback can recover from the error

View File

@ -31,8 +31,10 @@ public final class AudioOffloadSupport {
public static final class Builder {
/** Whether the format is supported with offload playback. */
private boolean isFormatSupported;
/** Whether playback of the format is supported with gapless transitions. */
private boolean isGaplessSupported;
/** Whether playback of the format is supported with speed changes. */
private boolean isSpeedChangeSupported;
@ -94,8 +96,10 @@ public final class AudioOffloadSupport {
/** Whether the format is supported with offload playback. */
public final boolean isFormatSupported;
/** Whether playback of the format is supported with gapless transitions. */
public final boolean isGaplessSupported;
/** Whether playback of the format is supported with speed changes. */
public final boolean isSpeedChangeSupported;

View File

@ -163,8 +163,10 @@ public interface AudioSink {
/** The underlying {@link AudioTrack}'s state. */
public final int audioTrackState;
/** If the exception can be recovered by recreating the sink. */
public final boolean isRecoverable;
/** The input {@link Format} of the sink when the error occurs. */
public final Format format;
@ -212,8 +214,10 @@ public interface AudioSink {
* Otherwise, the meaning of the error code depends on the sink implementation.
*/
public final int errorCode;
/** If the exception can be recovered by recreating the sink. */
public final boolean isRecoverable;
/** The input {@link Format} of the sink when the error occurs. */
public final Format format;
@ -236,6 +240,7 @@ public interface AudioSink {
final class UnexpectedDiscontinuityException extends Exception {
/** The actual presentation time of a sample, in microseconds. */
public final long actualPresentationTimeUs;
/** The expected presentation time of a sample, in microseconds. */
public final long expectedPresentationTimeUs;
@ -272,13 +277,16 @@ public interface AudioSink {
SINK_FORMAT_UNSUPPORTED
})
@interface SinkFormatSupport {}
/** The sink supports the format directly, without the need for internal transcoding. */
int SINK_FORMAT_SUPPORTED_DIRECTLY = 2;
/**
* The sink supports the format, but needs to transcode it internally to do so. Internal
* transcoding may result in lower quality and higher CPU load in some cases.
*/
int SINK_FORMAT_SUPPORTED_WITH_TRANSCODING = 1;
/** The sink does not support the format. */
int SINK_FORMAT_UNSUPPORTED = 0;
@ -301,6 +309,7 @@ public interface AudioSink {
/** The audio sink will never play in offload mode. */
int OFFLOAD_MODE_DISABLED = 0;
/**
* The audio sink will prefer offload playback except in the case where both the track is gapless
* and the device does support gapless offload playback.
@ -309,6 +318,7 @@ public interface AudioSink {
* savings.
*/
int OFFLOAD_MODE_ENABLED_GAPLESS_REQUIRED = 1;
/**
* The audio sink will prefer offload playback even if this might result in silence gaps between
* tracks.

View File

@ -61,23 +61,30 @@ import java.lang.annotation.Target;
STATE_ERROR
})
private @interface State {}
/** State when first initializing. */
private static final int STATE_INITIALIZING = 0;
/** State when we have a timestamp and we don't know if it's advancing. */
private static final int STATE_TIMESTAMP = 1;
/** State when we have a timestamp and we know it is advancing. */
private static final int STATE_TIMESTAMP_ADVANCING = 2;
/** State when the no timestamp is available. */
private static final int STATE_NO_TIMESTAMP = 3;
/** State when the last timestamp was rejected as invalid. */
private static final int STATE_ERROR = 4;
/** The polling interval for {@link #STATE_INITIALIZING} and {@link #STATE_TIMESTAMP}. */
private static final int FAST_POLL_INTERVAL_US = 10_000;
/**
* The polling interval for {@link #STATE_TIMESTAMP_ADVANCING} and {@link #STATE_NO_TIMESTAMP}.
*/
private static final int SLOW_POLL_INTERVAL_US = 10_000_000;
/** The polling interval for {@link #STATE_ERROR}. */
private static final int ERROR_POLL_INTERVAL_US = 500_000;

View File

@ -116,14 +116,17 @@ import java.lang.reflect.Method;
@Target(TYPE_USE)
@IntDef({PLAYSTATE_STOPPED, PLAYSTATE_PAUSED, PLAYSTATE_PLAYING})
private @interface PlayState {}
/**
* @see AudioTrack#PLAYSTATE_STOPPED
*/
private static final int PLAYSTATE_STOPPED = AudioTrack.PLAYSTATE_STOPPED;
/**
* @see AudioTrack#PLAYSTATE_PAUSED
*/
private static final int PLAYSTATE_PAUSED = AudioTrack.PLAYSTATE_PAUSED;
/**
* @see AudioTrack#PLAYSTATE_PLAYING
*/
@ -143,6 +146,7 @@ import java.lang.reflect.Method;
* <p>This is a fail safe that should not be required on correctly functioning devices.
*/
private static final long MAX_LATENCY_US = 5 * C.MICROS_PER_SECOND;
/** The duration of time used to smooth over an adjustment between position sampling modes. */
private static final long MODE_SWITCH_SMOOTHING_DURATION_US = C.MICROS_PER_SECOND;

View File

@ -110,20 +110,24 @@ public abstract class DecoderAudioRenderer<
REINITIALIZATION_STATE_WAIT_END_OF_STREAM
})
private @interface ReinitializationState {}
/** The decoder does not need to be re-initialized. */
private static final int REINITIALIZATION_STATE_NONE = 0;
/**
* The input format has changed in a way that requires the decoder to be re-initialized, but we
* haven't yet signaled an end of stream to the existing decoder. We need to do so in order to
* ensure that it outputs any remaining buffers before we release it.
*/
private static final int REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM = 1;
/**
* The input format has changed in a way that requires the decoder to be re-initialized, and we've
* signaled an end of stream to the existing decoder. We're waiting for the decoder to output an
* end of stream signal to indicate that it has output any remaining buffers before we release it.
*/
private static final int REINITIALIZATION_STATE_WAIT_END_OF_STREAM = 2;
/**
* Generally there is zero or one pending output stream offset. We track more offsets to allow for
* pending output streams that have fewer frames than the codec latency.

View File

@ -194,6 +194,7 @@ public final class DefaultAudioSink implements AudioSink {
/** Default instance. */
AudioTrackBufferSizeProvider DEFAULT =
new DefaultAudioTrackBufferSizeProvider.Builder().build();
/**
* Returns the buffer size to use when creating an {@link AudioTrack} for a specific format and
* output mode.
@ -404,12 +405,16 @@ public final class DefaultAudioSink implements AudioSink {
/** The default playback speed. */
public static final float DEFAULT_PLAYBACK_SPEED = 1f;
/** The minimum allowed playback speed. Lower values will be constrained to fall in range. */
public static final float MIN_PLAYBACK_SPEED = 0.1f;
/** The maximum allowed playback speed. Higher values will be constrained to fall in range. */
public static final float MAX_PLAYBACK_SPEED = 8f;
/** The minimum allowed pitch factor. Lower values will be constrained to fall in range. */
public static final float MIN_PITCH = 0.1f;
/** The maximum allowed pitch factor. Higher values will be constrained to fall in range. */
public static final float MAX_PITCH = 8f;
@ -425,8 +430,10 @@ public final class DefaultAudioSink implements AudioSink {
/** The audio sink plays PCM audio. */
public static final int OUTPUT_MODE_PCM = 0;
/** The audio sink plays encoded audio in offload. */
public static final int OUTPUT_MODE_OFFLOAD = 1;
/** The audio sink plays encoded audio in passthrough. */
public static final int OUTPUT_MODE_PASSTHROUGH = 2;
@ -1874,8 +1881,10 @@ public final class DefaultAudioSink implements AudioSink {
/** The playback parameters. */
public final PlaybackParameters playbackParameters;
/** The media time from which the playback parameters apply, in microseconds. */
public final long mediaTimeUs;
/** The audio track position from which the playback parameters apply, in microseconds. */
public final long audioTrackPositionUs;

View File

@ -44,14 +44,19 @@ public class DefaultAudioTrackBufferSizeProvider
/** Default minimum length for the {@link AudioTrack} buffer, in microseconds. */
private static final int MIN_PCM_BUFFER_DURATION_US = 250_000;
/** Default maximum length for the {@link AudioTrack} buffer, in microseconds. */
private static final int MAX_PCM_BUFFER_DURATION_US = 750_000;
/** Default multiplication factor to apply to the minimum buffer size requested. */
private static final int PCM_BUFFER_MULTIPLICATION_FACTOR = 4;
/** Default length for passthrough {@link AudioTrack} buffers, in microseconds. */
private static final int PASSTHROUGH_BUFFER_DURATION_US = 250_000;
/** Default length for offload {@link AudioTrack} buffers, in microseconds. */
private static final int OFFLOAD_BUFFER_DURATION_US = 50_000_000;
/**
* Default multiplication factor to apply to AC3 passthrough buffer to avoid underruns on some
* devices (e.g., Broadcom 7271).
@ -146,14 +151,19 @@ public class DefaultAudioTrackBufferSizeProvider
/** The minimum length for PCM {@link AudioTrack} buffers, in microseconds. */
protected final int minPcmBufferDurationUs;
/** The maximum length for PCM {@link AudioTrack} buffers, in microseconds. */
protected final int maxPcmBufferDurationUs;
/** The multiplication factor to apply to the minimum buffer size requested. */
protected final int pcmBufferMultiplicationFactor;
/** The length for passthrough {@link AudioTrack} buffers, in microseconds. */
protected final int passthroughBufferDurationUs;
/** The length for offload {@link AudioTrack} buffers, in microseconds. */
protected final int offloadBufferDurationUs;
/**
* The multiplication factor to apply to AC3 passthrough buffer to avoid underruns on some devices
* (e.g., Broadcom 7271).

View File

@ -93,6 +93,7 @@ import java.util.List;
public class MediaCodecAudioRenderer extends MediaCodecRenderer implements MediaClock {
private static final String TAG = "MediaCodecAudioRenderer";
/**
* Custom key used to indicate bits per sample by some decoders on Vivo devices. For example
* OMX.vivo.alac.decoder on the Vivo Z1 Pro.
@ -106,6 +107,7 @@ public class MediaCodecAudioRenderer extends MediaCodecRenderer implements Media
private int codecMaxInputSize;
private boolean codecNeedsDiscardChannelsWorkaround;
@Nullable private Format inputFormat;
/** Codec used for DRM decryption only in passthrough and offload. */
@Nullable private Format decryptOnlyCodecFormat;

View File

@ -44,11 +44,13 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
* minimumSilenceDurationUs}.
*/
public static final long DEFAULT_MINIMUM_SILENCE_DURATION_US = 150_000;
/**
* The default value for {@link #SilenceSkippingAudioProcessor(long, long, short)
* paddingSilenceUs}.
*/
public static final long DEFAULT_PADDING_SILENCE_US = 20_000;
/**
* The default value for {@link #SilenceSkippingAudioProcessor(long, long, short)
* silenceThresholdLevel}.
@ -65,10 +67,13 @@ public final class SilenceSkippingAudioProcessor extends BaseAudioProcessor {
STATE_SILENT,
})
private @interface State {}
/** State when the input is not silent. */
private static final int STATE_NOISY = 0;
/** State when the input may be silent but we haven't read enough yet to know. */
private static final int STATE_MAYBE_SILENT = 1;
/** State when the input is silent. */
private static final int STATE_SILENT = 2;

View File

@ -276,19 +276,25 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
@Target(TYPE_USE)
@IntDef({MODE_PLAYBACK, MODE_QUERY, MODE_DOWNLOAD, MODE_RELEASE})
public @interface Mode {}
/**
* Loads and refreshes (if necessary) a license for playback. Supports streaming and offline
* licenses.
*/
public static final int MODE_PLAYBACK = 0;
/** Restores an offline license to allow its status to be queried. */
public static final int MODE_QUERY = 1;
/** Downloads an offline license or renews an existing one. */
public static final int MODE_DOWNLOAD = 2;
/** Releases an existing offline license. */
public static final int MODE_RELEASE = 3;
/** Number of times to retry for initial provisioning and key request for reporting error. */
public static final int INITIAL_DRM_REQUEST_RETRY_COUNT = 3;
/** Default value for {@link Builder#setSessionKeepaliveMs(long)}. */
public static final long DEFAULT_SESSION_KEEPALIVE_MS = 5 * 60 * C.MILLIS_PER_SECOND;

Some files were not shown because too many files have changed in this diff Show More