implement getDurationAfterEffectApplied in TimestampAdjustment Effect
PiperOrigin-RevId: 653206245
This commit is contained in:
parent
c05a5c6237
commit
29a2486ce3
@ -44,6 +44,14 @@ public final class TimestampAdjustment implements GlEffect {
|
||||
* on any thread.
|
||||
*/
|
||||
void calculateOutputTimeUs(long inputTimeUs, TimestampConsumer outputTimeConsumer);
|
||||
|
||||
/**
|
||||
* Returns the expected duration of the output stream when the map is applied given a input
|
||||
* {@code durationUs}.
|
||||
*/
|
||||
default long getDurationUsAfterTimestampsMapped(long durationUs) {
|
||||
return durationUs;
|
||||
}
|
||||
}
|
||||
|
||||
private final TimestampMap timestampMap;
|
||||
@ -57,4 +65,9 @@ public final class TimestampAdjustment implements GlEffect {
|
||||
public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr) {
|
||||
return new TimestampAdjustmentShaderProgram(timestampMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDurationAfterEffectApplied(long durationUs) {
|
||||
return timestampMap.getDurationUsAfterTimestampsMapped(durationUs);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.audio.AudioProcessor;
|
||||
import androidx.media3.common.audio.SpeedChangingAudioProcessor;
|
||||
import androidx.media3.common.audio.SpeedProvider;
|
||||
import androidx.media3.common.util.TimestampConsumer;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.effect.SpeedChangeEffect;
|
||||
import androidx.media3.effect.TimestampAdjustment;
|
||||
@ -79,8 +80,21 @@ public final class Effects {
|
||||
SpeedProvider speedProvider) {
|
||||
SpeedChangingAudioProcessor speedChangingAudioProcessor =
|
||||
new SpeedChangingAudioProcessor(speedProvider);
|
||||
Effect audioDrivenvideoEffect =
|
||||
new TimestampAdjustment(speedChangingAudioProcessor::getSpeedAdjustedTimeAsync);
|
||||
return Pair.create(speedChangingAudioProcessor, audioDrivenvideoEffect);
|
||||
Effect audioDrivenVideoEffect =
|
||||
new TimestampAdjustment(
|
||||
new TimestampAdjustment.TimestampMap() {
|
||||
@Override
|
||||
public void calculateOutputTimeUs(
|
||||
long inputTimeUs, TimestampConsumer outputTimeConsumer) {
|
||||
speedChangingAudioProcessor.getSpeedAdjustedTimeAsync(
|
||||
inputTimeUs, outputTimeConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDurationUsAfterTimestampsMapped(long durationUs) {
|
||||
return speedChangingAudioProcessor.getDurationAfterProcessorApplied(durationUs);
|
||||
}
|
||||
});
|
||||
return Pair.create(speedChangingAudioProcessor, audioDrivenVideoEffect);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user