Make Mp4Muxers and FragmentedMp4Muxers implement AutoCloseable

PiperOrigin-RevId: 717549236
This commit is contained in:
sheenachhabra 2025-01-20 08:59:28 -08:00 committed by Copybara-Service
parent a31c7ad9a8
commit 6fe011beb4
2 changed files with 4 additions and 2 deletions

View File

@ -83,7 +83,7 @@ import java.nio.ByteBuffer;
* </ul>
*/
@UnstableApi
public final class FragmentedMp4Muxer {
public final class FragmentedMp4Muxer implements AutoCloseable {
/** The default fragment duration. */
public static final long DEFAULT_FRAGMENT_DURATION_MS = 2_000;
@ -254,6 +254,7 @@ public final class FragmentedMp4Muxer {
*
* @throws MuxerException If the muxer fails to finish writing the output.
*/
@Override
public void close() throws MuxerException {
try {
fragmentedMp4Writer.close();

View File

@ -109,7 +109,7 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull;
* </ul>
*/
@UnstableApi
public final class Mp4Muxer {
public final class Mp4Muxer implements AutoCloseable {
/** Parameters for {@link #FILE_FORMAT_MP4_WITH_AUXILIARY_TRACKS_EXTENSION}. */
public static final class Mp4AtFileParameters {
/** Provides temporary cache files to be used by the muxer. */
@ -535,6 +535,7 @@ public final class Mp4Muxer {
*
* @throws MuxerException If the muxer fails to finish writing the output.
*/
@Override
public void close() throws MuxerException {
@Nullable MuxerException exception = null;
try {