Make SpeedChangingAudioProcessor public

PiperOrigin-RevId: 542533743
This commit is contained in:
kimvde 2023-06-22 12:50:59 +00:00 committed by Tofunmi Adigun-Hameed
parent b8ac5b4210
commit 69cef452a0
5 changed files with 14 additions and 12 deletions

View File

@ -14,14 +14,12 @@
* limitations under the License. * limitations under the License.
*/ */
package androidx.media3.transformer; package androidx.media3.common.audio;
import static java.lang.Math.min; import static java.lang.Math.min;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.audio.AudioProcessor; import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.audio.BaseAudioProcessor;
import androidx.media3.common.audio.SonicAudioProcessor;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import com.google.errorprone.annotations.CanIgnoreReturnValue; import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -29,9 +27,10 @@ import java.nio.ByteBuffer;
/** /**
* An {@link AudioProcessor} that changes the speed of audio samples depending on their timestamp. * An {@link AudioProcessor} that changes the speed of audio samples depending on their timestamp.
*/ */
// TODO(b/198772621): Consider making the processor inactive and skipping it in the processor chain // TODO(b/288221200): Consider making the processor inactive and skipping it in the processor chain
// when speed is 1. // when speed is 1.
/* package */ final class SpeedChangingAudioProcessor extends BaseAudioProcessor { @UnstableApi
public final class SpeedChangingAudioProcessor extends BaseAudioProcessor {
/** The speed provider that provides the speed for each timestamp. */ /** The speed provider that provides the speed for each timestamp. */
private final SpeedProvider speedProvider; private final SpeedProvider speedProvider;

View File

@ -13,18 +13,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package androidx.media3.transformer; package androidx.media3.common.audio;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.util.UnstableApi;
/** A custom interface that determines the speed for media at specific timestamps. */ /** A custom interface that determines the speed for media at specific timestamps. */
/* package */ interface SpeedProvider { @UnstableApi
public interface SpeedProvider {
/** /**
* Provides the speed that the media should be played at, based on the timeUs. * Returns the media speed at the provided timestamp.
* *
* @param timeUs The timestamp of the media. * @param timeUs The timestamp of the media.
* @return The speed that the media should be played at, based on the timeUs. * @return The speed that the media should be played at.
*/ */
float getSpeed(long timeUs); float getSpeed(long timeUs);

View File

@ -13,14 +13,13 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package androidx.media3.transformer; package androidx.media3.common.audio;
import static androidx.media3.common.audio.AudioProcessor.EMPTY_BUFFER; import static androidx.media3.common.audio.AudioProcessor.EMPTY_BUFFER;
import static androidx.media3.common.util.Assertions.checkArgument; import static androidx.media3.common.util.Assertions.checkArgument;
import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.audio.AudioProcessor;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.ext.junit.runners.AndroidJUnit4;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;

View File

@ -30,6 +30,7 @@ import androidx.media3.common.MimeTypes;
import androidx.media3.common.audio.AudioProcessingPipeline; import androidx.media3.common.audio.AudioProcessingPipeline;
import androidx.media3.common.audio.AudioProcessor; import androidx.media3.common.audio.AudioProcessor;
import androidx.media3.common.audio.AudioProcessor.AudioFormat; import androidx.media3.common.audio.AudioProcessor.AudioFormat;
import androidx.media3.common.audio.SpeedChangingAudioProcessor;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import androidx.media3.decoder.DecoderInputBuffer; import androidx.media3.decoder.DecoderInputBuffer;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;

View File

@ -21,6 +21,7 @@ import static androidx.media3.extractor.metadata.mp4.SlowMotionData.Segment.BY_S
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.media3.common.C; import androidx.media3.common.C;
import androidx.media3.common.Metadata; import androidx.media3.common.Metadata;
import androidx.media3.common.audio.SpeedProvider;
import androidx.media3.common.util.Util; import androidx.media3.common.util.Util;
import androidx.media3.extractor.metadata.mp4.SlowMotionData; import androidx.media3.extractor.metadata.mp4.SlowMotionData;
import androidx.media3.extractor.metadata.mp4.SlowMotionData.Segment; import androidx.media3.extractor.metadata.mp4.SlowMotionData.Segment;