Skip to content

Commit

Permalink
Merge pull request #9915 from dburckh:avi
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 455094147
(cherry picked from commit ad3348c)
  • Loading branch information
marcbaechinger committed Jun 15, 2022
1 parent d867ebd commit 080b186
Show file tree
Hide file tree
Showing 21 changed files with 4,819 additions and 3 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
* MP4: Parse bitrates from `esds` boxes.
* Ogg: Allow duplicate Opus ID and comment headers
([#10038](https://github.com/google/ExoPlayer/issues/10038)).
* Add support for AVI
([#2092](https://github.com/google/ExoPlayer/issues/2092)).
* UI:
* Fix delivery of events to `OnClickListener`s set on `PlayerView` and
`LegacyPlayerView`, in the case that `useController=false`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public final class FileTypes {
@Target(TYPE_USE)
@IntDef({
UNKNOWN, AC3, AC4, ADTS, AMR, FLAC, FLV, MATROSKA, MP3, MP4, OGG, PS, TS, WAV, WEBVTT, JPEG,
MIDI
MIDI, AVI
})
public @interface Type {}
/** Unknown file type. */
Expand Down Expand Up @@ -81,6 +81,8 @@ public final class FileTypes {
public static final int JPEG = 14;
/** File type for the MIDI format. */
public static final int MIDI = 15;
/** File type for the AVI format. */
public static final int AVI = 16;

@VisibleForTesting /* package */ static final String HEADER_CONTENT_TYPE = "Content-Type";

Expand Down Expand Up @@ -116,6 +118,7 @@ public final class FileTypes {
private static final String EXTENSION_WEBVTT = ".webvtt";
private static final String EXTENSION_JPG = ".jpg";
private static final String EXTENSION_JPEG = ".jpeg";
private static final String EXTENSION_AVI = ".avi";

private FileTypes() {}

Expand Down Expand Up @@ -179,6 +182,8 @@ private FileTypes() {}
return FileTypes.WEBVTT;
case MimeTypes.IMAGE_JPEG:
return FileTypes.JPEG;
case MimeTypes.VIDEO_AVI:
return FileTypes.AVI;
default:
return FileTypes.UNKNOWN;
}
Expand Down Expand Up @@ -244,6 +249,8 @@ private FileTypes() {}
return FileTypes.WEBVTT;
} else if (filename.endsWith(EXTENSION_JPG) || filename.endsWith(EXTENSION_JPEG)) {
return FileTypes.JPEG;
} else if (filename.endsWith(EXTENSION_AVI)) {
return FileTypes.AVI;
} else {
return FileTypes.UNKNOWN;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public final class MimeTypes {
@UnstableApi public static final String VIDEO_FLV = BASE_TYPE_VIDEO + "/x-flv";
public static final String VIDEO_DOLBY_VISION = BASE_TYPE_VIDEO + "/dolby-vision";
public static final String VIDEO_OGG = BASE_TYPE_VIDEO + "/ogg";
public static final String VIDEO_AVI = BASE_TYPE_VIDEO + "/x-msvideo";
public static final String VIDEO_MJPEG = BASE_TYPE_VIDEO + "/mjpeg";
public static final String VIDEO_MP42 = BASE_TYPE_VIDEO + "/mp42";
public static final String VIDEO_MP43 = BASE_TYPE_VIDEO + "/mp43";
@UnstableApi public static final String VIDEO_UNKNOWN = BASE_TYPE_VIDEO + "/x-unknown";

// audio/ MIME types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import androidx.media3.common.util.TimestampAdjuster;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.extractor.amr.AmrExtractor;
import androidx.media3.extractor.avi.AviExtractor;
import androidx.media3.extractor.flac.FlacExtractor;
import androidx.media3.extractor.flv.FlvExtractor;
import androidx.media3.extractor.jpeg.JpegExtractor;
Expand Down Expand Up @@ -103,8 +104,11 @@ public final class DefaultExtractorsFactory implements ExtractorsFactory {
FileTypes.AC3,
FileTypes.AC4,
FileTypes.MP3,
FileTypes.JPEG,
// The following extractors are not part of the optimized ordering, and were appended
// without further analysis.
FileTypes.AVI,
FileTypes.MIDI,
FileTypes.JPEG,
};

private static final ExtensionLoader FLAC_EXTENSION_LOADER =
Expand Down Expand Up @@ -309,7 +313,8 @@ public synchronized Extractor[] createExtractors() {
@Override
public synchronized Extractor[] createExtractors(
Uri uri, Map<String, List<String>> responseHeaders) {
List<Extractor> extractors = new ArrayList<>(/* initialCapacity= */ 14);
List<Extractor> extractors =
new ArrayList<>(/* initialCapacity= */ DEFAULT_EXTRACTOR_ORDER.length);

@FileTypes.Type
int responseHeadersInferredFileType = inferFileTypeFromResponseHeaders(responseHeaders);
Expand Down Expand Up @@ -412,6 +417,9 @@ private void addExtractorsForFileType(@FileTypes.Type int fileType, List<Extract
extractors.add(midiExtractor);
}
break;
case FileTypes.AVI:
extractors.add(new AviExtractor());
break;
case FileTypes.WEBVTT:
case FileTypes.UNKNOWN:
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2022 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.avi;

/**
* A chunk, as defined in the AVI spec.
*
* <p>See https://docs.microsoft.com/en-us/windows/win32/directshow/avi-riff-file-reference.
*/
/* package */ interface AviChunk {

/** Returns the chunk type fourcc. */
int getType();
}
Loading

0 comments on commit 080b186

Please sign in to comment.