mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Make Muxer public
The reason for making the Muxer public is that we want to add an option to disable or configure the timer that will throw when the muxer doesn't receive any data for a given period of time. PiperOrigin-RevId: 482199360
This commit is contained in:
parent
601eaba7a6
commit
cf14d0687d
@ -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.
|
||||
*
|
||||
* <p>Query whether {@linkplain Factory#getSupportedSampleMimeTypes(int)} sample MIME types} are
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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;
|
||||
|
@ -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.
|
||||
*
|
||||
* <p>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 {
|
||||
|
@ -373,6 +373,20 @@ public final class Transformer {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the factory for muxers that write the media container.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
* <p>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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user