mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Rename MuxerWrapper.release() method
PiperOrigin-RevId: 615399319
This commit is contained in:
parent
644d9a3461
commit
668a172683
@ -617,7 +617,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finishes writing the output and releases any resources associated with muxing.
|
* Finishes writing the output and may release any resources associated with muxing.
|
||||||
*
|
*
|
||||||
* <p>When this method is called in {@link #MUXER_MODE_MUX_PARTIAL} mode, the resources are not
|
* <p>When this method is called in {@link #MUXER_MODE_MUX_PARTIAL} mode, the resources are not
|
||||||
* released and the {@link MuxerWrapper} can be reused after {@link #changeToAppendMode() changing
|
* released and the {@link MuxerWrapper} can be reused after {@link #changeToAppendMode() changing
|
||||||
@ -631,7 +631,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
* @throws Muxer.MuxerException If the underlying {@link Muxer} fails to finish writing the output
|
* @throws Muxer.MuxerException If the underlying {@link Muxer} fails to finish writing the output
|
||||||
* and the {@code releaseReason} is not {@link #MUXER_RELEASE_REASON_CANCELLED}.
|
* and the {@code releaseReason} is not {@link #MUXER_RELEASE_REASON_CANCELLED}.
|
||||||
*/
|
*/
|
||||||
public void release(@MuxerReleaseReason int releaseReason) throws Muxer.MuxerException {
|
public void finishWritingAndMaybeRelease(@MuxerReleaseReason int releaseReason)
|
||||||
|
throws Muxer.MuxerException {
|
||||||
if (releaseReason == MUXER_RELEASE_REASON_COMPLETED && muxerMode == MUXER_MODE_MUX_PARTIAL) {
|
if (releaseReason == MUXER_RELEASE_REASON_COMPLETED && muxerMode == MUXER_MODE_MUX_PARTIAL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -408,7 +408,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
muxerWrapper.release(getMuxerReleaseReason(endReason));
|
muxerWrapper.finishWritingAndMaybeRelease(getMuxerReleaseReason(endReason));
|
||||||
} catch (Muxer.MuxerException e) {
|
} catch (Muxer.MuxerException e) {
|
||||||
if (releaseExportException == null) {
|
if (releaseExportException == null) {
|
||||||
releaseExportException = ExportException.createForMuxer(e, ERROR_CODE_MUXING_FAILED);
|
releaseExportException = ExportException.createForMuxer(e, ERROR_CODE_MUXING_FAILED);
|
||||||
|
@ -77,7 +77,7 @@ public class MuxerWrapperTest {
|
|||||||
public void tearDown() throws Muxer.MuxerException {
|
public void tearDown() throws Muxer.MuxerException {
|
||||||
if (muxerWrapper != null) {
|
if (muxerWrapper != null) {
|
||||||
// Release with reason cancellation so that underlying resources are always released.
|
// Release with reason cancellation so that underlying resources are always released.
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_CANCELLED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_CANCELLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
muxerWrapper.setTrackCount(1);
|
muxerWrapper.setTrackCount(1);
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
muxerWrapper.setTrackCount(1);
|
muxerWrapper.setTrackCount(1);
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
muxerWrapper.setTrackCount(1);
|
muxerWrapper.setTrackCount(1);
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
muxerWrapper.setTrackCount(1);
|
muxerWrapper.setTrackCount(1);
|
||||||
Format differentAudioFormat = FAKE_AUDIO_TRACK_FORMAT.buildUpon().setSampleRate(48000).build();
|
Format differentAudioFormat = FAKE_AUDIO_TRACK_FORMAT.buildUpon().setSampleRate(48000).build();
|
||||||
@ -339,7 +339,7 @@ public class MuxerWrapperTest {
|
|||||||
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 17);
|
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 17);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper = null;
|
muxerWrapper = null;
|
||||||
|
|
||||||
DumpFileAsserts.assertOutput(
|
DumpFileAsserts.assertOutput(
|
||||||
@ -363,7 +363,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
|
|
||||||
assertThat(muxerWrapper.isEnded()).isTrue();
|
assertThat(muxerWrapper.isEnded()).isTrue();
|
||||||
muxerWrapper = null;
|
muxerWrapper = null;
|
||||||
@ -392,7 +392,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_AUDIO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_AUDIO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
|
|
||||||
assertThat(muxerWrapper.isEnded()).isTrue();
|
assertThat(muxerWrapper.isEnded()).isTrue();
|
||||||
muxerWrapper = null;
|
muxerWrapper = null;
|
||||||
@ -413,7 +413,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
muxerWrapper.endTrack(C.TRACK_TYPE_VIDEO);
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
muxerWrapper.setTrackCount(1);
|
muxerWrapper.setTrackCount(1);
|
||||||
muxerWrapper.addTrackFormat(FAKE_VIDEO_TRACK_FORMAT);
|
muxerWrapper.addTrackFormat(FAKE_VIDEO_TRACK_FORMAT);
|
||||||
@ -570,7 +570,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
|
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_COMPLETED);
|
||||||
|
|
||||||
// Resources are not released and samples can be written in the append mode.
|
// Resources are not released and samples can be written in the append mode.
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
@ -596,7 +596,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
|
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_CANCELLED);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_CANCELLED);
|
||||||
|
|
||||||
// Resources are released and samples can not be written in the append mode.
|
// Resources are released and samples can not be written in the append mode.
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
@ -621,7 +621,7 @@ public class MuxerWrapperTest {
|
|||||||
muxerWrapper.writeSample(
|
muxerWrapper.writeSample(
|
||||||
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
C.TRACK_TYPE_VIDEO, FAKE_SAMPLE, /* isKeyFrame= */ true, /* presentationTimeUs= */ 0);
|
||||||
|
|
||||||
muxerWrapper.release(MuxerWrapper.MUXER_RELEASE_REASON_ERROR);
|
muxerWrapper.finishWritingAndMaybeRelease(MuxerWrapper.MUXER_RELEASE_REASON_ERROR);
|
||||||
|
|
||||||
// Resources are released and samples can not be written in the append mode.
|
// Resources are released and samples can not be written in the append mode.
|
||||||
muxerWrapper.changeToAppendMode();
|
muxerWrapper.changeToAppendMode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user