Set a longer muxer timeout on emulators

This is because the force EOS workaround for videos is longer than the original
muxer timeout. This way the apps depending on Transformer won't have to manually
set the muxer timeout on emulators.

PiperOrigin-RevId: 651355755
This commit is contained in:
claincly 2024-07-11 04:10:36 -07:00 committed by Copybara-Service
parent b7f141ad2a
commit 81f5a5f5f3
3 changed files with 4 additions and 7 deletions

View File

@ -74,6 +74,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* operation takes a long time to finish, the timeout could be a result of slow GL operation back
* pressured the decoder, and the decoder is not able to decode another frame.
*/
// LINT.IfChange(SURFACE_TEXTURE_TIMEOUT_MS)
private static final long SURFACE_TEXTURE_TIMEOUT_MS = isRunningOnEmulator() ? 20_000 : 500;
// Wait delay between checking whether a registered frame arrives on the SurfaceTexture.

View File

@ -16,12 +16,10 @@
package androidx.media3.transformer;
import static androidx.media3.common.util.Util.isRunningOnEmulator;
import static androidx.media3.transformer.AndroidTestUtil.FORCE_TRANSCODE_VIDEO_EFFECTS;
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET;
import static androidx.media3.transformer.AndroidTestUtil.assumeFormatsSupported;
import static com.google.common.truth.Truth.assertThat;
import static java.lang.Math.max;
import android.content.Context;
import android.media.MediaCodec;
@ -56,9 +54,6 @@ import org.junit.runner.RunWith;
public class ForceEndOfStreamTest {
// Referenced from ExternalTextureManager
private static final long SURFACE_TEXTURE_TIMEOUT_MS = isRunningOnEmulator() ? 20_000 : 500;
private static final long MUXER_MAX_DELAYS_BETWEEN_SAMPLES_MS =
max(SURFACE_TEXTURE_TIMEOUT_MS, Transformer.DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS);
private final Context context = ApplicationProvider.getApplicationContext();
@Rule public final TestName testName = new TestName();
@ -131,7 +126,6 @@ public class ForceEndOfStreamTest {
context,
new FrameDroppingDecoderFactory(context, MP4_ASSET.videoFrameCount, framesToSkip),
Clock.DEFAULT))
.setMaxDelayBetweenMuxerSamplesMs(MUXER_MAX_DELAYS_BETWEEN_SAMPLES_MS)
.build();
}

View File

@ -19,6 +19,7 @@ package androidx.media3.transformer;
import static androidx.media3.common.util.Assertions.checkArgument;
import static androidx.media3.common.util.Assertions.checkNotNull;
import static androidx.media3.common.util.Assertions.checkState;
import static androidx.media3.common.util.Util.isRunningOnEmulator;
import static androidx.media3.extractor.AacUtil.AAC_LC_AUDIO_SAMPLE_COUNT;
import static androidx.media3.transformer.ExportException.ERROR_CODE_MUXING_APPEND;
import static androidx.media3.transformer.ExportResult.OPTIMIZATION_ABANDONED_KEYFRAME_PLACEMENT_OPTIMAL_FOR_TRIM;
@ -757,7 +758,8 @@ public final class Transformer {
* The default value for the {@linkplain Builder#setMaxDelayBetweenMuxerSamplesMs maximum delay
* between output samples}.
*/
public static final long DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS = 10_000;
public static final long DEFAULT_MAX_DELAY_BETWEEN_MUXER_SAMPLES_MS =
isRunningOnEmulator() ? 21_000 : 10_000;
@Documented
@Retention(RetentionPolicy.SOURCE)