提交 67d01549 编写于 作者: O Oliver Woodman

Use Java7 <> syntax

上级 91bcec82
......@@ -38,7 +38,7 @@ public class SmoothStreamingTestMediaDrmCallback implements MediaDrmCallback {
"http://playready.directtaps.net/pr/svc/rightsmanager.asmx";
private static final Map<String, String> KEY_REQUEST_PROPERTIES;
static {
HashMap<String, String> keyRequestProperties = new HashMap<String, String>();
HashMap<String, String> keyRequestProperties = new HashMap<>();
keyRequestProperties.put("Content-Type", "text/xml");
keyRequestProperties.put("SOAPAction",
"http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense");
......
......@@ -131,7 +131,7 @@ public class DashRendererBuilder implements RendererBuilder,
this.callback = callback;
MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser();
manifestDataSource = new DefaultUriDataSource(context, userAgent);
manifestFetcher = new ManifestFetcher<MediaPresentationDescription>(url, manifestDataSource,
manifestFetcher = new ManifestFetcher<>(url, manifestDataSource,
parser);
manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
......@@ -247,13 +247,13 @@ public class DashRendererBuilder implements RendererBuilder,
}
// Build the audio chunk sources.
List<ChunkSource> audioChunkSourceList = new ArrayList<ChunkSource>();
List<String> audioTrackNameList = new ArrayList<String>();
List<ChunkSource> audioChunkSourceList = new ArrayList<>();
List<String> audioTrackNameList = new ArrayList<>();
if (audioAdaptationSet != null) {
DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
FormatEvaluator audioEvaluator = new FormatEvaluator.FixedEvaluator();
List<Representation> audioRepresentations = audioAdaptationSet.representations;
List<String> codecs = new ArrayList<String>();
List<String> codecs = new ArrayList<>();
for (int i = 0; i < audioRepresentations.size(); i++) {
Format format = audioRepresentations.get(i).format;
audioTrackNameList.add(format.id + " (" + format.numChannels + "ch, " +
......@@ -307,8 +307,8 @@ public class DashRendererBuilder implements RendererBuilder,
// Build the text chunk sources.
DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
FormatEvaluator textEvaluator = new FormatEvaluator.FixedEvaluator();
List<ChunkSource> textChunkSourceList = new ArrayList<ChunkSource>();
List<String> textTrackNameList = new ArrayList<String>();
List<ChunkSource> textChunkSourceList = new ArrayList<>();
List<String> textTrackNameList = new ArrayList<>();
for (int i = 0; i < period.adaptationSets.size(); i++) {
AdaptationSet adaptationSet = period.adaptationSets.get(i);
if (adaptationSet.type == AdaptationSet.TYPE_TEXT) {
......
......@@ -207,7 +207,7 @@ public class DemoPlayer implements ExoPlayer.Listener, ChunkSampleSource.EventLi
player.addListener(this);
playerControl = new PlayerControl(player);
mainHandler = new Handler();
listeners = new CopyOnWriteArrayList<Listener>();
listeners = new CopyOnWriteArrayList<>();
lastReportedPlaybackState = STATE_IDLE;
rendererBuildingState = RENDERER_BUILDING_STATE_IDLE;
selectedTracks = new int[RENDERER_COUNT];
......
......@@ -76,7 +76,7 @@ public class HlsRendererBuilder implements RendererBuilder, ManifestCallback<Hls
this.player = player;
this.callback = callback;
HlsPlaylistParser parser = new HlsPlaylistParser();
ManifestFetcher<HlsPlaylist> playlistFetcher = new ManifestFetcher<HlsPlaylist>(url,
ManifestFetcher<HlsPlaylist> playlistFetcher = new ManifestFetcher<>(url,
new DefaultUriDataSource(context, userAgent), parser);
playlistFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
......@@ -113,7 +113,7 @@ public class HlsRendererBuilder implements RendererBuilder, ManifestCallback<Hls
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
MetadataTrackRenderer<Map<String, Object>> id3Renderer =
new MetadataTrackRenderer<Map<String, Object>>(sampleSource, new Id3Parser(),
new MetadataTrackRenderer<>(sampleSource, new Id3Parser(),
player.getId3MetadataRenderer(), mainHandler.getLooper());
Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
......
......@@ -97,7 +97,7 @@ public class SmoothStreamingRendererBuilder implements RendererBuilder,
manifestUrl += "/Manifest";
}
SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser();
manifestFetcher = new ManifestFetcher<SmoothStreamingManifest>(manifestUrl,
manifestFetcher = new ManifestFetcher<>(manifestUrl,
new DefaultHttpDataSource(userAgent, null), parser);
manifestFetcher.singleLoad(player.getMainHandler().getLooper(), this);
}
......
......@@ -127,8 +127,8 @@ public class DefaultLoadControl implements LoadControl {
this.allocator = allocator;
this.eventHandler = eventHandler;
this.eventListener = eventListener;
this.loaders = new ArrayList<Object>();
this.loaderStates = new HashMap<Object, LoaderState>();
this.loaders = new ArrayList<>();
this.loaderStates = new HashMap<>();
this.lowWatermarkUs = lowWatermarkMs * 1000L;
this.highWatermarkUs = highWatermarkMs * 1000L;
this.lowBufferLoad = lowBufferLoad;
......
......@@ -55,7 +55,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
Log.i(TAG, "Init " + ExoPlayerLibraryInfo.VERSION);
this.playWhenReady = false;
this.playbackState = STATE_IDLE;
this.listeners = new CopyOnWriteArraySet<Listener>();
this.listeners = new CopyOnWriteArraySet<>();
this.rendererEnabledFlags = new boolean[rendererCount];
for (int i = 0; i < rendererEnabledFlags.length; i++) {
rendererEnabledFlags[i] = true;
......
......@@ -99,7 +99,7 @@ import java.util.List;
this.bufferedPositionUs = TrackRenderer.UNKNOWN_TIME_US;
mediaClock = new MediaClock();
enabledRenderers = new ArrayList<TrackRenderer>(rendererEnabledFlags.length);
enabledRenderers = new ArrayList<>(rendererEnabledFlags.length);
// Note: The documentation for Process.THREAD_PRIORITY_AUDIO that states "Applications can
// not normally change to this priority" is incorrect.
internalPlaybackThread = new PriorityHandlerThread(getClass().getSimpleName() + ":Handler",
......
......@@ -236,7 +236,7 @@ public abstract class MediaCodecTrackRenderer extends TrackRenderer {
codecCounters = new CodecCounters();
sampleHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_DISABLED);
formatHolder = new MediaFormatHolder();
decodeOnlyPresentationTimestamps = new ArrayList<Long>();
decodeOnlyPresentationTimestamps = new ArrayList<>();
outputBufferInfo = new MediaCodec.BufferInfo();
codecReconfigurationState = RECONFIGURATION_STATE_NONE;
codecReinitializationState = REINITIALIZATION_STATE_NONE;
......
......@@ -53,7 +53,7 @@ public class MediaCodecUtil {
private static final String TAG = "MediaCodecUtil";
private static final HashMap<CodecKey, Pair<String, CodecCapabilities>> codecs =
new HashMap<CodecKey, Pair<String, CodecCapabilities>>();
new HashMap<>();
/**
* Get information about the decoder that will be used for a given mime type.
......
......@@ -121,7 +121,7 @@ public class MediaFormat {
channelCount = getOptionalIntegerV16(format, android.media.MediaFormat.KEY_CHANNEL_COUNT);
sampleRate = getOptionalIntegerV16(format, android.media.MediaFormat.KEY_SAMPLE_RATE);
pixelWidthHeightRatio = getOptionalFloatV16(format, KEY_PIXEL_WIDTH_HEIGHT_RATIO);
initializationData = new ArrayList<byte[]>();
initializationData = new ArrayList<>();
for (int i = 0; format.containsKey("csd-" + i); i++) {
ByteBuffer buffer = format.getByteBuffer("csd-" + i);
byte[] data = new byte[buffer.limit()];
......
......@@ -113,7 +113,7 @@ public class ChunkSampleSource implements SampleSource, Loader.Callback {
this.eventSourceId = eventSourceId;
this.minLoadableRetryCount = minLoadableRetryCount;
currentLoadableHolder = new ChunkOperationHolder();
mediaChunks = new LinkedList<BaseMediaChunk>();
mediaChunks = new LinkedList<>();
readOnlyMediaChunks = Collections.unmodifiableList(mediaChunks);
sampleQueue = new DefaultTrackOutput(loadControl.getAllocator());
state = STATE_UNPREPARED;
......
......@@ -94,7 +94,7 @@ public final class VideoFormatSelectorUtil {
String[] allowedContainerMimeTypes, boolean filterHdFormats, boolean orientationMayChange,
int viewportWidth, int viewportHeight) throws DecoderQueryException {
int maxVideoPixelsToRetain = Integer.MAX_VALUE;
ArrayList<Integer> selectedIndexList = new ArrayList<Integer>();
ArrayList<Integer> selectedIndexList = new ArrayList<>();
int maxDecodableFrameSize = MediaCodecUtil.maxH264DecodableFrameSize();
// First pass to filter out formats that individually fail to meet the selection criteria.
......
......@@ -232,7 +232,7 @@ public class DashChunkSource implements ChunkSource {
this.trackInfo = new TrackInfo(representations[0].format.mimeType, periodDurationUs);
this.formats = new Format[representations.length];
this.representationHolders = new HashMap<String, RepresentationHolder>();
this.representationHolders = new HashMap<>();
int maxWidth = 0;
int maxHeight = 0;
for (int i = 0; i < representations.length; i++) {
......
......@@ -112,7 +112,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
: -1;
UtcTimingElement utcTiming = null;
List<Period> periods = new ArrayList<Period>();
List<Period> periods = new ArrayList<>();
do {
xpp.next();
if (isStartTag(xpp, "BaseURL")) {
......@@ -152,7 +152,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
long startMs = parseDuration(xpp, "start", 0);
long durationMs = parseDuration(xpp, "duration", mpdDurationMs);
SegmentBase segmentBase = null;
List<AdaptationSet> adaptationSets = new ArrayList<AdaptationSet>();
List<AdaptationSet> adaptationSets = new ArrayList<>();
do {
xpp.next();
if (isStartTag(xpp, "BaseURL")) {
......@@ -188,7 +188,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
int id = -1;
ContentProtectionsBuilder contentProtectionsBuilder = new ContentProtectionsBuilder();
List<Representation> representations = new ArrayList<Representation>();
List<Representation> representations = new ArrayList<>();
do {
xpp.next();
if (isStartTag(xpp, "BaseURL")) {
......@@ -432,7 +432,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
timeline = parseSegmentTimeline(xpp);
} else if (isStartTag(xpp, "SegmentURL")) {
if (segments == null) {
segments = new ArrayList<RangedUri>();
segments = new ArrayList<>();
}
segments.add(parseSegmentUrl(xpp, baseUrl));
}
......@@ -499,7 +499,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
protected List<SegmentTimelineElement> parseSegmentTimeline(XmlPullParser xpp)
throws XmlPullParserException, IOException {
List<SegmentTimelineElement> segmentTimeline = new ArrayList<SegmentTimelineElement>();
List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
long elapsedTime = 0;
do {
xpp.next();
......@@ -642,7 +642,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
*/
public void addAdaptationSetProtection(ContentProtection contentProtection) {
if (adaptationSetProtections == null) {
adaptationSetProtections = new ArrayList<ContentProtection>();
adaptationSetProtections = new ArrayList<>();
}
maybeAddContentProtection(adaptationSetProtections, contentProtection);
}
......@@ -654,7 +654,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
*/
public void addRepresentationProtection(ContentProtection contentProtection) {
if (currentRepresentationProtections == null) {
currentRepresentationProtections = new ArrayList<ContentProtection>();
currentRepresentationProtections = new ArrayList<>();
}
maybeAddContentProtection(currentRepresentationProtections, contentProtection);
}
......
......@@ -124,7 +124,7 @@ public class UtcTimingElementResolver implements Loader.Callback {
private void resolveHttp(UriLoadable.Parser<Long> parser) {
singleUseLoader = new Loader("utctiming");
singleUseLoadable = new UriLoadable<Long>(timingElement.value, uriDataSource, parser);
singleUseLoadable = new UriLoadable<>(timingElement.value, uriDataSource, parser);
singleUseLoader.startLoading(singleUseLoadable, this);
}
......
......@@ -52,7 +52,7 @@ public abstract class DrmInitData {
public Mapped(String mimeType) {
super(mimeType);
schemeData = new HashMap<UUID, byte[]>();
schemeData = new HashMap<>();
}
@Override
......
......@@ -139,7 +139,7 @@ public class StreamingDrmSessionManager implements DrmSessionManager {
EventListener eventListener) throws UnsupportedSchemeException {
HashMap<String, String> optionalKeyRequestParameters;
if (!TextUtils.isEmpty(customData)) {
optionalKeyRequestParameters = new HashMap<String, String>();
optionalKeyRequestParameters = new HashMap<>();
optionalKeyRequestParameters.put(PLAYREADY_CUSTOM_DATA_KEY, customData);
} else {
optionalKeyRequestParameters = null;
......
......@@ -130,7 +130,7 @@ public class ExtractorSampleSource implements SampleSource, ExtractorOutput, Loa
this.remainingReleaseCount = downstreamRendererCount;
this.requestedBufferSize = requestedBufferSize;
this.minLoadableRetryCount = minLoadableRetryCount;
sampleQueues = new SparseArray<InternalTrackOutput>();
sampleQueues = new SparseArray<>();
allocator = new DefaultAllocator(BUFFER_FRAGMENT_LENGTH);
pendingResetPositionUs = NO_RESET_PENDING;
frameAccurateSeeking = true;
......
......@@ -57,7 +57,7 @@ import java.util.concurrent.LinkedBlockingDeque;
this.allocator = allocator;
allocationLength = allocator.getIndividualAllocationLength();
infoQueue = new InfoQueue();
dataQueue = new LinkedBlockingDeque<Allocation>();
dataQueue = new LinkedBlockingDeque<>();
extrasHolder = new SampleExtrasHolder();
scratch = new ParsableByteArray(INITIAL_SCRATCH_SIZE);
lastAllocationOffset = allocationLength;
......
......@@ -122,8 +122,8 @@ import java.util.List;
public ContainerAtom(int type, long endByteOffset) {
super(type);
leafChildren = new ArrayList<LeafAtom>();
containerChildren = new ArrayList<ContainerAtom>();
leafChildren = new ArrayList<>();
containerChildren = new ArrayList<>();
this.endByteOffset = endByteOffset;
}
......
......@@ -396,7 +396,7 @@ import java.util.List;
if (nalUnitLengthFieldLength == 3) {
throw new IllegalStateException();
}
List<byte[]> initializationData = new ArrayList<byte[]>();
List<byte[]> initializationData = new ArrayList<>();
// TODO: We should try and parse these using CodecSpecificDataUtil.parseSpsNalUnit, and
// expose the AVC profile and level somewhere useful; Most likely in MediaFormat.
int numSequenceParameterSets = parent.readUnsignedByte() & 0x1F;
......@@ -472,7 +472,7 @@ import java.util.List;
int height = parent.readUnsignedShort();
parent.skipBytes(50);
List<byte[]> initializationData = new ArrayList<byte[]>(1);
List<byte[]> initializationData = new ArrayList<>(1);
int childPosition = parent.getPosition();
while (childPosition - position < size) {
parent.setPosition(childPosition);
......
......@@ -110,7 +110,7 @@ public final class FragmentedMp4Extractor implements Extractor {
nalLength = new ParsableByteArray(4);
encryptionSignalByte = new ParsableByteArray(1);
extendedTypeScratch = new byte[16];
containerAtoms = new Stack<ContainerAtom>();
containerAtoms = new Stack<>();
fragmentRun = new TrackFragment();
parserState = STATE_READING_ATOM_HEADER;
}
......
......@@ -71,7 +71,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
public Mp4Extractor() {
atomHeader = new ParsableByteArray(Atom.LONG_HEADER_SIZE);
containerAtoms = new Stack<Atom.ContainerAtom>();
containerAtoms = new Stack<>();
nalStartCode = new ParsableByteArray(H264Util.NAL_START_CODE);
nalLength = new ParsableByteArray(4);
parserState = STATE_READING_ATOM_HEADER;
......@@ -216,7 +216,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
/** Updates the stored track metadata to reflect the contents of the specified moov atom. */
private void processMoovAtom(ContainerAtom moov) {
List<Mp4Track> tracks = new ArrayList<Mp4Track>();
List<Mp4Track> tracks = new ArrayList<>();
long earliestSampleOffset = Long.MAX_VALUE;
for (int i = 0; i < moov.containerChildren.size(); i++) {
Atom.ContainerAtom atom = moov.containerChildren.get(i);
......
......@@ -224,7 +224,7 @@ import java.util.List;
byte[] ppsData = new byte[pps.nalLength];
System.arraycopy(sps.nalData, 0, spsData, 0, sps.nalLength);
System.arraycopy(pps.nalData, 0, ppsData, 0, pps.nalLength);
List<byte[]> initializationData = new ArrayList<byte[]>();
List<byte[]> initializationData = new ArrayList<>();
initializationData.add(spsData);
initializationData.add(ppsData);
......
......@@ -85,7 +85,7 @@ public final class TsExtractor implements Extractor, SeekMap {
tsPacketBuffer = new ParsableByteArray(TS_PACKET_SIZE);
streamTypes = new SparseBooleanArray();
allowedPassthroughStreamTypes = getPassthroughStreamTypes(audioCapabilities);
tsPayloadReaders = new SparseArray<TsPayloadReader>();
tsPayloadReaders = new SparseArray<>();
tsPayloadReaders.put(TS_PAT_PID, new PatReader());
lastPts = Long.MIN_VALUE;
}
......
......@@ -37,7 +37,7 @@ import java.util.Stack;
private static final int VALID_FLOAT64_ELEMENT_SIZE_BYTES = 8;
private final byte[] scratch = new byte[8];
private final Stack<MasterElement> masterElementsStack = new Stack<MasterElement>();
private final Stack<MasterElement> masterElementsStack = new Stack<>();
private final VarintReader varintReader = new VarintReader();
private EbmlReaderOutput output;
......
......@@ -665,7 +665,7 @@ public final class WebmExtractor implements Extractor {
durationUs, audioTrackFormat.channelCount, audioTrackFormat.sampleRate,
parseVorbisCodecPrivate());
} else if (audioTrackFormat != null && CODEC_ID_OPUS.equals(audioTrackFormat.codecId)) {
ArrayList<byte[]> opusInitializationData = new ArrayList<byte[]>(3);
ArrayList<byte[]> opusInitializationData = new ArrayList<>(3);
opusInitializationData.add(audioTrackFormat.codecPrivate);
opusInitializationData.add(
ByteBuffer.allocate(Long.SIZE).putLong(audioTrackFormat.codecDelayNs).array());
......@@ -757,7 +757,7 @@ public final class WebmExtractor implements Extractor {
}
byte[] vorbisBooks = new byte[codecPrivate.length - offset];
System.arraycopy(codecPrivate, offset, vorbisBooks, 0, codecPrivate.length - offset);
ArrayList<byte[]> initializationData = new ArrayList<byte[]>(2);
ArrayList<byte[]> initializationData = new ArrayList<>(2);
initializationData.add(vorbisInfo);
initializationData.add(vorbisBooks);
return initializationData;
......
......@@ -516,7 +516,7 @@ public class HlsChunkSource {
}
private static Format[] buildEnabledFormats(List<Variant> variants, int[] variantIndices) {
ArrayList<Variant> enabledVariants = new ArrayList<Variant>();
ArrayList<Variant> enabledVariants = new ArrayList<>();
if (variantIndices != null) {
for (int i = 0; i < variantIndices.length; i++) {
enabledVariants.add(variants.get(variantIndices[i]));
......@@ -526,8 +526,8 @@ public class HlsChunkSource {
enabledVariants.addAll(variants);
}
ArrayList<Variant> definiteVideoVariants = new ArrayList<Variant>();
ArrayList<Variant> definiteAudioOnlyVariants = new ArrayList<Variant>();
ArrayList<Variant> definiteVideoVariants = new ArrayList<>();
ArrayList<Variant> definiteAudioOnlyVariants = new ArrayList<>();
for (int i = 0; i < enabledVariants.size(); i++) {
Variant variant = enabledVariants.get(i);
if (variant.format.height > 0 || variantHasExplicitCodecWithPrefix(variant, "avc")) {
......
......@@ -60,7 +60,7 @@ public final class HlsExtractorWrapper implements ExtractorOutput {
this.startTimeUs = startTimeUs;
this.extractor = extractor;
this.shouldSpliceIn = shouldSpliceIn;
sampleQueues = new SparseArray<DefaultTrackOutput>();
sampleQueues = new SparseArray<>();
}
/**
......
......@@ -106,7 +106,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
public HlsPlaylist parse(String connectionUrl, InputStream inputStream)
throws IOException, ParserException {
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
Queue<String> extraLines = new LinkedList<String>();
Queue<String> extraLines = new LinkedList<>();
String line;
try {
while ((line = reader.readLine()) != null) {
......@@ -137,8 +137,8 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
private static HlsMasterPlaylist parseMasterPlaylist(LineIterator iterator, String baseUri)
throws IOException {
ArrayList<Variant> variants = new ArrayList<Variant>();
ArrayList<Subtitle> subtitles = new ArrayList<Subtitle>();
ArrayList<Variant> variants = new ArrayList<>();
ArrayList<Subtitle> subtitles = new ArrayList<>();
int bitrate = 0;
String codecs = null;
int width = -1;
......@@ -202,7 +202,7 @@ public final class HlsPlaylistParser implements UriLoadable.Parser<HlsPlaylist>
int targetDurationSecs = 0;
int version = 1; // Default version == 1.
boolean live = true;
List<Segment> segments = new ArrayList<Segment>();
List<Segment> segments = new ArrayList<>();
double segmentDurationSecs = 0.0;
boolean segmentDiscontinuity = false;
......
......@@ -120,7 +120,7 @@ public class HlsSampleSource implements SampleSource, Loader.Callback {
this.eventListener = eventListener;
this.eventSourceId = eventSourceId;
this.pendingResetPositionUs = NO_RESET_PENDING;
extractors = new LinkedList<HlsExtractorWrapper>();
extractors = new LinkedList<>();
allocator = new DefaultAllocator(BUFFER_FRAGMENT_LENGTH);
}
......
......@@ -42,7 +42,7 @@ public class Id3Parser implements MetadataParser<Map<String, Object>> {
@Override
public Map<String, Object> parse(byte[] data, int size)
throws UnsupportedEncodingException, ParserException {
Map<String, Object> metadata = new HashMap<String, Object>();
Map<String, Object> metadata = new HashMap<>();
ParsableByteArray id3Data = new ParsableByteArray(data, size);
int id3Size = parseId3Header(id3Data);
......
......@@ -153,8 +153,8 @@ public class SmoothStreamingChunkSource implements ChunkSource {
int trackCount = trackIndices != null ? trackIndices.length : streamElement.tracks.length;
formats = new Format[trackCount];
extractorWrappers = new SparseArray<ChunkExtractorWrapper>();
mediaFormats = new SparseArray<MediaFormat>();
extractorWrappers = new SparseArray<>();
mediaFormats = new SparseArray<>();
int maxWidth = 0;
int maxHeight = 0;
for (int i = 0; i < trackCount; i++) {
......
......@@ -96,7 +96,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
this.parent = parent;
this.baseUri = baseUri;
this.tag = tag;
this.normalizedAttributes = new LinkedList<Pair<String, Object>>();
this.normalizedAttributes = new LinkedList<>();
}
public final Object parse(XmlPullParser xmlParser) throws XmlPullParserException, IOException,
......@@ -343,7 +343,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
super(parent, baseUri, TAG);
lookAheadCount = -1;
protectionElement = null;
streamElements = new LinkedList<StreamElement>();
streamElements = new LinkedList<>();
}
@Override
......@@ -473,7 +473,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
public StreamElementParser(ElementParser parent, String baseUri) {
super(parent, baseUri, TAG);
this.baseUri = baseUri;
tracks = new LinkedList<TrackElement>();
tracks = new LinkedList<>();
}
@Override
......@@ -539,7 +539,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
if (timescale == -1) {
timescale = (Long) getNormalizedAttribute(KEY_TIME_SCALE);
}
startTimes = new ArrayList<Long>();
startTimes = new ArrayList<>();
}
private int parseType(XmlPullParser parser) throws ParserException {
......@@ -602,7 +602,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
public TrackElementParser(ElementParser parent, String baseUri) {
super(parent, baseUri, TAG);
this.csd = new LinkedList<byte[]>();
this.csd = new LinkedList<>();
}
@Override
......
......@@ -49,7 +49,7 @@ public final class SubtitleLayout extends ViewGroup {
public SubtitleLayout(Context context, AttributeSet attrs) {
super(context, attrs);
subtitleViews = new ArrayList<SubtitleView>();
subtitleViews = new ArrayList<>();
fontScale = 1;
captionStyle = CaptionStyleCompat.DEFAULT;
}
......
......@@ -109,7 +109,7 @@ public class Eia608Parser {
/* package */ Eia608Parser() {
seiBuffer = new ParsableBitArray();
stringBuilder = new StringBuilder();
captions = new ArrayList<ClosedCaption>();
captions = new ArrayList<>();
}
/* package */ boolean canParse(String mimeType) {
......
......@@ -88,7 +88,7 @@ public class Eia608TrackRenderer extends TrackRenderer implements Callback {
formatHolder = new MediaFormatHolder();
sampleHolder = new SampleHolder(SampleHolder.BUFFER_REPLACEMENT_MODE_NORMAL);
captionStringBuilder = new StringBuilder();
pendingCaptionLists = new TreeSet<ClosedCaptionList>();
pendingCaptionLists = new TreeSet<>();
}
@Override
......
......@@ -76,7 +76,7 @@ import java.util.TreeSet;
public void addChild(TtmlNode child) {
if (children == null) {
children = new ArrayList<TtmlNode>();
children = new ArrayList<>();
}
children.add(child);
}
......@@ -93,7 +93,7 @@ import java.util.TreeSet;
}
public long[] getEventTimesUs() {
TreeSet<Long> eventTimeSet = new TreeSet<Long>();
TreeSet<Long> eventTimeSet = new TreeSet<>();
getEventTimes(eventTimeSet, false);
long[] eventTimes = new long[eventTimeSet.size()];
Iterator<Long> eventTimeIterator = eventTimeSet.iterator();
......
......@@ -105,7 +105,7 @@ public class TtmlParser implements SubtitleParser {
XmlPullParser xmlParser = xmlParserFactory.newPullParser();
xmlParser.setInput(inputStream, inputEncoding);
TtmlSubtitle ttmlSubtitle = null;
LinkedList<TtmlNode> nodeStack = new LinkedList<TtmlNode>();
LinkedList<TtmlNode> nodeStack = new LinkedList<>();
int unsupportedNodeDepth = 0;
int eventType = xmlParser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT) {
......
......@@ -81,7 +81,7 @@ public class WebvttParser implements SubtitleParser {
@Override
public WebvttSubtitle parse(InputStream inputStream, String inputEncoding, long startTimeUs)
throws IOException {
ArrayList<WebvttCue> subtitles = new ArrayList<WebvttCue>();
ArrayList<WebvttCue> subtitles = new ArrayList<>();
long mediaTimestampUs = startTimeUs;
long mediaTimestampOffsetUs = 0;
......
......@@ -100,7 +100,7 @@ public class WebvttSubtitle implements Subtitle {
for (int i = 0; i < numCues; i++) {
if ((cueTimesUs[i * 2] <= timeUs) && (timeUs < cueTimesUs[i * 2 + 1])) {
if (list == null) {
list = new ArrayList<Cue>();
list = new ArrayList<>();
}
WebvttCue cue = cues.get(i);
if (cue.isNormalCue()) {
......
......@@ -61,7 +61,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
private static final String TAG = "HttpDataSource";
private static final Pattern CONTENT_RANGE_HEADER =
Pattern.compile("^bytes (\\d+)-(\\d+)/(\\d+)$");
private static final AtomicReference<byte[]> skipBufferReference = new AtomicReference<byte[]>();
private static final AtomicReference<byte[]> skipBufferReference = new AtomicReference<>();
private final boolean allowCrossProtocolRedirects;
private final int connectTimeoutMillis;
......@@ -141,7 +141,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
this.userAgent = Assertions.checkNotEmpty(userAgent);
this.contentTypePredicate = contentTypePredicate;
this.listener = listener;
this.requestProperties = new HashMap<String, String>();
this.requestProperties = new HashMap<>();
this.connectTimeoutMillis = connectTimeoutMillis;
this.readTimeoutMillis = readTimeoutMillis;
this.allowCrossProtocolRedirects = allowCrossProtocolRedirects;
......
......@@ -62,7 +62,7 @@ public final class NetworkLock {
private int highestPriority;
private NetworkLock() {
queue = new PriorityQueue<Integer>();
queue = new PriorityQueue<>();
highestPriority = Integer.MAX_VALUE;
}
......
......@@ -30,7 +30,7 @@ public class LeastRecentlyUsedCacheEvictor implements CacheEvictor, Comparator<C
public LeastRecentlyUsedCacheEvictor(long maxBytes) {
this.maxBytes = maxBytes;
this.leastRecentlyUsed = new TreeSet<CacheSpan>(this);
this.leastRecentlyUsed = new TreeSet<>(this);
}
@Override
......
......@@ -50,9 +50,9 @@ public class SimpleCache implements Cache {
public SimpleCache(File cacheDir, CacheEvictor evictor) {
this.cacheDir = cacheDir;
this.evictor = evictor;
this.lockedSpans = new HashMap<String, CacheSpan>();
this.cachedSpans = new HashMap<String, TreeSet<CacheSpan>>();
this.listeners = new HashMap<String, ArrayList<Listener>>();
this.lockedSpans = new HashMap<>();
this.cachedSpans = new HashMap<>();
this.listeners = new HashMap<>();
// Start cache initialization.
final ConditionVariable conditionVariable = new ConditionVariable();
new Thread() {
......@@ -71,7 +71,7 @@ public class SimpleCache implements Cache {
public synchronized NavigableSet<CacheSpan> addListener(String key, Listener listener) {
ArrayList<Listener> listenersForKey = listeners.get(key);
if (listenersForKey == null) {
listenersForKey = new ArrayList<Listener>();
listenersForKey = new ArrayList<>();
listeners.put(key, listenersForKey);
}
listenersForKey.add(listener);
......@@ -92,12 +92,12 @@ public class SimpleCache implements Cache {
@Override
public synchronized NavigableSet<CacheSpan> getCachedSpans(String key) {
TreeSet<CacheSpan> spansForKey = cachedSpans.get(key);
return spansForKey == null ? null : new TreeSet<CacheSpan>(spansForKey);
return spansForKey == null ? null : new TreeSet<>(spansForKey);
}
@Override
public synchronized Set<String> getKeys() {
return new HashSet<String>(cachedSpans.keySet());
return new HashSet<>(cachedSpans.keySet());
}
@Override
......@@ -263,7 +263,7 @@ public class SimpleCache implements Cache {
private void addSpan(CacheSpan span) {
TreeSet<CacheSpan> spansForKey = cachedSpans.get(span.key);
if (spansForKey == null) {
spansForKey = new TreeSet<CacheSpan>();
spansForKey = new TreeSet<>();
cachedSpans.put(span.key, spansForKey);
}
spansForKey.add(span);
......
......@@ -132,7 +132,7 @@ public final class CodecSpecificDataUtil {
// data does not consist of NAL start code delimited units.
return null;
}
List<Integer> starts = new ArrayList<Integer>();
List<Integer> starts = new ArrayList<>();
int nalUnitIndex = 0;
do {
starts.add(nalUnitIndex);
......
......@@ -146,7 +146,7 @@ public class ManifestFetcher<T> implements Loader.Callback {
*/
public void singleLoad(Looper callbackLooper, final ManifestCallback<T> callback) {
SingleFetchHelper fetchHelper = new SingleFetchHelper(
new UriLoadable<T>(manifestUrl, uriDataSource, parser), callbackLooper, callback);
new UriLoadable<>(manifestUrl, uriDataSource, parser), callbackLooper, callback);
fetchHelper.startLoading();
}
......@@ -219,7 +219,7 @@ public class ManifestFetcher<T> implements Loader.Callback {
loader = new Loader("manifestLoader");
}
if (!loader.isLoading()) {
currentLoadable = new UriLoadable<T>(manifestUrl, uriDataSource, parser);
currentLoadable = new UriLoadable<>(manifestUrl, uriDataSource, parser);
loader.startLoading(currentLoadable, this);
notifyManifestRefreshStarted();
}
......
......@@ -67,7 +67,7 @@ public class SlidingPercentile {
public SlidingPercentile(int maxWeight) {
this.maxWeight = maxWeight;
recycledSamples = new Sample[MAX_RECYCLED_SAMPLES];
samples = new ArrayList<Sample>();
samples = new ArrayList<>();
currentSortOrder = SORT_ORDER_NONE;
}
......
......@@ -37,7 +37,7 @@ public class MediaFormatTest extends TestCase {
byte[] initData1 = new byte[] {1, 2, 3};
byte[] initData2 = new byte[] {4, 5, 6};
List<byte[]> initData = new ArrayList<byte[]>();
List<byte[]> initData = new ArrayList<>();
initData.add(initData1);
initData.add(initData2);
......
......@@ -383,7 +383,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
}
private static MediaPresentationDescription generateVodMpd() {
List<Representation> representations = new ArrayList<Representation>();
List<Representation> representations = new ArrayList<>();
SingleSegmentBase segmentBase1 = new SingleSegmentBase("https://example.com/1.mp4");
Representation representation1 =
......@@ -399,10 +399,10 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
}
private static MediaPresentationDescription generateLiveMpdWithTimeline(long startTime) {
List<Representation> representations = new ArrayList<Representation>();
List<Representation> representations = new ArrayList<>();
List<SegmentTimelineElement> segmentTimeline = new ArrayList<SegmentTimelineElement>();
List<RangedUri> mediaSegments = new ArrayList<RangedUri>();
List<SegmentTimelineElement> segmentTimeline = new ArrayList<>();
List<RangedUri> mediaSegments = new ArrayList<>();
long byteStart = 0;
for (int i = 0; i < LIVE_SEGMENT_COUNT; i++) {
segmentTimeline.add(new SegmentTimelineElement(startTime, LIVE_SEGMENT_DURATION_MS));
......@@ -423,7 +423,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
private static MediaPresentationDescription generateLiveMpdWithTemplate(
boolean limitTimeshiftBuffer) {
List<Representation> representations = new ArrayList<Representation>();
List<Representation> representations = new ArrayList<>();
UrlTemplate initializationTemplate = null;
UrlTemplate mediaTemplate = UrlTemplate.compile("$RepresentationID$/$Number$");
......@@ -464,7 +464,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
long seekPositionMs, long seekRangeStartMs, long seekRangeEndMs, long chunkStartTimeMs,
long chunkEndTimeMs) {
DashChunkSource chunkSource = setupLiveEdgeTimelineTest(startTimeMs, liveEdgeLatencyMs);
List<MediaChunk> queue = new ArrayList<MediaChunk>();
List<MediaChunk> queue = new ArrayList<>();
ChunkOperationHolder out = new ChunkOperationHolder();
chunkSource.getChunkOperation(queue, seekPositionMs * 1000, 0, out);
TimeRange seekRange = chunkSource.getSeekRange();
......@@ -482,7 +482,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
long chunkEndTimeMs, boolean limitTimeshiftBuffer) {
DashChunkSource chunkSource = setupLiveEdgeTemplateTest(startTimeMs, liveEdgeLatencyMs,
limitTimeshiftBuffer);
List<MediaChunk> queue = new ArrayList<MediaChunk>();
List<MediaChunk> queue = new ArrayList<>();
ChunkOperationHolder out = new ChunkOperationHolder();
chunkSource.getChunkOperation(queue, seekPositionMs * 1000, 0, out);
TimeRange seekRange = chunkSource.getSeekRange();
......
......@@ -267,7 +267,7 @@ public class Mp4ExtractorTest extends TestCase {
private static byte[] getStsc() {
int samplesPerChunk = -1;
List<Integer> samplesInChunkChangeIndices = new ArrayList<Integer>();
List<Integer> samplesInChunkChangeIndices = new ArrayList<>();
for (int i = 0; i < SAMPLES_IN_CHUNK.length; i++) {
if (SAMPLES_IN_CHUNK[i] != samplesPerChunk) {
samplesInChunkChangeIndices.add(i);
......
......@@ -173,7 +173,7 @@ public class DefaultEbmlReaderTest extends TestCase {
private static final int ID_DURATION = 0x4489;
private static final int ID_SIMPLE_BLOCK = 0xA3;
private final List<String> events = new ArrayList<String>();
private final List<String> events = new ArrayList<>();
@Override
public int getElementType(int id) {
......
......@@ -169,7 +169,7 @@ public final class FakeDataSource implements DataSource {
private boolean simulateUnknownLength;
public Builder() {
segments = new ArrayList<Segment>();
segments = new ArrayList<>();
}
/**
......
......@@ -34,7 +34,7 @@ public class WebvttSubtitleTest extends TestCase {
private WebvttSubtitle emptySubtitle = new WebvttSubtitle(new ArrayList<WebvttCue>(), 0);
private ArrayList<WebvttCue> simpleSubtitleCues = new ArrayList<WebvttCue>();
private ArrayList<WebvttCue> simpleSubtitleCues = new ArrayList<>();
{
WebvttCue firstCue = new WebvttCue(1000000, 2000000, FIRST_SUBTITLE_STRING);
simpleSubtitleCues.add(firstCue);
......@@ -44,7 +44,7 @@ public class WebvttSubtitleTest extends TestCase {
}
private WebvttSubtitle simpleSubtitle = new WebvttSubtitle(simpleSubtitleCues, 0);
private ArrayList<WebvttCue> overlappingSubtitleCues = new ArrayList<WebvttCue>();
private ArrayList<WebvttCue> overlappingSubtitleCues = new ArrayList<>();
{
WebvttCue firstCue = new WebvttCue(1000000, 3000000, FIRST_SUBTITLE_STRING);
overlappingSubtitleCues.add(firstCue);
......@@ -54,7 +54,8 @@ public class WebvttSubtitleTest extends TestCase {
}
private WebvttSubtitle overlappingSubtitle = new WebvttSubtitle(overlappingSubtitleCues, 0);
private ArrayList<WebvttCue> nestedSubtitleCues = new ArrayList<WebvttCue>();
@SuppressWarnings("unused")
private ArrayList<WebvttCue> nestedSubtitleCues = new ArrayList<>();
{
WebvttCue firstCue = new WebvttCue(1000000, 4000000, FIRST_SUBTITLE_STRING);
nestedSubtitleCues.add(firstCue);
......
......@@ -53,7 +53,7 @@ public class UtilTest extends TestCase {
}
public void testListBinarySearchFloor() {
List<Integer> values = new ArrayList<Integer>();
List<Integer> values = new ArrayList<>();
assertEquals(-1, Util.binarySearchFloor(values, 0, false, false));
assertEquals(0, Util.binarySearchFloor(values, 0, false, true));
......@@ -107,7 +107,7 @@ public class UtilTest extends TestCase {
}
public void testListBinarySearchCeil() {
List<Integer> values = new ArrayList<Integer>();
List<Integer> values = new ArrayList<>();
assertEquals(0, Util.binarySearchCeil(values, 0, false, false));
assertEquals(-1, Util.binarySearchCeil(values, 0, false, true));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册