Commit d9421f4f by cdrolle Committed by Oliver Woodman

Fixed issue when VOD-style period is present in a dynamic manifest

A VOD-style period in a dynamic manifest would result in a NullPointerException.
Also fix another issue in which an unrecognized mime type would also result in
NullPointerException.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=138075137
parent aaf38adc
......@@ -424,9 +424,13 @@ public final class DashMediaSource implements MediaSource {
// not correspond to the start of a segment in both, but this is an edge case.
DashSegmentIndex index =
period.adaptationSets.get(videoAdaptationSetIndex).representations.get(0).getIndex();
int segmentNum = index.getSegmentNum(defaultStartPositionInPeriodUs, periodDurationUs);
windowDefaultStartPositionUs =
defaultStartPositionUs - defaultStartPositionInPeriodUs + index.getTimeUs(segmentNum);
if (index != null) {
int segmentNum = index.getSegmentNum(defaultStartPositionInPeriodUs, periodDurationUs);
windowDefaultStartPositionUs =
defaultStartPositionUs - defaultStartPositionInPeriodUs + index.getTimeUs(segmentNum);
} else {
windowDefaultStartPositionUs = defaultStartPositionUs;
}
} else {
windowDefaultStartPositionUs = defaultStartPositionUs;
}
......
......@@ -81,6 +81,9 @@ public interface SubtitleDecoderFactory {
}
private Class<?> getDecoderClass(String mimeType) {
if (mimeType == null) {
return null;
}
try {
switch (mimeType) {
case MimeTypes.TEXT_VTT:
......
......@@ -84,7 +84,7 @@ public final class MimeTypes {
* @return Whether the top level type is audio.
*/
public static boolean isAudio(String mimeType) {
return getTopLevelType(mimeType).equals(BASE_TYPE_AUDIO);
return BASE_TYPE_AUDIO.equals(getTopLevelType(mimeType));
}
/**
......@@ -94,7 +94,7 @@ public final class MimeTypes {
* @return Whether the top level type is video.
*/
public static boolean isVideo(String mimeType) {
return getTopLevelType(mimeType).equals(BASE_TYPE_VIDEO);
return BASE_TYPE_VIDEO.equals(getTopLevelType(mimeType));
}
/**
......@@ -104,7 +104,7 @@ public final class MimeTypes {
* @return Whether the top level type is text.
*/
public static boolean isText(String mimeType) {
return getTopLevelType(mimeType).equals(BASE_TYPE_TEXT);
return BASE_TYPE_TEXT.equals(getTopLevelType(mimeType));
}
/**
......@@ -114,7 +114,7 @@ public final class MimeTypes {
* @return Whether the top level type is application.
*/
public static boolean isApplication(String mimeType) {
return getTopLevelType(mimeType).equals(BASE_TYPE_APPLICATION);
return BASE_TYPE_APPLICATION.equals(getTopLevelType(mimeType));
}
......@@ -237,9 +237,12 @@ public final class MimeTypes {
* Returns the top-level type of {@code mimeType}.
*
* @param mimeType The mimeType whose top-level type is required.
* @return The top-level type.
* @return The top-level type, or null if the mimeType is null.
*/
private static String getTopLevelType(String mimeType) {
if (mimeType == null) {
return null;
}
int indexOfSlash = mimeType.indexOf('/');
if (indexOfSlash == -1) {
throw new IllegalArgumentException("Invalid mime type: " + mimeType);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment