Skip to content

Commit

Permalink
Do not trim audio samples by changing their timestamp
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tonihei authored and tianyif committed Jun 29, 2023
1 parent 7996766 commit 2322462
Show file tree
Hide file tree
Showing 308 changed files with 1,920 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ public void clearVideoSurfaceView(@Nullable SurfaceView surfaceView) {}
/** 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) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ public static final class ItemData {

/** 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -94,8 +98,10 @@ public AdOverlayInfo build() {

/** 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,33 @@ public static final class AdGroup 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
* inserted ad live stream is joined while an ad is already playing and some ad information is
* 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;

Expand Down Expand Up @@ -535,14 +542,19 @@ private static AdGroup fromBundle(Bundle bundle) {
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;

Expand All @@ -564,12 +576,15 @@ private static AdGroup fromBundle(Bundle bundle) {

/** 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@ public AudioAttributes build() {

/** 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public final class AuxEffectInfo {
* @see android.media.AudioTrack#attachAuxEffect(int)
*/
public final int effectId;

/**
* The send level for the effect.
*
Expand Down
Loading

0 comments on commit 2322462

Please sign in to comment.