mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add HlsMasterPlaylist.copy method
Creates a copy of this playlist which includes only the variants identified by the given variantUrls. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163212562
This commit is contained in:
parent
1fdc11f2b3
commit
0a2f485079
1 changed files with 26 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source.hls.playlist;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -108,6 +109,20 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
|
||||||
? Collections.unmodifiableList(muxedCaptionFormats) : null;
|
? Collections.unmodifiableList(muxedCaptionFormats) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a copy of this playlist which includes only the renditions identified by the given
|
||||||
|
* urls.
|
||||||
|
*
|
||||||
|
* @param renditionUrls List of rendition urls.
|
||||||
|
* @return A copy of this playlist which includes only the renditions identified by the given
|
||||||
|
* urls.
|
||||||
|
*/
|
||||||
|
public HlsMasterPlaylist copy(List<String> renditionUrls) {
|
||||||
|
return new HlsMasterPlaylist(baseUri, tags, copyRenditionList(variants, renditionUrls),
|
||||||
|
copyRenditionList(audios, renditionUrls), copyRenditionList(subtitles, renditionUrls),
|
||||||
|
muxedAudioFormat, muxedCaptionFormats);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a playlist with a single variant.
|
* Creates a playlist with a single variant.
|
||||||
*
|
*
|
||||||
|
|
@ -121,4 +136,15 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
|
||||||
emptyList, null, null);
|
emptyList, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<HlsUrl> copyRenditionList(List<HlsUrl> variants, List<String> variantUrls) {
|
||||||
|
List<HlsUrl> copyVariants = new ArrayList<>();
|
||||||
|
for (int i = 0; i < variants.size(); i++) {
|
||||||
|
HlsUrl variant = variants.get(i);
|
||||||
|
if (variantUrls.contains(variant.url)) {
|
||||||
|
copyVariants.add(variant);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return copyVariants;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue