mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add setSequences method to Composition.Builder
For pause and resume feature, we need to buildUpon the original composition and then set the modified sequences. PiperOrigin-RevId: 559723694
This commit is contained in:
parent
2eafa570e9
commit
a6f9fefb88
1 changed files with 33 additions and 18 deletions
|
|
@ -42,24 +42,13 @@ public final class Composition {
|
||||||
/** A builder for {@link Composition} instances. */
|
/** A builder for {@link Composition} instances. */
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
|
|
||||||
private final ImmutableList<EditedMediaItemSequence> sequences;
|
private ImmutableList<EditedMediaItemSequence> sequences;
|
||||||
|
|
||||||
private Effects effects;
|
private Effects effects;
|
||||||
private boolean forceAudioTrack;
|
private boolean forceAudioTrack;
|
||||||
private boolean transmuxAudio;
|
private boolean transmuxAudio;
|
||||||
private boolean transmuxVideo;
|
private boolean transmuxVideo;
|
||||||
private @HdrMode int hdrMode;
|
private @HdrMode int hdrMode;
|
||||||
|
|
||||||
/** Creates a new instance to build upon the provided {@link Composition}. */
|
|
||||||
private Builder(Composition composition) {
|
|
||||||
sequences = composition.sequences;
|
|
||||||
effects = composition.effects;
|
|
||||||
forceAudioTrack = composition.forceAudioTrack;
|
|
||||||
transmuxAudio = composition.transmuxAudio;
|
|
||||||
transmuxVideo = composition.transmuxVideo;
|
|
||||||
hdrMode = composition.hdrMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an instance.
|
* Creates an instance.
|
||||||
*
|
*
|
||||||
|
|
@ -72,9 +61,8 @@ public final class Composition {
|
||||||
/**
|
/**
|
||||||
* Creates an instance.
|
* Creates an instance.
|
||||||
*
|
*
|
||||||
* @param sequences The {@link EditedMediaItemSequence} instances to compose. {@link MediaItem}
|
* @param sequences The {@link EditedMediaItemSequence} instances to compose. The list must be
|
||||||
* instances from different sequences that are overlapping in time will be mixed in the
|
* non empty. See {@link Composition#sequences} for more details.
|
||||||
* output. This list must not be empty.
|
|
||||||
*/
|
*/
|
||||||
public Builder(List<EditedMediaItemSequence> sequences) {
|
public Builder(List<EditedMediaItemSequence> sequences) {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
|
|
@ -84,6 +72,16 @@ public final class Composition {
|
||||||
effects = Effects.EMPTY;
|
effects = Effects.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Creates a new instance to build upon the provided {@link Composition}. */
|
||||||
|
private Builder(Composition composition) {
|
||||||
|
sequences = composition.sequences;
|
||||||
|
effects = composition.effects;
|
||||||
|
forceAudioTrack = composition.forceAudioTrack;
|
||||||
|
transmuxAudio = composition.transmuxAudio;
|
||||||
|
transmuxVideo = composition.transmuxVideo;
|
||||||
|
hdrMode = composition.hdrMode;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link Effects} to apply to the {@link Composition}.
|
* Sets the {@link Effects} to apply to the {@link Composition}.
|
||||||
*
|
*
|
||||||
|
|
@ -194,7 +192,7 @@ public final class Composition {
|
||||||
*
|
*
|
||||||
* <p>The default value is {@link #HDR_MODE_KEEP_HDR}. Apps that need to tone-map HDR to SDR
|
* <p>The default value is {@link #HDR_MODE_KEEP_HDR}. Apps that need to tone-map HDR to SDR
|
||||||
* should generally prefer {@link #HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL} over {@link
|
* should generally prefer {@link #HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_OPEN_GL} over {@link
|
||||||
* HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC}, because its behavior is likely to be more
|
* #HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC}, because its behavior is likely to be more
|
||||||
* consistent across devices.
|
* consistent across devices.
|
||||||
*
|
*
|
||||||
* @param hdrMode The {@link HdrMode} used.
|
* @param hdrMode The {@link HdrMode} used.
|
||||||
|
|
@ -211,6 +209,22 @@ public final class Composition {
|
||||||
return new Composition(
|
return new Composition(
|
||||||
sequences, effects, forceAudioTrack, transmuxAudio, transmuxVideo, hdrMode);
|
sequences, effects, forceAudioTrack, transmuxAudio, transmuxVideo, hdrMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets {@link Composition#sequences}.
|
||||||
|
*
|
||||||
|
* @param sequences The {@link EditedMediaItemSequence} instances to compose. The list must not
|
||||||
|
* be empty.
|
||||||
|
* @return This builder.
|
||||||
|
*/
|
||||||
|
@CanIgnoreReturnValue
|
||||||
|
/* package */ Builder setSequences(List<EditedMediaItemSequence> sequences) {
|
||||||
|
checkArgument(
|
||||||
|
!sequences.isEmpty(),
|
||||||
|
"The composition must contain at least one EditedMediaItemSequence.");
|
||||||
|
this.sequences = ImmutableList.copyOf(sequences);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -290,7 +304,8 @@ public final class Composition {
|
||||||
/**
|
/**
|
||||||
* The {@link EditedMediaItemSequence} instances to compose.
|
* The {@link EditedMediaItemSequence} instances to compose.
|
||||||
*
|
*
|
||||||
* <p>For more information, see {@link Builder#Builder(List)}.
|
* <p>{@link MediaItem} instances from different sequences that are overlapping in time will be
|
||||||
|
* mixed in the output.
|
||||||
*/
|
*/
|
||||||
public final ImmutableList<EditedMediaItemSequence> sequences;
|
public final ImmutableList<EditedMediaItemSequence> sequences;
|
||||||
|
|
||||||
|
|
@ -326,7 +341,7 @@ public final class Composition {
|
||||||
public final @HdrMode int hdrMode;
|
public final @HdrMode int hdrMode;
|
||||||
|
|
||||||
/** Returns a {@link Composition.Builder} initialized with the values of this instance. */
|
/** Returns a {@link Composition.Builder} initialized with the values of this instance. */
|
||||||
public Builder buildUpon() {
|
/* package */ Builder buildUpon() {
|
||||||
return new Builder(this);
|
return new Builder(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue