diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractor.java b/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractor.java new file mode 100644 index 0000000000..26dd392c28 --- /dev/null +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractor.java @@ -0,0 +1,55 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package androidx.media3.extractor; + +import androidx.media3.common.util.UnstableApi; +import java.io.IOException; + +/** An overridable {@link Extractor} implementation forwarding all methods to an underlying Extractor. */ +@UnstableApi +public class ForwardingExtractor implements Extractor { + private final Extractor delegate; + + public ForwardingExtractor(Extractor delegate) { + this.delegate = delegate; + } + + @Override + public boolean sniff(ExtractorInput input) throws IOException { + return delegate.sniff(input); + } + + @Override + public void init(ExtractorOutput output) { + delegate.init(output); + } + + @Override + public @ReadResult int read(ExtractorInput input, PositionHolder seekPosition) + throws IOException { + return delegate.read(input, seekPosition); + } + + @Override + public void seek(long position, long timeUs) { + delegate.seek(position, timeUs); + } + + @Override + public void release() { + delegate.release(); + } +} diff --git a/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractorOutput.java b/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractorOutput.java new file mode 100644 index 0000000000..6a23de48eb --- /dev/null +++ b/libraries/extractor/src/main/java/androidx/media3/extractor/ForwardingExtractorOutput.java @@ -0,0 +1,44 @@ +/* + * Copyright 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package androidx.media3.extractor; + +import androidx.media3.common.C; +import androidx.media3.common.util.UnstableApi; + +/** An overridable {@link ExtractorOutput} implementation forwarding all methods to another input. */ +@UnstableApi +public class ForwardingExtractorOutput implements ExtractorOutput { + private final ExtractorOutput output; + + public ForwardingExtractorOutput(ExtractorOutput output) { + this.output = output; + } + + @Override + public TrackOutput track(int id, @C.TrackType int type) { + return output.track(id, type); + } + + @Override + public void endTracks() { + output.endTracks(); + } + + @Override + public void seekMap(SeekMap seekMap) { + output.seekMap(seekMap); + } +}