diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Muxer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Muxer.java index 631ce56699..b25270942f 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Muxer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Muxer.java @@ -19,6 +19,7 @@ import android.os.ParcelFileDescriptor; import androidx.media3.common.C; import androidx.media3.common.Format; import androidx.media3.common.MimeTypes; +import androidx.media3.common.util.UnstableApi; import com.google.common.collect.ImmutableList; import java.io.IOException; import java.nio.ByteBuffer; @@ -26,17 +27,18 @@ import java.nio.ByteBuffer; /** * Abstracts media muxing operations. * - *
Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int)} sample MIME types} are + *
Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int) sample MIME types} are * supported and {@linkplain #addTrack(Format) add all tracks}, then {@linkplain * #writeSampleData(int, ByteBuffer, boolean, long) write sample data} to mux samples. Once any * sample data has been written, it is not possible to add tracks. After writing all sample data, * {@linkplain #release(boolean) release} the instance to finish writing to the output and return * any resources to the system. */ -/* package */ interface Muxer { +@UnstableApi +public interface Muxer { /** Thrown when a muxing failure occurs. */ - /* package */ final class MuxerException extends Exception { + final class MuxerException extends Exception { /** * Creates an instance. * @@ -91,7 +93,7 @@ import java.nio.ByteBuffer; * Writes the specified sample. * * @param trackIndex The index of the track, previously returned by {@link #addTrack(Format)}. - * @param data Buffer containing the sample data to write to the container. + * @param data A buffer containing the sample data to write to the container. * @param isKeyFrame Whether the sample is a key frame. * @param presentationTimeUs The presentation time of the sample in microseconds. * @throws MuxerException If the muxer fails to write the sample. @@ -100,11 +102,13 @@ import java.nio.ByteBuffer; throws MuxerException; /** - * Releases any resources associated with muxing. + * Finishes writing the output and releases any resources associated with muxing. + * + *
The muxer cannot be used anymore once this method has been called. * * @param forCancellation Whether the reason for releasing the resources is the transformation * cancellation. - * @throws MuxerException If the muxer fails to stop or release resources and {@code + * @throws MuxerException If the muxer fails to finish writing the output and {@code * forCancellation} is false. */ void release(boolean forCancellation) throws MuxerException; diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/MuxerWrapper.java b/libraries/transformer/src/main/java/androidx/media3/transformer/MuxerWrapper.java index 32f6bf99a7..611e469b06 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/MuxerWrapper.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/MuxerWrapper.java @@ -184,13 +184,13 @@ import java.nio.ByteBuffer; } /** - * Releases any resources associated with muxing. + * Finishes writing the output and releases any resources associated with muxing. * *
The muxer cannot be used anymore once this method has been called. * * @param forCancellation Whether the reason for releasing the resources is the transformation * cancellation. - * @throws Muxer.MuxerException If the underlying muxer fails to stop and to release resources and + * @throws Muxer.MuxerException If the underlying muxer fails to finish writing the output and * {@code forCancellation} is false. */ public void release(boolean forCancellation) throws Muxer.MuxerException { diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java index 9836223997..75c57ef423 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java @@ -373,6 +373,20 @@ public final class Transformer { return this; } + /** + * Sets the factory for muxers that write the media container. + * + *
The default value is a {@link DefaultMuxer.Factory}. + * + * @param muxerFactory A {@link Muxer.Factory}. + * @return This builder. + */ + @CanIgnoreReturnValue + public Builder setMuxerFactory(Muxer.Factory muxerFactory) { + this.muxerFactory = muxerFactory; + return this; + } + /** * Sets a provider for views to show diagnostic information (if available) during * transformation. @@ -407,21 +421,6 @@ public final class Transformer { return this; } - /** - * Sets the factory for muxers that write the media container. - * - *
The default value is a {@link DefaultMuxer.Factory}. - * - * @param muxerFactory A {@link Muxer.Factory}. - * @return This builder. - */ - @CanIgnoreReturnValue - @VisibleForTesting - /* package */ Builder setMuxerFactory(Muxer.Factory muxerFactory) { - this.muxerFactory = muxerFactory; - return this; - } - /** * Builds a {@link Transformer} instance. *