From 4c1a294b2e080b43068acaa5e2c4deed9a883dc3 Mon Sep 17 00:00:00 2001 From: bachinger Date: Wed, 5 May 2021 16:07:20 +0100 Subject: [PATCH] Format Java source files PiperOrigin-RevId: 372127633 --- .../exoplayer2/castdemo/MainActivity.java | 7 +- .../exoplayer2/ext/cast/CastTimeline.java | 5 +- .../exoplayer2/ext/cast/CastUtils.java | 9 +- .../ext/cast/DefaultCastOptionsProvider.java | 1 - .../cronet/ByteArrayUploadDataProvider.java | 5 +- .../ext/cronet/CronetDataSource.java | 19 +- .../ext/cronet/CronetDataSourceFactory.java | 13 +- .../ext/cronet/CronetEngineWrapper.java | 40 +-- .../ext/ffmpeg/FfmpegAudioRenderer.java | 5 +- .../exoplayer2/ext/ffmpeg/FfmpegLibrary.java | 4 +- .../exoplayer2/ext/flac/FlacDecoderJni.java | 9 +- .../exoplayer2/ext/flac/FlacLibrary.java | 5 +- .../ext/flac/LibflacAudioRenderer.java | 5 +- .../exoplayer2/ext/ima/ImaPlaybackTest.java | 4 +- .../ext/leanback/LeanbackPlayerAdapter.java | 20 +- .../media2/SessionPlayerConnectorTest.java | 5 +- .../android/exoplayer2/ext/media2/Utils.java | 1 - .../RepeatModeActionProvider.java | 9 +- .../ext/mediasession/TimelineQueueEditor.java | 8 +- .../mediasession/TimelineQueueNavigator.java | 12 +- .../ext/okhttp/OkHttpDataSource.java | 15 +- .../ext/okhttp/OkHttpDataSourceFactory.java | 6 +- .../exoplayer2/ext/opus/OpusPlaybackTest.java | 2 - .../ext/opus/OpusDecoderException.java | 1 - .../exoplayer2/ext/opus/OpusLibrary.java | 5 +- .../exoplayer2/ext/rtmp/RtmpDataSource.java | 1 - .../ext/rtmp/RtmpDataSourceFactory.java | 1 - .../exoplayer2/ext/vp9/VpxPlaybackTest.java | 1 - .../exoplayer2/ext/vp9/VpxDecoder.java | 7 +- .../exoplayer2/ext/vp9/VpxLibrary.java | 16 +- .../java/com/google/android/exoplayer2/C.java | 282 +++++---------- .../exoplayer2/ExoPlaybackException.java | 4 +- .../exoplayer2/ExoPlayerLibraryInfo.java | 9 +- .../com/google/android/exoplayer2/Format.java | 46 +-- .../IllegalSeekPositionException.java | 13 +- .../google/android/exoplayer2/MediaItem.java | 4 +- .../android/exoplayer2/ParserException.java | 9 +- .../google/android/exoplayer2/Timeline.java | 60 ++-- .../android/exoplayer2/audio/Ac3Util.java | 44 +-- .../exoplayer2/audio/AudioAttributes.java | 17 +- .../android/exoplayer2/audio/DtsUtil.java | 37 +- .../android/exoplayer2/decoder/Buffer.java | 24 +- .../exoplayer2/decoder/CryptoInfo.java | 25 +- .../decoder/DecoderInputBuffer.java | 24 +- .../android/exoplayer2/drm/DrmInitData.java | 67 ++-- .../android/exoplayer2/metadata/Metadata.java | 12 +- .../metadata/MetadataInputBuffer.java | 5 +- .../metadata/emsg/EventMessage.java | 36 +- .../metadata/emsg/EventMessageEncoder.java | 1 - .../exoplayer2/metadata/id3/ApicFrame.java | 26 +- .../exoplayer2/metadata/id3/BinaryFrame.java | 2 - .../exoplayer2/metadata/id3/ChapterFrame.java | 49 ++- .../metadata/id3/ChapterTocFrame.java | 37 +- .../exoplayer2/metadata/id3/CommentFrame.java | 5 +- .../exoplayer2/metadata/id3/GeobFrame.java | 29 +- .../exoplayer2/metadata/id3/Id3Decoder.java | 123 ++++--- .../exoplayer2/metadata/id3/Id3Frame.java | 5 +- .../exoplayer2/metadata/id3/PrivFrame.java | 23 +- .../exoplayer2/metadata/id3/UrlLinkFrame.java | 5 +- .../android/exoplayer2/source/TrackGroup.java | 4 +- .../google/android/exoplayer2/text/Cue.java | 20 +- .../exoplayer2/upstream/DataSource.java | 11 +- .../android/exoplayer2/upstream/DataSpec.java | 4 +- .../upstream/DefaultHttpDataSource.java | 30 +- .../exoplayer2/upstream/HttpDataSource.java | 43 +-- .../android/exoplayer2/util/Assertions.java | 1 - .../google/android/exoplayer2/util/Clock.java | 4 +- .../android/exoplayer2/util/ListenerSet.java | 6 +- .../android/exoplayer2/util/LongArray.java | 9 +- .../android/exoplayer2/util/NalUnitUtil.java | 111 +++--- .../exoplayer2/util/ParsableBitArray.java | 17 +- .../exoplayer2/util/ParsableByteArray.java | 115 ++----- .../util/ParsableNalUnitBitArray.java | 16 +- .../exoplayer2/util/RepeatModeUtil.java | 12 +- .../android/exoplayer2/util/TraceUtil.java | 1 - .../google/android/exoplayer2/util/Util.java | 97 +++--- .../android/exoplayer2/video/AvcConfig.java | 6 +- .../android/exoplayer2/video/ColorInfo.java | 17 +- .../android/exoplayer2/video/HevcConfig.java | 7 +- .../emsg/EventMessageDecoderTest.java | 2 +- .../metadata/emsg/EventMessageTest.java | 1 - .../metadata/id3/ChapterFrameTest.java | 10 +- .../metadata/id3/ChapterTocFrameTest.java | 14 +- .../metadata/id3/Id3DecoderTest.java | 103 +++++- .../metadata/id3/MlltFrameTest.java | 1 - .../exoplayer2/util/NalUnitUtilTest.java | 11 +- .../util/ParsableByteArrayTest.java | 116 +++---- .../upstream/ContentDataSourceTest.java | 7 +- .../upstream/TestContentProvider.java | 1 - .../android/exoplayer2/BaseRenderer.java | 16 +- .../android/exoplayer2/DefaultMediaClock.java | 12 +- .../exoplayer2/DefaultRenderersFactory.java | 31 +- .../android/exoplayer2/NoSampleRenderer.java | 38 +- .../android/exoplayer2/PlaybackInfo.java | 4 +- .../google/android/exoplayer2/Renderer.java | 58 ++-- .../exoplayer2/RendererCapabilities.java | 16 +- .../exoplayer2/audio/AudioCapabilities.java | 11 +- .../audio/AudioCapabilitiesReceiver.java | 10 +- .../exoplayer2/audio/AudioProcessor.java | 11 +- .../android/exoplayer2/audio/AudioSink.java | 29 +- .../audio/AudioTrackPositionTracker.java | 3 +- .../audio/ChannelMappingAudioProcessor.java | 1 - .../audio/DecoderAudioRenderer.java | 17 +- .../exoplayer2/audio/DefaultAudioSink.java | 11 +- .../audio/ResamplingAudioProcessor.java | 1 - .../android/exoplayer2/audio/Sonic.java | 5 +- .../exoplayer2/audio/SonicAudioProcessor.java | 1 - .../audio/TrimmingAudioProcessor.java | 1 - .../android/exoplayer2/decoder/Decoder.java | 5 +- .../exoplayer2/decoder/DecoderCounters.java | 40 +-- .../exoplayer2/decoder/OutputBuffer.java | 8 +- .../exoplayer2/decoder/SimpleDecoder.java | 22 +- .../decoder/SimpleOutputBuffer.java | 1 - .../android/exoplayer2/drm/ClearKeyUtil.java | 5 +- .../exoplayer2/drm/DecryptionException.java | 5 +- .../android/exoplayer2/drm/DrmSession.java | 14 +- .../exoplayer2/drm/FrameworkMediaDrm.java | 6 +- .../exoplayer2/drm/HttpMediaDrmCallback.java | 14 +- .../exoplayer2/drm/LocalMediaDrmCallback.java | 5 +- .../exoplayer2/drm/OfflineLicenseHelper.java | 13 +- .../drm/UnsupportedDrmException.java | 13 +- .../android/exoplayer2/drm/WidevineUtil.java | 4 +- .../exoplayer2/mediacodec/MediaCodecInfo.java | 44 ++- .../mediacodec/MediaCodecRenderer.java | 91 +++-- .../exoplayer2/mediacodec/MediaCodecUtil.java | 34 +- .../exoplayer2/metadata/MetadataRenderer.java | 1 - .../metadata/scte35/PrivateCommand.java | 36 +- .../metadata/scte35/SpliceCommand.java | 1 - .../metadata/scte35/SpliceInfoDecoder.java | 5 +- .../metadata/scte35/SpliceInsertCommand.java | 120 +++---- .../metadata/scte35/SpliceNullCommand.java | 20 +- .../scte35/SpliceScheduleCommand.java | 95 +++-- .../metadata/scte35/TimeSignalCommand.java | 32 +- .../exoplayer2/offline/DownloadException.java | 1 - .../offline/ProgressiveDownloader.java | 6 +- .../exoplayer2/offline/SegmentDownloader.java | 6 +- .../source/BehindLiveWindowException.java | 1 - .../source/ClippingMediaSource.java | 8 +- .../CompositeSequenceableLoaderFactory.java | 1 - .../source/ConcatenatingMediaSource.java | 5 +- ...ultCompositeSequenceableLoaderFactory.java | 1 - .../exoplayer2/source/ForwardingTimeline.java | 8 +- .../exoplayer2/source/LoopingMediaSource.java | 32 +- .../exoplayer2/source/MergingMediaSource.java | 17 +- .../source/ProgressiveMediaPeriod.java | 17 +- .../exoplayer2/source/SequenceableLoader.java | 17 +- .../exoplayer2/source/ShuffleOrder.java | 13 +- .../UnrecognizedInputFormatException.java | 5 +- .../source/ads/SinglePeriodAdTimeline.java | 1 - .../source/chunk/BaseMediaChunk.java | 16 +- .../source/chunk/BaseMediaChunkOutput.java | 5 +- .../source/chunk/BundledChunkExtractor.java | 5 +- .../exoplayer2/source/chunk/Chunk.java | 8 +- .../exoplayer2/source/chunk/ChunkHolder.java | 9 +- .../source/chunk/ChunkSampleStream.java | 15 +- .../exoplayer2/source/chunk/DataChunk.java | 11 +- .../source/chunk/InitializationChunk.java | 11 +- .../exoplayer2/source/chunk/MediaChunk.java | 16 +- .../source/chunk/SingleSampleMediaChunk.java | 1 - .../text/SimpleSubtitleDecoder.java | 1 - .../text/SimpleSubtitleOutputBuffer.java | 5 +- .../android/exoplayer2/text/Subtitle.java | 1 - .../exoplayer2/text/SubtitleDecoder.java | 5 +- .../text/SubtitleDecoderException.java | 4 +- .../exoplayer2/text/SubtitleInputBuffer.java | 5 +- .../exoplayer2/text/SubtitleOutputBuffer.java | 9 +- .../android/exoplayer2/text/TextRenderer.java | 4 +- .../exoplayer2/text/cea/Cea608Decoder.java | 207 +++++++---- .../exoplayer2/text/cea/Cea708Decoder.java | 294 ++++++++++------ .../exoplayer2/text/cea/CeaDecoder.java | 12 +- .../exoplayer2/text/cea/CeaSubtitle.java | 9 +- .../exoplayer2/text/dvb/DvbDecoder.java | 7 +- .../exoplayer2/text/dvb/DvbParser.java | 324 ++++++++++-------- .../exoplayer2/text/dvb/DvbSubtitle.java | 5 +- .../exoplayer2/text/ssa/SsaSubtitle.java | 4 +- .../text/subrip/SubripSubtitle.java | 5 +- .../exoplayer2/text/ttml/TtmlDecoder.java | 41 ++- .../exoplayer2/text/ttml/TtmlNode.java | 9 +- .../exoplayer2/text/ttml/TtmlRegion.java | 5 +- .../exoplayer2/text/ttml/TtmlRenderUtil.java | 9 +- .../exoplayer2/text/ttml/TtmlStyle.java | 13 +- .../exoplayer2/text/ttml/TtmlSubtitle.java | 4 +- .../exoplayer2/text/tx3g/Tx3gDecoder.java | 49 ++- .../exoplayer2/text/tx3g/Tx3gSubtitle.java | 5 +- .../exoplayer2/text/webvtt/CssParser.java | 22 +- .../text/webvtt/Mp4WebvttSubtitle.java | 4 +- .../text/webvtt/WebvttCssStyle.java | 17 +- .../text/webvtt/WebvttCueParser.java | 22 +- .../exoplayer2/text/webvtt/WebvttDecoder.java | 1 - .../text/webvtt/WebvttParserUtil.java | 1 - .../text/webvtt/WebvttSubtitle.java | 4 +- .../AdaptiveTrackSelection.java | 11 +- .../trackselection/FixedTrackSelection.java | 1 - .../trackselection/TrackSelector.java | 5 +- .../exoplayer2/upstream/Allocation.java | 5 +- .../exoplayer2/upstream/Allocator.java | 17 +- .../exoplayer2/upstream/AssetDataSource.java | 6 +- .../exoplayer2/upstream/BandwidthMeter.java | 4 +- .../upstream/ByteArrayDataSink.java | 1 - .../upstream/ByteArrayDataSource.java | 5 +- .../upstream/ContentDataSource.java | 10 +- .../android/exoplayer2/upstream/DataSink.java | 9 +- .../upstream/DataSourceInputStream.java | 9 +- .../exoplayer2/upstream/DefaultAllocator.java | 9 +- .../DefaultHttpDataSourceFactory.java | 8 +- .../exoplayer2/upstream/FileDataSource.java | 4 +- .../android/exoplayer2/upstream/Loader.java | 37 +- .../upstream/LoaderErrorThrower.java | 9 +- .../exoplayer2/upstream/ParsingLoadable.java | 9 +- .../upstream/PriorityDataSource.java | 5 +- .../upstream/PriorityDataSourceFactory.java | 9 +- .../upstream/RawResourceDataSource.java | 9 +- .../exoplayer2/upstream/TeeDataSource.java | 1 - .../exoplayer2/upstream/cache/Cache.java | 12 +- .../upstream/cache/CacheDataSink.java | 5 +- .../upstream/cache/CacheDataSource.java | 7 +- .../cache/CacheDataSourceFactory.java | 1 - .../upstream/cache/CacheEvictor.java | 4 +- .../exoplayer2/upstream/cache/CacheSpan.java | 8 +- .../upstream/cache/CachedRegionTracker.java | 30 +- .../cache/ContentMetadataMutations.java | 2 +- .../cache/DefaultContentMetadata.java | 1 - .../upstream/cache/NoOpCacheEvictor.java | 1 - .../upstream/cache/SimpleCacheSpan.java | 13 +- .../upstream/crypto/AesFlushingCipher.java | 5 +- .../upstream/crypto/CryptoUtil.java | 5 +- .../android/exoplayer2/util/AtomicFile.java | 4 +- .../android/exoplayer2/util/ColorParser.java | 17 +- .../exoplayer2/util/DebugTextViewHelper.java | 21 +- .../android/exoplayer2/util/EventLogger.java | 7 +- .../exoplayer2/util/LibraryLoader.java | 13 +- .../android/exoplayer2/util/MediaClock.java | 4 +- .../exoplayer2/util/PriorityTaskManager.java | 6 +- .../exoplayer2/util/SlidingPercentile.java | 18 +- .../exoplayer2/util/StandaloneMediaClock.java | 9 +- .../android/exoplayer2/util/UriUtil.java | 35 +- .../exoplayer2/video/DummySurface.java | 6 +- .../video/MediaCodecVideoRenderer.java | 28 +- .../video/VideoFrameReleaseHelper.java | 14 +- .../video/VideoRendererEventListener.java | 1 - .../exoplayer2/DefaultMediaClockTest.java | 28 +- .../analytics/AnalyticsCollectorTest.java | 6 +- .../audio/DecoderAudioRendererTest.java | 2 - .../SilenceSkippingAudioProcessorTest.java | 12 +- .../audio/SonicAudioProcessorTest.java | 1 - .../exoplayer2/drm/ClearKeyUtilTest.java | 1 - .../AsynchronousMediaCodecAdapterTest.java | 1 - .../mediacodec/BatchBufferTest.java | 1 - .../scte35/SpliceInfoDecoderTest.java | 180 ++++++---- .../CompositeSequenceableLoaderTest.java | 46 ++- .../exoplayer2/source/SampleQueueTest.java | 25 +- .../exoplayer2/source/ShuffleOrderTest.java | 1 - .../text/ttml/TtmlRenderUtilTest.java | 1 - .../exoplayer2/text/webvtt/CssParserTest.java | 3 +- .../text/webvtt/Mp4WebvttDecoderTest.java | 151 +++++--- .../text/webvtt/WebvttCueParserTest.java | 26 +- .../upstream/ByteArrayDataSourceTest.java | 17 +- .../upstream/DataSourceInputStreamTest.java | 9 +- .../upstream/cache/CacheDataSourceTest2.java | 22 +- .../upstream/cache/CacheWriterTest.java | 18 +- .../cache/CachedContentIndexTest.java | 191 +++++++++-- .../LeastRecentlyUsedCacheEvictorTest.java | 1 - .../upstream/cache/SimpleCacheSpanTest.java | 5 +- .../crypto/AesFlushingCipherTest.java | 1 - .../exoplayer2/util/AtomicFileTest.java | 1 - .../exoplayer2/util/ColorParserTest.java | 13 +- .../ReusableBufferedOutputStreamTest.java | 5 +- .../source/dash/DashMediaSource.java | 46 +-- .../source/dash/DashWrappingSegmentIndex.java | 1 - .../source/dash/DefaultDashChunkSource.java | 29 +- .../source/dash/EventSampleStream.java | 5 +- .../source/dash/manifest/AdaptationSet.java | 16 +- .../source/dash/manifest/DashManifest.java | 23 +- .../dash/manifest/DashManifestParser.java | 120 ++++--- .../source/dash/manifest/Descriptor.java | 11 +- .../source/dash/manifest/EventStream.java | 31 +- .../source/dash/manifest/Period.java | 18 +- .../source/dash/manifest/RangedUri.java | 16 +- .../source/dash/manifest/Representation.java | 58 +--- .../source/dash/manifest/SegmentBase.java | 25 +- .../dash/manifest/SingleSegmentIndex.java | 9 +- .../source/dash/manifest/UrlTemplate.java | 17 +- .../dash/manifest/UtcTimingElement.java | 1 - .../source/dash/EventSampleStreamTest.java | 166 +++++---- .../android/exoplayer2/extractor/CeaUtil.java | 1 - .../exoplayer2/extractor/ChunkIndex.java | 20 +- .../extractor/DefaultExtractorInput.java | 8 +- .../exoplayer2/extractor/Extractor.java | 13 +- .../exoplayer2/extractor/ExtractorInput.java | 5 +- .../exoplayer2/extractor/ExtractorOutput.java | 1 - .../extractor/GaplessInfoHolder.java | 17 +- .../exoplayer2/extractor/PositionHolder.java | 5 +- .../exoplayer2/extractor/TrackOutput.java | 26 +- .../exoplayer2/extractor/VorbisBitArray.java | 17 +- .../exoplayer2/extractor/VorbisUtil.java | 20 +- .../extractor/flv/AudioTagPayloadReader.java | 4 +- .../extractor/flv/FlvExtractor.java | 8 +- .../extractor/flv/ScriptTagPayloadReader.java | 4 +- .../extractor/flv/TagPayloadReader.java | 21 +- .../extractor/flv/VideoTagPayloadReader.java | 9 +- .../extractor/mkv/DefaultEbmlReader.java | 7 +- .../extractor/mkv/EbmlProcessor.java | 12 +- .../exoplayer2/extractor/mkv/EbmlReader.java | 4 +- .../extractor/mkv/MatroskaExtractor.java | 134 ++++---- .../exoplayer2/extractor/mkv/Sniffer.java | 13 +- .../extractor/mkv/VarintReader.java | 26 +- .../extractor/mp3/Mp3Extractor.java | 31 +- .../exoplayer2/extractor/mp3/VbriSeeker.java | 5 +- .../exoplayer2/extractor/mp3/XingSeeker.java | 15 +- .../exoplayer2/extractor/mp4/Atom.java | 52 +-- .../exoplayer2/extractor/mp4/AtomParsers.java | 164 +++++---- .../extractor/mp4/DefaultSampleValues.java | 1 - .../mp4/FixedSampleSizeRechunker.java | 14 +- .../extractor/mp4/FragmentedMp4Extractor.java | 114 +++--- .../extractor/mp4/MetadataUtil.java | 1 - .../extractor/mp4/Mp4Extractor.java | 22 +- .../extractor/mp4/PsshAtomUtil.java | 6 +- .../exoplayer2/extractor/mp4/Sniffer.java | 8 +- .../exoplayer2/extractor/mp4/Track.java | 55 ++- .../extractor/mp4/TrackEncryptionBox.java | 21 +- .../extractor/mp4/TrackFragment.java | 60 +--- .../extractor/mp4/TrackSampleTable.java | 5 +- .../exoplayer2/extractor/ogg/FlacReader.java | 10 +- .../extractor/ogg/OggExtractor.java | 1 - .../exoplayer2/extractor/ogg/OggPacket.java | 25 +- .../extractor/ogg/OggPageHeader.java | 18 +- .../exoplayer2/extractor/ogg/OpusReader.java | 4 +- .../extractor/ogg/StreamReader.java | 6 +- .../extractor/ogg/VorbisReader.java | 22 +- .../exoplayer2/extractor/ts/Ac3Extractor.java | 2 +- .../exoplayer2/extractor/ts/Ac3Reader.java | 5 +- .../exoplayer2/extractor/ts/AdtsReader.java | 24 +- .../ts/DefaultTsPayloadReaderFactory.java | 29 +- .../exoplayer2/extractor/ts/DtsReader.java | 6 +- .../extractor/ts/DvbSubtitleReader.java | 5 +- .../extractor/ts/ElementaryStreamReader.java | 9 +- .../exoplayer2/extractor/ts/H262Reader.java | 24 +- .../exoplayer2/extractor/ts/H264Reader.java | 39 ++- .../exoplayer2/extractor/ts/H265Reader.java | 15 +- .../exoplayer2/extractor/ts/Id3Reader.java | 4 +- .../exoplayer2/extractor/ts/LatmReader.java | 5 +- .../extractor/ts/MpegAudioReader.java | 10 +- .../extractor/ts/NalUnitTargetBuffer.java | 17 +- .../exoplayer2/extractor/ts/PesReader.java | 12 +- .../exoplayer2/extractor/ts/PsExtractor.java | 27 +- .../extractor/ts/SectionPayloadReader.java | 5 +- .../extractor/ts/SectionReader.java | 5 +- .../exoplayer2/extractor/ts/SeiReader.java | 9 +- .../extractor/ts/TsDurationReader.java | 1 - .../exoplayer2/extractor/ts/TsExtractor.java | 43 ++- .../extractor/ts/TsPayloadReader.java | 26 +- .../extractor/DefaultExtractorInputTest.java | 12 +- .../exoplayer2/extractor/ExtractorTest.java | 1 - .../extractor/VorbisBitArrayTest.java | 1 - .../exoplayer2/extractor/VorbisUtilTest.java | 21 +- .../amr/AmrExtractorParameterizedTest.java | 1 - .../extractor/mkv/DefaultEbmlReaderTest.java | 10 +- .../extractor/mkv/VarintReaderTest.java | 33 +- .../extractor/mp3/XingSeekerTest.java | 45 ++- .../extractor/mp4/AtomParsersTest.java | 29 +- .../extractor/mp4/PsshAtomUtilTest.java | 3 +- .../extractor/ogg/OggPageHeaderTest.java | 1 - .../extractor/ogg/VorbisReaderTest.java | 10 +- .../extractor/ts/SectionReaderTest.java | 20 +- .../hls/DefaultHlsDataSourceFactory.java | 5 +- .../exoplayer2/source/hls/HlsChunkSource.java | 32 +- .../source/hls/HlsDataSourceFactory.java | 1 - .../exoplayer2/source/hls/HlsManifest.java | 9 +- .../exoplayer2/source/hls/HlsMediaChunk.java | 12 +- .../exoplayer2/source/hls/HlsMediaPeriod.java | 18 +- .../exoplayer2/source/hls/HlsMediaSource.java | 4 +- .../source/hls/HlsSampleStream.java | 4 +- .../source/hls/HlsSampleStreamWrapper.java | 22 +- .../source/hls/TimestampAdjusterProvider.java | 9 +- .../source/hls/WebvttExtractor.java | 7 +- .../hls/playlist/HlsMasterPlaylist.java | 6 +- .../source/hls/playlist/HlsMediaPlaylist.java | 42 +-- .../source/hls/playlist/HlsPlaylist.java | 9 +- .../hls/playlist/HlsPlaylistParser.java | 37 +- .../hls/playlist/HlsPlaylistTracker.java | 4 +- .../source/rtsp/RtspMediaPeriodTest.java | 1 + .../smoothstreaming/DefaultSsChunkSource.java | 27 +- .../source/smoothstreaming/SsMediaSource.java | 14 +- .../smoothstreaming/manifest/SsManifest.java | 37 +- .../manifest/SsManifestParser.java | 81 +++-- .../smoothstreaming/offline/SsDownloader.java | 1 - .../exoplayer2/transformer/MuxerWrapper.java | 1 - .../transformer/TransformerBaseRenderer.java | 1 - ...fSlowMotionVideoSampleTransformerTest.java | 12 +- .../exoplayer2/ui/AspectRatioFrameLayout.java | 21 +- .../exoplayer2/ui/CaptionStyleCompat.java | 60 ++-- .../android/exoplayer2/ui/DefaultTimeBar.java | 66 ++-- .../exoplayer2/ui/SubtitlePainter.java | 41 +-- .../android/exoplayer2/ui/SubtitleView.java | 27 +- .../google/android/exoplayer2/ui/TimeBar.java | 21 +- .../gts/CommonEncryptionDrmTest.java | 16 +- .../playbacktests/gts/DashDownloadTest.java | 1 - .../playbacktests/gts/DashStreamingTest.java | 209 ++++++----- .../playbacktests/gts/DashTestData.java | 79 +++-- .../playbacktests/gts/DashTestRunner.java | 113 +++--- .../gts/DashWidevineOfflineTest.java | 16 +- .../gts/DebugRenderersFactory.java | 14 +- .../gts/EnumerateDecodersTest.java | 1 - .../gts/LogcatMetricsLogger.java | 1 - .../playbacktests/gts/MetricsLogger.java | 4 +- .../exoplayer2/testutil/ActionSchedule.java | 27 +- .../testutil/DecoderCountersUtil.java | 15 +- .../android/exoplayer2/testutil/Dumper.java | 6 +- .../exoplayer2/testutil/ExoHostedTest.java | 34 +- .../testutil/ExoPlayerTestRunner.java | 4 +- .../exoplayer2/testutil/ExtractorAsserts.java | 16 +- .../testutil/FakeAdaptiveDataSet.java | 23 +- .../exoplayer2/testutil/FakeChunkSource.java | 19 +- .../exoplayer2/testutil/FakeClock.java | 3 - .../exoplayer2/testutil/FakeDataSet.java | 23 +- .../exoplayer2/testutil/FakeDataSource.java | 10 +- .../testutil/FakeExtractorInput.java | 34 +- .../testutil/FakeExtractorOutput.java | 5 +- .../exoplayer2/testutil/FakeMediaSource.java | 8 +- .../exoplayer2/testutil/FakeTimeline.java | 9 +- .../exoplayer2/testutil/FakeTrackOutput.java | 1 - .../exoplayer2/testutil/HostActivity.java | 21 +- .../android/exoplayer2/testutil/TestUtil.java | 1 - .../testutil/WebServerDispatcher.java | 6 +- 424 files changed, 4403 insertions(+), 4626 deletions(-) diff --git a/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java b/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java index 12190abc27..86e93bcd9c 100644 --- a/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java +++ b/demos/cast/src/main/java/com/google/android/exoplayer2/castdemo/MainActivity.java @@ -201,8 +201,10 @@ public class MainActivity extends AppCompatActivity @Override @NonNull public QueueItemViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { - TextView v = (TextView) LayoutInflater.from(parent.getContext()) - .inflate(android.R.layout.simple_list_item_1, parent, false); + TextView v = + (TextView) + LayoutInflater.from(parent.getContext()) + .inflate(android.R.layout.simple_list_item_1, parent, false); return new QueueItemViewHolder(v); } @@ -223,7 +225,6 @@ public class MainActivity extends AppCompatActivity public int getItemCount() { return playerManager.getMediaQueueSize(); } - } private class RecyclerViewCallback extends ItemTouchHelper.SimpleCallback { diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastTimeline.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastTimeline.java index 1a03b779f6..8db6ef59fd 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastTimeline.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastTimeline.java @@ -24,9 +24,7 @@ import com.google.android.exoplayer2.MediaItem; import com.google.android.exoplayer2.Timeline; import java.util.Arrays; -/** - * A {@link Timeline} for Cast media queues. - */ +/** A {@link Timeline} for Cast media queues. */ /* package */ final class CastTimeline extends Timeline { /** Holds {@link Timeline} related data for a Cast media item. */ @@ -190,5 +188,4 @@ import java.util.Arrays; result = 31 * result + Arrays.hashCode(isLive); return result; } - } diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java index 4f3f52a5f9..8ff4e37d43 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java @@ -22,9 +22,7 @@ import com.google.android.gms.cast.CastStatusCodes; import com.google.android.gms.cast.MediaInfo; import com.google.android.gms.cast.MediaTrack; -/** - * Utility methods for ExoPlayer/Cast integration. - */ +/** Utility methods for ExoPlayer/Cast integration. */ /* package */ final class CastUtils { /** The duration returned by {@link MediaInfo#getStreamDuration()} for live streams. */ @@ -103,8 +101,8 @@ import com.google.android.gms.cast.MediaTrack; } /** - * Creates a {@link Format} instance containing all information contained in the given - * {@link MediaTrack} object. + * Creates a {@link Format} instance containing all information contained in the given {@link + * MediaTrack} object. * * @param mediaTrack The {@link MediaTrack}. * @return The equivalent {@link Format}. @@ -118,5 +116,4 @@ import com.google.android.gms.cast.MediaTrack; } private CastUtils() {} - } diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/DefaultCastOptionsProvider.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/DefaultCastOptionsProvider.java index 69702ea286..0a1838ab8e 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/DefaultCastOptionsProvider.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/DefaultCastOptionsProvider.java @@ -46,5 +46,4 @@ public final class DefaultCastOptionsProvider implements OptionsProvider { public List getAdditionalSessionProviders(Context context) { return Collections.emptyList(); } - } diff --git a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProvider.java b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProvider.java index e70538d7be..5c5528ed82 100644 --- a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProvider.java +++ b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/ByteArrayUploadDataProvider.java @@ -22,9 +22,7 @@ import java.nio.ByteBuffer; import org.chromium.net.UploadDataProvider; import org.chromium.net.UploadDataSink; -/** - * A {@link UploadDataProvider} implementation that provides data from a {@code byte[]}. - */ +/** A {@link UploadDataProvider} implementation that provides data from a {@code byte[]}. */ /* package */ final class ByteArrayUploadDataProvider extends UploadDataProvider { private final byte[] data; @@ -53,5 +51,4 @@ import org.chromium.net.UploadDataSink; position = 0; uploadDataSink.onRewindSucceeded(); } - } diff --git a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java index 9b73387fc1..71aac320c8 100644 --- a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java +++ b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSource.java @@ -265,9 +265,7 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { } } - /** - * Thrown when an error is encountered when trying to open a {@link CronetDataSource}. - */ + /** Thrown when an error is encountered when trying to open a {@link CronetDataSource}. */ public static final class OpenException extends HttpDataSourceException { /** @@ -985,13 +983,14 @@ public class CronetDataSource extends BaseDataSource implements HttpDataSource { private static int getStatus(UrlRequest request) throws InterruptedException { final ConditionVariable conditionVariable = new ConditionVariable(); final int[] statusHolder = new int[1]; - request.getStatus(new UrlRequest.StatusListener() { - @Override - public void onStatus(int status) { - statusHolder[0] = status; - conditionVariable.open(); - } - }); + request.getStatus( + new UrlRequest.StatusListener() { + @Override + public void onStatus(int status) { + statusHolder[0] = status; + conditionVariable.open(); + } + }); conditionVariable.block(); return statusHolder[0]; } diff --git a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceFactory.java b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceFactory.java index a446fcc299..f10d556f4c 100644 --- a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceFactory.java +++ b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetDataSourceFactory.java @@ -27,15 +27,11 @@ import org.chromium.net.CronetEngine; @Deprecated public final class CronetDataSourceFactory extends BaseFactory { - /** - * The default connection timeout, in milliseconds. - */ + /** The default connection timeout, in milliseconds. */ public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = CronetDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS; - /** - * The default read timeout, in milliseconds. - */ + /** The default read timeout, in milliseconds. */ public static final int DEFAULT_READ_TIMEOUT_MILLIS = CronetDataSource.DEFAULT_READ_TIMEOUT_MILLIS; @@ -338,8 +334,8 @@ public final class CronetDataSourceFactory extends BaseFactory { } @Override - protected HttpDataSource createDataSourceInternal(HttpDataSource.RequestProperties - defaultRequestProperties) { + protected HttpDataSource createDataSourceInternal( + HttpDataSource.RequestProperties defaultRequestProperties) { @Nullable CronetEngine cronetEngine = cronetEngineWrapper.getCronetEngine(); if (cronetEngine == null) { return fallbackFactory.createDataSource(); @@ -357,5 +353,4 @@ public final class CronetDataSourceFactory extends BaseFactory { } return dataSource; } - } diff --git a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetEngineWrapper.java b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetEngineWrapper.java index de292006ec..9b38c28e88 100644 --- a/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetEngineWrapper.java +++ b/extensions/cronet/src/main/java/com/google/android/exoplayer2/ext/cronet/CronetEngineWrapper.java @@ -49,25 +49,15 @@ public final class CronetEngineWrapper { @Retention(RetentionPolicy.SOURCE) @IntDef({SOURCE_NATIVE, SOURCE_GMS, SOURCE_UNKNOWN, SOURCE_USER_PROVIDED, SOURCE_UNAVAILABLE}) public @interface CronetEngineSource {} - /** - * Natively bundled Cronet implementation. - */ + /** Natively bundled Cronet implementation. */ public static final int SOURCE_NATIVE = 0; - /** - * Cronet implementation from GMSCore. - */ + /** Cronet implementation from GMSCore. */ public static final int SOURCE_GMS = 1; - /** - * Other (unknown) Cronet implementation. - */ + /** Other (unknown) Cronet implementation. */ public static final int SOURCE_UNKNOWN = 2; - /** - * User-provided Cronet engine. - */ + /** User-provided Cronet engine. */ public static final int SOURCE_USER_PROVIDED = 3; - /** - * No Cronet implementation available. Fallback Http provider is used if possible. - */ + /** No Cronet implementation available. Fallback Http provider is used if possible. */ public static final int SOURCE_UNAVAILABLE = 4; /** @@ -124,11 +114,15 @@ public final class CronetEngineWrapper { } Log.d(TAG, "CronetEngine built using " + providerName); } catch (SecurityException e) { - Log.w(TAG, "Failed to build CronetEngine. Please check if current process has " - + "android.permission.ACCESS_NETWORK_STATE."); + Log.w( + TAG, + "Failed to build CronetEngine. Please check if current process has " + + "android.permission.ACCESS_NETWORK_STATE."); } catch (UnsatisfiedLinkError e) { - Log.w(TAG, "Failed to link Cronet binaries. Please check if native Cronet binaries are " - + "bundled into your app."); + Log.w( + TAG, + "Failed to link Cronet binaries. Please check if native Cronet binaries are " + + "bundled into your app."); } } if (cronetEngine == null) { @@ -215,8 +209,7 @@ public final class CronetEngineWrapper { } /** - * Convert Cronet provider name into a sortable preference value. - * Smaller values are preferred. + * Convert Cronet provider name into a sortable preference value. Smaller values are preferred. */ private int evaluateCronetProviderType(String providerName) { if (isNativeProvider(providerName)) { @@ -229,9 +222,7 @@ public final class CronetEngineWrapper { return -1; } - /** - * Compares version strings of format "12.123.35.23". - */ + /** Compares version strings of format "12.123.35.23". */ private static int compareVersionStrings(String versionLeft, String versionRight) { if (versionLeft == null || versionRight == null) { return 0; @@ -253,5 +244,4 @@ public final class CronetEngineWrapper { return 0; } } - } diff --git a/extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java b/extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java index 878476d1a1..3991f53a38 100644 --- a/extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java +++ b/extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java @@ -79,10 +79,7 @@ public final class FfmpegAudioRenderer extends DecoderAudioRenderer errorMessage = errorMessageProvider.getErrorMessage(exception); callback.onError(LeanbackPlayerAdapter.this, errorMessage.first, errorMessage.second); } else { - callback.onError(LeanbackPlayerAdapter.this, exception.type, context.getString( - R.string.lb_media_player_error, exception.type, exception.rendererIndex)); + callback.onError( + LeanbackPlayerAdapter.this, + exception.type, + context.getString( + R.string.lb_media_player_error, exception.type, exception.rendererIndex)); } } @@ -298,7 +302,5 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab public void onRenderedFirstFrame() { // Do nothing. } - } - } diff --git a/extensions/media2/src/androidTest/java/com/google/android/exoplayer2/ext/media2/SessionPlayerConnectorTest.java b/extensions/media2/src/androidTest/java/com/google/android/exoplayer2/ext/media2/SessionPlayerConnectorTest.java index d4e996caa2..3bbbec150f 100644 --- a/extensions/media2/src/androidTest/java/com/google/android/exoplayer2/ext/media2/SessionPlayerConnectorTest.java +++ b/extensions/media2/src/androidTest/java/com/google/android/exoplayer2/ext/media2/SessionPlayerConnectorTest.java @@ -168,10 +168,7 @@ public class SessionPlayerConnectorTest { SimpleExoPlayer simpleExoPlayer = null; SessionPlayerConnector playerConnector = null; try { - simpleExoPlayer = - new SimpleExoPlayer.Builder(context) - .setLooper(Looper.myLooper()) - .build(); + simpleExoPlayer = new SimpleExoPlayer.Builder(context).setLooper(Looper.myLooper()).build(); playerConnector = new SessionPlayerConnector(simpleExoPlayer, new DefaultMediaItemConverter()); playerConnector.setControlDispatcher(controlDispatcher); diff --git a/extensions/media2/src/main/java/com/google/android/exoplayer2/ext/media2/Utils.java b/extensions/media2/src/main/java/com/google/android/exoplayer2/ext/media2/Utils.java index 873e35cc25..87b52f3598 100644 --- a/extensions/media2/src/main/java/com/google/android/exoplayer2/ext/media2/Utils.java +++ b/extensions/media2/src/main/java/com/google/android/exoplayer2/ext/media2/Utils.java @@ -89,7 +89,6 @@ import com.google.android.exoplayer2.audio.AudioAttributes; } } - private Utils() { // Prevent instantiation. } diff --git a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java index 87b9447f7c..157d5e9cee 100644 --- a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java +++ b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/RepeatModeActionProvider.java @@ -33,8 +33,7 @@ public final class RepeatModeActionProvider implements MediaSessionConnector.Cus private static final String ACTION_REPEAT_MODE = "ACTION_EXO_REPEAT_MODE"; - @RepeatModeUtil.RepeatToggleModes - private final int repeatToggleModes; + @RepeatModeUtil.RepeatToggleModes private final int repeatToggleModes; private final CharSequence repeatAllDescription; private final CharSequence repeatOneDescription; private final CharSequence repeatOffDescription; @@ -93,9 +92,9 @@ public final class RepeatModeActionProvider implements MediaSessionConnector.Cus iconResourceId = R.drawable.exo_media_action_repeat_off; break; } - PlaybackStateCompat.CustomAction.Builder repeatBuilder = new PlaybackStateCompat.CustomAction - .Builder(ACTION_REPEAT_MODE, actionLabel, iconResourceId); + PlaybackStateCompat.CustomAction.Builder repeatBuilder = + new PlaybackStateCompat.CustomAction.Builder( + ACTION_REPEAT_MODE, actionLabel, iconResourceId); return repeatBuilder.build(); } - } diff --git a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueEditor.java b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueEditor.java index cab16744b9..37d303c7c9 100644 --- a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueEditor.java +++ b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueEditor.java @@ -57,8 +57,8 @@ public final class TimelineQueueEditor /** * Adapter to get {@link MediaDescriptionCompat} of items in the queue and to notify the - * application about changes in the queue to sync the data structure backing the - * {@link MediaSessionConnector}. + * application about changes in the queue to sync the data structure backing the {@link + * MediaSessionConnector}. */ public interface QueueDataAdapter { /** @@ -83,9 +83,7 @@ public final class TimelineQueueEditor void move(int from, int to); } - /** - * Used to evaluate whether two {@link MediaDescriptionCompat} are considered equal. - */ + /** Used to evaluate whether two {@link MediaDescriptionCompat} are considered equal. */ interface MediaDescriptionEqualityChecker { /** * Returns {@code true} whether the descriptions are considered equal. diff --git a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueNavigator.java b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueNavigator.java index 4a27ca9d93..25f3ee30a5 100644 --- a/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueNavigator.java +++ b/extensions/mediasession/src/main/java/com/google/android/exoplayer2/ext/mediasession/TimelineQueueNavigator.java @@ -51,8 +51,8 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu /** * Creates an instance for a given {@link MediaSessionCompat}. - *

- * Equivalent to {@code TimelineQueueNavigator(mediaSession, DEFAULT_MAX_QUEUE_SIZE)}. + * + *

Equivalent to {@code TimelineQueueNavigator(mediaSession, DEFAULT_MAX_QUEUE_SIZE)}. * * @param mediaSession The {@link MediaSessionCompat}. */ @@ -62,10 +62,10 @@ public abstract class TimelineQueueNavigator implements MediaSessionConnector.Qu /** * Creates an instance for a given {@link MediaSessionCompat} and maximum queue size. - *

- * If the number of windows in the {@link Player}'s {@link Timeline} exceeds {@code maxQueueSize}, - * the media session queue will correspond to {@code maxQueueSize} windows centered on the one - * currently being played. + * + *

If the number of windows in the {@link Player}'s {@link Timeline} exceeds {@code + * maxQueueSize}, the media session queue will correspond to {@code maxQueueSize} windows centered + * on the one currently being played. * * @param mediaSession The {@link MediaSessionCompat}. * @param maxQueueSize The maximum queue size. diff --git a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java index 0b881955a1..3e3c75ffee 100644 --- a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java +++ b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSource.java @@ -463,11 +463,11 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { } /** - * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at - * index {@code offset}. - *

- * This method blocks until at least one byte of data can be read, the end of the opened range is - * detected, or an exception is thrown. + * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at index + * {@code offset}. + * + *

This method blocks until at least one byte of data can be read, the end of the opened range + * is detected, or an exception is thrown. * * @param buffer The buffer into which the read data should be stored. * @param offset The start offset into {@code buffer} at which data should be written. @@ -498,9 +498,7 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { return read; } - /** - * Closes the current connection quietly, if there is one. - */ + /** Closes the current connection quietly, if there is one. */ private void closeConnectionQuietly() { if (response != null) { Assertions.checkNotNull(response.body()).close(); @@ -508,5 +506,4 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource { } responseByteStream = null; } - } diff --git a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java index 5b6a31ca92..05780cbe3a 100644 --- a/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java +++ b/extensions/okhttp/src/main/java/com/google/android/exoplayer2/ext/okhttp/OkHttpDataSourceFactory.java @@ -104,11 +104,7 @@ public final class OkHttpDataSourceFactory extends BaseFactory { protected OkHttpDataSource createDataSourceInternal( HttpDataSource.RequestProperties defaultRequestProperties) { OkHttpDataSource dataSource = - new OkHttpDataSource( - callFactory, - userAgent, - cacheControl, - defaultRequestProperties); + new OkHttpDataSource(callFactory, userAgent, cacheControl, defaultRequestProperties); if (listener != null) { dataSource.addTransferListener(listener); } diff --git a/extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java b/extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java index 9cb606a718..7522b8048e 100644 --- a/extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java +++ b/extensions/opus/src/androidTest/java/com/google/android/exoplayer2/ext/opus/OpusPlaybackTest.java @@ -121,7 +121,5 @@ public class OpusPlaybackTest { Looper.myLooper().quit(); } } - } - } diff --git a/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoderException.java b/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoderException.java index 8d9cfea763..e9563b9af1 100644 --- a/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoderException.java +++ b/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoderException.java @@ -27,5 +27,4 @@ public final class OpusDecoderException extends DecoderException { /* package */ OpusDecoderException(String message, Throwable cause) { super(message, cause); } - } diff --git a/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusLibrary.java b/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusLibrary.java index 71ba1db106..47b1cef657 100644 --- a/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusLibrary.java +++ b/extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusLibrary.java @@ -48,9 +48,7 @@ public final class OpusLibrary { OpusLibrary.exoMediaCryptoType = exoMediaCryptoType; } - /** - * Returns whether the underlying library is available, loading it if necessary. - */ + /** Returns whether the underlying library is available, loading it if necessary. */ public static boolean isAvailable() { return LOADER.isAvailable(); } @@ -71,5 +69,6 @@ public final class OpusLibrary { } public static native String opusGetVersion(); + public static native boolean opusIsSecureDecodeSupported(); } diff --git a/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSource.java b/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSource.java index 587e310d64..f85a1c641c 100644 --- a/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSource.java +++ b/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSource.java @@ -80,5 +80,4 @@ public final class RtmpDataSource extends BaseDataSource { public Uri getUri() { return uri; } - } diff --git a/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSourceFactory.java b/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSourceFactory.java index 167a4175d7..70455fdd7a 100644 --- a/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSourceFactory.java +++ b/extensions/rtmp/src/main/java/com/google/android/exoplayer2/ext/rtmp/RtmpDataSourceFactory.java @@ -42,5 +42,4 @@ public final class RtmpDataSourceFactory implements DataSource.Factory { } return dataSource; } - } diff --git a/extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java b/extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java index d7a19f1662..59471296b4 100644 --- a/extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java +++ b/extensions/vp9/src/androidTest/java/com/google/android/exoplayer2/ext/vp9/VpxPlaybackTest.java @@ -157,5 +157,4 @@ public class VpxPlaybackTest { } } } - } diff --git a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java index 021ce3a946..7e8eedb210 100644 --- a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java +++ b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java @@ -145,8 +145,8 @@ public final class VpxDecoder if (result != NO_ERROR) { if (result == DRM_ERROR) { String message = "Drm error: " + vpxGetErrorMessage(vpxDecContext); - DecryptionException cause = new DecryptionException( - vpxGetErrorCode(vpxDecContext), message); + DecryptionException cause = + new DecryptionException(vpxGetErrorCode(vpxDecContext), message); return new VpxDecoderException(message, cause); } else { return new VpxDecoderException("Decode error: " + vpxGetErrorMessage(vpxDecContext)); @@ -209,6 +209,7 @@ public final class VpxDecoder boolean disableLoopFilter, boolean enableRowMultiThreadMode, int threads); private native long vpxClose(long context); + private native long vpxDecode(long context, ByteBuffer encoded, int length); private native long vpxSecureDecode( @@ -239,6 +240,6 @@ public final class VpxDecoder private native int vpxReleaseFrame(long context, VideoDecoderOutputBuffer outputBuffer); private native int vpxGetErrorCode(long context); - private native String vpxGetErrorMessage(long context); + private native String vpxGetErrorMessage(long context); } diff --git a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxLibrary.java b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxLibrary.java index 339ec021c6..8325265685 100644 --- a/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxLibrary.java +++ b/extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxLibrary.java @@ -48,9 +48,7 @@ public final class VpxLibrary { VpxLibrary.exoMediaCryptoType = exoMediaCryptoType; } - /** - * Returns whether the underlying library is available, loading it if necessary. - */ + /** Returns whether the underlying library is available, loading it if necessary. */ public static boolean isAvailable() { return LOADER.isAvailable(); } @@ -70,13 +68,10 @@ public final class VpxLibrary { return isAvailable() ? vpxGetBuildConfig() : null; } - /** - * Returns true if the underlying libvpx library supports high bit depth. - */ + /** Returns true if the underlying libvpx library supports high bit depth. */ public static boolean isHighBitDepthSupported() { String config = getBuildConfig(); - int indexHbd = config != null - ? config.indexOf("--enable-vp9-highbitdepth") : -1; + int indexHbd = config != null ? config.indexOf("--enable-vp9-highbitdepth") : -1; return indexHbd >= 0; } @@ -90,7 +85,8 @@ public final class VpxLibrary { } private static native String vpxGetVersion(); - private static native String vpxGetBuildConfig(); - public static native boolean vpxIsSecureDecodeSupported(); + private static native String vpxGetBuildConfig(); + + public static native boolean vpxIsSecureDecodeSupported(); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/C.java b/library/common/src/main/java/com/google/android/exoplayer2/C.java index 06eea5553c..512e4feeee 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/C.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/C.java @@ -49,14 +49,10 @@ public final class C { */ public static final long TIME_UNSET = Long.MIN_VALUE + 1; - /** - * Represents an unset or unknown index. - */ + /** Represents an unset or unknown index. */ public static final int INDEX_UNSET = -1; - /** - * Represents an unset or unknown position. - */ + /** Represents an unset or unknown position. */ public static final int POSITION_UNSET = -1; /** Represents an unset or unknown rate. */ @@ -74,9 +70,7 @@ public final class C { /** The number of microseconds in one second. */ public static final long MICROS_PER_SECOND = 1000000L; - /** - * The number of nanoseconds in one second. - */ + /** The number of nanoseconds in one second. */ public static final long NANOS_PER_SECOND = 1000000000L; /** The number of bits per byte. */ @@ -115,14 +109,10 @@ public final class C { */ @Deprecated public static final String UTF16LE_NAME = "UTF-16LE"; - /** - * The name of the serif font family. - */ + /** The name of the serif font family. */ public static final String SERIF_NAME = "serif"; - /** - * The name of the sans-serif font family. - */ + /** The name of the sans-serif font family. */ public static final String SANS_SERIF_NAME = "sans-serif"; /** @@ -133,22 +123,16 @@ public final class C { @Retention(RetentionPolicy.SOURCE) @IntDef({CRYPTO_MODE_UNENCRYPTED, CRYPTO_MODE_AES_CTR, CRYPTO_MODE_AES_CBC}) public @interface CryptoMode {} - /** - * @see MediaCodec#CRYPTO_MODE_UNENCRYPTED - */ + /** @see MediaCodec#CRYPTO_MODE_UNENCRYPTED */ public static final int CRYPTO_MODE_UNENCRYPTED = MediaCodec.CRYPTO_MODE_UNENCRYPTED; - /** - * @see MediaCodec#CRYPTO_MODE_AES_CTR - */ + /** @see MediaCodec#CRYPTO_MODE_AES_CTR */ public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR; - /** - * @see MediaCodec#CRYPTO_MODE_AES_CBC - */ + /** @see MediaCodec#CRYPTO_MODE_AES_CBC */ public static final int CRYPTO_MODE_AES_CBC = MediaCodec.CRYPTO_MODE_AES_CBC; /** - * Represents an unset {@link android.media.AudioTrack} session identifier. Equal to - * {@link AudioManager#AUDIO_SESSION_ID_GENERATE}. + * Represents an unset {@link android.media.AudioTrack} session identifier. Equal to {@link + * AudioManager#AUDIO_SESSION_ID_GENERATE}. */ public static final int AUDIO_SESSION_ID_UNSET = AudioManager.AUDIO_SESSION_ID_GENERATE; @@ -267,33 +251,19 @@ public final class C { STREAM_TYPE_VOICE_CALL }) public @interface StreamType {} - /** - * @see AudioManager#STREAM_ALARM - */ + /** @see AudioManager#STREAM_ALARM */ public static final int STREAM_TYPE_ALARM = AudioManager.STREAM_ALARM; - /** - * @see AudioManager#STREAM_DTMF - */ + /** @see AudioManager#STREAM_DTMF */ public static final int STREAM_TYPE_DTMF = AudioManager.STREAM_DTMF; - /** - * @see AudioManager#STREAM_MUSIC - */ + /** @see AudioManager#STREAM_MUSIC */ public static final int STREAM_TYPE_MUSIC = AudioManager.STREAM_MUSIC; - /** - * @see AudioManager#STREAM_NOTIFICATION - */ + /** @see AudioManager#STREAM_NOTIFICATION */ public static final int STREAM_TYPE_NOTIFICATION = AudioManager.STREAM_NOTIFICATION; - /** - * @see AudioManager#STREAM_RING - */ + /** @see AudioManager#STREAM_RING */ public static final int STREAM_TYPE_RING = AudioManager.STREAM_RING; - /** - * @see AudioManager#STREAM_SYSTEM - */ + /** @see AudioManager#STREAM_SYSTEM */ public static final int STREAM_TYPE_SYSTEM = AudioManager.STREAM_SYSTEM; - /** - * @see AudioManager#STREAM_VOICE_CALL - */ + /** @see AudioManager#STREAM_VOICE_CALL */ public static final int STREAM_TYPE_VOICE_CALL = AudioManager.STREAM_VOICE_CALL; /** The default stream type used by audio renderers. Equal to {@link #STREAM_TYPE_MUSIC}. */ public static final int STREAM_TYPE_DEFAULT = STREAM_TYPE_MUSIC; @@ -313,29 +283,17 @@ public final class C { CONTENT_TYPE_UNKNOWN }) public @interface AudioContentType {} - /** - * @see android.media.AudioAttributes#CONTENT_TYPE_MOVIE - */ + /** @see android.media.AudioAttributes#CONTENT_TYPE_MOVIE */ public static final int CONTENT_TYPE_MOVIE = android.media.AudioAttributes.CONTENT_TYPE_MOVIE; - /** - * @see android.media.AudioAttributes#CONTENT_TYPE_MUSIC - */ + /** @see android.media.AudioAttributes#CONTENT_TYPE_MUSIC */ public static final int CONTENT_TYPE_MUSIC = android.media.AudioAttributes.CONTENT_TYPE_MUSIC; - /** - * @see android.media.AudioAttributes#CONTENT_TYPE_SONIFICATION - */ + /** @see android.media.AudioAttributes#CONTENT_TYPE_SONIFICATION */ public static final int CONTENT_TYPE_SONIFICATION = android.media.AudioAttributes.CONTENT_TYPE_SONIFICATION; - /** - * @see android.media.AudioAttributes#CONTENT_TYPE_SPEECH - */ - public static final int CONTENT_TYPE_SPEECH = - android.media.AudioAttributes.CONTENT_TYPE_SPEECH; - /** - * @see android.media.AudioAttributes#CONTENT_TYPE_UNKNOWN - */ - public static final int CONTENT_TYPE_UNKNOWN = - android.media.AudioAttributes.CONTENT_TYPE_UNKNOWN; + /** @see android.media.AudioAttributes#CONTENT_TYPE_SPEECH */ + public static final int CONTENT_TYPE_SPEECH = android.media.AudioAttributes.CONTENT_TYPE_SPEECH; + /** @see android.media.AudioAttributes#CONTENT_TYPE_UNKNOWN */ + public static final int CONTENT_TYPE_UNKNOWN = android.media.AudioAttributes.CONTENT_TYPE_UNKNOWN; /** * Flags for audio attributes. Possible flag value is {@link #FLAG_AUDIBILITY_ENFORCED}. @@ -349,9 +307,7 @@ public final class C { flag = true, value = {FLAG_AUDIBILITY_ENFORCED}) public @interface AudioFlags {} - /** - * @see android.media.AudioAttributes#FLAG_AUDIBILITY_ENFORCED - */ + /** @see android.media.AudioAttributes#FLAG_AUDIBILITY_ENFORCED */ public static final int FLAG_AUDIBILITY_ENFORCED = android.media.AudioAttributes.FLAG_AUDIBILITY_ENFORCED; @@ -386,74 +342,46 @@ public final class C { USAGE_VOICE_COMMUNICATION_SIGNALLING }) public @interface AudioUsage {} - /** - * @see android.media.AudioAttributes#USAGE_ALARM - */ + /** @see android.media.AudioAttributes#USAGE_ALARM */ public static final int USAGE_ALARM = android.media.AudioAttributes.USAGE_ALARM; /** @see android.media.AudioAttributes#USAGE_ASSISTANCE_ACCESSIBILITY */ public static final int USAGE_ASSISTANCE_ACCESSIBILITY = android.media.AudioAttributes.USAGE_ASSISTANCE_ACCESSIBILITY; - /** - * @see android.media.AudioAttributes#USAGE_ASSISTANCE_NAVIGATION_GUIDANCE - */ + /** @see android.media.AudioAttributes#USAGE_ASSISTANCE_NAVIGATION_GUIDANCE */ public static final int USAGE_ASSISTANCE_NAVIGATION_GUIDANCE = android.media.AudioAttributes.USAGE_ASSISTANCE_NAVIGATION_GUIDANCE; - /** - * @see android.media.AudioAttributes#USAGE_ASSISTANCE_SONIFICATION - */ + /** @see android.media.AudioAttributes#USAGE_ASSISTANCE_SONIFICATION */ public static final int USAGE_ASSISTANCE_SONIFICATION = android.media.AudioAttributes.USAGE_ASSISTANCE_SONIFICATION; /** @see android.media.AudioAttributes#USAGE_ASSISTANT */ public static final int USAGE_ASSISTANT = android.media.AudioAttributes.USAGE_ASSISTANT; - /** - * @see android.media.AudioAttributes#USAGE_GAME - */ + /** @see android.media.AudioAttributes#USAGE_GAME */ public static final int USAGE_GAME = android.media.AudioAttributes.USAGE_GAME; - /** - * @see android.media.AudioAttributes#USAGE_MEDIA - */ + /** @see android.media.AudioAttributes#USAGE_MEDIA */ public static final int USAGE_MEDIA = android.media.AudioAttributes.USAGE_MEDIA; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION */ public static final int USAGE_NOTIFICATION = android.media.AudioAttributes.USAGE_NOTIFICATION; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_DELAYED - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_DELAYED */ public static final int USAGE_NOTIFICATION_COMMUNICATION_DELAYED = android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_DELAYED; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_INSTANT - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_INSTANT */ public static final int USAGE_NOTIFICATION_COMMUNICATION_INSTANT = android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_REQUEST - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION_COMMUNICATION_REQUEST */ public static final int USAGE_NOTIFICATION_COMMUNICATION_REQUEST = android.media.AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_REQUEST; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION_EVENT - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION_EVENT */ public static final int USAGE_NOTIFICATION_EVENT = android.media.AudioAttributes.USAGE_NOTIFICATION_EVENT; - /** - * @see android.media.AudioAttributes#USAGE_NOTIFICATION_RINGTONE - */ + /** @see android.media.AudioAttributes#USAGE_NOTIFICATION_RINGTONE */ public static final int USAGE_NOTIFICATION_RINGTONE = android.media.AudioAttributes.USAGE_NOTIFICATION_RINGTONE; - /** - * @see android.media.AudioAttributes#USAGE_UNKNOWN - */ + /** @see android.media.AudioAttributes#USAGE_UNKNOWN */ public static final int USAGE_UNKNOWN = android.media.AudioAttributes.USAGE_UNKNOWN; - /** - * @see android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION - */ + /** @see android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION */ public static final int USAGE_VOICE_COMMUNICATION = android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION; - /** - * @see android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION_SIGNALLING - */ + /** @see android.media.AudioAttributes#USAGE_VOICE_COMMUNICATION_SIGNALLING */ public static final int USAGE_VOICE_COMMUNICATION_SIGNALLING = android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION_SIGNALLING; @@ -518,13 +446,9 @@ public final class C { BUFFER_FLAG_DECODE_ONLY }) public @interface BufferFlags {} - /** - * Indicates that a buffer holds a synchronization sample. - */ + /** Indicates that a buffer holds a synchronization sample. */ public static final int BUFFER_FLAG_KEY_FRAME = MediaCodec.BUFFER_FLAG_KEY_FRAME; - /** - * Flag for empty buffers that signal that the end of the stream was reached. - */ + /** Flag for empty buffers that signal that the end of the stream was reached. */ public static final int BUFFER_FLAG_END_OF_STREAM = MediaCodec.BUFFER_FLAG_END_OF_STREAM; /** Indicates that a buffer has supplemental data. */ public static final int BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA = 1 << 28; // 0x10000000 @@ -577,9 +501,7 @@ public final class C { flag = true, value = {SELECTION_FLAG_DEFAULT, SELECTION_FLAG_FORCED, SELECTION_FLAG_AUTOSELECT}) public @interface SelectionFlags {} - /** - * Indicates that the track should be selected if user preferences do not state otherwise. - */ + /** Indicates that the track should be selected if user preferences do not state otherwise. */ public static final int SELECTION_FLAG_DEFAULT = 1; /** * Indicates that the track should be selected if its language matches the language of the @@ -608,17 +530,11 @@ public final class C { @Retention(RetentionPolicy.SOURCE) @IntDef({TYPE_DASH, TYPE_SS, TYPE_HLS, TYPE_RTSP, TYPE_OTHER}) public @interface ContentType {} - /** - * Value returned by {@link Util#inferContentType(String)} for DASH manifests. - */ + /** Value returned by {@link Util#inferContentType(String)} for DASH manifests. */ public static final int TYPE_DASH = 0; - /** - * Value returned by {@link Util#inferContentType(String)} for Smooth Streaming manifests. - */ + /** Value returned by {@link Util#inferContentType(String)} for Smooth Streaming manifests. */ public static final int TYPE_SS = 1; - /** - * Value returned by {@link Util#inferContentType(String)} for HLS manifests. - */ + /** Value returned by {@link Util#inferContentType(String)} for HLS manifests. */ public static final int TYPE_HLS = 2; /** Value returned by {@link Util#inferContentType(String)} for RTSP. */ public static final int TYPE_RTSP = 3; @@ -628,25 +544,17 @@ public final class C { */ public static final int TYPE_OTHER = 4; - /** - * A return value for methods where the end of an input was encountered. - */ + /** A return value for methods where the end of an input was encountered. */ public static final int RESULT_END_OF_INPUT = -1; /** * A return value for methods where the length of parsed data exceeds the maximum length allowed. */ public static final int RESULT_MAX_LENGTH_EXCEEDED = -2; - /** - * A return value for methods where nothing was read. - */ + /** A return value for methods where nothing was read. */ public static final int RESULT_NOTHING_READ = -3; - /** - * A return value for methods where a buffer was read. - */ + /** A return value for methods where a buffer was read. */ public static final int RESULT_BUFFER_READ = -4; - /** - * A return value for methods where a format was read. - */ + /** A return value for methods where a format was read. */ public static final int RESULT_FORMAT_READ = -5; /** A data type constant for data of unknown or unspecified type. */ @@ -697,25 +605,15 @@ public final class C { */ public static final int TRACK_TYPE_CUSTOM_BASE = 10000; - /** - * A selection reason constant for selections whose reasons are unknown or unspecified. - */ + /** A selection reason constant for selections whose reasons are unknown or unspecified. */ public static final int SELECTION_REASON_UNKNOWN = 0; - /** - * A selection reason constant for an initial track selection. - */ + /** A selection reason constant for an initial track selection. */ public static final int SELECTION_REASON_INITIAL = 1; - /** - * A selection reason constant for an manual (i.e. user initiated) track selection. - */ + /** A selection reason constant for an manual (i.e. user initiated) track selection. */ public static final int SELECTION_REASON_MANUAL = 2; - /** - * A selection reason constant for an adaptive track selection. - */ + /** A selection reason constant for an adaptive track selection. */ public static final int SELECTION_REASON_ADAPTIVE = 3; - /** - * A selection reason constant for a trick play track selection. - */ + /** A selection reason constant for a trick play track selection. */ public static final int SELECTION_REASON_TRICK_PLAY = 4; /** * Applications or extensions may define custom {@code SELECTION_REASON_*} constants greater than @@ -743,36 +641,36 @@ public final class C { public static final String CENC_TYPE_cbcs = "cbcs"; /** - * The Nil UUID as defined by - * RFC4122. + * The Nil UUID as defined by RFC4122. */ public static final UUID UUID_NIL = new UUID(0L, 0L); /** - * UUID for the W3C - * Common PSSH + * UUID for the W3C Common PSSH * box. */ public static final UUID COMMON_PSSH_UUID = new UUID(0x1077EFECC0B24D02L, 0xACE33C1E52E2FB4BL); /** * UUID for the ClearKey DRM scheme. - *

- * ClearKey is supported on Android devices running Android 5.0 (API Level 21) and up. + * + *

ClearKey is supported on Android devices running Android 5.0 (API Level 21) and up. */ public static final UUID CLEARKEY_UUID = new UUID(0xE2719D58A985B3C9L, 0x781AB030AF78D30EL); /** * UUID for the Widevine DRM scheme. - *

- * Widevine is supported on Android devices running Android 4.3 (API Level 18) and up. + * + *

Widevine is supported on Android devices running Android 4.3 (API Level 18) and up. */ public static final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL); /** * UUID for the PlayReady DRM scheme. - *

- * PlayReady is supported on all AndroidTV devices. Note that most other Android devices do not + * + *

PlayReady is supported on all AndroidTV devices. Note that most other Android devices do not * provide PlayReady support. */ public static final UUID PLAYREADY_UUID = new UUID(0x9A04F07998404286L, 0xAB92E65BE0885F95L); @@ -816,21 +714,15 @@ public final class C { STEREO_MODE_STEREO_MESH }) public @interface StereoMode {} - /** - * Indicates Monoscopic stereo layout, used with 360/3D/VR videos. - */ + /** Indicates Monoscopic stereo layout, used with 360/3D/VR videos. */ public static final int STEREO_MODE_MONO = 0; - /** - * Indicates Top-Bottom stereo layout, used with 360/3D/VR videos. - */ + /** Indicates Top-Bottom stereo layout, used with 360/3D/VR videos. */ public static final int STEREO_MODE_TOP_BOTTOM = 1; - /** - * Indicates Left-Right stereo layout, used with 360/3D/VR videos. - */ + /** Indicates Left-Right stereo layout, used with 360/3D/VR videos. */ public static final int STEREO_MODE_LEFT_RIGHT = 2; /** - * Indicates a stereo layout where the left and right eyes have separate meshes, - * used with 360/3D/VR videos. + * Indicates a stereo layout where the left and right eyes have separate meshes, used with + * 360/3D/VR videos. */ public static final int STEREO_MODE_STEREO_MESH = 3; @@ -842,17 +734,11 @@ public final class C { @Retention(RetentionPolicy.SOURCE) @IntDef({Format.NO_VALUE, COLOR_SPACE_BT709, COLOR_SPACE_BT601, COLOR_SPACE_BT2020}) public @interface ColorSpace {} - /** - * @see MediaFormat#COLOR_STANDARD_BT709 - */ + /** @see MediaFormat#COLOR_STANDARD_BT709 */ public static final int COLOR_SPACE_BT709 = MediaFormat.COLOR_STANDARD_BT709; - /** - * @see MediaFormat#COLOR_STANDARD_BT601_PAL - */ + /** @see MediaFormat#COLOR_STANDARD_BT601_PAL */ public static final int COLOR_SPACE_BT601 = MediaFormat.COLOR_STANDARD_BT601_PAL; - /** - * @see MediaFormat#COLOR_STANDARD_BT2020 - */ + /** @see MediaFormat#COLOR_STANDARD_BT2020 */ public static final int COLOR_SPACE_BT2020 = MediaFormat.COLOR_STANDARD_BT2020; /** @@ -863,17 +749,11 @@ public final class C { @Retention(RetentionPolicy.SOURCE) @IntDef({Format.NO_VALUE, COLOR_TRANSFER_SDR, COLOR_TRANSFER_ST2084, COLOR_TRANSFER_HLG}) public @interface ColorTransfer {} - /** - * @see MediaFormat#COLOR_TRANSFER_SDR_VIDEO - */ + /** @see MediaFormat#COLOR_TRANSFER_SDR_VIDEO */ public static final int COLOR_TRANSFER_SDR = MediaFormat.COLOR_TRANSFER_SDR_VIDEO; - /** - * @see MediaFormat#COLOR_TRANSFER_ST2084 - */ + /** @see MediaFormat#COLOR_TRANSFER_ST2084 */ public static final int COLOR_TRANSFER_ST2084 = MediaFormat.COLOR_TRANSFER_ST2084; - /** - * @see MediaFormat#COLOR_TRANSFER_HLG - */ + /** @see MediaFormat#COLOR_TRANSFER_HLG */ public static final int COLOR_TRANSFER_HLG = MediaFormat.COLOR_TRANSFER_HLG; /** @@ -884,13 +764,9 @@ public final class C { @Retention(RetentionPolicy.SOURCE) @IntDef({Format.NO_VALUE, COLOR_RANGE_LIMITED, COLOR_RANGE_FULL}) public @interface ColorRange {} - /** - * @see MediaFormat#COLOR_RANGE_LIMITED - */ + /** @see MediaFormat#COLOR_RANGE_LIMITED */ public static final int COLOR_RANGE_LIMITED = MediaFormat.COLOR_RANGE_LIMITED; - /** - * @see MediaFormat#COLOR_RANGE_FULL - */ + /** @see MediaFormat#COLOR_RANGE_FULL */ public static final int COLOR_RANGE_FULL = MediaFormat.COLOR_RANGE_FULL; /** Video projection types. */ @@ -1150,8 +1026,8 @@ public final class C { } /** - * Converts a time in milliseconds to the corresponding time in microseconds, preserving - * {@link #TIME_UNSET} values and {@link #TIME_END_OF_SOURCE} values. + * Converts a time in milliseconds to the corresponding time in microseconds, preserving {@link + * #TIME_UNSET} values and {@link #TIME_END_OF_SOURCE} values. * * @param timeMs The time in milliseconds. * @return The corresponding time in microseconds. diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java b/library/common/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java index eb04eef9c6..a6cc5d9bdc 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ExoPlaybackException.java @@ -59,8 +59,8 @@ public final class ExoPlaybackException extends Exception implements Bundleable public static final int TYPE_RENDERER = 1; /** * The error was an unexpected {@link RuntimeException}. - *

- * Call {@link #getUnexpectedException()} to retrieve the underlying cause. + * + *

Call {@link #getUnexpectedException()} to retrieve the underlying cause. */ public static final int TYPE_UNEXPECTED = 2; /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java b/library/common/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java index 0ce3929170..ec5ccb0484 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ExoPlayerLibraryInfo.java @@ -21,9 +21,7 @@ import java.util.HashSet; /** Information about the ExoPlayer library. */ public final class ExoPlayerLibraryInfo { - /** - * A tag to use when logging library information. - */ + /** A tag to use when logging library information. */ public static final String TAG = "ExoPlayer"; /** The version of the library expressed as a string, for example "1.2.3". */ @@ -73,9 +71,7 @@ public final class ExoPlayerLibraryInfo { private ExoPlayerLibraryInfo() {} // Prevents instantiation. - /** - * Returns a string consisting of registered module names separated by ", ". - */ + /** Returns a string consisting of registered module names separated by ", ". */ public static synchronized String registeredModules() { return registeredModulesString; } @@ -90,5 +86,4 @@ public final class ExoPlayerLibraryInfo { registeredModulesString = registeredModulesString + ", " + name; } } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Format.java b/library/common/src/main/java/com/google/android/exoplayer2/Format.java index 5b23a616b9..252266a874 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Format.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Format.java @@ -681,8 +681,8 @@ public final class Format implements Parcelable { */ public final int maxInputSize; /** - * Initialization data that must be provided to the decoder. Will not be null, but may be empty - * if initialization data is not required. + * Initialization data that must be provided to the decoder. Will not be null, but may be empty if + * initialization data is not required. */ public final List initializationData; /** DRM initialization data if the stream is protected, or null otherwise. */ @@ -697,17 +697,11 @@ public final class Format implements Parcelable { // Video specific. - /** - * The width of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. - */ + /** The width of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. */ public final int width; - /** - * The height of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. - */ + /** The height of the video in pixels, or {@link #NO_VALUE} if unknown or not applicable. */ public final int height; - /** - * The frame rate in frames per second, or {@link #NO_VALUE} if unknown or not applicable. - */ + /** The frame rate in frames per second, or {@link #NO_VALUE} if unknown or not applicable. */ public final float frameRate; /** * The clockwise rotation that should be applied to the video for it to be rendered in the correct @@ -729,13 +723,9 @@ public final class Format implements Parcelable { // Audio specific. - /** - * The number of audio channels, or {@link #NO_VALUE} if unknown or not applicable. - */ + /** The number of audio channels, or {@link #NO_VALUE} if unknown or not applicable. */ public final int channelCount; - /** - * The audio sampling rate in Hz, or {@link #NO_VALUE} if unknown or not applicable. - */ + /** The audio sampling rate in Hz, or {@link #NO_VALUE} if unknown or not applicable. */ public final int sampleRate; /** The {@link C.PcmEncoding} for PCM audio. Set to {@link #NO_VALUE} for other media types. */ @C.PcmEncoding public final int pcmEncoding; @@ -1549,17 +1539,17 @@ public final class Format implements Parcelable { dest.writeInt(accessibilityChannel); } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = + new Creator() { - @Override - public Format createFromParcel(Parcel in) { - return new Format(in); - } + @Override + public Format createFromParcel(Parcel in) { + return new Format(in); + } - @Override - public Format[] newArray(int size) { - return new Format[size]; - } - - }; + @Override + public Format[] newArray(int size) { + return new Format[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/IllegalSeekPositionException.java b/library/common/src/main/java/com/google/android/exoplayer2/IllegalSeekPositionException.java index 745e86983f..71f57dec82 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/IllegalSeekPositionException.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/IllegalSeekPositionException.java @@ -21,17 +21,11 @@ package com.google.android.exoplayer2; */ public final class IllegalSeekPositionException extends IllegalStateException { - /** - * The {@link Timeline} in which the seek was attempted. - */ + /** The {@link Timeline} in which the seek was attempted. */ public final Timeline timeline; - /** - * The index of the window being seeked to. - */ + /** The index of the window being seeked to. */ public final int windowIndex; - /** - * The seek position in the specified window. - */ + /** The seek position in the specified window. */ public final long positionMs; /** @@ -44,5 +38,4 @@ public final class IllegalSeekPositionException extends IllegalStateException { this.windowIndex = windowIndex; this.positionMs = positionMs; } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java b/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java index 8e9ecb27d1..c2d9acad7c 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/MediaItem.java @@ -559,9 +559,7 @@ public final class MediaItem implements Bundleable { return this; } - /** - * Returns a new {@link MediaItem} instance with the current builder values. - */ + /** Returns a new {@link MediaItem} instance with the current builder values. */ public MediaItem build() { checkState(drmLicenseUri == null || drmUuid != null); @Nullable PlaybackProperties playbackProperties = null; diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ParserException.java b/library/common/src/main/java/com/google/android/exoplayer2/ParserException.java index 716eceda94..29b4df1dec 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ParserException.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ParserException.java @@ -24,16 +24,12 @@ public class ParserException extends IOException { super(); } - /** - * @param message The detail message for the exception. - */ + /** @param message The detail message for the exception. */ public ParserException(String message) { super(message); } - /** - * @param cause The cause for the exception. - */ + /** @param cause The cause for the exception. */ public ParserException(Throwable cause) { super(cause); } @@ -45,5 +41,4 @@ public class ParserException extends IOException { public ParserException(String message, Throwable cause) { super(message, cause); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java index 4d90c0a268..93d57119a1 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/Timeline.java @@ -229,9 +229,7 @@ public abstract class Timeline implements Bundleable { */ public long defaultPositionUs; - /** - * The duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** The duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. */ public long durationUs; /** The index of the first period that belongs to this window. */ @@ -312,16 +310,12 @@ public abstract class Timeline implements Bundleable { return defaultPositionUs; } - /** - * Returns the duration of the window in milliseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** Returns the duration of the window in milliseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationMs() { return C.usToMs(durationUs); } - /** - * Returns the duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** Returns the duration of this window in microseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationUs() { return durationUs; } @@ -572,14 +566,10 @@ public abstract class Timeline implements Bundleable { */ @Nullable public Object uid; - /** - * The index of the window to which this period belongs. - */ + /** The index of the window to which this period belongs. */ public int windowIndex; - /** - * The duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** The duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. */ public long durationUs; /** @@ -660,16 +650,12 @@ public abstract class Timeline implements Bundleable { return this; } - /** - * Returns the duration of the period in milliseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** Returns the duration of the period in milliseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationMs() { return C.usToMs(durationUs); } - /** - * Returns the duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** Returns the duration of this period in microseconds, or {@link C#TIME_UNSET} if unknown. */ public long getDurationUs() { return durationUs; } @@ -777,8 +763,8 @@ public abstract class Timeline implements Bundleable { } /** - * Returns the number of ads in the ad group at index {@code adGroupIndex}, or - * {@link C#LENGTH_UNSET} if not yet known. + * Returns the number of ads in the ad group at index {@code adGroupIndex}, or {@link + * C#LENGTH_UNSET} if not yet known. * * @param adGroupIndex The ad group index. * @return The number of ads in the ad group, or {@link C#LENGTH_UNSET} if not yet known. @@ -788,8 +774,8 @@ public abstract class Timeline implements Bundleable { } /** - * Returns the duration of the ad at index {@code adIndexInAdGroup} in the ad group at - * {@code adGroupIndex}, in microseconds, or {@link C#TIME_UNSET} if not yet known. + * Returns the duration of the ad at index {@code adIndexInAdGroup} in the ad group at {@code + * adGroupIndex}, in microseconds, or {@link C#TIME_UNSET} if not yet known. * * @param adGroupIndex The ad group index. * @param adIndexInAdGroup The ad index in the ad group. @@ -949,16 +935,12 @@ public abstract class Timeline implements Bundleable { } }; - /** - * Returns whether the timeline is empty. - */ + /** Returns whether the timeline is empty. */ public final boolean isEmpty() { return getWindowCount() == 0; } - /** - * Returns the number of windows in the timeline. - */ + /** Returns the number of windows in the timeline. */ public abstract int getWindowCount(); /** @@ -974,13 +956,15 @@ public abstract class Timeline implements Bundleable { int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) { switch (repeatMode) { case Player.REPEAT_MODE_OFF: - return windowIndex == getLastWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET + return windowIndex == getLastWindowIndex(shuffleModeEnabled) + ? C.INDEX_UNSET : windowIndex + 1; case Player.REPEAT_MODE_ONE: return windowIndex; case Player.REPEAT_MODE_ALL: return windowIndex == getLastWindowIndex(shuffleModeEnabled) - ? getFirstWindowIndex(shuffleModeEnabled) : windowIndex + 1; + ? getFirstWindowIndex(shuffleModeEnabled) + : windowIndex + 1; default: throw new IllegalStateException(); } @@ -999,13 +983,15 @@ public abstract class Timeline implements Bundleable { int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) { switch (repeatMode) { case Player.REPEAT_MODE_OFF: - return windowIndex == getFirstWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET + return windowIndex == getFirstWindowIndex(shuffleModeEnabled) + ? C.INDEX_UNSET : windowIndex - 1; case Player.REPEAT_MODE_ONE: return windowIndex; case Player.REPEAT_MODE_ALL: return windowIndex == getFirstWindowIndex(shuffleModeEnabled) - ? getLastWindowIndex(shuffleModeEnabled) : windowIndex - 1; + ? getLastWindowIndex(shuffleModeEnabled) + : windowIndex - 1; default: throw new IllegalStateException(); } @@ -1064,9 +1050,7 @@ public abstract class Timeline implements Bundleable { public abstract Window getWindow( int windowIndex, Window window, long defaultPositionProjectionUs); - /** - * Returns the number of periods in the timeline. - */ + /** Returns the number of periods in the timeline. */ public abstract int getPeriodCount(); /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java b/library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java index f9a97d961f..f3dfb20f9b 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java @@ -66,21 +66,13 @@ public final class Ac3Util { * #STREAM_TYPE_UNDEFINED} otherwise. */ public final @StreamType int streamType; - /** - * The audio sampling rate in Hz. - */ + /** The audio sampling rate in Hz. */ public final int sampleRate; - /** - * The number of audio channels - */ + /** The number of audio channels */ public final int channelCount; - /** - * The size of the frame. - */ + /** The size of the frame. */ public final int frameSize; - /** - * Number of audio samples in the frame. - */ + /** Number of audio samples in the frame. */ public final int sampleCount; private SyncFrameInfo( @@ -97,7 +89,6 @@ public final class Ac3Util { this.frameSize = frameSize; this.sampleCount = sampleCount; } - } /** Maximum rate for an AC-3 audio stream, in bytes per second. */ @@ -118,27 +109,17 @@ public final class Ac3Util { */ public static final int TRUEHD_SYNCFRAME_PREFIX_LENGTH = 10; - /** - * The number of new samples per (E-)AC-3 audio block. - */ + /** The number of new samples per (E-)AC-3 audio block. */ private static final int AUDIO_SAMPLES_PER_AUDIO_BLOCK = 256; /** Each syncframe has 6 blocks that provide 256 new audio samples. See subsection 4.1. */ private static final int AC3_SYNCFRAME_AUDIO_SAMPLE_COUNT = 6 * AUDIO_SAMPLES_PER_AUDIO_BLOCK; - /** - * Number of audio blocks per E-AC-3 syncframe, indexed by numblkscod. - */ + /** Number of audio blocks per E-AC-3 syncframe, indexed by numblkscod. */ private static final int[] BLOCKS_PER_SYNCFRAME_BY_NUMBLKSCOD = new int[] {1, 2, 3, 6}; - /** - * Sample rates, indexed by fscod. - */ + /** Sample rates, indexed by fscod. */ private static final int[] SAMPLE_RATE_BY_FSCOD = new int[] {48000, 44100, 32000}; - /** - * Sample rates, indexed by fscod2 (E-AC-3). - */ + /** Sample rates, indexed by fscod2 (E-AC-3). */ private static final int[] SAMPLE_RATE_BY_FSCOD2 = new int[] {24000, 22050, 16000}; - /** - * Channel counts, indexed by acmod. - */ + /** Channel counts, indexed by acmod. */ private static final int[] CHANNEL_COUNT_BY_ACMOD = new int[] {2, 1, 2, 3, 3, 4, 4, 5}; /** Nominal bitrates in kbps, indexed by frmsizecod / 2. (See table 4.13.) */ private static final int[] BITRATE_BY_HALF_FRMSIZECOD = @@ -316,7 +297,7 @@ public final class Ac3Util { } if (streamType == SyncFrameInfo.STREAM_TYPE_TYPE0) { if (data.readBit()) { // pgmscle - data.skipBits(6); //pgmscl + data.skipBits(6); // pgmscl } if (acmod == 0 && data.readBit()) { // pgmscl2e data.skipBits(6); // pgmscl2 @@ -562,7 +543,9 @@ public final class Ac3Util { private static int getAc3SyncframeSize(int fscod, int frmsizecod) { int halfFrmsizecod = frmsizecod / 2; - if (fscod < 0 || fscod >= SAMPLE_RATE_BY_FSCOD.length || frmsizecod < 0 + if (fscod < 0 + || fscod >= SAMPLE_RATE_BY_FSCOD.length + || frmsizecod < 0 || halfFrmsizecod >= SYNCFRAME_SIZE_WORDS_BY_HALF_FRMSIZECOD_44_1.length) { // Invalid values provided. return C.LENGTH_UNSET; @@ -580,5 +563,4 @@ public final class Ac3Util { } private Ac3Util() {} - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java b/library/common/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java index b91e642d14..f503ab53c4 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/audio/AudioAttributes.java @@ -41,9 +41,7 @@ public final class AudioAttributes implements Bundleable { public static final AudioAttributes DEFAULT = new Builder().build(); - /** - * Builder for {@link AudioAttributes}. - */ + /** Builder for {@link AudioAttributes}. */ public static final class Builder { private @C.AudioContentType int contentType; @@ -64,25 +62,19 @@ public final class AudioAttributes implements Bundleable { allowedCapturePolicy = C.ALLOW_CAPTURE_BY_ALL; } - /** - * @see android.media.AudioAttributes.Builder#setContentType(int) - */ + /** @see android.media.AudioAttributes.Builder#setContentType(int) */ public Builder setContentType(@C.AudioContentType int contentType) { this.contentType = contentType; return this; } - /** - * @see android.media.AudioAttributes.Builder#setFlags(int) - */ + /** @see android.media.AudioAttributes.Builder#setFlags(int) */ public Builder setFlags(@C.AudioFlags int flags) { this.flags = flags; return this; } - /** - * @see android.media.AudioAttributes.Builder#setUsage(int) - */ + /** @see android.media.AudioAttributes.Builder#setUsage(int) */ public Builder setUsage(@C.AudioUsage int usage) { this.usage = usage; return this; @@ -98,7 +90,6 @@ public final class AudioAttributes implements Bundleable { public AudioAttributes build() { return new AudioAttributes(contentType, flags, usage, allowedCapturePolicy); } - } public final @C.AudioContentType int contentType; diff --git a/library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java index 3a0f0e093d..1a741d47d5 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java @@ -44,24 +44,22 @@ public final class DtsUtil { private static final byte FIRST_BYTE_LE = (byte) (SYNC_VALUE_LE >>> 24); private static final byte FIRST_BYTE_14B_LE = (byte) (SYNC_VALUE_14B_LE >>> 24); - /** - * Maps AMODE to the number of channels. See ETSI TS 102 114 table 5.4. - */ - private static final int[] CHANNELS_BY_AMODE = new int[] {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, - 7, 8, 8}; + /** Maps AMODE to the number of channels. See ETSI TS 102 114 table 5.4. */ + private static final int[] CHANNELS_BY_AMODE = + new int[] {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8}; - /** - * Maps SFREQ to the sampling frequency in Hz. See ETSI TS 102 144 table 5.5. - */ - private static final int[] SAMPLE_RATE_BY_SFREQ = new int[] {-1, 8000, 16000, 32000, -1, -1, - 11025, 22050, 44100, -1, -1, 12000, 24000, 48000, -1, -1}; + /** Maps SFREQ to the sampling frequency in Hz. See ETSI TS 102 144 table 5.5. */ + private static final int[] SAMPLE_RATE_BY_SFREQ = + new int[] { + -1, 8000, 16000, 32000, -1, -1, 11025, 22050, 44100, -1, -1, 12000, 24000, 48000, -1, -1 + }; - /** - * Maps RATE to 2 * bitrate in kbit/s. See ETSI TS 102 144 table 5.7. - */ - private static final int[] TWICE_BITRATE_KBPS_BY_RATE = new int[] {64, 112, 128, 192, 224, 256, - 384, 448, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1920, 2048, 2304, 2560, 2688, 2816, - 2823, 2944, 3072, 3840, 4096, 6144, 7680}; + /** Maps RATE to 2 * bitrate in kbit/s. See ETSI TS 102 144 table 5.7. */ + private static final int[] TWICE_BITRATE_KBPS_BY_RATE = + new int[] { + 64, 112, 128, 192, 224, 256, 384, 448, 512, 640, 768, 896, 1024, 1152, 1280, 1536, 1920, + 2048, 2304, 2560, 2688, 2816, 2823, 2944, 3072, 3840, 4096, 6144, 7680 + }; /** * Returns whether a given integer matches a DTS sync word. Synchronization and storage modes are @@ -99,8 +97,10 @@ public final class DtsUtil { int sfreq = frameBits.readBits(4); int sampleRate = SAMPLE_RATE_BY_SFREQ[sfreq]; int rate = frameBits.readBits(5); - int bitrate = rate >= TWICE_BITRATE_KBPS_BY_RATE.length ? Format.NO_VALUE - : TWICE_BITRATE_KBPS_BY_RATE[rate] * 1000 / 2; + int bitrate = + rate >= TWICE_BITRATE_KBPS_BY_RATE.length + ? Format.NO_VALUE + : TWICE_BITRATE_KBPS_BY_RATE[rate] * 1000 / 2; frameBits.skipBits(10); // MIX, DYNF, TIMEF, AUXF, HDCD, EXT_AUDIO_ID, EXT_AUDIO, ASPF channelCount += frameBits.readBits(2) > 0 ? 1 : 0; // LFF return new Format.Builder() @@ -230,5 +230,4 @@ public final class DtsUtil { } private DtsUtil() {} - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/decoder/Buffer.java b/library/common/src/main/java/com/google/android/exoplayer2/decoder/Buffer.java index 6d74bf820e..71ea215d2c 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/decoder/Buffer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/decoder/Buffer.java @@ -20,33 +20,24 @@ import com.google.android.exoplayer2.C; /** Base class for buffers with flags. */ public abstract class Buffer { - @C.BufferFlags - private int flags; + @C.BufferFlags private int flags; - /** - * Clears the buffer. - */ + /** Clears the buffer. */ public void clear() { flags = 0; } - /** - * Returns whether the {@link C#BUFFER_FLAG_DECODE_ONLY} flag is set. - */ + /** Returns whether the {@link C#BUFFER_FLAG_DECODE_ONLY} flag is set. */ public final boolean isDecodeOnly() { return getFlag(C.BUFFER_FLAG_DECODE_ONLY); } - /** - * Returns whether the {@link C#BUFFER_FLAG_END_OF_STREAM} flag is set. - */ + /** Returns whether the {@link C#BUFFER_FLAG_END_OF_STREAM} flag is set. */ public final boolean isEndOfStream() { return getFlag(C.BUFFER_FLAG_END_OF_STREAM); } - /** - * Returns whether the {@link C#BUFFER_FLAG_KEY_FRAME} flag is set. - */ + /** Returns whether the {@link C#BUFFER_FLAG_KEY_FRAME} flag is set. */ public final boolean isKeyFrame() { return getFlag(C.BUFFER_FLAG_KEY_FRAME); } @@ -69,8 +60,8 @@ public abstract class Buffer { /** * Adds the {@code flag} to this buffer's flags. * - * @param flag The flag to add to this buffer's flags, which should be one of the - * {@code C.BUFFER_FLAG_*} constants. + * @param flag The flag to add to this buffer's flags, which should be one of the {@code + * C.BUFFER_FLAG_*} constants. */ public final void addFlag(@C.BufferFlags int flag) { flags |= flag; @@ -94,5 +85,4 @@ public abstract class Buffer { protected final boolean getFlag(@C.BufferFlags int flag) { return (flags & flag) == flag; } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java b/library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java index 80486feb91..b4e04afe42 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java @@ -63,13 +63,9 @@ public final class CryptoInfo { * @see android.media.MediaCodec.CryptoInfo#numSubSamples */ public int numSubSamples; - /** - * @see android.media.MediaCodec.CryptoInfo.Pattern - */ + /** @see android.media.MediaCodec.CryptoInfo.Pattern */ public int encryptedBlocks; - /** - * @see android.media.MediaCodec.CryptoInfo.Pattern - */ + /** @see android.media.MediaCodec.CryptoInfo.Pattern */ public int clearBlocks; private final android.media.MediaCodec.CryptoInfo frameworkCryptoInfo; @@ -80,11 +76,16 @@ public final class CryptoInfo { patternHolder = Util.SDK_INT >= 24 ? new PatternHolderV24(frameworkCryptoInfo) : null; } - /** - * @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int) - */ - public void set(int numSubSamples, int[] numBytesOfClearData, int[] numBytesOfEncryptedData, - byte[] key, byte[] iv, @C.CryptoMode int mode, int encryptedBlocks, int clearBlocks) { + /** @see android.media.MediaCodec.CryptoInfo#set(int, int[], int[], byte[], byte[], int) */ + public void set( + int numSubSamples, + int[] numBytesOfClearData, + int[] numBytesOfEncryptedData, + byte[] key, + byte[] iv, + @C.CryptoMode int mode, + int encryptedBlocks, + int clearBlocks) { this.numSubSamples = numSubSamples; this.numBytesOfClearData = numBytesOfClearData; this.numBytesOfEncryptedData = numBytesOfEncryptedData; @@ -157,7 +158,5 @@ public final class CryptoInfo { pattern.set(encryptedBlocks, clearBlocks); frameworkCryptoInfo.setPattern(pattern); } - } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java b/library/common/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java index ff295657e1..71b3a68d19 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java @@ -66,22 +66,14 @@ public class DecoderInputBuffer extends Buffer { BUFFER_REPLACEMENT_MODE_DIRECT }) public @interface BufferReplacementMode {} - /** - * Disallows buffer replacement. - */ + /** Disallows buffer replacement. */ public static final int BUFFER_REPLACEMENT_MODE_DISABLED = 0; - /** - * Allows buffer replacement using {@link ByteBuffer#allocate(int)}. - */ + /** Allows buffer replacement using {@link ByteBuffer#allocate(int)}. */ public static final int BUFFER_REPLACEMENT_MODE_NORMAL = 1; - /** - * Allows buffer replacement using {@link ByteBuffer#allocateDirect(int)}. - */ + /** Allows buffer replacement using {@link ByteBuffer#allocateDirect(int)}. */ public static final int BUFFER_REPLACEMENT_MODE_DIRECT = 2; - /** - * {@link CryptoInfo} for encrypted data. - */ + /** {@link CryptoInfo} for encrypted data. */ public final CryptoInfo cryptoInfo; /** The buffer's data, or {@code null} if no data has been set. */ @@ -95,9 +87,7 @@ public class DecoderInputBuffer extends Buffer { */ public boolean waitingForKeys; - /** - * The time at which the sample should be presented. - */ + /** The time at which the sample should be presented. */ public long timeUs; /** @@ -194,9 +184,7 @@ public class DecoderInputBuffer extends Buffer { data = newData; } - /** - * Returns whether the {@link C#BUFFER_FLAG_ENCRYPTED} flag is set. - */ + /** Returns whether the {@link C#BUFFER_FLAG_ENCRYPTED} flag is set. */ public final boolean isEncrypted() { return getFlag(C.BUFFER_FLAG_ENCRYPTED); } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java b/library/common/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java index 4113f4c27d..5c366ef9e2 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java @@ -87,14 +87,10 @@ public final class DrmInitData implements Comparator, Parcelable { /** The protection scheme type, or null if not applicable or unknown. */ @Nullable public final String schemeType; - /** - * Number of {@link SchemeData}s. - */ + /** Number of {@link SchemeData}s. */ public final int schemeDataCount; - /** - * @param schemeDatas Scheme initialization data for possibly multiple DRM schemes. - */ + /** @param schemeDatas Scheme initialization data for possibly multiple DRM schemes. */ public DrmInitData(List schemeDatas) { this(null, false, schemeDatas.toArray(new SchemeData[0])); } @@ -107,9 +103,7 @@ public final class DrmInitData implements Comparator, Parcelable { this(schemeType, false, schemeDatas.toArray(new SchemeData[0])); } - /** - * @param schemeDatas Scheme initialization data for possibly multiple DRM schemes. - */ + /** @param schemeDatas Scheme initialization data for possibly multiple DRM schemes. */ public DrmInitData(SchemeData... schemeDatas) { this(null, schemeDatas); } @@ -122,8 +116,8 @@ public final class DrmInitData implements Comparator, Parcelable { this(schemeType, true, schemeDatas); } - private DrmInitData(@Nullable String schemeType, boolean cloneSchemeDatas, - SchemeData... schemeDatas) { + private DrmInitData( + @Nullable String schemeType, boolean cloneSchemeDatas, SchemeData... schemeDatas) { this.schemeType = schemeType; if (cloneSchemeDatas) { schemeDatas = schemeDatas.clone(); @@ -208,7 +202,8 @@ public final class DrmInitData implements Comparator, Parcelable { @Override public int compare(SchemeData first, SchemeData second) { - return C.UUID_NIL.equals(first.uuid) ? (C.UUID_NIL.equals(second.uuid) ? 0 : 1) + return C.UUID_NIL.equals(first.uuid) + ? (C.UUID_NIL.equals(second.uuid) ? 0 : 1) : first.uuid.compareTo(second.uuid); } @@ -228,17 +223,16 @@ public final class DrmInitData implements Comparator, Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public DrmInitData createFromParcel(Parcel in) { - return new DrmInitData(in); - } + @Override + public DrmInitData createFromParcel(Parcel in) { + return new DrmInitData(in); + } - @Override - public DrmInitData[] newArray(int size) { - return new DrmInitData[size]; - } - - }; + @Override + public DrmInitData[] newArray(int size) { + return new DrmInitData[size]; + } + }; // Internal methods. @@ -252,9 +246,7 @@ public final class DrmInitData implements Comparator, Parcelable { return false; } - /** - * Scheme initialization data. - */ + /** Scheme initialization data. */ public static final class SchemeData implements Parcelable { // Lazily initialized hashcode. @@ -324,9 +316,7 @@ public final class DrmInitData implements Comparator, Parcelable { return hasData() && !other.hasData() && matches(other.uuid); } - /** - * Returns whether {@link #data} is non-null. - */ + /** Returns whether {@link #data} is non-null. */ public boolean hasData() { return data != null; } @@ -387,18 +377,15 @@ public final class DrmInitData implements Comparator, Parcelable { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public SchemeData createFromParcel(Parcel in) { - return new SchemeData(in); - } - - @Override - public SchemeData[] newArray(int size) { - return new SchemeData[size]; - } - - }; + @Override + public SchemeData createFromParcel(Parcel in) { + return new SchemeData(in); + } + @Override + public SchemeData[] newArray(int size) { + return new SchemeData[size]; + } + }; } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java index 01ae340609..ffa837deff 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/Metadata.java @@ -62,16 +62,12 @@ public final class Metadata implements Parcelable { private final Entry[] entries; - /** - * @param entries The metadata entries. - */ + /** @param entries The metadata entries. */ public Metadata(Entry... entries) { this.entries = entries; } - /** - * @param entries The metadata entries. - */ + /** @param entries The metadata entries. */ public Metadata(List entries) { this.entries = entries.toArray(new Entry[0]); } @@ -83,9 +79,7 @@ public final class Metadata implements Parcelable { } } - /** - * Returns the number of metadata entries. - */ + /** Returns the number of metadata entries. */ public int length() { return entries.length; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/MetadataInputBuffer.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/MetadataInputBuffer.java index 55e0b75f71..0ce9eb616b 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/MetadataInputBuffer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/MetadataInputBuffer.java @@ -22,13 +22,12 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer; public final class MetadataInputBuffer extends DecoderInputBuffer { /** - * An offset that must be added to the metadata's timestamps after it's been decoded, or - * {@link Format#OFFSET_SAMPLE_RELATIVE} if {@link #timeUs} should be added. + * An offset that must be added to the metadata's timestamps after it's been decoded, or {@link + * Format#OFFSET_SAMPLE_RELATIVE} if {@link #timeUs} should be added. */ public long subsampleOffsetUs; public MetadataInputBuffer() { super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java index 0dd46bae22..8f8046d7e2 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java @@ -57,24 +57,16 @@ public final class EventMessage implements Metadata.Entry { /** The message scheme. */ public final String schemeIdUri; - /** - * The value for the event. - */ + /** The value for the event. */ public final String value; - /** - * The duration of the event in milliseconds. - */ + /** The duration of the event in milliseconds. */ public final long durationMs; - /** - * The instance identifier. - */ + /** The instance identifier. */ public final long id; - /** - * The body of the message. - */ + /** The body of the message. */ public final byte[] messageData; // Lazily initialized hashcode. @@ -185,16 +177,14 @@ public final class EventMessage implements Metadata.Entry { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public EventMessage createFromParcel(Parcel in) { - return new EventMessage(in); - } - - @Override - public EventMessage[] newArray(int size) { - return new EventMessage[size]; - } - - }; + @Override + public EventMessage createFromParcel(Parcel in) { + return new EventMessage(in); + } + @Override + public EventMessage[] newArray(int size) { + return new EventMessage[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoder.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoder.java index 4fa3f71b32..2fb0132731 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoder.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessageEncoder.java @@ -69,5 +69,4 @@ public final class EventMessageEncoder { outputStream.writeByte((int) (value >>> 8) & 0xFF); outputStream.writeByte((int) value & 0xFF); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ApicFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ApicFrame.java index 4f05cc7f08..13b0e5345d 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ApicFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ApicFrame.java @@ -59,7 +59,8 @@ public final class ApicFrame extends Id3Frame { return false; } ApicFrame other = (ApicFrame) obj; - return pictureType == other.pictureType && Util.areEqual(mimeType, other.mimeType) + return pictureType == other.pictureType + && Util.areEqual(mimeType, other.mimeType) && Util.areEqual(description, other.description) && Arrays.equals(pictureData, other.pictureData); } @@ -89,18 +90,17 @@ public final class ApicFrame extends Id3Frame { dest.writeByteArray(pictureData); } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { - @Override - public ApicFrame createFromParcel(Parcel in) { - return new ApicFrame(in); - } - - @Override - public ApicFrame[] newArray(int size) { - return new ApicFrame[size]; - } - - }; + @Override + public ApicFrame createFromParcel(Parcel in) { + return new ApicFrame(in); + } + @Override + public ApicFrame[] newArray(int size) { + return new ApicFrame[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/BinaryFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/BinaryFrame.java index 995418f3b4..39305404cf 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/BinaryFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/BinaryFrame.java @@ -75,7 +75,5 @@ public final class BinaryFrame extends Id3Frame { public BinaryFrame[] newArray(int size) { return new BinaryFrame[size]; } - }; - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java index 120b9269f1..e759a73aac 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterFrame.java @@ -31,18 +31,20 @@ public final class ChapterFrame extends Id3Frame { public final String chapterId; public final int startTimeMs; public final int endTimeMs; - /** - * The byte offset of the start of the chapter, or {@link C#POSITION_UNSET} if not set. - */ + /** The byte offset of the start of the chapter, or {@link C#POSITION_UNSET} if not set. */ public final long startOffset; - /** - * The byte offset of the end of the chapter, or {@link C#POSITION_UNSET} if not set. - */ + /** The byte offset of the end of the chapter, or {@link C#POSITION_UNSET} if not set. */ public final long endOffset; + private final Id3Frame[] subFrames; - public ChapterFrame(String chapterId, int startTimeMs, int endTimeMs, long startOffset, - long endOffset, Id3Frame[] subFrames) { + public ChapterFrame( + String chapterId, + int startTimeMs, + int endTimeMs, + long startOffset, + long endOffset, + Id3Frame[] subFrames) { super(ID); this.chapterId = chapterId; this.startTimeMs = startTimeMs; @@ -66,16 +68,12 @@ public final class ChapterFrame extends Id3Frame { } } - /** - * Returns the number of sub-frames. - */ + /** Returns the number of sub-frames. */ public int getSubFrameCount() { return subFrames.length; } - /** - * Returns the sub-frame at {@code index}. - */ + /** Returns the sub-frame at {@code index}. */ public Id3Frame getSubFrame(int index) { return subFrames[index]; } @@ -126,18 +124,17 @@ public final class ChapterFrame extends Id3Frame { return 0; } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = + new Creator() { - @Override - public ChapterFrame createFromParcel(Parcel in) { - return new ChapterFrame(in); - } - - @Override - public ChapterFrame[] newArray(int size) { - return new ChapterFrame[size]; - } - - }; + @Override + public ChapterFrame createFromParcel(Parcel in) { + return new ChapterFrame(in); + } + @Override + public ChapterFrame[] newArray(int size) { + return new ChapterFrame[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrame.java index 5e662c388c..ee7bcd397e 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrame.java @@ -33,7 +33,11 @@ public final class ChapterTocFrame extends Id3Frame { public final String[] children; private final Id3Frame[] subFrames; - public ChapterTocFrame(String elementId, boolean isRoot, boolean isOrdered, String[] children, + public ChapterTocFrame( + String elementId, + boolean isRoot, + boolean isOrdered, + String[] children, Id3Frame[] subFrames) { super(ID); this.elementId = elementId; @@ -56,16 +60,12 @@ public final class ChapterTocFrame extends Id3Frame { } } - /** - * Returns the number of sub-frames. - */ + /** Returns the number of sub-frames. */ public int getSubFrameCount() { return subFrames.length; } - /** - * Returns the sub-frame at {@code index}. - */ + /** Returns the sub-frame at {@code index}. */ public Id3Frame getSubFrame(int index) { return subFrames[index]; } @@ -107,18 +107,17 @@ public final class ChapterTocFrame extends Id3Frame { } } - public static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = + new Creator() { - @Override - public ChapterTocFrame createFromParcel(Parcel in) { - return new ChapterTocFrame(in); - } - - @Override - public ChapterTocFrame[] newArray(int size) { - return new ChapterTocFrame[size]; - } - - }; + @Override + public ChapterTocFrame createFromParcel(Parcel in) { + return new ChapterTocFrame(in); + } + @Override + public ChapterTocFrame[] newArray(int size) { + return new ChapterTocFrame[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/CommentFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/CommentFrame.java index 8b2d14444d..5d441e782f 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/CommentFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/CommentFrame.java @@ -54,7 +54,8 @@ public final class CommentFrame extends Id3Frame { return false; } CommentFrame other = (CommentFrame) obj; - return Util.areEqual(description, other.description) && Util.areEqual(language, other.language) + return Util.areEqual(description, other.description) + && Util.areEqual(language, other.language) && Util.areEqual(text, other.text); } @@ -93,7 +94,5 @@ public final class CommentFrame extends Id3Frame { public CommentFrame[] newArray(int size) { return new CommentFrame[size]; } - }; - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/GeobFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/GeobFrame.java index c0c8ad631f..2c609db8d5 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/GeobFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/GeobFrame.java @@ -58,8 +58,10 @@ public final class GeobFrame extends Id3Frame { return false; } GeobFrame other = (GeobFrame) obj; - return Util.areEqual(mimeType, other.mimeType) && Util.areEqual(filename, other.filename) - && Util.areEqual(description, other.description) && Arrays.equals(data, other.data); + return Util.areEqual(mimeType, other.mimeType) + && Util.areEqual(filename, other.filename) + && Util.areEqual(description, other.description) + && Arrays.equals(data, other.data); } @Override @@ -93,18 +95,17 @@ public final class GeobFrame extends Id3Frame { dest.writeByteArray(data); } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { - @Override - public GeobFrame createFromParcel(Parcel in) { - return new GeobFrame(in); - } - - @Override - public GeobFrame[] newArray(int size) { - return new GeobFrame[size]; - } - - }; + @Override + public GeobFrame createFromParcel(Parcel in) { + return new GeobFrame(in); + } + @Override + public GeobFrame[] newArray(int size) { + return new GeobFrame[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java index 5bd0e1e3e8..0d97cef846 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Decoder.java @@ -35,9 +35,7 @@ import java.util.Locale; /** Decodes ID3 tags. */ public final class Id3Decoder extends SimpleMetadataDecoder { - /** - * A predicate for determining whether individual frames should be decoded. - */ + /** A predicate for determining whether individual frames should be decoded. */ public interface FramePredicate { /** @@ -51,7 +49,6 @@ public final class Id3Decoder extends SimpleMetadataDecoder { * @return Whether the frame should be decoded. */ boolean evaluate(int majorVersion, int id0, int id1, int id2, int id3); - } /** A predicate that indicates no frames should be decoded. */ @@ -62,9 +59,7 @@ public final class Id3Decoder extends SimpleMetadataDecoder { /** The first three bytes of a well formed ID3 tag header. */ public static final int ID3_TAG = 0x00494433; - /** - * Length of an ID3 tag header. - */ + /** Length of an ID3 tag header. */ public static final int ID3_HEADER_LENGTH = 10; private static final int FRAME_FLAG_V3_IS_COMPRESSED = 0x0080; @@ -210,8 +205,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder { return new Id3Header(majorVersion, isUnsynchronized, framesSize); } - private static boolean validateFrames(ParsableByteArray id3Data, int majorVersion, - int frameHeaderSize, boolean unsignedIntFrameSizeHack) { + private static boolean validateFrames( + ParsableByteArray id3Data, + int majorVersion, + int frameHeaderSize, + boolean unsignedIntFrameSizeHack) { int startPosition = id3Data.getPosition(); try { while (id3Data.bytesLeft() >= frameHeaderSize) { @@ -238,8 +236,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder { if ((frameSize & 0x808080L) != 0) { return false; } - frameSize = (frameSize & 0xFF) | (((frameSize >> 8) & 0xFF) << 7) - | (((frameSize >> 16) & 0xFF) << 14) | (((frameSize >> 24) & 0xFF) << 21); + frameSize = + (frameSize & 0xFF) + | (((frameSize >> 8) & 0xFF) << 7) + | (((frameSize >> 16) & 0xFF) << 14) + | (((frameSize >> 24) & 0xFF) << 21); } boolean hasGroupIdentifier = false; boolean hasDataLength = false; @@ -289,8 +290,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder { if (majorVersion == 4) { frameSize = id3Data.readUnsignedIntToInt(); if (!unsignedIntFrameSizeHack) { - frameSize = (frameSize & 0xFF) | (((frameSize >> 8) & 0xFF) << 7) - | (((frameSize >> 16) & 0xFF) << 14) | (((frameSize >> 24) & 0xFF) << 21); + frameSize = + (frameSize & 0xFF) + | (((frameSize >> 8) & 0xFF) << 7) + | (((frameSize >> 16) & 0xFF) << 14) + | (((frameSize >> 24) & 0xFF) << 21); } } else if (majorVersion == 3) { frameSize = id3Data.readUnsignedIntToInt(); @@ -299,7 +303,11 @@ public final class Id3Decoder extends SimpleMetadataDecoder { } int flags = majorVersion >= 3 ? id3Data.readUnsignedShort() : 0; - if (frameId0 == 0 && frameId1 == 0 && frameId2 == 0 && frameId3 == 0 && frameSize == 0 + if (frameId0 == 0 + && frameId1 == 0 + && frameId2 == 0 + && frameId3 == 0 + && frameSize == 0 && flags == 0) { // We must be reading zero padding at the end of the tag. id3Data.setPosition(id3Data.limit()); @@ -360,13 +368,17 @@ public final class Id3Decoder extends SimpleMetadataDecoder { try { Id3Frame frame; - if (frameId0 == 'T' && frameId1 == 'X' && frameId2 == 'X' + if (frameId0 == 'T' + && frameId1 == 'X' + && frameId2 == 'X' && (majorVersion == 2 || frameId3 == 'X')) { frame = decodeTxxxFrame(id3Data, frameSize); } else if (frameId0 == 'T') { String id = getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3); frame = decodeTextInformationFrame(id3Data, frameSize, id); - } else if (frameId0 == 'W' && frameId1 == 'X' && frameId2 == 'X' + } else if (frameId0 == 'W' + && frameId1 == 'X' + && frameId2 == 'X' && (majorVersion == 2 || frameId3 == 'X')) { frame = decodeWxxxFrame(id3Data, frameSize); } else if (frameId0 == 'W') { @@ -374,21 +386,38 @@ public final class Id3Decoder extends SimpleMetadataDecoder { frame = decodeUrlLinkFrame(id3Data, frameSize, id); } else if (frameId0 == 'P' && frameId1 == 'R' && frameId2 == 'I' && frameId3 == 'V') { frame = decodePrivFrame(id3Data, frameSize); - } else if (frameId0 == 'G' && frameId1 == 'E' && frameId2 == 'O' + } else if (frameId0 == 'G' + && frameId1 == 'E' + && frameId2 == 'O' && (frameId3 == 'B' || majorVersion == 2)) { frame = decodeGeobFrame(id3Data, frameSize); - } else if (majorVersion == 2 ? (frameId0 == 'P' && frameId1 == 'I' && frameId2 == 'C') + } else if (majorVersion == 2 + ? (frameId0 == 'P' && frameId1 == 'I' && frameId2 == 'C') : (frameId0 == 'A' && frameId1 == 'P' && frameId2 == 'I' && frameId3 == 'C')) { frame = decodeApicFrame(id3Data, frameSize, majorVersion); - } else if (frameId0 == 'C' && frameId1 == 'O' && frameId2 == 'M' + } else if (frameId0 == 'C' + && frameId1 == 'O' + && frameId2 == 'M' && (frameId3 == 'M' || majorVersion == 2)) { frame = decodeCommentFrame(id3Data, frameSize); } else if (frameId0 == 'C' && frameId1 == 'H' && frameId2 == 'A' && frameId3 == 'P') { - frame = decodeChapterFrame(id3Data, frameSize, majorVersion, unsignedIntFrameSizeHack, - frameHeaderSize, framePredicate); + frame = + decodeChapterFrame( + id3Data, + frameSize, + majorVersion, + unsignedIntFrameSizeHack, + frameHeaderSize, + framePredicate); } else if (frameId0 == 'C' && frameId1 == 'T' && frameId2 == 'O' && frameId3 == 'C') { - frame = decodeChapterTOCFrame(id3Data, frameSize, majorVersion, unsignedIntFrameSizeHack, - frameHeaderSize, framePredicate); + frame = + decodeChapterTOCFrame( + id3Data, + frameSize, + majorVersion, + unsignedIntFrameSizeHack, + frameHeaderSize, + framePredicate); } else if (frameId0 == 'M' && frameId1 == 'L' && frameId2 == 'L' && frameId3 == 'T') { frame = decodeMlltFrame(id3Data, frameSize); } else { @@ -396,9 +425,12 @@ public final class Id3Decoder extends SimpleMetadataDecoder { frame = decodeBinaryFrame(id3Data, frameSize, id); } if (frame == null) { - Log.w(TAG, "Failed to decode frame: id=" - + getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3) + ", frameSize=" - + frameSize); + Log.w( + TAG, + "Failed to decode frame: id=" + + getFrameId(majorVersion, frameId0, frameId1, frameId2, frameId3) + + ", frameSize=" + + frameSize); } return frame; } catch (UnsupportedEncodingException e) { @@ -477,8 +509,8 @@ public final class Id3Decoder extends SimpleMetadataDecoder { return new UrlLinkFrame("WXXX", description, url); } - private static UrlLinkFrame decodeUrlLinkFrame(ParsableByteArray id3Data, int frameSize, - String id) throws UnsupportedEncodingException { + private static UrlLinkFrame decodeUrlLinkFrame( + ParsableByteArray id3Data, int frameSize, String id) throws UnsupportedEncodingException { byte[] data = new byte[frameSize]; id3Data.readBytes(data, 0, frameSize); @@ -528,8 +560,9 @@ public final class Id3Decoder extends SimpleMetadataDecoder { return new GeobFrame(mimeType, filename, description, objectData); } - private static ApicFrame decodeApicFrame(ParsableByteArray id3Data, int frameSize, - int majorVersion) throws UnsupportedEncodingException { + private static ApicFrame decodeApicFrame( + ParsableByteArray id3Data, int frameSize, int majorVersion) + throws UnsupportedEncodingException { int encoding = id3Data.readUnsignedByte(); String charset = getCharsetName(encoding); @@ -556,8 +589,9 @@ public final class Id3Decoder extends SimpleMetadataDecoder { int descriptionStartIndex = mimeTypeEndIndex + 2; int descriptionEndIndex = indexOfEos(data, descriptionStartIndex, encoding); - String description = new String(data, descriptionStartIndex, - descriptionEndIndex - descriptionStartIndex, charset); + String description = + new String( + data, descriptionStartIndex, descriptionEndIndex - descriptionStartIndex, charset); int pictureDataStartIndex = descriptionEndIndex + delimiterLength(encoding); byte[] pictureData = copyOfRangeIfValid(data, pictureDataStartIndex, data.length); @@ -622,8 +656,9 @@ public final class Id3Decoder extends SimpleMetadataDecoder { ArrayList subFrames = new ArrayList<>(); int limit = framePosition + frameSize; while (id3Data.getPosition() < limit) { - Id3Frame frame = decodeFrame(majorVersion, id3Data, unsignedIntFrameSizeHack, - frameHeaderSize, framePredicate); + Id3Frame frame = + decodeFrame( + majorVersion, id3Data, unsignedIntFrameSizeHack, frameHeaderSize, framePredicate); if (frame != null) { subFrames.add(frame); } @@ -707,8 +742,8 @@ public final class Id3Decoder extends SimpleMetadataDecoder { millisecondsDeviations); } - private static BinaryFrame decodeBinaryFrame(ParsableByteArray id3Data, int frameSize, - String id) { + private static BinaryFrame decodeBinaryFrame( + ParsableByteArray id3Data, int frameSize, String id) { byte[] frame = new byte[frameSize]; id3Data.readBytes(frame, 0, frameSize); @@ -716,8 +751,8 @@ public final class Id3Decoder extends SimpleMetadataDecoder { } /** - * Performs in-place removal of unsynchronization for {@code length} bytes starting from - * {@link ParsableByteArray#getPosition()} + * Performs in-place removal of unsynchronization for {@code length} bytes starting from {@link + * ParsableByteArray#getPosition()} * * @param data Contains the data to be processed. * @param length The length of the data to be processed. @@ -756,9 +791,10 @@ public final class Id3Decoder extends SimpleMetadataDecoder { } } - private static String getFrameId(int majorVersion, int frameId0, int frameId1, int frameId2, - int frameId3) { - return majorVersion == 2 ? String.format(Locale.US, "%c%c%c", frameId0, frameId1, frameId2) + private static String getFrameId( + int majorVersion, int frameId0, int frameId1, int frameId2, int frameId3) { + return majorVersion == 2 + ? String.format(Locale.US, "%c%c%c", frameId0, frameId1, frameId2) : String.format(Locale.US, "%c%c%c%c", frameId0, frameId1, frameId2, frameId3); } @@ -792,7 +828,8 @@ public final class Id3Decoder extends SimpleMetadataDecoder { private static int delimiterLength(int encodingByte) { return (encodingByte == ID3_TEXT_ENCODING_ISO_8859_1 || encodingByte == ID3_TEXT_ENCODING_UTF_8) - ? 1 : 2; + ? 1 + : 2; } /** @@ -841,7 +878,5 @@ public final class Id3Decoder extends SimpleMetadataDecoder { this.isUnsynchronized = isUnsynchronized; this.framesSize = framesSize; } - } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Frame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Frame.java index 24e1188879..e54de84f58 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Frame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/Id3Frame.java @@ -20,9 +20,7 @@ import com.google.android.exoplayer2.metadata.Metadata; /** Base class for ID3 frames. */ public abstract class Id3Frame implements Metadata.Entry { - /** - * The frame ID. - */ + /** The frame ID. */ public final String id; public Id3Frame(String id) { @@ -38,5 +36,4 @@ public abstract class Id3Frame implements Metadata.Entry { public int describeContents() { return 0; } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/PrivFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/PrivFrame.java index 773e49e846..567785ac16 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/PrivFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/PrivFrame.java @@ -75,18 +75,17 @@ public final class PrivFrame extends Id3Frame { dest.writeByteArray(privateData); } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator() { - @Override - public PrivFrame createFromParcel(Parcel in) { - return new PrivFrame(in); - } - - @Override - public PrivFrame[] newArray(int size) { - return new PrivFrame[size]; - } - - }; + @Override + public PrivFrame createFromParcel(Parcel in) { + return new PrivFrame(in); + } + @Override + public PrivFrame[] newArray(int size) { + return new PrivFrame[size]; + } + }; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/UrlLinkFrame.java b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/UrlLinkFrame.java index d9b73ab011..6648d852fa 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/UrlLinkFrame.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/metadata/id3/UrlLinkFrame.java @@ -49,7 +49,8 @@ public final class UrlLinkFrame extends Id3Frame { return false; } UrlLinkFrame other = (UrlLinkFrame) obj; - return id.equals(other.id) && Util.areEqual(description, other.description) + return id.equals(other.id) + && Util.areEqual(description, other.description) && Util.areEqual(url, other.url); } @@ -88,7 +89,5 @@ public final class UrlLinkFrame extends Id3Frame { public UrlLinkFrame[] newArray(int size) { return new UrlLinkFrame[size]; } - }; - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java index 2df780ce93..0888f3fa96 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/source/TrackGroup.java @@ -37,9 +37,7 @@ public final class TrackGroup implements Parcelable { // Lazily initialized hashcode. private int hashCode; - /** - * @param formats The track formats. At least one {@link Format} must be provided. - */ + /** @param formats The track formats. At least one {@link Format} must be provided. */ public TrackGroup(Format... formats) { Assertions.checkState(formats.length > 0); this.formats = formats; diff --git a/library/common/src/main/java/com/google/android/exoplayer2/text/Cue.java b/library/common/src/main/java/com/google/android/exoplayer2/text/Cue.java index 46f865782f..67f622d89f 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/text/Cue.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/text/Cue.java @@ -58,9 +58,7 @@ public final class Cue { */ public static final int ANCHOR_TYPE_START = 0; - /** - * Anchors the middle of the cue box. - */ + /** Anchors the middle of the cue box. */ public static final int ANCHOR_TYPE_MIDDLE = 1; /** @@ -78,14 +76,10 @@ public final class Cue { @IntDef({TYPE_UNSET, LINE_TYPE_FRACTION, LINE_TYPE_NUMBER}) public @interface LineType {} - /** - * Value for {@link #lineType} when {@link #line} is a fractional position. - */ + /** Value for {@link #lineType} when {@link #line} is a fractional position. */ public static final int LINE_TYPE_FRACTION = 0; - /** - * Value for {@link #lineType} when {@link #line} is a line number. - */ + /** Value for {@link #lineType} when {@link #line} is a line number. */ public static final int LINE_TYPE_NUMBER = 1; /** @@ -247,14 +241,10 @@ public final class Cue { */ public final float bitmapHeight; - /** - * Specifies whether or not the {@link #windowColor} property is set. - */ + /** Specifies whether or not the {@link #windowColor} property is set. */ public final boolean windowColorSet; - /** - * The fill color of the window. - */ + /** The fill color of the window. */ public final int windowColor; /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSource.java b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSource.java index c157002809..c6ac0a261a 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSource.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSource.java @@ -26,14 +26,10 @@ import java.util.Map; /** Reads data from URI-identified resources. */ public interface DataSource extends DataReader { - /** - * A factory for {@link DataSource} instances. - */ + /** A factory for {@link DataSource} instances. */ interface Factory { - /** - * Creates a {@link DataSource} instance. - */ + /** Creates a {@link DataSource} instance. */ DataSource createDataSource(); } @@ -83,7 +79,8 @@ public interface DataSource extends DataReader { * * @return The {@link Uri} from which data is being read, or null if the source is not open. */ - @Nullable Uri getUri(); + @Nullable + Uri getUri(); /** * When the source is open, returns the response headers associated with the last {@link #open} diff --git a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java index d484779d36..dde0835517 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DataSpec.java @@ -360,9 +360,7 @@ public final class DataSpec { /** The position of the data when read from {@link #uri}. */ public final long position; - /** - * The length of the data, or {@link C#LENGTH_UNSET}. - */ + /** The length of the data, or {@link C#LENGTH_UNSET}. */ public final long length; /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java index 88193c2646..9a48fd52b1 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java @@ -194,9 +194,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou /** The default connection timeout, in milliseconds. */ public static final int DEFAULT_CONNECT_TIMEOUT_MILLIS = 8 * 1000; - /** - * The default read timeout, in milliseconds. - */ + /** The default read timeout, in milliseconds. */ public static final int DEFAULT_READ_TIMEOUT_MILLIS = 8 * 1000; private static final String TAG = "DefaultHttpDataSource"; @@ -325,9 +323,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou requestProperties.clear(); } - /** - * Opens the source to read the specified data. - */ + /** Opens the source to read the specified data. */ @Override public long open(DataSpec dataSpec) throws HttpDataSourceException { this.dataSpec = dataSpec; @@ -411,8 +407,8 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou HttpUtil.getContentLength( connection.getHeaderField(HttpHeaders.CONTENT_LENGTH), connection.getHeaderField(HttpHeaders.CONTENT_RANGE)); - bytesToRead = contentLength != C.LENGTH_UNSET ? (contentLength - bytesToSkip) - : C.LENGTH_UNSET; + bytesToRead = + contentLength != C.LENGTH_UNSET ? (contentLength - bytesToSkip) : C.LENGTH_UNSET; } } else { // Gzip is enabled. If the server opts to use gzip then the content length in the response @@ -481,9 +477,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou } } - /** - * Establishes a connection, following redirects to do so where permitted. - */ + /** Establishes a connection, following redirects to do so where permitted. */ private HttpURLConnection makeConnection(DataSpec dataSpec) throws IOException { URL url = new URL(dataSpec.uri.toString()); @HttpMethod int httpMethod = dataSpec.httpMethod; @@ -675,11 +669,11 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou } /** - * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at - * index {@code offset}. - *

- * This method blocks until at least one byte of data can be read, the end of the opened range is - * detected, or an exception is thrown. + * Reads up to {@code length} bytes of data and stores them into {@code buffer}, starting at index + * {@code offset}. + * + *

This method blocks until at least one byte of data can be read, the end of the opened range + * is detected, or an exception is thrown. * * @param buffer The buffer into which the read data should be stored. * @param offset The start offset into {@code buffer} at which data should be written. @@ -756,9 +750,7 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou } } - /** - * Closes the current connection quietly, if there is one. - */ + /** Closes the current connection quietly, if there is one. */ private void closeConnectionQuietly() { if (connection != null) { try { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java b/library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java index dbaa686066..27b195a794 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/upstream/HttpDataSource.java @@ -33,9 +33,7 @@ import java.util.Map; /** An HTTP {@link DataSource}. */ public interface HttpDataSource extends DataSource { - /** - * A factory for {@link HttpDataSource} instances. - */ + /** A factory for {@link HttpDataSource} instances. */ interface Factory extends DataSource.Factory { @Override @@ -61,9 +59,9 @@ public interface HttpDataSource extends DataSource { } /** - * Stores HTTP request properties (aka HTTP headers) and provides methods to modify the headers - * in a thread safe way to avoid the potential of creating snapshots of an inconsistent or - * unintended state. + * Stores HTTP request properties (aka HTTP headers) and provides methods to modify the headers in + * a thread safe way to avoid the potential of creating snapshots of an inconsistent or unintended + * state. */ final class RequestProperties { @@ -119,9 +117,7 @@ public interface HttpDataSource extends DataSource { requestProperties.remove(name); } - /** - * Clears all request properties. - */ + /** Clears all request properties. */ public synchronized void clear() { requestPropertiesSnapshot = null; requestProperties.clear(); @@ -191,9 +187,7 @@ public interface HttpDataSource extends DataSource { && !contentType.contains("xml"); }; - /** - * Thrown when an error is encountered when trying to read from a {@link HttpDataSource}. - */ + /** Thrown when an error is encountered when trying to read from a {@link HttpDataSource}. */ class HttpDataSourceException extends IOException { @Documented @@ -207,9 +201,7 @@ public interface HttpDataSource extends DataSource { @Type public final int type; - /** - * The {@link DataSpec} associated with the current connection. - */ + /** The {@link DataSpec} associated with the current connection. */ public final DataSpec dataSpec; public HttpDataSourceException(DataSpec dataSpec, @Type int type) { @@ -230,8 +222,8 @@ public interface HttpDataSource extends DataSource { this.type = type; } - public HttpDataSourceException(String message, IOException cause, DataSpec dataSpec, - @Type int type) { + public HttpDataSourceException( + String message, IOException cause, DataSpec dataSpec, @Type int type) { super(message, cause); this.dataSpec = dataSpec; this.type = type; @@ -256,9 +248,7 @@ public interface HttpDataSource extends DataSource { } } - /** - * Thrown when the content type is invalid. - */ + /** Thrown when the content type is invalid. */ final class InvalidContentTypeException extends HttpDataSourceException { public final String contentType; @@ -274,17 +264,13 @@ public interface HttpDataSource extends DataSource { */ final class InvalidResponseCodeException extends HttpDataSourceException { - /** - * The response code that was outside of the 2xx range. - */ + /** The response code that was outside of the 2xx range. */ public final int responseCode; /** The http status message. */ @Nullable public final String responseMessage; - /** - * An unmodifiable map of the response header fields and values. - */ + /** An unmodifiable map of the response header fields and values. */ public final Map> headerFields; /** The response body. */ @@ -333,7 +319,6 @@ public interface HttpDataSource extends DataSource { this.headerFields = headerFields; this.responseBody = responseBody; } - } /** @@ -373,9 +358,7 @@ public interface HttpDataSource extends DataSource { */ void clearRequestProperty(String name); - /** - * Clears all request headers that were set by {@link #setRequestProperty(String, String)}. - */ + /** Clears all request headers that were set by {@link #setRequestProperty(String, String)}. */ void clearAllRequestProperties(); /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java index 0bb65e55e0..f83e918d4a 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Assertions.java @@ -224,5 +224,4 @@ public final class Assertions { throw new IllegalStateException("Not in applications main thread"); } } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Clock.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Clock.java index 8ecb2ab8ec..b21e5773e6 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Clock.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Clock.java @@ -25,9 +25,7 @@ import androidx.annotation.Nullable; */ public interface Clock { - /** - * Default {@link Clock} to use for all non-test cases. - */ + /** Default {@link Clock} to use for all non-test cases. */ Clock DEFAULT = new SystemClock(); /** diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java index a4436ccdab..fec99ea2a2 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ListenerSet.java @@ -88,11 +88,7 @@ public final class ListenerSet { * during one {@link Looper} message queue iteration were handled by the listeners. */ public ListenerSet(Looper looper, Clock clock, IterationFinishedEvent iterationFinishedEvent) { - this( - /* listeners= */ new CopyOnWriteArraySet<>(), - looper, - clock, - iterationFinishedEvent); + this(/* listeners= */ new CopyOnWriteArraySet<>(), looper, clock, iterationFinishedEvent); } private ListenerSet( diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/LongArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/LongArray.java index d6a1733697..a9709dff70 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/LongArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/LongArray.java @@ -29,9 +29,7 @@ public final class LongArray { this(DEFAULT_INITIAL_CAPACITY); } - /** - * @param initialCapacity The initial capacity of the array. - */ + /** @param initialCapacity The initial capacity of the array. */ public LongArray(int initialCapacity) { values = new long[initialCapacity]; } @@ -63,9 +61,7 @@ public final class LongArray { return values[index]; } - /** - * Returns the current size of the array. - */ + /** Returns the current size of the array. */ public int size() { return size; } @@ -78,5 +74,4 @@ public final class LongArray { public long[] toArray() { return Arrays.copyOf(values, size); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java index d6d4a7aa01..1fd44011e0 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java @@ -24,9 +24,7 @@ public final class NalUnitUtil { private static final String TAG = "NalUnitUtil"; - /** - * Holds data parsed from a sequence parameter set NAL unit. - */ + /** Holds data parsed from a sequence parameter set NAL unit. */ public static final class SpsData { public final int profileIdc; @@ -71,25 +69,23 @@ public final class NalUnitUtil { this.picOrderCntLsbLength = picOrderCntLsbLength; this.deltaPicOrderAlwaysZeroFlag = deltaPicOrderAlwaysZeroFlag; } - } - /** - * Holds data parsed from a picture parameter set NAL unit. - */ + /** Holds data parsed from a picture parameter set NAL unit. */ public static final class PpsData { public final int picParameterSetId; public final int seqParameterSetId; public final boolean bottomFieldPicOrderInFramePresentFlag; - public PpsData(int picParameterSetId, int seqParameterSetId, + public PpsData( + int picParameterSetId, + int seqParameterSetId, boolean bottomFieldPicOrderInFramePresentFlag) { this.picParameterSetId = picParameterSetId; this.seqParameterSetId = seqParameterSetId; this.bottomFieldPicOrderInFramePresentFlag = bottomFieldPicOrderInFramePresentFlag; } - } /** Four initial bytes that must prefix NAL units for decoding. */ @@ -98,25 +94,26 @@ public final class NalUnitUtil { /** Value for aspect_ratio_idc indicating an extended aspect ratio, in H.264 and H.265 SPSs. */ public static final int EXTENDED_SAR = 0xFF; /** Aspect ratios indexed by aspect_ratio_idc, in H.264 and H.265 SPSs. */ - public static final float[] ASPECT_RATIO_IDC_VALUES = new float[] { - 1f /* Unspecified. Assume square */, - 1f, - 12f / 11f, - 10f / 11f, - 16f / 11f, - 40f / 33f, - 24f / 11f, - 20f / 11f, - 32f / 11f, - 80f / 33f, - 18f / 11f, - 15f / 11f, - 64f / 33f, - 160f / 99f, - 4f / 3f, - 3f / 2f, - 2f - }; + public static final float[] ASPECT_RATIO_IDC_VALUES = + new float[] { + 1f /* Unspecified. Assume square */, + 1f, + 12f / 11f, + 10f / 11f, + 16f / 11f, + 40f / 33f, + 24f / 11f, + 20f / 11f, + 32f / 11f, + 80f / 33f, + 18f / 11f, + 15f / 11f, + 64f / 33f, + 160f / 99f, + 4f / 3f, + 3f / 2f, + 2f + }; private static final int H264_NAL_UNIT_TYPE_SEI = 6; // Supplemental enhancement information private static final int H264_NAL_UNIT_TYPE_SPS = 7; // Sequence parameter set @@ -131,10 +128,10 @@ public final class NalUnitUtil { private static int[] scratchEscapePositions = new int[10]; /** - * Unescapes {@code data} up to the specified limit, replacing occurrences of [0, 0, 3] with - * [0, 0]. The unescaped data is returned in-place, with the return value indicating its length. - *

- * Executions of this method are mutually exclusive, so it should not be called with very large + * Unescapes {@code data} up to the specified limit, replacing occurrences of [0, 0, 3] with [0, + * 0]. The unescaped data is returned in-place, with the return value indicating its length. + * + *

Executions of this method are mutually exclusive, so it should not be called with very large * buffers. * * @param data The data to unescape. @@ -150,8 +147,8 @@ public final class NalUnitUtil { if (position < limit) { if (scratchEscapePositions.length <= scratchEscapeCount) { // Grow scratchEscapePositions to hold a larger number of positions. - scratchEscapePositions = Arrays.copyOf(scratchEscapePositions, - scratchEscapePositions.length * 2); + scratchEscapePositions = + Arrays.copyOf(scratchEscapePositions, scratchEscapePositions.length * 2); } scratchEscapePositions[scratchEscapeCount++] = position; position += 3; @@ -180,9 +177,9 @@ public final class NalUnitUtil { /** * Discards data from the buffer up to the first SPS, where {@code data.position()} is interpreted * as the length of the buffer. - *

- * When the method returns, {@code data.position()} will contain the new length of the buffer. If - * the buffer is not empty it is guaranteed to start with an SPS. + * + *

When the method returns, {@code data.position()} will contain the new length of the buffer. + * If the buffer is not empty it is guaranteed to start with an SPS. * * @param data Buffer containing start code delimited NAL units. */ @@ -225,9 +222,9 @@ public final class NalUnitUtil { */ public static boolean isNalUnitSei(@Nullable String mimeType, byte nalUnitHeaderFirstByte) { return (MimeTypes.VIDEO_H264.equals(mimeType) - && (nalUnitHeaderFirstByte & 0x1F) == H264_NAL_UNIT_TYPE_SEI) + && (nalUnitHeaderFirstByte & 0x1F) == H264_NAL_UNIT_TYPE_SEI) || (MimeTypes.VIDEO_H265.equals(mimeType) - && ((nalUnitHeaderFirstByte & 0x7E) >> 1) == H265_NAL_UNIT_TYPE_PREFIX_SEI); + && ((nalUnitHeaderFirstByte & 0x7E) >> 1) == H265_NAL_UNIT_TYPE_PREFIX_SEI); } /** @@ -273,9 +270,16 @@ public final class NalUnitUtil { int chromaFormatIdc = 1; // Default is 4:2:0 boolean separateColorPlaneFlag = false; - if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 - || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 - || profileIdc == 128 || profileIdc == 138) { + if (profileIdc == 100 + || profileIdc == 110 + || profileIdc == 122 + || profileIdc == 244 + || profileIdc == 44 + || profileIdc == 83 + || profileIdc == 86 + || profileIdc == 118 + || profileIdc == 128 + || profileIdc == 138) { chromaFormatIdc = data.readUnsignedExpGolombCodedInt(); if (chromaFormatIdc == 3) { separateColorPlaneFlag = data.readBit(); @@ -403,16 +407,16 @@ public final class NalUnitUtil { /** * Finds the first NAL unit in {@code data}. - *

- * If {@code prefixFlags} is null then the first three bytes of a NAL unit must be entirely + * + *

If {@code prefixFlags} is null then the first three bytes of a NAL unit must be entirely * contained within the part of the array being searched in order for it to be found. - *

- * When {@code prefixFlags} is non-null, this method supports finding NAL units whose first four - * bytes span {@code data} arrays passed to successive calls. To use this feature, pass the same - * {@code prefixFlags} parameter to successive calls. State maintained in this parameter enables - * the detection of such NAL units. Note that when using this feature, the return value may be 3, - * 2 or 1 less than {@code startOffset}, to indicate a NAL unit starting 3, 2 or 1 bytes before - * the first byte in the current array. + * + *

When {@code prefixFlags} is non-null, this method supports finding NAL units whose first + * four bytes span {@code data} arrays passed to successive calls. To use this feature, pass the + * same {@code prefixFlags} parameter to successive calls. State maintained in this parameter + * enables the detection of such NAL units. Note that when using this feature, the return value + * may be 3, 2 or 1 less than {@code startOffset}, to indicate a NAL unit starting 3, 2 or 1 bytes + * before the first byte in the current array. * * @param data The data to search. * @param startOffset The offset (inclusive) in the data to start the search. @@ -422,8 +426,8 @@ public final class NalUnitUtil { * must be at least 3 elements long. * @return The offset of the NAL unit, or {@code endOffset} if a NAL unit was not found. */ - public static int findNalUnit(byte[] data, int startOffset, int endOffset, - boolean[] prefixFlags) { + public static int findNalUnit( + byte[] data, int startOffset, int endOffset, boolean[] prefixFlags) { int length = endOffset - startOffset; Assertions.checkState(length >= 0); @@ -515,5 +519,4 @@ public final class NalUnitUtil { private NalUnitUtil() { // Prevent instantiation. } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java index c14eee6f88..7efaa42c7a 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableBitArray.java @@ -89,16 +89,12 @@ public final class ParsableBitArray { byteLimit = limit; } - /** - * Returns the number of bits yet to be read. - */ + /** Returns the number of bits yet to be read. */ public int bitsLeft() { return (byteLimit - byteOffset) * 8 - bitOffset; } - /** - * Returns the current bit offset. - */ + /** Returns the current bit offset. */ public int getPosition() { return byteOffset * 8 + bitOffset; } @@ -124,9 +120,7 @@ public final class ParsableBitArray { assertValidOffset(); } - /** - * Skips a single bit. - */ + /** Skips a single bit. */ public void skipBit() { if (++bitOffset == 8) { bitOffset = 0; @@ -344,8 +338,7 @@ public final class ParsableBitArray { private void assertValidOffset() { // It is fine for position to be at the end of the array, but no further. - Assertions.checkState(byteOffset >= 0 - && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); + Assertions.checkState( + byteOffset >= 0 && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java index dff16d39f1..79913d2aa9 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableByteArray.java @@ -120,9 +120,7 @@ public final class ParsableByteArray { return limit - position; } - /** - * Returns the limit. - */ + /** Returns the limit. */ public int limit() { return limit; } @@ -137,9 +135,7 @@ public final class ParsableByteArray { this.limit = limit; } - /** - * Returns the current offset in the array, in bytes. - */ + /** Returns the current offset in the array, in bytes. */ public int getPosition() { return position; } @@ -186,8 +182,8 @@ public final class ParsableByteArray { } /** - * Reads the next {@code length} bytes into {@code bitArray}, and resets the position of - * {@code bitArray} to zero. + * Reads the next {@code length} bytes into {@code bitArray}, and resets the position of {@code + * bitArray} to zero. * * @param bitArray The {@link ParsableBitArray} into which the bytes should be read. * @param length The number of bytes to write. @@ -222,97 +218,70 @@ public final class ParsableByteArray { position += length; } - /** - * Peeks at the next byte as an unsigned value. - */ + /** Peeks at the next byte as an unsigned value. */ public int peekUnsignedByte() { return (data[position] & 0xFF); } - /** - * Peeks at the next char. - */ + /** Peeks at the next char. */ public char peekChar() { - return (char) ((data[position] & 0xFF) << 8 - | (data[position + 1] & 0xFF)); + return (char) ((data[position] & 0xFF) << 8 | (data[position + 1] & 0xFF)); } - /** - * Reads the next byte as an unsigned value. - */ + /** Reads the next byte as an unsigned value. */ public int readUnsignedByte() { return (data[position++] & 0xFF); } - /** - * Reads the next two bytes as an unsigned value. - */ + /** Reads the next two bytes as an unsigned value. */ public int readUnsignedShort() { - return (data[position++] & 0xFF) << 8 - | (data[position++] & 0xFF); + return (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF); } - /** - * Reads the next two bytes as an unsigned value. - */ + /** Reads the next two bytes as an unsigned value. */ public int readLittleEndianUnsignedShort() { return (data[position++] & 0xFF) | (data[position++] & 0xFF) << 8; } - /** - * Reads the next two bytes as a signed value. - */ + /** Reads the next two bytes as a signed value. */ public short readShort() { - return (short) ((data[position++] & 0xFF) << 8 - | (data[position++] & 0xFF)); + return (short) ((data[position++] & 0xFF) << 8 | (data[position++] & 0xFF)); } - /** - * Reads the next two bytes as a signed value. - */ + /** Reads the next two bytes as a signed value. */ public short readLittleEndianShort() { return (short) ((data[position++] & 0xFF) | (data[position++] & 0xFF) << 8); } - /** - * Reads the next three bytes as an unsigned value. - */ + /** Reads the next three bytes as an unsigned value. */ public int readUnsignedInt24() { return (data[position++] & 0xFF) << 16 | (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF); } - /** - * Reads the next three bytes as a signed value. - */ + /** Reads the next three bytes as a signed value. */ public int readInt24() { return ((data[position++] & 0xFF) << 24) >> 8 | (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF); } - /** - * Reads the next three bytes as a signed value in little endian order. - */ + /** Reads the next three bytes as a signed value in little endian order. */ public int readLittleEndianInt24() { return (data[position++] & 0xFF) | (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF) << 16; } - /** - * Reads the next three bytes as an unsigned value in little endian order. - */ + /** Reads the next three bytes as an unsigned value in little endian order. */ public int readLittleEndianUnsignedInt24() { return (data[position++] & 0xFF) | (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF) << 16; } - /** - * Reads the next four bytes as an unsigned value. - */ + /** Reads the next four bytes as an unsigned value. */ public long readUnsignedInt() { return (data[position++] & 0xFFL) << 24 | (data[position++] & 0xFFL) << 16 @@ -320,9 +289,7 @@ public final class ParsableByteArray { | (data[position++] & 0xFFL); } - /** - * Reads the next four bytes as an unsigned value in little endian order. - */ + /** Reads the next four bytes as an unsigned value in little endian order. */ public long readLittleEndianUnsignedInt() { return (data[position++] & 0xFFL) | (data[position++] & 0xFFL) << 8 @@ -330,9 +297,7 @@ public final class ParsableByteArray { | (data[position++] & 0xFFL) << 24; } - /** - * Reads the next four bytes as a signed value - */ + /** Reads the next four bytes as a signed value */ public int readInt() { return (data[position++] & 0xFF) << 24 | (data[position++] & 0xFF) << 16 @@ -340,9 +305,7 @@ public final class ParsableByteArray { | (data[position++] & 0xFF); } - /** - * Reads the next four bytes as a signed value in little endian order. - */ + /** Reads the next four bytes as a signed value in little endian order. */ public int readLittleEndianInt() { return (data[position++] & 0xFF) | (data[position++] & 0xFF) << 8 @@ -350,9 +313,7 @@ public final class ParsableByteArray { | (data[position++] & 0xFF) << 24; } - /** - * Reads the next eight bytes as a signed value. - */ + /** Reads the next eight bytes as a signed value. */ public long readLong() { return (data[position++] & 0xFFL) << 56 | (data[position++] & 0xFFL) << 48 @@ -364,9 +325,7 @@ public final class ParsableByteArray { | (data[position++] & 0xFFL); } - /** - * Reads the next eight bytes as a signed value in little endian order. - */ + /** Reads the next eight bytes as a signed value in little endian order. */ public long readLittleEndianLong() { return (data[position++] & 0xFFL) | (data[position++] & 0xFFL) << 8 @@ -378,20 +337,17 @@ public final class ParsableByteArray { | (data[position++] & 0xFFL) << 56; } - /** - * Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer. - */ + /** Reads the next four bytes, returning the integer portion of the fixed point 16.16 integer. */ public int readUnsignedFixedPoint1616() { - int result = (data[position++] & 0xFF) << 8 - | (data[position++] & 0xFF); + int result = (data[position++] & 0xFF) << 8 | (data[position++] & 0xFF); position += 2; // Skip the non-integer portion. return result; } /** * Reads a Synchsafe integer. - *

- * Synchsafe integers keep the highest bit of every byte zeroed. A 32 bit synchsafe integer can + * + *

Synchsafe integers keep the highest bit of every byte zeroed. A 32 bit synchsafe integer can * store 28 bits of information. * * @return The parsed value. @@ -444,16 +400,12 @@ public final class ParsableByteArray { return result; } - /** - * Reads the next four bytes as a 32-bit floating point value. - */ + /** Reads the next four bytes as a 32-bit floating point value. */ public float readFloat() { return Float.intBitsToFloat(readInt()); } - /** - * Reads the next eight bytes as a 64-bit floating point value. - */ + /** Reads the next eight bytes as a 64-bit floating point value. */ public double readDouble() { return Double.longBitsToDouble(readLong()); } @@ -555,8 +507,10 @@ public final class ParsableByteArray { while (lineLimit < limit && !Util.isLinebreak(data[lineLimit])) { lineLimit++; } - if (lineLimit - position >= 3 && data[position] == (byte) 0xEF - && data[position + 1] == (byte) 0xBB && data[position + 2] == (byte) 0xBF) { + if (lineLimit - position >= 3 + && data[position] == (byte) 0xEF + && data[position + 1] == (byte) 0xBB + && data[position + 2] == (byte) 0xBF) { // There's a UTF-8 byte order mark at the start of the line. Discard it. position += 3; } @@ -611,5 +565,4 @@ public final class ParsableByteArray { position += length; return value; } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java index 6738ed7b0e..46a532040e 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/ParsableNalUnitBitArray.java @@ -55,9 +55,7 @@ public final class ParsableNalUnitBitArray { assertValidOffset(); } - /** - * Skips a single bit. - */ + /** Skips a single bit. */ public void skipBit() { if (++bitOffset == 8) { bitOffset = 0; @@ -198,14 +196,16 @@ public final class ParsableNalUnitBitArray { } private boolean shouldSkipByte(int offset) { - return 2 <= offset && offset < byteLimit && data[offset] == (byte) 0x03 - && data[offset - 2] == (byte) 0x00 && data[offset - 1] == (byte) 0x00; + return 2 <= offset + && offset < byteLimit + && data[offset] == (byte) 0x03 + && data[offset - 2] == (byte) 0x00 + && data[offset - 1] == (byte) 0x00; } private void assertValidOffset() { // It is fine for position to be at the end of the array, but no further. - Assertions.checkState(byteOffset >= 0 - && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); + Assertions.checkState( + byteOffset >= 0 && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/RepeatModeUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/RepeatModeUtil.java index b58f83a9c6..26c586f9a4 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/RepeatModeUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/RepeatModeUtil.java @@ -35,13 +35,9 @@ public final class RepeatModeUtil { flag = true, value = {REPEAT_TOGGLE_MODE_NONE, REPEAT_TOGGLE_MODE_ONE, REPEAT_TOGGLE_MODE_ALL}) public @interface RepeatToggleModes {} - /** - * All repeat mode buttons disabled. - */ + /** All repeat mode buttons disabled. */ public static final int REPEAT_TOGGLE_MODE_NONE = 0; - /** - * "Repeat One" button enabled. - */ + /** "Repeat One" button enabled. */ public static final int REPEAT_TOGGLE_MODE_ONE = 1; /** "Repeat All" button enabled. */ public static final int REPEAT_TOGGLE_MODE_ALL = 1 << 1; // 2 @@ -57,8 +53,8 @@ public final class RepeatModeUtil { * @param enabledModes Bitmask of enabled modes. * @return The next repeat mode. */ - public static @Player.RepeatMode int getNextRepeatMode(@Player.RepeatMode int currentMode, - int enabledModes) { + public static @Player.RepeatMode int getNextRepeatMode( + @Player.RepeatMode int currentMode, int enabledModes) { for (int offset = 1; offset <= 2; offset++) { @Player.RepeatMode int proposedMode = (currentMode + offset) % 3; if (isRepeatModeEnabled(proposedMode, enabledModes)) { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/TraceUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/TraceUtil.java index df6ffd557c..87d63fcd06 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/TraceUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/TraceUtil.java @@ -56,5 +56,4 @@ public final class TraceUtil { private static void endSectionV18() { android.os.Trace.endSection(); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java index 07c7a0a776..97afa6a67d 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/Util.java @@ -126,23 +126,23 @@ public final class Util { */ public static final String MODEL = Build.MODEL; - /** - * A concise description of the device that it can be useful to log for debugging purposes. - */ - public static final String DEVICE_DEBUG_INFO = DEVICE + ", " + MODEL + ", " + MANUFACTURER + ", " - + SDK_INT; + /** A concise description of the device that it can be useful to log for debugging purposes. */ + public static final String DEVICE_DEBUG_INFO = + DEVICE + ", " + MODEL + ", " + MANUFACTURER + ", " + SDK_INT; /** An empty byte array. */ public static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; private static final String TAG = "Util"; - private static final Pattern XS_DATE_TIME_PATTERN = Pattern.compile( - "(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]" - + "(\\d\\d):(\\d\\d):(\\d\\d)([\\.,](\\d+))?" - + "([Zz]|((\\+|\\-)(\\d?\\d):?(\\d\\d)))?"); + private static final Pattern XS_DATE_TIME_PATTERN = + Pattern.compile( + "(\\d\\d\\d\\d)\\-(\\d\\d)\\-(\\d\\d)[Tt]" + + "(\\d\\d):(\\d\\d):(\\d\\d)([\\.,](\\d+))?" + + "([Zz]|((\\+|\\-)(\\d?\\d):?(\\d\\d)))?"); private static final Pattern XS_DURATION_PATTERN = - Pattern.compile("^(-)?P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?" - + "(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"); + Pattern.compile( + "^(-)?P(([0-9]*)Y)?(([0-9]*)M)?(([0-9]*)D)?" + + "(T(([0-9]*)H)?(([0-9]*)M)?(([0-9.]*)S)?)?$"); private static final Pattern ESCAPED_CHARACTER_PATTERN = Pattern.compile("%([A-Fa-f0-9]{2})"); // https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-deliver-content-overview#URLs. @@ -930,8 +930,8 @@ public final class Util { /** * Returns the index of the largest element in {@code array} that is less than (or optionally * equal to) a specified {@code value}. - *

- * The search is performed using a binary search algorithm, so the array must be sorted. If the + * + *

The search is performed using a binary search algorithm, so the array must be sorted. If the * array contains multiple elements equal to {@code value} and {@code inclusive} is true, the * index of the first one will be returned. * @@ -945,8 +945,8 @@ public final class Util { * @return The index of the largest element in {@code array} that is less than (or optionally * equal to) {@code value}. */ - public static int binarySearchFloor(long[] array, long value, boolean inclusive, - boolean stayInBounds) { + public static int binarySearchFloor( + long[] array, long value, boolean inclusive, boolean stayInBounds) { int index = Arrays.binarySearch(array, value); if (index < 0) { index = -(index + 2); @@ -1226,8 +1226,8 @@ public final class Util { } else if (matcher.group(9).equalsIgnoreCase("Z")) { timezoneShift = 0; } else { - timezoneShift = ((Integer.parseInt(matcher.group(12)) * 60 - + Integer.parseInt(matcher.group(13)))); + timezoneShift = + ((Integer.parseInt(matcher.group(12)) * 60 + Integer.parseInt(matcher.group(13)))); if ("-".equals(matcher.group(11))) { timezoneShift *= -1; } @@ -1237,12 +1237,13 @@ public final class Util { dateTime.clear(); // Note: The month value is 0-based, hence the -1 on group(2) - dateTime.set(Integer.parseInt(matcher.group(1)), - Integer.parseInt(matcher.group(2)) - 1, - Integer.parseInt(matcher.group(3)), - Integer.parseInt(matcher.group(4)), - Integer.parseInt(matcher.group(5)), - Integer.parseInt(matcher.group(6))); + dateTime.set( + Integer.parseInt(matcher.group(1)), + Integer.parseInt(matcher.group(2)) - 1, + Integer.parseInt(matcher.group(3)), + Integer.parseInt(matcher.group(4)), + Integer.parseInt(matcher.group(5)), + Integer.parseInt(matcher.group(6))); if (!TextUtils.isEmpty(matcher.group(8))) { final BigDecimal bd = new BigDecimal("0." + matcher.group(8)); // we care only for milliseconds, so movePointRight(3) @@ -1259,9 +1260,9 @@ public final class Util { /** * Scales a large timestamp. - *

- * Logically, scaling consists of a multiplication followed by a division. The actual operations - * performed are designed to minimize the probability of overflow. + * + *

Logically, scaling consists of a multiplication followed by a division. The actual + * operations performed are designed to minimize the probability of overflow. * * @param timestamp The timestamp to scale. * @param multiplier The multiplier. @@ -1431,8 +1432,10 @@ public final class Util { byte[] data = new byte[hexString.length() / 2]; for (int i = 0; i < data.length; i++) { int stringOffset = i * 2; - data[i] = (byte) ((Character.digit(hexString.charAt(stringOffset), 16) << 4) - + Character.digit(hexString.charAt(stringOffset + 1), 16)); + data[i] = + (byte) + ((Character.digit(hexString.charAt(stringOffset), 16) << 4) + + Character.digit(hexString.charAt(stringOffset + 1), 16)); } return data; } @@ -1486,8 +1489,13 @@ public final class Util { } catch (NameNotFoundException e) { versionName = "?"; } - return applicationName + "/" + versionName + " (Linux;Android " + Build.VERSION.RELEASE - + ") " + ExoPlayerLibraryInfo.VERSION_SLASHY; + return applicationName + + "/" + + versionName + + " (Linux;Android " + + Build.VERSION.RELEASE + + ") " + + ExoPlayerLibraryInfo.VERSION_SLASHY; } /** Returns the number of codec strings in {@code codecs} whose type matches {@code trackType}. */ @@ -1676,9 +1684,7 @@ public final class Util { } } - /** - * Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}. - */ + /** Returns the {@link C.AudioUsage} corresponding to the specified {@link C.StreamType}. */ @C.AudioUsage public static int getAudioUsageForStreamType(@C.StreamType int streamType) { switch (streamType) { @@ -1700,9 +1706,7 @@ public final class Util { } } - /** - * Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}. - */ + /** Returns the {@link C.AudioContentType} corresponding to the specified {@link C.StreamType}. */ @C.AudioContentType public static int getAudioContentTypeForStreamType(@C.StreamType int streamType) { switch (streamType) { @@ -1720,9 +1724,7 @@ public final class Util { } } - /** - * Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}. - */ + /** Returns the {@link C.StreamType} corresponding to the specified {@link C.AudioUsage}. */ @C.StreamType public static int getStreamTypeForAudioUsage(@C.AudioUsage int usage) { switch (usage) { @@ -1932,10 +1934,10 @@ public final class Util { * Escapes a string so that it's safe for use as a file or directory name on at least FAT32 * filesystems. FAT32 is the most restrictive of all filesystems still commonly used today. * - *

For simplicity, this only handles common characters known to be illegal on FAT32: - * <, >, :, ", /, \, |, ?, and *. % is also escaped since it is used as the escape - * character. Escaping is performed in a consistent way so that no collisions occur and - * {@link #unescapeFileName(String)} can be used to retrieve the original file name. + *

For simplicity, this only handles common characters known to be illegal on FAT32: <, + * >, :, ", /, \, |, ?, and *. % is also escaped since it is used as the escape character. + * Escaping is performed in a consistent way so that no collisions occur and {@link + * #unescapeFileName(String)} can be used to retrieve the original file name. * * @param fileName File name to be escaped. * @return An escaped file name which will be safe for use on at least FAT32 filesystems. @@ -2034,8 +2036,8 @@ public final class Util { } /** - * A hacky method that always throws {@code t} even if {@code t} is a checked exception, - * and is not declared to be thrown. + * A hacky method that always throws {@code t} even if {@code t} is a checked exception, and is + * not declared to be thrown. */ public static void sneakyThrow(Throwable t) { sneakyThrowInternal(t); @@ -2082,8 +2084,9 @@ public final class Util { */ public static int crc32(byte[] bytes, int start, int end, int initialValue) { for (int i = start; i < end; i++) { - initialValue = (initialValue << 8) - ^ CRC32_BYTES_MSBF[((initialValue >>> 24) ^ (bytes[i] & 0xFF)) & 0xFF]; + initialValue = + (initialValue << 8) + ^ CRC32_BYTES_MSBF[((initialValue >>> 24) ^ (bytes[i] & 0xFF)) & 0xFF]; } return initialValue; } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java b/library/common/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java index 975b66f093..94b29a83b6 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java @@ -66,8 +66,9 @@ public final class AvcConfig { @Nullable String codecs = null; if (numSequenceParameterSets > 0) { byte[] sps = initializationData.get(0); - SpsData spsData = NalUnitUtil.parseSpsNalUnit(initializationData.get(0), - nalUnitLengthFieldLength, sps.length); + SpsData spsData = + NalUnitUtil.parseSpsNalUnit( + initializationData.get(0), nalUnitLengthFieldLength, sps.length); width = spsData.width; height = spsData.height; pixelWidthAspectRatio = spsData.pixelWidthAspectRatio; @@ -109,5 +110,4 @@ public final class AvcConfig { data.skipBytes(length); return CodecSpecificDataUtil.buildNalUnit(data.getData(), offset, length); } - } diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java b/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java index 6d66c91f6c..4afa4d6f91 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/video/ColorInfo.java @@ -30,15 +30,13 @@ public final class ColorInfo implements Parcelable { * The color space of the video. Valid values are {@link C#COLOR_SPACE_BT601}, {@link * C#COLOR_SPACE_BT709}, {@link C#COLOR_SPACE_BT2020} or {@link Format#NO_VALUE} if unknown. */ - @C.ColorSpace - public final int colorSpace; + @C.ColorSpace public final int colorSpace; /** * The color range of the video. Valid values are {@link C#COLOR_RANGE_LIMITED}, {@link * C#COLOR_RANGE_FULL} or {@link Format#NO_VALUE} if unknown. */ - @C.ColorRange - public final int colorRange; + @C.ColorRange public final int colorRange; /** * The color transfer characteristics of the video. Valid values are {@link C#COLOR_TRANSFER_HLG}, @@ -99,8 +97,15 @@ public final class ColorInfo implements Parcelable { @Override public String toString() { - return "ColorInfo(" + colorSpace + ", " + colorRange + ", " + colorTransfer - + ", " + (hdrStaticInfo != null) + ")"; + return "ColorInfo(" + + colorSpace + + ", " + + colorRange + + ", " + + colorTransfer + + ", " + + (hdrStaticInfo != null) + + ")"; } @Override diff --git a/library/common/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java b/library/common/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java index c058457665..2abc2f8644 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java @@ -64,7 +64,11 @@ public final class HevcConfig { int numberOfNalUnits = data.readUnsignedShort(); for (int j = 0; j < numberOfNalUnits; j++) { int nalUnitLength = data.readUnsignedShort(); - System.arraycopy(NalUnitUtil.NAL_START_CODE, 0, buffer, bufferPosition, + System.arraycopy( + NalUnitUtil.NAL_START_CODE, + 0, + buffer, + bufferPosition, NalUnitUtil.NAL_START_CODE.length); bufferPosition += NalUnitUtil.NAL_START_CODE.length; System.arraycopy( @@ -116,5 +120,4 @@ public final class HevcConfig { this.nalUnitLengthFieldLength = nalUnitLengthFieldLength; this.codecs = codecs; } - } diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java index ed06eb0aff..d5fe793ac1 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageDecoderTest.java @@ -50,7 +50,7 @@ public final class EventMessageDecoderTest { assertThat(eventMessage.value).isEqualTo("123"); assertThat(eventMessage.durationMs).isEqualTo(3000); assertThat(eventMessage.id).isEqualTo(1000403); - assertThat(eventMessage.messageData).isEqualTo(new byte[]{0, 1, 2, 3, 4}); + assertThat(eventMessage.messageData).isEqualTo(new byte[] {0, 1, 2, 3, 4}); } @Test diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java index 9a47b81d44..536392f85e 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/emsg/EventMessageTest.java @@ -39,5 +39,4 @@ public final class EventMessageTest { // Assert equals. assertThat(fromParcelEventMessage).isEqualTo(eventMessage); } - } diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java index f3e883833a..25d6ceb780 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterFrameTest.java @@ -28,10 +28,11 @@ public final class ChapterFrameTest { @Test public void parcelable() { - Id3Frame[] subFrames = new Id3Frame[] { - new TextInformationFrame("TIT2", null, "title"), - new UrlLinkFrame("WXXX", "description", "url") - }; + Id3Frame[] subFrames = + new Id3Frame[] { + new TextInformationFrame("TIT2", null, "title"), + new UrlLinkFrame("WXXX", "description", "url") + }; ChapterFrame chapterFrameToParcel = new ChapterFrame("id", 0, 1, 2, 3, subFrames); Parcel parcel = Parcel.obtain(); @@ -43,5 +44,4 @@ public final class ChapterFrameTest { parcel.recycle(); } - } diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java index 0b4a9859c9..f0f8b41b70 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/ChapterTocFrameTest.java @@ -29,12 +29,13 @@ public final class ChapterTocFrameTest { @Test public void parcelable() { String[] children = new String[] {"child0", "child1"}; - Id3Frame[] subFrames = new Id3Frame[] { - new TextInformationFrame("TIT2", null, "title"), - new UrlLinkFrame("WXXX", "description", "url") - }; - ChapterTocFrame chapterTocFrameToParcel = new ChapterTocFrame("id", false, true, children, - subFrames); + Id3Frame[] subFrames = + new Id3Frame[] { + new TextInformationFrame("TIT2", null, "title"), + new UrlLinkFrame("WXXX", "description", "url") + }; + ChapterTocFrame chapterTocFrameToParcel = + new ChapterTocFrame("id", false, true, children, subFrames); Parcel parcel = Parcel.obtain(); chapterTocFrameToParcel.writeToParcel(parcel, 0); @@ -45,5 +46,4 @@ public final class ChapterTocFrameTest { parcel.recycle(); } - } diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java index 972e855a5b..f08b8f8740 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/Id3DecoderTest.java @@ -38,8 +38,13 @@ public final class Id3DecoderTest { @Test public void decodeTxxxFrame() { - byte[] rawId3 = buildSingleFrameTag("TXXX", new byte[] {3, 0, 109, 100, 105, 97, 108, 111, 103, - 95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0}); + byte[] rawId3 = + buildSingleFrameTag( + "TXXX", + new byte[] { + 3, 0, 109, 100, 105, 97, 108, 111, 103, 95, 86, 73, 78, 68, 73, 67, 79, 49, 53, 50, + 55, 54, 54, 52, 95, 115, 116, 97, 114, 116, 0 + }); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); @@ -65,8 +70,9 @@ public final class Id3DecoderTest { @Test public void decodeTextInformationFrame() { - byte[] rawId3 = buildSingleFrameTag("TIT2", new byte[] {3, 72, 101, 108, 108, 111, 32, 87, 111, - 114, 108, 100, 0}); + byte[] rawId3 = + buildSingleFrameTag( + "TIT2", new byte[] {3, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0}); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); @@ -92,9 +98,41 @@ public final class Id3DecoderTest { @Test public void decodeWxxxFrame() { - byte[] rawId3 = buildSingleFrameTag("WXXX", new byte[] {ID3_TEXT_ENCODING_UTF_8, 116, 101, 115, - 116, 0, 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, - 98, 99, 63, 100, 101, 102}); + byte[] rawId3 = + buildSingleFrameTag( + "WXXX", + new byte[] { + ID3_TEXT_ENCODING_UTF_8, + 116, + 101, + 115, + 116, + 0, + 104, + 116, + 116, + 112, + 115, + 58, + 47, + 47, + 116, + 101, + 115, + 116, + 46, + 99, + 111, + 109, + 47, + 97, + 98, + 99, + 63, + 100, + 101, + 102 + }); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); @@ -120,8 +158,13 @@ public final class Id3DecoderTest { @Test public void decodeUrlLinkFrame() { - byte[] rawId3 = buildSingleFrameTag("WCOM", new byte[] {104, 116, 116, 112, 115, 58, 47, 47, - 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, 99, 63, 100, 101, 102}); + byte[] rawId3 = + buildSingleFrameTag( + "WCOM", + new byte[] { + 104, 116, 116, 112, 115, 58, 47, 47, 116, 101, 115, 116, 46, 99, 111, 109, 47, 97, 98, + 99, 63, 100, 101, 102 + }); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); @@ -148,7 +191,7 @@ public final class Id3DecoderTest { assertThat(metadata.length()).isEqualTo(1); PrivFrame privFrame = (PrivFrame) metadata.get(0); assertThat(privFrame.owner).isEqualTo("test"); - assertThat(privFrame.privateData).isEqualTo(new byte[]{1, 2, 3, 4}); + assertThat(privFrame.privateData).isEqualTo(new byte[] {1, 2, 3, 4}); // Test empty. rawId3 = buildSingleFrameTag("PRIV", new byte[0]); @@ -161,9 +204,13 @@ public final class Id3DecoderTest { @Test public void decodeApicFrame() { - byte[] rawId3 = buildSingleFrameTag("APIC", new byte[] {3, 105, 109, 97, 103, 101, 47, 106, 112, - 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 0}); + byte[] rawId3 = + buildSingleFrameTag( + "APIC", + new byte[] { + 3, 105, 109, 97, 103, 101, 47, 106, 112, 101, 103, 0, 16, 72, 101, 108, 108, 111, 32, + 87, 111, 114, 108, 100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 + }); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); @@ -172,13 +219,37 @@ public final class Id3DecoderTest { assertThat(apicFrame.pictureType).isEqualTo(16); assertThat(apicFrame.description).isEqualTo("Hello World"); assertThat(apicFrame.pictureData).hasLength(10); - assertThat(apicFrame.pictureData).isEqualTo(new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 0}); + assertThat(apicFrame.pictureData).isEqualTo(new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}); } @Test public void decodeCommentFrame() { - byte[] rawId3 = buildSingleFrameTag("COMM", new byte[] {ID3_TEXT_ENCODING_UTF_8, 101, 110, 103, - 100, 101, 115, 99, 114, 105, 112, 116, 105, 111, 110, 0, 116, 101, 120, 116, 0}); + byte[] rawId3 = + buildSingleFrameTag( + "COMM", + new byte[] { + ID3_TEXT_ENCODING_UTF_8, + 101, + 110, + 103, + 100, + 101, + 115, + 99, + 114, + 105, + 112, + 116, + 105, + 111, + 110, + 0, + 116, + 101, + 120, + 116, + 0 + }); Id3Decoder decoder = new Id3Decoder(); Metadata metadata = decoder.decode(rawId3, rawId3.length); assertThat(metadata.length()).isEqualTo(1); diff --git a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java index 48e8fcede3..c42bd61e93 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/metadata/id3/MlltFrameTest.java @@ -45,5 +45,4 @@ public final class MlltFrameTest { parcel.recycle(); } - } diff --git a/library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java b/library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java index fe081a99db..4d9fc89a03 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java @@ -29,9 +29,10 @@ public final class NalUnitUtilTest { private static final int TEST_PARTIAL_NAL_POSITION = 4; private static final int TEST_NAL_POSITION = 10; - private static final byte[] SPS_TEST_DATA = createByteArray(0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, - 0x16, 0xEC, 0xA0, 0x50, 0x17, 0xFC, 0xB8, 0x08, 0x80, 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, - 0x00, 0x0F, 0x47, 0x8B, 0x16, 0xCB); + private static final byte[] SPS_TEST_DATA = + createByteArray( + 0x00, 0x00, 0x01, 0x67, 0x4D, 0x40, 0x16, 0xEC, 0xA0, 0x50, 0x17, 0xFC, 0xB8, 0x08, 0x80, + 0x00, 0x00, 0x03, 0x00, 0x80, 0x00, 0x00, 0x0F, 0x47, 0x8B, 0x16, 0xCB); private static final int SPS_TEST_DATA_OFFSET = 3; @Test @@ -121,8 +122,8 @@ public final class NalUnitUtilTest { @Test public void parseSpsNalUnit() { - NalUnitUtil.SpsData data = NalUnitUtil.parseSpsNalUnit(SPS_TEST_DATA, SPS_TEST_DATA_OFFSET, - SPS_TEST_DATA.length); + NalUnitUtil.SpsData data = + NalUnitUtil.parseSpsNalUnit(SPS_TEST_DATA, SPS_TEST_DATA_OFFSET, SPS_TEST_DATA.length); assertThat(data.width).isEqualTo(640); assertThat(data.height).isEqualTo(360); assertThat(data.deltaPicOrderAlwaysZeroFlag).isFalse(); diff --git a/library/common/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java b/library/common/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java index 444e5f7b46..fbf0368c9f 100644 --- a/library/common/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java +++ b/library/common/src/test/java/com/google/android/exoplayer2/util/ParsableByteArrayTest.java @@ -79,8 +79,8 @@ public final class ParsableByteArrayTest { } private static void testReadShort(short testValue) { - ParsableByteArray testArray = new ParsableByteArray( - ByteBuffer.allocate(4).putShort(testValue).array()); + ParsableByteArray testArray = + new ParsableByteArray(ByteBuffer.allocate(4).putShort(testValue).array()); int readValue = testArray.readShort(); // Assert that the value we read was the value we wrote. @@ -105,8 +105,8 @@ public final class ParsableByteArrayTest { } private static void testReadInt(int testValue) { - ParsableByteArray testArray = new ParsableByteArray( - ByteBuffer.allocate(4).putInt(testValue).array()); + ParsableByteArray testArray = + new ParsableByteArray(ByteBuffer.allocate(4).putInt(testValue).array()); int readValue = testArray.readInt(); // Assert that the value we read was the value we wrote. @@ -131,8 +131,9 @@ public final class ParsableByteArrayTest { } private static void testReadUnsignedInt(long testValue) { - ParsableByteArray testArray = new ParsableByteArray( - Arrays.copyOfRange(ByteBuffer.allocate(8).putLong(testValue).array(), 4, 8)); + ParsableByteArray testArray = + new ParsableByteArray( + Arrays.copyOfRange(ByteBuffer.allocate(8).putLong(testValue).array(), 4, 8)); long readValue = testArray.readUnsignedInt(); // Assert that the value we read was the value we wrote. @@ -167,8 +168,8 @@ public final class ParsableByteArrayTest { } private static void testReadUnsignedIntToInt(int testValue) { - ParsableByteArray testArray = new ParsableByteArray( - ByteBuffer.allocate(4).putInt(testValue).array()); + ParsableByteArray testArray = + new ParsableByteArray(ByteBuffer.allocate(4).putInt(testValue).array()); int readValue = testArray.readUnsignedIntToInt(); // Assert that the value we read was the value we wrote. @@ -203,8 +204,8 @@ public final class ParsableByteArrayTest { } private static void testReadUnsignedLongToLong(long testValue) { - ParsableByteArray testArray = new ParsableByteArray( - ByteBuffer.allocate(8).putLong(testValue).array()); + ParsableByteArray testArray = + new ParsableByteArray(ByteBuffer.allocate(8).putLong(testValue).array()); long readValue = testArray.readUnsignedLongToLong(); // Assert that the value we read was the value we wrote. @@ -229,8 +230,8 @@ public final class ParsableByteArrayTest { } private static void testReadLong(long testValue) { - ParsableByteArray testArray = new ParsableByteArray( - ByteBuffer.allocate(8).putLong(testValue).array()); + ParsableByteArray testArray = + new ParsableByteArray(ByteBuffer.allocate(8).putLong(testValue).array()); long readValue = testArray.readLong(); // Assert that the value we read was the value we wrote. @@ -327,28 +328,22 @@ public final class ParsableByteArrayTest { @Test public void readLittleEndianLong() { - ParsableByteArray byteArray = new ParsableByteArray(new byte[] { - 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, (byte) 0xFF - }); + ParsableByteArray byteArray = + new ParsableByteArray(new byte[] {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, (byte) 0xFF}); assertThat(byteArray.readLittleEndianLong()).isEqualTo(0xFF00000000000001L); assertThat(byteArray.getPosition()).isEqualTo(8); } @Test public void readLittleEndianUnsignedInt() { - ParsableByteArray byteArray = new ParsableByteArray(new byte[] { - 0x10, 0x00, 0x00, (byte) 0xFF - }); + ParsableByteArray byteArray = new ParsableByteArray(new byte[] {0x10, 0x00, 0x00, (byte) 0xFF}); assertThat(byteArray.readLittleEndianUnsignedInt()).isEqualTo(0xFF000010L); assertThat(byteArray.getPosition()).isEqualTo(4); } @Test public void readLittleEndianInt() { - ParsableByteArray byteArray = new ParsableByteArray(new byte[] { - 0x01, 0x00, 0x00, (byte) 0xFF - }); + ParsableByteArray byteArray = new ParsableByteArray(new byte[] {0x01, 0x00, 0x00, (byte) 0xFF}); assertThat(byteArray.readLittleEndianInt()).isEqualTo(0xFF000001); assertThat(byteArray.getPosition()).isEqualTo(4); } @@ -379,9 +374,8 @@ public final class ParsableByteArrayTest { @Test public void readLittleEndianUnsignedShort() { - ParsableByteArray byteArray = new ParsableByteArray(new byte[] { - 0x01, (byte) 0xFF, 0x02, (byte) 0xFF - }); + ParsableByteArray byteArray = + new ParsableByteArray(new byte[] {0x01, (byte) 0xFF, 0x02, (byte) 0xFF}); assertThat(byteArray.readLittleEndianUnsignedShort()).isEqualTo(0xFF01); assertThat(byteArray.getPosition()).isEqualTo(2); assertThat(byteArray.readLittleEndianUnsignedShort()).isEqualTo(0xFF02); @@ -390,9 +384,8 @@ public final class ParsableByteArrayTest { @Test public void readLittleEndianShort() { - ParsableByteArray byteArray = new ParsableByteArray(new byte[] { - 0x01, (byte) 0xFF, 0x02, (byte) 0xFF - }); + ParsableByteArray byteArray = + new ParsableByteArray(new byte[] {0x01, (byte) 0xFF, 0x02, (byte) 0xFF}); assertThat(byteArray.readLittleEndianShort()).isEqualTo((short) 0xFF01); assertThat(byteArray.getPosition()).isEqualTo(2); assertThat(byteArray.readLittleEndianShort()).isEqualTo((short) 0xFF02); @@ -402,13 +395,29 @@ public final class ParsableByteArrayTest { @Test public void readString() { byte[] data = { - (byte) 0xC3, (byte) 0xA4, (byte) 0x20, - (byte) 0xC3, (byte) 0xB6, (byte) 0x20, - (byte) 0xC2, (byte) 0xAE, (byte) 0x20, - (byte) 0xCF, (byte) 0x80, (byte) 0x20, - (byte) 0xE2, (byte) 0x88, (byte) 0x9A, (byte) 0x20, - (byte) 0xC2, (byte) 0xB1, (byte) 0x20, - (byte) 0xE8, (byte) 0xB0, (byte) 0xA2, (byte) 0x20, + (byte) 0xC3, + (byte) 0xA4, + (byte) 0x20, + (byte) 0xC3, + (byte) 0xB6, + (byte) 0x20, + (byte) 0xC2, + (byte) 0xAE, + (byte) 0x20, + (byte) 0xCF, + (byte) 0x80, + (byte) 0x20, + (byte) 0xE2, + (byte) 0x88, + (byte) 0x9A, + (byte) 0x20, + (byte) 0xC2, + (byte) 0xB1, + (byte) 0x20, + (byte) 0xE8, + (byte) 0xB0, + (byte) 0xA2, + (byte) 0x20, }; ParsableByteArray byteArray = new ParsableByteArray(data); assertThat(byteArray.readString(data.length)).isEqualTo("ä ö ® π √ ± 谢 "); @@ -425,9 +434,7 @@ public final class ParsableByteArrayTest { @Test public void readStringOutOfBoundsDoesNotMovePosition() { - byte[] data = { - (byte) 0xC3, (byte) 0xA4, (byte) 0x20 - }; + byte[] data = {(byte) 0xC3, (byte) 0xA4, (byte) 0x20}; ParsableByteArray byteArray = new ParsableByteArray(data); try { byteArray.readString(data.length + 1); @@ -446,9 +453,7 @@ public final class ParsableByteArrayTest { @Test public void readNullTerminatedStringWithLengths() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', 0, 'b', 'a', 'r', 0 - }; + byte[] bytes = new byte[] {'f', 'o', 'o', 0, 'b', 'a', 'r', 0}; // Test with lengths that match NUL byte positions. ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readNullTerminatedString(4)).isEqualTo("foo"); @@ -481,9 +486,7 @@ public final class ParsableByteArrayTest { @Test public void readNullTerminatedString() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', 0, 'b', 'a', 'r', 0 - }; + byte[] bytes = new byte[] {'f', 'o', 'o', 0, 'b', 'a', 'r', 0}; // Test normal case. ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readNullTerminatedString()).isEqualTo("foo"); @@ -505,9 +508,7 @@ public final class ParsableByteArrayTest { @Test public void readNullTerminatedStringWithoutEndingNull() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', 0, 'b', 'a', 'r' - }; + byte[] bytes = new byte[] {'f', 'o', 'o', 0, 'b', 'a', 'r'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readNullTerminatedString()).isEqualTo("foo"); assertThat(parser.readNullTerminatedString()).isEqualTo("bar"); @@ -548,9 +549,7 @@ public final class ParsableByteArrayTest { @Test public void readSingleLineWithoutEndingTrail() { - byte[] bytes = new byte[] { - 'f', 'o', 'o' - }; + byte[] bytes = new byte[] {'f', 'o', 'o'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readLine()).isEqualTo("foo"); assertThat(parser.readLine()).isNull(); @@ -558,9 +557,7 @@ public final class ParsableByteArrayTest { @Test public void readSingleLineWithEndingLf() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', '\n' - }; + byte[] bytes = new byte[] {'f', 'o', 'o', '\n'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readLine()).isEqualTo("foo"); assertThat(parser.readLine()).isNull(); @@ -568,9 +565,7 @@ public final class ParsableByteArrayTest { @Test public void readTwoLinesWithCrFollowedByLf() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', '\r', '\n', 'b', 'a', 'r' - }; + byte[] bytes = new byte[] {'f', 'o', 'o', '\r', '\n', 'b', 'a', 'r'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readLine()).isEqualTo("foo"); assertThat(parser.readLine()).isEqualTo("bar"); @@ -579,9 +574,7 @@ public final class ParsableByteArrayTest { @Test public void readThreeLinesWithEmptyLine() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', '\r', '\n', '\r', 'b', 'a', 'r' - }; + byte[] bytes = new byte[] {'f', 'o', 'o', '\r', '\n', '\r', 'b', 'a', 'r'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readLine()).isEqualTo("foo"); assertThat(parser.readLine()).isEqualTo(""); @@ -591,9 +584,7 @@ public final class ParsableByteArrayTest { @Test public void readFourLinesWithLfFollowedByCr() { - byte[] bytes = new byte[] { - 'f', 'o', 'o', '\n', '\r', '\r', 'b', 'a', 'r', '\r', '\n' - }; + byte[] bytes = new byte[] {'f', 'o', 'o', '\n', '\r', '\r', 'b', 'a', 'r', '\r', '\n'}; ParsableByteArray parser = new ParsableByteArray(bytes); assertThat(parser.readLine()).isEqualTo("foo"); assertThat(parser.readLine()).isEqualTo(""); @@ -601,5 +592,4 @@ public final class ParsableByteArrayTest { assertThat(parser.readLine()).isEqualTo("bar"); assertThat(parser.readLine()).isNull(); } - } diff --git a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java index b59a6e1618..3b65c2c84e 100644 --- a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java +++ b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/ContentDataSourceTest.java @@ -90,8 +90,11 @@ public final class ContentDataSourceTest { DataSpec dataSpec = new DataSpec(contentUri, offset, length); byte[] completeData = TestUtil.getByteArray(ApplicationProvider.getApplicationContext(), DATA_PATH); - byte[] expectedData = Arrays.copyOfRange(completeData, offset, - length == C.LENGTH_UNSET ? completeData.length : offset + length); + byte[] expectedData = + Arrays.copyOfRange( + completeData, + offset, + length == C.LENGTH_UNSET ? completeData.length : offset + length); TestUtil.assertDataSourceContent(dataSource, dataSpec, expectedData, !pipeMode); } finally { dataSource.close(); diff --git a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestContentProvider.java b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestContentProvider.java index a7ddd7118e..c259d2f7b7 100644 --- a/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestContentProvider.java +++ b/library/core/src/androidTest/java/com/google/android/exoplayer2/upstream/TestContentProvider.java @@ -123,5 +123,4 @@ public final class TestContentProvider extends ContentProvider private static String getFileName(Uri uri) { return uri.getPath().replaceFirst("/", ""); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java index 198244d9fe..c254777669 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java @@ -45,8 +45,8 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { private boolean throwRendererExceptionIsExecuting; /** - * @param trackType The track type that the renderer handles. One of the {@link C} - * {@code TRACK_TYPE_*} constants. + * @param trackType The track type that the renderer handles. One of the {@link C} {@code + * TRACK_TYPE_*} constants. */ public BaseRenderer(int trackType) { this.trackType = trackType; @@ -253,8 +253,8 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { /** * Called when the renderer is started. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. * * @throws ExoPlaybackException If an error occurs. */ @@ -273,8 +273,8 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { /** * Called when the renderer is disabled. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. */ protected void onDisabled() { // Do nothing. @@ -325,9 +325,7 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities { return Assertions.checkNotNull(configuration); } - /** - * Returns the index of the renderer within the player. - */ + /** Returns the index of the renderer within the player. */ protected final int getIndex() { return index; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/DefaultMediaClock.java b/library/core/src/main/java/com/google/android/exoplayer2/DefaultMediaClock.java index 9ee1846fc1..412a6fdbff 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/DefaultMediaClock.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/DefaultMediaClock.java @@ -22,8 +22,8 @@ import com.google.android.exoplayer2.util.MediaClock; import com.google.android.exoplayer2.util.StandaloneMediaClock; /** - * Default {@link MediaClock} which uses a renderer media clock and falls back to a - * {@link StandaloneMediaClock} if necessary. + * Default {@link MediaClock} which uses a renderer media clock and falls back to a {@link + * StandaloneMediaClock} if necessary. */ /* package */ final class DefaultMediaClock implements MediaClock { @@ -60,17 +60,13 @@ import com.google.android.exoplayer2.util.StandaloneMediaClock; isUsingStandaloneClock = true; } - /** - * Starts the standalone fallback clock. - */ + /** Starts the standalone fallback clock. */ public void start() { standaloneClockIsStarted = true; standaloneClock.start(); } - /** - * Stops the standalone fallback clock. - */ + /** Stops the standalone fallback clock. */ public void stop() { standaloneClockIsStarted = false; standaloneClock.stop(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/DefaultRenderersFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/DefaultRenderersFactory.java index a9337953ab..d4284842df 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/DefaultRenderersFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/DefaultRenderersFactory.java @@ -61,15 +61,13 @@ public class DefaultRenderersFactory implements RenderersFactory { @Retention(RetentionPolicy.SOURCE) @IntDef({EXTENSION_RENDERER_MODE_OFF, EXTENSION_RENDERER_MODE_ON, EXTENSION_RENDERER_MODE_PREFER}) public @interface ExtensionRendererMode {} - /** - * Do not allow use of extension renderers. - */ + /** Do not allow use of extension renderers. */ public static final int EXTENSION_RENDERER_MODE_OFF = 0; /** * Allow use of extension renderers. Extension renderers are indexed after core renderers of the * same type. A {@link TrackSelector} that prefers the first suitable renderer will therefore - * prefer to use a core renderer to an extension renderer in the case that both are able to play - * a given track. + * prefer to use a core renderer to an extension renderer in the case that both are able to play a + * given track. */ public static final int EXTENSION_RENDERER_MODE_ON = 1; /** @@ -331,10 +329,18 @@ public class DefaultRenderersFactory implements RenderersFactory { audioRendererEventListener, renderersList); } - buildTextRenderers(context, textRendererOutput, eventHandler.getLooper(), - extensionRendererMode, renderersList); - buildMetadataRenderers(context, metadataRendererOutput, eventHandler.getLooper(), - extensionRendererMode, renderersList); + buildTextRenderers( + context, + textRendererOutput, + eventHandler.getLooper(), + extensionRendererMode, + renderersList); + buildMetadataRenderers( + context, + metadataRendererOutput, + eventHandler.getLooper(), + extensionRendererMode, + renderersList); buildCameraMotionRenderers(context, extensionRendererMode, renderersList); buildMiscellaneousRenderers(context, eventHandler, extensionRendererMode, renderersList); return renderersList.toArray(new Renderer[0]); @@ -626,8 +632,11 @@ public class DefaultRenderersFactory implements RenderersFactory { * @param extensionRendererMode The extension renderer mode. * @param out An array to which the built renderers should be appended. */ - protected void buildMiscellaneousRenderers(Context context, Handler eventHandler, - @ExtensionRendererMode int extensionRendererMode, ArrayList out) { + protected void buildMiscellaneousRenderers( + Context context, + Handler eventHandler, + @ExtensionRendererMode int extensionRendererMode, + ArrayList out) { // Do nothing. } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/NoSampleRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/NoSampleRenderer.java index f3329b8ea7..3caaf9864f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/NoSampleRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/NoSampleRenderer.java @@ -122,8 +122,7 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities } @Override - public final void maybeThrowStreamError() throws IOException { - } + public final void maybeThrowStreamError() throws IOException {} @Override public final void resetPosition(long positionUs) throws ExoPlaybackException { @@ -188,8 +187,8 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities /** * Called when the renderer is enabled. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. * * @param joining Whether this renderer is being enabled to join an ongoing playback. * @throws ExoPlaybackException If an error occurs. @@ -200,11 +199,11 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities /** * Called when the renderer's offset has been changed. - *

- * The default implementation is a no-op. * - * @param offsetUs The offset that should be subtracted from {@code positionUs} in - * {@link #render(long, long)} to get the playback position with respect to the media. + *

The default implementation is a no-op. + * + * @param offsetUs The offset that should be subtracted from {@code positionUs} in {@link + * #render(long, long)} to get the playback position with respect to the media. * @throws ExoPlaybackException If an error occurs. */ protected void onRendererOffsetChanged(long offsetUs) throws ExoPlaybackException { @@ -212,11 +211,11 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities } /** - * Called when the position is reset. This occurs when the renderer is enabled after - * {@link #onRendererOffsetChanged(long)} has been called, and also when a position - * discontinuity is encountered. - *

- * The default implementation is a no-op. + * Called when the position is reset. This occurs when the renderer is enabled after {@link + * #onRendererOffsetChanged(long)} has been called, and also when a position discontinuity is + * encountered. + * + *

The default implementation is a no-op. * * @param positionUs The new playback position in microseconds. * @param joining Whether this renderer is being enabled to join an ongoing playback. @@ -228,8 +227,8 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities /** * Called when the renderer is started. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. * * @throws ExoPlaybackException If an error occurs. */ @@ -248,8 +247,8 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities /** * Called when the renderer is disabled. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. */ protected void onDisabled() { // Do nothing. @@ -275,11 +274,8 @@ public abstract class NoSampleRenderer implements Renderer, RendererCapabilities return configuration; } - /** - * Returns the index of the renderer within the player. - */ + /** Returns the index of the renderer within the player. */ protected final int getIndex() { return index; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/PlaybackInfo.java b/library/core/src/main/java/com/google/android/exoplayer2/PlaybackInfo.java index 9ccc2a5a40..e525b5130d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/PlaybackInfo.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/PlaybackInfo.java @@ -25,9 +25,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectorResult; import com.google.common.collect.ImmutableList; import java.util.List; -/** - * Information about an ongoing playback. - */ +/** Information about an ongoing playback. */ /* package */ final class PlaybackInfo { /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java b/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java index f84fef5004..e35016a83d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/Renderer.java @@ -302,9 +302,9 @@ public interface Renderer extends PlayerMessage.Target { /** * Starts the renderer, meaning that calls to {@link #render(long, long)} will cause media to be * rendered. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}. * * @throws ExoPlaybackException If an error occurs. */ @@ -332,9 +332,9 @@ public interface Renderer extends PlayerMessage.Target { /** * Returns whether the renderer has read the current {@link SampleStream} to the end. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}, {@link #STATE_STARTED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}, {@link #STATE_STARTED}. */ boolean hasReadStreamToEnd(); @@ -351,9 +351,9 @@ public interface Renderer extends PlayerMessage.Target { /** * Signals to the renderer that the current {@link SampleStream} will be the final one supplied * before it is next disabled or reset. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}, {@link #STATE_STARTED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}, {@link #STATE_STARTED}. */ void setCurrentStreamFinal(); @@ -366,9 +366,9 @@ public interface Renderer extends PlayerMessage.Target { /** * Throws an error that's preventing the renderer from reading from its {@link SampleStream}. Does * nothing if no such error exists. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}, {@link #STATE_STARTED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}, {@link #STATE_STARTED}. * * @throws IOException An error that's preventing the renderer from making progress or buffering * more data. @@ -377,12 +377,12 @@ public interface Renderer extends PlayerMessage.Target { /** * Signals to the renderer that a position discontinuity has occurred. - *

- * After a position discontinuity, the renderer's {@link SampleStream} is guaranteed to provide + * + *

After a position discontinuity, the renderer's {@link SampleStream} is guaranteed to provide * samples starting from a key frame. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}, {@link #STATE_STARTED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}, {@link #STATE_STARTED}. * * @param positionUs The new playback position in microseconds. * @throws ExoPlaybackException If an error occurs handling the reset. @@ -433,16 +433,16 @@ public interface Renderer extends PlayerMessage.Target { /** * Whether the renderer is able to immediately render media from the current position. - *

- * If the renderer is in the {@link #STATE_STARTED} state then returning true indicates that the - * renderer has everything that it needs to continue playback. Returning false indicates that + * + *

If the renderer is in the {@link #STATE_STARTED} state then returning true indicates that + * the renderer has everything that it needs to continue playback. Returning false indicates that * the player should pause until the renderer is ready. - *

- * If the renderer is in the {@link #STATE_ENABLED} state then returning true indicates that the - * renderer is ready for playback to be started. Returning false indicates that it is not. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}, {@link #STATE_STARTED}. + * + *

If the renderer is in the {@link #STATE_ENABLED} state then returning true indicates that + * the renderer is ready for playback to be started. Returning false indicates that it is not. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}, {@link #STATE_STARTED}. * * @return Whether the renderer is ready to render media. */ @@ -470,9 +470,9 @@ public interface Renderer extends PlayerMessage.Target { /** * Disable the renderer, transitioning it to the {@link #STATE_DISABLED} state. - *

- * This method may be called when the renderer is in the following states: - * {@link #STATE_ENABLED}. + * + *

This method may be called when the renderer is in the following states: {@link + * #STATE_ENABLED}. */ void disable(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/RendererCapabilities.java b/library/core/src/main/java/com/google/android/exoplayer2/RendererCapabilities.java index dc7a8f8642..37176cb752 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/RendererCapabilities.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/RendererCapabilities.java @@ -61,18 +61,14 @@ public interface RendererCapabilities { /** A mask to apply to {@link Capabilities} to obtain the {@link AdaptiveSupport} only. */ int ADAPTIVE_SUPPORT_MASK = 0b11000; - /** - * The {@link Renderer} can seamlessly adapt between formats. - */ + /** The {@link Renderer} can seamlessly adapt between formats. */ int ADAPTIVE_SEAMLESS = 0b10000; /** * The {@link Renderer} can adapt between formats, but may suffer a brief discontinuity * (~50-100ms) when adaptation occurs. */ int ADAPTIVE_NOT_SEAMLESS = 0b01000; - /** - * The {@link Renderer} does not support adaptation between formats. - */ + /** The {@link Renderer} does not support adaptation between formats. */ int ADAPTIVE_NOT_SUPPORTED = 0b00000; /** @@ -86,13 +82,9 @@ public interface RendererCapabilities { /** A mask to apply to {@link Capabilities} to obtain the {@link TunnelingSupport} only. */ int TUNNELING_SUPPORT_MASK = 0b100000; - /** - * The {@link Renderer} supports tunneled output. - */ + /** The {@link Renderer} supports tunneled output. */ int TUNNELING_SUPPORTED = 0b100000; - /** - * The {@link Renderer} does not support tunneled output. - */ + /** The {@link Renderer} does not support tunneled output. */ int TUNNELING_NOT_SUPPORTED = 0b000000; /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java index 9dee990905..ebedf4d340 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilities.java @@ -123,9 +123,7 @@ public final class AudioCapabilities { return Arrays.binarySearch(supportedEncodings, encoding) >= 0; } - /** - * Returns the maximum number of channels the device can play at the same time. - */ + /** Returns the maximum number of channels the device can play at the same time. */ public int getMaxChannelCount() { return maxChannelCount; } @@ -150,8 +148,11 @@ public final class AudioCapabilities { @Override public String toString() { - return "AudioCapabilities[maxChannelCount=" + maxChannelCount - + ", supportedEncodings=" + Arrays.toString(supportedEncodings) + "]"; + return "AudioCapabilities[maxChannelCount=" + + maxChannelCount + + ", supportedEncodings=" + + Arrays.toString(supportedEncodings) + + "]"; } private static boolean deviceMaySetExternalSurroundSoundGlobalSetting() { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilitiesReceiver.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilitiesReceiver.java index c9c78a7422..caed07b6ad 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilitiesReceiver.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioCapabilitiesReceiver.java @@ -34,9 +34,7 @@ import com.google.android.exoplayer2.util.Util; */ public final class AudioCapabilitiesReceiver { - /** - * Listener notified when audio capabilities change. - */ + /** Listener notified when audio capabilities change. */ public interface Listener { /** @@ -45,7 +43,6 @@ public final class AudioCapabilitiesReceiver { * @param audioCapabilities The current audio capabilities for the device. */ void onAudioCapabilitiesChanged(AudioCapabilities audioCapabilities); - } private final Context context; @@ -77,8 +74,8 @@ public final class AudioCapabilitiesReceiver { /** * Registers the receiver, meaning it will notify the listener when audio capability changes - * occur. The current audio capabilities will be returned. It is important to call - * {@link #unregister} when the receiver is no longer required. + * occur. The current audio capabilities will be returned. It is important to call {@link + * #unregister} when the receiver is no longer required. * * @return The current audio capabilities for the device. */ @@ -162,5 +159,4 @@ public final class AudioCapabilitiesReceiver { onNewAudioCapabilities(AudioCapabilities.getCapabilities(context)); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java index f75b2cd317..c99729c52a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioProcessor.java @@ -76,7 +76,6 @@ public interface AudioProcessor { public UnhandledAudioFormatException(AudioFormat inputAudioFormat) { super("Unhandled format: " + inputAudioFormat); } - } /** An empty, direct {@link ByteBuffer}. */ @@ -114,11 +113,11 @@ public interface AudioProcessor { void queueInput(ByteBuffer buffer); /** - * Queues an end of stream signal. After this method has been called, - * {@link #queueInput(ByteBuffer)} may not be called until after the next call to - * {@link #flush()}. Calling {@link #getOutput()} will return any remaining output data. Multiple - * calls may be required to read all of the remaining output data. {@link #isEnded()} will return - * {@code true} once all remaining output data has been read. + * Queues an end of stream signal. After this method has been called, {@link + * #queueInput(ByteBuffer)} may not be called until after the next call to {@link #flush()}. + * Calling {@link #getOutput()} will return any remaining output data. Multiple calls may be + * required to read all of the remaining output data. {@link #isEnded()} will return {@code true} + * once all remaining output data has been read. */ void queueEndOfStream(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java index 0abf326538..5cd82577df 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioSink.java @@ -57,9 +57,7 @@ import java.nio.ByteBuffer; */ public interface AudioSink { - /** - * Listener for audio sink events. - */ + /** Listener for audio sink events. */ interface Listener { /** @@ -132,9 +130,7 @@ public interface AudioSink { default void onAudioSinkError(Exception audioSinkError) {} } - /** - * Thrown when a failure occurs configuring the sink. - */ + /** Thrown when a failure occurs configuring the sink. */ final class ConfigurationException extends Exception { /** Input {@link Format} of the sink when the configuration failure occurs. */ @@ -200,8 +196,8 @@ public interface AudioSink { /** * The error value returned from the sink implementation. If the sink writes to a platform - * {@link AudioTrack}, this will be the error value returned from - * {@link AudioTrack#write(byte[], int, int)} or {@link AudioTrack#write(ByteBuffer, int, int)}. + * {@link AudioTrack}, this will be the error value returned from {@link + * AudioTrack#write(byte[], int, int)} or {@link AudioTrack#write(ByteBuffer, int, int)}. * Otherwise, the meaning of the error code depends on the sink implementation. */ public final int errorCode; @@ -223,7 +219,6 @@ public interface AudioSink { this.errorCode = errorCode; this.format = format; } - } /** Thrown when the sink encounters an unexpected timestamp discontinuity. */ @@ -327,9 +322,7 @@ public interface AudioSink { void configure(Format inputFormat, int specifiedBufferSize, @Nullable int[] outputChannels) throws ConfigurationException; - /** - * Starts or resumes consuming audio if initialized. - */ + /** Starts or resumes consuming audio if initialized. */ void play(); /** Signals to the sink that the next buffer may be discontinuous with the previous buffer. */ @@ -370,9 +363,7 @@ public interface AudioSink { */ boolean isEnded(); - /** - * Returns whether the sink has data pending that has not been consumed yet. - */ + /** Returns whether the sink has data pending that has not been consumed yet. */ boolean hasPendingData(); /** @@ -395,8 +386,8 @@ public interface AudioSink { /** * Sets attributes for audio playback. If the attributes have changed and if the sink is not * configured for use with tunneling, then it is reset and the audio session id is cleared. - *

- * If the sink is configured for use with tunneling then the audio attributes are ignored. The + * + *

If the sink is configured for use with tunneling then the audio attributes are ignored. The * sink is not reset and the audio session id is not cleared. The passed attributes will be used * if the sink is later re-configured into non-tunneled mode. * @@ -432,9 +423,7 @@ public interface AudioSink { */ void setVolume(float volume); - /** - * Pauses playback. - */ + /** Pauses playback. */ void pause(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java index 8891a6d8d1..6c26d87fcf 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/AudioTrackPositionTracker.java @@ -409,8 +409,7 @@ import java.lang.reflect.Method; * @return Whether the audio track has any pending data to play out. */ public boolean hasPendingData(long writtenFrames) { - return writtenFrames > getPlaybackHeadPosition() - || forceHasPendingData(); + return writtenFrames > getPlaybackHeadPosition() || forceHasPendingData(); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java index c064c7e459..74c78b1af3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ChannelMappingAudioProcessor.java @@ -94,5 +94,4 @@ import java.nio.ByteBuffer; outputChannels = null; pendingOutputChannels = null; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java index 4367883df9..fb078c0054 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java @@ -94,9 +94,7 @@ public abstract class DecoderAudioRenderer< REINITIALIZATION_STATE_WAIT_END_OF_STREAM }) private @interface ReinitializationState {} - /** - * The decoder does not need to be re-initialized. - */ + /** The decoder does not need to be re-initialized. */ private static final int REINITIALIZATION_STATE_NONE = 0; /** * The input format has changed in a way that requires the decoder to be re-initialized, but we @@ -153,11 +151,7 @@ public abstract class DecoderAudioRenderer< @Nullable Handler eventHandler, @Nullable AudioRendererEventListener eventListener, AudioProcessor... audioProcessors) { - this( - eventHandler, - eventListener, - /* audioCapabilities= */ null, - audioProcessors); + this(eventHandler, eventListener, /* audioCapabilities= */ null, audioProcessors); } /** @@ -417,7 +411,8 @@ public abstract class DecoderAudioRenderer< } private boolean feedInputBuffer() throws DecoderException, ExoPlaybackException { - if (decoder == null || decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM + if (decoder == null + || decoderReinitializationState == REINITIALIZATION_STATE_WAIT_END_OF_STREAM || inputStreamEnded) { // We need to reinitialize the decoder or the input stream has ended. return false; @@ -621,7 +616,9 @@ public abstract class DecoderAudioRenderer< decoder = createDecoder(inputFormat, mediaCrypto); TraceUtil.endSection(); long codecInitializedTimestamp = SystemClock.elapsedRealtime(); - eventDispatcher.decoderInitialized(decoder.getName(), codecInitializedTimestamp, + eventDispatcher.decoderInitialized( + decoder.getName(), + codecInitializedTimestamp, codecInitializedTimestamp - codecInitializingTimestamp); decoderCounters.decoderInitCount++; } catch (DecoderException e) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java index 10ac561014..376776575b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/DefaultAudioSink.java @@ -73,7 +73,6 @@ public final class DefaultAudioSink implements AudioSink { private InvalidAudioTrackTimestampException(String message) { super(message); } - } /** @@ -301,8 +300,8 @@ public final class DefaultAudioSink implements AudioSink { /** * Whether to throw an {@link InvalidAudioTrackTimestampException} when a spurious timestamp is * reported from {@link AudioTrack#getTimestamp}. - *

- * The flag must be set before creating a player. Should be set to {@code true} for testing and + * + *

The flag must be set before creating a player. Should be set to {@code true} for testing and * debugging purposes only. */ public static boolean failOnSpuriousAudioTimestamp = false; @@ -876,8 +875,10 @@ public final class DefaultAudioSink implements AudioSink { int count = activeAudioProcessors.length; int index = count; while (index >= 0) { - ByteBuffer input = index > 0 ? outputBuffers[index - 1] - : (inputBuffer != null ? inputBuffer : AudioProcessor.EMPTY_BUFFER); + ByteBuffer input = + index > 0 + ? outputBuffers[index - 1] + : (inputBuffer != null ? inputBuffer : AudioProcessor.EMPTY_BUFFER); if (index == count) { writeBuffer(input, avSyncPresentationTimeUs); } else { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java index a4d2a1b67a..14ba4788e3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/ResamplingAudioProcessor.java @@ -135,5 +135,4 @@ import java.nio.ByteBuffer; inputBuffer.position(inputBuffer.limit()); buffer.flip(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/Sonic.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/Sonic.java index 5ddedd7bd7..58cd145e35 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/Sonic.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/Sonic.java @@ -24,8 +24,8 @@ import java.util.Arrays; /** * Sonic audio stream processor for time/pitch stretching. - *

- * Based on https://github.com/waywardgeek/sonic. + * + *

Based on https://github.com/waywardgeek/sonic. */ /* package */ final class Sonic { @@ -512,5 +512,4 @@ import java.util.Arrays; } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java index bbfd77469d..b7d14667be 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/SonicAudioProcessor.java @@ -255,5 +255,4 @@ public final class SonicAudioProcessor implements AudioProcessor { outputBytes = 0; inputEnded = false; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java b/library/core/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java index ed51726530..bd3017bf53 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/audio/TrimmingAudioProcessor.java @@ -178,5 +178,4 @@ import java.nio.ByteBuffer; protected void onReset() { endBuffer = Util.EMPTY_BYTE_ARRAY; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/decoder/Decoder.java b/library/core/src/main/java/com/google/android/exoplayer2/decoder/Decoder.java index c94eb2c38a..68852182ae 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/decoder/Decoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/decoder/Decoder.java @@ -65,9 +65,6 @@ public interface Decoder { */ void flush(); - /** - * Releases the decoder. Must be called when the decoder is no longer needed. - */ + /** Releases the decoder. Must be called when the decoder is no longer needed. */ void release(); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/decoder/DecoderCounters.java b/library/core/src/main/java/com/google/android/exoplayer2/decoder/DecoderCounters.java index 698e329be5..779513d412 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/decoder/DecoderCounters.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/decoder/DecoderCounters.java @@ -26,53 +26,45 @@ import static java.lang.Math.max; */ public final class DecoderCounters { - /** - * The number of times a decoder has been initialized. - */ + /** The number of times a decoder has been initialized. */ public int decoderInitCount; - /** - * The number of times a decoder has been released. - */ + /** The number of times a decoder has been released. */ public int decoderReleaseCount; - /** - * The number of queued input buffers. - */ + /** The number of queued input buffers. */ public int inputBufferCount; /** * The number of skipped input buffers. - *

- * A skipped input buffer is an input buffer that was deliberately not sent to the decoder. + * + *

A skipped input buffer is an input buffer that was deliberately not sent to the decoder. */ public int skippedInputBufferCount; - /** - * The number of rendered output buffers. - */ + /** The number of rendered output buffers. */ public int renderedOutputBufferCount; /** * The number of skipped output buffers. - *

- * A skipped output buffer is an output buffer that was deliberately not rendered. + * + *

A skipped output buffer is an output buffer that was deliberately not rendered. */ public int skippedOutputBufferCount; /** * The number of dropped buffers. - *

- * A dropped buffer is an buffer that was supposed to be decoded/rendered, but was instead + * + *

A dropped buffer is an buffer that was supposed to be decoded/rendered, but was instead * dropped because it could not be rendered in time. */ public int droppedBufferCount; /** * The maximum number of dropped buffers without an interleaving rendered output buffer. - *

- * Skipped output buffers are ignored for the purposes of calculating this value. + * + *

Skipped output buffers are ignored for the purposes of calculating this value. */ public int maxConsecutiveDroppedBufferCount; /** * The number of times all buffers to a keyframe were dropped. - *

- * Each time buffers to a keyframe are dropped, this counter is increased by one, and the dropped - * buffer counters are increased by one (for the current output buffer) plus the number of buffers - * dropped from the source to advance to the keyframe. + * + *

Each time buffers to a keyframe are dropped, this counter is increased by one, and the + * dropped buffer counters are increased by one (for the current output buffer) plus the number of + * buffers dropped from the source to advance to the keyframe. */ public int droppedToKeyframeCount; /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java b/library/core/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java index 073f6ecca7..bce21cca9c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java @@ -29,9 +29,7 @@ public abstract class OutputBuffer extends Buffer { void releaseOutputBuffer(S outputBuffer); } - /** - * The presentation timestamp for the buffer, in microseconds. - */ + /** The presentation timestamp for the buffer, in microseconds. */ public long timeUs; /** @@ -39,8 +37,6 @@ public abstract class OutputBuffer extends Buffer { */ public int skippedOutputBufferCount; - /** - * Releases the output buffer for reuse. Must be called when the buffer is no longer needed. - */ + /** Releases the output buffer for reuse. Must be called when the buffer is no longer needed. */ public abstract void release(); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java index da69924e03..896fb06568 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java @@ -77,8 +77,8 @@ public abstract class SimpleDecoder< /** * Sets the initial size of each input buffer. - *

- * This method should only be called before the decoder is used (i.e. before the first call to + * + *

This method should only be called before the decoder is used (i.e. before the first call to * {@link #dequeueInputBuffer()}. * * @param size The required input buffer size. @@ -96,8 +96,10 @@ public abstract class SimpleDecoder< synchronized (lock) { maybeThrowException(); Assertions.checkState(dequeuedInputBuffer == null); - dequeuedInputBuffer = availableInputBufferCount == 0 ? null - : availableInputBuffers[--availableInputBufferCount]; + dequeuedInputBuffer = + availableInputBufferCount == 0 + ? null + : availableInputBuffers[--availableInputBufferCount]; return dequeuedInputBuffer; } } @@ -184,8 +186,8 @@ public abstract class SimpleDecoder< /** * Notifies the decode loop if there exists a queued input buffer and an available output buffer * to decode into. - *

- * Should only be called whilst synchronized on the lock object. + * + *

Should only be called whilst synchronized on the lock object. */ private void maybeNotifyDecodeLoop() { if (canDecodeBuffer()) { @@ -282,14 +284,10 @@ public abstract class SimpleDecoder< availableOutputBuffers[availableOutputBufferCount++] = outputBuffer; } - /** - * Creates a new input buffer. - */ + /** Creates a new input buffer. */ protected abstract I createInputBuffer(); - /** - * Creates a new output buffer. - */ + /** Creates a new output buffer. */ protected abstract O createOutputBuffer(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java b/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java index 12d3c8ca26..81561701e2 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java @@ -59,5 +59,4 @@ public class SimpleOutputBuffer extends OutputBuffer { public void release() { owner.releaseOutputBuffer(this); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/ClearKeyUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/ClearKeyUtil.java index 1c64570f9e..0aace3f95f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/ClearKeyUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/ClearKeyUtil.java @@ -21,9 +21,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; -/** - * Utility methods for ClearKey. - */ +/** Utility methods for ClearKey. */ /* package */ final class ClearKeyUtil { private static final String TAG = "ClearKeyUtil"; @@ -93,5 +91,4 @@ import org.json.JSONObject; private static String base64UrlToBase64(String base64Url) { return base64Url.replace('-', '+').replace('_', '/'); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DecryptionException.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DecryptionException.java index f144cc1ac2..eddaba3d93 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DecryptionException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DecryptionException.java @@ -18,9 +18,7 @@ package com.google.android.exoplayer2.drm; /** Thrown when a non-platform component fails to decrypt data. */ public class DecryptionException extends Exception { - /** - * A component specific error code. - */ + /** A component specific error code. */ public final int errorCode; /** @@ -31,5 +29,4 @@ public class DecryptionException extends Exception { super(message); this.errorCode = errorCode; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSession.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSession.java index e72d552a68..954bdd86c4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSession.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DrmSession.java @@ -56,7 +56,6 @@ public interface DrmSession { public DrmSessionException(Throwable cause) { super(cause); } - } /** @@ -74,9 +73,7 @@ public interface DrmSession { * This is a terminal state. */ int STATE_ERROR = 1; - /** - * The session is being opened. - */ + /** The session is being opened. */ int STATE_OPENING = 2; /** The session is open, but does not have keys required for decryption. */ int STATE_OPENED = 3; @@ -84,11 +81,12 @@ public interface DrmSession { int STATE_OPENED_WITH_KEYS = 4; /** - * Returns the current state of the session, which is one of {@link #STATE_ERROR}, - * {@link #STATE_RELEASED}, {@link #STATE_OPENING}, {@link #STATE_OPENED} and - * {@link #STATE_OPENED_WITH_KEYS}. + * Returns the current state of the session, which is one of {@link #STATE_ERROR}, {@link + * #STATE_RELEASED}, {@link #STATE_OPENING}, {@link #STATE_OPENED} and {@link + * #STATE_OPENED_WITH_KEYS}. */ - @State int getState(); + @State + int getState(); /** Returns whether this session allows playback of clear samples prior to keys being loaded. */ default boolean playClearSamplesWithoutKeys() { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java index a54975392b..c01ce45264 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java @@ -295,8 +295,10 @@ public final class FrameworkMediaDrm implements ExoMediaDrm { public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException { // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still // indicate that it required secure video decoders [Internal ref: b/11428937]. - boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21 - && C.WIDEVINE_UUID.equals(uuid) && "L3".equals(getPropertyString("securityLevel")); + boolean forceAllowInsecureDecoderComponents = + Util.SDK_INT < 21 + && C.WIDEVINE_UUID.equals(uuid) + && "L3".equals(getPropertyString("securityLevel")); return new FrameworkMediaCrypto( adjustUuid(uuid), initData, forceAllowInsecureDecoderComponents); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/HttpMediaDrmCallback.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/HttpMediaDrmCallback.java index 6a20cf7bda..d5288a1b35 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/HttpMediaDrmCallback.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/HttpMediaDrmCallback.java @@ -102,9 +102,7 @@ public final class HttpMediaDrmCallback implements MediaDrmCallback { } } - /** - * Clears all headers for key requests made by the callback. - */ + /** Clears all headers for key requests made by the callback. */ public void clearAllKeyRequestProperties() { synchronized (keyRequestProperties) { keyRequestProperties.clear(); @@ -139,12 +137,14 @@ public final class HttpMediaDrmCallback implements MediaDrmCallback { } Map requestProperties = new HashMap<>(); // Add standard request properties for supported schemes. - String contentType = C.PLAYREADY_UUID.equals(uuid) ? "text/xml" - : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream"); + String contentType = + C.PLAYREADY_UUID.equals(uuid) + ? "text/xml" + : (C.CLEARKEY_UUID.equals(uuid) ? "application/json" : "application/octet-stream"); requestProperties.put("Content-Type", contentType); if (C.PLAYREADY_UUID.equals(uuid)) { - requestProperties.put("SOAPAction", - "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense"); + requestProperties.put( + "SOAPAction", "http://schemas.microsoft.com/DRM/2007/03/protocols/AcquireLicense"); } // Add additional request properties. synchronized (keyRequestProperties) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/LocalMediaDrmCallback.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/LocalMediaDrmCallback.java index d141b6c4c1..a95291413f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/LocalMediaDrmCallback.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/LocalMediaDrmCallback.java @@ -30,9 +30,7 @@ public final class LocalMediaDrmCallback implements MediaDrmCallback { private final byte[] keyResponse; - /** - * @param keyResponse The fixed response for all key requests. - */ + /** @param keyResponse The fixed response for all key requests. */ public LocalMediaDrmCallback(byte[] keyResponse) { this.keyResponse = Assertions.checkNotNull(keyResponse); } @@ -46,5 +44,4 @@ public final class LocalMediaDrmCallback implements MediaDrmCallback { public byte[] executeKeyRequest(UUID uuid, KeyRequest request) { return keyResponse; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java index b218d0cadb..bfa9d191c4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java @@ -133,10 +133,10 @@ public final class OfflineLicenseHelper { @Nullable Map optionalKeyRequestParameters, DrmSessionEventListener.EventDispatcher eventDispatcher) { this( - new DefaultDrmSessionManager.Builder() - .setUuidAndExoMediaDrmProvider(uuid, mediaDrmProvider) - .setKeyRequestParameters(optionalKeyRequestParameters) - .build(callback), + new DefaultDrmSessionManager.Builder() + .setUuidAndExoMediaDrmProvider(uuid, mediaDrmProvider) + .setKeyRequestParameters(optionalKeyRequestParameters) + .build(callback), eventDispatcher); } @@ -255,9 +255,7 @@ public final class OfflineLicenseHelper { return Assertions.checkNotNull(licenseDurationRemainingSec); } - /** - * Releases the helper. Should be called when the helper is no longer required. - */ + /** Releases the helper. Should be called when the helper is no longer required. */ public void release() { handlerThread.quit(); } @@ -288,5 +286,4 @@ public final class OfflineLicenseHelper { conditionVariable.block(); return Assertions.checkNotNull(drmSession); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/UnsupportedDrmException.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/UnsupportedDrmException.java index cd728df1b2..e52c770388 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/UnsupportedDrmException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/UnsupportedDrmException.java @@ -31,9 +31,7 @@ public final class UnsupportedDrmException extends Exception { @Retention(RetentionPolicy.SOURCE) @IntDef({REASON_UNSUPPORTED_SCHEME, REASON_INSTANTIATION_ERROR}) public @interface Reason {} - /** - * The requested DRM scheme is unsupported by the device. - */ + /** The requested DRM scheme is unsupported by the device. */ public static final int REASON_UNSUPPORTED_SCHEME = 1; /** * There device advertises support for the requested DRM scheme, but there was an error @@ -41,14 +39,10 @@ public final class UnsupportedDrmException extends Exception { */ public static final int REASON_INSTANTIATION_ERROR = 2; - /** - * Either {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. - */ + /** Either {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. */ @Reason public final int reason; - /** - * @param reason {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. - */ + /** @param reason {@link #REASON_UNSUPPORTED_SCHEME} or {@link #REASON_INSTANTIATION_ERROR}. */ public UnsupportedDrmException(@Reason int reason) { this.reason = reason; } @@ -61,5 +55,4 @@ public final class UnsupportedDrmException extends Exception { super(cause); this.reason = reason; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/WidevineUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/WidevineUtil.java index a5998488f2..2af6a5cd1b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/WidevineUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/WidevineUtil.java @@ -42,7 +42,8 @@ public final class WidevineUtil { if (keyStatus == null) { return null; } - return new Pair<>(getDurationRemainingSec(keyStatus, PROPERTY_LICENSE_DURATION_REMAINING), + return new Pair<>( + getDurationRemainingSec(keyStatus, PROPERTY_LICENSE_DURATION_REMAINING), getDurationRemainingSec(keyStatus, PROPERTY_PLAYBACK_DURATION_REMAINING)); } @@ -59,5 +60,4 @@ public final class WidevineUtil { } return C.TIME_UNSET; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java index 99396af2f4..6d4c11603a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecInfo.java @@ -214,7 +214,8 @@ public final class MediaCodecInfo { * @return The profile levels supported by the decoder. */ public CodecProfileLevel[] getProfileLevels() { - return capabilities == null || capabilities.profileLevels == null ? new CodecProfileLevel[0] + return capabilities == null || capabilities.profileLevels == null + ? new CodecProfileLevel[0] : capabilities.profileLevels; } @@ -571,8 +572,8 @@ public final class MediaCodecInfo { logNoSupport("channelCount.aCaps"); return false; } - int maxInputChannelCount = adjustMaxInputChannelCount(name, mimeType, - audioCapabilities.getMaxInputChannelCount()); + int maxInputChannelCount = + adjustMaxInputChannelCount(name, mimeType, audioCapabilities.getMaxInputChannelCount()); if (maxInputChannelCount < channelCount) { logNoSupport("channelCount.support, " + channelCount); return false; @@ -581,13 +582,31 @@ public final class MediaCodecInfo { } private void logNoSupport(String message) { - Log.d(TAG, "NoSupport [" + message + "] [" + name + ", " + mimeType + "] [" - + Util.DEVICE_DEBUG_INFO + "]"); + Log.d( + TAG, + "NoSupport [" + + message + + "] [" + + name + + ", " + + mimeType + + "] [" + + Util.DEVICE_DEBUG_INFO + + "]"); } private void logAssumedSupport(String message) { - Log.d(TAG, "AssumedSupport [" + message + "] [" + name + ", " + mimeType + "] [" - + Util.DEVICE_DEBUG_INFO + "]"); + Log.d( + TAG, + "AssumedSupport [" + + message + + "] [" + + name + + ", " + + mimeType + + "] [" + + Util.DEVICE_DEBUG_INFO + + "]"); } private static int adjustMaxInputChannelCount(String name, String mimeType, int maxChannelCount) { @@ -619,8 +638,15 @@ public final class MediaCodecInfo { // Default to the platform limit, which is 30. assumedMaxChannelCount = 30; } - Log.w(TAG, "AssumedMaxChannelAdjustment: " + name + ", [" + maxChannelCount + " to " - + assumedMaxChannelCount + "]"); + Log.w( + TAG, + "AssumedMaxChannelAdjustment: " + + name + + ", [" + + maxChannelCount + + " to " + + assumedMaxChannelCount + + "]"); return assumedMaxChannelCount; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java index 2190e1fcd5..3bdb57e488 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java @@ -89,14 +89,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer { private static final int NO_SUITABLE_DECODER_ERROR = CUSTOM_ERROR_CODE_BASE + 1; private static final int DECODER_QUERY_ERROR = CUSTOM_ERROR_CODE_BASE + 2; - /** - * The mime type for which a decoder was being initialized. - */ + /** The mime type for which a decoder was being initialized. */ public final String mimeType; - /** - * Whether it was required that the decoder support a secure output path. - */ + /** Whether it was required that the decoder support a secure output path. */ public final boolean secureDecoderRequired; /** @@ -197,9 +193,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * If the {@link MediaCodec} is hotswapped (i.e. replaced during playback), this is the period of * time during which {@link #isReady()} will report true regardless of whether the new codec has * output frames that are ready to be rendered. - *

- * This allows codec hotswapping to be performed seamlessly, without interrupting the playback of - * other renderers, provided the new codec is able to decode some frames within this time period. + * + *

This allows codec hotswapping to be performed seamlessly, without interrupting the playback + * of other renderers, provided the new codec is able to decode some frames within this time + * period. */ private static final long MAX_CODEC_HOTSWAP_TIME_MS = 1000; @@ -215,13 +212,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer { RECONFIGURATION_STATE_QUEUE_PENDING }) private @interface ReconfigurationState {} - /** - * There is no pending adaptive reconfiguration work. - */ + /** There is no pending adaptive reconfiguration work. */ private static final int RECONFIGURATION_STATE_NONE = 0; - /** - * Codec configuration data needs to be written into the next buffer. - */ + /** Codec configuration data needs to be written into the next buffer. */ private static final int RECONFIGURATION_STATE_WRITE_PENDING = 1; /** * Codec configuration data has been written into the next buffer, but that buffer still needs to @@ -267,17 +260,13 @@ public abstract class MediaCodecRenderer extends BaseRenderer { }) private @interface AdaptationWorkaroundMode {} - /** - * The adaptation workaround is never used. - */ + /** The adaptation workaround is never used. */ private static final int ADAPTATION_WORKAROUND_MODE_NEVER = 0; /** * The adaptation workaround is used when adapting between formats of the same resolution only. */ private static final int ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION = 1; - /** - * The adaptation workaround is always used when adapting between formats. - */ + /** The adaptation workaround is always used when adapting between formats. */ private static final int ADAPTATION_WORKAROUND_MODE_ALWAYS = 2; /** @@ -517,9 +506,7 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * @throws DecoderQueryException If there was an error querying decoders. */ @Capabilities - protected abstract int supportsFormat( - MediaCodecSelector mediaCodecSelector, - Format format) + protected abstract int supportsFormat(MediaCodecSelector mediaCodecSelector, Format format) throws DecoderQueryException; /** @@ -1401,16 +1388,16 @@ public abstract class MediaCodecRenderer extends BaseRenderer { /** * Called when a {@link MediaCodec} has been created and configured. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. * * @param name The name of the codec that was initialized. * @param initializedTimestampMs {@link SystemClock#elapsedRealtime()} when initialization * finished. * @param initializationDurationMs The time taken to initialize the codec in milliseconds. */ - protected void onCodecInitialized(String name, long initializedTimestampMs, - long initializationDurationMs) { + protected void onCodecInitialized( + String name, long initializedTimestampMs, long initializationDurationMs) { // Do nothing. } @@ -2017,8 +2004,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { /** * Incrementally renders any remaining output. - *

- * The default implementation is a no-op. + * + *

The default implementation is a no-op. * * @throws ExoPlaybackException Thrown if an error occurs rendering remaining output. */ @@ -2340,11 +2327,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer { /** * Returns whether the decoder is known to fail when flushed. - *

- * If true is returned, the renderer will work around the issue by releasing the decoder and + * + *

If true is returned, the renderer will work around the issue by releasing the decoder and * instantiating a new one rather than flushing the current instance. - *

- * See [Internal: b/8347958, b/8543366]. + * + *

See [Internal: b/8347958, b/8543366]. * * @param name The name of the decoder. * @return True if the decoder is known to fail when flushed. @@ -2352,9 +2339,10 @@ public abstract class MediaCodecRenderer extends BaseRenderer { private static boolean codecNeedsFlushWorkaround(String name) { return Util.SDK_INT < 18 || (Util.SDK_INT == 18 - && ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name))) - || (Util.SDK_INT == 19 && Util.MODEL.startsWith("SM-G800") - && ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name))); + && ("OMX.SEC.avc.dec".equals(name) || "OMX.SEC.avc.dec.secure".equals(name))) + || (Util.SDK_INT == 19 + && Util.MODEL.startsWith("SM-G800") + && ("OMX.Exynos.avc.dec".equals(name) || "OMX.Exynos.avc.dec.secure".equals(name))); } /** @@ -2371,14 +2359,19 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * @return The mode specifying when the adaptation workaround should be enabled. */ private @AdaptationWorkaroundMode int codecAdaptationWorkaroundMode(String name) { - if (Util.SDK_INT <= 25 && "OMX.Exynos.avc.dec.secure".equals(name) - && (Util.MODEL.startsWith("SM-T585") || Util.MODEL.startsWith("SM-A510") - || Util.MODEL.startsWith("SM-A520") || Util.MODEL.startsWith("SM-J700"))) { + if (Util.SDK_INT <= 25 + && "OMX.Exynos.avc.dec.secure".equals(name) + && (Util.MODEL.startsWith("SM-T585") + || Util.MODEL.startsWith("SM-A510") + || Util.MODEL.startsWith("SM-A520") + || Util.MODEL.startsWith("SM-J700"))) { return ADAPTATION_WORKAROUND_MODE_ALWAYS; } else if (Util.SDK_INT < 24 && ("OMX.Nvidia.h264.decode".equals(name) || "OMX.Nvidia.h264.decode.secure".equals(name)) - && ("flounder".equals(Util.DEVICE) || "flounder_lte".equals(Util.DEVICE) - || "grouper".equals(Util.DEVICE) || "tilapia".equals(Util.DEVICE))) { + && ("flounder".equals(Util.DEVICE) + || "flounder_lte".equals(Util.DEVICE) + || "grouper".equals(Util.DEVICE) + || "tilapia".equals(Util.DEVICE))) { return ADAPTATION_WORKAROUND_MODE_SAME_RESOLUTION; } else { return ADAPTATION_WORKAROUND_MODE_NEVER; @@ -2397,7 +2390,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * @return True if the decoder is known to fail if NAL units are queued before CSD. */ private static boolean codecNeedsDiscardToSpsWorkaround(String name, Format format) { - return Util.SDK_INT < 21 && format.initializationData.isEmpty() + return Util.SDK_INT < 21 + && format.initializationData.isEmpty() && "OMX.MTK.VIDEO.DECODER.AVC".equals(name); } @@ -2443,11 +2437,11 @@ public abstract class MediaCodecRenderer extends BaseRenderer { /** * Returns whether the decoder is known to behave incorrectly if flushed after receiving an input * buffer with {@link MediaCodec#BUFFER_FLAG_END_OF_STREAM} set. - *

- * If true is returned, the renderer will work around the issue by instantiating a new decoder + * + *

If true is returned, the renderer will work around the issue by instantiating a new decoder * when this case occurs. - *

- * See [Internal: b/8578467, b/23361053]. + * + *

See [Internal: b/8578467, b/23361053]. * * @param name The name of the decoder. * @return True if the decoder is known to behave incorrectly if flushed after receiving an input @@ -2509,7 +2503,8 @@ public abstract class MediaCodecRenderer extends BaseRenderer { * channel. False otherwise. */ private static boolean codecNeedsMonoChannelCountWorkaround(String name, Format format) { - return Util.SDK_INT <= 18 && format.channelCount == 1 + return Util.SDK_INT <= 18 + && format.channelCount == 1 && "OMX.MTK.AUDIO.DECODER.MP3".equals(name); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java index 36eea4276e..b1276f6e6f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecUtil.java @@ -48,8 +48,8 @@ public final class MediaCodecUtil { /** * Thrown when an error occurs querying the device for its underlying media capabilities. - *

- * Such failures are not expected in normal operation and are normally temporary (e.g. if the + * + *

Such failures are not expected in normal operation and are normally temporary (e.g. if the * mediaserver process has crashed and is yet to restart). */ public static class DecoderQueryException extends Exception { @@ -57,7 +57,6 @@ public final class MediaCodecUtil { private DecoderQueryException(Throwable cause) { super("Failed to query underlying media codecs", cause); } - } private static final String TAG = "MediaCodecUtil"; @@ -175,8 +174,12 @@ public final class MediaCodecUtil { mediaCodecList = new MediaCodecListCompatV16(); decoderInfos = getDecoderInfosInternal(key, mediaCodecList); if (!decoderInfos.isEmpty()) { - Log.w(TAG, "MediaCodecList API didn't list secure decoder for: " + mimeType - + ". Assuming: " + decoderInfos.get(0).name); + Log.w( + TAG, + "MediaCodecList API didn't list secure decoder for: " + + mimeType + + ". Assuming: " + + decoderInfos.get(0).name); } } applyWorkarounds(mimeType, decoderInfos); @@ -383,9 +386,7 @@ public final class MediaCodecUtil { */ @Nullable private static String getCodecMimeType( - android.media.MediaCodecInfo info, - String name, - String mimeType) { + android.media.MediaCodecInfo info, String name, String mimeType) { String[] supportedTypes = info.getSupportedTypes(); for (String supportedType : supportedTypes) { if (supportedType.equalsIgnoreCase(mimeType)) { @@ -507,7 +508,8 @@ public final class MediaCodecUtil { } // VP8 decoder on Samsung Galaxy S4 cannot be queried. - if (Util.SDK_INT <= 19 && Util.DEVICE.startsWith("jflte") + if (Util.SDK_INT <= 19 + && Util.DEVICE.startsWith("jflte") && "OMX.qcom.video.decoder.vp8".equals(name)) { return false; } @@ -842,8 +844,8 @@ public final class MediaCodecUtil { * Conversion values taken from ISO 14496-10 Table A-1. * * @param avcLevel one of CodecProfileLevel.AVCLevel* constants. - * @return maximum frame size that can be decoded by a decoder with the specified avc level - * (or {@code -1} if the level is not recognized) + * @return maximum frame size that can be decoded by a decoder with the specified avc level (or + * {@code -1} if the level is not recognized) */ private static int avcLevelToMaxFrameSize(int avcLevel) { switch (avcLevel) { @@ -916,9 +918,7 @@ public final class MediaCodecUtil { private interface MediaCodecListCompat { - /** - * The number of codecs in the list. - */ + /** The number of codecs in the list. */ int getCodecCount(); /** @@ -928,9 +928,7 @@ public final class MediaCodecUtil { */ android.media.MediaCodecInfo getCodecInfoAt(int index); - /** - * Returns whether secure decoders are explicitly listed, if present. - */ + /** Returns whether secure decoders are explicitly listed, if present. */ boolean secureDecodersExplicit(); /** Whether the specified {@link CodecCapabilities} {@code feature} is supported. */ @@ -989,7 +987,6 @@ public final class MediaCodecUtil { mediaCodecInfos = new MediaCodecList(codecKind).getCodecInfos(); } } - } private static final class MediaCodecListCompatV16 implements MediaCodecListCompat { @@ -1023,7 +1020,6 @@ public final class MediaCodecUtil { String feature, String mimeType, CodecCapabilities capabilities) { return false; } - } private static final class CodecKey { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/MetadataRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/MetadataRenderer.java index 182e4e5303..afb32ee211 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/MetadataRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/MetadataRenderer.java @@ -233,5 +233,4 @@ public final class MetadataRenderer extends BaseRenderer implements Callback { private void invokeRendererInternal(Metadata metadata) { output.onMetadata(metadata); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/PrivateCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/PrivateCommand.java index f1ceaa3bb4..a849851aa0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/PrivateCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/PrivateCommand.java @@ -23,17 +23,11 @@ import com.google.android.exoplayer2.util.Util; /** Represents a private command as defined in SCTE35, Section 9.3.6. */ public final class PrivateCommand extends SpliceCommand { - /** - * The {@code pts_adjustment} as defined in SCTE35, Section 9.2. - */ + /** The {@code pts_adjustment} as defined in SCTE35, Section 9.2. */ public final long ptsAdjustment; - /** - * The identifier as defined in SCTE35, Section 9.3.6. - */ + /** The identifier as defined in SCTE35, Section 9.3.6. */ public final long identifier; - /** - * The private bytes as defined in SCTE35, Section 9.3.6. - */ + /** The private bytes as defined in SCTE35, Section 9.3.6. */ public final byte[] commandBytes; private PrivateCommand(long identifier, byte[] commandBytes, long ptsAdjustment) { @@ -48,8 +42,8 @@ public final class PrivateCommand extends SpliceCommand { commandBytes = Util.castNonNull(in.createByteArray()); } - /* package */ static PrivateCommand parseFromSection(ParsableByteArray sectionData, - int commandLength, long ptsAdjustment) { + /* package */ static PrivateCommand parseFromSection( + ParsableByteArray sectionData, int commandLength, long ptsAdjustment) { long identifier = sectionData.readUnsignedInt(); byte[] privateBytes = new byte[commandLength - 4 /* identifier size */]; sectionData.readBytes(privateBytes, 0, privateBytes.length); @@ -68,16 +62,14 @@ public final class PrivateCommand extends SpliceCommand { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public PrivateCommand createFromParcel(Parcel in) { - return new PrivateCommand(in); - } - - @Override - public PrivateCommand[] newArray(int size) { - return new PrivateCommand[size]; - } - - }; + @Override + public PrivateCommand createFromParcel(Parcel in) { + return new PrivateCommand(in); + } + @Override + public PrivateCommand[] newArray(int size) { + return new PrivateCommand[size]; + } + }; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceCommand.java index 8cb4dcec2b..40da002c04 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceCommand.java @@ -31,5 +31,4 @@ public abstract class SpliceCommand implements Metadata.Entry { public int describeContents() { return 0; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoder.java index fbcf9da6f3..f26d446b80 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoder.java @@ -78,8 +78,8 @@ public final class SpliceInfoDecoder extends SimpleMetadataDecoder { command = SpliceScheduleCommand.parseFromSection(sectionData); break; case TYPE_SPLICE_INSERT: - command = SpliceInsertCommand.parseFromSection(sectionData, ptsAdjustment, - timestampAdjuster); + command = + SpliceInsertCommand.parseFromSection(sectionData, ptsAdjustment, timestampAdjuster); break; case TYPE_TIME_SIGNAL: command = TimeSignalCommand.parseFromSection(sectionData, ptsAdjustment, timestampAdjuster); @@ -93,5 +93,4 @@ public final class SpliceInfoDecoder extends SimpleMetadataDecoder { } return command == null ? new Metadata() : new Metadata(command); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInsertCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInsertCommand.java index 8c8c6a1ffb..e5df2b963b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInsertCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceInsertCommand.java @@ -27,13 +27,9 @@ import java.util.List; /** Represents a splice insert command defined in SCTE35, Section 9.3.3. */ public final class SpliceInsertCommand extends SpliceCommand { - /** - * The splice event id. - */ + /** The splice event id. */ public final long spliceEventId; - /** - * True if the event with id {@link #spliceEventId} has been canceled. - */ + /** True if the event with id {@link #spliceEventId} has been canceled. */ public final boolean spliceEventCancelIndicator; /** * If true, the splice event is an opportunity to exit from the network feed. If false, indicates @@ -47,53 +43,53 @@ public final class SpliceInsertCommand extends SpliceCommand { public final boolean programSpliceFlag; /** * Whether splicing should be done at the nearest opportunity. If false, splicing should be done - * at the moment indicated by {@link #programSplicePlaybackPositionUs} or - * {@link ComponentSplice#componentSplicePlaybackPositionUs}, depending on - * {@link #programSpliceFlag}. + * at the moment indicated by {@link #programSplicePlaybackPositionUs} or {@link + * ComponentSplice#componentSplicePlaybackPositionUs}, depending on {@link #programSpliceFlag}. */ public final boolean spliceImmediateFlag; /** - * If {@link #programSpliceFlag} is true, the PTS at which the program splice should occur. - * {@link C#TIME_UNSET} otherwise. + * If {@link #programSpliceFlag} is true, the PTS at which the program splice should occur. {@link + * C#TIME_UNSET} otherwise. */ public final long programSplicePts; - /** - * Equivalent to {@link #programSplicePts} but in the playback timebase. - */ + /** Equivalent to {@link #programSplicePts} but in the playback timebase. */ public final long programSplicePlaybackPositionUs; /** - * If {@link #programSpliceFlag} is false, a non-empty list containing the - * {@link ComponentSplice}s. Otherwise, an empty list. + * If {@link #programSpliceFlag} is false, a non-empty list containing the {@link + * ComponentSplice}s. Otherwise, an empty list. */ public final List componentSpliceList; /** - * If {@link #breakDurationUs} is not {@link C#TIME_UNSET}, defines whether - * {@link #breakDurationUs} should be used to know when to return to the network feed. If - * {@link #breakDurationUs} is {@link C#TIME_UNSET}, the value is undefined. + * If {@link #breakDurationUs} is not {@link C#TIME_UNSET}, defines whether {@link + * #breakDurationUs} should be used to know when to return to the network feed. If {@link + * #breakDurationUs} is {@link C#TIME_UNSET}, the value is undefined. */ public final boolean autoReturn; /** * The duration of the splice in microseconds, or {@link C#TIME_UNSET} if no duration is present. */ public final long breakDurationUs; - /** - * The unique program id as defined in SCTE35, Section 9.3.3. - */ + /** The unique program id as defined in SCTE35, Section 9.3.3. */ public final int uniqueProgramId; - /** - * Holds the value of {@code avail_num} as defined in SCTE35, Section 9.3.3. - */ + /** Holds the value of {@code avail_num} as defined in SCTE35, Section 9.3.3. */ public final int availNum; - /** - * Holds the value of {@code avails_expected} as defined in SCTE35, Section 9.3.3. - */ + /** Holds the value of {@code avails_expected} as defined in SCTE35, Section 9.3.3. */ public final int availsExpected; - private SpliceInsertCommand(long spliceEventId, boolean spliceEventCancelIndicator, - boolean outOfNetworkIndicator, boolean programSpliceFlag, boolean spliceImmediateFlag, - long programSplicePts, long programSplicePlaybackPositionUs, - List componentSpliceList, boolean autoReturn, long breakDurationUs, - int uniqueProgramId, int availNum, int availsExpected) { + private SpliceInsertCommand( + long spliceEventId, + boolean spliceEventCancelIndicator, + boolean outOfNetworkIndicator, + boolean programSpliceFlag, + boolean spliceImmediateFlag, + long programSplicePts, + long programSplicePlaybackPositionUs, + List componentSpliceList, + boolean autoReturn, + long breakDurationUs, + int uniqueProgramId, + int availNum, + int availsExpected) { this.spliceEventId = spliceEventId; this.spliceEventCancelIndicator = spliceEventCancelIndicator; this.outOfNetworkIndicator = outOfNetworkIndicator; @@ -130,8 +126,8 @@ public final class SpliceInsertCommand extends SpliceCommand { availsExpected = in.readInt(); } - /* package */ static SpliceInsertCommand parseFromSection(ParsableByteArray sectionData, - long ptsAdjustment, TimestampAdjuster timestampAdjuster) { + /* package */ static SpliceInsertCommand parseFromSection( + ParsableByteArray sectionData, long ptsAdjustment, TimestampAdjuster timestampAdjuster) { long spliceEventId = sectionData.readUnsignedInt(); // splice_event_cancel_indicator(1), reserved(7). boolean spliceEventCancelIndicator = (sectionData.readUnsignedByte() & 0x80) != 0; @@ -163,8 +159,11 @@ public final class SpliceInsertCommand extends SpliceCommand { if (!spliceImmediateFlag) { componentSplicePts = TimeSignalCommand.parseSpliceTime(sectionData, ptsAdjustment); } - componentSplices.add(new ComponentSplice(componentTag, componentSplicePts, - timestampAdjuster.adjustTsTimestamp(componentSplicePts))); + componentSplices.add( + new ComponentSplice( + componentTag, + componentSplicePts, + timestampAdjuster.adjustTsTimestamp(componentSplicePts))); } } if (durationFlag) { @@ -177,23 +176,31 @@ public final class SpliceInsertCommand extends SpliceCommand { availNum = sectionData.readUnsignedByte(); availsExpected = sectionData.readUnsignedByte(); } - return new SpliceInsertCommand(spliceEventId, spliceEventCancelIndicator, outOfNetworkIndicator, - programSpliceFlag, spliceImmediateFlag, programSplicePts, - timestampAdjuster.adjustTsTimestamp(programSplicePts), componentSplices, autoReturn, - breakDurationUs, uniqueProgramId, availNum, availsExpected); + return new SpliceInsertCommand( + spliceEventId, + spliceEventCancelIndicator, + outOfNetworkIndicator, + programSpliceFlag, + spliceImmediateFlag, + programSplicePts, + timestampAdjuster.adjustTsTimestamp(programSplicePts), + componentSplices, + autoReturn, + breakDurationUs, + uniqueProgramId, + availNum, + availsExpected); } - /** - * Holds splicing information for specific splice insert command components. - */ + /** Holds splicing information for specific splice insert command components. */ public static final class ComponentSplice { public final int componentTag; public final long componentSplicePts; public final long componentSplicePlaybackPositionUs; - private ComponentSplice(int componentTag, long componentSplicePts, - long componentSplicePlaybackPositionUs) { + private ComponentSplice( + int componentTag, long componentSplicePts, long componentSplicePlaybackPositionUs) { this.componentTag = componentTag; this.componentSplicePts = componentSplicePts; this.componentSplicePlaybackPositionUs = componentSplicePlaybackPositionUs; @@ -208,7 +215,6 @@ public final class SpliceInsertCommand extends SpliceCommand { public static ComponentSplice createFromParcel(Parcel in) { return new ComponentSplice(in.readInt(), in.readLong(), in.readLong()); } - } // Parcelable implementation. @@ -237,16 +243,14 @@ public final class SpliceInsertCommand extends SpliceCommand { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public SpliceInsertCommand createFromParcel(Parcel in) { - return new SpliceInsertCommand(in); - } - - @Override - public SpliceInsertCommand[] newArray(int size) { - return new SpliceInsertCommand[size]; - } - - }; + @Override + public SpliceInsertCommand createFromParcel(Parcel in) { + return new SpliceInsertCommand(in); + } + @Override + public SpliceInsertCommand[] newArray(int size) { + return new SpliceInsertCommand[size]; + } + }; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceNullCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceNullCommand.java index aed0a0e2bc..196f297970 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceNullCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceNullCommand.java @@ -30,16 +30,14 @@ public final class SpliceNullCommand extends SpliceCommand { public static final Creator CREATOR = new Creator() { - @Override - public SpliceNullCommand createFromParcel(Parcel in) { - return new SpliceNullCommand(); - } - - @Override - public SpliceNullCommand[] newArray(int size) { - return new SpliceNullCommand[size]; - } - - }; + @Override + public SpliceNullCommand createFromParcel(Parcel in) { + return new SpliceNullCommand(); + } + @Override + public SpliceNullCommand[] newArray(int size) { + return new SpliceNullCommand[size]; + } + }; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceScheduleCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceScheduleCommand.java index e252ae7354..6e62177fc7 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceScheduleCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/SpliceScheduleCommand.java @@ -26,18 +26,12 @@ import java.util.List; /** Represents a splice schedule command as defined in SCTE35, Section 9.3.2. */ public final class SpliceScheduleCommand extends SpliceCommand { - /** - * Represents a splice event as contained in a {@link SpliceScheduleCommand}. - */ + /** Represents a splice event as contained in a {@link SpliceScheduleCommand}. */ public static final class Event { - /** - * The splice event id. - */ + /** The splice event id. */ public final long spliceEventId; - /** - * True if the event with id {@link #spliceEventId} has been canceled. - */ + /** True if the event with id {@link #spliceEventId} has been canceled. */ public final boolean spliceEventCancelIndicator; /** * If true, the splice event is an opportunity to exit from the network feed. If false, @@ -55,14 +49,14 @@ public final class SpliceScheduleCommand extends SpliceCommand { */ public final long utcSpliceTime; /** - * If {@link #programSpliceFlag} is false, a non-empty list containing the - * {@link ComponentSplice}s. Otherwise, an empty list. + * If {@link #programSpliceFlag} is false, a non-empty list containing the {@link + * ComponentSplice}s. Otherwise, an empty list. */ public final List componentSpliceList; /** - * If {@link #breakDurationUs} is not {@link C#TIME_UNSET}, defines whether - * {@link #breakDurationUs} should be used to know when to return to the network feed. If - * {@link #breakDurationUs} is {@link C#TIME_UNSET}, the value is undefined. + * If {@link #breakDurationUs} is not {@link C#TIME_UNSET}, defines whether {@link + * #breakDurationUs} should be used to know when to return to the network feed. If {@link + * #breakDurationUs} is {@link C#TIME_UNSET}, the value is undefined. */ public final boolean autoReturn; /** @@ -70,23 +64,25 @@ public final class SpliceScheduleCommand extends SpliceCommand { * present. */ public final long breakDurationUs; - /** - * The unique program id as defined in SCTE35, Section 9.3.2. - */ + /** The unique program id as defined in SCTE35, Section 9.3.2. */ public final int uniqueProgramId; - /** - * Holds the value of {@code avail_num} as defined in SCTE35, Section 9.3.2. - */ + /** Holds the value of {@code avail_num} as defined in SCTE35, Section 9.3.2. */ public final int availNum; - /** - * Holds the value of {@code avails_expected} as defined in SCTE35, Section 9.3.2. - */ + /** Holds the value of {@code avails_expected} as defined in SCTE35, Section 9.3.2. */ public final int availsExpected; - private Event(long spliceEventId, boolean spliceEventCancelIndicator, - boolean outOfNetworkIndicator, boolean programSpliceFlag, - List componentSpliceList, long utcSpliceTime, boolean autoReturn, - long breakDurationUs, int uniqueProgramId, int availNum, int availsExpected) { + private Event( + long spliceEventId, + boolean spliceEventCancelIndicator, + boolean outOfNetworkIndicator, + boolean programSpliceFlag, + List componentSpliceList, + long utcSpliceTime, + boolean autoReturn, + long breakDurationUs, + int uniqueProgramId, + int availNum, + int availsExpected) { this.spliceEventId = spliceEventId; this.spliceEventCancelIndicator = spliceEventCancelIndicator; this.outOfNetworkIndicator = outOfNetworkIndicator; @@ -159,9 +155,18 @@ public final class SpliceScheduleCommand extends SpliceCommand { availNum = sectionData.readUnsignedByte(); availsExpected = sectionData.readUnsignedByte(); } - return new Event(spliceEventId, spliceEventCancelIndicator, outOfNetworkIndicator, - programSpliceFlag, componentSplices, utcSpliceTime, autoReturn, breakDurationUs, - uniqueProgramId, availNum, availsExpected); + return new Event( + spliceEventId, + spliceEventCancelIndicator, + outOfNetworkIndicator, + programSpliceFlag, + componentSplices, + utcSpliceTime, + autoReturn, + breakDurationUs, + uniqueProgramId, + availNum, + availsExpected); } private void writeToParcel(Parcel dest) { @@ -185,12 +190,9 @@ public final class SpliceScheduleCommand extends SpliceCommand { private static Event createFromParcel(Parcel in) { return new Event(in); } - } - /** - * Holds splicing information for specific splice schedule command components. - */ + /** Holds splicing information for specific splice schedule command components. */ public static final class ComponentSplice { public final int componentTag; @@ -209,12 +211,9 @@ public final class SpliceScheduleCommand extends SpliceCommand { dest.writeInt(componentTag); dest.writeLong(utcSpliceTime); } - } - /** - * The list of scheduled events. - */ + /** The list of scheduled events. */ public final List events; private SpliceScheduleCommand(List events) { @@ -253,16 +252,14 @@ public final class SpliceScheduleCommand extends SpliceCommand { public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public SpliceScheduleCommand createFromParcel(Parcel in) { - return new SpliceScheduleCommand(in); - } - - @Override - public SpliceScheduleCommand[] newArray(int size) { - return new SpliceScheduleCommand[size]; - } - - }; + @Override + public SpliceScheduleCommand createFromParcel(Parcel in) { + return new SpliceScheduleCommand(in); + } + @Override + public SpliceScheduleCommand[] newArray(int size) { + return new SpliceScheduleCommand[size]; + } + }; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/TimeSignalCommand.java b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/TimeSignalCommand.java index 5115b7a722..aec2a91731 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/TimeSignalCommand.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/metadata/scte35/TimeSignalCommand.java @@ -23,13 +23,9 @@ import com.google.android.exoplayer2.util.TimestampAdjuster; /** Represents a time signal command as defined in SCTE35, Section 9.3.4. */ public final class TimeSignalCommand extends SpliceCommand { - /** - * A PTS value, as defined in SCTE35, Section 9.3.4. - */ + /** A PTS value, as defined in SCTE35, Section 9.3.4. */ public final long ptsTime; - /** - * Equivalent to {@link #ptsTime} but in the playback timebase. - */ + /** Equivalent to {@link #ptsTime} but in the playback timebase. */ public final long playbackPositionUs; private TimeSignalCommand(long ptsTime, long playbackPositionUs) { @@ -37,8 +33,8 @@ public final class TimeSignalCommand extends SpliceCommand { this.playbackPositionUs = playbackPositionUs; } - /* package */ static TimeSignalCommand parseFromSection(ParsableByteArray sectionData, - long ptsAdjustment, TimestampAdjuster timestampAdjuster) { + /* package */ static TimeSignalCommand parseFromSection( + ParsableByteArray sectionData, long ptsAdjustment, TimestampAdjuster timestampAdjuster) { long ptsTime = parseSpliceTime(sectionData, ptsAdjustment); long playbackPositionUs = timestampAdjuster.adjustTsTimestamp(ptsTime); return new TimeSignalCommand(ptsTime, playbackPositionUs); @@ -76,16 +72,14 @@ public final class TimeSignalCommand extends SpliceCommand { public static final Creator CREATOR = new Creator() { - @Override - public TimeSignalCommand createFromParcel(Parcel in) { - return new TimeSignalCommand(in.readLong(), in.readLong()); - } - - @Override - public TimeSignalCommand[] newArray(int size) { - return new TimeSignalCommand[size]; - } - - }; + @Override + public TimeSignalCommand createFromParcel(Parcel in) { + return new TimeSignalCommand(in.readLong(), in.readLong()); + } + @Override + public TimeSignalCommand[] newArray(int size) { + return new TimeSignalCommand[size]; + } + }; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadException.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadException.java index 983727c14d..2f7d7eba89 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/DownloadException.java @@ -29,5 +29,4 @@ public final class DownloadException extends IOException { public DownloadException(Throwable cause) { super(cause); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/ProgressiveDownloader.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/ProgressiveDownloader.java index c2d93f2045..22270a1d4e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/ProgressiveDownloader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/ProgressiveDownloader.java @@ -80,11 +80,7 @@ public final class ProgressiveDownloader implements Downloader { @SuppressWarnings("methodref.receiver.bound.invalid") CacheWriter.ProgressListener progressListener = this::onProgress; cacheWriter = - new CacheWriter( - dataSource, - dataSpec, - /* temporaryBuffer= */ null, - progressListener); + new CacheWriter(dataSource, dataSpec, /* temporaryBuffer= */ null, progressListener); priorityTaskManager = cacheDataSourceFactory.getUpstreamPriorityTaskManager(); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/offline/SegmentDownloader.java b/library/core/src/main/java/com/google/android/exoplayer2/offline/SegmentDownloader.java index 74df93d82f..7156f50a22 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/offline/SegmentDownloader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/offline/SegmentDownloader.java @@ -469,11 +469,7 @@ public abstract class SegmentDownloader> impleme this.progressNotifier = progressNotifier; this.temporaryBuffer = temporaryBuffer; this.cacheWriter = - new CacheWriter( - dataSource, - segment.dataSpec, - temporaryBuffer, - progressNotifier); + new CacheWriter(dataSource, segment.dataSpec, temporaryBuffer, progressNotifier); } @Override diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/BehindLiveWindowException.java b/library/core/src/main/java/com/google/android/exoplayer2/source/BehindLiveWindowException.java index 2d56762175..743659773a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/BehindLiveWindowException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/BehindLiveWindowException.java @@ -23,5 +23,4 @@ public final class BehindLiveWindowException extends IOException { public BehindLiveWindowException() { super(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java index 6a58605480..5da426c517 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ClippingMediaSource.java @@ -59,9 +59,7 @@ public final class ClippingMediaSource extends CompositeMediaSource { /** The reason clipping failed. */ public final @Reason int reason; - /** - * @param reason The reason clipping failed. - */ + /** @param reason The reason clipping failed. */ public IllegalClippingException(@Reason int reason) { super("Illegal clipping: " + getReasonDescription(reason)); this.reason = reason; @@ -293,9 +291,7 @@ public final class ClippingMediaSource extends CompositeMediaSource { refreshSourceInfo(clippingTimeline); } - /** - * Provides a clipped view of a specified timeline. - */ + /** Provides a clipped view of a specified timeline. */ private static final class ClippingTimeline extends ForwardingTimeline { private final long startUs; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderFactory.java index 1507068664..8492245442 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderFactory.java @@ -25,5 +25,4 @@ public interface CompositeSequenceableLoaderFactory { * @return A composite {@link SequenceableLoader} that comprises the given loaders. */ SequenceableLoader createCompositeSequenceableLoader(SequenceableLoader... loaders); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java index 48305bc916..bb9098be4d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ConcatenatingMediaSource.java @@ -86,8 +86,8 @@ public final class ConcatenatingMediaSource extends CompositeMediaSource { private final Map mediaPeriodToChildMediaPeriodId; /** - * Loops the provided source indefinitely. Note that it is usually better to use - * {@link ExoPlayer#setRepeatMode(int)}. + * Loops the provided source indefinitely. Note that it is usually better to use {@link + * ExoPlayer#setRepeatMode(int)}. * * @param childSource The {@link MediaSource} to loop. */ @@ -163,7 +163,8 @@ public final class LoopingMediaSource extends CompositeMediaSource { childWindowCount = childTimeline.getWindowCount(); this.loopCount = loopCount; if (childPeriodCount > 0) { - Assertions.checkState(loopCount <= Integer.MAX_VALUE / childPeriodCount, + Assertions.checkState( + loopCount <= Integer.MAX_VALUE / childPeriodCount, "LoopingMediaSource contains too many periods"); } } @@ -215,7 +216,6 @@ public final class LoopingMediaSource extends CompositeMediaSource { protected Object getChildUidByChildIndex(int childIndex) { return childIndex; } - } private static final class InfinitelyLoopingTimeline extends ForwardingTimeline { @@ -225,23 +225,23 @@ public final class LoopingMediaSource extends CompositeMediaSource { } @Override - public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode, - boolean shuffleModeEnabled) { - int childNextWindowIndex = timeline.getNextWindowIndex(windowIndex, repeatMode, - shuffleModeEnabled); - return childNextWindowIndex == C.INDEX_UNSET ? getFirstWindowIndex(shuffleModeEnabled) + public int getNextWindowIndex( + int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) { + int childNextWindowIndex = + timeline.getNextWindowIndex(windowIndex, repeatMode, shuffleModeEnabled); + return childNextWindowIndex == C.INDEX_UNSET + ? getFirstWindowIndex(shuffleModeEnabled) : childNextWindowIndex; } @Override - public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode, - boolean shuffleModeEnabled) { - int childPreviousWindowIndex = timeline.getPreviousWindowIndex(windowIndex, repeatMode, - shuffleModeEnabled); - return childPreviousWindowIndex == C.INDEX_UNSET ? getLastWindowIndex(shuffleModeEnabled) + public int getPreviousWindowIndex( + int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) { + int childPreviousWindowIndex = + timeline.getPreviousWindowIndex(windowIndex, repeatMode, shuffleModeEnabled); + return childPreviousWindowIndex == C.INDEX_UNSET + ? getLastWindowIndex(shuffleModeEnabled) : childPreviousWindowIndex; } - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java b/library/core/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java index 3a9bfe4f91..d5d6f51fb4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/MergingMediaSource.java @@ -44,9 +44,7 @@ import java.util.Map; */ public final class MergingMediaSource extends CompositeMediaSource { - /** - * Thrown when a {@link MergingMediaSource} cannot merge its sources. - */ + /** Thrown when a {@link MergingMediaSource} cannot merge its sources. */ public static final class IllegalMergeException extends IOException { /** The reason the merge failed. One of {@link #REASON_PERIOD_COUNT_MISMATCH}. */ @@ -54,23 +52,16 @@ public final class MergingMediaSource extends CompositeMediaSource { @Retention(RetentionPolicy.SOURCE) @IntDef({REASON_PERIOD_COUNT_MISMATCH}) public @interface Reason {} - /** - * The sources have different period counts. - */ + /** The sources have different period counts. */ public static final int REASON_PERIOD_COUNT_MISMATCH = 0; - /** - * The reason the merge failed. - */ + /** The reason the merge failed. */ @Reason public final int reason; - /** - * @param reason The reason the merge failed. - */ + /** @param reason The reason the merge failed. */ public IllegalMergeException(@Reason int reason) { this.reason = reason; } - } private static final int PERIOD_COUNT_UNSET = -1; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java index 791dd72479..9c0bccaa88 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java @@ -73,9 +73,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; Loader.ReleaseCallback, UpstreamFormatChangedListener { - /** - * Listener for information about the period. - */ + /** Listener for information about the period. */ interface Listener { /** @@ -404,7 +402,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; if (largestQueuedTimestampUs == Long.MAX_VALUE) { largestQueuedTimestampUs = getLargestQueuedTimestampUs(); } - return largestQueuedTimestampUs == Long.MIN_VALUE ? lastSeekPositionUs + return largestQueuedTimestampUs == Long.MIN_VALUE + ? lastSeekPositionUs : largestQueuedTimestampUs; } @@ -552,8 +551,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; if (durationUs == C.TIME_UNSET && seekMap != null) { boolean isSeekable = seekMap.isSeekable(); long largestQueuedTimestampUs = getLargestQueuedTimestampUs(); - durationUs = largestQueuedTimestampUs == Long.MIN_VALUE ? 0 - : largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US; + durationUs = + largestQueuedTimestampUs == Long.MIN_VALUE + ? 0 + : largestQueuedTimestampUs + DEFAULT_LAST_SAMPLE_DURATION_US; listener.onSourceInfoRefreshed(durationUs, isSeekable, isLive); } StatsDataSource dataSource = loadable.dataSource; @@ -844,8 +845,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; * retry. */ private boolean configureRetry(ExtractingLoadable loadable, int currentExtractedSampleCount) { - if (length != C.LENGTH_UNSET - || (seekMap != null && seekMap.getDurationUs() != C.TIME_UNSET)) { + if (length != C.LENGTH_UNSET || (seekMap != null && seekMap.getDurationUs() != C.TIME_UNSET)) { // We're playing an on-demand stream. Resume the current loadable, which will // request data starting from the point it left off. extractedSamplesCountAtStartOfLoad = currentExtractedSampleCount; @@ -957,7 +957,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public int skipData(long positionUs) { return ProgressiveMediaPeriod.this.skipData(track, positionUs); } - } /** Loads the media stream and extracts sample data from it. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/SequenceableLoader.java b/library/core/src/main/java/com/google/android/exoplayer2/source/SequenceableLoader.java index e500d0520a..91f0e9b820 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/SequenceableLoader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/SequenceableLoader.java @@ -21,9 +21,7 @@ import com.google.android.exoplayer2.C; /** A loader that can proceed in approximate synchronization with other loaders. */ public interface SequenceableLoader { - /** - * A callback to be notified of {@link SequenceableLoader} events. - */ + /** A callback to be notified of {@link SequenceableLoader} events. */ interface Callback { /** @@ -31,7 +29,6 @@ public interface SequenceableLoader { * to be called when it can continue to load data. Called on the playback thread. */ void onContinueLoadingRequested(T source); - } /** @@ -42,19 +39,17 @@ public interface SequenceableLoader { */ long getBufferedPositionUs(); - /** - * Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished. - */ + /** Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished. */ long getNextLoadPositionUs(); /** * Attempts to continue loading. * * @param positionUs The current playback position in microseconds. If playback of the period to - * which this loader belongs has not yet started, the value will be the starting position - * in the period minus the duration of any media in previous periods still to be played. - * @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return - * a different value than prior to the call. False otherwise. + * which this loader belongs has not yet started, the value will be the starting position in + * the period minus the duration of any media in previous periods still to be played. + * @return True if progress was made, meaning that {@link #getNextLoadPositionUs()} will return a + * different value than prior to the call. False otherwise. */ boolean continueLoading(long positionUs); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ShuffleOrder.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ShuffleOrder.java index 5af9dbd20a..e8f804fbe0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ShuffleOrder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ShuffleOrder.java @@ -26,9 +26,7 @@ import java.util.Random; */ public interface ShuffleOrder { - /** - * The default {@link ShuffleOrder} implementation for random shuffle order. - */ + /** The default {@link ShuffleOrder} implementation for random shuffle order. */ class DefaultShuffleOrder implements ShuffleOrder { private final Random random; @@ -164,12 +162,9 @@ public interface ShuffleOrder { } return shuffled; } - } - /** - * A {@link ShuffleOrder} implementation which does not shuffle. - */ + /** A {@link ShuffleOrder} implementation which does not shuffle. */ final class UnshuffledShuffleOrder implements ShuffleOrder { private final int length; @@ -224,9 +219,7 @@ public interface ShuffleOrder { } } - /** - * Returns length of shuffle order. - */ + /** Returns length of shuffle order. */ int getLength(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/UnrecognizedInputFormatException.java b/library/core/src/main/java/com/google/android/exoplayer2/source/UnrecognizedInputFormatException.java index 324f89794a..5ba1bfb5e0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/UnrecognizedInputFormatException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/UnrecognizedInputFormatException.java @@ -21,9 +21,7 @@ import com.google.android.exoplayer2.ParserException; /** Thrown if the input format was not recognized. */ public class UnrecognizedInputFormatException extends ParserException { - /** - * The {@link Uri} from which the unrecognized data was read. - */ + /** The {@link Uri} from which the unrecognized data was read. */ public final Uri uri; /** @@ -34,5 +32,4 @@ public class UnrecognizedInputFormatException extends ParserException { super(message); this.uri = uri; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java index cc82510a29..9c3dd042b4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/ads/SinglePeriodAdTimeline.java @@ -55,5 +55,4 @@ public final class SinglePeriodAdTimeline extends ForwardingTimeline { adPlaybackState); return period; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunk.java index 8693bb8912..330bb494da 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunk.java @@ -65,8 +65,15 @@ public abstract class BaseMediaChunk extends MediaChunk { long clippedStartTimeUs, long clippedEndTimeUs, long chunkIndex) { - super(dataSource, dataSpec, trackFormat, trackSelectionReason, trackSelectionData, startTimeUs, - endTimeUs, chunkIndex); + super( + dataSource, + dataSpec, + trackFormat, + trackSelectionReason, + trackSelectionData, + startTimeUs, + endTimeUs, + chunkIndex); this.clippedStartTimeUs = clippedStartTimeUs; this.clippedEndTimeUs = clippedEndTimeUs; } @@ -90,11 +97,8 @@ public abstract class BaseMediaChunk extends MediaChunk { return Assertions.checkStateNotNull(firstSampleIndices)[trackIndex]; } - /** - * Returns the output most recently passed to {@link #init(BaseMediaChunkOutput)}. - */ + /** Returns the output most recently passed to {@link #init(BaseMediaChunkOutput)}. */ protected final BaseMediaChunkOutput getOutput() { return Assertions.checkStateNotNull(output); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java index 961d1f8db6..f7b2524e07 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BaseMediaChunkOutput.java @@ -52,9 +52,7 @@ public final class BaseMediaChunkOutput implements TrackOutputProvider { return new DummyTrackOutput(); } - /** - * Returns the current absolute write indices of the individual sample queues. - */ + /** Returns the current absolute write indices of the individual sample queues. */ public int[] getWriteIndices() { int[] writeIndices = new int[sampleQueues.length]; for (int i = 0; i < sampleQueues.length; i++) { @@ -72,5 +70,4 @@ public final class BaseMediaChunkOutput implements TrackOutputProvider { sampleQueue.setSampleOffsetUs(sampleOffsetUs); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java index ff19ee1d26..322ee748fd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/BundledChunkExtractor.java @@ -164,8 +164,9 @@ public final class BundledChunkExtractor implements ExtractorOutput, ChunkExtrac // Assert that if we're seeing a new track we have not seen endTracks. Assertions.checkState(sampleFormats == null); // TODO: Manifest formats for embedded tracks should also be passed here. - bindingTrackOutput = new BindingTrackOutput(id, type, - type == primaryTrackType ? primaryTrackManifestFormat : null); + bindingTrackOutput = + new BindingTrackOutput( + id, type, type == primaryTrackType ? primaryTrackManifestFormat : null); bindingTrackOutput.bind(trackOutputProvider, endTimeUs); bindingTrackOutputs.put(id, bindingTrackOutput); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/Chunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/Chunk.java index 1c729b3f35..b8dab7a075 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/Chunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/Chunk.java @@ -57,8 +57,8 @@ public abstract class Chunk implements Loadable { */ @Nullable public final Object trackSelectionData; /** - * The start time of the media contained by the chunk, or {@link C#TIME_UNSET} if the data - * being loaded does not contain media samples. + * The start time of the media contained by the chunk, or {@link C#TIME_UNSET} if the data being + * loaded does not contain media samples. */ public final long startTimeUs; /** @@ -99,9 +99,7 @@ public abstract class Chunk implements Loadable { loadTaskId = LoadEventInfo.getNewId(); } - /** - * Returns the duration of the chunk in microseconds. - */ + /** Returns the duration of the chunk in microseconds. */ public final long getDurationUs() { return endTimeUs - startTimeUs; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkHolder.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkHolder.java index da0a71e82d..8d47ac7ad9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkHolder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkHolder.java @@ -23,17 +23,12 @@ public final class ChunkHolder { /** The chunk. */ @Nullable public Chunk chunk; - /** - * Indicates that the end of the stream has been reached. - */ + /** Indicates that the end of the stream has been reached. */ public boolean endOfStream; - /** - * Clears the holder. - */ + /** Clears the holder. */ public void clear() { chunk = null; endOfStream = false; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java index 40c1b7f357..1dd1186a3b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/ChunkSampleStream.java @@ -211,9 +211,7 @@ public class ChunkSampleStream throw new IllegalStateException(); } - /** - * Returns the {@link ChunkSource} used by this stream. - */ + /** Returns the {@link ChunkSource} used by this stream. */ public T getChunkSource() { return chunkSource; } @@ -233,8 +231,10 @@ public class ChunkSampleStream } else { long bufferedPositionUs = lastSeekPositionUs; BaseMediaChunk lastMediaChunk = getLastMediaChunk(); - BaseMediaChunk lastCompletedMediaChunk = lastMediaChunk.isLoadCompleted() ? lastMediaChunk - : mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null; + BaseMediaChunk lastCompletedMediaChunk = + lastMediaChunk.isLoadCompleted() + ? lastMediaChunk + : mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null; if (lastCompletedMediaChunk != null) { bufferedPositionUs = max(bufferedPositionUs, lastCompletedMediaChunk.endTimeUs); } @@ -812,9 +812,7 @@ public class ChunkSampleStream return firstRemovedChunk; } - /** - * A {@link SampleStream} embedded in a {@link ChunkSampleStream}. - */ + /** A {@link SampleStream} embedded in a {@link ChunkSampleStream}. */ public final class EmbeddedSampleStream implements SampleStream { public final ChunkSampleStream parent; @@ -895,5 +893,4 @@ public class ChunkSampleStream } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java index cec6c0ee02..7e8afb00ab 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/DataChunk.java @@ -53,8 +53,15 @@ public abstract class DataChunk extends Chunk { int trackSelectionReason, @Nullable Object trackSelectionData, @Nullable byte[] data) { - super(dataSource, dataSpec, type, trackFormat, trackSelectionReason, trackSelectionData, - C.TIME_UNSET, C.TIME_UNSET); + super( + dataSource, + dataSpec, + type, + trackFormat, + trackSelectionReason, + trackSelectionData, + C.TIME_UNSET, + C.TIME_UNSET); this.data = data == null ? Util.EMPTY_BYTE_ARRAY : data; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java index 944b25395a..b9717a3d46 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/InitializationChunk.java @@ -54,8 +54,15 @@ public final class InitializationChunk extends Chunk { int trackSelectionReason, @Nullable Object trackSelectionData, ChunkExtractor chunkExtractor) { - super(dataSource, dataSpec, C.DATA_TYPE_MEDIA_INITIALIZATION, trackFormat, trackSelectionReason, - trackSelectionData, C.TIME_UNSET, C.TIME_UNSET); + super( + dataSource, + dataSpec, + C.DATA_TYPE_MEDIA_INITIALIZATION, + trackFormat, + trackSelectionReason, + trackSelectionData, + C.TIME_UNSET, + C.TIME_UNSET); this.chunkExtractor = chunkExtractor; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/MediaChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/MediaChunk.java index 690b9db4d8..7e4913db15 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/MediaChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/MediaChunk.java @@ -47,8 +47,15 @@ public abstract class MediaChunk extends Chunk { long startTimeUs, long endTimeUs, long chunkIndex) { - super(dataSource, dataSpec, C.DATA_TYPE_MEDIA, trackFormat, trackSelectionReason, - trackSelectionData, startTimeUs, endTimeUs); + super( + dataSource, + dataSpec, + C.DATA_TYPE_MEDIA, + trackFormat, + trackSelectionReason, + trackSelectionData, + startTimeUs, + endTimeUs); Assertions.checkNotNull(trackFormat); this.chunkIndex = chunkIndex; } @@ -58,9 +65,6 @@ public abstract class MediaChunk extends Chunk { return chunkIndex != C.INDEX_UNSET ? chunkIndex + 1 : C.INDEX_UNSET; } - /** - * Returns whether the chunk has been fully loaded. - */ + /** Returns whether the chunk has been fully loaded. */ public abstract boolean isLoadCompleted(); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java index 4c84a91be2..1ded32b70c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java @@ -74,7 +74,6 @@ public final class SingleSampleMediaChunk extends BaseMediaChunk { this.sampleFormat = sampleFormat; } - @Override public boolean isLoadCompleted() { return loadCompleted; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java index fb5e1f198a..d54f9e0f58 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java @@ -89,5 +89,4 @@ public abstract class SimpleSubtitleDecoder */ protected abstract Subtitle decode(byte[] data, int size, boolean reset) throws SubtitleDecoderException; - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleOutputBuffer.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleOutputBuffer.java index 6807661c84..ab2736e680 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleOutputBuffer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleOutputBuffer.java @@ -15,9 +15,7 @@ */ package com.google.android.exoplayer2.text; -/** - * A {@link SubtitleOutputBuffer} for decoders that extend {@link SimpleSubtitleDecoder}. - */ +/** A {@link SubtitleOutputBuffer} for decoders that extend {@link SimpleSubtitleDecoder}. */ /* package */ final class SimpleSubtitleOutputBuffer extends SubtitleOutputBuffer { private final Owner owner; @@ -32,5 +30,4 @@ package com.google.android.exoplayer2.text; public final void release() { owner.releaseOutputBuffer(this); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/Subtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/Subtitle.java index 861faa73f9..6581939d07 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/Subtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/Subtitle.java @@ -53,5 +53,4 @@ public interface Subtitle { * @return A list of cues that should be displayed, possibly empty. */ List getCues(long timeUs); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoder.java index 7571b0ffef..e02ac36e5c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoder.java @@ -23,11 +23,10 @@ public interface SubtitleDecoder /** * Informs the decoder of the current playback position. - *

- * Must be called prior to each attempt to dequeue output buffers from the decoder. + * + *

Must be called prior to each attempt to dequeue output buffers from the decoder. * * @param positionUs The current playback position in microseconds. */ void setPositionUs(long positionUs); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderException.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderException.java index 7de577f18c..05d10c4786 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderException.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleDecoderException.java @@ -21,9 +21,7 @@ import com.google.android.exoplayer2.decoder.DecoderException; /** Thrown when an error occurs decoding subtitle data. */ public class SubtitleDecoderException extends DecoderException { - /** - * @param message The detail message for this exception. - */ + /** @param message The detail message for this exception. */ public SubtitleDecoderException(String message) { super(message); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleInputBuffer.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleInputBuffer.java index 9866517a58..1e80a62e11 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleInputBuffer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleInputBuffer.java @@ -22,13 +22,12 @@ import com.google.android.exoplayer2.decoder.DecoderInputBuffer; public class SubtitleInputBuffer extends DecoderInputBuffer { /** - * An offset that must be added to the subtitle's event times after it's been decoded, or - * {@link Format#OFFSET_SAMPLE_RELATIVE} if {@link #timeUs} should be added. + * An offset that must be added to the subtitle's event times after it's been decoded, or {@link + * Format#OFFSET_SAMPLE_RELATIVE} if {@link #timeUs} should be added. */ public long subsampleOffsetUs; public SubtitleInputBuffer() { super(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java index 1dfa9ffb45..7d9c8d9c32 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java @@ -33,14 +33,14 @@ public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subti * * @param timeUs The time of the start of the subtitle in microseconds. * @param subtitle The subtitle. - * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or - * {@link Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added. + * @param subsampleOffsetUs An offset that must be added to the subtitle's event times, or {@link + * Format#OFFSET_SAMPLE_RELATIVE} if {@code timeUs} should be added. */ public void setContent(long timeUs, Subtitle subtitle, long subsampleOffsetUs) { this.timeUs = timeUs; this.subtitle = subtitle; - this.subsampleOffsetUs = subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs - : subsampleOffsetUs; + this.subsampleOffsetUs = + subsampleOffsetUs == Format.OFFSET_SAMPLE_RELATIVE ? this.timeUs : subsampleOffsetUs; } @Override @@ -68,5 +68,4 @@ public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subti super.clear(); subtitle = null; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java index c721fe8da0..5a27d5bb3a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/TextRenderer.java @@ -58,9 +58,7 @@ public final class TextRenderer extends BaseRenderer implements Callback { REPLACEMENT_STATE_WAIT_END_OF_STREAM }) private @interface ReplacementState {} - /** - * The decoder does not need to be replaced. - */ + /** The decoder does not need to be replaced. */ private static final int REPLACEMENT_STATE_NONE = 0; /** * The decoder needs to be replaced, but we haven't yet signaled an end of stream to the existing diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java index 97890d7ee5..b0e3f3f15e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea608Decoder.java @@ -141,72 +141,148 @@ public final class Cea608Decoder extends CeaDecoder { private static final byte CTRL_END_OF_CAPTION = 0x2F; // Basic North American 608 CC char set, mostly ASCII. Indexed by (char-0x20). - private static final int[] BASIC_CHARACTER_SET = new int[] { - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, // ! " # $ % & ' - 0x28, 0x29, // ( ) - 0xE1, // 2A: 225 'á' "Latin small letter A with acute" - 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, // + , - . / - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, // 0 1 2 3 4 5 6 7 - 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, // 8 9 : ; < = > ? - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, // @ A B C D E F G - 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, // H I J K L M N O - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, // P Q R S T U V W - 0x58, 0x59, 0x5A, 0x5B, // X Y Z [ - 0xE9, // 5C: 233 'é' "Latin small letter E with acute" - 0x5D, // ] - 0xED, // 5E: 237 'í' "Latin small letter I with acute" - 0xF3, // 5F: 243 'ó' "Latin small letter O with acute" - 0xFA, // 60: 250 'ú' "Latin small letter U with acute" - 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, // a b c d e f g - 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, // h i j k l m n o - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, // p q r s t u v w - 0x78, 0x79, 0x7A, // x y z - 0xE7, // 7B: 231 'ç' "Latin small letter C with cedilla" - 0xF7, // 7C: 247 '÷' "Division sign" - 0xD1, // 7D: 209 'Ñ' "Latin capital letter N with tilde" - 0xF1, // 7E: 241 'ñ' "Latin small letter N with tilde" - 0x25A0 // 7F: "Black Square" (NB: 2588 = Full Block) - }; + private static final int[] BASIC_CHARACTER_SET = + new int[] { + 0x20, + 0x21, + 0x22, + 0x23, + 0x24, + 0x25, + 0x26, + 0x27, // ! " # $ % & ' + 0x28, + 0x29, // ( ) + 0xE1, // 2A: 225 'á' "Latin small letter A with acute" + 0x2B, + 0x2C, + 0x2D, + 0x2E, + 0x2F, // + , - . / + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, // 0 1 2 3 4 5 6 7 + 0x38, + 0x39, + 0x3A, + 0x3B, + 0x3C, + 0x3D, + 0x3E, + 0x3F, // 8 9 : ; < = > ? + 0x40, + 0x41, + 0x42, + 0x43, + 0x44, + 0x45, + 0x46, + 0x47, // @ A B C D E F G + 0x48, + 0x49, + 0x4A, + 0x4B, + 0x4C, + 0x4D, + 0x4E, + 0x4F, // H I J K L M N O + 0x50, + 0x51, + 0x52, + 0x53, + 0x54, + 0x55, + 0x56, + 0x57, // P Q R S T U V W + 0x58, + 0x59, + 0x5A, + 0x5B, // X Y Z [ + 0xE9, // 5C: 233 'é' "Latin small letter E with acute" + 0x5D, // ] + 0xED, // 5E: 237 'í' "Latin small letter I with acute" + 0xF3, // 5F: 243 'ó' "Latin small letter O with acute" + 0xFA, // 60: 250 'ú' "Latin small letter U with acute" + 0x61, + 0x62, + 0x63, + 0x64, + 0x65, + 0x66, + 0x67, // a b c d e f g + 0x68, + 0x69, + 0x6A, + 0x6B, + 0x6C, + 0x6D, + 0x6E, + 0x6F, // h i j k l m n o + 0x70, + 0x71, + 0x72, + 0x73, + 0x74, + 0x75, + 0x76, + 0x77, // p q r s t u v w + 0x78, + 0x79, + 0x7A, // x y z + 0xE7, // 7B: 231 'ç' "Latin small letter C with cedilla" + 0xF7, // 7C: 247 '÷' "Division sign" + 0xD1, // 7D: 209 'Ñ' "Latin capital letter N with tilde" + 0xF1, // 7E: 241 'ñ' "Latin small letter N with tilde" + 0x25A0 // 7F: "Black Square" (NB: 2588 = Full Block) + }; // Special North American 608 CC char set. - private static final int[] SPECIAL_CHARACTER_SET = new int[] { - 0xAE, // 30: 174 '®' "Registered Sign" - registered trademark symbol - 0xB0, // 31: 176 '°' "Degree Sign" - 0xBD, // 32: 189 '½' "Vulgar Fraction One Half" (1/2 symbol) - 0xBF, // 33: 191 '¿' "Inverted Question Mark" - 0x2122, // 34: "Trade Mark Sign" (tm superscript) - 0xA2, // 35: 162 '¢' "Cent Sign" - 0xA3, // 36: 163 '£' "Pound Sign" - pounds sterling - 0x266A, // 37: "Eighth Note" - music note - 0xE0, // 38: 224 'à' "Latin small letter A with grave" - 0x20, // 39: TRANSPARENT SPACE - for now use ordinary space - 0xE8, // 3A: 232 'è' "Latin small letter E with grave" - 0xE2, // 3B: 226 'â' "Latin small letter A with circumflex" - 0xEA, // 3C: 234 'ê' "Latin small letter E with circumflex" - 0xEE, // 3D: 238 'î' "Latin small letter I with circumflex" - 0xF4, // 3E: 244 'ô' "Latin small letter O with circumflex" - 0xFB // 3F: 251 'û' "Latin small letter U with circumflex" - }; + private static final int[] SPECIAL_CHARACTER_SET = + new int[] { + 0xAE, // 30: 174 '®' "Registered Sign" - registered trademark symbol + 0xB0, // 31: 176 '°' "Degree Sign" + 0xBD, // 32: 189 '½' "Vulgar Fraction One Half" (1/2 symbol) + 0xBF, // 33: 191 '¿' "Inverted Question Mark" + 0x2122, // 34: "Trade Mark Sign" (tm superscript) + 0xA2, // 35: 162 '¢' "Cent Sign" + 0xA3, // 36: 163 '£' "Pound Sign" - pounds sterling + 0x266A, // 37: "Eighth Note" - music note + 0xE0, // 38: 224 'à' "Latin small letter A with grave" + 0x20, // 39: TRANSPARENT SPACE - for now use ordinary space + 0xE8, // 3A: 232 'è' "Latin small letter E with grave" + 0xE2, // 3B: 226 'â' "Latin small letter A with circumflex" + 0xEA, // 3C: 234 'ê' "Latin small letter E with circumflex" + 0xEE, // 3D: 238 'î' "Latin small letter I with circumflex" + 0xF4, // 3E: 244 'ô' "Latin small letter O with circumflex" + 0xFB // 3F: 251 'û' "Latin small letter U with circumflex" + }; // Extended Spanish/Miscellaneous and French char set. - private static final int[] SPECIAL_ES_FR_CHARACTER_SET = new int[] { - // Spanish and misc. - 0xC1, 0xC9, 0xD3, 0xDA, 0xDC, 0xFC, 0x2018, 0xA1, - 0x2A, 0x27, 0x2014, 0xA9, 0x2120, 0x2022, 0x201C, 0x201D, - // French. - 0xC0, 0xC2, 0xC7, 0xC8, 0xCA, 0xCB, 0xEB, 0xCE, - 0xCF, 0xEF, 0xD4, 0xD9, 0xF9, 0xDB, 0xAB, 0xBB - }; + private static final int[] SPECIAL_ES_FR_CHARACTER_SET = + new int[] { + // Spanish and misc. + 0xC1, 0xC9, 0xD3, 0xDA, 0xDC, 0xFC, 0x2018, 0xA1, + 0x2A, 0x27, 0x2014, 0xA9, 0x2120, 0x2022, 0x201C, 0x201D, + // French. + 0xC0, 0xC2, 0xC7, 0xC8, 0xCA, 0xCB, 0xEB, 0xCE, + 0xCF, 0xEF, 0xD4, 0xD9, 0xF9, 0xDB, 0xAB, 0xBB + }; - //Extended Portuguese and German/Danish char set. - private static final int[] SPECIAL_PT_DE_CHARACTER_SET = new int[] { - // Portuguese. - 0xC3, 0xE3, 0xCD, 0xCC, 0xEC, 0xD2, 0xF2, 0xD5, - 0xF5, 0x7B, 0x7D, 0x5C, 0x5E, 0x5F, 0x7C, 0x7E, - // German/Danish. - 0xC4, 0xE4, 0xD6, 0xF6, 0xDF, 0xA5, 0xA4, 0x2502, - 0xC5, 0xE5, 0xD8, 0xF8, 0x250C, 0x2510, 0x2514, 0x2518 - }; + // Extended Portuguese and German/Danish char set. + private static final int[] SPECIAL_PT_DE_CHARACTER_SET = + new int[] { + // Portuguese. + 0xC3, 0xE3, 0xCD, 0xCC, 0xEC, 0xD2, 0xF2, 0xD5, + 0xF5, 0x7B, 0x7D, 0x5C, 0x5E, 0x5F, 0x7C, 0x7E, + // German/Danish. + 0xC4, 0xE4, 0xD6, 0xF6, 0xDF, 0xA5, 0xA4, 0x2502, + 0xC5, 0xE5, 0xD8, 0xF8, 0x250C, 0x2510, 0x2514, 0x2518 + }; private static final boolean[] ODD_PARITY_BYTE_TABLE = { false, true, true, false, true, false, false, true, // 0 @@ -383,8 +459,8 @@ public final class Cea608Decoder extends CeaDecoder { ccData.reset(subtitleData.array(), subtitleData.limit()); boolean captionDataProcessed = false; while (ccData.bytesLeft() >= packetLength) { - byte ccHeader = packetLength == 2 ? CC_IMPLICIT_DATA_HEADER - : (byte) ccData.readUnsignedByte(); + byte ccHeader = + packetLength == 2 ? CC_IMPLICIT_DATA_HEADER : (byte) ccData.readUnsignedByte(); int ccByte1 = ccData.readUnsignedByte(); int ccByte2 = ccData.readUnsignedByte(); @@ -669,7 +745,8 @@ public final class Cea608Decoder extends CeaDecoder { // Clear the working memory. resetCueBuilders(); - if (oldCaptionMode == CC_MODE_PAINT_ON || captionMode == CC_MODE_ROLL_UP + if (oldCaptionMode == CC_MODE_PAINT_ON + || captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_UNKNOWN) { // When switching from paint-on or to roll-up or unknown, we also need to clear the caption. cues = Collections.emptyList(); @@ -1065,9 +1142,7 @@ public final class Cea608Decoder extends CeaDecoder { this.underline = underline; this.start = start; } - } - } /** See ANSI/CTA-608-E R-2014 Annex C.9 for Caption Erase Logic. */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java index e91edcd307..d09be81f37 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/Cea708Decoder.java @@ -57,62 +57,62 @@ public final class Cea708Decoder extends CeaDecoder { private static final int CC_VALID_FLAG = 0x04; // Base Commands - private static final int GROUP_C0_END = 0x1F; // Miscellaneous Control Codes - private static final int GROUP_G0_END = 0x7F; // ASCII Printable Characters - private static final int GROUP_C1_END = 0x9F; // Captioning Command Control Codes - private static final int GROUP_G1_END = 0xFF; // ISO 8859-1 LATIN-1 Character Set + private static final int GROUP_C0_END = 0x1F; // Miscellaneous Control Codes + private static final int GROUP_G0_END = 0x7F; // ASCII Printable Characters + private static final int GROUP_C1_END = 0x9F; // Captioning Command Control Codes + private static final int GROUP_G1_END = 0xFF; // ISO 8859-1 LATIN-1 Character Set // Extended Commands - private static final int GROUP_C2_END = 0x1F; // Extended Control Code Set 1 - private static final int GROUP_G2_END = 0x7F; // Extended Miscellaneous Characters - private static final int GROUP_C3_END = 0x9F; // Extended Control Code Set 2 - private static final int GROUP_G3_END = 0xFF; // Future Expansion + private static final int GROUP_C2_END = 0x1F; // Extended Control Code Set 1 + private static final int GROUP_G2_END = 0x7F; // Extended Miscellaneous Characters + private static final int GROUP_C3_END = 0x9F; // Extended Control Code Set 2 + private static final int GROUP_G3_END = 0xFF; // Future Expansion // Group C0 Commands - private static final int COMMAND_NUL = 0x00; // Nul - private static final int COMMAND_ETX = 0x03; // EndOfText - private static final int COMMAND_BS = 0x08; // Backspace - private static final int COMMAND_FF = 0x0C; // FormFeed (Flush) - private static final int COMMAND_CR = 0x0D; // CarriageReturn - private static final int COMMAND_HCR = 0x0E; // ClearLine - private static final int COMMAND_EXT1 = 0x10; // Extended Control Code Flag + private static final int COMMAND_NUL = 0x00; // Nul + private static final int COMMAND_ETX = 0x03; // EndOfText + private static final int COMMAND_BS = 0x08; // Backspace + private static final int COMMAND_FF = 0x0C; // FormFeed (Flush) + private static final int COMMAND_CR = 0x0D; // CarriageReturn + private static final int COMMAND_HCR = 0x0E; // ClearLine + private static final int COMMAND_EXT1 = 0x10; // Extended Control Code Flag private static final int COMMAND_EXT1_START = 0x11; private static final int COMMAND_EXT1_END = 0x17; private static final int COMMAND_P16_START = 0x18; private static final int COMMAND_P16_END = 0x1F; // Group C1 Commands - private static final int COMMAND_CW0 = 0x80; // SetCurrentWindow to 0 - private static final int COMMAND_CW1 = 0x81; // SetCurrentWindow to 1 - private static final int COMMAND_CW2 = 0x82; // SetCurrentWindow to 2 - private static final int COMMAND_CW3 = 0x83; // SetCurrentWindow to 3 - private static final int COMMAND_CW4 = 0x84; // SetCurrentWindow to 4 - private static final int COMMAND_CW5 = 0x85; // SetCurrentWindow to 5 - private static final int COMMAND_CW6 = 0x86; // SetCurrentWindow to 6 - private static final int COMMAND_CW7 = 0x87; // SetCurrentWindow to 7 - private static final int COMMAND_CLW = 0x88; // ClearWindows (+1 byte) - private static final int COMMAND_DSW = 0x89; // DisplayWindows (+1 byte) - private static final int COMMAND_HDW = 0x8A; // HideWindows (+1 byte) - private static final int COMMAND_TGW = 0x8B; // ToggleWindows (+1 byte) - private static final int COMMAND_DLW = 0x8C; // DeleteWindows (+1 byte) - private static final int COMMAND_DLY = 0x8D; // Delay (+1 byte) - private static final int COMMAND_DLC = 0x8E; // DelayCancel - private static final int COMMAND_RST = 0x8F; // Reset - private static final int COMMAND_SPA = 0x90; // SetPenAttributes (+2 bytes) - private static final int COMMAND_SPC = 0x91; // SetPenColor (+3 bytes) - private static final int COMMAND_SPL = 0x92; // SetPenLocation (+2 bytes) - private static final int COMMAND_SWA = 0x97; // SetWindowAttributes (+4 bytes) - private static final int COMMAND_DF0 = 0x98; // DefineWindow 0 (+6 bytes) - private static final int COMMAND_DF1 = 0x99; // DefineWindow 1 (+6 bytes) - private static final int COMMAND_DF2 = 0x9A; // DefineWindow 2 (+6 bytes) - private static final int COMMAND_DF3 = 0x9B; // DefineWindow 3 (+6 bytes) + private static final int COMMAND_CW0 = 0x80; // SetCurrentWindow to 0 + private static final int COMMAND_CW1 = 0x81; // SetCurrentWindow to 1 + private static final int COMMAND_CW2 = 0x82; // SetCurrentWindow to 2 + private static final int COMMAND_CW3 = 0x83; // SetCurrentWindow to 3 + private static final int COMMAND_CW4 = 0x84; // SetCurrentWindow to 4 + private static final int COMMAND_CW5 = 0x85; // SetCurrentWindow to 5 + private static final int COMMAND_CW6 = 0x86; // SetCurrentWindow to 6 + private static final int COMMAND_CW7 = 0x87; // SetCurrentWindow to 7 + private static final int COMMAND_CLW = 0x88; // ClearWindows (+1 byte) + private static final int COMMAND_DSW = 0x89; // DisplayWindows (+1 byte) + private static final int COMMAND_HDW = 0x8A; // HideWindows (+1 byte) + private static final int COMMAND_TGW = 0x8B; // ToggleWindows (+1 byte) + private static final int COMMAND_DLW = 0x8C; // DeleteWindows (+1 byte) + private static final int COMMAND_DLY = 0x8D; // Delay (+1 byte) + private static final int COMMAND_DLC = 0x8E; // DelayCancel + private static final int COMMAND_RST = 0x8F; // Reset + private static final int COMMAND_SPA = 0x90; // SetPenAttributes (+2 bytes) + private static final int COMMAND_SPC = 0x91; // SetPenColor (+3 bytes) + private static final int COMMAND_SPL = 0x92; // SetPenLocation (+2 bytes) + private static final int COMMAND_SWA = 0x97; // SetWindowAttributes (+4 bytes) + private static final int COMMAND_DF0 = 0x98; // DefineWindow 0 (+6 bytes) + private static final int COMMAND_DF1 = 0x99; // DefineWindow 1 (+6 bytes) + private static final int COMMAND_DF2 = 0x9A; // DefineWindow 2 (+6 bytes) + private static final int COMMAND_DF3 = 0x9B; // DefineWindow 3 (+6 bytes) private static final int COMMAND_DF4 = 0x9C; // DefineWindow 4 (+6 bytes) - private static final int COMMAND_DF5 = 0x9D; // DefineWindow 5 (+6 bytes) - private static final int COMMAND_DF6 = 0x9E; // DefineWindow 6 (+6 bytes) - private static final int COMMAND_DF7 = 0x9F; // DefineWindow 7 (+6 bytes) + private static final int COMMAND_DF5 = 0x9D; // DefineWindow 5 (+6 bytes) + private static final int COMMAND_DF6 = 0x9E; // DefineWindow 6 (+6 bytes) + private static final int COMMAND_DF7 = 0x9F; // DefineWindow 7 (+6 bytes) // G0 Table Special Chars - private static final int CHARACTER_MN = 0x7F; // MusicNote + private static final int CHARACTER_MN = 0x7F; // MusicNote // G2 Table Special Chars private static final int CHARACTER_TSP = 0x20; @@ -825,7 +825,6 @@ public final class Cea708Decoder extends CeaDecoder { packetData = new byte[2 * packetSize - 1]; currentIndex = 0; } - } // TODO: There is a lot of overlap between Cea708Decoder.CueInfoBuilder and @@ -872,45 +871,64 @@ public final class Cea708Decoder extends CeaDecoder { private static final int PEN_OFFSET_NORMAL = 1; // The window style properties are specified in the CEA-708 specification. - private static final int[] WINDOW_STYLE_JUSTIFICATION = new int[] { - JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, - JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, JUSTIFICATION_CENTER, - JUSTIFICATION_LEFT - }; - private static final int[] WINDOW_STYLE_PRINT_DIRECTION = new int[] { - DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, - DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, - DIRECTION_TOP_TO_BOTTOM - }; - private static final int[] WINDOW_STYLE_SCROLL_DIRECTION = new int[] { - DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, - DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, - DIRECTION_RIGHT_TO_LEFT - }; - private static final boolean[] WINDOW_STYLE_WORD_WRAP = new boolean[] { - false, false, false, true, true, true, false - }; - private static final int[] WINDOW_STYLE_FILL = new int[] { - COLOR_SOLID_BLACK, COLOR_TRANSPARENT, COLOR_SOLID_BLACK, COLOR_SOLID_BLACK, - COLOR_TRANSPARENT, COLOR_SOLID_BLACK, COLOR_SOLID_BLACK - }; + private static final int[] WINDOW_STYLE_JUSTIFICATION = + new int[] { + JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, + JUSTIFICATION_LEFT, JUSTIFICATION_LEFT, JUSTIFICATION_CENTER, + JUSTIFICATION_LEFT + }; + private static final int[] WINDOW_STYLE_PRINT_DIRECTION = + new int[] { + DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, + DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, DIRECTION_LEFT_TO_RIGHT, + DIRECTION_TOP_TO_BOTTOM + }; + private static final int[] WINDOW_STYLE_SCROLL_DIRECTION = + new int[] { + DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, + DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, DIRECTION_BOTTOM_TO_TOP, + DIRECTION_RIGHT_TO_LEFT + }; + private static final boolean[] WINDOW_STYLE_WORD_WRAP = + new boolean[] {false, false, false, true, true, true, false}; + private static final int[] WINDOW_STYLE_FILL = + new int[] { + COLOR_SOLID_BLACK, + COLOR_TRANSPARENT, + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK, + COLOR_TRANSPARENT, + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK + }; // The pen style properties are specified in the CEA-708 specification. - private static final int[] PEN_STYLE_FONT_STYLE = new int[] { - PEN_FONT_STYLE_DEFAULT, PEN_FONT_STYLE_MONOSPACED_WITH_SERIFS, - PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITH_SERIFS, PEN_FONT_STYLE_MONOSPACED_WITHOUT_SERIFS, - PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITHOUT_SERIFS, - PEN_FONT_STYLE_MONOSPACED_WITHOUT_SERIFS, - PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITHOUT_SERIFS - }; - private static final int[] PEN_STYLE_EDGE_TYPE = new int[] { - BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, - BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_UNIFORM, - BORDER_AND_EDGE_TYPE_UNIFORM - }; - private static final int[] PEN_STYLE_BACKGROUND = new int[] { - COLOR_SOLID_BLACK, COLOR_SOLID_BLACK, COLOR_SOLID_BLACK, COLOR_SOLID_BLACK, - COLOR_SOLID_BLACK, COLOR_TRANSPARENT, COLOR_TRANSPARENT}; + private static final int[] PEN_STYLE_FONT_STYLE = + new int[] { + PEN_FONT_STYLE_DEFAULT, + PEN_FONT_STYLE_MONOSPACED_WITH_SERIFS, + PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITH_SERIFS, + PEN_FONT_STYLE_MONOSPACED_WITHOUT_SERIFS, + PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITHOUT_SERIFS, + PEN_FONT_STYLE_MONOSPACED_WITHOUT_SERIFS, + PEN_FONT_STYLE_PROPORTIONALLY_SPACED_WITHOUT_SERIFS + }; + private static final int[] PEN_STYLE_EDGE_TYPE = + new int[] { + BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, + BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_NONE, BORDER_AND_EDGE_TYPE_UNIFORM, + BORDER_AND_EDGE_TYPE_UNIFORM + }; + private static final int[] PEN_STYLE_BACKGROUND = + new int[] { + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK, + COLOR_SOLID_BLACK, + COLOR_TRANSPARENT, + COLOR_TRANSPARENT + }; private final List rolledUpCaptions; private final SpannableStringBuilder captionStringBuilder; @@ -992,9 +1010,19 @@ public final class Cea708Decoder extends CeaDecoder { return visible; } - public void defineWindow(boolean visible, boolean rowLock, boolean columnLock, int priority, - boolean relativePositioning, int verticalAnchor, int horizontalAnchor, int rowCount, - int columnCount, int anchorId, int windowStyleId, int penStyleId) { + public void defineWindow( + boolean visible, + boolean rowLock, + boolean columnLock, + int priority, + boolean relativePositioning, + int verticalAnchor, + int horizontalAnchor, + int rowCount, + int columnCount, + int anchorId, + int windowStyleId, + int penStyleId) { this.defined = true; this.visible = visible; this.rowLock = rowLock; @@ -1022,8 +1050,11 @@ public final class Cea708Decoder extends CeaDecoder { // windowStyleId is 1-based. int windowStyleIdIndex = windowStyleId - 1; // Note that Border type and border color are the same for all window styles. - setWindowAttributes(WINDOW_STYLE_FILL[windowStyleIdIndex], COLOR_TRANSPARENT, - WINDOW_STYLE_WORD_WRAP[windowStyleIdIndex], BORDER_AND_EDGE_TYPE_NONE, + setWindowAttributes( + WINDOW_STYLE_FILL[windowStyleIdIndex], + COLOR_TRANSPARENT, + WINDOW_STYLE_WORD_WRAP[windowStyleIdIndex], + BORDER_AND_EDGE_TYPE_NONE, WINDOW_STYLE_PRINT_DIRECTION[windowStyleIdIndex], WINDOW_STYLE_SCROLL_DIRECTION[windowStyleIdIndex], WINDOW_STYLE_JUSTIFICATION[windowStyleIdIndex]); @@ -1035,34 +1066,53 @@ public final class Cea708Decoder extends CeaDecoder { int penStyleIdIndex = penStyleId - 1; // Note that pen size, offset, italics, underline, foreground color, and foreground // opacity are the same for all pen styles. - setPenAttributes(0, PEN_OFFSET_NORMAL, PEN_SIZE_STANDARD, false, false, - PEN_STYLE_EDGE_TYPE[penStyleIdIndex], PEN_STYLE_FONT_STYLE[penStyleIdIndex]); + setPenAttributes( + 0, + PEN_OFFSET_NORMAL, + PEN_SIZE_STANDARD, + false, + false, + PEN_STYLE_EDGE_TYPE[penStyleIdIndex], + PEN_STYLE_FONT_STYLE[penStyleIdIndex]); setPenColor(COLOR_SOLID_WHITE, PEN_STYLE_BACKGROUND[penStyleIdIndex], COLOR_SOLID_BLACK); } } - - public void setWindowAttributes(int fillColor, int borderColor, boolean wordWrapToggle, - int borderType, int printDirection, int scrollDirection, int justification) { + public void setWindowAttributes( + int fillColor, + int borderColor, + boolean wordWrapToggle, + int borderType, + int printDirection, + int scrollDirection, + int justification) { this.windowFillColor = fillColor; // TODO: Add support for border color and types. // TODO: Add support for word wrap. // TODO: Add support for other scroll directions. // TODO: Add support for other print directions. this.justification = justification; - } - public void setPenAttributes(int textTag, int offset, int penSize, boolean italicsToggle, - boolean underlineToggle, int edgeType, int fontStyle) { + public void setPenAttributes( + int textTag, + int offset, + int penSize, + boolean italicsToggle, + boolean underlineToggle, + int edgeType, + int fontStyle) { // TODO: Add support for text tags. // TODO: Add support for other offsets. // TODO: Add support for other pen sizes. if (italicsStartPosition != C.POSITION_UNSET) { if (!italicsToggle) { - captionStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, - captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + captionStringBuilder.setSpan( + new StyleSpan(Typeface.ITALIC), + italicsStartPosition, + captionStringBuilder.length(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); italicsStartPosition = C.POSITION_UNSET; } } else if (italicsToggle) { @@ -1071,8 +1121,11 @@ public final class Cea708Decoder extends CeaDecoder { if (underlineStartPosition != C.POSITION_UNSET) { if (!underlineToggle) { - captionStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, - captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + captionStringBuilder.setSpan( + new UnderlineSpan(), + underlineStartPosition, + captionStringBuilder.length(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); underlineStartPosition = C.POSITION_UNSET; } } else if (underlineToggle) { @@ -1086,8 +1139,10 @@ public final class Cea708Decoder extends CeaDecoder { public void setPenColor(int foregroundColor, int backgroundColor, int edgeColor) { if (foregroundColorStartPosition != C.POSITION_UNSET) { if (this.foregroundColor != foregroundColor) { - captionStringBuilder.setSpan(new ForegroundColorSpan(this.foregroundColor), - foregroundColorStartPosition, captionStringBuilder.length(), + captionStringBuilder.setSpan( + new ForegroundColorSpan(this.foregroundColor), + foregroundColorStartPosition, + captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } @@ -1098,8 +1153,10 @@ public final class Cea708Decoder extends CeaDecoder { if (backgroundColorStartPosition != C.POSITION_UNSET) { if (this.backgroundColor != backgroundColor) { - captionStringBuilder.setSpan(new BackgroundColorSpan(this.backgroundColor), - backgroundColorStartPosition, captionStringBuilder.length(), + captionStringBuilder.setSpan( + new BackgroundColorSpan(this.backgroundColor), + backgroundColorStartPosition, + captionStringBuilder.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } @@ -1165,23 +1222,35 @@ public final class Cea708Decoder extends CeaDecoder { if (length > 0) { if (italicsStartPosition != C.POSITION_UNSET) { - spannableStringBuilder.setSpan(new StyleSpan(Typeface.ITALIC), italicsStartPosition, - length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringBuilder.setSpan( + new StyleSpan(Typeface.ITALIC), + italicsStartPosition, + length, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (underlineStartPosition != C.POSITION_UNSET) { - spannableStringBuilder.setSpan(new UnderlineSpan(), underlineStartPosition, - length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringBuilder.setSpan( + new UnderlineSpan(), + underlineStartPosition, + length, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (foregroundColorStartPosition != C.POSITION_UNSET) { - spannableStringBuilder.setSpan(new ForegroundColorSpan(foregroundColor), - foregroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringBuilder.setSpan( + new ForegroundColorSpan(foregroundColor), + foregroundColorStartPosition, + length, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (backgroundColorStartPosition != C.POSITION_UNSET) { - spannableStringBuilder.setSpan(new BackgroundColorSpan(backgroundColor), - backgroundColorStartPosition, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + spannableStringBuilder.setSpan( + new BackgroundColorSpan(backgroundColor), + backgroundColorStartPosition, + length, + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } } @@ -1308,10 +1377,7 @@ public final class Cea708Decoder extends CeaDecoder { // TODO: Add support for the Alternative Minimum Color List or the full 64 RGB combinations. // Return values based on the Minimum Color List - return Color.argb(alpha, - (red > 1 ? 255 : 0), - (green > 1 ? 255 : 0), - (blue > 1 ? 255 : 0)); + return Color.argb(alpha, (red > 1 ? 255 : 0), (green > 1 ? 255 : 0), (blue > 1 ? 255 : 0)); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaDecoder.java index 81ef58a712..1bb940b1f7 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaDecoder.java @@ -28,9 +28,7 @@ import com.google.android.exoplayer2.util.Util; import java.util.ArrayDeque; import java.util.PriorityQueue; -/** - * Base class for subtitle parsers for CEA captions. - */ +/** Base class for subtitle parsers for CEA captions. */ /* package */ abstract class CeaDecoder implements SubtitleDecoder { private static final int NUM_INPUT_BUFFERS = 10; @@ -154,14 +152,10 @@ import java.util.PriorityQueue; // Do nothing. } - /** - * Returns whether there is data available to create a new {@link Subtitle}. - */ + /** Returns whether there is data available to create a new {@link Subtitle}. */ protected abstract boolean isNewSubtitleDataAvailable(); - /** - * Creates a {@link Subtitle} from the available data. - */ + /** Creates a {@link Subtitle} from the available data. */ protected abstract Subtitle createSubtitle(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaSubtitle.java index 738f251e27..bc02caf5c0 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/cea/CeaSubtitle.java @@ -22,16 +22,12 @@ import com.google.android.exoplayer2.util.Assertions; import java.util.Collections; import java.util.List; -/** - * A representation of a CEA subtitle. - */ +/** A representation of a CEA subtitle. */ /* package */ final class CeaSubtitle implements Subtitle { private final List cues; - /** - * @param cues The subtitle cues. - */ + /** @param cues The subtitle cues. */ public CeaSubtitle(List cues) { this.cues = cues; } @@ -56,5 +52,4 @@ import java.util.List; public List getCues(long timeUs) { return timeUs >= 0 ? cues : Collections.emptyList(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java index 22ce893fce..0e98a2e7eb 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbDecoder.java @@ -26,9 +26,9 @@ public final class DvbDecoder extends SimpleSubtitleDecoder { private final DvbParser parser; /** - * @param initializationData The initialization data for the decoder. The initialization data - * must consist of a single byte array containing 5 bytes: flag_pes_stripped (1), - * composition_page (2), ancillary_page (2). + * @param initializationData The initialization data for the decoder. The initialization data must + * consist of a single byte array containing 5 bytes: flag_pes_stripped (1), composition_page + * (2), ancillary_page (2). */ public DvbDecoder(List initializationData) { super("DvbDecoder"); @@ -45,5 +45,4 @@ public final class DvbDecoder extends SimpleSubtitleDecoder { } return new DvbSubtitle(parser.decode(data, length)); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java index 5cdbfdf72e..1d5ec8454c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbParser.java @@ -34,9 +34,7 @@ import java.util.Collections; import java.util.List; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -/** - * Parses {@link Cue}s from a DVB subtitle bitstream. - */ +/** Parses {@link Cue}s from a DVB subtitle bitstream. */ /* package */ final class DvbParser { private static final String TAG = "DvbParser"; @@ -72,15 +70,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; private static final int DATA_TYPE_END_LINE = 0xF0; // Clut mapping tables, as defined by ETSI EN 300 743 10.4, 10.5, 10.6 - private static final byte[] defaultMap2To4 = { - (byte) 0x00, (byte) 0x07, (byte) 0x08, (byte) 0x0F}; - private static final byte[] defaultMap2To8 = { - (byte) 0x00, (byte) 0x77, (byte) 0x88, (byte) 0xFF}; + private static final byte[] defaultMap2To4 = {(byte) 0x00, (byte) 0x07, (byte) 0x08, (byte) 0x0F}; + private static final byte[] defaultMap2To8 = {(byte) 0x00, (byte) 0x77, (byte) 0x88, (byte) 0xFF}; private static final byte[] defaultMap4To8 = { - (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, - (byte) 0x44, (byte) 0x55, (byte) 0x66, (byte) 0x77, - (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, - (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF}; + (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33, + (byte) 0x44, (byte) 0x55, (byte) 0x66, (byte) 0x77, + (byte) 0x88, (byte) 0x99, (byte) 0xAA, (byte) 0xBB, + (byte) 0xCC, (byte) 0xDD, (byte) 0xEE, (byte) 0xFF + }; private final Paint defaultPaint; private final Paint fillRegionPaint; @@ -108,14 +105,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; fillRegionPaint.setPathEffect(null); canvas = new Canvas(); defaultDisplayDefinition = new DisplayDefinition(719, 575, 0, 719, 0, 575); - defaultClutDefinition = new ClutDefinition(0, generateDefault2BitClutEntries(), - generateDefault4BitClutEntries(), generateDefault8BitClutEntries()); + defaultClutDefinition = + new ClutDefinition( + 0, + generateDefault2BitClutEntries(), + generateDefault4BitClutEntries(), + generateDefault8BitClutEntries()); subtitleService = new SubtitleService(subtitlePageId, ancillaryPageId); } - /** - * Resets the parser. - */ + /** Resets the parser. */ public void reset() { subtitleService.reset(); } @@ -141,12 +140,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } // Update the canvas bitmap if necessary. - DisplayDefinition displayDefinition = subtitleService.displayDefinition != null - ? subtitleService.displayDefinition : defaultDisplayDefinition; - if (bitmap == null || displayDefinition.width + 1 != bitmap.getWidth() + DisplayDefinition displayDefinition = + subtitleService.displayDefinition != null + ? subtitleService.displayDefinition + : defaultDisplayDefinition; + if (bitmap == null + || displayDefinition.width + 1 != bitmap.getWidth() || displayDefinition.height + 1 != bitmap.getHeight()) { - bitmap = Bitmap.createBitmap(displayDefinition.width + 1, displayDefinition.height + 1, - Bitmap.Config.ARGB_8888); + bitmap = + Bitmap.createBitmap( + displayDefinition.width + 1, displayDefinition.height + 1, Bitmap.Config.ARGB_8888); canvas.setBitmap(bitmap); } @@ -161,10 +164,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; RegionComposition regionComposition = subtitleService.regions.get(regionId); // Clip drawing to the current region and display definition window. - int baseHorizontalAddress = pageRegion.horizontalAddress - + displayDefinition.horizontalPositionMinimum; - int baseVerticalAddress = pageRegion.verticalAddress - + displayDefinition.verticalPositionMinimum; + int baseHorizontalAddress = + pageRegion.horizontalAddress + displayDefinition.horizontalPositionMinimum; + int baseVerticalAddress = + pageRegion.verticalAddress + displayDefinition.verticalPositionMinimum; int clipRight = min( baseHorizontalAddress + regionComposition.width, @@ -192,9 +195,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } if (objectData != null) { @Nullable Paint paint = objectData.nonModifyingColorFlag ? null : defaultPaint; - paintPixelDataSubBlocks(objectData, clutDefinition, regionComposition.depth, + paintPixelDataSubBlocks( + objectData, + clutDefinition, + regionComposition.depth, baseHorizontalAddress + regionObject.horizontalPosition, - baseVerticalAddress + regionObject.verticalPosition, paint, canvas); + baseVerticalAddress + regionObject.verticalPosition, + paint, + canvas); } } @@ -208,7 +216,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; color = clutDefinition.clutEntries2Bit[regionComposition.pixelCode2Bit]; } fillRegionPaint.setColor(color); - canvas.drawRect(baseHorizontalAddress, baseVerticalAddress, + canvas.drawRect( + baseHorizontalAddress, + baseVerticalAddress, baseHorizontalAddress + regionComposition.width, baseVerticalAddress + regionComposition.height, fillRegionPaint); @@ -244,8 +254,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** * Parses a subtitling segment, as defined by ETSI EN 300 743 7.2 - *

- * The {@link SubtitleService} is updated with the parsed segment data. + * + *

The {@link SubtitleService} is updated with the parsed segment data. */ private static void parseSubtitlingSegment(ParsableBitArray data, SubtitleService service) { int segmentType = data.readBits(8); @@ -321,9 +331,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; data.skipBytes(dataFieldLimit - data.getBytePosition()); } - /** - * Parses a display definition segment, as defined by ETSI EN 300 743 7.2.1. - */ + /** Parses a display definition segment, as defined by ETSI EN 300 743 7.2.1. */ private static DisplayDefinition parseDisplayDefinition(ParsableBitArray data) { data.skipBits(4); // dds_version_number (4). boolean displayWindowFlag = data.readBit(); @@ -347,13 +355,16 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; verticalPositionMaximum = height; } - return new DisplayDefinition(width, height, horizontalPositionMinimum, - horizontalPositionMaximum, verticalPositionMinimum, verticalPositionMaximum); + return new DisplayDefinition( + width, + height, + horizontalPositionMinimum, + horizontalPositionMaximum, + verticalPositionMinimum, + verticalPositionMaximum); } - /** - * Parses a page composition segment, as defined by ETSI EN 300 743 7.2.2. - */ + /** Parses a page composition segment, as defined by ETSI EN 300 743 7.2.2. */ private static PageComposition parsePageComposition(ParsableBitArray data, int length) { int timeoutSecs = data.readBits(8); int version = data.readBits(4); @@ -374,9 +385,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; return new PageComposition(timeoutSecs, version, state, regions); } - /** - * Parses a region composition segment, as defined by ETSI EN 300 743 7.2.3. - */ + /** Parses a region composition segment, as defined by ETSI EN 300 743 7.2.3. */ private static RegionComposition parseRegionComposition(ParsableBitArray data, int length) { int id = data.readBits(8); data.skipBits(4); // Skip region_version_number @@ -412,18 +421,32 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; remainingLength -= 2; } - regionObjects.put(objectId, new RegionObject(objectType, objectProvider, - objectHorizontalPosition, objectVerticalPosition, foregroundPixelCode, - backgroundPixelCode)); + regionObjects.put( + objectId, + new RegionObject( + objectType, + objectProvider, + objectHorizontalPosition, + objectVerticalPosition, + foregroundPixelCode, + backgroundPixelCode)); } - return new RegionComposition(id, fillFlag, width, height, levelOfCompatibility, depth, clutId, - pixelCode8Bit, pixelCode4Bit, pixelCode2Bit, regionObjects); + return new RegionComposition( + id, + fillFlag, + width, + height, + levelOfCompatibility, + depth, + clutId, + pixelCode8Bit, + pixelCode4Bit, + pixelCode2Bit, + regionObjects); } - /** - * Parses a CLUT definition segment, as defined by ETSI EN 300 743 7.2.4. - */ + /** Parses a CLUT definition segment, as defined by ETSI EN 300 743 7.2.4. */ private static ClutDefinition parseClutDefinition(ParsableBitArray data, int length) { int clutId = data.readBits(8); data.skipBits(8); // Skip clut_version_number (4), reserved (4) @@ -475,8 +498,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; int r = (int) (y + (1.40200 * (cr - 128))); int g = (int) (y - (0.34414 * (cb - 128)) - (0.71414 * (cr - 128))); int b = (int) (y + (1.77200 * (cb - 128))); - clutEntries[entryId] = getColor(a, Util.constrainValue(r, 0, 255), - Util.constrainValue(g, 0, 255), Util.constrainValue(b, 0, 255)); + clutEntries[entryId] = + getColor( + a, + Util.constrainValue(r, 0, 255), + Util.constrainValue(g, 0, 255), + Util.constrainValue(b, 0, 255)); } return new ClutDefinition(clutId, clutEntries2Bit, clutEntries4Bit, clutEntries8Bit); @@ -533,17 +560,19 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; entries[0] = 0x00000000; for (int i = 1; i < entries.length; i++) { if (i < 8) { - entries[i] = getColor( - 0xFF, - ((i & 0x01) != 0 ? 0xFF : 0x00), - ((i & 0x02) != 0 ? 0xFF : 0x00), - ((i & 0x04) != 0 ? 0xFF : 0x00)); + entries[i] = + getColor( + 0xFF, + ((i & 0x01) != 0 ? 0xFF : 0x00), + ((i & 0x02) != 0 ? 0xFF : 0x00), + ((i & 0x04) != 0 ? 0xFF : 0x00)); } else { - entries[i] = getColor( - 0xFF, - ((i & 0x01) != 0 ? 0x7F : 0x00), - ((i & 0x02) != 0 ? 0x7F : 0x00), - ((i & 0x04) != 0 ? 0x7F : 0x00)); + entries[i] = + getColor( + 0xFF, + ((i & 0x01) != 0 ? 0x7F : 0x00), + ((i & 0x02) != 0 ? 0x7F : 0x00), + ((i & 0x04) != 0 ? 0x7F : 0x00)); } } return entries; @@ -554,40 +583,45 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; entries[0] = 0x00000000; for (int i = 0; i < entries.length; i++) { if (i < 8) { - entries[i] = getColor( - 0x3F, - ((i & 0x01) != 0 ? 0xFF : 0x00), - ((i & 0x02) != 0 ? 0xFF : 0x00), - ((i & 0x04) != 0 ? 0xFF : 0x00)); + entries[i] = + getColor( + 0x3F, + ((i & 0x01) != 0 ? 0xFF : 0x00), + ((i & 0x02) != 0 ? 0xFF : 0x00), + ((i & 0x04) != 0 ? 0xFF : 0x00)); } else { switch (i & 0x88) { case 0x00: - entries[i] = getColor( - 0xFF, - (((i & 0x01) != 0 ? 0x55 : 0x00) + ((i & 0x10) != 0 ? 0xAA : 0x00)), - (((i & 0x02) != 0 ? 0x55 : 0x00) + ((i & 0x20) != 0 ? 0xAA : 0x00)), - (((i & 0x04) != 0 ? 0x55 : 0x00) + ((i & 0x40) != 0 ? 0xAA : 0x00))); + entries[i] = + getColor( + 0xFF, + (((i & 0x01) != 0 ? 0x55 : 0x00) + ((i & 0x10) != 0 ? 0xAA : 0x00)), + (((i & 0x02) != 0 ? 0x55 : 0x00) + ((i & 0x20) != 0 ? 0xAA : 0x00)), + (((i & 0x04) != 0 ? 0x55 : 0x00) + ((i & 0x40) != 0 ? 0xAA : 0x00))); break; case 0x08: - entries[i] = getColor( - 0x7F, - (((i & 0x01) != 0 ? 0x55 : 0x00) + ((i & 0x10) != 0 ? 0xAA : 0x00)), - (((i & 0x02) != 0 ? 0x55 : 0x00) + ((i & 0x20) != 0 ? 0xAA : 0x00)), - (((i & 0x04) != 0 ? 0x55 : 0x00) + ((i & 0x40) != 0 ? 0xAA : 0x00))); + entries[i] = + getColor( + 0x7F, + (((i & 0x01) != 0 ? 0x55 : 0x00) + ((i & 0x10) != 0 ? 0xAA : 0x00)), + (((i & 0x02) != 0 ? 0x55 : 0x00) + ((i & 0x20) != 0 ? 0xAA : 0x00)), + (((i & 0x04) != 0 ? 0x55 : 0x00) + ((i & 0x40) != 0 ? 0xAA : 0x00))); break; case 0x80: - entries[i] = getColor( - 0xFF, - (127 + ((i & 0x01) != 0 ? 0x2B : 0x00) + ((i & 0x10) != 0 ? 0x55 : 0x00)), - (127 + ((i & 0x02) != 0 ? 0x2B : 0x00) + ((i & 0x20) != 0 ? 0x55 : 0x00)), - (127 + ((i & 0x04) != 0 ? 0x2B : 0x00) + ((i & 0x40) != 0 ? 0x55 : 0x00))); + entries[i] = + getColor( + 0xFF, + (127 + ((i & 0x01) != 0 ? 0x2B : 0x00) + ((i & 0x10) != 0 ? 0x55 : 0x00)), + (127 + ((i & 0x02) != 0 ? 0x2B : 0x00) + ((i & 0x20) != 0 ? 0x55 : 0x00)), + (127 + ((i & 0x04) != 0 ? 0x2B : 0x00) + ((i & 0x40) != 0 ? 0x55 : 0x00))); break; case 0x88: - entries[i] = getColor( - 0xFF, - (((i & 0x01) != 0 ? 0x2B : 0x00) + ((i & 0x10) != 0 ? 0x55 : 0x00)), - (((i & 0x02) != 0 ? 0x2B : 0x00) + ((i & 0x20) != 0 ? 0x55 : 0x00)), - (((i & 0x04) != 0 ? 0x2B : 0x00) + ((i & 0x40) != 0 ? 0x55 : 0x00))); + entries[i] = + getColor( + 0xFF, + (((i & 0x01) != 0 ? 0x2B : 0x00) + ((i & 0x10) != 0 ? 0x55 : 0x00)), + (((i & 0x02) != 0 ? 0x2B : 0x00) + ((i & 0x20) != 0 ? 0x55 : 0x00)), + (((i & 0x04) != 0 ? 0x2B : 0x00) + ((i & 0x40) != 0 ? 0x55 : 0x00))); break; } } @@ -618,10 +652,22 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } else { clutEntries = clutDefinition.clutEntries2Bit; } - paintPixelDataSubBlock(objectData.topFieldData, clutEntries, regionDepth, horizontalAddress, - verticalAddress, paint, canvas); - paintPixelDataSubBlock(objectData.bottomFieldData, clutEntries, regionDepth, horizontalAddress, - verticalAddress + 1, paint, canvas); + paintPixelDataSubBlock( + objectData.topFieldData, + clutEntries, + regionDepth, + horizontalAddress, + verticalAddress, + paint, + canvas); + paintPixelDataSubBlock( + objectData.bottomFieldData, + clutEntries, + regionDepth, + horizontalAddress, + verticalAddress + 1, + paint, + canvas); } /** Draws a pixel data sub-block, as defined by ETSI EN 300 743 7.2.5.1, into a canvas. */ @@ -652,8 +698,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } else { clutMapTable2ToX = null; } - column = paint2BitPixelCodeString(data, clutEntries, clutMapTable2ToX, column, line, - paint, canvas); + column = + paint2BitPixelCodeString( + data, clutEntries, clutMapTable2ToX, column, line, paint, canvas); data.byteAlign(); break; case DATA_TYPE_4BP_CODE_STRING: @@ -663,8 +710,9 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } else { clutMapTable4ToX = null; } - column = paint4BitPixelCodeString(data, clutEntries, clutMapTable4ToX, column, line, - paint, canvas); + column = + paint4BitPixelCodeString( + data, clutEntries, clutMapTable4ToX, column, line, paint, canvas); data.byteAlign(); break; case DATA_TYPE_8BP_CODE_STRING: @@ -854,9 +902,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; // Private inner classes. - /** - * The subtitle service definition. - */ + /** The subtitle service definition. */ private static final class SubtitleService { public final int subtitlePageId; @@ -890,13 +936,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; displayDefinition = null; pageComposition = null; } - } /** * Contains the geometry and active area of the subtitle service. - *

- * See ETSI EN 300 743 7.2.1 + * + *

See ETSI EN 300 743 7.2.1 */ private static final class DisplayDefinition { @@ -908,8 +953,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final int verticalPositionMinimum; public final int verticalPositionMaximum; - public DisplayDefinition(int width, int height, int horizontalPositionMinimum, - int horizontalPositionMaximum, int verticalPositionMinimum, int verticalPositionMaximum) { + public DisplayDefinition( + int width, + int height, + int horizontalPositionMinimum, + int horizontalPositionMaximum, + int verticalPositionMinimum, + int verticalPositionMaximum) { this.width = width; this.height = height; this.horizontalPositionMinimum = horizontalPositionMinimum; @@ -917,13 +967,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; this.verticalPositionMinimum = verticalPositionMinimum; this.verticalPositionMaximum = verticalPositionMaximum; } - } /** - * The page is the definition and arrangement of regions in the screen. - *

- * See ETSI EN 300 743 7.2.2 + * The page is the definition and arrangement of regions in the screen. + * + *

See ETSI EN 300 743 7.2.2 */ private static final class PageComposition { @@ -932,20 +981,19 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final int state; public final SparseArray regions; - public PageComposition(int timeoutSecs, int version, int state, - SparseArray regions) { + public PageComposition( + int timeoutSecs, int version, int state, SparseArray regions) { this.timeOutSecs = timeoutSecs; this.version = version; this.state = state; this.regions = regions; } - } /** * A region within a {@link PageComposition}. - *

- * See ETSI EN 300 743 7.2.2 + * + *

See ETSI EN 300 743 7.2.2 */ private static final class PageRegion { @@ -956,13 +1004,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; this.horizontalAddress = horizontalAddress; this.verticalAddress = verticalAddress; } - } /** * An area of the page composed of a list of objects and a CLUT. - *

- * See ETSI EN 300 743 7.2.3 + * + *

See ETSI EN 300 743 7.2.3 */ private static final class RegionComposition { @@ -978,9 +1025,18 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final int pixelCode2Bit; public final SparseArray regionObjects; - public RegionComposition(int id, boolean fillFlag, int width, int height, - int levelOfCompatibility, int depth, int clutId, int pixelCode8Bit, int pixelCode4Bit, - int pixelCode2Bit, SparseArray regionObjects) { + public RegionComposition( + int id, + boolean fillFlag, + int width, + int height, + int levelOfCompatibility, + int depth, + int clutId, + int pixelCode8Bit, + int pixelCode4Bit, + int pixelCode2Bit, + SparseArray regionObjects) { this.id = id; this.fillFlag = fillFlag; this.width = width; @@ -1000,13 +1056,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; regionObjects.put(otherRegionObjects.keyAt(i), otherRegionObjects.valueAt(i)); } } - } /** * An object within a {@link RegionComposition}. - *

- * See ETSI EN 300 743 7.2.3 + * + *

See ETSI EN 300 743 7.2.3 */ private static final class RegionObject { @@ -1017,8 +1072,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final int foregroundPixelCode; // TODO: Use this or remove it. public final int backgroundPixelCode; // TODO: Use this or remove it. - public RegionObject(int type, int provider, int horizontalPosition, - int verticalPosition, int foregroundPixelCode, int backgroundPixelCode) { + public RegionObject( + int type, + int provider, + int horizontalPosition, + int verticalPosition, + int foregroundPixelCode, + int backgroundPixelCode) { this.type = type; this.provider = provider; this.horizontalPosition = horizontalPosition; @@ -1026,13 +1086,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; this.foregroundPixelCode = foregroundPixelCode; this.backgroundPixelCode = backgroundPixelCode; } - } /** * CLUT family definition containing the color tables for the three bit depths defined - *

- * See ETSI EN 300 743 7.2.4 + * + *

See ETSI EN 300 743 7.2.4 */ private static final class ClutDefinition { @@ -1041,20 +1100,19 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final int[] clutEntries4Bit; public final int[] clutEntries8Bit; - public ClutDefinition(int id, int[] clutEntries2Bit, int[] clutEntries4Bit, - int[] clutEntries8bit) { + public ClutDefinition( + int id, int[] clutEntries2Bit, int[] clutEntries4Bit, int[] clutEntries8bit) { this.id = id; this.clutEntries2Bit = clutEntries2Bit; this.clutEntries4Bit = clutEntries4Bit; this.clutEntries8Bit = clutEntries8bit; } - } /** * The textual or graphical representation of an object. - *

- * See ETSI EN 300 743 7.2.5 + * + *

See ETSI EN 300 743 7.2.5 */ private static final class ObjectData { @@ -1063,14 +1121,12 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public final byte[] topFieldData; public final byte[] bottomFieldData; - public ObjectData(int id, boolean nonModifyingColorFlag, byte[] topFieldData, - byte[] bottomFieldData) { + public ObjectData( + int id, boolean nonModifyingColorFlag, byte[] topFieldData, byte[] bottomFieldData) { this.id = id; this.nonModifyingColorFlag = nonModifyingColorFlag; this.topFieldData = topFieldData; this.bottomFieldData = bottomFieldData; } - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java index 75728359c7..de9cf45369 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/dvb/DvbSubtitle.java @@ -20,9 +20,7 @@ import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Subtitle; import java.util.List; -/** - * A representation of a DVB subtitle. - */ +/** A representation of a DVB subtitle. */ /* package */ final class DvbSubtitle implements Subtitle { private final List cues; @@ -50,5 +48,4 @@ import java.util.List; public List getCues(long timeUs) { return cues; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java index 4093f7974d..79da60c34e 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java @@ -23,9 +23,7 @@ import com.google.android.exoplayer2.util.Util; import java.util.Collections; import java.util.List; -/** - * A representation of an SSA/ASS subtitle. - */ +/** A representation of an SSA/ASS subtitle. */ /* package */ final class SsaSubtitle implements Subtitle { private final List> cues; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java index 01ed1711a9..631a638408 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java @@ -23,9 +23,7 @@ import com.google.android.exoplayer2.util.Util; import java.util.Collections; import java.util.List; -/** - * A representation of a SubRip subtitle. - */ +/** A representation of a SubRip subtitle. */ /* package */ final class SubripSubtitle implements Subtitle { private final Cue[] cues; @@ -68,5 +66,4 @@ import java.util.List; return Collections.singletonList(cues[index]); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java index 1d84b7a6b3..6a57e14970 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlDecoder.java @@ -80,8 +80,9 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { private static final String ATTR_IMAGE = "backgroundImage"; private static final Pattern CLOCK_TIME = - Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])" - + "(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$"); + Pattern.compile( + "^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])" + + "(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$"); private static final Pattern OFFSET_TIME = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$"); private static final Pattern FONT_SIZE = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$"); @@ -526,12 +527,10 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { } break; case TtmlNode.ATTR_TTS_FONT_WEIGHT: - style = createIfNull(style).setBold( - TtmlNode.BOLD.equalsIgnoreCase(attributeValue)); + style = createIfNull(style).setBold(TtmlNode.BOLD.equalsIgnoreCase(attributeValue)); break; case TtmlNode.ATTR_TTS_FONT_STYLE: - style = createIfNull(style).setItalic( - TtmlNode.ITALIC.equalsIgnoreCase(attributeValue)); + style = createIfNull(style).setItalic(TtmlNode.ITALIC.equalsIgnoreCase(attributeValue)); break; case TtmlNode.ATTR_TTS_TEXT_ALIGN: style = createIfNull(style).setTextAlign(parseAlignment(attributeValue)); @@ -729,19 +728,21 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { || tag.equals(TtmlNode.TAG_INFORMATION); } - private static void parseFontSize(String expression, TtmlStyle out) throws - SubtitleDecoderException { + private static void parseFontSize(String expression, TtmlStyle out) + throws SubtitleDecoderException { String[] expressions = Util.split(expression, "\\s+"); Matcher matcher; if (expressions.length == 1) { matcher = FONT_SIZE.matcher(expression); - } else if (expressions.length == 2){ + } else if (expressions.length == 2) { matcher = FONT_SIZE.matcher(expressions[1]); - Log.w(TAG, "Multiple values in fontSize attribute. Picking the second value for vertical font" - + " size and ignoring the first."); + Log.w( + TAG, + "Multiple values in fontSize attribute. Picking the second value for vertical font" + + " size and ignoring the first."); } else { - throw new SubtitleDecoderException("Invalid number of entries for fontSize: " - + expressions.length + "."); + throw new SubtitleDecoderException( + "Invalid number of entries for fontSize: " + expressions.length + "."); } if (matcher.matches()) { @@ -814,13 +815,15 @@ public final class TtmlDecoder extends SimpleSubtitleDecoder { @Nullable String fraction = matcher.group(4); durationSeconds += (fraction != null) ? Double.parseDouble(fraction) : 0; @Nullable String frames = matcher.group(5); - durationSeconds += (frames != null) - ? Long.parseLong(frames) / frameAndTickRate.effectiveFrameRate : 0; + durationSeconds += + (frames != null) ? Long.parseLong(frames) / frameAndTickRate.effectiveFrameRate : 0; @Nullable String subframes = matcher.group(6); - durationSeconds += (subframes != null) - ? ((double) Long.parseLong(subframes)) / frameAndTickRate.subFrameRate - / frameAndTickRate.effectiveFrameRate - : 0; + durationSeconds += + (subframes != null) + ? ((double) Long.parseLong(subframes)) + / frameAndTickRate.subFrameRate + / frameAndTickRate.effectiveFrameRate + : 0; return (long) (durationSeconds * C.MICROS_PER_SECOND); } matcher = OFFSET_TIME.matcher(time); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java index 7e39d1e9f8..0677ef1e27 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlNode.java @@ -32,9 +32,7 @@ import java.util.TreeMap; import java.util.TreeSet; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -/** - * A package internal representation of TTML node. - */ +/** A package internal representation of TTML node. */ /* package */ final class TtmlNode { public static final String TAG_TT = "tt"; @@ -342,8 +340,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; boolean isPNode = TAG_P.equals(tag); for (int i = 0; i < getChildCount(); i++) { - getChild(i).traverseForText(timeUs, descendsPNode || isPNode, resolvedRegionId, - regionOutputs); + getChild(i) + .traverseForText(timeUs, descendsPNode || isPNode, resolvedRegionId, regionOutputs); } if (isPNode) { TtmlRenderUtil.endParagraph(getRegionOutputText(resolvedRegionId, regionOutputs)); @@ -473,5 +471,4 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; builder.delete(builder.length() - 1, builder.length()); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRegion.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRegion.java index 36c862568f..593bfd7761 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRegion.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRegion.java @@ -17,9 +17,7 @@ package com.google.android.exoplayer2.text.ttml; import com.google.android.exoplayer2.text.Cue; -/** - * Represents a TTML Region. - */ +/** Represents a TTML Region. */ /* package */ final class TtmlRegion { public final String id; @@ -69,5 +67,4 @@ import com.google.android.exoplayer2.text.Cue; this.textSize = textSize; this.verticalType = verticalType; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java index e578a04072..b7f4b0f5b1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtil.java @@ -41,9 +41,7 @@ import java.util.ArrayDeque; import java.util.Deque; import java.util.Map; -/** - * Package internal utility class to render styled TtmlNodes. - */ +/** Package internal utility class to render styled TtmlNodes. */ /* package */ final class TtmlRenderUtil { private static final String TAG = "TtmlRenderUtil"; @@ -92,8 +90,8 @@ import java.util.Map; @Cue.VerticalType int verticalType) { if (style.getStyle() != TtmlStyle.UNSPECIFIED) { - builder.setSpan(new StyleSpan(style.getStyle()), start, end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + builder.setSpan( + new StyleSpan(style.getStyle()), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } if (style.isLinethrough()) { builder.setSpan(new StrikethroughSpan(), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -313,5 +311,4 @@ import java.util.Map; } private TtmlRenderUtil() {} - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlStyle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlStyle.java index d1c7291652..82ce86df2a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlStyle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlStyle.java @@ -24,9 +24,7 @@ import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; -/** - * Style object of a TtmlNode - */ +/** Style object of a TtmlNode */ /* package */ final class TtmlStyle { public static final int UNSPECIFIED = -1; @@ -109,12 +107,12 @@ import java.lang.annotation.RetentionPolicy; * @return {@link #UNSPECIFIED}, {@link #STYLE_NORMAL}, {@link #STYLE_BOLD}, {@link #STYLE_BOLD} * or {@link #STYLE_BOLD_ITALIC}. */ - @StyleFlags public int getStyle() { + @StyleFlags + public int getStyle() { if (bold == UNSPECIFIED && italic == UNSPECIFIED) { return UNSPECIFIED; } - return (bold == ON ? STYLE_BOLD : STYLE_NORMAL) - | (italic == ON ? STYLE_ITALIC : STYLE_NORMAL); + return (bold == ON ? STYLE_BOLD : STYLE_NORMAL) | (italic == ON ? STYLE_ITALIC : STYLE_NORMAL); } public boolean isLinethrough() { @@ -352,7 +350,8 @@ import java.lang.annotation.RetentionPolicy; return this; } - @FontSizeUnit public int getFontSizeUnit() { + @FontSizeUnit + public int getFontSizeUnit() { return fontSizeUnit; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java index 6a52338a94..68c11a9a25 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/ttml/TtmlSubtitle.java @@ -24,9 +24,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -/** - * A representation of a TTML subtitle. - */ +/** A representation of a TTML subtitle. */ /* package */ final class TtmlSubtitle implements Subtitle { private final TtmlNode root; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java index ea08c375ef..4b8f539f42 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java @@ -92,19 +92,20 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder { && (initializationData.get(0).length == 48 || initializationData.get(0).length == 53)) { byte[] initializationBytes = initializationData.get(0); defaultFontFace = initializationBytes[24]; - defaultColorRgba = ((initializationBytes[26] & 0xFF) << 24) - | ((initializationBytes[27] & 0xFF) << 16) - | ((initializationBytes[28] & 0xFF) << 8) - | (initializationBytes[29] & 0xFF); + defaultColorRgba = + ((initializationBytes[26] & 0xFF) << 24) + | ((initializationBytes[27] & 0xFF) << 16) + | ((initializationBytes[28] & 0xFF) << 8) + | (initializationBytes[29] & 0xFF); String fontFamily = Util.fromUtf8Bytes(initializationBytes, 43, initializationBytes.length - 43); defaultFontFamily = TX3G_SERIF.equals(fontFamily) ? C.SERIF_NAME : C.SANS_SERIF_NAME; - //font size (initializationBytes[25]) is 5% of video height + // font size (initializationBytes[25]) is 5% of video height calculatedVideoTrackHeight = 20 * initializationBytes[25]; customVerticalPlacement = (initializationBytes[0] & 0x20) != 0; if (customVerticalPlacement) { - int requestedVerticalPlacement = ((initializationBytes[10] & 0xFF) << 8) - | (initializationBytes[11] & 0xFF); + int requestedVerticalPlacement = + ((initializationBytes[10] & 0xFF) << 8) | (initializationBytes[11] & 0xFF); defaultVerticalPlacement = Util.constrainValue( (float) requestedVerticalPlacement / calculatedVideoTrackHeight, 0.0f, 0.95f); @@ -131,10 +132,9 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder { } // Attach default styles. SpannableStringBuilder cueText = new SpannableStringBuilder(cueTextString); - attachFontFace(cueText, defaultFontFace, DEFAULT_FONT_FACE, 0, cueText.length(), - SPAN_PRIORITY_LOW); - attachColor(cueText, defaultColorRgba, DEFAULT_COLOR, 0, cueText.length(), - SPAN_PRIORITY_LOW); + attachFontFace( + cueText, defaultFontFace, DEFAULT_FONT_FACE, 0, cueText.length(), SPAN_PRIORITY_LOW); + attachColor(cueText, defaultColorRgba, DEFAULT_COLOR, 0, cueText.length(), SPAN_PRIORITY_LOW); attachFontFamily(cueText, defaultFontFamily, 0, cueText.length()); float verticalPlacement = defaultVerticalPlacement; // Find and attach additional styles. @@ -180,8 +180,8 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder { return parsableByteArray.readString(textLength, Charsets.UTF_8); } - private void applyStyleRecord(ParsableByteArray parsableByteArray, - SpannableStringBuilder cueText) throws SubtitleDecoderException { + private void applyStyleRecord(ParsableByteArray parsableByteArray, SpannableStringBuilder cueText) + throws SubtitleDecoderException { assertTrue(parsableByteArray.bytesLeft() >= SIZE_STYLE_RECORD); int start = parsableByteArray.readUnsignedShort(); int end = parsableByteArray.readUnsignedShort(); @@ -203,8 +203,13 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder { attachColor(cueText, colorRgba, defaultColorRgba, start, end, SPAN_PRIORITY_HIGH); } - private static void attachFontFace(SpannableStringBuilder cueText, int fontFace, - int defaultFontFace, int start, int end, int spanPriority) { + private static void attachFontFace( + SpannableStringBuilder cueText, + int fontFace, + int defaultFontFace, + int start, + int end, + int spanPriority) { if (fontFace != defaultFontFace) { final int flags = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority; boolean isBold = (fontFace & FONT_FACE_BOLD) != 0; @@ -228,11 +233,19 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder { } } - private static void attachColor(SpannableStringBuilder cueText, int colorRgba, - int defaultColorRgba, int start, int end, int spanPriority) { + private static void attachColor( + SpannableStringBuilder cueText, + int colorRgba, + int defaultColorRgba, + int start, + int end, + int spanPriority) { if (colorRgba != defaultColorRgba) { int colorArgb = ((colorRgba & 0xFF) << 24) | (colorRgba >>> 8); - cueText.setSpan(new ForegroundColorSpan(colorArgb), start, end, + cueText.setSpan( + new ForegroundColorSpan(colorArgb), + start, + end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE | spanPriority); } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gSubtitle.java index adb1190ce4..100e080056 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gSubtitle.java @@ -22,9 +22,7 @@ import com.google.android.exoplayer2.util.Assertions; import java.util.Collections; import java.util.List; -/** - * A representation of a tx3g subtitle. - */ +/** A representation of a tx3g subtitle. */ /* package */ final class Tx3gSubtitle implements Subtitle { public static final Tx3gSubtitle EMPTY = new Tx3gSubtitle(); @@ -59,5 +57,4 @@ import java.util.List; public List getCues(long timeUs) { return timeUs >= 0 ? cues : Collections.emptyList(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/CssParser.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/CssParser.java index 0bd1312942..7302324b48 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/CssParser.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/CssParser.java @@ -146,9 +146,7 @@ import java.util.regex.Pattern; return target; } - /** - * Reads the contents of ::cue() and returns it as a string. - */ + /** Reads the contents of ::cue() and returns it as a string. */ private static String readCueTarget(ParsableByteArray input) { int position = input.getPosition(); int limit = input.limit(); @@ -161,8 +159,8 @@ import java.util.regex.Pattern; // --offset to return ')' to the input. } - private static void parseStyleDeclaration(ParsableByteArray input, WebvttCssStyle style, - StringBuilder stringBuilder) { + private static void parseStyleDeclaration( + ParsableByteArray input, WebvttCssStyle style, StringBuilder stringBuilder) { skipWhitespaceAndComments(input); String property = parseIdentifier(input, stringBuilder); if ("".equals(property)) { @@ -243,7 +241,7 @@ import java.util.regex.Pattern; } private static boolean maybeSkipWhitespace(ParsableByteArray input) { - switch(peekCharAtPosition(input, input.getPosition())) { + switch (peekCharAtPosition(input, input.getPosition())) { case '\t': case '\r': case '\n': @@ -319,10 +317,15 @@ import java.util.regex.Pattern; int position = input.getPosition(); int limit = input.limit(); boolean identifierEndFound = false; - while (position < limit && !identifierEndFound) { + while (position < limit && !identifierEndFound) { char c = (char) input.getData()[position]; - if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || c == '#' - || c == '-' || c == '.' || c == '_') { + if ((c >= 'A' && c <= 'Z') + || (c >= 'a' && c <= 'z') + || (c >= '0' && c <= '9') + || c == '#' + || c == '-' + || c == '.' + || c == '_') { position++; stringBuilder.append(c); } else { @@ -362,5 +365,4 @@ import java.util.regex.Pattern; style.setTargetClasses(Util.nullSafeArrayCopyOfRange(classDivision, 1, classDivision.length)); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttSubtitle.java index c87c88133c..00c8ecdc48 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttSubtitle.java @@ -22,9 +22,7 @@ import com.google.android.exoplayer2.util.Assertions; import java.util.Collections; import java.util.List; -/** - * Representation of a Webvtt subtitle embedded in a MP4 container file. - */ +/** Representation of a Webvtt subtitle embedded in a MP4 container file. */ /* package */ final class Mp4WebvttSubtitle implements Subtitle { private final List cues; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java index b8f9e9b343..9296197e51 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCssStyle.java @@ -116,7 +116,7 @@ public final class WebvttCssStyle { } public void setTargetId(String targetId) { - this.targetId = targetId; + this.targetId = targetId; } public void setTargetTagName(String targetTag) { @@ -151,7 +151,9 @@ public final class WebvttCssStyle { */ public int getSpecificityScore( @Nullable String id, @Nullable String tag, Set classes, @Nullable String voice) { - if (targetId.isEmpty() && targetTag.isEmpty() && targetClasses.isEmpty() + if (targetId.isEmpty() + && targetTag.isEmpty() + && targetClasses.isEmpty() && targetVoice.isEmpty()) { // The selector is universal. It matches with the minimum score if and only if the given // element is a whole cue. @@ -175,12 +177,12 @@ public final class WebvttCssStyle { * @return {@link #UNSPECIFIED}, {@link #STYLE_NORMAL}, {@link #STYLE_BOLD}, {@link #STYLE_BOLD} * or {@link #STYLE_BOLD_ITALIC}. */ - @StyleFlags public int getStyle() { + @StyleFlags + public int getStyle() { if (bold == UNSPECIFIED && italic == UNSPECIFIED) { return UNSPECIFIED; } - return (bold == ON ? STYLE_BOLD : STYLE_NORMAL) - | (italic == ON ? STYLE_ITALIC : STYLE_NORMAL); + return (bold == ON ? STYLE_BOLD : STYLE_NORMAL) | (italic == ON ? STYLE_ITALIC : STYLE_NORMAL); } public boolean isLinethrough() { @@ -200,6 +202,7 @@ public final class WebvttCssStyle { this.underline = underline ? ON : OFF; return this; } + public WebvttCssStyle setBold(boolean bold) { this.bold = bold ? ON : OFF; return this; @@ -264,7 +267,8 @@ public final class WebvttCssStyle { return this; } - @FontSizeUnit public int getFontSizeUnit() { + @FontSizeUnit + public int getFontSizeUnit() { return fontSizeUnit; } @@ -298,5 +302,4 @@ public final class WebvttCssStyle { } return target.equals(actual) ? currentScore + score : -1; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java index a040a3acf3..63cfc8b8dd 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParser.java @@ -111,8 +111,8 @@ public final class WebvttCueParser { */ private static final int TEXT_ALIGNMENT_RIGHT = 5; - public static final Pattern CUE_HEADER_PATTERN = Pattern - .compile("^(\\S+)\\s+-->\\s+(\\S+)(.*)?$"); + public static final Pattern CUE_HEADER_PATTERN = + Pattern.compile("^(\\S+)\\s+-->\\s+(\\S+)(.*)?$"); private static final Pattern CUE_SETTING_PATTERN = Pattern.compile("(\\S+?):(\\S+)"); private static final char CHAR_LESS_THAN = '<'; @@ -257,8 +257,8 @@ public final class WebvttCueParser { boolean isClosingTag = markup.charAt(ltPos + 1) == CHAR_SLASH; pos = findEndOfTag(markup, ltPos + 1); boolean isVoidTag = markup.charAt(pos - 2) == CHAR_SLASH; - String fullTagExpression = markup.substring(ltPos + (isClosingTag ? 2 : 1), - isVoidTag ? pos - 2 : pos - 1); + String fullTagExpression = + markup.substring(ltPos + (isClosingTag ? 2 : 1), isVoidTag ? pos - 2 : pos - 1); if (fullTagExpression.trim().isEmpty()) { continue; } @@ -535,14 +535,12 @@ public final class WebvttCueParser { int start = startTag.position; int end = text.length(); - switch(startTag.name) { + switch (startTag.name) { case TAG_BOLD: - text.setSpan(new StyleSpan(STYLE_BOLD), start, end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + text.setSpan(new StyleSpan(STYLE_BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case TAG_ITALIC: - text.setSpan(new StyleSpan(STYLE_ITALIC), start, end, - Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + text.setSpan(new StyleSpan(STYLE_ITALIC), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); break; case TAG_RUBY: applyRubySpans(text, cueId, startTag, nestedElements, styles); @@ -658,8 +656,8 @@ public final class WebvttCueParser { } } - private static void applyStyleToText(SpannableStringBuilder spannedText, WebvttCssStyle style, - int start, int end) { + private static void applyStyleToText( + SpannableStringBuilder spannedText, WebvttCssStyle style, int start, int end) { if (style == null) { return; } @@ -924,7 +922,6 @@ public final class WebvttCueParser { public int compareTo(StyleMatch another) { return Integer.compare(this.score, another.score); } - } private static final class StartTag { @@ -968,7 +965,6 @@ public final class WebvttCueParser { /* voice= */ "", /* classes= */ Collections.emptySet()); } - } /** Information about a complete element (i.e. start tag and end position). */ diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoder.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoder.java index 383c90af36..c7d0e24429 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoder.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttDecoder.java @@ -117,5 +117,4 @@ public final class WebvttDecoder extends SimpleSubtitleDecoder { private static void skipComment(ParsableByteArray parsableWebvttData) { while (!TextUtils.isEmpty(parsableWebvttData.readLine())) {} } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttParserUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttParserUtil.java index 07b1fb7f9c..02d2d3bcac 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttParserUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttParserUtil.java @@ -113,5 +113,4 @@ public final class WebvttParserUtil { } return null; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitle.java b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitle.java index 4a8f5a5471..301f4ea19a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitle.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/text/webvtt/WebvttSubtitle.java @@ -25,9 +25,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -/** - * A representation of a WebVTT subtitle. - */ +/** A representation of a WebVTT subtitle. */ /* package */ final class WebvttSubtitle implements Subtitle { private final List cueInfos; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java index 6dc3b2f636..95df027ac2 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelection.java @@ -421,8 +421,10 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { Util.getPlayoutDurationForMediaDuration(mediaDurationBeforeThisChunkUs, playbackSpeed); if (playoutDurationBeforeThisChunkUs >= minDurationToRetainAfterDiscardUs && format.bitrate < idealFormat.bitrate - && format.height != Format.NO_VALUE && format.height < 720 - && format.width != Format.NO_VALUE && format.width < 1280 + && format.height != Format.NO_VALUE + && format.height < 720 + && format.width != Format.NO_VALUE + && format.width < 1280 && format.height < idealFormat.height) { return i; } @@ -493,8 +495,9 @@ public class AdaptiveTrackSelection extends BaseTrackSelection { } private long minDurationForQualityIncreaseUs(long availableDurationUs) { - boolean isAvailableDurationTooShort = availableDurationUs != C.TIME_UNSET - && availableDurationUs <= minDurationForQualityIncreaseUs; + boolean isAvailableDurationTooShort = + availableDurationUs != C.TIME_UNSET + && availableDurationUs <= minDurationForQualityIncreaseUs; return isAvailableDurationTooShort ? (long) (availableDurationUs * bufferedFractionToLiveEdgeForQualityIncrease) : minDurationForQualityIncreaseUs; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/FixedTrackSelection.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/FixedTrackSelection.java index b630c127ac..7995526408 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/FixedTrackSelection.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/FixedTrackSelection.java @@ -89,5 +89,4 @@ public final class FixedTrackSelection extends BaseTrackSelection { public Object getSelectionData() { return data; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java index 59c5d5447b..c1dee080df 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java @@ -85,9 +85,7 @@ import com.google.android.exoplayer2.util.Assertions; */ public abstract class TrackSelector { - /** - * Notified when selections previously made by a {@link TrackSelector} are no longer valid. - */ + /** Notified when selections previously made by a {@link TrackSelector} are no longer valid. */ public interface InvalidationListener { /** @@ -95,7 +93,6 @@ public abstract class TrackSelector { * longer valid. May be called from any thread. */ void onTrackSelectionsInvalidated(); - } @Nullable private InvalidationListener listener; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocation.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocation.java index 4121a40875..7e815d259f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocation.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocation.java @@ -29,9 +29,7 @@ public final class Allocation { */ public final byte[] data; - /** - * The offset of the allocated space in {@link #data}. - */ + /** The offset of the allocated space in {@link #data}. */ public final int offset; /** @@ -42,5 +40,4 @@ public final class Allocation { this.data = data; this.offset = offset; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java index d508d375c3..6b9ddcc1da 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Allocator.java @@ -20,8 +20,8 @@ public interface Allocator { /** * Obtain an {@link Allocation}. - *

- * When the caller has finished with the {@link Allocation}, it should be returned by calling + * + *

When the caller has finished with the {@link Allocation}, it should be returned by calling * {@link #release(Allocation)}. * * @return The {@link Allocation}. @@ -43,19 +43,14 @@ public interface Allocator { void release(Allocation[] allocations); /** - * Hints to the allocator that it should make a best effort to release any excess - * {@link Allocation}s. + * Hints to the allocator that it should make a best effort to release any excess {@link + * Allocation}s. */ void trim(); - /** - * Returns the total number of bytes currently allocated. - */ + /** Returns the total number of bytes currently allocated. */ int getTotalBytesAllocated(); - /** - * Returns the length of each individual {@link Allocation}. - */ + /** Returns the length of each individual {@link Allocation}. */ int getIndividualAllocationLength(); - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/AssetDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/AssetDataSource.java index 05838c8a2d..8651f85ed7 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/AssetDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/AssetDataSource.java @@ -30,15 +30,12 @@ import java.io.InputStream; /** A {@link DataSource} for reading from a local asset. */ public final class AssetDataSource extends BaseDataSource { - /** - * Thrown when an {@link IOException} is encountered reading a local asset. - */ + /** Thrown when an {@link IOException} is encountered reading a local asset. */ public static final class AssetDataSourceException extends IOException { public AssetDataSourceException(IOException cause) { super(cause); } - } private final AssetManager assetManager; @@ -142,5 +139,4 @@ public final class AssetDataSource extends BaseDataSource { } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/BandwidthMeter.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/BandwidthMeter.java index c5b2893398..44e0bb4d4b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/BandwidthMeter.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/BandwidthMeter.java @@ -24,9 +24,7 @@ import java.util.concurrent.CopyOnWriteArrayList; /** Provides estimates of the currently available bandwidth. */ public interface BandwidthMeter { - /** - * A listener of {@link BandwidthMeter} events. - */ + /** A listener of {@link BandwidthMeter} events. */ interface EventListener { /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSink.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSink.java index 63b8fd6e19..9471483419 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSink.java @@ -57,5 +57,4 @@ public final class ByteArrayDataSink implements DataSink { public byte[] getData() { return stream == null ? null : stream.toByteArray(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSource.java index 24d2c728a1..331c3affb5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ByteArrayDataSource.java @@ -33,9 +33,7 @@ public final class ByteArrayDataSource extends BaseDataSource { private int bytesRemaining; private boolean opened; - /** - * @param data The data to be read. - */ + /** @param data The data to be read. */ public ByteArrayDataSource(byte[] data) { super(/* isNetwork= */ false); Assertions.checkNotNull(data); @@ -90,5 +88,4 @@ public final class ByteArrayDataSource extends BaseDataSource { } uri = null; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java index be93f883fe..21fa3a8031 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ContentDataSource.java @@ -32,15 +32,12 @@ import java.nio.channels.FileChannel; /** A {@link DataSource} for reading from a content URI. */ public final class ContentDataSource extends BaseDataSource { - /** - * Thrown when an {@link IOException} is encountered reading from a content URI. - */ + /** Thrown when an {@link IOException} is encountered reading from a content URI. */ public static class ContentDataSourceException extends IOException { public ContentDataSourceException(IOException cause) { super(cause); } - } private final ContentResolver resolver; @@ -51,9 +48,7 @@ public final class ContentDataSource extends BaseDataSource { private long bytesRemaining; private boolean opened; - /** - * @param context A context. - */ + /** @param context A context. */ public ContentDataSource(Context context) { super(/* isNetwork= */ false); this.resolver = context.getContentResolver(); @@ -188,5 +183,4 @@ public final class ContentDataSource extends BaseDataSource { } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSink.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSink.java index 594403c33d..af644a8c48 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSink.java @@ -20,16 +20,11 @@ import java.io.IOException; /** A component to which streams of data can be written. */ public interface DataSink { - /** - * A factory for {@link DataSink} instances. - */ + /** A factory for {@link DataSink} instances. */ interface Factory { - /** - * Creates a {@link DataSink} instance. - */ + /** Creates a {@link DataSink} instance. */ DataSink createDataSink(); - } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSourceInputStream.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSourceInputStream.java index c4296bd6f6..ddc68d137a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSourceInputStream.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DataSourceInputStream.java @@ -44,17 +44,15 @@ public final class DataSourceInputStream extends InputStream { singleByteArray = new byte[1]; } - /** - * Returns the total number of bytes that have been read or skipped. - */ + /** Returns the total number of bytes that have been read or skipped. */ public long bytesRead() { return totalBytesRead; } /** * Optional call to open the underlying {@link DataSource}. - *

- * Calling this method does nothing if the {@link DataSource} is already open. Calling this + * + *

Calling this method does nothing if the {@link DataSource} is already open. Calling this * method is optional, since the read and skip methods will automatically open the underlying * {@link DataSource} if it's not open already. * @@ -102,5 +100,4 @@ public final class DataSourceInputStream extends InputStream { opened = true; } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java index f354dc58ef..b79b66c930 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultAllocator.java @@ -51,16 +51,16 @@ public final class DefaultAllocator implements Allocator { /** * Constructs an instance with some {@link Allocation}s created up front. - *

- * Note: {@link Allocation}s created up front will never be discarded by {@link #trim()}. + * + *

Note: {@link Allocation}s created up front will never be discarded by {@link #trim()}. * * @param trimOnReset Whether memory is freed when the allocator is reset. Should be true unless * the allocator will be re-used by multiple player instances. * @param individualAllocationSize The length of each individual {@link Allocation}. * @param initialAllocationCount The number of allocations to create up front. */ - public DefaultAllocator(boolean trimOnReset, int individualAllocationSize, - int initialAllocationCount) { + public DefaultAllocator( + boolean trimOnReset, int individualAllocationSize, int initialAllocationCount) { Assertions.checkArgument(individualAllocationSize > 0); Assertions.checkArgument(initialAllocationCount >= 0); this.trimOnReset = trimOnReset; @@ -179,5 +179,4 @@ public final class DefaultAllocator implements Allocator { public int getIndividualAllocationLength() { return individualAllocationSize; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSourceFactory.java index 88b9112af8..ca309ad592 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/DefaultHttpDataSourceFactory.java @@ -61,8 +61,12 @@ public final class DefaultHttpDataSourceFactory extends BaseFactory { */ public DefaultHttpDataSourceFactory( @Nullable String userAgent, @Nullable TransferListener listener) { - this(userAgent, listener, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, - DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, false); + this( + userAgent, + listener, + DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS, + DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, + false); } /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/FileDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/FileDataSource.java index 7fba170f36..0428c0a66f 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/FileDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/FileDataSource.java @@ -87,8 +87,8 @@ public final class FileDataSource extends BaseDataSource { this.file = openLocalFile(uri); file.seek(dataSpec.position); - bytesRemaining = dataSpec.length == C.LENGTH_UNSET ? file.length() - dataSpec.position - : dataSpec.length; + bytesRemaining = + dataSpec.length == C.LENGTH_UNSET ? file.length() - dataSpec.position : dataSpec.length; if (bytesRemaining < 0) { throw new DataSourceException(DataSourceException.POSITION_OUT_OF_RANGE); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java index d731455e51..8c9d9caff1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/Loader.java @@ -39,20 +39,15 @@ import java.util.concurrent.atomic.AtomicBoolean; /** Manages the background loading of {@link Loadable}s. */ public final class Loader implements LoaderErrorThrower { - /** - * Thrown when an unexpected exception or error is encountered during loading. - */ + /** Thrown when an unexpected exception or error is encountered during loading. */ public static final class UnexpectedLoaderException extends IOException { public UnexpectedLoaderException(Throwable cause) { super("Unexpected " + cause.getClass().getSimpleName() + ": " + cause.getMessage(), cause); } - } - /** - * An object that can be loaded using a {@link Loader}. - */ + /** An object that can be loaded using a {@link Loader}. */ public interface Loadable { /** @@ -83,9 +78,7 @@ public final class Loader implements LoaderErrorThrower { void load() throws IOException; } - /** - * A callback to be notified of {@link Loader} events. - */ + /** A callback to be notified of {@link Loader} events. */ public interface Callback { /** @@ -138,16 +131,11 @@ public final class Loader implements LoaderErrorThrower { T loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount); } - /** - * A callback to be notified when a {@link Loader} has finished being released. - */ + /** A callback to be notified when a {@link Loader} has finished being released. */ public interface ReleaseCallback { - /** - * Called when the {@link Loader} has finished being released. - */ + /** Called when the {@link Loader} has finished being released. */ void onLoaderReleased(); - } private static final String THREAD_NAME_PREFIX = "ExoPlayer:Loader:"; @@ -314,8 +302,8 @@ public final class Loader implements LoaderErrorThrower { if (fatalError != null) { throw fatalError; } else if (currentTask != null) { - currentTask.maybeThrowError(minRetryCount == Integer.MIN_VALUE - ? currentTask.defaultMinRetryCount : minRetryCount); + currentTask.maybeThrowError( + minRetryCount == Integer.MIN_VALUE ? currentTask.defaultMinRetryCount : minRetryCount); } } @@ -344,8 +332,12 @@ public final class Loader implements LoaderErrorThrower { private boolean canceled; private volatile boolean released; - public LoadTask(Looper looper, T loadable, Loader.Callback callback, - int defaultMinRetryCount, long startTimeMs) { + public LoadTask( + Looper looper, + T loadable, + Loader.Callback callback, + int defaultMinRetryCount, + long startTimeMs) { super(looper); this.loadable = loadable; this.callback = callback; @@ -522,7 +514,6 @@ public final class Loader implements LoaderErrorThrower { private long getRetryDelayMillis() { return min((errorCount - 1) * 1000, 5000); } - } private static final class ReleaseTask implements Runnable { @@ -537,7 +528,5 @@ public final class Loader implements LoaderErrorThrower { public void run() { callback.onLoaderReleased(); } - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoaderErrorThrower.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoaderErrorThrower.java index 64d5938c89..eea3da8556 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoaderErrorThrower.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/LoaderErrorThrower.java @@ -32,8 +32,8 @@ public interface LoaderErrorThrower { /** * Throws a fatal error, or a non-fatal error if loading is currently backed off and the current - * {@link Loadable} has incurred a number of errors greater than the specified minimum number - * of retries. Else does nothing. + * {@link Loadable} has incurred a number of errors greater than the specified minimum number of + * retries. Else does nothing. * * @param minRetryCount A minimum retry count that must be exceeded for a non-fatal error to be * thrown. Should be non-negative. @@ -41,9 +41,7 @@ public interface LoaderErrorThrower { */ void maybeThrowError(int minRetryCount) throws IOException; - /** - * A {@link LoaderErrorThrower} that never throws. - */ + /** A {@link LoaderErrorThrower} that never throws. */ final class Dummy implements LoaderErrorThrower { @Override @@ -56,5 +54,4 @@ public interface LoaderErrorThrower { // Do nothing. } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ParsingLoadable.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ParsingLoadable.java index c9701ed9c9..0296e093c1 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/ParsingLoadable.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/ParsingLoadable.java @@ -35,9 +35,7 @@ import java.util.Map; */ public final class ParsingLoadable implements Loadable { - /** - * Parses an object from loaded data. - */ + /** Parses an object from loaded data. */ public interface Parser { /** @@ -50,7 +48,6 @@ public final class ParsingLoadable implements Loadable { * @throws IOException If an error occurs reading data from the stream. */ T parse(Uri uri, InputStream inputStream) throws IOException; - } /** @@ -123,8 +120,8 @@ public final class ParsingLoadable implements Loadable { * @param type See {@link #type}. * @param parser Parses the object from the response. */ - public ParsingLoadable(DataSource dataSource, DataSpec dataSpec, int type, - Parser parser) { + public ParsingLoadable( + DataSource dataSource, DataSpec dataSpec, int type, Parser parser) { this.dataSource = new StatsDataSource(dataSource); this.dataSpec = dataSpec; this.type = type; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSource.java index 2f0d244307..921c5597cc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSource.java @@ -47,8 +47,8 @@ public final class PriorityDataSource implements DataSource { * @param priorityTaskManager The priority manager to which the task is registered. * @param priority The priority of the task. */ - public PriorityDataSource(DataSource upstream, PriorityTaskManager priorityTaskManager, - int priority) { + public PriorityDataSource( + DataSource upstream, PriorityTaskManager priorityTaskManager, int priority) { this.upstream = Assertions.checkNotNull(upstream); this.priorityTaskManager = Assertions.checkNotNull(priorityTaskManager); this.priority = priority; @@ -87,5 +87,4 @@ public final class PriorityDataSource implements DataSource { public void close() throws IOException { upstream.close(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSourceFactory.java index cec2c9a79d..8f61480300 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/PriorityDataSourceFactory.java @@ -31,8 +31,8 @@ public final class PriorityDataSourceFactory implements Factory { * @param priorityTaskManager The priority manager to which PriorityDataSource task is registered. * @param priority The priority of PriorityDataSource task. */ - public PriorityDataSourceFactory(Factory upstreamFactory, PriorityTaskManager priorityTaskManager, - int priority) { + public PriorityDataSourceFactory( + Factory upstreamFactory, PriorityTaskManager priorityTaskManager, int priority) { this.upstreamFactory = upstreamFactory; this.priorityTaskManager = priorityTaskManager; this.priority = priority; @@ -40,8 +40,7 @@ public final class PriorityDataSourceFactory implements Factory { @Override public PriorityDataSource createDataSource() { - return new PriorityDataSource(upstreamFactory.createDataSource(), priorityTaskManager, - priority); + return new PriorityDataSource( + upstreamFactory.createDataSource(), priorityTaskManager, priority); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java index ccdf7975a6..00ad798bb4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/RawResourceDataSource.java @@ -53,9 +53,7 @@ import java.nio.channels.FileChannel; */ public final class RawResourceDataSource extends BaseDataSource { - /** - * Thrown when an {@link IOException} is encountered reading from a raw resource. - */ + /** Thrown when an {@link IOException} is encountered reading from a raw resource. */ public static class RawResourceDataSourceException extends IOException { public RawResourceDataSourceException(String message) { super(message); @@ -88,9 +86,7 @@ public final class RawResourceDataSource extends BaseDataSource { private long bytesRemaining; private boolean opened; - /** - * @param context A context. - */ + /** @param context A context. */ public RawResourceDataSource(Context context) { super(/* isNetwork= */ false); this.resources = context.getResources(); @@ -267,5 +263,4 @@ public final class RawResourceDataSource extends BaseDataSource { } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/TeeDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/TeeDataSource.java index 3ece5c1617..b1a7f7bd96 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/TeeDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/TeeDataSource.java @@ -100,5 +100,4 @@ public final class TeeDataSource implements DataSource { } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java index eb782bd334..3d3fa076fa 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/Cache.java @@ -41,9 +41,7 @@ import java.util.Set; */ public interface Cache { - /** - * Listener of {@link Cache} events. - */ + /** Listener of {@link Cache} events. */ interface Listener { /** @@ -77,9 +75,7 @@ public interface Cache { void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan); } - /** - * Thrown when an error is encountered when writing data. - */ + /** Thrown when an error is encountered when writing data. */ class CacheException extends IOException { public CacheException(String message) { @@ -152,9 +148,7 @@ public interface Cache { /** Returns the cache keys of all of the resources that are at least partially cached. */ Set getKeys(); - /** - * Returns the total disk space in bytes used by the cache. - */ + /** Returns the total disk space in bytes used by the cache. */ long getCacheSpace(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java index 76a833ddb5..7661171e4c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSink.java @@ -242,8 +242,8 @@ public final class CacheDataSink implements DataSink { FileOutputStream underlyingFileOutputStream = new FileOutputStream(file); if (bufferSize > 0) { if (bufferedOutputStream == null) { - bufferedOutputStream = new ReusableBufferedOutputStream(underlyingFileOutputStream, - bufferSize); + bufferedOutputStream = + new ReusableBufferedOutputStream(underlyingFileOutputStream, bufferSize); } else { bufferedOutputStream.reset(underlyingFileOutputStream); } @@ -275,5 +275,4 @@ public final class CacheDataSink implements DataSink { } } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java index efccb0cf78..e26dfd5c67 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSource.java @@ -342,9 +342,9 @@ public final class CacheDataSource implements DataSource { public static final int FLAG_BLOCK_ON_CACHE = 1; /** - * A flag indicating whether the cache is bypassed following any cache related error. If set - * then cache related exceptions may be thrown for one cycle of open, read and close calls. - * Subsequent cycles of these calls will then bypass the cache. + * A flag indicating whether the cache is bypassed following any cache related error. If set then + * cache related exceptions may be thrown for one cycle of open, read and close calls. Subsequent + * cycles of these calls will then bypass the cache. */ public static final int FLAG_IGNORE_CACHE_ON_ERROR = 1 << 1; // 2 @@ -863,5 +863,4 @@ public final class CacheDataSource implements DataSource { totalCachedBytesRead = 0; } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java index 2c51da8a8d..0f6159e349 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceFactory.java @@ -109,5 +109,4 @@ public final class CacheDataSourceFactory implements DataSource.Factory { eventListener, cacheKeyFactory); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java index 6ebfe01df4..6e59c4ecdc 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheEvictor.java @@ -30,9 +30,7 @@ public interface CacheEvictor extends Cache.Listener { */ boolean requiresCacheSpanTouches(); - /** - * Called when cache has been initialized. - */ + /** Called when cache has been initialized. */ void onCacheInitialized(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java index cba8f35009..ceb8ee7410 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CacheSpan.java @@ -71,16 +71,12 @@ public class CacheSpan implements Comparable { this.lastTouchTimestamp = lastTouchTimestamp; } - /** - * Returns whether this is an open-ended {@link CacheSpan}. - */ + /** Returns whether this is an open-ended {@link CacheSpan}. */ public boolean isOpenEnded() { return length == C.LENGTH_UNSET; } - /** - * Returns whether this is a hole {@link CacheSpan}. - */ + /** Returns whether this is a hole {@link CacheSpan}. */ public boolean isHoleSpan() { return !isCached; } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTracker.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTracker.java index d26e8036d7..3306b032ef 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTracker.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/CachedRegionTracker.java @@ -66,19 +66,20 @@ public final class CachedRegionTracker implements Cache.Listener { } /** - * When provided with a byte offset, this method locates the cached region within which the - * offset falls, and returns the approximate end position in milliseconds of that region. If the - * byte offset does not fall within a cached region then {@link #NOT_CACHED} is returned. - * If the cached region extends to the end of the stream, {@link #CACHED_TO_END} is returned. + * When provided with a byte offset, this method locates the cached region within which the offset + * falls, and returns the approximate end position in milliseconds of that region. If the byte + * offset does not fall within a cached region then {@link #NOT_CACHED} is returned. If the cached + * region extends to the end of the stream, {@link #CACHED_TO_END} is returned. * * @param byteOffset The byte offset in the underlying stream. - * @return The end position of the corresponding cache region, {@link #NOT_CACHED}, or - * {@link #CACHED_TO_END}. + * @return The end position of the corresponding cache region, {@link #NOT_CACHED}, or {@link + * #CACHED_TO_END}. */ public synchronized int getRegionEndTimeMs(long byteOffset) { lookupRegion.startOffset = byteOffset; @Nullable Region floorRegion = regions.floor(lookupRegion); - if (floorRegion == null || byteOffset > floorRegion.endOffset + if (floorRegion == null + || byteOffset > floorRegion.endOffset || floorRegion.endOffsetIndex == -1) { return NOT_CACHED; } @@ -87,8 +88,9 @@ public final class CachedRegionTracker implements Cache.Listener { && floorRegion.endOffset == (chunkIndex.offsets[index] + chunkIndex.sizes[index])) { return CACHED_TO_END; } - long segmentFractionUs = (chunkIndex.durationsUs[index] - * (floorRegion.endOffset - chunkIndex.offsets[index])) / chunkIndex.sizes[index]; + long segmentFractionUs = + (chunkIndex.durationsUs[index] * (floorRegion.endOffset - chunkIndex.offsets[index])) + / chunkIndex.sizes[index]; return (int) ((chunkIndex.timesUs[index] + segmentFractionUs) / 1000); } @@ -174,13 +176,9 @@ public final class CachedRegionTracker implements Cache.Listener { private static class Region implements Comparable { - /** - * The first byte of the region (inclusive). - */ + /** The first byte of the region (inclusive). */ public long startOffset; - /** - * End offset of the region (exclusive). - */ + /** End offset of the region (exclusive). */ public long endOffset; /** * The index in chunkIndex that contains the end offset. May be -1 if the end offset comes @@ -198,7 +196,5 @@ public final class CachedRegionTracker implements Cache.Listener { public int compareTo(Region another) { return Util.compareLong(startOffset, another.startOffset); } - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadataMutations.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadataMutations.java index f6cac58997..7f84f80843 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadataMutations.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/ContentMetadataMutations.java @@ -122,7 +122,7 @@ public class ContentMetadataMutations { return Collections.unmodifiableList(new ArrayList<>(removedValues)); } - /** Returns a map of metadata name, value pairs to be set. Values are copied. */ + /** Returns a map of metadata name, value pairs to be set. Values are copied. */ public Map getEditedValues() { HashMap hashMap = new HashMap<>(editedValues); for (Entry entry : hashMap.entrySet()) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java index 706fa0d2c3..b963a81e0c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/DefaultContentMetadata.java @@ -168,5 +168,4 @@ public final class DefaultContentMetadata implements ContentMetadata { throw new IllegalArgumentException(); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java index db3cd2ef34..9f5f7c6646 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/NoOpCacheEvictor.java @@ -52,5 +52,4 @@ public final class NoOpCacheEvictor implements CacheEvictor { public void onSpanTouched(Cache cache, CacheSpan oldSpan, CacheSpan newSpan) { // Do nothing. } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java index d02f7c0988..c9a70761b5 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpan.java @@ -29,12 +29,12 @@ import java.util.regex.Pattern; /* package */ static final String COMMON_SUFFIX = ".exo"; private static final String SUFFIX = ".v3" + COMMON_SUFFIX; - private static final Pattern CACHE_FILE_PATTERN_V1 = Pattern.compile( - "^(.+)\\.(\\d+)\\.(\\d+)\\.v1\\.exo$", Pattern.DOTALL); - private static final Pattern CACHE_FILE_PATTERN_V2 = Pattern.compile( - "^(.+)\\.(\\d+)\\.(\\d+)\\.v2\\.exo$", Pattern.DOTALL); - private static final Pattern CACHE_FILE_PATTERN_V3 = Pattern.compile( - "^(\\d+)\\.(\\d+)\\.(\\d+)\\.v3\\.exo$", Pattern.DOTALL); + private static final Pattern CACHE_FILE_PATTERN_V1 = + Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v1\\.exo$", Pattern.DOTALL); + private static final Pattern CACHE_FILE_PATTERN_V2 = + Pattern.compile("^(.+)\\.(\\d+)\\.(\\d+)\\.v2\\.exo$", Pattern.DOTALL); + private static final Pattern CACHE_FILE_PATTERN_V3 = + Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\.v3\\.exo$", Pattern.DOTALL); /** * Returns a new {@link File} instance from {@code cacheDir}, {@code id}, {@code position}, {@code @@ -203,5 +203,4 @@ import java.util.regex.Pattern; Assertions.checkState(isCached); return new SimpleCacheSpan(key, position, length, lastTouchTimestamp, file); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipher.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipher.java index 6df114442b..b539d31ab9 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipher.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipher.java @@ -57,7 +57,9 @@ public final class AesFlushingCipher { if (startPadding != 0) { updateInPlace(new byte[startPadding], 0, startPadding); } - } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException + } catch (NoSuchAlgorithmException + | NoSuchPaddingException + | InvalidKeyException | InvalidAlgorithmParameterException e) { // Should never happen. throw new RuntimeException(e); @@ -119,5 +121,4 @@ public final class AesFlushingCipher { private byte[] getInitializationVector(long nonce, long counter) { return ByteBuffer.allocate(16).putLong(nonce).putLong(counter).array(); } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/CryptoUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/CryptoUtil.java index 3418f46ed0..20681ee15a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/CryptoUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/upstream/crypto/CryptoUtil.java @@ -17,9 +17,7 @@ package com.google.android.exoplayer2.upstream.crypto; import androidx.annotation.Nullable; -/** - * Utility functions for the crypto package. - */ +/** Utility functions for the crypto package. */ /* package */ final class CryptoUtil { private CryptoUtil() {} @@ -42,5 +40,4 @@ import androidx.annotation.Nullable; } return hash; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java b/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java index fa40f0f012..2e3b00044c 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/AtomicFile.java @@ -65,8 +65,8 @@ public final class AtomicFile { /** * Start a new write operation on the file. This returns an {@link OutputStream} to which you can * write the new file data. If the whole data is written successfully you must call - * {@link #endWrite(OutputStream)}. On failure you should call {@link OutputStream#close()} - * only to free up resources used by it. + * {@link #endWrite(OutputStream)}. On failure you should call {@link OutputStream#close()} only + * to free up resources used by it. * *

Example usage: * diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java b/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java index 6f35168d08..1200fcb70b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/ColorParser.java @@ -35,14 +35,14 @@ public final class ColorParser { private static final String RGB = "rgb"; private static final String RGBA = "rgba"; - private static final Pattern RGB_PATTERN = Pattern.compile( - "^rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$"); + private static final Pattern RGB_PATTERN = + Pattern.compile("^rgb\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$"); - private static final Pattern RGBA_PATTERN_INT_ALPHA = Pattern.compile( - "^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$"); + private static final Pattern RGBA_PATTERN_INT_ALPHA = + Pattern.compile("^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d{1,3})\\)$"); - private static final Pattern RGBA_PATTERN_FLOAT_ALPHA = Pattern.compile( - "^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d*\\.?\\d*?)\\)$"); + private static final Pattern RGBA_PATTERN_FLOAT_ALPHA = + Pattern.compile("^rgba\\((\\d{1,3}),(\\d{1,3}),(\\d{1,3}),(\\d*\\.?\\d*?)\\)$"); private static final Map COLOR_MAP; @@ -86,8 +86,9 @@ public final class ColorParser { } return color; } else if (colorExpression.startsWith(RGBA)) { - Matcher matcher = (alphaHasFloatFormat ? RGBA_PATTERN_FLOAT_ALPHA : RGBA_PATTERN_INT_ALPHA) - .matcher(colorExpression); + Matcher matcher = + (alphaHasFloatFormat ? RGBA_PATTERN_FLOAT_ALPHA : RGBA_PATTERN_INT_ALPHA) + .matcher(colorExpression); if (matcher.matches()) { return Color.argb( alphaHasFloatFormat diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java index f7aac3bdae..c874b5365b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/DebugTextViewHelper.java @@ -190,16 +190,23 @@ public class DebugTextViewHelper implements Player.Listener, Runnable { return ""; } counters.ensureUpdated(); - return " sib:" + counters.skippedInputBufferCount - + " sb:" + counters.skippedOutputBufferCount - + " rb:" + counters.renderedOutputBufferCount - + " db:" + counters.droppedBufferCount - + " mcdb:" + counters.maxConsecutiveDroppedBufferCount - + " dk:" + counters.droppedToKeyframeCount; + return " sib:" + + counters.skippedInputBufferCount + + " sb:" + + counters.skippedOutputBufferCount + + " rb:" + + counters.renderedOutputBufferCount + + " db:" + + counters.droppedBufferCount + + " mcdb:" + + counters.maxConsecutiveDroppedBufferCount + + " dk:" + + counters.droppedToKeyframeCount; } private static String getPixelAspectRatioString(float pixelAspectRatio) { - return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f ? "" + return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f + ? "" : (" par:" + String.format(Locale.US, "%.02f", pixelAspectRatio)); } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java b/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java index 12513f597a..e982212a18 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/EventLogger.java @@ -57,6 +57,7 @@ public class EventLogger implements AnalyticsListener { private static final String DEFAULT_TAG = "EventLogger"; private static final int MAX_TIMELINE_ITEM_LINES = 3; private static final NumberFormat TIME_FORMAT; + static { TIME_FORMAT = NumberFormat.getInstance(Locale.US); TIME_FORMAT.setMinimumFractionDigits(2); @@ -667,8 +668,10 @@ public class EventLogger implements AnalyticsListener { @SuppressWarnings("ReferenceEquality") private static String getTrackStatusString( @Nullable TrackSelection selection, TrackGroup group, int trackIndex) { - return getTrackStatusString(selection != null && selection.getTrackGroup() == group - && selection.indexOf(trackIndex) != C.INDEX_UNSET); + return getTrackStatusString( + selection != null + && selection.getTrackGroup() == group + && selection.indexOf(trackIndex) != C.INDEX_UNSET); } private static String getTrackStatusString(boolean enabled) { diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/LibraryLoader.java b/library/core/src/main/java/com/google/android/exoplayer2/util/LibraryLoader.java index be8ebe2f5c..f46f7a223b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/LibraryLoader.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/LibraryLoader.java @@ -26,25 +26,21 @@ public final class LibraryLoader { private boolean loadAttempted; private boolean isAvailable; - /** - * @param libraries The names of the libraries to load. - */ + /** @param libraries The names of the libraries to load. */ public LibraryLoader(String... libraries) { nativeLibraries = libraries; } /** - * Overrides the names of the libraries to load. Must be called before any call to - * {@link #isAvailable()}. + * Overrides the names of the libraries to load. Must be called before any call to {@link + * #isAvailable()}. */ public synchronized void setLibraries(String... libraries) { Assertions.checkState(!loadAttempted, "Cannot set libraries after loading"); nativeLibraries = libraries; } - /** - * Returns whether the underlying libraries are available, loading them if necessary. - */ + /** Returns whether the underlying libraries are available, loading them if necessary. */ public synchronized boolean isAvailable() { if (loadAttempted) { return isAvailable; @@ -62,5 +58,4 @@ public final class LibraryLoader { } return isAvailable; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/MediaClock.java b/library/core/src/main/java/com/google/android/exoplayer2/util/MediaClock.java index 48954cb9df..baa4802372 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/MediaClock.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/MediaClock.java @@ -20,9 +20,7 @@ import com.google.android.exoplayer2.PlaybackParameters; /** Tracks the progression of media time. */ public interface MediaClock { - /** - * Returns the current media position in microseconds. - */ + /** Returns the current media position in microseconds. */ long getPositionUs(); /** diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/PriorityTaskManager.java b/library/core/src/main/java/com/google/android/exoplayer2/util/PriorityTaskManager.java index 9021e26211..e380d84e35 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/PriorityTaskManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/PriorityTaskManager.java @@ -31,15 +31,12 @@ import java.util.PriorityQueue; */ public final class PriorityTaskManager { - /** - * Thrown when task attempts to proceed when another registered task has a higher priority. - */ + /** Thrown when task attempts to proceed when another registered task has a higher priority. */ public static class PriorityTooLowException extends IOException { public PriorityTooLowException(int priority, int highestPriority) { super("Priority too low [priority=" + priority + ", highest=" + highestPriority + "]"); } - } private final Object lock = new Object(); @@ -117,5 +114,4 @@ public final class PriorityTaskManager { lock.notifyAll(); } } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/SlidingPercentile.java b/library/core/src/main/java/com/google/android/exoplayer2/util/SlidingPercentile.java index 829f252c22..ebe5c2a5f4 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/SlidingPercentile.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/SlidingPercentile.java @@ -55,9 +55,7 @@ public class SlidingPercentile { private int totalWeight; private int recycledSampleCount; - /** - * @param maxWeight The maximum weight. - */ + /** @param maxWeight The maximum weight. */ public SlidingPercentile(int maxWeight) { this.maxWeight = maxWeight; recycledSamples = new Sample[MAX_RECYCLED_SAMPLES]; @@ -82,8 +80,8 @@ public class SlidingPercentile { public void addSample(int weight, float value) { ensureSortedByIndex(); - Sample newSample = recycledSampleCount > 0 ? recycledSamples[--recycledSampleCount] - : new Sample(); + Sample newSample = + recycledSampleCount > 0 ? recycledSamples[--recycledSampleCount] : new Sample(); newSample.index = nextSampleIndex++; newSample.weight = weight; newSample.value = value; @@ -127,9 +125,7 @@ public class SlidingPercentile { return samples.isEmpty() ? Float.NaN : samples.get(samples.size() - 1).value; } - /** - * Sorts the samples by index. - */ + /** Sorts the samples by index. */ private void ensureSortedByIndex() { if (currentSortOrder != SORT_ORDER_BY_INDEX) { Collections.sort(samples, INDEX_COMPARATOR); @@ -137,9 +133,7 @@ public class SlidingPercentile { } } - /** - * Sorts the samples by value. - */ + /** Sorts the samples by value. */ private void ensureSortedByValue() { if (currentSortOrder != SORT_ORDER_BY_VALUE) { Collections.sort(samples, VALUE_COMPARATOR); @@ -152,7 +146,5 @@ public class SlidingPercentile { public int index; public int weight; public float value; - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java b/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java index 87970d3c00..4c4d4d114b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/StandaloneMediaClock.java @@ -41,9 +41,7 @@ public final class StandaloneMediaClock implements MediaClock { playbackParameters = PlaybackParameters.DEFAULT; } - /** - * Starts the clock. Does nothing if the clock is already started. - */ + /** Starts the clock. Does nothing if the clock is already started. */ public void start() { if (!started) { baseElapsedMs = clock.elapsedRealtime(); @@ -51,9 +49,7 @@ public final class StandaloneMediaClock implements MediaClock { } } - /** - * Stops the clock. Does nothing if the clock is already stopped. - */ + /** Stops the clock. Does nothing if the clock is already stopped. */ public void stop() { if (started) { resetPosition(getPositionUs()); @@ -102,5 +98,4 @@ public final class StandaloneMediaClock implements MediaClock { public PlaybackParameters getPlaybackParameters() { return playbackParameters; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/util/UriUtil.java b/library/core/src/main/java/com/google/android/exoplayer2/util/UriUtil.java index ecc5c91ae3..c95f6c7a6a 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/util/UriUtil.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/util/UriUtil.java @@ -22,39 +22,37 @@ import androidx.annotation.Nullable; /** Utility methods for manipulating URIs. */ public final class UriUtil { - /** - * The length of arrays returned by {@link #getUriIndices(String)}. - */ + /** The length of arrays returned by {@link #getUriIndices(String)}. */ private static final int INDEX_COUNT = 4; /** * An index into an array returned by {@link #getUriIndices(String)}. - *

- * The value at this position in the array is the index of the ':' after the scheme. Equals -1 if - * the URI is a relative reference (no scheme). The hier-part starts at (schemeColon + 1), + * + *

The value at this position in the array is the index of the ':' after the scheme. Equals -1 + * if the URI is a relative reference (no scheme). The hier-part starts at (schemeColon + 1), * including when the URI has no scheme. */ private static final int SCHEME_COLON = 0; /** * An index into an array returned by {@link #getUriIndices(String)}. - *

- * The value at this position in the array is the index of the path part. Equals (schemeColon + 1) - * if no authority part, (schemeColon + 3) if the authority part consists of just "//", and + * + *

The value at this position in the array is the index of the path part. Equals (schemeColon + + * 1) if no authority part, (schemeColon + 3) if the authority part consists of just "//", and * (query) if no path part. The characters starting at this index can be "//" only if the * authority part is non-empty (in this case the double-slash means the first segment is empty). */ private static final int PATH = 1; /** * An index into an array returned by {@link #getUriIndices(String)}. - *

- * The value at this position in the array is the index of the query part, including the '?' + * + *

The value at this position in the array is the index of the query part, including the '?' * before the query. Equals fragment if no query part, and (fragment - 1) if the query part is a * single '?' with no data. */ private static final int QUERY = 2; /** * An index into an array returned by {@link #getUriIndices(String)}. - *

- * The value at this position in the array is the index of the fragment part, including the '#' + * + *

The value at this position in the array is the index of the fragment part, including the '#' * before the fragment. Equal to the length of the URI if no fragment part, and (length - 1) if * the fragment part is a single '#' with no data. */ @@ -198,7 +196,8 @@ public final class UriUtil { uri.delete(segmentStart, nextSegmentStart); limit -= nextSegmentStart - segmentStart; i = segmentStart; - } else if (i == segmentStart + 2 && uri.charAt(segmentStart) == '.' + } else if (i == segmentStart + 2 + && uri.charAt(segmentStart) == '.' && uri.charAt(segmentStart + 1) == '.') { // Given "abc/def/../ghi", remove "def/../" to get "abc/ghi". int prevSegmentStart = uri.lastIndexOf("/", segmentStart - 2) + 1; @@ -254,9 +253,10 @@ public final class UriUtil { // Determine hier-part structure: hier-part = "//" authority path / path // This block can also cope with schemeIndex == -1. - boolean hasAuthority = schemeIndex + 2 < queryIndex - && uriString.charAt(schemeIndex + 1) == '/' - && uriString.charAt(schemeIndex + 2) == '/'; + boolean hasAuthority = + schemeIndex + 2 < queryIndex + && uriString.charAt(schemeIndex + 1) == '/' + && uriString.charAt(schemeIndex + 2) == '/'; int pathIndex; if (hasAuthority) { pathIndex = uriString.indexOf('/', schemeIndex + 3); // find first '/' after "://" @@ -273,5 +273,4 @@ public final class UriUtil { indices[FRAGMENT] = fragmentIndex; return indices; } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/DummySurface.java b/library/core/src/main/java/com/google/android/exoplayer2/video/DummySurface.java index a68a64b28d..51e23dbbba 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/DummySurface.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/DummySurface.java @@ -41,9 +41,7 @@ public final class DummySurface extends Surface { private static final String TAG = "DummySurface"; - /** - * Whether the surface is secure. - */ + /** Whether the surface is secure. */ public final boolean secure; private static @SecureMode int secureMode; @@ -214,7 +212,5 @@ public final class DummySurface extends Surface { Assertions.checkNotNull(eglSurfaceTexture); eglSurfaceTexture.release(); } - } - } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java index 09bb6fb570..510e269e85 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/MediaCodecVideoRenderer.java @@ -97,8 +97,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { private static final String KEY_CROP_TOP = "crop-top"; // Long edge length in pixels for standard video formats, in decreasing in order. - private static final int[] STANDARD_LONG_EDGE_VIDEO_PX = new int[] { - 1920, 1600, 1440, 1280, 960, 854, 640, 540, 480}; + private static final int[] STANDARD_LONG_EDGE_VIDEO_PX = + new int[] {1920, 1600, 1440, 1280, 960, 854, 640, 540, 480}; /** * Scale factor for the initial maximum input size used to configure the codec in non-adaptive @@ -166,8 +166,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { * @param allowedJoiningTimeMs The maximum duration in milliseconds for which this video renderer * can attempt to seamlessly join an ongoing playback. */ - public MediaCodecVideoRenderer(Context context, MediaCodecSelector mediaCodecSelector, - long allowedJoiningTimeMs) { + public MediaCodecVideoRenderer( + Context context, MediaCodecSelector mediaCodecSelector, long allowedJoiningTimeMs) { this( context, mediaCodecSelector, @@ -676,8 +676,8 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { } @Override - protected void onCodecInitialized(String name, long initializedTimestampMs, - long initializationDurationMs) { + protected void onCodecInitialized( + String name, long initializedTimestampMs, long initializationDurationMs) { eventDispatcher.decoderInitialized(name, initializedTimestampMs, initializationDurationMs); codecNeedsSetOutputSurfaceWorkaround = codecNeedsSetOutputSurfaceWorkaround(name); codecHandlesHdr10PlusOutOfBandMetadata = @@ -1065,9 +1065,7 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { * @throws ExoPlaybackException If an error occurs flushing the codec. */ protected boolean maybeDropBuffersToKeyframe( - long positionUs, - boolean treatDroppedBuffersAsSkipped) - throws ExoPlaybackException { + long positionUs, boolean treatDroppedBuffersAsSkipped) throws ExoPlaybackException { int droppedSourceBufferCount = skipSource(positionUs); if (droppedSourceBufferCount == 0) { return false; @@ -1162,8 +1160,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { } private void setJoiningDeadlineMs() { - joiningDeadlineMs = allowedJoiningTimeMs > 0 - ? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) : C.TIME_UNSET; + joiningDeadlineMs = + allowedJoiningTimeMs > 0 + ? (SystemClock.elapsedRealtime() + allowedJoiningTimeMs) + : C.TIME_UNSET; } private void clearRenderedFirstFrame() { @@ -1423,8 +1423,10 @@ public class MediaCodecVideoRenderer extends MediaCodecRenderer { // Don't return a size not larger than the format for which the codec is being configured. return null; } else if (Util.SDK_INT >= 21) { - Point alignedSize = codecInfo.alignVideoSizeV21(isVerticalVideo ? shortEdgePx : longEdgePx, - isVerticalVideo ? longEdgePx : shortEdgePx); + Point alignedSize = + codecInfo.alignVideoSizeV21( + isVerticalVideo ? shortEdgePx : longEdgePx, + isVerticalVideo ? longEdgePx : shortEdgePx); float frameRate = format.frameRate; if (codecInfo.isVideoSizeAndRateSupportedV21(alignedSize.x, alignedSize.y, frameRate)) { return alignedSize; diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java index 1778ed6976..e5537d0f56 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoFrameReleaseHelper.java @@ -464,7 +464,6 @@ public final class VideoFrameReleaseHelper { updateDefaultDisplayRefreshRateParams(); } } - } /** @@ -524,21 +523,17 @@ public final class VideoFrameReleaseHelper { @Override public boolean handleMessage(Message message) { switch (message.what) { - case CREATE_CHOREOGRAPHER: { + case CREATE_CHOREOGRAPHER: createChoreographerInstanceInternal(); return true; - } - case MSG_ADD_OBSERVER: { + case MSG_ADD_OBSERVER: addObserverInternal(); return true; - } - case MSG_REMOVE_OBSERVER: { + case MSG_REMOVE_OBSERVER: removeObserverInternal(); return true; - } - default: { + default: return false; - } } } @@ -560,6 +555,5 @@ public final class VideoFrameReleaseHelper { sampledVsyncTimeNs = C.TIME_UNSET; } } - } } diff --git a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoRendererEventListener.java b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoRendererEventListener.java index 494620f89a..202fd99fc3 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/video/VideoRendererEventListener.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/video/VideoRendererEventListener.java @@ -261,5 +261,4 @@ public interface VideoRendererEventListener { } } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java b/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java index 867857cbe5..9be4c76e62 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/DefaultMediaClockTest.java @@ -282,8 +282,9 @@ public class DefaultMediaClockTest { @Test public void rendererNotReady_shouldStillUseRendererClock() throws ExoPlaybackException { - MediaClockRenderer mediaClockRenderer = new MediaClockRenderer(/* isReady= */ false, - /* isEnded= */ false, /* hasReadStreamToEnd= */ false); + MediaClockRenderer mediaClockRenderer = + new MediaClockRenderer( + /* isReady= */ false, /* isEnded= */ false, /* hasReadStreamToEnd= */ false); mediaClock.start(); mediaClock.onRendererEnabled(mediaClockRenderer); // We're not advancing the renderer media clock. Thus, the clock should appear to be stopped. @@ -293,8 +294,9 @@ public class DefaultMediaClockTest { @Test public void rendererNotReadyAndReadStreamToEnd_shouldFallbackToStandaloneClock() throws ExoPlaybackException { - MediaClockRenderer mediaClockRenderer = new MediaClockRenderer(/* isReady= */ false, - /* isEnded= */ false, /* hasReadStreamToEnd= */ true); + MediaClockRenderer mediaClockRenderer = + new MediaClockRenderer( + /* isReady= */ false, /* isEnded= */ false, /* hasReadStreamToEnd= */ true); mediaClock.start(); mediaClock.onRendererEnabled(mediaClockRenderer); assertClockIsRunning(/* isReadingAhead= */ false); @@ -312,18 +314,17 @@ public class DefaultMediaClockTest { } @Test - public void rendererEnded_shouldFallbackToStandaloneClock() - throws ExoPlaybackException { - MediaClockRenderer mediaClockRenderer = new MediaClockRenderer(/* isReady= */ true, - /* isEnded= */ true, /* hasReadStreamToEnd= */ true); + public void rendererEnded_shouldFallbackToStandaloneClock() throws ExoPlaybackException { + MediaClockRenderer mediaClockRenderer = + new MediaClockRenderer( + /* isReady= */ true, /* isEnded= */ true, /* hasReadStreamToEnd= */ true); mediaClock.start(); mediaClock.onRendererEnabled(mediaClockRenderer); assertClockIsRunning(/* isReadingAhead= */ false); } @Test - public void staleDisableRendererClock_shouldNotThrow() - throws ExoPlaybackException { + public void staleDisableRendererClock_shouldNotThrow() throws ExoPlaybackException { MediaClockRenderer mediaClockRenderer = new MediaClockRenderer(); mediaClockRenderer.positionUs = TEST_POSITION_US; mediaClock.onRendererDisabled(mediaClockRenderer); @@ -332,8 +333,7 @@ public class DefaultMediaClockTest { } @Test - public void enableSameRendererClockTwice_shouldNotThrow() - throws ExoPlaybackException { + public void enableSameRendererClockTwice_shouldNotThrow() throws ExoPlaybackException { MediaClockRenderer mediaClockRenderer = new MediaClockRenderer(); mediaClock.onRendererEnabled(mediaClockRenderer); mediaClock.onRendererEnabled(mediaClockRenderer); @@ -343,8 +343,7 @@ public class DefaultMediaClockTest { } @Test - public void enableOtherRendererClock_shouldThrow() - throws ExoPlaybackException { + public void enableOtherRendererClock_shouldThrow() throws ExoPlaybackException { MediaClockRenderer mediaClockRenderer1 = new MediaClockRenderer(); MediaClockRenderer mediaClockRenderer2 = new MediaClockRenderer(); mediaClockRenderer1.positionUs = TEST_POSITION_US; @@ -459,5 +458,4 @@ public class DefaultMediaClockTest { return isEnded; } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java index 9545209805..5a110c65fe 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/analytics/AnalyticsCollectorTest.java @@ -1348,11 +1348,7 @@ public final class AnalyticsCollectorTest { assertThat(listener.getEvents(EVENT_SEEK_STARTED)).containsExactly(contentBeforeMidroll); assertThat(listener.getEvents(EVENT_SEEK_PROCESSED)).containsExactly(contentAfterMidroll); assertThat(listener.getEvents(EVENT_IS_LOADING_CHANGED)) - .containsExactly( - contentBeforeMidroll, - contentBeforeMidroll, - midrollAd, - midrollAd) + .containsExactly(contentBeforeMidroll, contentBeforeMidroll, midrollAd, midrollAd) .inOrder(); assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)) .containsExactly(contentBeforeMidroll, midrollAd, contentAfterMidroll); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java index f24e09346f..7a6fe531af 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java @@ -167,7 +167,5 @@ public class DecoderAudioRendererTest { } return null; } - } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java index 9c14c37587..8176894702 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/SilenceSkippingAudioProcessorTest.java @@ -88,9 +88,7 @@ public final class SilenceSkippingAudioProcessorTest { // Given a signal with only noise. InputBufferProvider inputBufferProvider = getInputBufferProviderForAlternatingSilenceAndNoise( - TEST_SIGNAL_SILENCE_DURATION_MS, - /* noiseDurationMs= */ 0, - TEST_SIGNAL_FRAME_COUNT); + TEST_SIGNAL_SILENCE_DURATION_MS, /* noiseDurationMs= */ 0, TEST_SIGNAL_FRAME_COUNT); // When processing the entire signal. silenceSkippingAudioProcessor.setEnabled(true); @@ -110,9 +108,7 @@ public final class SilenceSkippingAudioProcessorTest { // Given a signal with only silence. InputBufferProvider inputBufferProvider = getInputBufferProviderForAlternatingSilenceAndNoise( - /* silenceDurationMs= */ 0, - TEST_SIGNAL_NOISE_DURATION_MS, - TEST_SIGNAL_FRAME_COUNT); + /* silenceDurationMs= */ 0, TEST_SIGNAL_NOISE_DURATION_MS, TEST_SIGNAL_FRAME_COUNT); // When processing the entire signal. SilenceSkippingAudioProcessor silenceSkippingAudioProcessor = @@ -287,9 +283,7 @@ public final class SilenceSkippingAudioProcessorTest { * between silence/noise of the specified durations to fill {@code totalFrameCount}. */ private static InputBufferProvider getInputBufferProviderForAlternatingSilenceAndNoise( - int silenceDurationMs, - int noiseDurationMs, - int totalFrameCount) { + int silenceDurationMs, int noiseDurationMs, int totalFrameCount) { int sampleRate = AUDIO_FORMAT.sampleRate; int channelCount = AUDIO_FORMAT.channelCount; Pcm16BitAudioBuilder audioBuilder = new Pcm16BitAudioBuilder(channelCount, totalFrameCount); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java index 46e179456c..5a2af2de84 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/audio/SonicAudioProcessorTest.java @@ -122,5 +122,4 @@ public final class SonicAudioProcessorTest { // Expected. } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java index 57fab8bb65..bed2e6f91f 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/drm/ClearKeyUtilTest.java @@ -134,5 +134,4 @@ public final class ClearKeyUtilTest { // Request should be unchanged. assertThat(ClearKeyUtil.adjustRequestData(KEY_REQUEST)).isEqualTo(KEY_REQUEST); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java b/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java index 74a7d1c987..bec1a7bf4b 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecAdapterTest.java @@ -75,7 +75,6 @@ public class AsynchronousMediaCodecAdapterTest { assertThat(adapter.dequeueInputBufferIndex()).isEqualTo(0); } - @Test public void dequeueInputBufferIndex_withMediaCodecError_throwsException() throws Exception { // Set an error directly on the adapter (not through the looper). diff --git a/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java b/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java index b488403a68..8a25a66262 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/mediacodec/BatchBufferTest.java @@ -262,5 +262,4 @@ public final class BatchBufferTest { sampleBuffer.data.putLong(timeUs); sampleBuffer.flip(); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java index dcb1f634c9..b505ab62f6 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/metadata/scte35/SpliceInfoDecoderTest.java @@ -46,22 +46,33 @@ public final class SpliceInfoDecoderTest { @Test public void wrappedAroundTimeSignalCommand() { - byte[] rawTimeSignalSection = new byte[] { - 0, // table_id. - (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). - 0x14, // section_length(8). - 0x00, // protocol_version. - 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). - 0x00, 0x00, 0x00, 0x00, // pts_adjustment(32). - 0x00, // cw_index. - 0x00, // tier(8). - 0x00, // tier(4), splice_command_length(4). - 0x05, // splice_command_length(8). - 0x06, // splice_command_type = time_signal. - // Start of splice_time(). - (byte) 0x80, // time_specified_flag, reserved, pts_time(1). - 0x52, 0x03, 0x02, (byte) 0x8f, // pts_time(32). PTS for a second after playback position. - 0x00, 0x00, 0x00, 0x00}; // CRC_32 (ignored, check happens at extraction). + byte[] rawTimeSignalSection = + new byte[] { + 0, // table_id. + (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). + 0x14, // section_length(8). + 0x00, // protocol_version. + 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). + 0x00, + 0x00, + 0x00, + 0x00, // pts_adjustment(32). + 0x00, // cw_index. + 0x00, // tier(8). + 0x00, // tier(4), splice_command_length(4). + 0x05, // splice_command_length(8). + 0x06, // splice_command_type = time_signal. + // Start of splice_time(). + (byte) 0x80, // time_specified_flag, reserved, pts_time(1). + 0x52, + 0x03, + 0x02, + (byte) 0x8f, // pts_time(32). PTS for a second after playback position. + 0x00, + 0x00, + 0x00, + 0x00 + }; // CRC_32 (ignored, check happens at extraction). // The playback position is 57:15:58.43 approximately. // With this offset, the playback position pts before wrapping is 0x451ebf851. @@ -73,30 +84,45 @@ public final class SpliceInfoDecoderTest { @Test public void test2SpliceInsertCommands() { - byte[] rawSpliceInsertCommand1 = new byte[] { - 0, // table_id. - (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). - 0x19, // section_length(8). - 0x00, // protocol_version. - 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). - 0x00, 0x00, 0x00, 0x00, // pts_adjustment(32). - 0x00, // cw_index. - 0x00, // tier(8). - 0x00, // tier(4), splice_command_length(4). - 0x0e, // splice_command_length(8). - 0x05, // splice_command_type = splice_insert. - // Start of splice_insert(). - 0x00, 0x00, 0x00, 0x42, // splice_event_id. - 0x00, // splice_event_cancel_indicator, reserved. - 0x40, // out_of_network_indicator, program_splice_flag, duration_flag, - // splice_immediate_flag, reserved. - // start of splice_time(). - (byte) 0x80, // time_specified_flag, reserved, pts_time(1). - 0x00, 0x00, 0x00, 0x00, // PTS for playback position 3s. - 0x00, 0x10, // unique_program_id. - 0x01, // avail_num. - 0x02, // avails_expected. - 0x00, 0x00, 0x00, 0x00}; // CRC_32 (ignored, check happens at extraction). + byte[] rawSpliceInsertCommand1 = + new byte[] { + 0, // table_id. + (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). + 0x19, // section_length(8). + 0x00, // protocol_version. + 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). + 0x00, + 0x00, + 0x00, + 0x00, // pts_adjustment(32). + 0x00, // cw_index. + 0x00, // tier(8). + 0x00, // tier(4), splice_command_length(4). + 0x0e, // splice_command_length(8). + 0x05, // splice_command_type = splice_insert. + // Start of splice_insert(). + 0x00, + 0x00, + 0x00, + 0x42, // splice_event_id. + 0x00, // splice_event_cancel_indicator, reserved. + 0x40, // out_of_network_indicator, program_splice_flag, duration_flag, + // splice_immediate_flag, reserved. + // start of splice_time(). + (byte) 0x80, // time_specified_flag, reserved, pts_time(1). + 0x00, + 0x00, + 0x00, + 0x00, // PTS for playback position 3s. + 0x00, + 0x10, // unique_program_id. + 0x01, // avail_num. + 0x02, // avails_expected. + 0x00, + 0x00, + 0x00, + 0x00 + }; // CRC_32 (ignored, check happens at extraction). Metadata metadata = feedInputBuffer(rawSpliceInsertCommand1, 2000000, 3000000); assertThat(metadata.length()).isEqualTo(1); @@ -112,35 +138,50 @@ public final class SpliceInfoDecoderTest { assertThat(command.availNum).isEqualTo(1); assertThat(command.availsExpected).isEqualTo(2); - byte[] rawSpliceInsertCommand2 = new byte[] { - 0, // table_id. - (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). - 0x22, // section_length(8). - 0x00, // protocol_version. - 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). - 0x00, 0x00, 0x00, 0x00, // pts_adjustment(32). - 0x00, // cw_index. - 0x00, // tier(8). - 0x00, // tier(4), splice_command_length(4). - 0x13, // splice_command_length(8). - 0x05, // splice_command_type = splice_insert. - // Start of splice_insert(). - (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, // splice_event_id. - 0x00, // splice_event_cancel_indicator, reserved. - 0x00, // out_of_network_indicator, program_splice_flag, duration_flag, - // splice_immediate_flag, reserved. - 0x02, // component_count. - 0x10, // component_tag. - // start of splice_time(). - (byte) 0x81, // time_specified_flag, reserved, pts_time(1). - (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, // PTS for playback position 10s. - // start of splice_time(). - 0x11, // component_tag. - 0x00, // time_specified_flag, reserved. - 0x00, 0x20, // unique_program_id. - 0x01, // avail_num. - 0x02, // avails_expected. - 0x00, 0x00, 0x00, 0x00}; // CRC_32 (ignored, check happens at extraction). + byte[] rawSpliceInsertCommand2 = + new byte[] { + 0, // table_id. + (byte) 0x80, // section_syntax_indicator, private_indicator, reserved, section_length(4). + 0x22, // section_length(8). + 0x00, // protocol_version. + 0x00, // encrypted_packet, encryption_algorithm, pts_adjustment(1). + 0x00, + 0x00, + 0x00, + 0x00, // pts_adjustment(32). + 0x00, // cw_index. + 0x00, // tier(8). + 0x00, // tier(4), splice_command_length(4). + 0x13, // splice_command_length(8). + 0x05, // splice_command_type = splice_insert. + // Start of splice_insert(). + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, // splice_event_id. + 0x00, // splice_event_cancel_indicator, reserved. + 0x00, // out_of_network_indicator, program_splice_flag, duration_flag, + // splice_immediate_flag, reserved. + 0x02, // component_count. + 0x10, // component_tag. + // start of splice_time(). + (byte) 0x81, // time_specified_flag, reserved, pts_time(1). + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, + (byte) 0xff, // PTS for playback position 10s. + // start of splice_time(). + 0x11, // component_tag. + 0x00, // time_specified_flag, reserved. + 0x00, + 0x20, // unique_program_id. + 0x01, // avail_num. + 0x02, // avails_expected. + 0x00, + 0x00, + 0x00, + 0x00 + }; // CRC_32 (ignored, check happens at extraction). // By changing the subsample offset we force adjuster reconstruction. long subsampleOffset = 1000011; @@ -203,5 +244,4 @@ public final class SpliceInfoDecoderTest { return TimestampAdjuster.ptsToUs(TimestampAdjuster.usToNonWrappedPts(timeUs - offsetUs)) + offsetUs; } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java index c2f9ad07f7..a205496dd0 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/source/CompositeSequenceableLoaderTest.java @@ -36,8 +36,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader(/* bufferedPositionUs */ 1000, /* nextLoadPositionUs */ 2000); FakeSequenceableLoader loader2 = new FakeSequenceableLoader(/* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ 2001); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(1000); } @@ -55,8 +55,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader( /* bufferedPositionUs */ C.TIME_END_OF_SOURCE, /* nextLoadPositionUs */ C.TIME_END_OF_SOURCE); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2, loader3}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2, loader3}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(1000); } @@ -74,8 +74,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader( /* bufferedPositionUs */ C.TIME_END_OF_SOURCE, /* nextLoadPositionUs */ C.TIME_END_OF_SOURCE); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getBufferedPositionUs()).isEqualTo(C.TIME_END_OF_SOURCE); } @@ -89,8 +89,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader(/* bufferedPositionUs */ 1000, /* nextLoadPositionUs */ 2001); FakeSequenceableLoader loader2 = new FakeSequenceableLoader(/* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ 2000); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getNextLoadPositionUs()).isEqualTo(2000); } @@ -107,8 +107,8 @@ public final class CompositeSequenceableLoaderTest { FakeSequenceableLoader loader3 = new FakeSequenceableLoader( /* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ C.TIME_END_OF_SOURCE); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2, loader3}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2, loader3}); assertThat(compositeSequenceableLoader.getNextLoadPositionUs()).isEqualTo(2000); } @@ -124,8 +124,8 @@ public final class CompositeSequenceableLoaderTest { FakeSequenceableLoader loader2 = new FakeSequenceableLoader( /* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ C.TIME_END_OF_SOURCE); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.getNextLoadPositionUs()).isEqualTo(C.TIME_END_OF_SOURCE); } @@ -140,8 +140,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader(/* bufferedPositionUs */ 1000, /* nextLoadPositionUs */ 2000); FakeSequenceableLoader loader2 = new FakeSequenceableLoader(/* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ 2001); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); compositeSequenceableLoader.continueLoading(100); assertThat(loader1.numInvocations).isEqualTo(1); @@ -160,8 +160,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader(/* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ 2001); FakeSequenceableLoader loader3 = new FakeSequenceableLoader(/* bufferedPositionUs */ 1002, /* nextLoadPositionUs */ 2002); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2, loader3}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2, loader3}); compositeSequenceableLoader.continueLoading(3000); assertThat(loader1.numInvocations).isEqualTo(1); @@ -181,8 +181,8 @@ public final class CompositeSequenceableLoaderTest { FakeSequenceableLoader loader2 = new FakeSequenceableLoader( /* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ C.TIME_END_OF_SOURCE); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); compositeSequenceableLoader.continueLoading(3000); assertThat(loader1.numInvocations).isEqualTo(0); @@ -202,8 +202,8 @@ public final class CompositeSequenceableLoaderTest { new FakeSequenceableLoader(/* bufferedPositionUs */ 1001, /* nextLoadPositionUs */ 2001); loader1.setNextChunkDurationUs(1000); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.continueLoading(100)).isTrue(); } @@ -222,8 +222,8 @@ public final class CompositeSequenceableLoaderTest { // loader2 is not the furthest behind, but it can make progress if allowed. loader2.setNextChunkDurationUs(1000); - CompositeSequenceableLoader compositeSequenceableLoader = new CompositeSequenceableLoader( - new SequenceableLoader[] {loader1, loader2}); + CompositeSequenceableLoader compositeSequenceableLoader = + new CompositeSequenceableLoader(new SequenceableLoader[] {loader1, loader2}); assertThat(compositeSequenceableLoader.continueLoading(3000)).isTrue(); } @@ -274,7 +274,5 @@ public final class CompositeSequenceableLoaderTest { private void setNextChunkDurationUs(int nextChunkDurationUs) { this.nextChunkDurationUs = nextChunkDurationUs; } - } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java index 8ce5c999f7..317ddceb05 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java @@ -1384,9 +1384,7 @@ public final class SampleQueueTest { // Internal methods. - /** - * Writes standard test data to {@code sampleQueue}. - */ + /** Writes standard test data to {@code sampleQueue}. */ private void writeTestData() { writeTestData( DATA, SAMPLE_SIZES, SAMPLE_OFFSETS, SAMPLE_TIMESTAMPS, SAMPLE_FORMATS, SAMPLE_FLAGS); @@ -1402,12 +1400,15 @@ public final class SampleQueueTest { ENCRYPTED_SAMPLES_FLAGS); } - /** - * Writes the specified test data to {@code sampleQueue}. - */ + /** Writes the specified test data to {@code sampleQueue}. */ @SuppressWarnings("ReferenceEquality") - private void writeTestData(byte[] data, int[] sampleSizes, int[] sampleOffsets, - long[] sampleTimestamps, Format[] sampleFormats, int[] sampleFlags) { + private void writeTestData( + byte[] data, + int[] sampleSizes, + int[] sampleOffsets, + long[] sampleTimestamps, + Format[] sampleFormats, + int[] sampleFlags) { sampleQueue.sampleData(new ParsableByteArray(data), data.length); Format format = null; for (int i = 0; i < sampleTimestamps.length; i++) { @@ -1440,9 +1441,7 @@ public final class SampleQueueTest { (sampleFlags & C.BUFFER_FLAG_ENCRYPTED) != 0 ? CRYPTO_DATA : null); } - /** - * Asserts correct reading of standard test data from {@code sampleQueue}. - */ + /** Asserts correct reading of standard test data from {@code sampleQueue}. */ private void assertReadTestData() { assertReadTestData(/* startFormat= */ null, 0); } @@ -1724,9 +1723,7 @@ public final class SampleQueueTest { assertThat(allocator.getTotalBytesAllocated()).isEqualTo(ALLOCATION_SIZE * count); } - /** - * Asserts {@code inputBuffer} does not contain any sample data. - */ + /** Asserts {@code inputBuffer} does not contain any sample data. */ private void assertInputBufferContainsNoSampleData() { if (inputBuffer.data == null) { return; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java index bfa4dbd049..c301337651 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/source/ShuffleOrderTest.java @@ -167,5 +167,4 @@ public final class ShuffleOrderTest { assertThat(newNextIndex).isEqualTo(expectedNextIndex); } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java index f9d12aefd1..ce57d720de 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/text/ttml/TtmlRenderUtilTest.java @@ -122,5 +122,4 @@ public final class TtmlRenderUtilTest { return globalStyles; } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java index 797a0b5d94..2dcb3af157 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/CssParserTest.java @@ -180,7 +180,7 @@ public final class CssParserTest { // Universal selector. assertThat(style.getSpecificityScore("", "", Collections.emptySet(), "")).isEqualTo(1); // Class match without tag match. - style.setTargetClasses(new String[] { "class1", "class2"}); + style.setTargetClasses(new String[] {"class1", "class2"}); assertThat( style.getSpecificityScore( "", "", new HashSet<>(Arrays.asList("class1", "class2", "class3")), "")) @@ -265,5 +265,4 @@ public final class CssParserTest { assertThat(actualElem.isUnderline()).isEqualTo(expected.isUnderline()); } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java index 18a76c1a57..a81d1665e3 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/Mp4WebvttDecoderTest.java @@ -33,54 +33,127 @@ import org.junit.runner.RunWith; public final class Mp4WebvttDecoderTest { private static final byte[] SINGLE_CUE_SAMPLE = { - 0x00, 0x00, 0x00, 0x1C, // Size - 0x76, 0x74, 0x74, 0x63, // "vttc" Box type. VTT Cue box begins: - - 0x00, 0x00, 0x00, 0x14, // Contained payload box's size - 0x70, 0x61, 0x79, 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: - - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x0a // Hello World\n + 0x00, + 0x00, + 0x00, + 0x1C, // Size + 0x76, + 0x74, + 0x74, + 0x63, // "vttc" Box type. VTT Cue box begins: + 0x00, + 0x00, + 0x00, + 0x14, // Contained payload box's size + 0x70, + 0x61, + 0x79, + 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: + 0x48, + 0x65, + 0x6c, + 0x6c, + 0x6f, + 0x20, + 0x57, + 0x6f, + 0x72, + 0x6c, + 0x64, + 0x0a // Hello World\n }; private static final byte[] DOUBLE_CUE_SAMPLE = { - 0x00, 0x00, 0x00, 0x1B, // Size - 0x76, 0x74, 0x74, 0x63, // "vttc" Box type. First VTT Cue box begins: - - 0x00, 0x00, 0x00, 0x13, // First contained payload box's size - 0x70, 0x61, 0x79, 0x6c, // First contained payload box's type (payl), Cue Payload Box begins: - - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, // Hello World - - 0x00, 0x00, 0x00, 0x17, // Size - 0x76, 0x74, 0x74, 0x63, // "vttc" Box type. Second VTT Cue box begins: - - 0x00, 0x00, 0x00, 0x0F, // Contained payload box's size - 0x70, 0x61, 0x79, 0x6c, // Contained payload box's type (payl), Payload begins: - - 0x42, 0x79, 0x65, 0x20, 0x42, 0x79, 0x65 // Bye Bye + 0x00, + 0x00, + 0x00, + 0x1B, // Size + 0x76, + 0x74, + 0x74, + 0x63, // "vttc" Box type. First VTT Cue box begins: + 0x00, + 0x00, + 0x00, + 0x13, // First contained payload box's size + 0x70, + 0x61, + 0x79, + 0x6c, // First contained payload box's type (payl), Cue Payload Box begins: + 0x48, + 0x65, + 0x6c, + 0x6c, + 0x6f, + 0x20, + 0x57, + 0x6f, + 0x72, + 0x6c, + 0x64, // Hello World + 0x00, + 0x00, + 0x00, + 0x17, // Size + 0x76, + 0x74, + 0x74, + 0x63, // "vttc" Box type. Second VTT Cue box begins: + 0x00, + 0x00, + 0x00, + 0x0F, // Contained payload box's size + 0x70, + 0x61, + 0x79, + 0x6c, // Contained payload box's type (payl), Payload begins: + 0x42, + 0x79, + 0x65, + 0x20, + 0x42, + 0x79, + 0x65 // Bye Bye }; private static final byte[] NO_CUE_SAMPLE = { - 0x00, 0x00, 0x00, 0x1B, // Size - 0x74, 0x74, 0x74, 0x63, // "tttc" Box type, which is not a Cue. Should be skipped: - - 0x00, 0x00, 0x00, 0x13, // Contained payload box's size - 0x70, 0x61, 0x79, 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: - - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64 // Hello World + 0x00, + 0x00, + 0x00, + 0x1B, // Size + 0x74, + 0x74, + 0x74, + 0x63, // "tttc" Box type, which is not a Cue. Should be skipped: + 0x00, + 0x00, + 0x00, + 0x13, // Contained payload box's size + 0x70, + 0x61, + 0x79, + 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: + 0x48, + 0x65, + 0x6c, + 0x6c, + 0x6f, + 0x20, + 0x57, + 0x6f, + 0x72, + 0x6c, + 0x64 // Hello World }; private static final byte[] INCOMPLETE_HEADER_SAMPLE = { - 0x00, 0x00, 0x00, 0x23, // Size - 0x76, 0x74, 0x74, 0x63, // "vttc" Box type. VTT Cue box begins: - - 0x00, 0x00, 0x00, 0x14, // Contained payload box's size - 0x70, 0x61, 0x79, 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: - - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x0a, // Hello World\n - - 0x00, 0x00, 0x00, 0x07, // Size of an incomplete header, which belongs to the first vttc box. - 0x76, 0x74, 0x74 + 0x00, 0x00, 0x00, 0x23, // Size + 0x76, 0x74, 0x74, 0x63, // "vttc" Box type. VTT Cue box begins: + 0x00, 0x00, 0x00, 0x14, // Contained payload box's size + 0x70, 0x61, 0x79, 0x6c, // Contained payload box's type (payl), Cue Payload Box begins: + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x0a, // Hello World\n + 0x00, 0x00, 0x00, 0x07, // Size of an incomplete header, which belongs to the first vttc box. + 0x76, 0x74, 0x74 }; @Rule public final Expect expect = Expect.create(); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java index 778820b451..a576958b88 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/text/webvtt/WebvttCueParserTest.java @@ -31,8 +31,10 @@ public final class WebvttCueParserTest { @Test public void parseStrictValidClassesAndTrailingTokens() throws Exception { - Spanned text = parseCueText("" - + "This is text with html tags"); + Spanned text = + parseCueText( + "This is text with" + + " html tags"); assertThat(text.toString()).isEqualTo("This is text with html tags"); assertThat(text).hasUnderlineSpanBetween("This ".length(), "This is".length()); @@ -42,8 +44,10 @@ public final class WebvttCueParserTest { @Test public void parseStrictValidUnsupportedTagsStrippedOut() throws Exception { - Spanned text = parseCueText("This is text with " - + "html tags"); + Spanned text = + parseCueText( + "This is text with " + + "html tags"); assertThat(text.toString()).isEqualTo("This is text with html tags"); assertThat(text).hasNoSpans(); @@ -92,8 +96,8 @@ public final class WebvttCueParserTest { @Test public void parseWellFormedUnclosedEndAtCueEnd() throws Exception { - Spanned text = parseCueText("An unclosed u tag with " - + "italic inside"); + Spanned text = + parseCueText("An unclosed u tag with " + "italic inside"); assertThat(text.toString()).isEqualTo("An unclosed u tag with italic inside"); assertThat(text) @@ -201,11 +205,13 @@ public final class WebvttCueParserTest { @Test public void parseMonkey() throws Exception { - Spanned text = parseCueText("< u>An unclosed u tag with <<<<< i>italic" - + " inside"); + Spanned text = + parseCueText( + "< u>An unclosed u tag with <<<<< i>italic" + " inside"); assertThat(text.toString()).isEqualTo("An unclosed u tag with italic inside"); - text = parseCueText(">>>>>>>>>An unclosed u tag with <<<<< italic" - + " inside"); + text = + parseCueText( + ">>>>>>>>>An unclosed u tag with <<<<< italic" + " inside"); assertThat(text.toString()).isEqualTo(">>>>>>>>>An unclosed u tag with inside"); } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java index 21c942974a..d770f27902 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/ByteArrayDataSourceTest.java @@ -98,8 +98,14 @@ public final class ByteArrayDataSourceTest { * @param maxReadLength The maximum length of each read. * @param expectFailOnOpen Whether it is expected that opening the source will fail. */ - private void readTestData(byte[] testData, int dataOffset, int dataLength, int outputBufferLength, - int writeOffset, int maxReadLength, boolean expectFailOnOpen) { + private void readTestData( + byte[] testData, + int dataOffset, + int dataLength, + int outputBufferLength, + int writeOffset, + int maxReadLength, + boolean expectFailOnOpen) { int expectedFinalBytesRead = testData.length - dataOffset; if (dataLength != C.LENGTH_UNSET) { expectedFinalBytesRead = min(expectedFinalBytesRead, dataLength); @@ -137,8 +143,10 @@ public final class ByteArrayDataSourceTest { accumulatedBytesRead += bytesRead; assertThat(accumulatedBytesRead).isAtMost(expectedFinalBytesRead); // If we haven't read all of the bytes the request should have been satisfied in full. - assertThat(accumulatedBytesRead == expectedFinalBytesRead - || bytesRead == requestedReadLength).isTrue(); + assertThat( + accumulatedBytesRead == expectedFinalBytesRead + || bytesRead == requestedReadLength) + .isTrue(); } else { // We're done. Check we read the expected number of bytes. assertThat(accumulatedBytesRead).isEqualTo(expectedFinalBytesRead); @@ -154,5 +162,4 @@ public final class ByteArrayDataSourceTest { fail(); } } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java index 5bc3e4d04a..212b294455 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/DataSourceInputStreamTest.java @@ -59,8 +59,8 @@ public final class DataSourceInputStreamTest { byte[] readBytes = new byte[TEST_DATA.length]; int totalBytesRead = 0; while (totalBytesRead < TEST_DATA.length) { - int bytesRead = inputStream.read(readBytes, totalBytesRead, - TEST_DATA.length - totalBytesRead); + int bytesRead = + inputStream.read(readBytes, totalBytesRead, TEST_DATA.length - totalBytesRead); assertThat(bytesRead).isGreaterThan(0); totalBytesRead += bytesRead; assertThat(inputStream.bytesRead()).isEqualTo(totalBytesRead); @@ -96,12 +96,13 @@ public final class DataSourceInputStreamTest { private static DataSourceInputStream buildTestInputStream() { FakeDataSource fakeDataSource = new FakeDataSource(); - fakeDataSource.getDataSet().newDefaultData() + fakeDataSource + .getDataSet() + .newDefaultData() .appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 5)) .appendReadData(Arrays.copyOfRange(TEST_DATA, 5, 10)) .appendReadData(Arrays.copyOfRange(TEST_DATA, 10, 15)) .appendReadData(Arrays.copyOfRange(TEST_DATA, 15, TEST_DATA.length)); return new DataSourceInputStream(fakeDataSource, new DataSpec(Uri.EMPTY)); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java index e6b44e9aa8..af43da8280 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheDataSourceTest2.java @@ -136,9 +136,7 @@ public final class CacheDataSourceTest2 { assertThat(openedDataSpecs[0].length).isEqualTo(end - start); } - /** - * Asserts that the upstream source was not opened. - */ + /** Asserts that the upstream source was not opened. */ private void assertNoOpen(FakeDataSource upstreamSource) { DataSpec[] openedDataSpecs = upstreamSource.getAndClearOpenedDataSpecs(); assertThat(openedDataSpecs).hasLength(0); @@ -150,8 +148,8 @@ public final class CacheDataSourceTest2 { return fakeDataSource; } - private static CacheDataSource buildCacheDataSource(Context context, DataSource upstreamSource, - boolean useAesEncryption) throws CacheException { + private static CacheDataSource buildCacheDataSource( + Context context, DataSource upstreamSource, boolean useAesEncryption) throws CacheException { File cacheDir = context.getExternalCacheDir(); Cache cache = new SimpleCache( @@ -163,16 +161,19 @@ public final class CacheDataSourceTest2 { // Source and cipher final String secretKey = "testKey:12345678"; DataSource file = new FileDataSource(); - DataSource cacheReadDataSource = useAesEncryption - ? new AesCipherDataSource(Util.getUtf8Bytes(secretKey), file) : file; + DataSource cacheReadDataSource = + useAesEncryption ? new AesCipherDataSource(Util.getUtf8Bytes(secretKey), file) : file; // Sink and cipher CacheDataSink cacheSink = new CacheDataSink(cache, EXO_CACHE_MAX_FILESIZE); byte[] scratch = new byte[3897]; - DataSink cacheWriteDataSink = useAesEncryption - ? new AesCipherDataSink(Util.getUtf8Bytes(secretKey), cacheSink, scratch) : cacheSink; + DataSink cacheWriteDataSink = + useAesEncryption + ? new AesCipherDataSink(Util.getUtf8Bytes(secretKey), cacheSink, scratch) + : cacheSink; - return new CacheDataSource(cache, + return new CacheDataSource( + cache, upstreamSource, cacheReadDataSource, cacheWriteDataSink, @@ -189,5 +190,4 @@ public final class CacheDataSourceTest2 { // Check that the cache really is empty now. assertThat(cache.getKeys().isEmpty()).isTrue(); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java index b094f332de..1ff7ea81d7 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CacheWriterTest.java @@ -113,9 +113,12 @@ public final class CacheWriterTest { @Test public void cacheUnknownLength() throws Exception { - FakeDataSet fakeDataSet = new FakeDataSet().newData("test_data") - .setSimulateUnknownLength(true) - .appendReadData(TestUtil.buildTestData(100)).endData(); + FakeDataSet fakeDataSet = + new FakeDataSet() + .newData("test_data") + .setSimulateUnknownLength(true) + .appendReadData(TestUtil.buildTestData(100)) + .endData(); FakeDataSource dataSource = new FakeDataSource(fakeDataSet); DataSpec dataSpec = new DataSpec(Uri.parse("test_data")); @@ -135,9 +138,12 @@ public final class CacheWriterTest { @Test public void cacheUnknownLengthPartialCaching() throws Exception { - FakeDataSet fakeDataSet = new FakeDataSet().newData("test_data") - .setSimulateUnknownLength(true) - .appendReadData(TestUtil.buildTestData(100)).endData(); + FakeDataSet fakeDataSet = + new FakeDataSet() + .newData("test_data") + .setSimulateUnknownLength(true) + .appendReadData(TestUtil.buildTestData(100)) + .endData(); FakeDataSource dataSource = new FakeDataSource(fakeDataSet); Uri testUri = Uri.parse("test_data"); diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java index 1237d3a312..33e6576b73 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/CachedContentIndexTest.java @@ -42,38 +42,171 @@ import org.junit.runner.RunWith; public class CachedContentIndexTest { private final byte[] testIndexV1File = { - 0, 0, 0, 1, // version - 0, 0, 0, 0, // flags - 0, 0, 0, 2, // number_of_CachedContent - 0, 0, 0, 5, // cache_id 5 - 0, 5, 65, 66, 67, 68, 69, // cache_key "ABCDE" - 0, 0, 0, 0, 0, 0, 0, 10, // original_content_length - 0, 0, 0, 2, // cache_id 2 - 0, 5, 75, 76, 77, 78, 79, // cache_key "KLMNO" - 0, 0, 0, 0, 0, 0, 10, 0, // original_content_length - (byte) 0xF6, (byte) 0xFB, 0x50, 0x41 // hashcode_of_CachedContent_array + 0, + 0, + 0, + 1, // version + 0, + 0, + 0, + 0, // flags + 0, + 0, + 0, + 2, // number_of_CachedContent + 0, + 0, + 0, + 5, // cache_id 5 + 0, + 5, + 65, + 66, + 67, + 68, + 69, // cache_key "ABCDE" + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 10, // original_content_length + 0, + 0, + 0, + 2, // cache_id 2 + 0, + 5, + 75, + 76, + 77, + 78, + 79, // cache_key "KLMNO" + 0, + 0, + 0, + 0, + 0, + 0, + 10, + 0, // original_content_length + (byte) 0xF6, + (byte) 0xFB, + 0x50, + 0x41 // hashcode_of_CachedContent_array }; private final byte[] testIndexV2File = { - 0, 0, 0, 2, // version - 0, 0, 0, 0, // flags - 0, 0, 0, 2, // number_of_CachedContent - 0, 0, 0, 5, // cache_id 5 - 0, 5, 65, 66, 67, 68, 69, // cache_key "ABCDE" - 0, 0, 0, 2, // metadata count - 0, 9, 101, 120, 111, 95, 114, 101, 100, 105, 114, // "exo_redir" - 0, 0, 0, 5, // value length - 97, 98, 99, 100, 101, // Redirected Uri "abcde" - 0, 7, 101, 120, 111, 95, 108, 101, 110, // "exo_len" - 0, 0, 0, 8, // value length - 0, 0, 0, 0, 0, 0, 0, 10, // original_content_length - 0, 0, 0, 2, // cache_id 2 - 0, 5, 75, 76, 77, 78, 79, // cache_key "KLMNO" - 0, 0, 0, 1, // metadata count - 0, 7, 101, 120, 111, 95, 108, 101, 110, // "exo_len" - 0, 0, 0, 8, // value length - 0, 0, 0, 0, 0, 0, 10, 0, // original_content_length - 0x12, 0x15, 0x66, (byte) 0x8A // hashcode_of_CachedContent_array + 0, + 0, + 0, + 2, // version + 0, + 0, + 0, + 0, // flags + 0, + 0, + 0, + 2, // number_of_CachedContent + 0, + 0, + 0, + 5, // cache_id 5 + 0, + 5, + 65, + 66, + 67, + 68, + 69, // cache_key "ABCDE" + 0, + 0, + 0, + 2, // metadata count + 0, + 9, + 101, + 120, + 111, + 95, + 114, + 101, + 100, + 105, + 114, // "exo_redir" + 0, + 0, + 0, + 5, // value length + 97, + 98, + 99, + 100, + 101, // Redirected Uri "abcde" + 0, + 7, + 101, + 120, + 111, + 95, + 108, + 101, + 110, // "exo_len" + 0, + 0, + 0, + 8, // value length + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 10, // original_content_length + 0, + 0, + 0, + 2, // cache_id 2 + 0, + 5, + 75, + 76, + 77, + 78, + 79, // cache_key "KLMNO" + 0, + 0, + 0, + 1, // metadata count + 0, + 7, + 101, + 120, + 111, + 95, + 108, + 101, + 110, // "exo_len" + 0, + 0, + 0, + 8, // value length + 0, + 0, + 0, + 0, + 0, + 0, + 10, + 0, // original_content_length + 0x12, + 0x15, + 0x66, + (byte) 0x8A // hashcode_of_CachedContent_array }; private File cacheDir; diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java index 4984e71a3e..ffe5dbdb87 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/LeastRecentlyUsedCacheEvictorTest.java @@ -38,5 +38,4 @@ public class LeastRecentlyUsedCacheEvictorTest { evictor.onCacheInitialized(); evictor.onStartFile(Mockito.mock(Cache.class), "key", 0, maxBytes + 1); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java index fa56c31a89..b0641a705c 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/cache/SimpleCacheSpanTest.java @@ -68,7 +68,9 @@ public class SimpleCacheSpanTest { + "A standalone carriage-return character \r" + "A next-line character \u0085" + "A line-separator character \u2028" - + "A paragraph-separator character \u2029", 1, 2); + + "A paragraph-separator character \u2029", + 1, + 2); } @Test @@ -142,5 +144,4 @@ public class SimpleCacheSpanTest { CacheSpan cacheSpan = SimpleCacheSpan.createCacheEntry(cacheFile, cacheFileLength, index); assertWithMessage(cacheFile.toString()).that(cacheSpan).isNull(); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java b/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java index 9af0710e9b..2811b0eada 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/upstream/crypto/AesFlushingCipherTest.java @@ -196,5 +196,4 @@ public class AesFlushingCipherTest { int differingByteCount = getDifferingByteCount(reference, data, originalOffset); assertThat(differingByteCount).isEqualTo(0); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java index cab14c2c31..dd5ccac8cd 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/util/AtomicFileTest.java @@ -90,5 +90,4 @@ public final class AtomicFileTest { assertThat(input.read()).isEqualTo(-1); input.close(); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java index c2f165dec1..da9ddbe491 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ColorParserTest.java @@ -84,16 +84,11 @@ public final class ColorParserTest { @Test public void rgbaColorParsing() { assertThat(parseTtmlColor("rgba(255,255,255,255)")).isEqualTo(WHITE); - assertThat(parseTtmlColor("rgba(255,255,255,255)")) - .isEqualTo(argb(255, 255, 255, 255)); + assertThat(parseTtmlColor("rgba(255,255,255,255)")).isEqualTo(argb(255, 255, 255, 255)); assertThat(parseTtmlColor("rgba(0, 0, 0, 255)")).isEqualTo(BLACK); - assertThat(parseTtmlColor("rgba(0, 0, 255, 0)")) - .isEqualTo(argb(0, 0, 0, 255)); + assertThat(parseTtmlColor("rgba(0, 0, 255, 0)")).isEqualTo(argb(0, 0, 0, 255)); assertThat(parseTtmlColor("rgba(255, 0, 0, 255)")).isEqualTo(RED); - assertThat(parseTtmlColor("rgba(255, 0, 255, 0)")) - .isEqualTo(argb(0, 255, 0, 255)); - assertThat(parseTtmlColor("rgba(255, 0, 0, 205)")) - .isEqualTo(argb(205, 255, 0, 0)); + assertThat(parseTtmlColor("rgba(255, 0, 255, 0)")).isEqualTo(argb(0, 255, 0, 255)); + assertThat(parseTtmlColor("rgba(255, 0, 0, 205)")).isEqualTo(argb(205, 255, 0, 0)); } - } diff --git a/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java b/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java index 6ab273bf5b..bc1cc8a5cb 100644 --- a/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java +++ b/library/core/src/test/java/com/google/android/exoplayer2/util/ReusableBufferedOutputStreamTest.java @@ -32,8 +32,8 @@ public final class ReusableBufferedOutputStreamTest { @Test public void reset() throws Exception { ByteArrayOutputStream byteArrayOutputStream1 = new ByteArrayOutputStream(1000); - ReusableBufferedOutputStream outputStream = new ReusableBufferedOutputStream( - byteArrayOutputStream1, 1000); + ReusableBufferedOutputStream outputStream = + new ReusableBufferedOutputStream(byteArrayOutputStream1, 1000); outputStream.write(TEST_DATA_1); outputStream.close(); @@ -45,5 +45,4 @@ public final class ReusableBufferedOutputStreamTest { assertThat(byteArrayOutputStream1.toByteArray()).isEqualTo(TEST_DATA_1); assertThat(byteArrayOutputStream2.toByteArray()).isEqualTo(TEST_DATA_2); } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 4136fab1bf..44d824b602 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -648,8 +648,8 @@ public final class DashMediaSource extends BaseMediaSource { // Loadable callbacks. - /* package */ void onManifestLoadCompleted(ParsingLoadable loadable, - long elapsedRealtimeMs, long loadDurationMs) { + /* package */ void onManifestLoadCompleted( + ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) { LoadEventInfo loadEventInfo = new LoadEventInfo( loadable.loadTaskId, @@ -773,8 +773,8 @@ public final class DashMediaSource extends BaseMediaSource { return loadErrorAction; } - /* package */ void onUtcTimestampLoadCompleted(ParsingLoadable loadable, - long elapsedRealtimeMs, long loadDurationMs) { + /* package */ void onUtcTimestampLoadCompleted( + ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) { LoadEventInfo loadEventInfo = new LoadEventInfo( loadable.loadTaskId, @@ -811,8 +811,8 @@ public final class DashMediaSource extends BaseMediaSource { return Loader.DONT_RETRY; } - /* package */ void onLoadCanceled(ParsingLoadable loadable, long elapsedRealtimeMs, - long loadDurationMs) { + /* package */ void onLoadCanceled( + ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) { LoadEventInfo loadEventInfo = new LoadEventInfo( loadable.loadTaskId, @@ -857,10 +857,13 @@ public final class DashMediaSource extends BaseMediaSource { } } - private void resolveUtcTimingElementHttp(UtcTimingElement timingElement, - ParsingLoadable.Parser parser) { - startLoading(new ParsingLoadable<>(dataSource, Uri.parse(timingElement.value), - C.DATA_TYPE_TIME_SYNCHRONIZATION, parser), new UtcTimestampCallback(), 1); + private void resolveUtcTimingElementHttp( + UtcTimingElement timingElement, ParsingLoadable.Parser parser) { + startLoading( + new ParsingLoadable<>( + dataSource, Uri.parse(timingElement.value), C.DATA_TYPE_TIME_SYNCHRONIZATION, parser), + new UtcTimestampCallback(), + 1); } private void loadNtpTimeOffset() { @@ -1081,8 +1084,10 @@ public final class DashMediaSource extends BaseMediaSource { return min((staleManifestReloadAttempt - 1) * 1000, 5000); } - private void startLoading(ParsingLoadable loadable, - Loader.Callback> callback, int minRetryCount) { + private void startLoading( + ParsingLoadable loadable, + Loader.Callback> callback, + int minRetryCount) { long elapsedRealtimeMs = loader.startLoading(loadable, callback, minRetryCount); manifestEventDispatcher.loadStarted( new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs), @@ -1257,7 +1262,11 @@ public final class DashMediaSource extends BaseMediaSource { Assertions.checkIndex(periodIndex, 0, getPeriodCount()); Object id = setIdentifiers ? manifest.getPeriod(periodIndex).id : null; Object uid = setIdentifiers ? (firstPeriodId + periodIndex) : null; - return period.set(id, uid, 0, manifest.getPeriodDurationUs(periodIndex), + return period.set( + id, + uid, + 0, + manifest.getPeriodDurationUs(periodIndex), C.msToUs(manifest.getPeriod(periodIndex).startMs - manifest.getPeriod(0).startMs) - offsetInFirstPeriodUs); } @@ -1270,8 +1279,8 @@ public final class DashMediaSource extends BaseMediaSource { @Override public Window getWindow(int windowIndex, Window window, long defaultPositionProjectionUs) { Assertions.checkIndex(windowIndex, 0, 1); - long windowDefaultStartPositionUs = getAdjustedWindowDefaultStartPositionUs( - defaultPositionProjectionUs); + long windowDefaultStartPositionUs = + getAdjustedWindowDefaultStartPositionUs(defaultPositionProjectionUs); return window.set( Window.SINGLE_WINDOW_UID, mediaItem, @@ -1338,7 +1347,8 @@ public final class DashMediaSource extends BaseMediaSource { return windowDefaultStartPositionUs; } long segmentNum = snapIndex.getSegmentNum(defaultStartPositionInPeriodUs, periodDurationUs); - return windowDefaultStartPositionUs + snapIndex.getTimeUs(segmentNum) + return windowDefaultStartPositionUs + + snapIndex.getTimeUs(segmentNum) - defaultStartPositionInPeriodUs; } @@ -1394,7 +1404,6 @@ public final class DashMediaSource extends BaseMediaSource { int errorCount) { return onManifestLoadError(loadable, elapsedRealtimeMs, loadDurationMs, error, errorCount); } - } private final class UtcTimestampCallback implements Loader.Callback> { @@ -1423,7 +1432,6 @@ public final class DashMediaSource extends BaseMediaSource { int errorCount) { return onUtcTimestampLoadError(loadable, elapsedRealtimeMs, loadDurationMs, error); } - } private static final class XsDateTimeParser implements ParsingLoadable.Parser { @@ -1433,7 +1441,6 @@ public final class DashMediaSource extends BaseMediaSource { String firstLine = new BufferedReader(new InputStreamReader(inputStream)).readLine(); return Util.parseXsDateTime(firstLine); } - } /* package */ static final class Iso8601Parser implements ParsingLoadable.Parser { @@ -1472,7 +1479,6 @@ public final class DashMediaSource extends BaseMediaSource { throw new ParserException(e); } } - } /** diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java index 1d46d08422..e894e07c3d 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java @@ -87,5 +87,4 @@ public final class DashWrappingSegmentIndex implements DashSegmentIndex { public boolean isExplicit() { return true; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 70853e2422..fc273558fe 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -127,7 +127,6 @@ public class DefaultDashChunkSource implements DashChunkSource { closedCaptionFormats, playerEmsgHandler); } - } private final LoaderErrorThrower manifestLoaderErrorThrower; @@ -354,9 +353,15 @@ public class DefaultDashChunkSource implements DashChunkSource { } if (pendingInitializationUri != null || pendingIndexUri != null) { // We have initialization and/or index requests to make. - out.chunk = newInitializationChunk(representationHolder, dataSource, - trackSelection.getSelectedFormat(), trackSelection.getSelectionReason(), - trackSelection.getSelectionData(), pendingInitializationUri, pendingIndexUri); + out.chunk = + newInitializationChunk( + representationHolder, + dataSource, + trackSelection.getSelectedFormat(), + trackSelection.getSelectionReason(), + trackSelection.getSelectionData(), + pendingInitializationUri, + pendingIndexUri); return; } } @@ -458,7 +463,8 @@ public class DefaultDashChunkSource implements DashChunkSource { return true; } // Workaround for missing segment at the end of the period - if (!manifest.dynamic && chunk instanceof MediaChunk + if (!manifest.dynamic + && chunk instanceof MediaChunk && e instanceof InvalidResponseCodeException && ((InvalidResponseCodeException) e).responseCode == 404) { RepresentationHolder representationHolder = @@ -582,8 +588,17 @@ public class DefaultDashChunkSource implements DashChunkSource { ? 0 : DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED; DataSpec dataSpec = DashUtil.buildDataSpec(representation, segmentUri, flags); - return new SingleSampleMediaChunk(dataSource, dataSpec, trackFormat, trackSelectionReason, - trackSelectionData, startTimeUs, endTimeUs, firstSegmentNum, trackType, trackFormat); + return new SingleSampleMediaChunk( + dataSource, + dataSpec, + trackFormat, + trackSelectionReason, + trackSelectionData, + startTimeUs, + endTimeUs, + firstSegmentNum, + trackType, + trackFormat); } else { int segmentCount = 1; for (int i = 1; i < maxSegmentCount; i++) { diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/EventSampleStream.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/EventSampleStream.java index 1abe48a047..e5da2252d9 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/EventSampleStream.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/EventSampleStream.java @@ -29,8 +29,8 @@ import com.google.android.exoplayer2.util.Util; import java.io.IOException; /** - * A {@link SampleStream} consisting of serialized {@link EventMessage}s read from an - * {@link EventStream}. + * A {@link SampleStream} consisting of serialized {@link EventMessage}s read from an {@link + * EventStream}. */ /* package */ final class EventSampleStream implements SampleStream { @@ -129,5 +129,4 @@ import java.io.IOException; currentIndex = newIndex; return skipped; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java index 316b98ebcd..48b228e993 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java @@ -21,9 +21,7 @@ import java.util.List; /** Represents a set of interchangeable encoded versions of a media content component. */ public class AdaptationSet { - /** - * Value of {@link #id} indicating no value is set.= - */ + /** Value of {@link #id} indicating no value is set.= */ public static final int ID_UNSET = -1; /** @@ -33,19 +31,15 @@ public class AdaptationSet { public final int id; /** - * The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C} - * {@code TRACK_TYPE_*} constants. + * The type of the adaptation set. One of the {@link com.google.android.exoplayer2.C} {@code + * TRACK_TYPE_*} constants. */ public final int type; - /** - * {@link Representation}s in the adaptation set. - */ + /** {@link Representation}s in the adaptation set. */ public final List representations; - /** - * Accessibility descriptors in the adaptation set. - */ + /** Accessibility descriptors in the adaptation set. */ public final List accessibilityDescriptors; /** Essential properties in the adaptation set. */ diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java index b1b61fde5f..06699afa7a 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java @@ -42,14 +42,10 @@ public class DashManifest implements FilterableManifest { */ public final long durationMs; - /** - * The {@code minBufferTime} value in milliseconds, or {@link C#TIME_UNSET} if not present. - */ + /** The {@code minBufferTime} value in milliseconds, or {@link C#TIME_UNSET} if not present. */ public final long minBufferTimeMs; - /** - * Whether the manifest has value "dynamic" for the {@code type} attribute. - */ + /** Whether the manifest has value "dynamic" for the {@code type} attribute. */ public final boolean dynamic; /** @@ -59,8 +55,7 @@ public class DashManifest implements FilterableManifest { public final long minUpdatePeriodMs; /** - * The {@code timeShiftBufferDepth} value in milliseconds, or {@link C#TIME_UNSET} if not - * present. + * The {@code timeShiftBufferDepth} value in milliseconds, or {@link C#TIME_UNSET} if not present. */ public final long timeShiftBufferDepthMs; @@ -71,8 +66,8 @@ public class DashManifest implements FilterableManifest { public final long suggestedPresentationDelayMs; /** - * The {@code publishTime} value in milliseconds since epoch, or {@link C#TIME_UNSET} if - * not present. + * The {@code publishTime} value in milliseconds since epoch, or {@link C#TIME_UNSET} if not + * present. */ public final long publishTimeMs; @@ -159,8 +154,9 @@ public class DashManifest implements FilterableManifest { Period period = getPeriod(periodIndex); ArrayList copyAdaptationSets = copyAdaptationSets(period.adaptationSets, keys); - Period copiedPeriod = new Period(period.id, period.startMs - shiftMs, copyAdaptationSets, - period.eventStreams); + Period copiedPeriod = + new Period( + period.id, period.startMs - shiftMs, copyAdaptationSets, period.eventStreams); copyPeriods.add(copiedPeriod); } } @@ -206,10 +202,9 @@ public class DashManifest implements FilterableManifest { adaptationSet.accessibilityDescriptors, adaptationSet.essentialProperties, adaptationSet.supplementalProperties)); - } while(key.periodIndex == periodIndex); + } while (key.periodIndex == periodIndex); // Add back the last key which doesn't belong to the period being processed keys.addFirst(key); return copyAdaptationSets; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java index 6fc6038f50..2b849e9eba 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java @@ -107,19 +107,19 @@ public class DashManifestParser extends DefaultHandler } } - protected DashManifest parseMediaPresentationDescription(XmlPullParser xpp, - String baseUrl) throws XmlPullParserException, IOException { + protected DashManifest parseMediaPresentationDescription(XmlPullParser xpp, String baseUrl) + throws XmlPullParserException, IOException { long availabilityStartTime = parseDateTime(xpp, "availabilityStartTime", C.TIME_UNSET); long durationMs = parseDuration(xpp, "mediaPresentationDuration", C.TIME_UNSET); long minBufferTimeMs = parseDuration(xpp, "minBufferTime", C.TIME_UNSET); String typeString = xpp.getAttributeValue(null, "type"); boolean dynamic = "dynamic".equals(typeString); - long minUpdateTimeMs = dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET) - : C.TIME_UNSET; - long timeShiftBufferDepthMs = dynamic - ? parseDuration(xpp, "timeShiftBufferDepth", C.TIME_UNSET) : C.TIME_UNSET; - long suggestedPresentationDelayMs = dynamic - ? parseDuration(xpp, "suggestedPresentationDelay", C.TIME_UNSET) : C.TIME_UNSET; + long minUpdateTimeMs = + dynamic ? parseDuration(xpp, "minimumUpdatePeriod", C.TIME_UNSET) : C.TIME_UNSET; + long timeShiftBufferDepthMs = + dynamic ? parseDuration(xpp, "timeShiftBufferDepth", C.TIME_UNSET) : C.TIME_UNSET; + long suggestedPresentationDelayMs = + dynamic ? parseDuration(xpp, "suggestedPresentationDelay", C.TIME_UNSET) : C.TIME_UNSET; long publishTimeMs = parseDateTime(xpp, "publishTime", C.TIME_UNSET); ProgramInformation programInformation = null; UtcTimingElement utcTiming = null; @@ -168,8 +168,8 @@ public class DashManifestParser extends DefaultHandler } } else { long periodDurationMs = periodWithDurationMs.second; - nextPeriodStartMs = periodDurationMs == C.TIME_UNSET ? C.TIME_UNSET - : (period.startMs + periodDurationMs); + nextPeriodStartMs = + periodDurationMs == C.TIME_UNSET ? C.TIME_UNSET : (period.startMs + periodDurationMs); periods.add(period); } } else { @@ -522,10 +522,14 @@ public class DashManifestParser extends DefaultHandler protected int parseContentType(XmlPullParser xpp) { String contentType = xpp.getAttributeValue(null, "contentType"); - return TextUtils.isEmpty(contentType) ? C.TRACK_TYPE_UNKNOWN - : MimeTypes.BASE_TYPE_AUDIO.equals(contentType) ? C.TRACK_TYPE_AUDIO - : MimeTypes.BASE_TYPE_VIDEO.equals(contentType) ? C.TRACK_TYPE_VIDEO - : MimeTypes.BASE_TYPE_TEXT.equals(contentType) ? C.TRACK_TYPE_TEXT + return TextUtils.isEmpty(contentType) + ? C.TRACK_TYPE_UNKNOWN + : MimeTypes.BASE_TYPE_AUDIO.equals(contentType) + ? C.TRACK_TYPE_AUDIO + : MimeTypes.BASE_TYPE_VIDEO.equals(contentType) + ? C.TRACK_TYPE_VIDEO + : MimeTypes.BASE_TYPE_TEXT.equals(contentType) + ? C.TRACK_TYPE_TEXT : C.TRACK_TYPE_UNKNOWN; } @@ -733,8 +737,14 @@ public class DashManifestParser extends DefaultHandler supplementalProperties); segmentBase = segmentBase != null ? segmentBase : new SingleSegmentBase(); - return new RepresentationInfo(format, baseUrl, segmentBase, drmSchemeType, drmSchemeDatas, - inbandEventStreams, Representation.REVISION_ID_DEFAULT); + return new RepresentationInfo( + format, + baseUrl, + segmentBase, + drmSchemeType, + drmSchemeDatas, + inbandEventStreams, + Representation.REVISION_ID_DEFAULT); } protected Format buildFormat( @@ -827,8 +837,9 @@ public class DashManifestParser extends DefaultHandler throws XmlPullParserException, IOException { long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1); - long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset", - parent != null ? parent.presentationTimeOffset : 0); + long presentationTimeOffset = + parseLong( + xpp, "presentationTimeOffset", parent != null ? parent.presentationTimeOffset : 0); long indexStart = parent != null ? parent.indexStart : 0; long indexLength = parent != null ? parent.indexLength : 0; @@ -849,14 +860,18 @@ public class DashManifestParser extends DefaultHandler } } while (!XmlPullParserUtil.isEndTag(xpp, "SegmentBase")); - return buildSingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart, - indexLength); + return buildSingleSegmentBase( + initialization, timescale, presentationTimeOffset, indexStart, indexLength); } - protected SingleSegmentBase buildSingleSegmentBase(RangedUri initialization, long timescale, - long presentationTimeOffset, long indexStart, long indexLength) { - return new SingleSegmentBase(initialization, timescale, presentationTimeOffset, indexStart, - indexLength); + protected SingleSegmentBase buildSingleSegmentBase( + RangedUri initialization, + long timescale, + long presentationTimeOffset, + long indexStart, + long indexLength) { + return new SingleSegmentBase( + initialization, timescale, presentationTimeOffset, indexStart, indexLength); } protected SegmentList parseSegmentList( @@ -870,8 +885,9 @@ public class DashManifestParser extends DefaultHandler throws XmlPullParserException, IOException { long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1); - long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset", - parent != null ? parent.presentationTimeOffset : 0); + long presentationTimeOffset = + parseLong( + xpp, "presentationTimeOffset", parent != null ? parent.presentationTimeOffset : 0); long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET); long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1); long availabilityTimeOffsetUs = @@ -952,8 +968,9 @@ public class DashManifestParser extends DefaultHandler long timeShiftBufferDepthMs) throws XmlPullParserException, IOException { long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1); - long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset", - parent != null ? parent.presentationTimeOffset : 0); + long presentationTimeOffset = + parseLong( + xpp, "presentationTimeOffset", parent != null ? parent.presentationTimeOffset : 0); long duration = parseLong(xpp, "duration", parent != null ? parent.duration : C.TIME_UNSET); long startNumber = parseLong(xpp, "startNumber", parent != null ? parent.startNumber : 1); long endNumber = @@ -962,10 +979,11 @@ public class DashManifestParser extends DefaultHandler getFinalAvailabilityTimeOffset( baseUrlAvailabilityTimeOffsetUs, segmentBaseAvailabilityTimeOffsetUs); - UrlTemplate mediaTemplate = parseUrlTemplate(xpp, "media", - parent != null ? parent.mediaTemplate : null); - UrlTemplate initializationTemplate = parseUrlTemplate(xpp, "initialization", - parent != null ? parent.initializationTemplate : null); + UrlTemplate mediaTemplate = + parseUrlTemplate(xpp, "media", parent != null ? parent.mediaTemplate : null); + UrlTemplate initializationTemplate = + parseUrlTemplate( + xpp, "initialization", parent != null ? parent.initializationTemplate : null); RangedUri initialization = null; List timeline = null; @@ -1065,8 +1083,12 @@ public class DashManifestParser extends DefaultHandler return buildEventStream(schemeIdUri, value, timescale, presentationTimesUs, events); } - protected EventStream buildEventStream(String schemeIdUri, String value, long timescale, - long[] presentationTimesUs, EventMessage[] events) { + protected EventStream buildEventStream( + String schemeIdUri, + String value, + long timescale, + long[] presentationTimesUs, + EventMessage[] events) { return new EventStream(schemeIdUri, value, timescale, presentationTimesUs, events); } @@ -1095,8 +1117,8 @@ public class DashManifestParser extends DefaultHandler long duration = parseLong(xpp, "duration", C.TIME_UNSET); long presentationTime = parseLong(xpp, "presentationTime", 0); long durationMs = Util.scaleLargeTimestamp(duration, C.MILLIS_PER_SECOND, timescale); - long presentationTimesUs = Util.scaleLargeTimestamp(presentationTime, C.MICROS_PER_SECOND, - timescale); + long presentationTimesUs = + Util.scaleLargeTimestamp(presentationTime, C.MICROS_PER_SECOND, timescale); String messageData = parseString(xpp, "messageData", null); byte[] eventObject = parseEventObject(xpp, scratchOutputStream); return Pair.create( @@ -1137,8 +1159,8 @@ public class DashManifestParser extends DefaultHandler case (XmlPullParser.START_TAG): xmlSerializer.startTag(xpp.getNamespace(), xpp.getName()); for (int i = 0; i < xpp.getAttributeCount(); i++) { - xmlSerializer.attribute(xpp.getAttributeNamespace(i), xpp.getAttributeName(i), - xpp.getAttributeValue(i)); + xmlSerializer.attribute( + xpp.getAttributeNamespace(i), xpp.getAttributeName(i), xpp.getAttributeValue(i)); } break; case (XmlPullParser.END_TAG): @@ -1271,8 +1293,8 @@ public class DashManifestParser extends DefaultHandler return parseRangedUrl(xpp, "media", "mediaRange"); } - protected RangedUri parseRangedUrl(XmlPullParser xpp, String urlAttribute, - String rangeAttribute) { + protected RangedUri parseRangedUrl( + XmlPullParser xpp, String urlAttribute, String rangeAttribute) { String urlText = xpp.getAttributeValue(null, urlAttribute); long rangeStart = 0; long rangeLength = C.LENGTH_UNSET; @@ -1539,9 +1561,7 @@ public class DashManifestParser extends DefaultHandler } } - /** - * Removes unnecessary {@link SchemeData}s with null {@link SchemeData#data}. - */ + /** Removes unnecessary {@link SchemeData}s with null {@link SchemeData#data}. */ private static void filterRedundantIncompleteSchemeDatas(ArrayList schemeDatas) { for (int i = schemeDatas.size() - 1; i >= 0; i--) { SchemeData schemeData = schemeDatas.get(i); @@ -1612,9 +1632,9 @@ public class DashManifestParser extends DefaultHandler /** * Checks two adaptation set content types for consistency, returning the consistent type, or * throwing an {@link IllegalStateException} if the types are inconsistent. - *

- * Two types are consistent if they are equal, or if one is {@link C#TRACK_TYPE_UNKNOWN}. - * Where one of the types is {@link C#TRACK_TYPE_UNKNOWN}, the other is returned. + * + *

Two types are consistent if they are equal, or if one is {@link C#TRACK_TYPE_UNKNOWN}. Where + * one of the types is {@link C#TRACK_TYPE_UNKNOWN}, the other is returned. * * @param firstType The first type. * @param secondType The second type. @@ -1651,8 +1671,7 @@ public class DashManifestParser extends DefaultHandler return new Descriptor(schemeIdUri, value, id); } - protected static int parseCea608AccessibilityChannel( - List accessibilityDescriptors) { + protected static int parseCea608AccessibilityChannel(List accessibilityDescriptors) { for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:scte:dash:cc:cea-608:2015".equals(descriptor.schemeIdUri) @@ -1668,8 +1687,7 @@ public class DashManifestParser extends DefaultHandler return Format.NO_VALUE; } - protected static int parseCea708AccessibilityChannel( - List accessibilityDescriptors) { + protected static int parseCea708AccessibilityChannel(List accessibilityDescriptors) { for (int i = 0; i < accessibilityDescriptors.size(); i++) { Descriptor descriptor = accessibilityDescriptors.get(i); if ("urn:scte:dash:cc:cea-708:2015".equals(descriptor.schemeIdUri) @@ -1867,7 +1885,5 @@ public class DashManifestParser extends DefaultHandler this.inbandEventStreams = inbandEventStreams; this.revisionId = revisionId; } - } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Descriptor.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Descriptor.java index 55dba54db1..23c8ee368e 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Descriptor.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Descriptor.java @@ -23,13 +23,9 @@ public final class Descriptor { /** The scheme URI. */ public final String schemeIdUri; - /** - * The value, or null. - */ + /** The value, or null. */ @Nullable public final String value; - /** - * The identifier, or null. - */ + /** The identifier, or null. */ @Nullable public final String id; /** @@ -52,7 +48,8 @@ public final class Descriptor { return false; } Descriptor other = (Descriptor) obj; - return Util.areEqual(schemeIdUri, other.schemeIdUri) && Util.areEqual(value, other.value) + return Util.areEqual(schemeIdUri, other.schemeIdUri) + && Util.areEqual(value, other.value) && Util.areEqual(id, other.id); } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/EventStream.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/EventStream.java index 178693fe04..ddc2fe5d1a 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/EventStream.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/EventStream.java @@ -20,32 +20,26 @@ import com.google.android.exoplayer2.metadata.emsg.EventMessage; /** A DASH in-MPD EventStream element, as defined by ISO/IEC 23009-1, 2nd edition, section 5.10. */ public final class EventStream { - /** - * {@link EventMessage}s in the event stream. - */ + /** {@link EventMessage}s in the event stream. */ public final EventMessage[] events; - /** - * Presentation time of the events in microsecond, sorted in ascending order. - */ + /** Presentation time of the events in microsecond, sorted in ascending order. */ public final long[] presentationTimesUs; - /** - * The scheme URI. - */ + /** The scheme URI. */ public final String schemeIdUri; - /** - * The value of the event stream. Use empty string if not defined in manifest. - */ + /** The value of the event stream. Use empty string if not defined in manifest. */ public final String value; - /** - * The timescale in units per seconds, as defined in the manifest. - */ + /** The timescale in units per seconds, as defined in the manifest. */ public final long timescale; - public EventStream(String schemeIdUri, String value, long timescale, long[] presentationTimesUs, + public EventStream( + String schemeIdUri, + String value, + long timescale, + long[] presentationTimesUs, EventMessage[] events) { this.schemeIdUri = schemeIdUri; this.value = value; @@ -54,11 +48,8 @@ public final class EventStream { this.events = events; } - /** - * A constructed id of this {@link EventStream}. Equal to {@code schemeIdUri + "/" + value}. - */ + /** A constructed id of this {@link EventStream}. Equal to {@code schemeIdUri + "/" + value}. */ public String id() { return schemeIdUri + "/" + value; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java index a2396e2533..449803ea1e 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java @@ -23,22 +23,16 @@ import java.util.List; /** Encapsulates media content components over a contiguous period of time. */ public class Period { - /** - * The period identifier, if one exists. - */ + /** The period identifier, if one exists. */ @Nullable public final String id; /** The start time of the period in milliseconds, relative to the start of the manifest. */ public final long startMs; - /** - * The adaptation sets belonging to the period. - */ + /** The adaptation sets belonging to the period. */ public final List adaptationSets; - /** - * The event stream belonging to the period. - */ + /** The event stream belonging to the period. */ public final List eventStreams; /** The asset identifier for this period, if one exists */ @@ -59,7 +53,10 @@ public class Period { * @param adaptationSets The adaptation sets belonging to the period. * @param eventStreams The {@link EventStream}s belonging to the period. */ - public Period(@Nullable String id, long startMs, List adaptationSets, + public Period( + @Nullable String id, + long startMs, + List adaptationSets, List eventStreams) { this(id, startMs, adaptationSets, eventStreams, /* assetIdentifier= */ null); } @@ -100,5 +97,4 @@ public class Period { } return C.INDEX_UNSET; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java index 60975dd54b..1637b2625a 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java @@ -23,14 +23,10 @@ import com.google.android.exoplayer2.util.UriUtil; /** Defines a range of data located at a reference uri. */ public final class RangedUri { - /** - * The (zero based) index of the first byte of the range. - */ + /** The (zero based) index of the first byte of the range. */ public final long start; - /** - * The length of the range, or {@link C#LENGTH_UNSET} to indicate that the range is unbounded. - */ + /** The length of the range, or {@link C#LENGTH_UNSET} to indicate that the range is unbounded. */ public final long length; private final String referenceUri; @@ -90,10 +86,14 @@ public final class RangedUri { if (other == null || !resolvedUri.equals(other.resolveUriString(baseUri))) { return null; } else if (length != C.LENGTH_UNSET && start + length == other.start) { - return new RangedUri(resolvedUri, start, + return new RangedUri( + resolvedUri, + start, other.length == C.LENGTH_UNSET ? C.LENGTH_UNSET : length + other.length); } else if (other.length != C.LENGTH_UNSET && other.start + other.length == start) { - return new RangedUri(resolvedUri, other.start, + return new RangedUri( + resolvedUri, + other.start, length == C.LENGTH_UNSET ? C.LENGTH_UNSET : other.length + length); } else { return null; diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java index 226ae84c51..e45972f262 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java @@ -29,9 +29,7 @@ import java.util.List; /** A DASH representation. */ public abstract class Representation { - /** - * A default value for {@link #revisionId}. - */ + /** A default value for {@link #revisionId}. */ public static final long REVISION_ID_DEFAULT = -1; /** @@ -41,17 +39,11 @@ public abstract class Representation { * often a suitable. */ public final long revisionId; - /** - * The format of the representation. - */ + /** The format of the representation. */ public final Format format; - /** - * The base URL of the representation. - */ + /** The base URL of the representation. */ public final String baseUrl; - /** - * The offset of the presentation timestamps in the media stream relative to media time. - */ + /** The offset of the presentation timestamps in the media stream relative to media time. */ public final long presentationTimeOffsetUs; /** The in-band event streams in the representation. May be empty. */ public final List inbandEventStreams; @@ -89,12 +81,7 @@ public abstract class Representation { SegmentBase segmentBase, @Nullable List inbandEventStreams) { return newInstance( - revisionId, - format, - baseUrl, - segmentBase, - inbandEventStreams, - /* cacheKey= */ null); + revisionId, format, baseUrl, segmentBase, inbandEventStreams, /* cacheKey= */ null); } /** @@ -129,8 +116,8 @@ public abstract class Representation { return new MultiSegmentRepresentation( revisionId, format, baseUrl, (MultiSegmentBase) segmentBase, inbandEventStreams); } else { - throw new IllegalArgumentException("segmentBase must be of type SingleSegmentBase or " - + "MultiSegmentBase"); + throw new IllegalArgumentException( + "segmentBase must be of type SingleSegmentBase or " + "MultiSegmentBase"); } } @@ -175,19 +162,13 @@ public abstract class Representation { @Nullable public abstract String getCacheKey(); - /** - * A DASH representation consisting of a single segment. - */ + /** A DASH representation consisting of a single segment. */ public static class SingleSegmentRepresentation extends Representation { - /** - * The uri of the single segment. - */ + /** The uri of the single segment. */ public final Uri uri; - /** - * The content length, or {@link C#LENGTH_UNSET} if unknown. - */ + /** The content length, or {@link C#LENGTH_UNSET} if unknown. */ public final long contentLength; @Nullable private final String cacheKey; @@ -217,10 +198,10 @@ public abstract class Representation { List inbandEventStreams, @Nullable String cacheKey, long contentLength) { - RangedUri rangedUri = new RangedUri(null, initializationStart, - initializationEnd - initializationStart + 1); - SingleSegmentBase segmentBase = new SingleSegmentBase(rangedUri, 1, 0, indexStart, - indexEnd - indexStart + 1); + RangedUri rangedUri = + new RangedUri(null, initializationStart, initializationEnd - initializationStart + 1); + SingleSegmentBase segmentBase = + new SingleSegmentBase(rangedUri, 1, 0, indexStart, indexEnd - indexStart + 1); return new SingleSegmentRepresentation( revisionId, format, uri, segmentBase, inbandEventStreams, cacheKey, contentLength); } @@ -249,8 +230,8 @@ public abstract class Representation { this.contentLength = contentLength; // If we have an index uri then the index is defined externally, and we shouldn't return one // directly. If we don't, then we can't do better than an index defining a single segment. - segmentIndex = indexUri != null ? null - : new SingleSegmentIndex(new RangedUri(null, 0, contentLength)); + segmentIndex = + indexUri != null ? null : new SingleSegmentIndex(new RangedUri(null, 0, contentLength)); } @Override @@ -270,12 +251,9 @@ public abstract class Representation { public String getCacheKey() { return cacheKey; } - } - /** - * A DASH representation consisting of multiple segments. - */ + /** A DASH representation consisting of multiple segments. */ public static class MultiSegmentRepresentation extends Representation implements DashSegmentIndex { @@ -368,7 +346,5 @@ public abstract class Representation { public boolean isExplicit() { return segmentBase.isExplicit(); } - } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java index 20f45b8036..754d5fc99d 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java @@ -62,16 +62,12 @@ public abstract class SegmentBase { return initialization; } - /** - * Returns the presentation time offset, in microseconds. - */ + /** Returns the presentation time offset, in microseconds. */ public long getPresentationTimeOffsetUs() { return Util.scaleLargeTimestamp(presentationTimeOffset, C.MICROS_PER_SECOND, timescale); } - /** - * A {@link SegmentBase} that defines a single segment. - */ + /** A {@link SegmentBase} that defines a single segment. */ public static class SingleSegmentBase extends SegmentBase { /* package */ final long indexStart; @@ -112,12 +108,9 @@ public abstract class SegmentBase { ? null : new RangedUri(/* referenceUri= */ null, indexStart, indexLength); } - } - /** - * A {@link SegmentBase} that consists of multiple segments. - */ + /** A {@link SegmentBase} that consists of multiple segments. */ public abstract static class MultiSegmentBase extends SegmentBase { /* package */ final long startNumber; @@ -365,7 +358,6 @@ public abstract class SegmentBase { public boolean isExplicit() { return true; } - } /** A {@link MultiSegmentBase} that uses a SegmentTemplate to define its segments. */ @@ -434,8 +426,9 @@ public abstract class SegmentBase { @Nullable public RangedUri getInitialization(Representation representation) { if (initializationTemplate != null) { - String urlString = initializationTemplate.buildUri(representation.format.id, 0, - representation.format.bitrate, 0); + String urlString = + initializationTemplate.buildUri( + representation.format.id, 0, representation.format.bitrate, 0); return new RangedUri(urlString, 0, C.LENGTH_UNSET); } else { return super.getInitialization(representation); @@ -450,8 +443,9 @@ public abstract class SegmentBase { } else { time = (sequenceNumber - startNumber) * duration; } - String uriString = mediaTemplate.buildUri(representation.format.id, sequenceNumber, - representation.format.bitrate, time); + String uriString = + mediaTemplate.buildUri( + representation.format.id, sequenceNumber, representation.format.bitrate, time); return new RangedUri(uriString, 0, C.LENGTH_UNSET); } @@ -507,5 +501,4 @@ public abstract class SegmentBase { return 31 * (int) startTime + (int) duration; } } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java index a5806450a3..77f189f5b1 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java @@ -18,16 +18,12 @@ package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.source.dash.DashSegmentIndex; -/** - * A {@link DashSegmentIndex} that defines a single segment. - */ +/** A {@link DashSegmentIndex} that defines a single segment. */ /* package */ final class SingleSegmentIndex implements DashSegmentIndex { private final RangedUri uri; - /** - * @param uri A {@link RangedUri} defining the location of the segment data. - */ + /** @param uri A {@link RangedUri} defining the location of the segment data. */ public SingleSegmentIndex(RangedUri uri) { this.uri = uri; } @@ -81,5 +77,4 @@ import com.google.android.exoplayer2.source.dash.DashSegmentIndex; public boolean isExplicit() { return true; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java index fbf06c5885..cc3597a33a 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java @@ -58,11 +58,9 @@ public final class UrlTemplate { return new UrlTemplate(urlPieces, identifiers, identifierFormatTags, identifierCount); } - /** - * Internal constructor. Use {@link #compile(String)} to build instances of this class. - */ - private UrlTemplate(String[] urlPieces, int[] identifiers, String[] identifierFormatTags, - int identifierCount) { + /** Internal constructor. Use {@link #compile(String)} to build instances of this class. */ + private UrlTemplate( + String[] urlPieces, int[] identifiers, String[] identifierFormatTags, int identifierCount) { this.urlPieces = urlPieces; this.identifiers = identifiers; this.identifierFormatTags = identifierFormatTags; @@ -100,8 +98,8 @@ public final class UrlTemplate { /** * Parses {@code template}, placing the decomposed components into the provided arrays. - *

- * If the return value is N, {@code urlPieces} will contain (N+1) strings that must be + * + *

If the return value is N, {@code urlPieces} will contain (N+1) strings that must be * interleaved with N arguments in order to construct a url. The N identifiers that correspond to * the required arguments, together with the tags that define their required formatting, are * returned in {@code identifiers} and {@code identifierFormatTags} respectively. @@ -113,8 +111,8 @@ public final class UrlTemplate { * @return The number of identifiers in the template url. * @throws IllegalArgumentException If the template string is malformed. */ - private static int parseTemplate(String template, String[] urlPieces, int[] identifiers, - String[] identifierFormatTags) { + private static int parseTemplate( + String template, String[] urlPieces, int[] identifiers, String[] identifierFormatTags) { urlPieces[0] = ""; int templateIndex = 0; int identifierCount = 0; @@ -169,5 +167,4 @@ public final class UrlTemplate { } return identifierCount; } - } diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java index 9508623c9d..7deb92e66c 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java @@ -30,5 +30,4 @@ public final class UtcTimingElement { public String toString() { return schemeIdUri + ", " + value; } - } diff --git a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java index 348290eb69..2ebca95996 100644 --- a/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java +++ b/library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java @@ -63,8 +63,8 @@ public final class EventSampleStreamTest { */ @Test public void readDataReturnFormatForFirstRead() { - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[0], new EventMessage[0]); + EventStream eventStream = + new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[0], new EventMessage[0]); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false); int result = readData(sampleStream); @@ -78,8 +78,8 @@ public final class EventSampleStreamTest { */ @Test public void readDataOutOfBoundReturnEndOfStreamAfterFormatForNonDynamicEventSampleStream() { - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[0], new EventMessage[0]); + EventStream eventStream = + new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[0], new EventMessage[0]); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false); // first read - read format readData(sampleStream); @@ -95,8 +95,8 @@ public final class EventSampleStreamTest { */ @Test public void readDataOutOfBoundReturnEndOfStreamAfterFormatForDynamicEventSampleStream() { - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[0], new EventMessage[0]); + EventStream eventStream = + new EventStream(SCHEME_ID, VALUE, TIME_SCALE, new long[0], new EventMessage[0]); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, true); // first read - read format readData(sampleStream); @@ -113,16 +113,20 @@ public final class EventSampleStreamTest { public void readDataReturnDataAfterFormat() { long presentationTimeUs = 1000000; EventMessage eventMessage = newEventMessageWithId(1); - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs}, new EventMessage[] {eventMessage}); + EventStream eventStream = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs}, + new EventMessage[] {eventMessage}); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false); // first read - read format readData(sampleStream); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage)); } /** @@ -136,9 +140,13 @@ public final class EventSampleStreamTest { long presentationTimeUs2 = 2000000; EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2}, - new EventMessage[] {eventMessage1, eventMessage2}); + EventStream eventStream = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2}, + new EventMessage[] {eventMessage1, eventMessage2}); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false); // first read - read format readData(sampleStream); @@ -147,8 +155,7 @@ public final class EventSampleStreamTest { int result = readData(sampleStream); assertThat(skipped).isEqualTo(1); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage2)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2)); } /** @@ -162,9 +169,13 @@ public final class EventSampleStreamTest { long presentationTimeUs2 = 2000000; EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); - EventStream eventStream = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2}, - new EventMessage[] {eventMessage1, eventMessage2}); + EventStream eventStream = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2}, + new EventMessage[] {eventMessage1, eventMessage2}); EventSampleStream sampleStream = new EventSampleStream(eventStream, FORMAT, false); // first read - read format readData(sampleStream); @@ -172,8 +183,7 @@ public final class EventSampleStreamTest { sampleStream.seekToUs(presentationTimeUs2); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage2)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2)); } /** @@ -190,12 +200,20 @@ public final class EventSampleStreamTest { EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); EventMessage eventMessage3 = newEventMessageWithId(3); - EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2}, - new EventMessage[] {eventMessage1, eventMessage2}); - EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, - new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); + EventStream eventStream1 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2}, + new EventMessage[] {eventMessage1, eventMessage2}); + EventStream eventStream2 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, + new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true); // first read - read format readData(sampleStream); @@ -206,8 +224,7 @@ public final class EventSampleStreamTest { sampleStream.updateEventStream(eventStream2, true); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage3)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage3)); } /** @@ -224,12 +241,20 @@ public final class EventSampleStreamTest { EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); EventMessage eventMessage3 = newEventMessageWithId(3); - EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2}, - new EventMessage[] {eventMessage1, eventMessage2}); - EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, - new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); + EventStream eventStream1 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2}, + new EventMessage[] {eventMessage1, eventMessage2}); + EventStream eventStream2 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, + new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true); // first read - read format readData(sampleStream); @@ -238,8 +263,7 @@ public final class EventSampleStreamTest { sampleStream.updateEventStream(eventStream2, true); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage3)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage3)); } /** @@ -257,12 +281,20 @@ public final class EventSampleStreamTest { EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); EventMessage eventMessage3 = newEventMessageWithId(3); - EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1}, - new EventMessage[] {eventMessage1}); - EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, - new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); + EventStream eventStream1 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1}, + new EventMessage[] {eventMessage1}); + EventStream eventStream2 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, + new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true); // first read - read format readData(sampleStream); @@ -273,8 +305,7 @@ public final class EventSampleStreamTest { sampleStream.updateEventStream(eventStream2, true); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage2)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2)); } /** @@ -291,12 +322,20 @@ public final class EventSampleStreamTest { EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); EventMessage eventMessage3 = newEventMessageWithId(3); - EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2}, - new EventMessage[] {eventMessage1, eventMessage2}); - EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, - new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); + EventStream eventStream1 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2}, + new EventMessage[] {eventMessage1, eventMessage2}); + EventStream eventStream2 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, + new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true); // first read - read format readData(sampleStream); @@ -305,8 +344,7 @@ public final class EventSampleStreamTest { sampleStream.updateEventStream(eventStream2, true); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage2)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage2)); } /** @@ -323,12 +361,20 @@ public final class EventSampleStreamTest { EventMessage eventMessage1 = newEventMessageWithId(1); EventMessage eventMessage2 = newEventMessageWithId(2); EventMessage eventMessage3 = newEventMessageWithId(3); - EventStream eventStream1 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1}, - new EventMessage[] {eventMessage1}); - EventStream eventStream2 = new EventStream(SCHEME_ID, VALUE, TIME_SCALE, - new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, - new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); + EventStream eventStream1 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1}, + new EventMessage[] {eventMessage1}); + EventStream eventStream2 = + new EventStream( + SCHEME_ID, + VALUE, + TIME_SCALE, + new long[] {presentationTimeUs1, presentationTimeUs2, presentationTimeUs3}, + new EventMessage[] {eventMessage1, eventMessage2, eventMessage3}); EventSampleStream sampleStream = new EventSampleStream(eventStream1, FORMAT, true); // first read - read format readData(sampleStream); @@ -337,8 +383,7 @@ public final class EventSampleStreamTest { sampleStream.updateEventStream(eventStream2, true); int result = readData(sampleStream); assertThat(result).isEqualTo(C.RESULT_BUFFER_READ); - assertThat(inputBuffer.data.array()) - .isEqualTo(getEncodedMessage(eventMessage3)); + assertThat(inputBuffer.data.array()).isEqualTo(getEncodedMessage(eventMessage3)); } private int readData(EventSampleStream sampleStream) { @@ -353,5 +398,4 @@ public final class EventSampleStreamTest { private byte[] getEncodedMessage(EventMessage eventMessage) { return eventMessageEncoder.encode(eventMessage); } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/CeaUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/CeaUtil.java index 525b335f13..caf72df415 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/CeaUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/CeaUtil.java @@ -133,5 +133,4 @@ public final class CeaUtil { } private CeaUtil() {} - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ChunkIndex.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ChunkIndex.java index 3a783e4df9..8291ed1ea4 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ChunkIndex.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ChunkIndex.java @@ -21,29 +21,19 @@ import java.util.Arrays; /** Defines chunks of samples within a media stream. */ public final class ChunkIndex implements SeekMap { - /** - * The number of chunks. - */ + /** The number of chunks. */ public final int length; - /** - * The chunk sizes, in bytes. - */ + /** The chunk sizes, in bytes. */ public final int[] sizes; - /** - * The chunk byte offsets. - */ + /** The chunk byte offsets. */ public final long[] offsets; - /** - * The chunk durations, in microseconds. - */ + /** The chunk durations, in microseconds. */ public final long[] durationsUs; - /** - * The start time of each chunk, in microseconds. - */ + /** The start time of each chunk, in microseconds. */ public final long[] timesUs; private final long durationUs; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java index 38844f61c7..b953d39e65 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/DefaultExtractorInput.java @@ -205,8 +205,11 @@ public final class DefaultExtractorInput implements ExtractorInput { private void ensureSpaceForPeek(int length) { int requiredLength = peekBufferPosition + length; if (requiredLength > peekBuffer.length) { - int newPeekCapacity = Util.constrainValue(peekBuffer.length * 2, - requiredLength + PEEK_MIN_FREE_SPACE_AFTER_RESIZE, requiredLength + PEEK_MAX_FREE_SPACE); + int newPeekCapacity = + Util.constrainValue( + peekBuffer.length * 2, + requiredLength + PEEK_MIN_FREE_SPACE_AFTER_RESIZE, + requiredLength + PEEK_MAX_FREE_SPACE); peekBuffer = Arrays.copyOf(peekBuffer, newPeekCapacity); } } @@ -300,5 +303,4 @@ public final class DefaultExtractorInput implements ExtractorInput { position += bytesRead; } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java index 63870282b5..21fb7f1269 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/Extractor.java @@ -38,8 +38,8 @@ public interface Extractor { */ int RESULT_SEEK = 1; /** - * Returned by {@link #read(ExtractorInput, PositionHolder)} if the end of the - * {@link ExtractorInput} was reached. Equal to {@link C#RESULT_END_OF_INPUT}. + * Returned by {@link #read(ExtractorInput, PositionHolder)} if the end of the {@link + * ExtractorInput} was reached. Equal to {@link C#RESULT_END_OF_INPUT}. */ int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT; @@ -101,8 +101,8 @@ public interface Extractor { /** * Notifies the extractor that a seek has occurred. - *

- * Following a call to this method, the {@link ExtractorInput} passed to the next invocation of + * + *

Following a call to this method, the {@link ExtractorInput} passed to the next invocation of * {@link #read(ExtractorInput, PositionHolder)} is required to provide data starting from {@code * position} in the stream. Valid random access positions are the start of the stream and * positions that can be obtained from any {@link SeekMap} passed to the {@link ExtractorOutput}. @@ -112,9 +112,6 @@ public interface Extractor { */ void seek(long position, long timeUs); - /** - * Releases all kept resources. - */ + /** Releases all kept resources. */ void release(); - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java index 6799ca6de1..8b2b31eec5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorInput.java @@ -230,9 +230,7 @@ public interface ExtractorInput extends DataReader { */ void advancePeekPosition(int length) throws IOException; - /** - * Resets the peek position to equal the current read position. - */ + /** Resets the peek position to equal the current read position. */ void resetPeekPosition(); /** @@ -266,5 +264,4 @@ public interface ExtractorInput extends DataReader { * @throws E The given {@link Throwable} object. */ void setRetryPosition(long position, E e) throws E; - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java index 09f5fa493d..bffda30d0b 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ExtractorOutput.java @@ -66,5 +66,4 @@ public interface ExtractorOutput { * @param seekMap The extracted {@link SeekMap}. */ void seekMap(SeekMap seekMap); - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/GaplessInfoHolder.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/GaplessInfoHolder.java index 09d2fd1f88..0bf6b146d5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/GaplessInfoHolder.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/GaplessInfoHolder.java @@ -33,20 +33,18 @@ public final class GaplessInfoHolder { Pattern.compile("^ [0-9a-fA-F]{8} ([0-9a-fA-F]{8}) ([0-9a-fA-F]{8})"); /** - * The number of samples to trim from the start of the decoded audio stream, or - * {@link Format#NO_VALUE} if not set. + * The number of samples to trim from the start of the decoded audio stream, or {@link + * Format#NO_VALUE} if not set. */ public int encoderDelay; /** - * The number of samples to trim from the end of the decoded audio stream, or - * {@link Format#NO_VALUE} if not set. + * The number of samples to trim from the end of the decoded audio stream, or {@link + * Format#NO_VALUE} if not set. */ public int encoderPadding; - /** - * Creates a new holder for gapless playback information. - */ + /** Creates a new holder for gapless playback information. */ public GaplessInfoHolder() { encoderDelay = Format.NO_VALUE; encoderPadding = Format.NO_VALUE; @@ -121,11 +119,8 @@ public final class GaplessInfoHolder { return false; } - /** - * Returns whether {@link #encoderDelay} and {@link #encoderPadding} have been set. - */ + /** Returns whether {@link #encoderDelay} and {@link #encoderPadding} have been set. */ public boolean hasGaplessInfo() { return encoderDelay != Format.NO_VALUE && encoderPadding != Format.NO_VALUE; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/PositionHolder.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/PositionHolder.java index e4ac523350..94ca7282d3 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/PositionHolder.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/PositionHolder.java @@ -18,9 +18,6 @@ package com.google.android.exoplayer2.extractor; /** Holds a position in the stream. */ public final class PositionHolder { - /** - * The held position. - */ + /** The held position. */ public long position; - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/TrackOutput.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/TrackOutput.java index a461f4b700..499a0ddeb8 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/TrackOutput.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/TrackOutput.java @@ -31,19 +31,13 @@ import java.util.Arrays; /** Receives track level data extracted by an {@link Extractor}. */ public interface TrackOutput { - /** - * Holds data required to decrypt a sample. - */ + /** Holds data required to decrypt a sample. */ final class CryptoData { - /** - * The encryption mode used for the sample. - */ + /** The encryption mode used for the sample. */ @C.CryptoMode public final int cryptoMode; - /** - * The encryption key associated with the sample. Its contents must not be modified. - */ + /** The encryption key associated with the sample. Its contents must not be modified. */ public final byte[] encryptionKey; /** @@ -53,8 +47,7 @@ public interface TrackOutput { public final int encryptedBlocks; /** - * The number of clear blocks in the encryption pattern, 0 if pattern encryption does not - * apply. + * The number of clear blocks in the encryption pattern, 0 if pattern encryption does not apply. */ public final int clearBlocks; @@ -64,8 +57,8 @@ public interface TrackOutput { * @param encryptedBlocks See {@link #encryptedBlocks}. * @param clearBlocks See {@link #clearBlocks}. */ - public CryptoData(@C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks, - int clearBlocks) { + public CryptoData( + @C.CryptoMode int cryptoMode, byte[] encryptionKey, int encryptedBlocks, int clearBlocks) { this.cryptoMode = cryptoMode; this.encryptionKey = encryptionKey; this.encryptedBlocks = encryptedBlocks; @@ -81,8 +74,10 @@ public interface TrackOutput { return false; } CryptoData other = (CryptoData) obj; - return cryptoMode == other.cryptoMode && encryptedBlocks == other.encryptedBlocks - && clearBlocks == other.clearBlocks && Arrays.equals(encryptionKey, other.encryptionKey); + return cryptoMode == other.cryptoMode + && encryptedBlocks == other.encryptedBlocks + && clearBlocks == other.clearBlocks + && Arrays.equals(encryptionKey, other.encryptionKey); } @Override @@ -93,7 +88,6 @@ public interface TrackOutput { result = 31 * result + clearBlocks; return result; } - } /** Defines the part of the sample data to which a call to {@link #sampleData} corresponds. */ diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisBitArray.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisBitArray.java index 7ec9c93832..56f419a184 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisBitArray.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisBitArray.java @@ -43,9 +43,7 @@ public final class VorbisBitArray { byteLimit = data.length; } - /** - * Resets the reading position to zero. - */ + /** Resets the reading position to zero. */ public void reset() { byteOffset = 0; bitOffset = 0; @@ -97,9 +95,7 @@ public final class VorbisBitArray { assertValidOffset(); } - /** - * Returns the reading position in bits. - */ + /** Returns the reading position in bits. */ public int getPosition() { return byteOffset * 8 + bitOffset; } @@ -115,17 +111,14 @@ public final class VorbisBitArray { assertValidOffset(); } - /** - * Returns the number of remaining bits. - */ + /** Returns the number of remaining bits. */ public int bitsLeft() { return (byteLimit - byteOffset) * 8 - bitOffset; } private void assertValidOffset() { // It is fine for position to be at the end of the array, but no further. - Assertions.checkState(byteOffset >= 0 - && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); + Assertions.checkState( + byteOffset >= 0 && (byteOffset < byteLimit || (byteOffset == byteLimit && bitOffset == 0))); } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java index ede2ab39e9..201400259d 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/VorbisUtil.java @@ -124,8 +124,8 @@ public final class VorbisUtil { /** * Returns ilog(x), which is the index of the highest set bit in {@code x}. * - * @see - * Vorbis spec + * @see Vorbis + * spec * @param x the value of which the ilog should be calculated. * @return ilog(x) */ @@ -346,8 +346,7 @@ public final class VorbisUtil { return modes; } - private static void readMappings(int channels, VorbisBitArray bitArray) - throws ParserException { + private static void readMappings(int channels, VorbisBitArray bitArray) throws ParserException { int mappingsCount = bitArray.readBits(6) + 1; for (int i = 0; i < mappingsCount; i++) { int mappingType = bitArray.readBits(16); @@ -425,7 +424,7 @@ public final class VorbisUtil { int floorType = bitArray.readBits(16); switch (floorType) { case 0: - bitArray.skipBits(8); //order + bitArray.skipBits(8); // order bitArray.skipBits(16); // rate bitArray.skipBits(16); // barkMapSize bitArray.skipBits(6); // amplitudeBits @@ -475,8 +474,8 @@ public final class VorbisUtil { private static CodeBook readBook(VorbisBitArray bitArray) throws ParserException { if (bitArray.readBits(24) != 0x564342) { - throw new ParserException("expected code book to start with [0x56, 0x43, 0x42] at " - + bitArray.getPosition()); + throw new ParserException( + "expected code book to start with [0x56, 0x43, 0x42] at " + bitArray.getPosition()); } int dimensions = bitArray.readBits(16); int entries = bitArray.readBits(24); @@ -498,7 +497,7 @@ public final class VorbisUtil { } } else { int length = bitArray.readBits(5) + 1; - for (int i = 0; i < lengthMap.length;) { + for (int i = 0; i < lengthMap.length; ) { int num = bitArray.readBits(iLog(entries - i)); for (int j = 0; j < num && i < lengthMap.length; i++, j++) { lengthMap[i] = length; @@ -550,14 +549,13 @@ public final class VorbisUtil { public final int lookupType; public final boolean isOrdered; - public CodeBook(int dimensions, int entries, long[] lengthMap, int lookupType, - boolean isOrdered) { + public CodeBook( + int dimensions, int entries, long[] lengthMap, int lookupType, boolean isOrdered) { this.dimensions = dimensions; this.entries = entries; this.lengthMap = lengthMap; this.lookupType = lookupType; this.isOrdered = isOrdered; } - } } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java index 0ca65e4de5..124d62dd40 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java @@ -24,9 +24,7 @@ import com.google.android.exoplayer2.util.MimeTypes; import com.google.android.exoplayer2.util.ParsableByteArray; import java.util.Collections; -/** - * Parses audio tags from an FLV stream and extracts AAC frames. - */ +/** Parses audio tags from an FLV stream and extracts AAC frames. */ /* package */ final class AudioTagPayloadReader extends TagPayloadReader { private static final int AUDIO_FORMAT_MP3 = 2; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/FlvExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/FlvExtractor.java index 2fdaf7dc46..ffb85d07f0 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/FlvExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/FlvExtractor.java @@ -198,12 +198,12 @@ public final class FlvExtractor implements Extractor { boolean hasAudio = (flags & 0x04) != 0; boolean hasVideo = (flags & 0x01) != 0; if (hasAudio && audioReader == null) { - audioReader = new AudioTagPayloadReader( - extractorOutput.track(TAG_TYPE_AUDIO, C.TRACK_TYPE_AUDIO)); + audioReader = + new AudioTagPayloadReader(extractorOutput.track(TAG_TYPE_AUDIO, C.TRACK_TYPE_AUDIO)); } if (hasVideo && videoReader == null) { - videoReader = new VideoTagPayloadReader( - extractorOutput.track(TAG_TYPE_VIDEO, C.TRACK_TYPE_VIDEO)); + videoReader = + new VideoTagPayloadReader(extractorOutput.track(TAG_TYPE_VIDEO, C.TRACK_TYPE_VIDEO)); } extractorOutput.endTracks(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java index f0b4efb106..696b38c8a5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java @@ -25,9 +25,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -/** - * Parses Script Data tags from an FLV stream and extracts metadata information. - */ +/** Parses Script Data tags from an FLV stream and extracts metadata information. */ /* package */ final class ScriptTagPayloadReader extends TagPayloadReader { private static final String NAME_METADATA = "onMetaData"; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/TagPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/TagPayloadReader.java index 48914b7c2c..d80e029704 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/TagPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/TagPayloadReader.java @@ -19,37 +19,30 @@ import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.extractor.TrackOutput; import com.google.android.exoplayer2.util.ParsableByteArray; -/** - * Extracts individual samples from FLV tags, preserving original order. - */ +/** Extracts individual samples from FLV tags, preserving original order. */ /* package */ abstract class TagPayloadReader { - /** - * Thrown when the format is not supported. - */ + /** Thrown when the format is not supported. */ public static final class UnsupportedFormatException extends ParserException { public UnsupportedFormatException(String msg) { super(msg); } - } protected final TrackOutput output; - /** - * @param output A {@link TrackOutput} to which samples should be written. - */ + /** @param output A {@link TrackOutput} to which samples should be written. */ protected TagPayloadReader(TrackOutput output) { this.output = output; } /** * Notifies the reader that a seek has occurred. - *

- * Following a call to this method, the data passed to the next invocation of - * {@link #consume(ParsableByteArray, long)} will not be a continuation of the data that - * was previously passed. Hence the reader should reset any internal state. + * + *

Following a call to this method, the data passed to the next invocation of {@link + * #consume(ParsableByteArray, long)} will not be a continuation of the data that was previously + * passed. Hence the reader should reset any internal state. */ public abstract void seek(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java index 6ab4da1acf..03ff74c39d 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java @@ -24,9 +24,7 @@ import com.google.android.exoplayer2.util.NalUnitUtil; import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.video.AvcConfig; -/** - * Parses video tags from an FLV stream and extracts H.264 nal units. - */ +/** Parses video tags from an FLV stream and extracts H.264 nal units. */ /* package */ final class VideoTagPayloadReader extends TagPayloadReader { // Video codec. @@ -50,9 +48,7 @@ import com.google.android.exoplayer2.video.AvcConfig; private boolean hasOutputKeyframe; private int frameType; - /** - * @param output A {@link TrackOutput} to which samples should be written. - */ + /** @param output A {@link TrackOutput} to which samples should be written. */ public VideoTagPayloadReader(TrackOutput output) { super(output); nalStartCode = new ParsableByteArray(NalUnitUtil.NAL_START_CODE); @@ -143,5 +139,4 @@ import com.google.android.exoplayer2.video.AvcConfig; return false; } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReader.java index 754cd7a4c2..0e56a0d197 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReader.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.extractor.mkv; - import androidx.annotation.IntDef; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ParserException; @@ -30,9 +29,7 @@ import java.util.ArrayDeque; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull; -/** - * Default implementation of {@link EbmlReader}. - */ +/** Default implementation of {@link EbmlReader}. */ /* package */ final class DefaultEbmlReader implements EbmlReader { @Documented @@ -250,7 +247,5 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; this.elementId = elementId; this.elementEndPosition = elementEndPosition; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlProcessor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlProcessor.java index 7291ae9c83..458b2e87e3 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlProcessor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlProcessor.java @@ -79,12 +79,12 @@ public interface EbmlProcessor { /** * Called when the start of a master element is encountered. - *

- * Following events should be considered as taking place within this element until a matching call - * to {@link #endMasterElement(int)} is made. - *

- * Note that it is possible for another master element of the same element ID to be nested within - * itself. + * + *

Following events should be considered as taking place within this element until a matching + * call to {@link #endMasterElement(int)} is made. + * + *

Note that it is possible for another master element of the same element ID to be nested + * within itself. * * @param id The element ID. * @param contentPosition The position of the start of the element's content in the stream. diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java index fc32fba4f7..c19906a93a 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/EbmlReader.java @@ -37,8 +37,8 @@ import java.io.IOException; /** * Resets the state of the reader. - *

- * Subsequent calls to {@link #read(ExtractorInput)} will start reading a new EBML structure + * + *

Subsequent calls to {@link #read(ExtractorInput)} will start reading a new EBML structure * from scratch. */ void reset(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java index c3f3e5e901..54e27088ca 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java @@ -91,8 +91,8 @@ public class MatroskaExtractor implements Extractor { public @interface Flags {} /** * Flag to disable seeking for cues. - *

- * Normally (i.e. when this flag is not set) the extractor will seek to the cues element if its + * + *

Normally (i.e. when this flag is not set) the extractor will seek to the cues element if its * position is specified in the seek head and if it's after the first cluster. Setting this flag * disables seeking to the cues element. If the cues element is after the first cluster then the * media is treated as being unseekable. @@ -282,25 +282,21 @@ public class MatroskaExtractor implements Extractor { 49, 10, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 48, 48, 32, 45, 45, 62, 32, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 48, 48, 10 }; - /** - * The byte offset of the end timecode in {@link #SUBRIP_PREFIX}. - */ + /** The byte offset of the end timecode in {@link #SUBRIP_PREFIX}. */ private static final int SUBRIP_PREFIX_END_TIMECODE_OFFSET = 19; /** * The value by which to divide a time in microseconds to convert it to the unit of the last value * in a subrip timecode (milliseconds). */ private static final long SUBRIP_TIMECODE_LAST_VALUE_SCALING_FACTOR = 1000; - /** - * The format of a subrip timecode. - */ + /** The format of a subrip timecode. */ private static final String SUBRIP_TIMECODE_FORMAT = "%02d:%02d:%02d,%03d"; - /** - * Matroska specific format line for SSA subtitles. - */ - private static final byte[] SSA_DIALOGUE_FORMAT = Util.getUtf8Bytes("Format: Start, End, " - + "ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"); + /** Matroska specific format line for SSA subtitles. */ + private static final byte[] SSA_DIALOGUE_FORMAT = + Util.getUtf8Bytes( + "Format: Start, End, " + + "ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text"); /** * A template for the prefix that must be added to each SSA sample. * @@ -317,35 +313,23 @@ public class MatroskaExtractor implements Extractor { 68, 105, 97, 108, 111, 103, 117, 101, 58, 32, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 44, 48, 58, 48, 48, 58, 48, 48, 58, 48, 48, 44 }; - /** - * The byte offset of the end timecode in {@link #SSA_PREFIX}. - */ + /** The byte offset of the end timecode in {@link #SSA_PREFIX}. */ private static final int SSA_PREFIX_END_TIMECODE_OFFSET = 21; /** * The value by which to divide a time in microseconds to convert it to the unit of the last value * in an SSA timecode (1/100ths of a second). */ private static final long SSA_TIMECODE_LAST_VALUE_SCALING_FACTOR = 10_000; - /** - * The format of an SSA timecode. - */ + /** The format of an SSA timecode. */ private static final String SSA_TIMECODE_FORMAT = "%01d:%02d:%02d:%02d"; - /** - * The length in bytes of a WAVEFORMATEX structure. - */ + /** The length in bytes of a WAVEFORMATEX structure. */ private static final int WAVE_FORMAT_SIZE = 18; - /** - * Format tag indicating a WAVEFORMATEXTENSIBLE structure. - */ + /** Format tag indicating a WAVEFORMATEXTENSIBLE structure. */ private static final int WAVE_FORMAT_EXTENSIBLE = 0xFFFE; - /** - * Format tag for PCM. - */ + /** Format tag for PCM. */ private static final int WAVE_FORMAT_PCM = 1; - /** - * Sub format for PCM. - */ + /** Sub format for PCM. */ private static final UUID WAVE_SUBFORMAT_PCM = new UUID(0x0100000000001000L, 0x800000AA00389B71L); /** Some HTC devices signal rotation in track names. */ @@ -760,8 +744,10 @@ public class MatroskaExtractor implements Extractor { if (currentTrack.cryptoData == null) { throw new ParserException("Encrypted Track found but ContentEncKeyID was not found"); } - currentTrack.drmInitData = new DrmInitData(new SchemeData(C.UUID_NIL, - MimeTypes.VIDEO_WEBM, currentTrack.cryptoData.encryptionKey)); + currentTrack.drmInitData = + new DrmInitData( + new SchemeData( + C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.cryptoData.encryptionKey)); } break; case ID_CONTENT_ENCODINGS: @@ -949,10 +935,10 @@ public class MatroskaExtractor implements Extractor { case 1: currentTrack.colorSpace = C.COLOR_SPACE_BT709; break; - case 4: // BT.470M. - case 5: // BT.470BG. - case 6: // SMPTE 170M. - case 7: // SMPTE 240M. + case 4: // BT.470M. + case 5: // BT.470BG. + case 6: // SMPTE 170M. + case 7: // SMPTE 240M. currentTrack.colorSpace = C.COLOR_SPACE_BT601; break; case 9: @@ -965,9 +951,9 @@ public class MatroskaExtractor implements Extractor { case ID_COLOUR_TRANSFER: assertInTrackEntry(id); switch ((int) value) { - case 1: // BT.709. - case 6: // SMPTE 170M. - case 7: // SMPTE 240M. + case 1: // BT.709. + case 6: // SMPTE 170M. + case 7: // SMPTE 240M. currentTrack.colorTransfer = C.COLOR_TRANSFER_SDR; break; case 16: @@ -982,8 +968,8 @@ public class MatroskaExtractor implements Extractor { break; case ID_COLOUR_RANGE: assertInTrackEntry(id); - switch((int) value) { - case 1: // Broadcast range. + switch ((int) value) { + case 1: // Broadcast range. currentTrack.colorRange = C.COLOR_RANGE_LIMITED; break; case 2: @@ -1591,8 +1577,10 @@ public class MatroskaExtractor implements Extractor { // number of samples in the current page. This definition holds good only for Ogg and // irrelevant for Matroska. So we always set this to -1 (the decoder will ignore this value if // we set it to -1). The android platform media extractor [2] does the same. - // [1] https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp#314 - // [2] https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright/NuMediaExtractor.cpp#474 + // [1] + // https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp#314 + // [2] + // https://android.googlesource.com/platform/frameworks/av/+/lollipop-release/media/libstagefright/NuMediaExtractor.cpp#474 vorbisNumPageSamples.setPosition(0); output.sampleData(vorbisNumPageSamples, 4); sampleBytesWritten += 4; @@ -1735,9 +1723,12 @@ public class MatroskaExtractor implements Extractor { */ private SeekMap buildSeekMap( @Nullable LongArray cueTimesUs, @Nullable LongArray cueClusterPositions) { - if (segmentContentPosition == C.POSITION_UNSET || durationUs == C.TIME_UNSET - || cueTimesUs == null || cueTimesUs.size() == 0 - || cueClusterPositions == null || cueClusterPositions.size() != cueTimesUs.size()) { + if (segmentContentPosition == C.POSITION_UNSET + || durationUs == C.TIME_UNSET + || cueTimesUs == null + || cueTimesUs.size() == 0 + || cueClusterPositions == null + || cueClusterPositions.size() != cueTimesUs.size()) { // Cues information is missing or incomplete. return new SeekMap.Unseekable(durationUs); } @@ -1977,15 +1968,11 @@ public class MatroskaExtractor implements Extractor { private static final int DISPLAY_UNIT_PIXELS = 0; private static final int MAX_CHROMATICITY = 50_000; // Defined in CTA-861.3. - /** - * Default max content light level (CLL) that should be encoded into hdrStaticInfo. - */ - private static final int DEFAULT_MAX_CLL = 1000; // nits. + /** Default max content light level (CLL) that should be encoded into hdrStaticInfo. */ + private static final int DEFAULT_MAX_CLL = 1000; // nits. - /** - * Default frame-average light level (FALL) that should be encoded into hdrStaticInfo. - */ - private static final int DEFAULT_MAX_FALL = 200; // nits. + /** Default frame-average light level (FALL) that should be encoded into hdrStaticInfo. */ + private static final int DEFAULT_MAX_FALL = 200; // nits. // Common elements. public @MonotonicNonNull String name; @@ -2012,15 +1999,11 @@ public class MatroskaExtractor implements Extractor { public float projectionPosePitch = 0f; public float projectionPoseRoll = 0f; public byte @MonotonicNonNull [] projectionData = null; - @C.StereoMode - public int stereoMode = Format.NO_VALUE; + @C.StereoMode public int stereoMode = Format.NO_VALUE; public boolean hasColorInfo = false; - @C.ColorSpace - public int colorSpace = Format.NO_VALUE; - @C.ColorTransfer - public int colorTransfer = Format.NO_VALUE; - @C.ColorRange - public int colorRange = Format.NO_VALUE; + @C.ColorSpace public int colorSpace = Format.NO_VALUE; + @C.ColorTransfer public int colorTransfer = Format.NO_VALUE; + @C.ColorRange public int colorRange = Format.NO_VALUE; public int maxContentLuminance = DEFAULT_MAX_CLL; public int maxFrameAverageLuminance = DEFAULT_MAX_FALL; public float primaryRChromaticityX = Format.NO_VALUE; @@ -2167,8 +2150,12 @@ public class MatroskaExtractor implements Extractor { if (pcmEncoding == C.ENCODING_INVALID) { pcmEncoding = Format.NO_VALUE; mimeType = MimeTypes.AUDIO_UNKNOWN; - Log.w(TAG, "Unsupported PCM bit depth: " + audioBitDepth + ". Setting mimeType to " - + mimeType); + Log.w( + TAG, + "Unsupported PCM bit depth: " + + audioBitDepth + + ". Setting mimeType to " + + mimeType); } } else { mimeType = MimeTypes.AUDIO_UNKNOWN; @@ -2362,21 +2349,25 @@ public class MatroskaExtractor implements Extractor { @Nullable private byte[] getHdrStaticInfo() { // Are all fields present. - if (primaryRChromaticityX == Format.NO_VALUE || primaryRChromaticityY == Format.NO_VALUE - || primaryGChromaticityX == Format.NO_VALUE || primaryGChromaticityY == Format.NO_VALUE - || primaryBChromaticityX == Format.NO_VALUE || primaryBChromaticityY == Format.NO_VALUE + if (primaryRChromaticityX == Format.NO_VALUE + || primaryRChromaticityY == Format.NO_VALUE + || primaryGChromaticityX == Format.NO_VALUE + || primaryGChromaticityY == Format.NO_VALUE + || primaryBChromaticityX == Format.NO_VALUE + || primaryBChromaticityY == Format.NO_VALUE || whitePointChromaticityX == Format.NO_VALUE - || whitePointChromaticityY == Format.NO_VALUE || maxMasteringLuminance == Format.NO_VALUE + || whitePointChromaticityY == Format.NO_VALUE + || maxMasteringLuminance == Format.NO_VALUE || minMasteringLuminance == Format.NO_VALUE) { return null; } byte[] hdrStaticInfoData = new byte[25]; ByteBuffer hdrStaticInfo = ByteBuffer.wrap(hdrStaticInfoData).order(ByteOrder.LITTLE_ENDIAN); - hdrStaticInfo.put((byte) 0); // Type. + hdrStaticInfo.put((byte) 0); // Type. hdrStaticInfo.putShort((short) ((primaryRChromaticityX * MAX_CHROMATICITY) + 0.5f)); hdrStaticInfo.putShort((short) ((primaryRChromaticityY * MAX_CHROMATICITY) + 0.5f)); - hdrStaticInfo.putShort((short) ((primaryGChromaticityX * MAX_CHROMATICITY) + 0.5f)); + hdrStaticInfo.putShort((short) ((primaryGChromaticityX * MAX_CHROMATICITY) + 0.5f)); hdrStaticInfo.putShort((short) ((primaryGChromaticityY * MAX_CHROMATICITY) + 0.5f)); hdrStaticInfo.putShort((short) ((primaryBChromaticityX * MAX_CHROMATICITY) + 0.5f)); hdrStaticInfo.putShort((short) ((primaryBChromaticityY * MAX_CHROMATICITY) + 0.5f)); @@ -2525,5 +2516,4 @@ public class MatroskaExtractor implements Extractor { return codecPrivate; } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java index 415d3d4546..f1dcaf4ec7 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/Sniffer.java @@ -26,10 +26,9 @@ import java.io.IOException; */ /* package */ final class Sniffer { - /** - * The number of bytes to search for a valid header in {@link #sniff(ExtractorInput)}. - */ + /** The number of bytes to search for a valid header in {@link #sniff(ExtractorInput)}. */ private static final int SEARCH_LENGTH = 1024; + private static final int ID_EBML = 0x1A45DFA3; private final ParsableByteArray scratch; @@ -42,8 +41,11 @@ import java.io.IOException; /** @see com.google.android.exoplayer2.extractor.Extractor#sniff(ExtractorInput) */ public boolean sniff(ExtractorInput input) throws IOException { long inputLength = input.getLength(); - int bytesToSearch = (int) (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH - ? SEARCH_LENGTH : inputLength); + int bytesToSearch = + (int) + (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH + ? SEARCH_LENGTH + : inputLength); // Find four bytes equal to ID_EBML near the start of the input. input.peekFully(scratch.getData(), 0, 4); long tag = scratch.readUnsignedInt(); @@ -106,5 +108,4 @@ import java.io.IOException; peekLength += length + 1; return value; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java index 6b244de72d..a6ee6d9cc1 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/VarintReader.java @@ -20,9 +20,7 @@ import com.google.android.exoplayer2.extractor.ExtractorInput; import java.io.EOFException; import java.io.IOException; -/** - * Reads EBML variable-length integers (varints) from an {@link ExtractorInput}. - */ +/** Reads EBML variable-length integers (varints) from an {@link ExtractorInput}. */ /* package */ final class VarintReader { private static final int STATE_BEGIN_READING = 0; @@ -34,9 +32,8 @@ import java.io.IOException; * *

{@code 0x80} is a one-byte integer, {@code 0x40} is two bytes, and so on up to eight bytes. */ - private static final long[] VARINT_LENGTH_MASKS = new long[] { - 0x80L, 0x40L, 0x20L, 0x10L, 0x08L, 0x04L, 0x02L, 0x01L - }; + private static final long[] VARINT_LENGTH_MASKS = + new long[] {0x80L, 0x40L, 0x20L, 0x10L, 0x08L, 0x04L, 0x02L, 0x01L}; private final byte[] scratch; @@ -47,9 +44,7 @@ import java.io.IOException; scratch = new byte[8]; } - /** - * Resets the reader to start reading a new variable-length integer. - */ + /** Resets the reader to start reading a new variable-length integer. */ public void reset() { state = STATE_BEGIN_READING; length = 0; @@ -110,9 +105,7 @@ import java.io.IOException; return assembleVarint(scratch, length, removeLengthMask); } - /** - * Returns the number of bytes occupied by the most recently parsed varint. - */ + /** Returns the number of bytes occupied by the most recently parsed varint. */ public int getLastLength() { return length; } @@ -121,8 +114,8 @@ import java.io.IOException; * Parses and the length of the varint given the first byte. * * @param firstByte First byte of the varint. - * @return Length of the varint beginning with the given byte if it was valid, - * {@link C#LENGTH_UNSET} otherwise. + * @return Length of the varint beginning with the given byte if it was valid, {@link + * C#LENGTH_UNSET} otherwise. */ public static int parseUnsignedVarintLength(int firstByte) { int varIntLength = C.LENGTH_UNSET; @@ -143,8 +136,8 @@ import java.io.IOException; * @param removeLengthMask Removes the variable-length integer length mask from the value. * @return Parsed and assembled varint. */ - public static long assembleVarint(byte[] varintBytes, int varintLength, - boolean removeLengthMask) { + public static long assembleVarint( + byte[] varintBytes, int varintLength, boolean removeLengthMask) { long varint = varintBytes[0] & 0xFFL; if (removeLengthMask) { varint &= ~VARINT_LENGTH_MASKS[varintLength - 1]; @@ -154,5 +147,4 @@ import java.io.IOException; } return varint; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java index 21b7c8544f..7879d97bcb 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java @@ -101,22 +101,16 @@ public final class Mp3Extractor implements Extractor { ((id0 == 'C' && id1 == 'O' && id2 == 'M' && (id3 == 'M' || majorVersion == 2)) || (id0 == 'M' && id1 == 'L' && id2 == 'L' && (id3 == 'T' || majorVersion == 2))); - /** - * The maximum number of bytes to search when synchronizing, before giving up. - */ + /** The maximum number of bytes to search when synchronizing, before giving up. */ private static final int MAX_SYNC_BYTES = 128 * 1024; /** * The maximum number of bytes to peek when sniffing, excluding the ID3 header, before giving up. */ private static final int MAX_SNIFF_BYTES = 32 * 1024; - /** - * Maximum length of data read into {@link #scratch}. - */ + /** Maximum length of data read into {@link #scratch}. */ private static final int SCRATCH_LENGTH = 10; - /** - * Mask that includes the audio header values that must match between frames. - */ + /** Mask that includes the audio header values that must match between frames. */ private static final int MPEG_AUDIO_HEADER_MASK = 0xFFFE0C00; private static final int SEEK_HEADER_XING = 0x58696e67; @@ -153,17 +147,15 @@ public final class Mp3Extractor implements Extractor { this(0); } - /** - * @param flags Flags that control the extractor's behavior. - */ + /** @param flags Flags that control the extractor's behavior. */ public Mp3Extractor(@Flags int flags) { this(flags, C.TIME_UNSET); } /** * @param flags Flags that control the extractor's behavior. - * @param forcedFirstSampleTimestampUs A timestamp to force for the first sample, or - * {@link C#TIME_UNSET} if forcing is not required. + * @param forcedFirstSampleTimestampUs A timestamp to force for the first sample, or {@link + * C#TIME_UNSET} if forcing is not required. */ public Mp3Extractor(@Flags int flags, long forcedFirstSampleTimestampUs) { this.flags = flags; @@ -473,9 +465,10 @@ public final class Mp3Extractor implements Extractor { private Seeker maybeReadSeekFrame(ExtractorInput input) throws IOException { ParsableByteArray frame = new ParsableByteArray(synchronizedHeader.frameSize); input.peekFully(frame.getData(), 0, synchronizedHeader.frameSize); - int xingBase = (synchronizedHeader.version & 1) != 0 - ? (synchronizedHeader.channels != 1 ? 36 : 21) // MPEG 1 - : (synchronizedHeader.channels != 1 ? 21 : 13); // MPEG 2 or 2.5 + int xingBase = + (synchronizedHeader.version & 1) != 0 + ? (synchronizedHeader.channels != 1 ? 36 : 21) // MPEG 1 + : (synchronizedHeader.channels != 1 ? 21 : 13); // MPEG 2 or 2.5 int seekHeader = getSeekFrameHeader(frame, xingBase); @Nullable Seeker seeker; if (seekHeader == SEEK_HEADER_XING || seekHeader == SEEK_HEADER_INFO) { @@ -518,9 +511,7 @@ public final class Mp3Extractor implements Extractor { Util.castNonNull(extractorOutput); } - /** - * Returns whether the headers match in those bits masked by {@link #MPEG_AUDIO_HEADER_MASK}. - */ + /** Returns whether the headers match in those bits masked by {@link #MPEG_AUDIO_HEADER_MASK}. */ private static boolean headersMatch(int headerA, long headerB) { return (headerA & MPEG_AUDIO_HEADER_MASK) == (headerB & MPEG_AUDIO_HEADER_MASK); } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java index daf5265ddd..f2532863c4 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/VbriSeeker.java @@ -55,8 +55,9 @@ import com.google.android.exoplayer2.util.Util; return null; } int sampleRate = mpegAudioHeader.sampleRate; - long durationUs = Util.scaleLargeTimestamp(numFrames, - C.MICROS_PER_SECOND * (sampleRate >= 32000 ? 1152 : 576), sampleRate); + long durationUs = + Util.scaleLargeTimestamp( + numFrames, C.MICROS_PER_SECOND * (sampleRate >= 32000 ? 1152 : 576), sampleRate); int entryCount = frame.readUnsignedShort(); int scale = frame.readUnsignedShort(); int entrySize = frame.readUnsignedShort(); diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java index d95721be5d..51950e6282 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/XingSeeker.java @@ -57,8 +57,8 @@ import com.google.android.exoplayer2.util.Util; // If the frame count is missing/invalid, the header can't be used to determine the duration. return null; } - long durationUs = Util.scaleLargeTimestamp(frameCount, samplesPerFrame * C.MICROS_PER_SECOND, - sampleRate); + long durationUs = + Util.scaleLargeTimestamp(frameCount, samplesPerFrame * C.MICROS_PER_SECOND, sampleRate); if ((flags & 0x06) != 0x06) { // If the size in bytes or table of contents is missing, the stream is not seekable. return new XingSeeker(position, mpegAudioHeader.frameSize, durationUs); @@ -141,8 +141,8 @@ import com.google.android.exoplayer2.util.Util; double nextScaledPosition = prevTableIndex == 99 ? 256 : tableOfContents[prevTableIndex + 1]; // Linearly interpolate between the two scaled positions. double interpolateFraction = percent - prevTableIndex; - scaledPosition = prevScaledPosition - + (interpolateFraction * (nextScaledPosition - prevScaledPosition)); + scaledPosition = + prevScaledPosition + (interpolateFraction * (nextScaledPosition - prevScaledPosition)); } long positionOffset = Math.round((scaledPosition / 256) * dataSize); // Ensure returned positions skip the frame containing the XING header. @@ -164,8 +164,10 @@ import com.google.android.exoplayer2.util.Util; long nextTimeUs = getTimeUsForTableIndex(prevTableIndex + 1); long nextScaledPosition = prevTableIndex == 99 ? 256 : tableOfContents[prevTableIndex + 1]; // Linearly interpolate between the two table entries. - double interpolateFraction = prevScaledPosition == nextScaledPosition ? 0 - : ((scaledPosition - prevScaledPosition) / (nextScaledPosition - prevScaledPosition)); + double interpolateFraction = + prevScaledPosition == nextScaledPosition + ? 0 + : ((scaledPosition - prevScaledPosition) / (nextScaledPosition - prevScaledPosition)); return prevTimeUs + Math.round(interpolateFraction * (nextTimeUs - prevTimeUs)); } @@ -188,5 +190,4 @@ import com.google.android.exoplayer2.util.Util; private long getTimeUsForTableIndex(int tableIndex) { return (durationUs * tableIndex) / 100; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Atom.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Atom.java index 95cd1e2c17..b75dfcc46d 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Atom.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Atom.java @@ -24,29 +24,19 @@ import java.util.List; @SuppressWarnings("ConstantField") /* package */ abstract class Atom { - /** - * Size of an atom header, in bytes. - */ + /** Size of an atom header, in bytes. */ public static final int HEADER_SIZE = 8; - /** - * Size of a full atom header, in bytes. - */ + /** Size of a full atom header, in bytes. */ public static final int FULL_HEADER_SIZE = 12; - /** - * Size of a long atom header, in bytes. - */ + /** Size of a long atom header, in bytes. */ public static final int LONG_HEADER_SIZE = 16; - /** - * Value for the size field in an atom that defines its size in the largesize field. - */ + /** Value for the size field in an atom that defines its size in the largesize field. */ public static final int DEFINES_LARGE_SIZE = 1; - /** - * Value for the size field in an atom that extends to the end of the file. - */ + /** Value for the size field in an atom that extends to the end of the file. */ public static final int EXTENDS_TO_END_SIZE = 0; @SuppressWarnings("ConstantCaseForConstants") @@ -408,14 +398,10 @@ import java.util.List; return getAtomTypeString(type); } - /** - * An MP4 atom that is a leaf. - */ + /** An MP4 atom that is a leaf. */ /* package */ static final class LeafAtom extends Atom { - /** - * The atom data. - */ + /** The atom data. */ public final ParsableByteArray data; /** @@ -426,12 +412,9 @@ import java.util.List; super(type); this.data = data; } - } - /** - * An MP4 atom that has child atoms. - */ + /** An MP4 atom that has child atoms. */ /* package */ static final class ContainerAtom extends Atom { public final long endPosition; @@ -537,22 +520,19 @@ import java.util.List; @Override public String toString() { return getAtomTypeString(type) - + " leaves: " + Arrays.toString(leafChildren.toArray()) - + " containers: " + Arrays.toString(containerChildren.toArray()); + + " leaves: " + + Arrays.toString(leafChildren.toArray()) + + " containers: " + + Arrays.toString(containerChildren.toArray()); } - } - /** - * Parses the version number out of the additional integer component of a full atom. - */ + /** Parses the version number out of the additional integer component of a full atom. */ public static int parseFullAtomVersion(int fullAtomInt) { return 0x000000FF & (fullAtomInt >> 24); } - /** - * Parses the atom flags out of the additional integer component of a full atom. - */ + /** Parses the atom flags out of the additional integer component of a full atom. */ public static int parseFullAtomFlags(int fullAtomInt) { return 0x00FFFFFF & fullAtomInt; } @@ -564,10 +544,10 @@ import java.util.List; * @return The corresponding four character string. */ public static String getAtomTypeString(int type) { - return "" + (char) ((type >> 24) & 0xFF) + return "" + + (char) ((type >> 24) & 0xFF) + (char) ((type >> 16) & 0xFF) + (char) ((type >> 8) & 0xFF) + (char) (type & 0xFF); } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java index dc098994df..20b2de1849 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java @@ -316,10 +316,20 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } } } - return stsdData.format == null ? null - : new Track(tkhdData.id, trackType, mdhdData.first, movieTimescale, durationUs, - stsdData.format, stsdData.requiredSampleTransformation, stsdData.trackEncryptionBoxes, - stsdData.nalUnitLengthFieldLength, editListDurations, editListMediaTimes); + return stsdData.format == null + ? null + : new Track( + tkhdData.id, + trackType, + mdhdData.first, + movieTimescale, + durationUs, + stsdData.format, + stsdData.requiredSampleTransformation, + stsdData.trackEncryptionBoxes, + stsdData.nalUnitLengthFieldLength, + editListDurations, + editListMediaTimes); } /** @@ -576,15 +586,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; && track.type == C.TRACK_TYPE_AUDIO && timestamps.length >= 2) { long editStartTime = checkNotNull(track.editListMediaTimes)[0]; - long editEndTime = editStartTime + Util.scaleLargeTimestamp(track.editListDurations[0], - track.timescale, track.movieTimescale); + long editEndTime = + editStartTime + + Util.scaleLargeTimestamp( + track.editListDurations[0], track.timescale, track.movieTimescale); if (canApplyEditWithGaplessInfo(timestamps, duration, editStartTime, editEndTime)) { long paddingTimeUnits = duration - editEndTime; - long encoderDelay = Util.scaleLargeTimestamp(editStartTime - timestamps[0], - track.format.sampleRate, track.timescale); - long encoderPadding = Util.scaleLargeTimestamp(paddingTimeUnits, - track.format.sampleRate, track.timescale); - if ((encoderDelay != 0 || encoderPadding != 0) && encoderDelay <= Integer.MAX_VALUE + long encoderDelay = + Util.scaleLargeTimestamp( + editStartTime - timestamps[0], track.format.sampleRate, track.timescale); + long encoderPadding = + Util.scaleLargeTimestamp(paddingTimeUnits, track.format.sampleRate, track.timescale); + if ((encoderDelay != 0 || encoderPadding != 0) + && encoderDelay <= Integer.MAX_VALUE && encoderPadding <= Integer.MAX_VALUE) { gaplessInfoHolder.encoderDelay = (int) encoderDelay; gaplessInfoHolder.encoderPadding = (int) encoderPadding; @@ -922,8 +936,16 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; || childAtomType == Atom.TYPE_dva1 || childAtomType == Atom.TYPE_dvhe || childAtomType == Atom.TYPE_dvh1) { - parseVideoSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, - rotationDegrees, drmInitData, out, i); + parseVideoSampleEntry( + stsd, + childAtomType, + childStartPosition, + childAtomSize, + trackId, + rotationDegrees, + drmInitData, + out, + i); } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca || childAtomType == Atom.TYPE_ac_3 @@ -945,13 +967,24 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; || childAtomType == Atom.TYPE_ulaw || childAtomType == Atom.TYPE_Opus || childAtomType == Atom.TYPE_fLaC) { - parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, - language, isQuickTime, drmInitData, out, i); - } else if (childAtomType == Atom.TYPE_TTML || childAtomType == Atom.TYPE_tx3g - || childAtomType == Atom.TYPE_wvtt || childAtomType == Atom.TYPE_stpp + parseAudioSampleEntry( + stsd, + childAtomType, + childStartPosition, + childAtomSize, + trackId, + language, + isQuickTime, + drmInitData, + out, + i); + } else if (childAtomType == Atom.TYPE_TTML + || childAtomType == Atom.TYPE_tx3g + || childAtomType == Atom.TYPE_wvtt + || childAtomType == Atom.TYPE_stpp || childAtomType == Atom.TYPE_c608) { - parseTextSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId, - language, out); + parseTextSampleEntry( + stsd, childAtomType, childStartPosition, childAtomSize, trackId, language, out); } else if (childAtomType == Atom.TYPE_mett) { parseMetaDataSampleEntry(stsd, childAtomType, childStartPosition, trackId, out); } else if (childAtomType == Atom.TYPE_camm) { @@ -1040,8 +1073,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; parseSampleEntryEncryptionData(parent, position, size); if (sampleEntryEncryptionData != null) { atomType = sampleEntryEncryptionData.first; - drmInitData = drmInitData == null ? null - : drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType); + drmInitData = + drmInitData == null + ? null + : drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType); out.trackEncryptionBoxes[entryIndex] = sampleEntryEncryptionData.second; } parent.setPosition(childPosition); @@ -1059,8 +1094,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; @Nullable List initializationData = null; @Nullable String codecs = null; @Nullable byte[] projectionData = null; - @C.StereoMode - int stereoMode = Format.NO_VALUE; + @C.StereoMode int stereoMode = Format.NO_VALUE; while (childPosition - position < size) { parent.setPosition(childPosition); int childStartPosition = parent.getPosition(); @@ -1248,14 +1282,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; if (quickTimeSoundDescriptionVersion == 0 || quickTimeSoundDescriptionVersion == 1) { channelCount = parent.readUnsignedShort(); - parent.skipBytes(6); // sampleSize, compressionId, packetSize. + parent.skipBytes(6); // sampleSize, compressionId, packetSize. sampleRate = parent.readUnsignedFixedPoint1616(); if (quickTimeSoundDescriptionVersion == 1) { parent.skipBytes(16); } } else if (quickTimeSoundDescriptionVersion == 2) { - parent.skipBytes(16); // always[3,16,Minus2,0,65536], sizeOfStructOnly + parent.skipBytes(16); // always[3,16,Minus2,0,65536], sizeOfStructOnly sampleRate = (int) Math.round(parent.readDouble()); channelCount = parent.readUnsignedIntToInt(); @@ -1275,8 +1309,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; parseSampleEntryEncryptionData(parent, position, size); if (sampleEntryEncryptionData != null) { atomType = sampleEntryEncryptionData.first; - drmInitData = drmInitData == null ? null - : drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType); + drmInitData = + drmInitData == null + ? null + : drmInitData.copyWithSchemeType(sampleEntryEncryptionData.second.schemeType); out.trackEncryptionBoxes[entryIndex] = sampleEntryEncryptionData.second; } parent.setPosition(childPosition); @@ -1331,8 +1367,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; Assertions.checkState(childAtomSize > 0, "childAtomSize should be positive"); int childAtomType = parent.readInt(); if (childAtomType == Atom.TYPE_esds || (isQuickTime && childAtomType == Atom.TYPE_wave)) { - int esdsAtomPosition = childAtomType == Atom.TYPE_esds ? childPosition - : findEsdsPosition(parent, childPosition, childAtomSize); + int esdsAtomPosition = + childAtomType == Atom.TYPE_esds + ? childPosition + : findEsdsPosition(parent, childPosition, childAtomSize); if (esdsAtomPosition != C.POSITION_UNSET) { Pair<@NullableType String, byte @NullableType []> mimeTypeAndInitializationData = parseEsdsFromParent(parent, esdsAtomPosition); @@ -1352,12 +1390,12 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } } else if (childAtomType == Atom.TYPE_dac3) { parent.setPosition(Atom.HEADER_SIZE + childPosition); - out.format = Ac3Util.parseAc3AnnexFFormat(parent, Integer.toString(trackId), language, - drmInitData); + out.format = + Ac3Util.parseAc3AnnexFFormat(parent, Integer.toString(trackId), language, drmInitData); } else if (childAtomType == Atom.TYPE_dec3) { parent.setPosition(Atom.HEADER_SIZE + childPosition); - out.format = Ac3Util.parseEAc3AnnexFFormat(parent, Integer.toString(trackId), language, - drmInitData); + out.format = + Ac3Util.parseEAc3AnnexFFormat(parent, Integer.toString(trackId), language, drmInitData); } else if (childAtomType == Atom.TYPE_dac4) { parent.setPosition(Atom.HEADER_SIZE + childPosition); out.format = @@ -1536,8 +1574,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; childPosition += childAtomSize; } - if (C.CENC_TYPE_cenc.equals(schemeType) || C.CENC_TYPE_cbc1.equals(schemeType) - || C.CENC_TYPE_cens.equals(schemeType) || C.CENC_TYPE_cbcs.equals(schemeType)) { + if (C.CENC_TYPE_cenc.equals(schemeType) + || C.CENC_TYPE_cbc1.equals(schemeType) + || C.CENC_TYPE_cens.equals(schemeType) + || C.CENC_TYPE_cbcs.equals(schemeType)) { Assertions.checkStateNotNull(dataFormat, "frma atom is mandatory"); Assertions.checkState( schemeInformationBoxPosition != C.POSITION_UNSET, "schi atom is mandatory"); @@ -1583,8 +1623,14 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; constantIv = new byte[constantIvSize]; parent.readBytes(constantIv, 0, constantIvSize); } - return new TrackEncryptionBox(defaultIsProtected, schemeType, defaultPerSampleIvSize, - defaultKeyId, defaultCryptByteBlock, defaultSkipByteBlock, constantIv); + return new TrackEncryptionBox( + defaultIsProtected, + schemeType, + defaultPerSampleIvSize, + defaultKeyId, + defaultCryptByteBlock, + defaultSkipByteBlock, + constantIv); } childPosition += childAtomSize; } @@ -1650,8 +1696,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; private int nextSamplesPerChunkChangeIndex; private int remainingSamplesPerChunkChanges; - public ChunkIterator(ParsableByteArray stsc, ParsableByteArray chunkOffsets, - boolean chunkOffsetsAreLongs) { + public ChunkIterator( + ParsableByteArray stsc, ParsableByteArray chunkOffsets, boolean chunkOffsetsAreLongs) { this.stsc = stsc; this.chunkOffsets = chunkOffsets; this.chunkOffsetsAreLongs = chunkOffsetsAreLongs; @@ -1667,22 +1713,23 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; if (++index == length) { return false; } - offset = chunkOffsetsAreLongs ? chunkOffsets.readUnsignedLongToLong() - : chunkOffsets.readUnsignedInt(); + offset = + chunkOffsetsAreLongs + ? chunkOffsets.readUnsignedLongToLong() + : chunkOffsets.readUnsignedInt(); if (index == nextSamplesPerChunkChangeIndex) { numSamples = stsc.readUnsignedIntToInt(); stsc.skipBytes(4); // Skip sample_description_index - nextSamplesPerChunkChangeIndex = --remainingSamplesPerChunkChanges > 0 - ? (stsc.readUnsignedIntToInt() - 1) : C.INDEX_UNSET; + nextSamplesPerChunkChangeIndex = + --remainingSamplesPerChunkChanges > 0 + ? (stsc.readUnsignedIntToInt() - 1) + : C.INDEX_UNSET; } return true; } - } - /** - * Holds data parsed from a tkhd atom. - */ + /** Holds data parsed from a tkhd atom. */ private static final class TkhdData { private final int id; @@ -1694,12 +1741,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; this.duration = duration; this.rotationDegrees = rotationDegrees; } - } - /** - * Holds data parsed from an stsd atom and its children. - */ + /** Holds data parsed from an stsd atom and its children. */ private static final class StsdData { public static final int STSD_HEADER_SIZE = 8; @@ -1714,17 +1758,12 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; trackEncryptionBoxes = new TrackEncryptionBox[numberOfEntries]; requiredSampleTransformation = Track.TRANSFORMATION_NONE; } - } - /** - * A box containing sample sizes (e.g. stsz, stz2). - */ + /** A box containing sample sizes (e.g. stsz, stz2). */ private interface SampleSizeBox { - /** - * Returns the number of samples. - */ + /** Returns the number of samples. */ int getSampleCount(); /** Returns the size of each sample if fixed, or {@link C#LENGTH_UNSET} otherwise. */ @@ -1734,9 +1773,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; int readNextSampleSize(); } - /** - * An stsz sample size box. - */ + /** An stsz sample size box. */ /* package */ static final class StszSampleSizeBox implements SampleSizeBox { private final int fixedSampleSize; @@ -1782,9 +1819,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } } - /** - * An stz2 sample size box. - */ + /** An stz2 sample size box. */ /* package */ static final class Stz2SampleSizeBox implements SampleSizeBox { private final ParsableByteArray data; @@ -1832,5 +1867,4 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; } } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/DefaultSampleValues.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/DefaultSampleValues.java index 1ec0237356..f1f6f57774 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/DefaultSampleValues.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/DefaultSampleValues.java @@ -28,5 +28,4 @@ package com.google.android.exoplayer2.extractor.mp4; this.size = size; this.flags = flags; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FixedSampleSizeRechunker.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FixedSampleSizeRechunker.java index 5ebc0a3587..ae16c8107f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FixedSampleSizeRechunker.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FixedSampleSizeRechunker.java @@ -26,9 +26,7 @@ import com.google.android.exoplayer2.util.Util; */ /* package */ final class FixedSampleSizeRechunker { - /** - * The result of a rechunking operation. - */ + /** The result of a rechunking operation. */ public static final class Results { public final long[] offsets; @@ -52,12 +50,9 @@ import com.google.android.exoplayer2.util.Util; this.flags = flags; this.duration = duration; } - } - /** - * Maximum number of bytes for each buffer in rechunked output. - */ + /** Maximum number of bytes for each buffer in rechunked output. */ private static final int MAX_SAMPLE_SIZE = 8 * 1024; /** @@ -68,7 +63,10 @@ import com.google.android.exoplayer2.util.Util; * @param chunkSampleCounts Sample counts for each of the MP4 stream's chunks. * @param timestampDeltaInTimeUnits Timestamp delta between each sample in time units. */ - public static Results rechunk(int fixedSampleSize, long[] chunkOffsets, int[] chunkSampleCounts, + public static Results rechunk( + int fixedSampleSize, + long[] chunkOffsets, + int[] chunkSampleCounts, long timestampDeltaInTimeUnits) { int maxSampleCount = MAX_SAMPLE_SIZE / fixedSampleSize; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java index e14381c564..e3e5f27090 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java @@ -91,8 +91,8 @@ public class FragmentedMp4Extractor implements Extractor { * Flag to work around an issue in some video streams where every frame is marked as a sync frame. * The workaround overrides the sync frame flags in the stream, forcing them to false except for * the first sample in each segment. - *

- * This flag does nothing if the stream is not a video stream. + * + *

This flag does nothing if the stream is not a video stream. */ public static final int FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME = 1; /** Flag to ignore any tfdt boxes in the stream. */ @@ -110,6 +110,7 @@ public class FragmentedMp4Extractor implements Extractor { @SuppressWarnings("ConstantCaseForConstants") private static final int SAMPLE_GROUP_TYPE_seig = 0x73656967; + private static final byte[] PIFF_SAMPLE_ENCRYPTION_BOX_EXTENDED_TYPE = new byte[] {-94, 57, 79, 82, 90, -101, 79, 20, -94, 68, 108, 66, 124, 100, -115, -12}; @@ -182,9 +183,7 @@ public class FragmentedMp4Extractor implements Extractor { this(0); } - /** - * @param flags Flags that control the extractor's behavior. - */ + /** @param flags Flags that control the extractor's behavior. */ public FragmentedMp4Extractor(@Flags int flags) { this(flags, /* timestampAdjuster= */ null); } @@ -685,13 +684,16 @@ public class FragmentedMp4Extractor implements Extractor { int defaultSampleSize = trex.readInt(); int defaultSampleFlags = trex.readInt(); - return Pair.create(trackId, new DefaultSampleValues(defaultSampleDescriptionIndex, - defaultSampleDuration, defaultSampleSize, defaultSampleFlags)); + return Pair.create( + trackId, + new DefaultSampleValues( + defaultSampleDescriptionIndex, + defaultSampleDuration, + defaultSampleSize, + defaultSampleFlags)); } - /** - * Parses an mehd atom (defined in 14496-12). - */ + /** Parses an mehd atom (defined in 14496-12). */ private static long parseMehd(ParsableByteArray mehd) { mehd.setPosition(Atom.HEADER_SIZE); int fullAtom = mehd.readInt(); @@ -699,8 +701,12 @@ public class FragmentedMp4Extractor implements Extractor { return version == 0 ? mehd.readUnsignedInt() : mehd.readUnsignedLongToLong(); } - private static void parseMoof(ContainerAtom moof, SparseArray trackBundleArray, - @Flags int flags, byte[] extendedTypeScratch) throws ParserException { + private static void parseMoof( + ContainerAtom moof, + SparseArray trackBundleArray, + @Flags int flags, + byte[] extendedTypeScratch) + throws ParserException { int moofContainerChildrenSize = moof.containerChildren.size(); for (int i = 0; i < moofContainerChildrenSize; i++) { Atom.ContainerAtom child = moof.containerChildren.get(i); @@ -711,11 +717,13 @@ public class FragmentedMp4Extractor implements Extractor { } } - /** - * Parses a traf atom (defined in 14496-12). - */ - private static void parseTraf(ContainerAtom traf, SparseArray trackBundleArray, - @Flags int flags, byte[] extendedTypeScratch) throws ParserException { + /** Parses a traf atom (defined in 14496-12). */ + private static void parseTraf( + ContainerAtom traf, + SparseArray trackBundleArray, + @Flags int flags, + byte[] extendedTypeScratch) + throws ParserException { LeafAtom tfhd = checkNotNull(traf.getLeafAtomOfType(Atom.TYPE_tfhd)); @Nullable TrackBundle trackBundle = parseTfhd(tfhd.data, trackBundleArray); if (trackBundle == null) { @@ -803,8 +811,9 @@ public class FragmentedMp4Extractor implements Extractor { } } - private static void parseSaiz(TrackEncryptionBox encryptionBox, ParsableByteArray saiz, - TrackFragment out) throws ParserException { + private static void parseSaiz( + TrackEncryptionBox encryptionBox, ParsableByteArray saiz, TrackFragment out) + throws ParserException { int vectorSize = encryptionBox.perSampleIvSize; saiz.setPosition(Atom.HEADER_SIZE); int fullAtom = saiz.readInt(); @@ -911,8 +920,12 @@ public class FragmentedMp4Extractor implements Extractor { ((atomFlags & 0x20 /* default_sample_flags_present */) != 0) ? tfhd.readInt() : defaultSampleValues.flags; - trackBundle.fragment.header = new DefaultSampleValues(defaultSampleDescriptionIndex, - defaultSampleDuration, defaultSampleSize, defaultSampleFlags); + trackBundle.fragment.header = + new DefaultSampleValues( + defaultSampleDescriptionIndex, + defaultSampleDuration, + defaultSampleSize, + defaultSampleFlags); return trackBundle; } @@ -989,7 +1002,8 @@ public class FragmentedMp4Extractor implements Extractor { // Currently we only support a single edit that moves the entire media timeline (indicated by // duration == 0). Other uses of edit lists are uncommon and unsupported. - if (track.editListDurations != null && track.editListDurations.length == 1 + if (track.editListDurations != null + && track.editListDurations.length == 1 && track.editListDurations[0] == 0) { edtsOffsetUs = Util.scaleLargeTimestamp( @@ -1001,8 +1015,9 @@ public class FragmentedMp4Extractor implements Extractor { long[] sampleDecodingTimeUsTable = fragment.sampleDecodingTimeUsTable; boolean[] sampleIsSyncFrameTable = fragment.sampleIsSyncFrameTable; - boolean workaroundEveryVideoFrameIsSyncFrame = track.type == C.TRACK_TYPE_VIDEO - && (flags & FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME) != 0; + boolean workaroundEveryVideoFrameIsSyncFrame = + track.type == C.TRACK_TYPE_VIDEO + && (flags & FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME) != 0; int trackRunEnd = trackRunStart + fragment.trunLength[index]; long timescale = track.timescale; @@ -1035,8 +1050,8 @@ public class FragmentedMp4Extractor implements Extractor { sampleDecodingTimeUsTable[i] += trackBundle.moovSampleTable.durationUs; } sampleSizeTable[i] = sampleSize; - sampleIsSyncFrameTable[i] = ((sampleFlags >> 16) & 0x1) == 0 - && (!workaroundEveryVideoFrameIsSyncFrame || i == 0); + sampleIsSyncFrameTable[i] = + ((sampleFlags >> 16) & 0x1) == 0 && (!workaroundEveryVideoFrameIsSyncFrame || i == 0); cumulativeTime += sampleDuration; } fragment.nextFragmentDecodeTime = cumulativeTime; @@ -1050,8 +1065,9 @@ public class FragmentedMp4Extractor implements Extractor { return value; } - private static void parseUuid(ParsableByteArray uuid, TrackFragment out, - byte[] extendedTypeScratch) throws ParserException { + private static void parseUuid( + ParsableByteArray uuid, TrackFragment out, byte[] extendedTypeScratch) + throws ParserException { uuid.setPosition(Atom.HEADER_SIZE); uuid.readBytes(extendedTypeScratch, 0, 16); @@ -1167,8 +1183,15 @@ public class FragmentedMp4Extractor implements Extractor { sgpd.readBytes(constantIv, 0, constantIvSize); } out.definesEncryptionData = true; - out.trackEncryptionBox = new TrackEncryptionBox(isProtected, schemeType, perSampleIvSize, keyId, - cryptByteBlock, skipByteBlock, constantIv); + out.trackEncryptionBox = + new TrackEncryptionBox( + isProtected, + schemeType, + perSampleIvSize, + keyId, + cryptByteBlock, + skipByteBlock, + constantIv); } /** @@ -1196,8 +1219,8 @@ public class FragmentedMp4Extractor implements Extractor { earliestPresentationTime = atom.readUnsignedLongToLong(); offset += atom.readUnsignedLongToLong(); } - long earliestPresentationTimeUs = Util.scaleLargeTimestamp(earliestPresentationTime, - C.MICROS_PER_SECOND, timescale); + long earliestPresentationTimeUs = + Util.scaleLargeTimestamp(earliestPresentationTime, C.MICROS_PER_SECOND, timescale); atom.skipBytes(2); @@ -1232,8 +1255,8 @@ public class FragmentedMp4Extractor implements Extractor { offset += sizes[i]; } - return Pair.create(earliestPresentationTimeUs, - new ChunkIndex(sizes, offsets, durationsUs, timesUs)); + return Pair.create( + earliestPresentationTimeUs, new ChunkIndex(sizes, offsets, durationsUs, timesUs)); } private void readEncryptionData(ExtractorInput input) throws IOException { @@ -1529,14 +1552,18 @@ public class FragmentedMp4Extractor implements Extractor { /** Returns whether the extractor should decode a container atom with type {@code atom}. */ private static boolean shouldParseContainerAtom(int atom) { - return atom == Atom.TYPE_moov || atom == Atom.TYPE_trak || atom == Atom.TYPE_mdia - || atom == Atom.TYPE_minf || atom == Atom.TYPE_stbl || atom == Atom.TYPE_moof - || atom == Atom.TYPE_traf || atom == Atom.TYPE_mvex || atom == Atom.TYPE_edts; + return atom == Atom.TYPE_moov + || atom == Atom.TYPE_trak + || atom == Atom.TYPE_mdia + || atom == Atom.TYPE_minf + || atom == Atom.TYPE_stbl + || atom == Atom.TYPE_moof + || atom == Atom.TYPE_traf + || atom == Atom.TYPE_mvex + || atom == Atom.TYPE_edts; } - /** - * Holds data corresponding to a metadata sample. - */ + /** Holds data corresponding to a metadata sample. */ private static final class MetadataSampleInfo { public final long presentationTimeDeltaUs; @@ -1546,12 +1573,9 @@ public class FragmentedMp4Extractor implements Extractor { this.presentationTimeDeltaUs = presentationTimeDeltaUs; this.size = size; } - } - /** - * Holds data corresponding to a single track. - */ + /** Holds data corresponding to a single track. */ private static final class TrackBundle { private static final int SINGLE_SUBSAMPLE_ENCRYPTION_DATA_LENGTH = 8; @@ -1822,7 +1846,5 @@ public class FragmentedMp4Extractor implements Extractor { : moovSampleTable.track.getSampleDescriptionEncryptionBox(sampleDescriptionIndex); return encryptionBox != null && encryptionBox.isEncrypted ? encryptionBox : null; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java index a5470dace6..9aa19cff56 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/MetadataUtil.java @@ -594,5 +594,4 @@ import org.checkerframework.checker.nullness.compatqual.NullableType; Log.w(TAG, "Failed to parse uint8 attribute value"); return -1; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java index 092dbae496..a3aa195068 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java @@ -166,9 +166,7 @@ public final class Mp4Extractor implements Extractor, SeekMap { @FileType private int fileType; @Nullable private MotionPhotoMetadata motionPhotoMetadata; - /** - * Creates a new extractor for unfragmented MP4 streams. - */ + /** Creates a new extractor for unfragmented MP4 streams. */ public Mp4Extractor() { this(/* flags= */ 0); } @@ -452,9 +450,7 @@ public final class Mp4Extractor implements Extractor, SeekMap { } } - /** - * Updates the stored track metadata to reflect the contents of the specified moov atom. - */ + /** Updates the stored track metadata to reflect the contents of the specified moov atom. */ private void processMoovAtom(ContainerAtom moov) throws ParserException { int firstVideoTrackIndex = C.INDEX_UNSET; long durationUs = C.TIME_UNSET; @@ -503,8 +499,8 @@ public final class Mp4Extractor implements Extractor, SeekMap { long trackDurationUs = track.durationUs != C.TIME_UNSET ? track.durationUs : trackSampleTable.durationUs; durationUs = max(durationUs, trackDurationUs); - Mp4Track mp4Track = new Mp4Track(track, trackSampleTable, - extractorOutput.track(i, track.type)); + Mp4Track mp4Track = + new Mp4Track(track, trackSampleTable, extractorOutput.track(i, track.type)); // Each sample has up to three bytes of overhead for the start code that replaces its length. // Allow ten source samples per output sample, like the platform extractor. @@ -634,8 +630,12 @@ public final class Mp4Extractor implements Extractor, SeekMap { sampleCurrentNalBytesRemaining -= writtenBytes; } } - trackOutput.sampleMetadata(track.sampleTable.timestampsUs[sampleIndex], - track.sampleTable.flags[sampleIndex], sampleSize, 0, null); + trackOutput.sampleMetadata( + track.sampleTable.timestampsUs[sampleIndex], + track.sampleTable.flags[sampleIndex], + sampleSize, + 0, + null); track.sampleIndex++; sampleTrackIndex = C.INDEX_UNSET; sampleBytesRead = 0; @@ -908,7 +908,5 @@ public final class Mp4Extractor implements Extractor, SeekMap { this.sampleTable = sampleTable; this.trackOutput = trackOutput; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java index c47ca8d6ba..3be0946e94 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java @@ -104,8 +104,8 @@ public final class PsshAtomUtil { /** * Parses the version from a PSSH atom. Version 0 and 1 PSSH atoms are supported. - *

- * The version is only parsed if the data is a valid PSSH atom. + * + *

The version is only parsed if the data is a valid PSSH atom. * * @param atom The atom to parse. * @return The parsed version. -1 if the input is not a valid PSSH atom, or if the PSSH atom has @@ -201,7 +201,5 @@ public final class PsshAtomUtil { this.version = version; this.schemeData = schemeData; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java index 5a8b467cc2..2c4a847ee5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Sniffer.java @@ -108,8 +108,11 @@ import java.io.IOException; private static boolean sniffInternal(ExtractorInput input, boolean fragmented, boolean acceptHeic) throws IOException { long inputLength = input.getLength(); - int bytesToSearch = (int) (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH - ? SEARCH_LENGTH : inputLength); + int bytesToSearch = + (int) + (inputLength == C.LENGTH_UNSET || inputLength > SEARCH_LENGTH + ? SEARCH_LENGTH + : inputLength); ParsableByteArray buffer = new ParsableByteArray(64); int bytesSearched = 0; @@ -223,5 +226,4 @@ import java.io.IOException; private Sniffer() { // Prevent instantiation. } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java index 1e917f825d..3771be0952 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java @@ -34,18 +34,12 @@ public final class Track { @Retention(RetentionPolicy.SOURCE) @IntDef({TRANSFORMATION_NONE, TRANSFORMATION_CEA608_CDAT}) public @interface Transformation {} - /** - * A no-op sample transformation. - */ + /** A no-op sample transformation. */ public static final int TRANSFORMATION_NONE = 0; - /** - * A transformation for caption samples in cdat atoms. - */ + /** A transformation for caption samples in cdat atoms. */ public static final int TRANSFORMATION_CEA608_CDAT = 1; - /** - * The track identifier. - */ + /** The track identifier. */ public final int id; /** @@ -53,24 +47,16 @@ public final class Track { */ public final int type; - /** - * The track timescale, defined as the number of time units that pass in one second. - */ + /** The track timescale, defined as the number of time units that pass in one second. */ public final long timescale; - /** - * The movie timescale. - */ + /** The movie timescale. */ public final long movieTimescale; - /** - * The duration of the track in microseconds, or {@link C#TIME_UNSET} if unknown. - */ + /** The duration of the track in microseconds, or {@link C#TIME_UNSET} if unknown. */ public final long durationUs; - /** - * The format. - */ + /** The format. */ public final Format format; /** @@ -79,14 +65,10 @@ public final class Track { */ @Transformation public final int sampleTransformation; - /** - * Durations of edit list segments in the movie timescale. Null if there is no edit list. - */ + /** Durations of edit list segments in the movie timescale. Null if there is no edit list. */ @Nullable public final long[] editListDurations; - /** - * Media times for edit list segments in the track timescale. Null if there is no edit list. - */ + /** Media times for edit list segments in the track timescale. Null if there is no edit list. */ @Nullable public final long[] editListMediaTimes; /** @@ -97,10 +79,18 @@ public final class Track { @Nullable private final TrackEncryptionBox[] sampleDescriptionEncryptionBoxes; - public Track(int id, int type, long timescale, long movieTimescale, long durationUs, - Format format, @Transformation int sampleTransformation, - @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, int nalUnitLengthFieldLength, - @Nullable long[] editListDurations, @Nullable long[] editListMediaTimes) { + public Track( + int id, + int type, + long timescale, + long movieTimescale, + long durationUs, + Format format, + @Transformation int sampleTransformation, + @Nullable TrackEncryptionBox[] sampleDescriptionEncryptionBoxes, + int nalUnitLengthFieldLength, + @Nullable long[] editListDurations, + @Nullable long[] editListMediaTimes) { this.id = id; this.type = type; this.timescale = timescale; @@ -123,7 +113,8 @@ public final class Track { */ @Nullable public TrackEncryptionBox getSampleDescriptionEncryptionBox(int sampleDescriptionIndex) { - return sampleDescriptionEncryptionBoxes == null ? null + return sampleDescriptionEncryptionBoxes == null + ? null : sampleDescriptionEncryptionBoxes[sampleDescriptionIndex]; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java index 986c5bb255..aed1bcf48f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java @@ -29,14 +29,10 @@ public final class TrackEncryptionBox { private static final String TAG = "TrackEncryptionBox"; - /** - * Indicates the encryption state of the samples in the sample group. - */ + /** Indicates the encryption state of the samples in the sample group. */ public final boolean isEncrypted; - /** - * The protection scheme type, as defined by the 'schm' box, or null if unknown. - */ + /** The protection scheme type, as defined by the 'schm' box, or null if unknown. */ @Nullable public final String schemeType; /** @@ -76,8 +72,9 @@ public final class TrackEncryptionBox { this.schemeType = schemeType; this.perSampleIvSize = perSampleIvSize; this.defaultInitializationVector = defaultInitializationVector; - cryptoData = new TrackOutput.CryptoData(schemeToCryptoMode(schemeType), keyId, - defaultEncryptedBlocks, defaultClearBlocks); + cryptoData = + new TrackOutput.CryptoData( + schemeToCryptoMode(schemeType), keyId, defaultEncryptedBlocks, defaultClearBlocks); } @C.CryptoMode @@ -94,10 +91,12 @@ public final class TrackEncryptionBox { case C.CENC_TYPE_cbcs: return C.CRYPTO_MODE_AES_CBC; default: - Log.w(TAG, "Unsupported protection scheme type '" + schemeType + "'. Assuming AES-CTR " - + "crypto mode."); + Log.w( + TAG, + "Unsupported protection scheme type '" + + schemeType + + "'. Assuming AES-CTR crypto mode."); return C.CRYPTO_MODE_AES_CTR; } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java index 92ce551f48..5a1fc6e0d8 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackFragment.java @@ -21,56 +21,34 @@ import com.google.android.exoplayer2.util.ParsableByteArray; import java.io.IOException; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -/** - * A holder for information corresponding to a single fragment of an mp4 file. - */ +/** A holder for information corresponding to a single fragment of an mp4 file. */ /* package */ final class TrackFragment { /** The default values for samples from the track fragment header. */ public @MonotonicNonNull DefaultSampleValues header; - /** - * The position (byte offset) of the start of fragment. - */ + /** The position (byte offset) of the start of fragment. */ public long atomPosition; - /** - * The position (byte offset) of the start of data contained in the fragment. - */ + /** The position (byte offset) of the start of data contained in the fragment. */ public long dataPosition; - /** - * The position (byte offset) of the start of auxiliary data. - */ + /** The position (byte offset) of the start of auxiliary data. */ public long auxiliaryDataPosition; - /** - * The number of track runs of the fragment. - */ + /** The number of track runs of the fragment. */ public int trunCount; - /** - * The total number of samples in the fragment. - */ + /** The total number of samples in the fragment. */ public int sampleCount; - /** - * The position (byte offset) of the start of sample data of each track run in the fragment. - */ + /** The position (byte offset) of the start of sample data of each track run in the fragment. */ public long[] trunDataPosition; - /** - * The number of samples contained by each track run in the fragment. - */ + /** The number of samples contained by each track run in the fragment. */ public int[] trunLength; - /** - * The size of each sample in the fragment. - */ + /** The size of each sample in the fragment. */ public int[] sampleSizeTable; /** The composition time offset of each sample in the fragment, in microseconds. */ public int[] sampleCompositionTimeOffsetUsTable; /** The decoding time of each sample in the fragment, in microseconds. */ public long[] sampleDecodingTimeUsTable; - /** - * Indicates which samples are sync frames. - */ + /** Indicates which samples are sync frames. */ public boolean[] sampleIsSyncFrameTable; - /** - * Whether the fragment defines encryption data. - */ + /** Whether the fragment defines encryption data. */ public boolean definesEncryptionData; /** * If {@link #definesEncryptionData} is true, indicates which samples use sub-sample encryption. @@ -84,9 +62,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; * otherwise. */ public final ParsableByteArray sampleEncryptionData; - /** - * Whether {@link #sampleEncryptionData} needs populating with the actual encryption data. - */ + /** Whether {@link #sampleEncryptionData} needs populating with the actual encryption data. */ public boolean sampleEncryptionDataNeedsFill; /** * The duration of all the samples defined in the fragments up to and including this one, plus the @@ -113,10 +89,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** * Resets the fragment. - *

- * {@link #sampleCount} and {@link #nextFragmentDecodeTime} are set to 0, and both - * {@link #definesEncryptionData} and {@link #sampleEncryptionDataNeedsFill} is set to false, - * and {@link #trackEncryptionBox} is set to null. + * + *

{@link #sampleCount} and {@link #nextFragmentDecodeTime} are set to 0, and both {@link + * #definesEncryptionData} and {@link #sampleEncryptionDataNeedsFill} is set to false, and {@link + * #trackEncryptionBox} is set to null. */ public void reset() { trunCount = 0; @@ -129,8 +105,8 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** * Configures the fragment for the specified number of samples. - *

- * The {@link #sampleCount} of the fragment is set to the specified sample count, and the + * + *

The {@link #sampleCount} of the fragment is set to the specified sample count, and the * contained tables are resized if necessary such that they are at least this length. * * @param sampleCount The number of samples in the new run. diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackSampleTable.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackSampleTable.java index ca500b2931..5104aeb209 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackSampleTable.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackSampleTable.java @@ -19,9 +19,7 @@ import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Util; -/** - * Sample table for a track in an MP4 file. - */ +/** Sample table for a track in an MP4 file. */ /* package */ final class TrackSampleTable { /** The track corresponding to this sample table. */ @@ -101,5 +99,4 @@ import com.google.android.exoplayer2.util.Util; } return C.INDEX_UNSET; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java index a86b4350c0..fd7688baad 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/FlacReader.java @@ -32,9 +32,7 @@ import com.google.android.exoplayer2.util.Util; import java.util.Arrays; import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; -/** - * {@link StreamReader} to extract Flac data out of Ogg byte stream. - */ +/** {@link StreamReader} to extract Flac data out of Ogg byte stream. */ /* package */ final class FlacReader extends StreamReader { private static final byte AUDIO_PACKET_TYPE = (byte) 0xFF; @@ -45,7 +43,9 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; @Nullable private FlacOggSeeker flacOggSeeker; public static boolean verifyBitstreamType(ParsableByteArray data) { - return data.bytesLeft() >= 5 && data.readUnsignedByte() == 0x7F && // packet type + return data.bytesLeft() >= 5 + && data.readUnsignedByte() == 0x7F + && // packet type data.readUnsignedInt() == 0x464C4143; // ASCII signature "FLAC" } @@ -157,7 +157,5 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; checkState(firstFrameOffset != -1); return new FlacSeekTableSeekMap(streamMetadata, firstFrameOffset); } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java index 49c8e2fb3b..a51f463410 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggExtractor.java @@ -114,5 +114,4 @@ public class OggExtractor implements Extractor { scratch.setPosition(0); return scratch; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java index 14a5fea607..e9d0b8b4fc 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPacket.java @@ -24,22 +24,18 @@ import com.google.android.exoplayer2.util.ParsableByteArray; import java.io.IOException; import java.util.Arrays; -/** - * OGG packet class. - */ +/** OGG packet class. */ /* package */ final class OggPacket { private final OggPageHeader pageHeader = new OggPageHeader(); - private final ParsableByteArray packetArray = new ParsableByteArray( - new byte[OggPageHeader.MAX_PAGE_PAYLOAD], 0); + private final ParsableByteArray packetArray = + new ParsableByteArray(new byte[OggPageHeader.MAX_PAGE_PAYLOAD], 0); private int currentSegmentIndex = C.INDEX_UNSET; private int segmentCount; private boolean populated; - /** - * Resets this reader. - */ + /** Resets this reader. */ public void reset() { pageHeader.reset(); packetArray.reset(/* limit= */ 0); @@ -93,8 +89,8 @@ import java.util.Arrays; populated = pageHeader.laces[segmentIndex - 1] != 255; } // Advance now since we are sure reading didn't throw an exception. - currentSegmentIndex = segmentIndex == pageHeader.pageSegmentCount ? C.INDEX_UNSET - : segmentIndex; + currentSegmentIndex = + segmentIndex == pageHeader.pageSegmentCount ? C.INDEX_UNSET : segmentIndex; } return true; } @@ -113,16 +109,12 @@ import java.util.Arrays; return pageHeader; } - /** - * Returns a {@link ParsableByteArray} containing the packet's payload. - */ + /** Returns a {@link ParsableByteArray} containing the packet's payload. */ public ParsableByteArray getPayload() { return packetArray; } - /** - * Trims the packet data array. - */ + /** Trims the packet data array. */ public void trimPayload() { if (packetArray.getData().length == OggPageHeader.MAX_PAGE_PAYLOAD) { return; @@ -152,5 +144,4 @@ import java.util.Arrays; } return size; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java index a59eca6c8c..462fbe0c52 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeader.java @@ -23,16 +23,14 @@ import com.google.android.exoplayer2.util.ParsableByteArray; import java.io.EOFException; import java.io.IOException; -/** - * Data object to store header information. - */ -/* package */ final class OggPageHeader { +/** Data object to store header information. */ +/* package */ final class OggPageHeader { public static final int EMPTY_PAGE_HEADER_SIZE = 27; public static final int MAX_SEGMENT_COUNT = 255; public static final int MAX_PAGE_PAYLOAD = 255 * 255; - public static final int MAX_PAGE_SIZE = EMPTY_PAGE_HEADER_SIZE + MAX_SEGMENT_COUNT - + MAX_PAGE_PAYLOAD; + public static final int MAX_PAGE_SIZE = + EMPTY_PAGE_HEADER_SIZE + MAX_SEGMENT_COUNT + MAX_PAGE_PAYLOAD; private static final int CAPTURE_PATTERN = 0x4f676753; // OggS private static final int CAPTURE_PATTERN_SIZE = 4; @@ -53,16 +51,14 @@ import java.io.IOException; public int headerSize; public int bodySize; /** - * Be aware that {@code laces.length} is always {@link #MAX_SEGMENT_COUNT}. Instead use - * {@link #pageSegmentCount} to iterate. + * Be aware that {@code laces.length} is always {@link #MAX_SEGMENT_COUNT}. Instead use {@link + * #pageSegmentCount} to iterate. */ public final int[] laces = new int[MAX_SEGMENT_COUNT]; private final ParsableByteArray scratch = new ParsableByteArray(MAX_SEGMENT_COUNT); - /** - * Resets all primitive member fields to zero. - */ + /** Resets all primitive member fields to zero. */ public void reset() { revision = 0; type = 0; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OpusReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OpusReader.java index 08b6fb8cae..32791c33d5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OpusReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OpusReader.java @@ -25,9 +25,7 @@ import java.util.Arrays; import java.util.List; import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; -/** - * {@link StreamReader} to extract Opus data out of Ogg byte stream. - */ +/** {@link StreamReader} to extract Opus data out of Ogg byte stream. */ /* package */ final class OpusReader extends StreamReader { private static final int OPUS_CODE = 0x4f707573; diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java index f160655459..7b0871c151 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/StreamReader.java @@ -90,9 +90,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; currentGranule = 0; } - /** - * @see Extractor#seek(long, long) - */ + /** @see Extractor#seek(long, long) */ final void seek(long position, long timeUs) { oggPacket.reset(); if (position == 0) { @@ -294,7 +292,5 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; public SeekMap createSeekMap() { return new SeekMap.Unseekable(C.TIME_UNSET); } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java index 7e7b6eb84d..607bffe858 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java @@ -31,9 +31,7 @@ import java.util.ArrayList; import java.util.Arrays; import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; -/** - * {@link StreamReader} to extract Vorbis data out of Ogg byte stream. - */ +/** {@link StreamReader} to extract Vorbis data out of Ogg byte stream. */ /* package */ final class VorbisReader extends StreamReader { @Nullable private VorbisSetup vorbisSetup; @@ -81,8 +79,8 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; int packetBlockSize = decodeBlockSize(packet.getData()[0], checkStateNotNull(vorbisSetup)); // a packet contains samples produced from overlapping the previous and current frame data // (https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-350001.3.2) - int samplesInPacket = seenFirstAudioPacket ? (packetBlockSize + previousPacketBlockSize) / 4 - : 0; + int samplesInPacket = + seenFirstAudioPacket ? (packetBlockSize + previousPacketBlockSize) / 4 : 0; // codec expects the number of samples appended to audio data appendNumberOfSamples(packet, samplesInPacket); @@ -196,9 +194,7 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; return currentBlockSize; } - /** - * Class to hold all data read from Vorbis setup headers. - */ + /** Class to hold all data read from Vorbis setup headers. */ /* package */ static final class VorbisSetup { public final VorbisUtil.VorbisIdHeader idHeader; @@ -207,15 +203,17 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf; public final Mode[] modes; public final int iLogModes; - public VorbisSetup(VorbisUtil.VorbisIdHeader idHeader, VorbisUtil.CommentHeader - commentHeader, byte[] setupHeaderData, Mode[] modes, int iLogModes) { + public VorbisSetup( + VorbisUtil.VorbisIdHeader idHeader, + VorbisUtil.CommentHeader commentHeader, + byte[] setupHeaderData, + Mode[] modes, + int iLogModes) { this.idHeader = idHeader; this.commentHeader = commentHeader; this.setupHeaderData = setupHeaderData; this.modes = modes; this.iLogModes = iLogModes; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java index 94a277582d..65f0f3a60a 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Extractor.java @@ -42,6 +42,7 @@ public final class Ac3Extractor implements Extractor { * up. */ private static final int MAX_SNIFF_BYTES = 8 * 1024; + private static final int AC3_SYNC_WORD = 0x0B77; private static final int MAX_SYNC_FRAME_SIZE = 2786; @@ -142,5 +143,4 @@ public final class Ac3Extractor implements Extractor { reader.consume(sampleData); return RESULT_CONTINUE; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java index 2de59a5a07..2706e779ee 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java @@ -71,9 +71,7 @@ public final class Ac3Reader implements ElementaryStreamReader { // Used when reading the samples. private long timeUs; - /** - * Constructs a new reader for (E-)AC-3 elementary streams. - */ + /** Constructs a new reader for (E-)AC-3 elementary streams. */ public Ac3Reader() { this(null); } @@ -215,5 +213,4 @@ public final class Ac3Reader implements ElementaryStreamReader { // specifies the number of PCM audio samples per second. sampleDurationUs = C.MICROS_PER_SECOND * frameInfo.sampleCount / format.sampleRate; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java index 13d76134da..0e1a1ed783 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java @@ -98,9 +98,7 @@ public final class AdtsReader implements ElementaryStreamReader { private @MonotonicNonNull TrackOutput currentOutput; private long currentSampleDuration; - /** - * @param exposeId3 True if the reader should expose ID3 information. - */ + /** @param exposeId3 True if the reader should expose ID3 information. */ public AdtsReader(boolean exposeId3) { this(exposeId3, null); } @@ -219,9 +217,7 @@ public final class AdtsReader implements ElementaryStreamReader { return bytesRead == targetLength; } - /** - * Sets the state to STATE_FINDING_SAMPLE. - */ + /** Sets the state to STATE_FINDING_SAMPLE. */ private void setFindingSampleState() { state = STATE_FINDING_SAMPLE; bytesRead = 0; @@ -229,8 +225,8 @@ public final class AdtsReader implements ElementaryStreamReader { } /** - * Sets the state to STATE_READING_ID3_HEADER and resets the fields required for - * {@link #parseId3Header()}. + * Sets the state to STATE_READING_ID3_HEADER and resets the fields required for {@link + * #parseId3Header()}. */ private void setReadingId3HeaderState() { state = STATE_READING_ID3_HEADER; @@ -247,8 +243,8 @@ public final class AdtsReader implements ElementaryStreamReader { * @param priorReadBytes Size of prior read bytes * @param sampleSize Size of the sample */ - private void setReadingSampleState(TrackOutput outputToUse, long currentSampleDuration, - int priorReadBytes, int sampleSize) { + private void setReadingSampleState( + TrackOutput outputToUse, long currentSampleDuration, int priorReadBytes, int sampleSize) { state = STATE_READING_SAMPLE; bytesRead = priorReadBytes; this.currentOutput = outputToUse; @@ -256,9 +252,7 @@ public final class AdtsReader implements ElementaryStreamReader { this.sampleSize = sampleSize; } - /** - * Sets the state to STATE_READING_ADTS_HEADER. - */ + /** Sets the state to STATE_READING_ADTS_HEADER. */ private void setReadingAdtsHeaderState() { state = STATE_READING_ADTS_HEADER; bytesRead = 0; @@ -468,8 +462,8 @@ public final class AdtsReader implements ElementaryStreamReader { private void parseId3Header() { id3Output.sampleData(id3HeaderBuffer, ID3_HEADER_SIZE); id3HeaderBuffer.setPosition(ID3_SIZE_OFFSET); - setReadingSampleState(id3Output, 0, ID3_HEADER_SIZE, - id3HeaderBuffer.readSynchSafeInt() + ID3_HEADER_SIZE); + setReadingSampleState( + id3Output, 0, ID3_HEADER_SIZE, id3HeaderBuffer.readSynchSafeInt() + ID3_HEADER_SIZE); } /** Parses the sample header. */ diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java index 6b5579e3a9..3d9c2b04c5 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java @@ -117,11 +117,11 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact * @param flags A combination of {@code FLAG_*} values that control the behavior of the created * readers. * @param closedCaptionFormats {@link Format}s to be exposed by payload readers for streams with - * embedded closed captions when no caption service descriptors are provided. If - * {@link #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, {@code closedCaptionFormats} overrides - * any descriptor information. If not set, and {@code closedCaptionFormats} is empty, a - * closed caption track with {@link Format#accessibilityChannel} {@link Format#NO_VALUE} will - * be exposed. + * embedded closed captions when no caption service descriptors are provided. If {@link + * #FLAG_OVERRIDE_CAPTION_DESCRIPTORS} is set, {@code closedCaptionFormats} overrides any + * descriptor information. If not set, and {@code closedCaptionFormats} is empty, a closed + * caption track with {@link Format#accessibilityChannel} {@link Format#NO_VALUE} will be + * exposed. */ public DefaultTsPayloadReaderFactory(@Flags int flags, List closedCaptionFormats) { this.flags = flags; @@ -142,10 +142,12 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact return new PesReader(new MpegAudioReader(esInfo.language)); case TsExtractor.TS_STREAM_TYPE_AAC_ADTS: return isSet(FLAG_IGNORE_AAC_STREAM) - ? null : new PesReader(new AdtsReader(false, esInfo.language)); + ? null + : new PesReader(new AdtsReader(false, esInfo.language)); case TsExtractor.TS_STREAM_TYPE_AAC_LATM: return isSet(FLAG_IGNORE_AAC_STREAM) - ? null : new PesReader(new LatmReader(esInfo.language)); + ? null + : new PesReader(new LatmReader(esInfo.language)); case TsExtractor.TS_STREAM_TYPE_AC3: case TsExtractor.TS_STREAM_TYPE_E_AC3: return new PesReader(new Ac3Reader(esInfo.language)); @@ -163,9 +165,13 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact case TsExtractor.TS_STREAM_TYPE_H263: return new PesReader(new H263Reader(buildUserDataReader(esInfo))); case TsExtractor.TS_STREAM_TYPE_H264: - return isSet(FLAG_IGNORE_H264_STREAM) ? null - : new PesReader(new H264Reader(buildSeiReader(esInfo), - isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), isSet(FLAG_DETECT_ACCESS_UNITS))); + return isSet(FLAG_IGNORE_H264_STREAM) + ? null + : new PesReader( + new H264Reader( + buildSeiReader(esInfo), + isSet(FLAG_ALLOW_NON_IDR_KEYFRAMES), + isSet(FLAG_DETECT_ACCESS_UNITS))); case TsExtractor.TS_STREAM_TYPE_H265: return new PesReader(new H265Reader(buildSeiReader(esInfo))); case TsExtractor.TS_STREAM_TYPE_SPLICE_INFO: @@ -175,8 +181,7 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact case TsExtractor.TS_STREAM_TYPE_ID3: return new PesReader(new Id3Reader()); case TsExtractor.TS_STREAM_TYPE_DVBSUBS: - return new PesReader( - new DvbSubtitleReader(esInfo.dvbSubtitleInfos)); + return new PesReader(new DvbSubtitleReader(esInfo.dvbSubtitleInfos)); case TsExtractor.TS_STREAM_TYPE_AIT: return new SectionReader(new PassthroughSectionPayloadReader(MimeTypes.APPLICATION_AIT)); default: diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DtsReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DtsReader.java index 3ffc44b730..0a10aa7790 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DtsReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DtsReader.java @@ -179,8 +179,8 @@ public final class DtsReader implements ElementaryStreamReader { sampleSize = DtsUtil.getDtsFrameSize(frameData); // In this class a sample is an access unit (frame in DTS), but the format's sample rate // specifies the number of PCM audio samples per second. - sampleDurationUs = (int) (C.MICROS_PER_SECOND - * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate); + sampleDurationUs = + (int) + (C.MICROS_PER_SECOND * DtsUtil.parseDtsAudioSampleCount(frameData) / format.sampleRate); } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java index 592e28ba57..34552c3089 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java @@ -39,9 +39,7 @@ public final class DvbSubtitleReader implements ElementaryStreamReader { private int sampleBytesWritten; private long sampleTimeUs; - /** - * @param subtitleInfos Information about the DVB subtitles associated to the stream. - */ + /** @param subtitleInfos Information about the DVB subtitles associated to the stream. */ public DvbSubtitleReader(List subtitleInfos) { this.subtitleInfos = subtitleInfos; outputs = new TrackOutput[subtitleInfos.size()]; @@ -121,5 +119,4 @@ public final class DvbSubtitleReader implements ElementaryStreamReader { bytesToCheck--; return writingSample; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/ElementaryStreamReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/ElementaryStreamReader.java index a876959723..48227d6670 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/ElementaryStreamReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/ElementaryStreamReader.java @@ -23,9 +23,7 @@ import com.google.android.exoplayer2.util.ParsableByteArray; /** Extracts individual samples from an elementary media stream, preserving original order. */ public interface ElementaryStreamReader { - /** - * Notifies the reader that a seek has occurred. - */ + /** Notifies the reader that a seek has occurred. */ void seek(); /** @@ -53,9 +51,6 @@ public interface ElementaryStreamReader { */ void consume(ParsableByteArray data) throws ParserException; - /** - * Called when a packet ends. - */ + /** Called when a packet ends. */ void packetFinished(); - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java index de9756e155..c42c3557e8 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java @@ -46,8 +46,8 @@ public final class H262Reader implements ElementaryStreamReader { private @MonotonicNonNull TrackOutput output; // Maps (frame_rate_code - 1) indices to values, as defined in ITU-T H.262 Table 6-4. - private static final double[] FRAME_RATE_VALUES = new double[] { - 24000d / 1001, 24, 25, 30000d / 1001, 30, 50, 60000d / 1001, 60}; + private static final double[] FRAME_RATE_VALUES = + new double[] {24000d / 1001, 24, 25, 30000d / 1001, 30, 50, 60000d / 1001, 60}; @Nullable private final UserDataReader userDataReader; @Nullable private final ParsableByteArray userDataParsable; @@ -191,8 +191,10 @@ public final class H262Reader implements ElementaryStreamReader { if (!startedFirstSample || sampleHasPicture) { // Start the next sample. samplePosition = totalBytesWritten - bytesWrittenPastStartCode; - sampleTimeUs = pesTimeUs != C.TIME_UNSET ? pesTimeUs - : (startedFirstSample ? (sampleTimeUs + frameDurationUs) : 0); + sampleTimeUs = + pesTimeUs != C.TIME_UNSET + ? pesTimeUs + : (startedFirstSample ? (sampleTimeUs + frameDurationUs) : 0); sampleIsKeyframe = false; pesTimeUs = C.TIME_UNSET; startedFirstSample = true; @@ -230,7 +232,7 @@ public final class H262Reader implements ElementaryStreamReader { float pixelWidthHeightRatio = 1f; int aspectRatioCode = (csdData[7] & 0xF0) >> 4; - switch(aspectRatioCode) { + switch (aspectRatioCode) { case 2: pixelWidthHeightRatio = (4 * height) / (float) (3 * width); break; @@ -285,9 +287,7 @@ public final class H262Reader implements ElementaryStreamReader { data = new byte[initialCapacity]; } - /** - * Resets the buffer, clearing any data that it holds. - */ + /** Resets the buffer, clearing any data that it holds. */ public void reset() { isFilling = false; length = 0; @@ -300,9 +300,9 @@ public final class H262Reader implements ElementaryStreamReader { * @param startCodeValue The start code value. * @param bytesAlreadyPassed The number of bytes of the start code that have been passed to * {@link #onData(byte[], int, int)}, or 0. - * @return Whether the csd data is now complete. If true is returned, neither - * this method nor {@link #onData(byte[], int, int)} should be called again without an - * interleaving call to {@link #reset()}. + * @return Whether the csd data is now complete. If true is returned, neither this method nor + * {@link #onData(byte[], int, int)} should be called again without an interleaving call to + * {@link #reset()}. */ public boolean onStartCode(int startCodeValue, int bytesAlreadyPassed) { if (isFilling) { @@ -338,7 +338,5 @@ public final class H262Reader implements ElementaryStreamReader { System.arraycopy(newData, offset, data, length, readLength); length += readLength; } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java index 116bcfef29..6790747ac9 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java @@ -153,8 +153,11 @@ public final class H264Reader implements ElementaryStreamReader { // Indicate the end of the previous NAL unit. If the length to the start of the next unit // is negative then we wrote too many bytes to the NAL buffers. Discard the excess bytes // when notifying that the unit has ended. - endNalUnit(absolutePosition, bytesWrittenPastPosition, - lengthToNalUnit < 0 ? -lengthToNalUnit : 0, pesTimeUs); + endNalUnit( + absolutePosition, + bytesWrittenPastPosition, + lengthToNalUnit < 0 ? -lengthToNalUnit : 0, + pesTimeUs); // Indicate the start of the next NAL unit. startNalUnit(absolutePosition, nalUnitType, pesTimeUs); // Continue scanning the data. @@ -286,8 +289,8 @@ public final class H264Reader implements ElementaryStreamReader { private long sampleTimeUs; private boolean sampleIsKeyframe; - public SampleReader(TrackOutput output, boolean allowNonIdrKeyframes, - boolean detectAccessUnits) { + public SampleReader( + TrackOutput output, boolean allowNonIdrKeyframes, boolean detectAccessUnits) { this.output = output; this.allowNonIdrKeyframes = allowNonIdrKeyframes; this.detectAccessUnits = detectAccessUnits; @@ -323,9 +326,10 @@ public final class H264Reader implements ElementaryStreamReader { nalUnitTimeUs = pesTimeUs; nalUnitStartPosition = position; if ((allowNonIdrKeyframes && nalUnitType == NAL_UNIT_TYPE_NON_IDR) - || (detectAccessUnits && (nalUnitType == NAL_UNIT_TYPE_IDR - || nalUnitType == NAL_UNIT_TYPE_NON_IDR - || nalUnitType == NAL_UNIT_TYPE_PARTITION_A))) { + || (detectAccessUnits + && (nalUnitType == NAL_UNIT_TYPE_IDR + || nalUnitType == NAL_UNIT_TYPE_NON_IDR + || nalUnitType == NAL_UNIT_TYPE_PARTITION_A))) { // Store the previous header and prepare to populate the new one. SliceHeaderData newSliceHeader = previousSliceHeader; previousSliceHeader = sliceHeader; @@ -438,8 +442,7 @@ public final class H264Reader implements ElementaryStreamReader { } deltaPicOrderCntBottom = bitArray.readSignedExpGolombCodedInt(); } - } else if (spsData.picOrderCountType == 1 - && !spsData.deltaPicOrderAlwaysZeroFlag) { + } else if (spsData.picOrderCountType == 1 && !spsData.deltaPicOrderAlwaysZeroFlag) { if (!bitArray.canReadExpGolombCodedNum()) { return; } @@ -451,9 +454,21 @@ public final class H264Reader implements ElementaryStreamReader { deltaPicOrderCnt1 = bitArray.readSignedExpGolombCodedInt(); } } - sliceHeader.setAll(spsData, nalRefIdc, sliceType, frameNum, picParameterSetId, fieldPicFlag, - bottomFieldFlagPresent, bottomFieldFlag, idrPicFlag, idrPicId, picOrderCntLsb, - deltaPicOrderCntBottom, deltaPicOrderCnt0, deltaPicOrderCnt1); + sliceHeader.setAll( + spsData, + nalRefIdc, + sliceType, + frameNum, + picParameterSetId, + fieldPicFlag, + bottomFieldFlagPresent, + bottomFieldFlag, + idrPicFlag, + idrPicId, + picOrderCntLsb, + deltaPicOrderCntBottom, + deltaPicOrderCnt0, + deltaPicOrderCnt1); isFilling = false; } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java index dd5dcc1782..9dccd88280 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java @@ -76,9 +76,7 @@ public final class H265Reader implements ElementaryStreamReader { // Scratch variables to avoid allocations. private final ParsableByteArray seiWrapper; - /** - * @param seiReader An SEI reader for consuming closed caption channels. - */ + /** @param seiReader An SEI reader for consuming closed caption channels. */ public H265Reader(SeiReader seiReader) { this.seiReader = seiReader; prefixFlags = new boolean[3]; @@ -157,8 +155,11 @@ public final class H265Reader implements ElementaryStreamReader { // Indicate the end of the previous NAL unit. If the length to the start of the next unit // is negative then we wrote too many bytes to the NAL buffers. Discard the excess bytes // when notifying that the unit has ended. - endNalUnit(absolutePosition, bytesWrittenPastPosition, - lengthToNalUnit < 0 ? -lengthToNalUnit : 0, pesTimeUs); + endNalUnit( + absolutePosition, + bytesWrittenPastPosition, + lengthToNalUnit < 0 ? -lengthToNalUnit : 0, + pesTimeUs); // Indicate the start of the next NAL unit. startNalUnit(absolutePosition, bytesWrittenPastPosition, nalUnitType, pesTimeUs); // Continue scanning the data. @@ -371,9 +372,7 @@ public final class H265Reader implements ElementaryStreamReader { .build(); } - /** - * Skips scaling_list_data(). See H.265/HEVC (2014) 7.3.4. - */ + /** Skips scaling_list_data(). See H.265/HEVC (2014) 7.3.4. */ private static void skipScalingList(ParsableNalUnitBitArray bitArray) { for (int sizeId = 0; sizeId < 4; sizeId++) { for (int matrixId = 0; matrixId < 6; matrixId += sizeId == 3 ? 3 : 1) { diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java index 66eb67f16c..74937ddce9 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java @@ -97,7 +97,8 @@ public final class Id3Reader implements ElementaryStreamReader { if (sampleBytesRead + headerBytesAvailable == ID3_HEADER_LENGTH) { // We've finished reading the ID3 header. Extract the sample size. id3Header.setPosition(0); - if ('I' != id3Header.readUnsignedByte() || 'D' != id3Header.readUnsignedByte() + if ('I' != id3Header.readUnsignedByte() + || 'D' != id3Header.readUnsignedByte() || '3' != id3Header.readUnsignedByte()) { Log.w(TAG, "Discarding invalid ID3 tag"); writingSample = false; @@ -122,5 +123,4 @@ public final class Id3Reader implements ElementaryStreamReader { output.sampleMetadata(sampleTimeUs, C.BUFFER_FLAG_KEY_FRAME, sampleSize, 0, null); writingSample = false; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/LatmReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/LatmReader.java index 64f56f6455..c9520fa55f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/LatmReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/LatmReader.java @@ -73,9 +73,7 @@ public final class LatmReader implements ElementaryStreamReader { private int channelCount; @Nullable private String codecs; - /** - * @param language Track language. - */ + /** @param language Track language. */ public LatmReader(@Nullable String language) { this.language = language; sampleDataBuffer = new ParsableByteArray(INITIAL_BUFFER_SIZE); @@ -319,5 +317,4 @@ public final class LatmReader implements ElementaryStreamReader { int bytesForValue = data.readBits(2); return data.readBits((bytesForValue + 1) * 8); } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.java index f65f515a9a..a3e0712332 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.java @@ -118,13 +118,13 @@ public final class MpegAudioReader implements ElementaryStreamReader { /** * Attempts to locate the start of the next frame header. - *

- * If a frame header is located then the state is changed to {@link #STATE_READING_HEADER}, the + * + *

If a frame header is located then the state is changed to {@link #STATE_READING_HEADER}, the * first two bytes of the header are written into {@link #headerScratch}, and the position of the * source is advanced to the byte that immediately follows these two bytes. - *

- * If a frame header is not located then the position of the source is advanced to the limit, and - * the method should be called again with the next source to continue the search. + * + *

If a frame header is not located then the position of the source is advanced to the limit, + * and the method should be called again with the next source to continue the search. * * @param source The source from which to read. */ diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/NalUnitTargetBuffer.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/NalUnitTargetBuffer.java index ece2fdf767..04081c7cdf 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/NalUnitTargetBuffer.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/NalUnitTargetBuffer.java @@ -19,8 +19,8 @@ import com.google.android.exoplayer2.util.Assertions; import java.util.Arrays; /** - * A buffer that fills itself with data corresponding to a specific NAL unit, as it is - * encountered in the stream. + * A buffer that fills itself with data corresponding to a specific NAL unit, as it is encountered + * in the stream. */ /* package */ final class NalUnitTargetBuffer { @@ -40,17 +40,13 @@ import java.util.Arrays; nalData[2] = 1; } - /** - * Resets the buffer, clearing any data that it holds. - */ + /** Resets the buffer, clearing any data that it holds. */ public void reset() { isFilling = false; isCompleted = false; } - /** - * Returns whether the buffer currently holds a complete NAL unit of the target type. - */ + /** Returns whether the buffer currently holds a complete NAL unit of the target type. */ public boolean isCompleted() { return isCompleted; } @@ -92,8 +88,8 @@ import java.util.Arrays; /** * Called to indicate that a NAL unit has ended. * - * @param discardPadding The number of excess bytes that were passed to - * {@link #appendToNalUnit(byte[], int, int)}, which should be discarded. + * @param discardPadding The number of excess bytes that were passed to {@link + * #appendToNalUnit(byte[], int, int)}, which should be discarded. * @return Whether the ended NAL unit is of the target type. */ public boolean endNalUnit(int discardPadding) { @@ -105,5 +101,4 @@ import java.util.Arrays; isCompleted = true; return true; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PesReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PesReader.java index eb3606a8b0..7b4ca00cef 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PesReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PesReader.java @@ -65,7 +65,9 @@ public final class PesReader implements TsPayloadReader { } @Override - public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + public void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) { this.timestampAdjuster = timestampAdjuster; reader.createTracks(extractorOutput, idGenerator); @@ -208,8 +210,11 @@ public final class PesReader implements TsPayloadReader { if (packetLength == 0) { payloadSize = C.LENGTH_UNSET; } else { - payloadSize = packetLength + 6 /* packetLength does not include the first 6 bytes */ - - HEADER_SIZE - extendedHeaderLength; + payloadSize = + packetLength + + 6 /* packetLength does not include the first 6 bytes */ + - HEADER_SIZE + - extendedHeaderLength; if (payloadSize < 0) { Log.w(TAG, "Found negative packet payload size: " + payloadSize); payloadSize = C.LENGTH_UNSET; @@ -249,5 +254,4 @@ public final class PesReader implements TsPayloadReader { timeUs = timestampAdjuster.adjustTsTimestamp(pts); } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java index f8aed61321..29ef815b25 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/PsExtractor.java @@ -92,8 +92,11 @@ public final class PsExtractor implements Extractor { input.peekFully(scratch, 0, 14); // Verify the PACK_START_CODE for the first 4 bytes - if (PACK_START_CODE != (((scratch[0] & 0xFF) << 24) | ((scratch[1] & 0xFF) << 16) - | ((scratch[2] & 0xFF) << 8) | (scratch[3] & 0xFF))) { + if (PACK_START_CODE + != (((scratch[0] & 0xFF) << 24) + | ((scratch[1] & 0xFF) << 16) + | ((scratch[2] & 0xFF) << 8) + | (scratch[3] & 0xFF))) { return false; } // Verify the 01xxx1xx marker on the 5th byte @@ -121,8 +124,8 @@ public final class PsExtractor implements Extractor { input.advancePeekPosition(packStuffingLength); // Now check that the next 3 bytes are the beginning of an MPEG start code input.peekFully(scratch, 0, 3); - return (PACKET_START_CODE_PREFIX == (((scratch[0] & 0xFF) << 16) | ((scratch[1] & 0xFF) << 8) - | (scratch[2] & 0xFF))); + return (PACKET_START_CODE_PREFIX + == (((scratch[0] & 0xFF) << 16) | ((scratch[1] & 0xFF) << 8) | (scratch[2] & 0xFF))); } @Override @@ -210,7 +213,7 @@ public final class PsExtractor implements Extractor { input.skipFully(systemHeaderLength + 6); return RESULT_CONTINUE; } else if (((nextStartCode & 0xFFFFFF00) >> 8) != PACKET_START_CODE_PREFIX) { - input.skipFully(1); // Skip bytes until we see a valid start code again. + input.skipFully(1); // Skip bytes until we see a valid start code again. return RESULT_CONTINUE; } @@ -296,9 +299,7 @@ public final class PsExtractor implements Extractor { } } - /** - * Parses PES packet data and extracts samples. - */ + /** Parses PES packet data and extracts samples. */ private static final class PesReader { private static final int PES_SCRATCH_SIZE = 64; @@ -321,10 +322,10 @@ public final class PsExtractor implements Extractor { /** * Notifies the reader that a seek has occurred. - *

- * Following a call to this method, the data passed to the next invocation of - * {@link #consume(ParsableByteArray)} will not be a continuation of the data that was - * previously passed. Hence the reader should reset any internal state. + * + *

Following a call to this method, the data passed to the next invocation of {@link + * #consume(ParsableByteArray)} will not be a continuation of the data that was previously + * passed. Hence the reader should reset any internal state. */ public void seek() { seenFirstDts = false; @@ -393,7 +394,5 @@ public final class PsExtractor implements Extractor { timeUs = timestampAdjuster.adjustTsTimestamp(pts); } } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionPayloadReader.java index 4bd5867565..40e15fa08d 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionPayloadReader.java @@ -32,7 +32,9 @@ public interface SectionPayloadReader { * @param idGenerator A {@link PesReader.TrackIdGenerator} that generates unique track ids for the * {@link TrackOutput}s. */ - void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator); /** @@ -43,5 +45,4 @@ public interface SectionPayloadReader { * Otherwise, all bytes belonging to the table section are included. */ void consume(ParsableByteArray sectionData); - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java index 3b2bd4ce89..4a73799c07 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SectionReader.java @@ -48,7 +48,9 @@ public final class SectionReader implements TsPayloadReader { } @Override - public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + public void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) { reader.init(timestampAdjuster, extractorOutput, idGenerator); waitingForPayloadStart = true; @@ -137,5 +139,4 @@ public final class SectionReader implements TsPayloadReader { } } } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java index 9fff73315c..b3229db262 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java @@ -33,9 +33,7 @@ public final class SeiReader { private final List closedCaptionFormats; private final TrackOutput[] outputs; - /** - * @param closedCaptionFormats A list of formats for the closed caption channels to expose. - */ + /** @param closedCaptionFormats A list of formats for the closed caption channels to expose. */ public SeiReader(List closedCaptionFormats) { this.closedCaptionFormats = closedCaptionFormats; outputs = new TrackOutput[closedCaptionFormats.size()]; @@ -47,8 +45,9 @@ public final class SeiReader { TrackOutput output = extractorOutput.track(idGenerator.getTrackId(), C.TRACK_TYPE_TEXT); Format channelFormat = closedCaptionFormats.get(i); @Nullable String channelMimeType = channelFormat.sampleMimeType; - Assertions.checkArgument(MimeTypes.APPLICATION_CEA608.equals(channelMimeType) - || MimeTypes.APPLICATION_CEA708.equals(channelMimeType), + Assertions.checkArgument( + MimeTypes.APPLICATION_CEA608.equals(channelMimeType) + || MimeTypes.APPLICATION_CEA708.equals(channelMimeType), "Invalid closed caption mime type provided: " + channelMimeType); String formatId = channelFormat.id != null ? channelFormat.id : idGenerator.getFormatId(); output.format( diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java index 504b84d575..249cdfac3f 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsDurationReader.java @@ -193,5 +193,4 @@ import java.io.IOException; } return C.TIME_UNSET; } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java index 325f05ff2b..5e0798ae61 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsExtractor.java @@ -64,13 +64,9 @@ public final class TsExtractor implements Extractor { @IntDef({MODE_MULTI_PMT, MODE_SINGLE_PMT, MODE_HLS}) public @interface Mode {} - /** - * Behave as defined in ISO/IEC 13818-1. - */ + /** Behave as defined in ISO/IEC 13818-1. */ public static final int MODE_MULTI_PMT = 0; - /** - * Assume only one PMT will be contained in the stream, even if more are declared by the PAT. - */ + /** Assume only one PMT will be contained in the stream, even if more are declared by the PAT. */ public static final int MODE_SINGLE_PMT = 1; /** * Enable single PMT mode, map {@link TrackOutput}s by their type (instead of PID) and ignore @@ -475,9 +471,7 @@ public final class TsExtractor implements Extractor { id3Reader = null; } - /** - * Parses Program Association Table data. - */ + /** Parses Program Association Table data. */ private class PatReader implements SectionPayloadReader { private final ParsableBitArray patScratch; @@ -487,7 +481,9 @@ public final class TsExtractor implements Extractor { } @Override - public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + public void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) { // Do nothing. } @@ -528,12 +524,9 @@ public final class TsExtractor implements Extractor { tsPayloadReaders.remove(TS_PAT_PID); } } - } - /** - * Parses Program Map Table. - */ + /** Parses Program Map Table. */ private class PmtReader implements SectionPayloadReader { private static final int TS_PMT_DESC_REGISTRATION = 0x05; @@ -560,7 +553,9 @@ public final class TsExtractor implements Extractor { } @Override - public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + public void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator) { // Do nothing. } @@ -577,8 +572,8 @@ public final class TsExtractor implements Extractor { if (mode == MODE_SINGLE_PMT || mode == MODE_HLS || remainingPmts == 1) { timestampAdjuster = timestampAdjusters.get(0); } else { - timestampAdjuster = new TimestampAdjuster( - timestampAdjusters.get(0).getFirstSampleTimestampUs()); + timestampAdjuster = + new TimestampAdjuster(timestampAdjusters.get(0).getFirstSampleTimestampUs()); timestampAdjusters.add(timestampAdjuster); } @@ -615,7 +610,9 @@ public final class TsExtractor implements Extractor { // appears intermittently during playback. See [Internal: b/20261500]. EsInfo id3EsInfo = new EsInfo(TS_STREAM_TYPE_ID3, null, null, Util.EMPTY_BYTE_ARRAY); id3Reader = payloadReaderFactory.createPayloadReader(TS_STREAM_TYPE_ID3, id3EsInfo); - id3Reader.init(timestampAdjuster, output, + id3Reader.init( + timestampAdjuster, + output, new TrackIdGenerator(programNumber, TS_STREAM_TYPE_ID3, MAX_PID_PLUS_ONE)); } @@ -661,7 +658,9 @@ public final class TsExtractor implements Extractor { @Nullable TsPayloadReader reader = trackIdToReaderScratch.valueAt(i); if (reader != null) { if (reader != id3Reader) { - reader.init(timestampAdjuster, output, + reader.init( + timestampAdjuster, + output, new TrackIdGenerator(programNumber, trackId, MAX_PID_PLUS_ONE)); } tsPayloadReaders.put(trackPid, reader); @@ -741,8 +740,8 @@ public final class TsExtractor implements Extractor { int dvbSubtitlingType = data.readUnsignedByte(); byte[] initializationData = new byte[4]; data.readBytes(initializationData, 0, 4); - dvbSubtitleInfos.add(new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType, - initializationData)); + dvbSubtitleInfos.add( + new DvbSubtitleInfo(dvbLanguage, dvbSubtitlingType, initializationData)); } } else if (descriptorTag == TS_PMT_DESC_AIT) { streamType = TS_STREAM_TYPE_AIT; @@ -757,7 +756,5 @@ public final class TsExtractor implements Extractor { dvbSubtitleInfos, Arrays.copyOfRange(data.getData(), descriptorsStartPosition, descriptorsEndPosition)); } - } - } diff --git a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsPayloadReader.java b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsPayloadReader.java index 581f4ec4ea..34405a7a1a 100644 --- a/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsPayloadReader.java +++ b/library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/TsPayloadReader.java @@ -32,15 +32,13 @@ import java.util.List; /** Parses TS packet payload data. */ public interface TsPayloadReader { - /** - * Factory of {@link TsPayloadReader} instances. - */ + /** Factory of {@link TsPayloadReader} instances. */ interface Factory { /** * Returns the initial mapping from PIDs to payload readers. - *

- * This method allows the injection of payload readers for reserved PIDs, excluding PID 0. + * + *

This method allows the injection of payload readers for reserved PIDs, excluding PID 0. * * @return A {@link SparseArray} that maps PIDs to payload readers. */ @@ -59,9 +57,7 @@ public interface TsPayloadReader { TsPayloadReader createPayloadReader(int streamType, EsInfo esInfo); } - /** - * Holds information associated with a PMT entry. - */ + /** Holds information associated with a PMT entry. */ final class EsInfo { public final int streamType; @@ -89,7 +85,6 @@ public interface TsPayloadReader { : Collections.unmodifiableList(dvbSubtitleInfos); this.descriptorBytes = descriptorBytes; } - } /** @@ -111,12 +106,9 @@ public interface TsPayloadReader { this.type = type; this.initializationData = initializationData; } - } - /** - * Generates track ids for initializing {@link TsPayloadReader}s' {@link TrackOutput}s. - */ + /** Generates track ids for initializing {@link TsPayloadReader}s' {@link TrackOutput}s. */ final class TrackIdGenerator { private static final int ID_UNSET = Integer.MIN_VALUE; @@ -165,8 +157,7 @@ public interface TsPayloadReader { * called after the first {@link #generateNewId()} call. * * @return The last generated format id, with the format {@code "programNumber/trackId"}. If no - * {@code programNumber} was provided, the {@code trackId} alone is used as - * format id. + * {@code programNumber} was provided, the {@code trackId} alone is used as format id. */ public String getFormatId() { maybeThrowUninitializedError(); @@ -178,7 +169,6 @@ public interface TsPayloadReader { throw new IllegalStateException("generateNewId() must be called before retrieving ids."); } } - } /** @@ -212,7 +202,9 @@ public interface TsPayloadReader { * @param idGenerator A {@link PesReader.TrackIdGenerator} that generates unique track ids for the * {@link TrackOutput}s. */ - void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TrackIdGenerator idGenerator); /** diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java index 646c378eb4..cc5fe8e5e7 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/DefaultExtractorInputTest.java @@ -43,8 +43,7 @@ public class DefaultExtractorInputTest { @Test public void initialPosition() throws Exception { FakeDataSource testDataSource = buildDataSource(); - DefaultExtractorInput input = - new DefaultExtractorInput(testDataSource, 123, C.LENGTH_UNSET); + DefaultExtractorInput input = new DefaultExtractorInput(testDataSource, 123, C.LENGTH_UNSET); assertThat(input.getPosition()).isEqualTo(123); } @@ -608,7 +607,9 @@ public class DefaultExtractorInputTest { private static FakeDataSource buildDataSource() throws Exception { FakeDataSource testDataSource = new FakeDataSource(); - testDataSource.getDataSet().newDefaultData() + testDataSource + .getDataSet() + .newDefaultData() .appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 3)) .appendReadData(Arrays.copyOfRange(TEST_DATA, 3, 6)) .appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9)); @@ -625,7 +626,9 @@ public class DefaultExtractorInputTest { private static FakeDataSource buildFailingDataSource() throws Exception { FakeDataSource testDataSource = new FakeDataSource(); - testDataSource.getDataSet().newDefaultData() + testDataSource + .getDataSet() + .newDefaultData() .appendReadData(Arrays.copyOfRange(TEST_DATA, 0, 6)) .appendReadError(new IOException()) .appendReadData(Arrays.copyOfRange(TEST_DATA, 6, 9)); @@ -637,5 +640,4 @@ public class DefaultExtractorInputTest { FakeDataSource testDataSource = buildDataSource(); return new DefaultExtractorInput(testDataSource, 0, C.LENGTH_UNSET); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java index caf184a119..390d1a2c77 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ExtractorTest.java @@ -34,5 +34,4 @@ public final class ExtractorTest { assertThat(C.RESULT_END_OF_INPUT != Extractor.RESULT_CONTINUE).isTrue(); assertThat(C.RESULT_END_OF_INPUT != Extractor.RESULT_SEEK).isTrue(); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisBitArrayTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisBitArrayTest.java index 6d29af5127..95e8d7321d 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisBitArrayTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisBitArrayTest.java @@ -147,5 +147,4 @@ public final class VorbisBitArrayTest { bitArray.readBit(); assertThat(bitArray.getPosition()).isEqualTo(1); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisUtilTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisUtilTest.java index 9f0d6e0ff2..0db0ebd79b 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisUtilTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/VorbisUtilTest.java @@ -103,15 +103,15 @@ public final class VorbisUtilTest { @Test public void verifyVorbisHeaderCapturePattern_withValidHeader_returnsTrue() throws ParserException { - ParsableByteArray header = new ParsableByteArray( - new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); + ParsableByteArray header = + new ParsableByteArray(new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x01, header, false)).isTrue(); } @Test public void verifyVorbisHeaderCapturePattern_withValidHeader_returnsFalse() { - ParsableByteArray header = new ParsableByteArray( - new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); + ParsableByteArray header = + new ParsableByteArray(new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); try { VorbisUtil.verifyVorbisHeaderCapturePattern(0x99, header, false); fail(); @@ -123,15 +123,15 @@ public final class VorbisUtilTest { @Test public void verifyVorbisHeaderCapturePattern_withInvalidHeaderQuite_returnsFalse() throws ParserException { - ParsableByteArray header = new ParsableByteArray( - new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); + ParsableByteArray header = + new ParsableByteArray(new byte[] {0x01, 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x99, header, true)).isFalse(); } @Test public void verifyVorbisHeaderCapturePattern_withInvalidPattern_returnsFalse() { - ParsableByteArray header = new ParsableByteArray( - new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); + ParsableByteArray header = + new ParsableByteArray(new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); try { VorbisUtil.verifyVorbisHeaderCapturePattern(0x01, header, false); fail(); @@ -143,9 +143,8 @@ public final class VorbisUtilTest { @Test public void verifyVorbisHeaderCapturePatternQuite_withInvalidPatternQuite_returnsFalse() throws ParserException { - ParsableByteArray header = new ParsableByteArray( - new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); + ParsableByteArray header = + new ParsableByteArray(new byte[] {0x01, 'x', 'v', 'o', 'r', 'b', 'i', 's'}); assertThat(verifyVorbisHeaderCapturePattern(0x01, header, true)).isFalse(); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorParameterizedTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorParameterizedTest.java index 1c28a143fa..d8f9f20ae3 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorParameterizedTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/amr/AmrExtractorParameterizedTest.java @@ -71,7 +71,6 @@ public final class AmrExtractorParameterizedTest { simulationConfig); } - private static ExtractorAsserts.ExtractorFactory createAmrExtractorFactory(boolean withSeeking) { return () -> { if (!withSeeking) { diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java index a8275fd64c..e1a700f5ed 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/DefaultEbmlReaderTest.java @@ -104,8 +104,7 @@ public class DefaultEbmlReaderTest { @Test public void floatElementFourBytes() throws IOException { - ExtractorInput input = - createTestInput(0x44, 0x89, 0x84, 0x3F, 0x80, 0x00, 0x00); + ExtractorInput input = createTestInput(0x44, 0x89, 0x84, 0x3F, 0x80, 0x00, 0x00); TestProcessor expected = new TestProcessor(); expected.floatElement(TestProcessor.ID_DURATION, 1.0); assertEvents(input, expected.events); @@ -206,8 +205,9 @@ public class DefaultEbmlReaderTest { @Override public void startMasterElement(int id, long contentPosition, long contentSize) { - events.add(formatEvent(id, "start contentPosition=" + contentPosition - + " contentSize=" + contentSize)); + events.add( + formatEvent( + id, "start contentPosition=" + contentPosition + " contentSize=" + contentSize)); } @Override @@ -240,7 +240,5 @@ public class DefaultEbmlReaderTest { private static String formatEvent(int id, String event) { return "[" + Integer.toHexString(id) + "] " + event; } - } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java index 7a3c73e4d5..e18d2cb40f 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mkv/VarintReaderTest.java @@ -88,9 +88,7 @@ public final class VarintReaderTest { public void readVarintEndOfInputAtStart() throws IOException { VarintReader reader = new VarintReader(); // Build an input with no data. - ExtractorInput input = new FakeExtractorInput.Builder() - .setSimulateUnknownLength(true) - .build(); + ExtractorInput input = new FakeExtractorInput.Builder().setSimulateUnknownLength(true).build(); // End of input allowed. long result = reader.readUnsignedVarint(input, true, false, 8); assertThat(result).isEqualTo(RESULT_END_OF_INPUT); @@ -106,10 +104,11 @@ public final class VarintReaderTest { @Test public void readVarintExceedsMaximumAllowedLength() throws IOException { VarintReader reader = new VarintReader(); - ExtractorInput input = new FakeExtractorInput.Builder() - .setData(DATA_8_BYTE_0) - .setSimulateUnknownLength(true) - .build(); + ExtractorInput input = + new FakeExtractorInput.Builder() + .setData(DATA_8_BYTE_0) + .setSimulateUnknownLength(true) + .build(); long result = reader.readUnsignedVarint(input, false, true, 4); assertThat(result).isEqualTo(RESULT_MAX_LENGTH_EXCEEDED); } @@ -191,10 +190,8 @@ public final class VarintReaderTest { private static void testReadVarint( VarintReader reader, boolean removeMask, byte[] data, int expectedLength, long expectedValue) throws IOException { - ExtractorInput input = new FakeExtractorInput.Builder() - .setData(data) - .setSimulateUnknownLength(true) - .build(); + ExtractorInput input = + new FakeExtractorInput.Builder().setData(data).setSimulateUnknownLength(true).build(); long result = reader.readUnsignedVarint(input, false, removeMask, 8); assertThat(input.getPosition()).isEqualTo(expectedLength); assertThat(result).isEqualTo(expectedValue); @@ -203,12 +200,13 @@ public final class VarintReaderTest { private static void testReadVarintFlaky( VarintReader reader, boolean removeMask, byte[] data, int expectedLength, long expectedValue) throws IOException { - ExtractorInput input = new FakeExtractorInput.Builder() - .setData(data) - .setSimulateUnknownLength(true) - .setSimulateIOErrors(true) - .setSimulatePartialReads(true) - .build(); + ExtractorInput input = + new FakeExtractorInput.Builder() + .setData(data) + .setSimulateUnknownLength(true) + .setSimulateIOErrors(true) + .setSimulatePartialReads(true) + .build(); long result = -1; while (result == -1) { try { @@ -224,5 +222,4 @@ public final class VarintReaderTest { assertThat(input.getPosition()).isEqualTo(expectedLength); assertThat(result).isEqualTo(expectedValue); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java index 7c481831c2..3b40bf85d7 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp3/XingSeekerTest.java @@ -34,23 +34,18 @@ public final class XingSeekerTest { // Xing header/payload from http://storage.googleapis.com/exoplayer-test-media-0/play.mp3. private static final int XING_FRAME_HEADER_DATA = 0xFFFB3000; - private static final byte[] XING_FRAME_PAYLOAD = Util.getBytesFromHexString( - "00000007000008dd000e7919000205080a0d0f1214171a1c1e212426292c2e303336383b3d404245484a4c4f5254" - + "575a5c5e616466696b6e707376787a7d808285878a8c8f929496999c9ea1a4a6a8abaeb0b3b5b8babdc0c2c4c7" - + "cacccfd2d4d6d9dcdee1e3e6e8ebeef0f2f5f8fafd"); + private static final byte[] XING_FRAME_PAYLOAD = + Util.getBytesFromHexString( + "00000007000008dd000e7919000205080a0d0f1214171a1c1e212426292c2e303336383b3d404245484a4c4f5254" + + "575a5c5e616466696b6e707376787a7d808285878a8c8f929496999c9ea1a4a6a8abaeb0b3b5b8babdc0c2c4c7" + + "cacccfd2d4d6d9dcdee1e3e6e8ebeef0f2f5f8fafd"); private static final int XING_FRAME_POSITION = 157; - /** - * Data size, as encoded in {@link #XING_FRAME_PAYLOAD}. - */ + /** Data size, as encoded in {@link #XING_FRAME_PAYLOAD}. */ private static final int DATA_SIZE_BYTES = 948505; - /** - * Duration of the audio stream in microseconds, encoded in {@link #XING_FRAME_PAYLOAD}. - */ + /** Duration of the audio stream in microseconds, encoded in {@link #XING_FRAME_PAYLOAD}. */ private static final int STREAM_DURATION_US = 59271836; - /** - * The length of the stream in bytes. - */ + /** The length of the stream in bytes. */ private static final int STREAM_LENGTH = XING_FRAME_POSITION + DATA_SIZE_BYTES; private XingSeeker seeker; @@ -61,10 +56,18 @@ public final class XingSeekerTest { public void setUp() throws Exception { MpegAudioUtil.Header xingFrameHeader = new MpegAudioUtil.Header(); xingFrameHeader.setForHeaderData(XING_FRAME_HEADER_DATA); - seeker = XingSeeker.create(C.LENGTH_UNSET, XING_FRAME_POSITION, xingFrameHeader, - new ParsableByteArray(XING_FRAME_PAYLOAD)); - seekerWithInputLength = XingSeeker.create(STREAM_LENGTH, - XING_FRAME_POSITION, xingFrameHeader, new ParsableByteArray(XING_FRAME_PAYLOAD)); + seeker = + XingSeeker.create( + C.LENGTH_UNSET, + XING_FRAME_POSITION, + xingFrameHeader, + new ParsableByteArray(XING_FRAME_PAYLOAD)); + seekerWithInputLength = + XingSeeker.create( + STREAM_LENGTH, + XING_FRAME_POSITION, + xingFrameHeader, + new ParsableByteArray(XING_FRAME_PAYLOAD)); xingFrameSize = xingFrameHeader.frameSize; } @@ -82,11 +85,8 @@ public final class XingSeekerTest { @Test public void getTimeUsAtEndOfStream() { - assertThat(seeker.getTimeUs(STREAM_LENGTH)) - .isEqualTo(STREAM_DURATION_US); - assertThat( - seekerWithInputLength.getTimeUs(STREAM_LENGTH)) - .isEqualTo(STREAM_DURATION_US); + assertThat(seeker.getTimeUs(STREAM_LENGTH)).isEqualTo(STREAM_DURATION_US); + assertThat(seekerWithInputLength.getTimeUs(STREAM_LENGTH)).isEqualTo(STREAM_DURATION_US); } @Test @@ -125,5 +125,4 @@ public final class XingSeekerTest { assertThat(seekPoint.position).isEqualTo(position); } } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java index 651384094f..238c97f767 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/AtomParsersTest.java @@ -30,21 +30,25 @@ public final class AtomParsersTest { private static final String ATOM_HEADER = "000000000000000000000000"; private static final String SAMPLE_COUNT = "00000004"; - private static final byte[] FOUR_BIT_STZ2 = Util.getBytesFromHexString(ATOM_HEADER + "00000004" - + SAMPLE_COUNT + "1234"); - private static final byte[] EIGHT_BIT_STZ2 = Util.getBytesFromHexString(ATOM_HEADER + "00000008" - + SAMPLE_COUNT + "01020304"); - private static final byte[] SIXTEEN_BIT_STZ2 = Util.getBytesFromHexString(ATOM_HEADER + "00000010" - + SAMPLE_COUNT + "0001000200030004"); + private static final byte[] FOUR_BIT_STZ2 = + Util.getBytesFromHexString(ATOM_HEADER + "00000004" + SAMPLE_COUNT + "1234"); + private static final byte[] EIGHT_BIT_STZ2 = + Util.getBytesFromHexString(ATOM_HEADER + "00000008" + SAMPLE_COUNT + "01020304"); + private static final byte[] SIXTEEN_BIT_STZ2 = + Util.getBytesFromHexString(ATOM_HEADER + "00000010" + SAMPLE_COUNT + "0001000200030004"); @Test public void parseCommonEncryptionSinfFromParentIgnoresUnknownSchemeType() { - byte[] cencSinf = new byte[] { - 0, 0, 0, 24, 115, 105, 110, 102, // size (4), 'sinf' (4) - 0, 0, 0, 16, 115, 99, 104, 109, // size (4), 'schm' (4) - 0, 0, 0, 0, 88, 88, 88, 88}; // version (1), flags (3), 'xxxx' (4) - assertThat(AtomParsers.parseCommonEncryptionSinfFromParent( - new ParsableByteArray(cencSinf), 0, cencSinf.length)).isNull(); + byte[] cencSinf = + new byte[] { + 0, 0, 0, 24, 115, 105, 110, 102, // size (4), 'sinf' (4) + 0, 0, 0, 16, 115, 99, 104, 109, // size (4), 'schm' (4) + 0, 0, 0, 0, 88, 88, 88, 88 + }; // version (1), flags (3), 'xxxx' (4) + assertThat( + AtomParsers.parseCommonEncryptionSinfFromParent( + new ParsableByteArray(cencSinf), 0, cencSinf.length)) + .isNull(); } @Test @@ -70,5 +74,4 @@ public final class AtomParsersTest { assertThat(box.readNextSampleSize()).isEqualTo(i + 1); } } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java index cc5dd3cdd1..cee9e22af9 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtilTest.java @@ -34,7 +34,7 @@ public final class PsshAtomUtilTest { @Test public void buildPsshAtom() { - byte[] schemeData = new byte[]{0, 1, 2, 3, 4, 5}; + byte[] schemeData = new byte[] {0, 1, 2, 3, 4, 5}; byte[] psshAtom = PsshAtomUtil.buildPsshAtom(C.WIDEVINE_UUID, schemeData); // Read the PSSH atom back and assert its content is as expected. ParsableByteArray parsablePsshAtom = new ParsableByteArray(psshAtom); @@ -50,5 +50,4 @@ public final class PsshAtomUtilTest { parsablePsshAtom.readBytes(psshSchemeData, 0, schemeData.length); assertThat(psshSchemeData).isEqualTo(schemeData); } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java index c952c0b220..ad821401ae 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/OggPageHeaderTest.java @@ -172,4 +172,3 @@ public final class OggPageHeaderTest { S get() throws E; } } - diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java index 7db02d4789..cab37c4183 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ogg/VorbisReaderTest.java @@ -62,8 +62,13 @@ public final class VorbisReaderTest { byte[] data = TestUtil.getByteArray( ApplicationProvider.getApplicationContext(), "media/binary/ogg/vorbis_header_pages"); - ExtractorInput input = new FakeExtractorInput.Builder().setData(data).setSimulateIOErrors(true) - .setSimulateUnknownLength(true).setSimulatePartialReads(true).build(); + ExtractorInput input = + new FakeExtractorInput.Builder() + .setData(data) + .setSimulateIOErrors(true) + .setSimulateUnknownLength(true) + .setSimulatePartialReads(true) + .build(); VorbisReader reader = new VorbisReader(); VorbisReader.VorbisSetup vorbisSetup = readSetupHeaders(reader, input); @@ -114,5 +119,4 @@ public final class VorbisReaderTest { } } } - } diff --git a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java index a023a32729..59054ebbab 100644 --- a/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java +++ b/library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/SectionReaderTest.java @@ -46,7 +46,9 @@ public final class SectionReaderTest { Arrays.fill(packetPayload, (byte) 0xFF); payloadReader = new CustomSectionPayloadReader(); reader = new SectionReader(payloadReader); - reader.init(new TimestampAdjuster(0), new FakeExtractorOutput(), + reader.init( + new TimestampAdjuster(0), + new FakeExtractorOutput(), new TsPayloadReader.TrackIdGenerator(0, 1)); } @@ -157,10 +159,12 @@ public final class SectionReaderTest { @Test public void crcChecks() { - byte[] correctCrcPat = new byte[] { - (byte) 0x0, (byte) 0x0, (byte) 0xb0, (byte) 0xd, (byte) 0x0, (byte) 0x1, (byte) 0xc1, - (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0xe1, (byte) 0x0, (byte) 0xe8, - (byte) 0xf9, (byte) 0x5e, (byte) 0x7d}; + byte[] correctCrcPat = + new byte[] { + (byte) 0x0, (byte) 0x0, (byte) 0xb0, (byte) 0xd, (byte) 0x0, (byte) 0x1, (byte) 0xc1, + (byte) 0x0, (byte) 0x0, (byte) 0x0, (byte) 0x1, (byte) 0xe1, (byte) 0x0, (byte) 0xe8, + (byte) 0xf9, (byte) 0x5e, (byte) 0x7d + }; byte[] incorrectCrcPat = Arrays.copyOf(correctCrcPat, correctCrcPat.length); // Crc field is incorrect, and should not be passed to the payload reader. incorrectCrcPat[16]--; @@ -192,7 +196,9 @@ public final class SectionReaderTest { List parsedTableIds; @Override - public void init(TimestampAdjuster timestampAdjuster, ExtractorOutput extractorOutput, + public void init( + TimestampAdjuster timestampAdjuster, + ExtractorOutput extractorOutput, TsPayloadReader.TrackIdGenerator idGenerator) { parsedTableIds = new ArrayList<>(); } @@ -201,7 +207,5 @@ public final class SectionReaderTest { public void consume(ParsableByteArray sectionData) { parsedTableIds.add(sectionData.readUnsignedByte()); } - } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsDataSourceFactory.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsDataSourceFactory.java index 5382e5f6e3..25c0e8c0e6 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsDataSourceFactory.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsDataSourceFactory.java @@ -22,9 +22,7 @@ public final class DefaultHlsDataSourceFactory implements HlsDataSourceFactory { private final DataSource.Factory dataSourceFactory; - /** - * @param dataSourceFactory The {@link DataSource.Factory} to use for all data types. - */ + /** @param dataSourceFactory The {@link DataSource.Factory} to use for all data types. */ public DefaultHlsDataSourceFactory(DataSource.Factory dataSourceFactory) { this.dataSourceFactory = dataSourceFactory; } @@ -33,5 +31,4 @@ public final class DefaultHlsDataSourceFactory implements HlsDataSourceFactory { public DataSource createDataSource(int dataType) { return dataSourceFactory.createDataSource(); } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java index 66cd100a63..74f1b68aed 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java @@ -59,9 +59,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** Source of Hls (possibly adaptive) chunks. */ /* package */ class HlsChunkSource { - /** - * Chunk holder that allows the scheduling of retries. - */ + /** Chunk holder that allows the scheduling of retries. */ public static final class HlsChunkHolder { public HlsChunkHolder() { @@ -71,17 +69,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** The chunk to be loaded next. */ @Nullable public Chunk chunk; - /** - * Indicates that the end of the stream has been reached. - */ + /** Indicates that the end of the stream has been reached. */ public boolean endOfStream; /** Indicates that the chunk source is waiting for the referred playlist to be refreshed. */ @Nullable public Uri playlistUrl; - /** - * Clears the holder. - */ + /** Clears the holder. */ public void clear() { chunk = null; endOfStream = false; @@ -209,9 +203,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } } - /** - * Returns the track group exposed by the source. - */ + /** Returns the track group exposed by the source. */ public TrackGroup getTrackGroup() { return trackGroup; } @@ -230,9 +222,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; return trackSelection; } - /** - * Resets the source. - */ + /** Resets the source. */ public void reset() { fatalError = null; } @@ -859,7 +849,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public Object getSelectionData() { return null; } - } private static final class EncryptionKeyChunk extends DataChunk { @@ -873,8 +862,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; int trackSelectionReason, @Nullable Object trackSelectionData, byte[] scratchSpace) { - super(dataSource, dataSpec, C.DATA_TYPE_DRM, trackFormat, trackSelectionReason, - trackSelectionData, scratchSpace); + super( + dataSource, + dataSpec, + C.DATA_TYPE_DRM, + trackFormat, + trackSelectionReason, + trackSelectionData, + scratchSpace); } @Override @@ -887,7 +882,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; public byte[] getResult() { return result; } - } @VisibleForTesting diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsDataSourceFactory.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsDataSourceFactory.java index 7ec2f6c1f5..499797c51a 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsDataSourceFactory.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsDataSourceFactory.java @@ -29,5 +29,4 @@ public interface HlsDataSourceFactory { * @return A {@link DataSource} for the given data type. */ DataSource createDataSource(int dataType); - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsManifest.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsManifest.java index cf908145a0..ff2dcf0ba9 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsManifest.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsManifest.java @@ -21,13 +21,9 @@ import com.google.android.exoplayer2.source.hls.playlist.HlsMediaPlaylist; /** Holds a master playlist along with a snapshot of one of its media playlists. */ public final class HlsManifest { - /** - * The master playlist of an HLS stream. - */ + /** The master playlist of an HLS stream. */ public final HlsMasterPlaylist masterPlaylist; - /** - * A snapshot of a media playlist referred to by {@link #masterPlaylist}. - */ + /** A snapshot of a media playlist referred to by {@link #masterPlaylist}. */ public final HlsMediaPlaylist mediaPlaylist; /** @@ -38,5 +34,4 @@ public final class HlsManifest { this.masterPlaylist = masterPlaylist; this.mediaPlaylist = mediaPlaylist; } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java index 3527eb1fc3..13ef8697d3 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaChunk.java @@ -48,9 +48,7 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull; -/** - * An HLS {@link MediaChunk}. - */ +/** An HLS {@link MediaChunk}. */ /* package */ final class HlsMediaChunk extends MediaChunk { /** @@ -191,14 +189,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; private static final AtomicInteger uidSource = new AtomicInteger(); - /** - * A unique identifier for the chunk. - */ + /** A unique identifier for the chunk. */ public final int uid; - /** - * The discontinuity sequence number of the chunk. - */ + /** The discontinuity sequence number of the chunk. */ public final int discontinuitySequenceNumber; /** The url of the playlist from which this chunk was obtained. */ diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java index 66dd308e52..287787acff 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java @@ -268,8 +268,8 @@ public final class HlsMediaPeriod int[] streamChildIndices = new int[selections.length]; int[] selectionChildIndices = new int[selections.length]; for (int i = 0; i < selections.length; i++) { - streamChildIndices[i] = streams[i] == null ? C.INDEX_UNSET - : streamWrapperIndices.get(streams[i]); + streamChildIndices[i] = + streams[i] == null ? C.INDEX_UNSET : streamWrapperIndices.get(streams[i]); selectionChildIndices[i] = C.INDEX_UNSET; if (selections[i] != null) { TrackGroup trackGroup = selections[i].getTrackGroup(); @@ -297,8 +297,14 @@ public final class HlsMediaPeriod childSelections[j] = selectionChildIndices[j] == i ? selections[j] : null; } HlsSampleStreamWrapper sampleStreamWrapper = sampleStreamWrappers[i]; - boolean wasReset = sampleStreamWrapper.selectTracks(childSelections, mayRetainStreamFlags, - childStreams, streamResetFlags, positionUs, forceReset); + boolean wasReset = + sampleStreamWrapper.selectTracks( + childSelections, + mayRetainStreamFlags, + childStreams, + streamResetFlags, + positionUs, + forceReset); boolean wrapperEnabled = false; for (int j = 0; j < selections.length; j++) { SampleStream childStream = childStreams[j]; @@ -320,7 +326,8 @@ public final class HlsMediaPeriod // that the first wrapper will correspond to a variant, or else an audio rendition, or // else a text rendition, in that order. sampleStreamWrapper.setIsTimestampMaster(true); - if (wasReset || enabledSampleStreamWrappers.length == 0 + if (wasReset + || enabledSampleStreamWrappers.length == 0 || sampleStreamWrapper != enabledSampleStreamWrappers[0]) { // The wrapper responsible for initializing the timestamp adjusters was reset or // changed. We need to reset the timestamp adjuster provider and all other wrappers. @@ -866,5 +873,4 @@ public final class HlsMediaPeriod .setLanguage(language) .build(); } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java index 1927ceb0cb..2cc46c40cf 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java @@ -515,8 +515,8 @@ public final class HlsMediaSource extends BaseMediaSource @Override public void onPrimaryPlaylistRefreshed(HlsMediaPlaylist playlist) { SinglePeriodTimeline timeline; - long windowStartTimeMs = playlist.hasProgramDateTime ? C.usToMs(playlist.startTimeUs) - : C.TIME_UNSET; + long windowStartTimeMs = + playlist.hasProgramDateTime ? C.usToMs(playlist.startTimeUs) : C.TIME_UNSET; // For playlist types EVENT and VOD we know segments are never removed, so the presentation // started at the same time as the window. Otherwise, we don't know the presentation start time. long presentationStartTimeMs = diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStream.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStream.java index 53d9b0cd9e..a590607850 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStream.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStream.java @@ -22,9 +22,7 @@ import com.google.android.exoplayer2.source.SampleStream; import com.google.android.exoplayer2.util.Assertions; import java.io.IOException; -/** - * {@link SampleStream} for a particular sample queue in HLS. - */ +/** {@link SampleStream} for a particular sample queue in HLS. */ /* package */ final class HlsSampleStream implements SampleStream { private final int trackGroupIndex; diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java index da28de4094..16a6b48250 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java @@ -84,15 +84,17 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull; /** - * Loads {@link HlsMediaChunk}s obtained from a {@link HlsChunkSource}, and provides - * {@link SampleStream}s from which the loaded media can be consumed. + * Loads {@link HlsMediaChunk}s obtained from a {@link HlsChunkSource}, and provides {@link + * SampleStream}s from which the loaded media can be consumed. */ -/* package */ final class HlsSampleStreamWrapper implements Loader.Callback, - Loader.ReleaseCallback, SequenceableLoader, ExtractorOutput, UpstreamFormatChangedListener { +/* package */ final class HlsSampleStreamWrapper + implements Loader.Callback, + Loader.ReleaseCallback, + SequenceableLoader, + ExtractorOutput, + UpstreamFormatChangedListener { - /** - * A callback to be notified of events. - */ + /** A callback to be notified of events. */ public interface Callback extends SequenceableLoader.Callback { /** @@ -664,8 +666,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; } else { long bufferedPositionUs = lastSeekPositionUs; HlsMediaChunk lastMediaChunk = getLastMediaChunk(); - HlsMediaChunk lastCompletedMediaChunk = lastMediaChunk.isLoadCompleted() ? lastMediaChunk - : mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null; + HlsMediaChunk lastCompletedMediaChunk = + lastMediaChunk.isLoadCompleted() + ? lastMediaChunk + : mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null; if (lastCompletedMediaChunk != null) { bufferedPositionUs = max(bufferedPositionUs, lastCompletedMediaChunk.endTimeUs); } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/TimestampAdjusterProvider.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/TimestampAdjusterProvider.java index 83d4c31924..9249bec7a5 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/TimestampAdjusterProvider.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/TimestampAdjusterProvider.java @@ -30,8 +30,8 @@ public final class TimestampAdjusterProvider { } /** - * Returns a {@link TimestampAdjuster} suitable for adjusting the pts timestamps contained in - * a chunk with a given discontinuity sequence. + * Returns a {@link TimestampAdjuster} suitable for adjusting the pts timestamps contained in a + * chunk with a given discontinuity sequence. * * @param discontinuitySequence The chunk's discontinuity sequence. * @return A {@link TimestampAdjuster}. @@ -45,11 +45,8 @@ public final class TimestampAdjusterProvider { return adjuster; } - /** - * Resets the provider. - */ + /** Resets the provider. */ public void reset() { timestampAdjusters.clear(); } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java index 832de00cf9..53f7421254 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java @@ -115,8 +115,10 @@ public final class WebvttExtractor implements Extractor { // Increase the size of sampleData if necessary. if (sampleSize == sampleData.length) { - sampleData = Arrays.copyOf(sampleData, - (currentFileSize != C.LENGTH_UNSET ? currentFileSize : sampleData.length) * 3 / 2); + sampleData = + Arrays.copyOf( + sampleData, + (currentFileSize != C.LENGTH_UNSET ? currentFileSize : sampleData.length) * 3 / 2); } // Consume to the input. @@ -200,5 +202,4 @@ public final class WebvttExtractor implements Extractor { output.endTracks(); return trackOutput; } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java index 72f6a361d7..2db9425a84 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java @@ -145,7 +145,6 @@ public final class HlsMasterPlaylist extends HlsPlaylist { this.groupId = groupId; this.name = name; } - } /** All of the media playlist URLs referenced by the playlist. */ @@ -214,8 +213,8 @@ public final class HlsMasterPlaylist extends HlsPlaylist { this.subtitles = Collections.unmodifiableList(subtitles); this.closedCaptions = Collections.unmodifiableList(closedCaptions); this.muxedAudioFormat = muxedAudioFormat; - this.muxedCaptionFormats = muxedCaptionFormats != null - ? Collections.unmodifiableList(muxedCaptionFormats) : null; + this.muxedCaptionFormats = + muxedCaptionFormats != null ? Collections.unmodifiableList(muxedCaptionFormats) : null; this.variableDefinitions = Collections.unmodifiableMap(variableDefinitions); this.sessionKeyDrmInitData = Collections.unmodifiableList(sessionKeyDrmInitData); } @@ -317,5 +316,4 @@ public final class HlsMasterPlaylist extends HlsPlaylist { } return copiedStreams; } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java index ea7303656c..698d0057eb 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java @@ -341,7 +341,8 @@ public final class HlsMediaPlaylist extends HlsPlaylist { @Override public int compareTo(Long relativeStartTimeUs) { return this.relativeStartTimeUs > relativeStartTimeUs - ? 1 : (this.relativeStartTimeUs < relativeStartTimeUs ? -1 : 0); + ? 1 + : (this.relativeStartTimeUs < relativeStartTimeUs ? -1 : 0); } } @@ -388,13 +389,9 @@ public final class HlsMediaPlaylist extends HlsPlaylist { public static final int PLAYLIST_TYPE_VOD = 1; public static final int PLAYLIST_TYPE_EVENT = 2; - /** - * The type of the playlist. See {@link PlaylistType}. - */ + /** The type of the playlist. See {@link PlaylistType}. */ @PlaylistType public final int playlistType; - /** - * The start offset in microseconds, as defined by #EXT-X-START. - */ + /** The start offset in microseconds, as defined by #EXT-X-START. */ public final long startOffsetUs; /** * If {@link #hasProgramDateTime} is true, contains the datetime as microseconds since epoch. @@ -402,9 +399,7 @@ public final class HlsMediaPlaylist extends HlsPlaylist { * playlist. */ public final long startTimeUs; - /** - * Whether the playlist contains the #EXT-X-DISCONTINUITY-SEQUENCE tag. - */ + /** Whether the playlist contains the #EXT-X-DISCONTINUITY-SEQUENCE tag. */ public final boolean hasDiscontinuitySequence; /** * The discontinuity sequence number of the first media segment in the playlist, as defined by @@ -416,13 +411,9 @@ public final class HlsMediaPlaylist extends HlsPlaylist { * #EXT-X-MEDIA-SEQUENCE. */ public final long mediaSequence; - /** - * The compatibility version, as defined by #EXT-X-VERSION. - */ + /** The compatibility version, as defined by #EXT-X-VERSION. */ public final int version; - /** - * The target duration in microseconds, as defined by #EXT-X-TARGETDURATION. - */ + /** The target duration in microseconds, as defined by #EXT-X-TARGETDURATION. */ public final long targetDurationUs; /** * The target duration for segment parts, as defined by #EXT-X-PART-INF, or {@link C#TIME_UNSET} @@ -431,18 +422,14 @@ public final class HlsMediaPlaylist extends HlsPlaylist { public final long partTargetDurationUs; /** Whether the playlist contains the #EXT-X-ENDLIST tag. */ public final boolean hasEndTag; - /** - * Whether the playlist contains a #EXT-X-PROGRAM-DATE-TIME tag. - */ + /** Whether the playlist contains a #EXT-X-PROGRAM-DATE-TIME tag. */ public final boolean hasProgramDateTime; /** * Contains the CDM protection schemes used by segments in this playlist. Does not contain any key * acquisition data. Null if none of the segments in the playlist is CDM-encrypted. */ @Nullable public final DrmInitData protectionSchemes; - /** - * The list of segments in the playlist. - */ + /** The list of segments in the playlist. */ public final List segments; /** * The list of parts at the end of the playlist for which the segment is not in the playlist yet. @@ -519,8 +506,10 @@ public final class HlsMediaPlaylist extends HlsPlaylist { } else { durationUs = 0; } - this.startOffsetUs = startOffsetUs == C.TIME_UNSET ? C.TIME_UNSET - : startOffsetUs >= 0 ? startOffsetUs : durationUs + startOffsetUs; + this.startOffsetUs = + startOffsetUs == C.TIME_UNSET + ? C.TIME_UNSET + : startOffsetUs >= 0 ? startOffsetUs : durationUs + startOffsetUs; this.serverControl = serverControl; } @@ -553,9 +542,7 @@ public final class HlsMediaPlaylist extends HlsPlaylist { || (partCount == otherPartCount && hasEndTag && !other.hasEndTag); } - /** - * Returns the result of adding the duration of the playlist to its start time. - */ + /** Returns the result of adding the duration of the playlist to its start time. */ public long getEndTimeUs() { return startTimeUs + durationUs; } @@ -621,5 +608,4 @@ public final class HlsMediaPlaylist extends HlsPlaylist { serverControl, renditionReports); } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylist.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylist.java index 9cec1cd33b..17d31d4ceb 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylist.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylist.java @@ -22,13 +22,9 @@ import java.util.List; /** Represents an HLS playlist. */ public abstract class HlsPlaylist implements FilterableManifest { - /** - * The base uri. Used to resolve relative paths. - */ + /** The base uri. Used to resolve relative paths. */ public final String baseUri; - /** - * The list of tags in the playlist. - */ + /** The list of tags in the playlist. */ public final List tags; /** * Whether the media is formed of independent segments, as defined by the @@ -46,5 +42,4 @@ public abstract class HlsPlaylist implements FilterableManifest { this.tags = Collections.unmodifiableList(tags); this.hasIndependentSegments = hasIndependentSegments; } - } diff --git a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java index 7b5aa3ef3f..4b0da0b701 100644 --- a/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java +++ b/library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java @@ -139,14 +139,14 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser tracks) {} + @Override public void onSessionTimelineRequestFailed(String message, @Nullable Throwable cause) {} }, diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java index b35dc98608..c5857c5f0f 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java @@ -68,7 +68,6 @@ public class DefaultSsChunkSource implements SsChunkSource { return new DefaultSsChunkSource( manifestLoaderErrorThrower, manifest, elementIndex, trackSelection, dataSource); } - } private final LoaderErrorThrower manifestLoaderErrorThrower; @@ -112,9 +111,19 @@ public class DefaultSsChunkSource implements SsChunkSource { ? Assertions.checkNotNull(manifest.protectionElement).trackEncryptionBoxes : null; int nalUnitLengthFieldLength = streamElement.type == C.TRACK_TYPE_VIDEO ? 4 : 0; - Track track = new Track(manifestTrackIndex, streamElement.type, streamElement.timescale, - C.TIME_UNSET, manifest.durationUs, format, Track.TRANSFORMATION_NONE, - trackEncryptionBoxes, nalUnitLengthFieldLength, null, null); + Track track = + new Track( + manifestTrackIndex, + streamElement.type, + streamElement.timescale, + C.TIME_UNSET, + manifest.durationUs, + format, + Track.TRANSFORMATION_NONE, + trackEncryptionBoxes, + nalUnitLengthFieldLength, + null, + null); FragmentedMp4Extractor extractor = new FragmentedMp4Extractor( FragmentedMp4Extractor.FLAG_WORKAROUND_EVERY_VIDEO_FRAME_IS_SYNC_FRAME @@ -146,8 +155,9 @@ public class DefaultSsChunkSource implements SsChunkSource { // There's no overlap between the old and new elements because at least one is empty. currentManifestChunkOffset += currentElementChunkCount; } else { - long currentElementEndTimeUs = currentElement.getStartTimeUs(currentElementChunkCount - 1) - + currentElement.getChunkDurationUs(currentElementChunkCount - 1); + long currentElementEndTimeUs = + currentElement.getStartTimeUs(currentElementChunkCount - 1) + + currentElement.getChunkDurationUs(currentElementChunkCount - 1); long newElementStartTimeUs = newElement.getStartTimeUs(0); if (currentElementEndTimeUs <= newElementStartTimeUs) { // There's no overlap between the old and new elements. @@ -325,8 +335,9 @@ public class DefaultSsChunkSource implements SsChunkSource { StreamElement currentElement = manifest.streamElements[streamElementIndex]; int lastChunkIndex = currentElement.chunkCount - 1; - long lastChunkEndTimeUs = currentElement.getStartTimeUs(lastChunkIndex) - + currentElement.getChunkDurationUs(lastChunkIndex); + long lastChunkEndTimeUs = + currentElement.getStartTimeUs(lastChunkIndex) + + currentElement.getChunkDurationUs(lastChunkIndex); return lastChunkEndTimeUs - playbackPositionUs; } diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java index da2ffe9006..d5604df513 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java @@ -361,9 +361,7 @@ public final class SsMediaSource extends BaseMediaSource */ public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30_000; - /** - * The minimum period between manifest refreshes. - */ + /** The minimum period between manifest refreshes. */ private static final int MINIMUM_MANIFEST_REFRESH_PERIOD_MS = 5000; /** * The minimum default start position for live streams, relative to the start of the live window. @@ -636,8 +634,8 @@ public final class SsMediaSource extends BaseMediaSource manifest, mediaItem); } else { - long durationUs = manifest.durationUs != C.TIME_UNSET ? manifest.durationUs - : endTimeUs - startTimeUs; + long durationUs = + manifest.durationUs != C.TIME_UNSET ? manifest.durationUs : endTimeUs - startTimeUs; timeline = new SinglePeriodTimeline( startTimeUs + durationUs, @@ -666,8 +664,9 @@ public final class SsMediaSource extends BaseMediaSource if (manifestLoader.hasFatalError()) { return; } - ParsingLoadable loadable = new ParsingLoadable<>(manifestDataSource, - manifestUri, C.DATA_TYPE_MANIFEST, manifestParser); + ParsingLoadable loadable = + new ParsingLoadable<>( + manifestDataSource, manifestUri, C.DATA_TYPE_MANIFEST, manifestParser); long elapsedRealtimeMs = manifestLoader.startLoading( loadable, this, loadErrorHandlingPolicy.getMinimumLoadableRetryCount(loadable.type)); @@ -675,5 +674,4 @@ public final class SsMediaSource extends BaseMediaSource new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, elapsedRealtimeMs), loadable.type); } - } diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java index b91bfc8f67..97e155b379 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java @@ -52,9 +52,7 @@ public class SsManifest implements FilterableManifest { } } - /** - * Represents a StreamIndex element. - */ + /** Represents a StreamIndex element. */ public static class StreamElement { private static final String URL_PLACEHOLDER_START_TIME_1 = "{start time}"; @@ -156,9 +154,22 @@ public class SsManifest implements FilterableManifest { * @throws IndexOutOfBoundsException If a key has an invalid index. */ public StreamElement copy(Format[] formats) { - return new StreamElement(baseUri, chunkTemplate, type, subType, timescale, name, maxWidth, - maxHeight, displayWidth, displayHeight, language, formats, chunkStartTimes, - chunkStartTimesUs, lastChunkDurationUs); + return new StreamElement( + baseUri, + chunkTemplate, + type, + subType, + timescale, + name, + maxWidth, + maxHeight, + displayWidth, + displayHeight, + language, + formats, + chunkStartTimes, + chunkStartTimesUs, + lastChunkDurationUs); } /** @@ -188,7 +199,8 @@ public class SsManifest implements FilterableManifest { * @return The duration of the chunk, in microseconds. */ public long getChunkDurationUs(int chunkIndex) { - return (chunkIndex == chunkCount - 1) ? lastChunkDurationUs + return (chunkIndex == chunkCount - 1) + ? lastChunkDurationUs : chunkStartTimesUs[chunkIndex + 1] - chunkStartTimesUs[chunkIndex]; } @@ -205,11 +217,12 @@ public class SsManifest implements FilterableManifest { Assertions.checkState(chunkIndex < chunkStartTimes.size()); String bitrateString = Integer.toString(formats[track].bitrate); String startTimeString = chunkStartTimes.get(chunkIndex).toString(); - String chunkUrl = chunkTemplate - .replace(URL_PLACEHOLDER_BITRATE_1, bitrateString) - .replace(URL_PLACEHOLDER_BITRATE_2, bitrateString) - .replace(URL_PLACEHOLDER_START_TIME_1, startTimeString) - .replace(URL_PLACEHOLDER_START_TIME_2, startTimeString); + String chunkUrl = + chunkTemplate + .replace(URL_PLACEHOLDER_BITRATE_1, bitrateString) + .replace(URL_PLACEHOLDER_BITRATE_2, bitrateString) + .replace(URL_PLACEHOLDER_START_TIME_1, startTimeString) + .replace(URL_PLACEHOLDER_START_TIME_2, startTimeString); return UriUtil.resolveToUri(baseUri, chunkUrl); } } diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java index 05eb8acc0d..1c683b9e42 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java @@ -78,20 +78,15 @@ public class SsManifestParser implements ParsingLoadable.Parser { } } - /** - * Thrown if a required field is missing. - */ + /** Thrown if a required field is missing. */ public static class MissingFieldException extends ParserException { public MissingFieldException(String fieldName) { super("Missing required field: " + fieldName); } - } - /** - * A base class for parsers that parse components of a smooth streaming manifest. - */ + /** A base class for parsers that parse components of a smooth streaming manifest. */ private abstract static class ElementParser { private final String baseUri; @@ -224,23 +219,17 @@ public class SsManifestParser implements ParsingLoadable.Parser { // Do nothing. } - /** - * @param xmlParser The underlying {@link XmlPullParser} - */ + /** @param xmlParser The underlying {@link XmlPullParser} */ protected void parseText(XmlPullParser xmlParser) { // Do nothing. } - /** - * @param xmlParser The underlying {@link XmlPullParser} - */ + /** @param xmlParser The underlying {@link XmlPullParser} */ protected void parseEndTag(XmlPullParser xmlParser) { // Do nothing. } - /** - * @param parsedChild A parsed child object. - */ + /** @param parsedChild A parsed child object. */ protected void addChild(Object parsedChild) { // Do nothing. } @@ -320,7 +309,6 @@ public class SsManifestParser implements ParsingLoadable.Parser { return defaultValue; } } - } private static class SmoothStreamingMediaParser extends ElementParser { @@ -380,8 +368,10 @@ public class SsManifestParser implements ParsingLoadable.Parser { StreamElement[] streamElementArray = new StreamElement[streamElements.size()]; streamElements.toArray(streamElementArray); if (protectionElement != null) { - DrmInitData drmInitData = new DrmInitData(new SchemeData(protectionElement.uuid, - MimeTypes.VIDEO_MP4, protectionElement.data)); + DrmInitData drmInitData = + new DrmInitData( + new SchemeData( + protectionElement.uuid, MimeTypes.VIDEO_MP4, protectionElement.data)); for (StreamElement streamElement : streamElementArray) { int type = streamElement.type; if (type == C.TRACK_TYPE_VIDEO || type == C.TRACK_TYPE_AUDIO) { @@ -392,10 +382,17 @@ public class SsManifestParser implements ParsingLoadable.Parser { } } } - return new SsManifest(majorVersion, minorVersion, timescale, duration, dvrWindowLength, - lookAheadCount, isLive, protectionElement, streamElementArray); + return new SsManifest( + majorVersion, + minorVersion, + timescale, + duration, + dvrWindowLength, + lookAheadCount, + isLive, + protectionElement, + streamElementArray); } - } private static class ProtectionParser extends ElementParser { @@ -633,10 +630,22 @@ public class SsManifestParser implements ParsingLoadable.Parser { public Object build() { Format[] formatArray = new Format[formats.size()]; formats.toArray(formatArray); - return new StreamElement(baseUri, url, type, subType, timescale, name, maxWidth, maxHeight, - displayWidth, displayHeight, language, formatArray, startTimes, lastChunkDuration); + return new StreamElement( + baseUri, + url, + type, + subType, + timescale, + name, + maxWidth, + maxHeight, + displayWidth, + displayHeight, + language, + formatArray, + startTimes, + lastChunkDuration); } - } private static class QualityLevelParser extends ElementParser { @@ -669,8 +678,8 @@ public class SsManifestParser implements ParsingLoadable.Parser { @Nullable String sampleMimeType = fourCCToMimeType(parseRequiredString(parser, KEY_FOUR_CC)); int type = (Integer) getNormalizedAttribute(KEY_TYPE); if (type == C.TRACK_TYPE_VIDEO) { - List codecSpecificData = buildCodecSpecificData( - parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA)); + List codecSpecificData = + buildCodecSpecificData(parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA)); formatBuilder .setContainerMimeType(MimeTypes.VIDEO_MP4) .setWidth(parseRequiredInt(parser, KEY_MAX_WIDTH)) @@ -683,8 +692,8 @@ public class SsManifestParser implements ParsingLoadable.Parser { } int channelCount = parseRequiredInt(parser, KEY_CHANNELS); int sampleRate = parseRequiredInt(parser, KEY_SAMPLING_RATE); - List codecSpecificData = buildCodecSpecificData( - parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA)); + List codecSpecificData = + buildCodecSpecificData(parser.getAttributeValue(null, KEY_CODEC_PRIVATE_DATA)); if (codecSpecificData.isEmpty() && MimeTypes.AUDIO_AAC.equals(sampleMimeType)) { codecSpecificData = Collections.singletonList( @@ -746,11 +755,15 @@ public class SsManifestParser implements ParsingLoadable.Parser { @Nullable private static String fourCCToMimeType(String fourCC) { - if (fourCC.equalsIgnoreCase("H264") || fourCC.equalsIgnoreCase("X264") - || fourCC.equalsIgnoreCase("AVC1") || fourCC.equalsIgnoreCase("DAVC")) { + if (fourCC.equalsIgnoreCase("H264") + || fourCC.equalsIgnoreCase("X264") + || fourCC.equalsIgnoreCase("AVC1") + || fourCC.equalsIgnoreCase("DAVC")) { return MimeTypes.VIDEO_H264; - } else if (fourCC.equalsIgnoreCase("AAC") || fourCC.equalsIgnoreCase("AACL") - || fourCC.equalsIgnoreCase("AACH") || fourCC.equalsIgnoreCase("AACP")) { + } else if (fourCC.equalsIgnoreCase("AAC") + || fourCC.equalsIgnoreCase("AACL") + || fourCC.equalsIgnoreCase("AACH") + || fourCC.equalsIgnoreCase("AACP")) { return MimeTypes.AUDIO_AAC; } else if (fourCC.equalsIgnoreCase("TTML") || fourCC.equalsIgnoreCase("DFXP")) { return MimeTypes.APPLICATION_TTML; @@ -769,7 +782,5 @@ public class SsManifestParser implements ParsingLoadable.Parser { } return null; } - } - } diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloader.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloader.java index cf06774824..416e4b92a6 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloader.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/offline/SsDownloader.java @@ -129,5 +129,4 @@ public final class SsDownloader extends SegmentDownloader { } return segments; } - } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java index 2e9710dc15..e400630d5e 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/MuxerWrapper.java @@ -201,5 +201,4 @@ import java.nio.ByteBuffer; } return trackTimeUs - minTrackTimeUs <= MAX_TRACK_WRITE_AHEAD_US; } - } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java index 33888226b8..40d6690a30 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/TransformerBaseRenderer.java @@ -16,7 +16,6 @@ package com.google.android.exoplayer2.transformer; - import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import com.google.android.exoplayer2.BaseRenderer; diff --git a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformerTest.java b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformerTest.java index a63db831fc..c29289e4c8 100644 --- a/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformerTest.java +++ b/library/transformer/src/test/java/com/google/android/exoplayer2/transformer/SefSlowMotionVideoSampleTransformerTest.java @@ -236,9 +236,7 @@ public class SefSlowMotionVideoSampleTransformerTest { /** Creates a {@link Format} for an SEF slow motion video track. */ private static Format createSefSlowMotionFormat( - int captureFrameRate, - int inputMaxLayer, - List segments) { + int captureFrameRate, int inputMaxLayer, List segments) { SmtaMetadataEntry smtaMetadataEntry = new SmtaMetadataEntry(captureFrameRate, /* svcTemporalLayerCount= */ inputMaxLayer + 1); SlowMotionData slowMotionData = new SlowMotionData(segments); @@ -259,9 +257,7 @@ public class SefSlowMotionVideoSampleTransformerTest { * @return The output layers. */ private static List getKeptOutputLayers( - SefSlowMotionVideoSampleTransformer sampleTransformer, - int[] layerSequence, - int frameCount) { + SefSlowMotionVideoSampleTransformer sampleTransformer, int[] layerSequence, int frameCount) { List outputLayers = new ArrayList<>(); for (int i = 0; i < frameCount; i++) { int layer = layerSequence[i % layerSequence.length]; @@ -286,9 +282,7 @@ public class SefSlowMotionVideoSampleTransformerTest { * @return The frame output times, in microseconds. */ private static List getOutputTimesUs( - SefSlowMotionVideoSampleTransformer sampleTransformer, - int[] layerSequence, - int frameCount) { + SefSlowMotionVideoSampleTransformer sampleTransformer, int[] layerSequence, int frameCount) { List outputTimesUs = new ArrayList<>(); for (int i = 0; i < frameCount; i++) { int layer = layerSequence[i % layerSequence.length]; diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java index e9da5af5a7..e2428948fa 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/AspectRatioFrameLayout.java @@ -60,9 +60,7 @@ public final class AspectRatioFrameLayout extends FrameLayout { }) public @interface ResizeMode {} - /** - * Either the width or height is decreased to obtain the desired aspect ratio. - */ + /** Either the width or height is decreased to obtain the desired aspect ratio. */ public static final int RESIZE_MODE_FIT = 0; /** * The width is fixed and the height is increased or decreased to obtain the desired aspect ratio. @@ -72,13 +70,9 @@ public final class AspectRatioFrameLayout extends FrameLayout { * The height is fixed and the width is increased or decreased to obtain the desired aspect ratio. */ public static final int RESIZE_MODE_FIXED_HEIGHT = 2; - /** - * The specified aspect ratio is ignored. - */ + /** The specified aspect ratio is ignored. */ public static final int RESIZE_MODE_FILL = 3; - /** - * Either the width or height is increased to obtain the desired aspect ratio. - */ + /** Either the width or height is increased to obtain the desired aspect ratio. */ public static final int RESIZE_MODE_ZOOM = 4; /** @@ -107,8 +101,10 @@ public final class AspectRatioFrameLayout extends FrameLayout { super(context, attrs); resizeMode = RESIZE_MODE_FIT; if (attrs != null) { - TypedArray a = context.getTheme().obtainStyledAttributes(attrs, - R.styleable.AspectRatioFrameLayout, 0, 0); + TypedArray a = + context + .getTheme() + .obtainStyledAttributes(attrs, R.styleable.AspectRatioFrameLayout, 0, 0); try { resizeMode = a.getInt(R.styleable.AspectRatioFrameLayout_resize_mode, RESIZE_MODE_FIT); } finally { @@ -202,7 +198,8 @@ public final class AspectRatioFrameLayout extends FrameLayout { break; } aspectRatioUpdateDispatcher.scheduleUpdate(videoAspectRatio, viewAspectRatio, true); - super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), + super.onMeasure( + MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY)); } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/CaptionStyleCompat.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/CaptionStyleCompat.java index 22c8ca78b1..dc96abb31d 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/CaptionStyleCompat.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/CaptionStyleCompat.java @@ -45,30 +45,18 @@ public final class CaptionStyleCompat { EDGE_TYPE_DEPRESSED }) public @interface EdgeType {} - /** - * Edge type value specifying no character edges. - */ + /** Edge type value specifying no character edges. */ public static final int EDGE_TYPE_NONE = 0; - /** - * Edge type value specifying uniformly outlined character edges. - */ + /** Edge type value specifying uniformly outlined character edges. */ public static final int EDGE_TYPE_OUTLINE = 1; - /** - * Edge type value specifying drop-shadowed character edges. - */ + /** Edge type value specifying drop-shadowed character edges. */ public static final int EDGE_TYPE_DROP_SHADOW = 2; - /** - * Edge type value specifying raised bevel character edges. - */ + /** Edge type value specifying raised bevel character edges. */ public static final int EDGE_TYPE_RAISED = 3; - /** - * Edge type value specifying depressed bevel character edges. - */ + /** Edge type value specifying depressed bevel character edges. */ public static final int EDGE_TYPE_DEPRESSED = 4; - /** - * Use color setting specified by the track and fallback to default caption style. - */ + /** Use color setting specified by the track and fallback to default caption style. */ public static final int USE_TRACK_COLOR_SETTINGS = 1; /** Default caption style. */ @@ -81,36 +69,29 @@ public final class CaptionStyleCompat { Color.WHITE, /* typeface= */ null); - /** - * The preferred foreground color. - */ + /** The preferred foreground color. */ public final int foregroundColor; - /** - * The preferred background color. - */ + /** The preferred background color. */ public final int backgroundColor; - /** - * The preferred window color. - */ + /** The preferred window color. */ public final int windowColor; /** * The preferred edge type. One of: + * *

    - *
  • {@link #EDGE_TYPE_NONE} - *
  • {@link #EDGE_TYPE_OUTLINE} - *
  • {@link #EDGE_TYPE_DROP_SHADOW} - *
  • {@link #EDGE_TYPE_RAISED} - *
  • {@link #EDGE_TYPE_DEPRESSED} + *
  • {@link #EDGE_TYPE_NONE} + *
  • {@link #EDGE_TYPE_OUTLINE} + *
  • {@link #EDGE_TYPE_DROP_SHADOW} + *
  • {@link #EDGE_TYPE_RAISED} + *
  • {@link #EDGE_TYPE_DEPRESSED} *
*/ @EdgeType public final int edgeType; - /** - * The preferred edge color, if using an edge type other than {@link #EDGE_TYPE_NONE}. - */ + /** The preferred edge color, if using an edge type other than {@link #EDGE_TYPE_NONE}. */ public final int edgeColor; /** The preferred typeface, or {@code null} if unspecified. */ @@ -162,8 +143,12 @@ public final class CaptionStyleCompat { private static CaptionStyleCompat createFromCaptionStyleV19( CaptioningManager.CaptionStyle captionStyle) { return new CaptionStyleCompat( - captionStyle.foregroundColor, captionStyle.backgroundColor, Color.TRANSPARENT, - captionStyle.edgeType, captionStyle.edgeColor, captionStyle.getTypeface()); + captionStyle.foregroundColor, + captionStyle.backgroundColor, + Color.TRANSPARENT, + captionStyle.edgeType, + captionStyle.edgeColor, + captionStyle.getTypeface()); } @RequiresApi(21) @@ -178,5 +163,4 @@ public final class CaptionStyleCompat { captionStyle.hasEdgeColor() ? captionStyle.edgeColor : DEFAULT.edgeColor, captionStyle.getTypeface()); } - } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java index 88b2853e97..95d939f157 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/DefaultTimeBar.java @@ -289,19 +289,24 @@ public class DefaultTimeBar extends View implements TimeBar { defaultTouchTargetHeight = Math.max(scrubberDrawable.getMinimumHeight(), defaultTouchTargetHeight); } - barHeight = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_bar_height, - defaultBarHeight); - touchTargetHeight = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_touch_target_height, - defaultTouchTargetHeight); + barHeight = + a.getDimensionPixelSize(R.styleable.DefaultTimeBar_bar_height, defaultBarHeight); + touchTargetHeight = + a.getDimensionPixelSize( + R.styleable.DefaultTimeBar_touch_target_height, defaultTouchTargetHeight); barGravity = a.getInt(R.styleable.DefaultTimeBar_bar_gravity, BAR_GRAVITY_CENTER); - adMarkerWidth = a.getDimensionPixelSize(R.styleable.DefaultTimeBar_ad_marker_width, - defaultAdMarkerWidth); - scrubberEnabledSize = a.getDimensionPixelSize( - R.styleable.DefaultTimeBar_scrubber_enabled_size, defaultScrubberEnabledSize); - scrubberDisabledSize = a.getDimensionPixelSize( - R.styleable.DefaultTimeBar_scrubber_disabled_size, defaultScrubberDisabledSize); - scrubberDraggedSize = a.getDimensionPixelSize( - R.styleable.DefaultTimeBar_scrubber_dragged_size, defaultScrubberDraggedSize); + adMarkerWidth = + a.getDimensionPixelSize( + R.styleable.DefaultTimeBar_ad_marker_width, defaultAdMarkerWidth); + scrubberEnabledSize = + a.getDimensionPixelSize( + R.styleable.DefaultTimeBar_scrubber_enabled_size, defaultScrubberEnabledSize); + scrubberDisabledSize = + a.getDimensionPixelSize( + R.styleable.DefaultTimeBar_scrubber_disabled_size, defaultScrubberDisabledSize); + scrubberDraggedSize = + a.getDimensionPixelSize( + R.styleable.DefaultTimeBar_scrubber_dragged_size, defaultScrubberDraggedSize); int playedColor = a.getInt(R.styleable.DefaultTimeBar_played_color, DEFAULT_PLAYED_COLOR); int scrubberColor = a.getInt(R.styleable.DefaultTimeBar_scrubber_color, DEFAULT_SCRUBBER_COLOR); @@ -309,8 +314,8 @@ public class DefaultTimeBar extends View implements TimeBar { a.getInt(R.styleable.DefaultTimeBar_buffered_color, DEFAULT_BUFFERED_COLOR); int unplayedColor = a.getInt(R.styleable.DefaultTimeBar_unplayed_color, DEFAULT_UNPLAYED_COLOR); - int adMarkerColor = a.getInt(R.styleable.DefaultTimeBar_ad_marker_color, - DEFAULT_AD_MARKER_COLOR); + int adMarkerColor = + a.getInt(R.styleable.DefaultTimeBar_ad_marker_color, DEFAULT_AD_MARKER_COLOR); int playedAdMarkerColor = a.getInt( R.styleable.DefaultTimeBar_played_ad_marker_color, DEFAULT_PLAYED_AD_MARKER_COLOR); @@ -536,10 +541,10 @@ public class DefaultTimeBar extends View implements TimeBar { } @Override - public void setAdGroupTimesMs(@Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups, - int adGroupCount) { - Assertions.checkArgument(adGroupCount == 0 - || (adGroupTimesMs != null && playedAdGroups != null)); + public void setAdGroupTimesMs( + @Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups, int adGroupCount) { + Assertions.checkArgument( + adGroupCount == 0 || (adGroupTimesMs != null && playedAdGroups != null)); this.adGroupCount = adGroupCount; this.adGroupTimesMs = adGroupTimesMs; this.playedAdGroups = playedAdGroups; @@ -666,8 +671,12 @@ public class DefaultTimeBar extends View implements TimeBar { protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMode = MeasureSpec.getMode(heightMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); - int height = heightMode == MeasureSpec.UNSPECIFIED ? touchTargetHeight - : heightMode == MeasureSpec.EXACTLY ? heightSize : Math.min(touchTargetHeight, heightSize); + int height = + heightMode == MeasureSpec.UNSPECIFIED + ? touchTargetHeight + : heightMode == MeasureSpec.EXACTLY + ? heightSize + : Math.min(touchTargetHeight, heightSize); setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), height); updateDrawableState(); } @@ -887,8 +896,9 @@ public class DefaultTimeBar extends View implements TimeBar { long adGroupTimeMs = Util.constrainValue(adGroupTimesMs[i], 0, duration); int markerPositionOffset = (int) (progressBar.width() * adGroupTimeMs / duration) - adMarkerOffset; - int markerLeft = progressBar.left + Math.min(progressBar.width() - adMarkerWidth, - Math.max(0, markerPositionOffset)); + int markerLeft = + progressBar.left + + Math.min(progressBar.width() - adMarkerWidth, Math.max(0, markerPositionOffset)); Paint paint = playedAdGroups[i] ? playedAdMarkerPaint : adMarkerPaint; canvas.drawRect(markerLeft, barTop, markerLeft + adMarkerWidth, barBottom, paint); } @@ -901,8 +911,10 @@ public class DefaultTimeBar extends View implements TimeBar { int playheadX = Util.constrainValue(scrubberBar.right, scrubberBar.left, progressBar.right); int playheadY = scrubberBar.centerY(); if (scrubberDrawable == null) { - int scrubberSize = (scrubbing || isFocused()) ? scrubberDraggedSize - : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize); + int scrubberSize = + (scrubbing || isFocused()) + ? scrubberDraggedSize + : (isEnabled() ? scrubberEnabledSize : scrubberDisabledSize); int playheadRadius = (int) ((scrubberSize * scrubberScale) / 2); canvas.drawCircle(playheadX, playheadY, playheadRadius, scrubberPaint); } else { @@ -918,7 +930,8 @@ public class DefaultTimeBar extends View implements TimeBar { } private void updateDrawableState() { - if (scrubberDrawable != null && scrubberDrawable.isStateful() + if (scrubberDrawable != null + && scrubberDrawable.isStateful() && scrubberDrawable.setState(getDrawableState())) { invalidate(); } @@ -942,7 +955,8 @@ public class DefaultTimeBar extends View implements TimeBar { private long getPositionIncrement() { return keyTimeIncrement == C.TIME_UNSET - ? (duration == C.TIME_UNSET ? 0 : (duration / keyCountIncrement)) : keyTimeIncrement; + ? (duration == C.TIME_UNSET ? 0 : (duration / keyCountIncrement)) + : keyTimeIncrement; } private boolean setDrawableLayoutDirection(Drawable drawable) { diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java index 5037eb4a4e..e21e0aa2dd 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitlePainter.java @@ -43,16 +43,12 @@ import com.google.android.exoplayer2.util.Util; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.RequiresNonNull; -/** - * Paints subtitle {@link Cue}s. - */ +/** Paints subtitle {@link Cue}s. */ /* package */ final class SubtitlePainter { private static final String TAG = "SubtitlePainter"; - /** - * Ratio of inner padding to font size. - */ + /** Ratio of inner padding to font size. */ private static final float INNER_PADDING_RATIO = 0.125f; // Styled dimensions. @@ -71,21 +67,17 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; @Nullable private Alignment cueTextAlignment; @Nullable private Bitmap cueBitmap; private float cueLine; - @Cue.LineType - private int cueLineType; - @Cue.AnchorType - private int cueLineAnchor; + @Cue.LineType private int cueLineType; + @Cue.AnchorType private int cueLineAnchor; private float cuePosition; - @Cue.AnchorType - private int cuePositionAnchor; + @Cue.AnchorType private int cuePositionAnchor; private float cueSize; private float cueBitmapHeight; private int foregroundColor; private int backgroundColor; private int windowColor; private int edgeColor; - @CaptionStyleCompat.EdgeType - private int edgeType; + @CaptionStyleCompat.EdgeType private int edgeType; private float defaultTextSizePx; private float cueTextSizePx; private float bottomPaddingFraction; @@ -137,8 +129,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; * call, and so an instance of this class is able to optimize repeated calls to this method in * which the same parameters are passed. * - * @param cue The cue to draw. - * sizes embedded within the cue should be applied. Otherwise, it is ignored. + * @param cue The cue to draw. sizes embedded within the cue should be applied. Otherwise, it is + * ignored. * @param style The style to use when drawing the cue text. * @param defaultTextSizePx The default text size to use when drawing the text, in pixels. * @param cueTextSizePx The embedded text size of this cue, in pixels. @@ -291,8 +283,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; } Alignment textAlignment = cueTextAlignment == null ? Alignment.ALIGN_CENTER : cueTextAlignment; - textLayout = new StaticLayout(cueText, textPaint, availableWidth, textAlignment, spacingMult, - spacingAdd, true); + textLayout = + new StaticLayout( + cueText, textPaint, availableWidth, textAlignment, spacingMult, spacingAdd, true); int textHeight = textLayout.getHeight(); int textWidth = 0; int lineCount = textLayout.getLineCount(); @@ -364,8 +357,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; } // Update the derived drawing variables. - this.textLayout = new StaticLayout(cueText, textPaint, textWidth, textAlignment, spacingMult, - spacingAdd, true); + this.textLayout = + new StaticLayout( + cueText, textPaint, textWidth, textAlignment, spacingMult, spacingAdd, true); this.edgeLayout = new StaticLayout( cueTextEdge, textPaint, textWidth, textAlignment, spacingMult, spacingAdd, true); @@ -382,8 +376,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; float anchorX = parentLeft + (parentWidth * cuePosition); float anchorY = parentTop + (parentHeight * cueLine); int width = Math.round(parentWidth * cueSize); - int height = cueBitmapHeight != Cue.DIMEN_UNSET ? Math.round(parentHeight * cueBitmapHeight) - : Math.round(width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth())); + int height = + cueBitmapHeight != Cue.DIMEN_UNSET + ? Math.round(parentHeight * cueBitmapHeight) + : Math.round(width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth())); int x = Math.round( cuePositionAnchor == Cue.ANCHOR_TYPE_END @@ -474,5 +470,4 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; // equals methods, so we perform one explicitly here. return first == second || (first != null && first.equals(second)); } - } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java index 62321e2219..c82cac109a 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/SubtitleView.java @@ -235,8 +235,8 @@ public final class SubtitleView extends FrameLayout implements TextOutput { /** * Sets the text size to be a fraction of the view's remaining height after its top and bottom * padding have been subtracted. - *

- * Equivalent to {@code #setFractionalTextSize(fractionOfHeight, false)}. + * + *

Equivalent to {@code #setFractionalTextSize(fractionOfHeight, false)}. * * @param fractionOfHeight A fraction between 0 and 1. */ @@ -249,9 +249,9 @@ public final class SubtitleView extends FrameLayout implements TextOutput { * * @param fractionOfHeight A fraction between 0 and 1. * @param ignorePadding Set to true if {@code fractionOfHeight} should be interpreted as a - * fraction of this view's height ignoring any top and bottom padding. Set to false if - * {@code fractionOfHeight} should be interpreted as a fraction of this view's remaining - * height after the top and bottom padding has been subtracted. + * fraction of this view's height ignoring any top and bottom padding. Set to false if {@code + * fractionOfHeight} should be interpreted as a fraction of this view's remaining height after + * the top and bottom padding has been subtracted. */ public void setFractionalTextSize(float fractionOfHeight, boolean ignorePadding) { setTextSize( @@ -268,8 +268,8 @@ public final class SubtitleView extends FrameLayout implements TextOutput { } /** - * Sets whether styling embedded within the cues should be applied. Enabled by default. - * Overrides any setting made with {@link SubtitleView#setApplyEmbeddedFontSizes}. + * Sets whether styling embedded within the cues should be applied. Enabled by default. Overrides + * any setting made with {@link SubtitleView#setApplyEmbeddedFontSizes}. * * @param applyEmbeddedStyles Whether styling embedded within the cues should be applied. */ @@ -279,8 +279,8 @@ public final class SubtitleView extends FrameLayout implements TextOutput { } /** - * Sets whether font sizes embedded within the cues should be applied. Enabled by default. - * Only takes effect if {@link SubtitleView#setApplyEmbeddedStyles} is set to true. + * Sets whether font sizes embedded within the cues should be applied. Enabled by default. Only + * takes effect if {@link SubtitleView#setApplyEmbeddedStyles} is set to true. * * @param applyEmbeddedFontSizes Whether font sizes embedded within the cues should be applied. */ @@ -310,11 +310,11 @@ public final class SubtitleView extends FrameLayout implements TextOutput { } /** - * Sets the bottom padding fraction to apply when {@link Cue#line} is {@link Cue#DIMEN_UNSET}, - * as a fraction of the view's remaining height after its top and bottom padding have been + * Sets the bottom padding fraction to apply when {@link Cue#line} is {@link Cue#DIMEN_UNSET}, as + * a fraction of the view's remaining height after its top and bottom padding have been * subtracted. - *

- * Note that this padding is applied in addition to any standard view padding. + * + *

Note that this padding is applied in addition to any standard view padding. * * @param bottomPaddingFraction The bottom padding fraction. */ @@ -412,5 +412,4 @@ public final class SubtitleView extends FrameLayout implements TextOutput { } return cue; } - } diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java index 9e3f2e42ff..467394f653 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/TimeBar.java @@ -38,15 +38,13 @@ public interface TimeBar { */ void removeListener(OnScrubListener listener); - /** - * @see View#isEnabled() - */ + /** @see View#isEnabled() */ void setEnabled(boolean enabled); /** * Sets the position increment for key presses and accessibility actions, in milliseconds. - *

- * Clears any increment specified in a preceding call to {@link #setKeyCountIncrement(int)}. + * + *

Clears any increment specified in a preceding call to {@link #setKeyCountIncrement(int)}. * * @param time The time increment, in milliseconds. */ @@ -56,8 +54,8 @@ public interface TimeBar { * Sets the position increment for key presses and accessibility actions, as a number of * increments that divide the duration of the media. For example, passing 20 will cause key * presses to increment/decrement the position by 1/20th of the duration (if known). - *

- * Clears any increment specified in a preceding call to {@link #setKeyTimeIncrement(long)}. + * + *

Clears any increment specified in a preceding call to {@link #setKeyTimeIncrement(long)}. * * @param count The number of increments that divide the duration of the media. */ @@ -102,12 +100,10 @@ public interface TimeBar { * groups. * @param adGroupCount The number of ad groups. */ - void setAdGroupTimesMs(@Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups, - int adGroupCount); + void setAdGroupTimesMs( + @Nullable long[] adGroupTimesMs, @Nullable boolean[] playedAdGroups, int adGroupCount); - /** - * Listener for scrubbing events. - */ + /** Listener for scrubbing events. */ interface OnScrubListener { /** @@ -135,5 +131,4 @@ public interface TimeBar { */ void onScrubStop(TimeBar timeBar, long position, boolean canceled); } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/CommonEncryptionDrmTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/CommonEncryptionDrmTest.java index 0f2c856dd7..8f2d9c6f21 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/CommonEncryptionDrmTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/CommonEncryptionDrmTest.java @@ -40,10 +40,18 @@ public final class CommonEncryptionDrmTest { private static final String[] IDS_VIDEO = new String[] {"1", "2"}; // Seeks help reproduce playback issues in certain devices. - private static final ActionSchedule ACTION_SCHEDULE_WITH_SEEKS = new ActionSchedule.Builder(TAG) - .waitForPlaybackState(Player.STATE_READY).delay(30000).seekAndWait(300000).delay(10000) - .seekAndWait(270000).delay(10000).seekAndWait(200000).delay(10000).seekAndWait(732000) - .build(); + private static final ActionSchedule ACTION_SCHEDULE_WITH_SEEKS = + new ActionSchedule.Builder(TAG) + .waitForPlaybackState(Player.STATE_READY) + .delay(30000) + .seekAndWait(300000) + .delay(10000) + .seekAndWait(270000) + .delay(10000) + .seekAndWait(200000) + .delay(10000) + .seekAndWait(732000) + .build(); @Rule public ActivityTestRule testRule = new ActivityTestRule<>(HostActivity.class); diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashDownloadTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashDownloadTest.java index c14295b027..418cb69176 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashDownloadTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashDownloadTest.java @@ -128,5 +128,4 @@ public final class DashDownloadTest { new MediaItem.Builder().setUri(MANIFEST_URI).setStreamKeys(keys).build(), cacheDataSourceFactory); } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java index c3e82ec33d..495372ab48 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashStreamingTest.java @@ -42,49 +42,75 @@ public final class DashStreamingTest { private static final String TAG = "DashStreamingTest"; - private static final ActionSchedule SEEKING_SCHEDULE = new ActionSchedule.Builder(TAG) - .waitForPlaybackState(Player.STATE_READY) - .delay(10000).seekAndWait(15000) - .delay(10000).seek(30000).seek(31000).seek(32000).seek(33000).seekAndWait(34000) - .delay(1000).pause().delay(1000).play() - .delay(1000).pause().seekAndWait(120000).delay(1000).play() - .build(); - private static final ActionSchedule RENDERER_DISABLING_SCHEDULE = new ActionSchedule.Builder(TAG) - .waitForPlaybackState(Player.STATE_READY) - // Wait 10 seconds, disable the video renderer, wait another 10 seconds and enable it again. - .delay(10000).disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .delay(10000).enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - // Ditto for the audio renderer. - .delay(10000).disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .delay(10000).enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - // Wait 10 seconds, then disable and enable the video renderer 5 times in quick succession. - .delay(10000).disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) - // Ditto for the audio renderer. - .delay(10000).disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) - // Wait 10 seconds, detach the surface, wait another 10 seconds and attach it again. - .delay(10000).clearVideoSurface() - .delay(10000).setVideoSurface() - // Wait 10 seconds, then seek to near end. - .delay(10000).seek(120000) - .build(); + private static final ActionSchedule SEEKING_SCHEDULE = + new ActionSchedule.Builder(TAG) + .waitForPlaybackState(Player.STATE_READY) + .delay(10000) + .seekAndWait(15000) + .delay(10000) + .seek(30000) + .seek(31000) + .seek(32000) + .seek(33000) + .seekAndWait(34000) + .delay(1000) + .pause() + .delay(1000) + .play() + .delay(1000) + .pause() + .seekAndWait(120000) + .delay(1000) + .play() + .build(); + private static final ActionSchedule RENDERER_DISABLING_SCHEDULE = + new ActionSchedule.Builder(TAG) + .waitForPlaybackState(Player.STATE_READY) + // Wait 10 seconds, disable the video renderer, wait another 10 seconds and enable it + // again. + .delay(10000) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .delay(10000) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + // Ditto for the audio renderer. + .delay(10000) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .delay(10000) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + // Wait 10 seconds, then disable and enable the video renderer 5 times in quick + // succession. + .delay(10000) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.VIDEO_RENDERER_INDEX) + // Ditto for the audio renderer. + .delay(10000) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .disableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + .enableRenderer(DashTestRunner.AUDIO_RENDERER_INDEX) + // Wait 10 seconds, detach the surface, wait another 10 seconds and attach it again. + .delay(10000) + .clearVideoSurface() + .delay(10000) + .setVideoSurface() + // Wait 10 seconds, then seek to near end. + .delay(10000) + .seek(120000) + .build(); @Rule public ActivityTestRule testRule = new ActivityTestRule<>(HostActivity.class); @@ -124,8 +150,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.H264_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H264_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_ADAPTIVE) .run(); } @@ -142,8 +168,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H264_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_ADAPTIVE) .run(); } @@ -160,8 +186,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H264_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_CDD_ADAPTIVE) .run(); } @@ -193,8 +219,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.H265_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H265_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H265_CDD_ADAPTIVE) .run(); } @@ -210,8 +236,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H265_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H265_CDD_ADAPTIVE) .run(); } @@ -227,8 +253,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, - DashTestData.H265_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H265_CDD_ADAPTIVE) .run(); } @@ -245,8 +271,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.VP9_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, - DashTestData.VP9_CDD_FIXED) + .setAudioVideoFormats( + DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, DashTestData.VP9_CDD_FIXED) .run(); } @@ -261,8 +287,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.VP9_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, - DashTestData.VP9_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, DashTestData.VP9_CDD_ADAPTIVE) .run(); } @@ -278,8 +304,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, - DashTestData.VP9_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, DashTestData.VP9_CDD_ADAPTIVE) .run(); } @@ -295,8 +321,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, - DashTestData.VP9_CDD_ADAPTIVE) + .setAudioVideoFormats( + DashTestData.VP9_VORBIS_AUDIO_REPRESENTATION_ID, DashTestData.VP9_CDD_ADAPTIVE) .run(); } @@ -314,7 +340,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.H264_23_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_BASELINE_480P_23FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -331,7 +358,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.H264_24_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_BASELINE_480P_24FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -348,7 +376,8 @@ public final class DashStreamingTest { .setManifestUrl(DashTestData.H264_29_MANIFEST) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.AAC_AUDIO_REPRESENTATION_ID, DashTestData.H264_BASELINE_480P_29FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -368,8 +397,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H264, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, - DashTestData.WIDEVINE_H264_CDD_FIXED) + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_CDD_FIXED) .run(); } @@ -387,7 +416,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H264, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_CDD_ADAPTIVE) .run(); } @@ -407,7 +437,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_CDD_ADAPTIVE) .run(); } @@ -427,7 +458,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_CDD_ADAPTIVE) .run(); } @@ -446,8 +478,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H265, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, - DashTestData.WIDEVINE_H265_CDD_FIXED) + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H265_CDD_FIXED) .run(); } @@ -463,7 +495,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H265, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H265_CDD_ADAPTIVE) .run(); } @@ -481,7 +514,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H265_CDD_ADAPTIVE) .run(); } @@ -499,7 +533,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H265_CDD_ADAPTIVE) .run(); } @@ -518,7 +553,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_VP9, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_VP9_CDD_FIXED) .run(); } @@ -535,7 +571,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_VP9, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(true) - .setAudioVideoFormats(DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_VP9_CDD_ADAPTIVE) .run(); } @@ -553,7 +590,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(SEEKING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_VP9_CDD_ADAPTIVE) .run(); } @@ -571,7 +609,8 @@ public final class DashStreamingTest { .setFullPlaybackNoSeeking(false) .setCanIncludeAdditionalVideoFormats(true) .setActionSchedule(RENDERER_DISABLING_SCHEDULE) - .setAudioVideoFormats(DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_VP9_CDD_ADAPTIVE) .run(); } @@ -591,7 +630,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H264, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_BASELINE_480P_23FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -609,7 +649,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H264, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_BASELINE_480P_24FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -627,7 +668,8 @@ public final class DashStreamingTest { .setWidevineInfo(MimeTypes.VIDEO_H264, true) .setFullPlaybackNoSeeking(true) .setCanIncludeAdditionalVideoFormats(false) - .setAudioVideoFormats(DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, + .setAudioVideoFormats( + DashTestData.WIDEVINE_AAC_AUDIO_REPRESENTATION_ID, DashTestData.WIDEVINE_H264_BASELINE_480P_29FPS_VIDEO_REPRESENTATION_ID) .run(); } @@ -681,5 +723,4 @@ public final class DashStreamingTest { MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ false, /* tunneling= */ false); return decoderInfo == null || !decoderInfo.adaptive; } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestData.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestData.java index 4d888867f2..40037baba0 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestData.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestData.java @@ -53,20 +53,24 @@ import com.google.android.exoplayer2.util.Util; public static final String H264_MAIN_240P_VIDEO_REPRESENTATION_ID = "avc-main-240"; public static final String H264_MAIN_480P_VIDEO_REPRESENTATION_ID = "avc-main-480"; // The highest quality H264 format mandated by the Android CDD. - public static final String H264_CDD_FIXED = Util.SDK_INT < 23 - ? H264_BASELINE_480P_VIDEO_REPRESENTATION_ID : H264_MAIN_480P_VIDEO_REPRESENTATION_ID; + public static final String H264_CDD_FIXED = + Util.SDK_INT < 23 + ? H264_BASELINE_480P_VIDEO_REPRESENTATION_ID + : H264_MAIN_480P_VIDEO_REPRESENTATION_ID; // Multiple H264 formats mandated by the Android CDD. Note: The CDD actually mandated main profile // support from API level 23, but we opt to test only from 24 due to known issues on API level 23 // when switching between baseline and main profiles on certain devices. - public static final String[] H264_CDD_ADAPTIVE = Util.SDK_INT < 24 - ? new String[] { - H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, - H264_BASELINE_480P_VIDEO_REPRESENTATION_ID} - : new String[] { - H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, - H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, - H264_MAIN_240P_VIDEO_REPRESENTATION_ID, - H264_MAIN_480P_VIDEO_REPRESENTATION_ID}; + public static final String[] H264_CDD_ADAPTIVE = + Util.SDK_INT < 24 + ? new String[] { + H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, H264_BASELINE_480P_VIDEO_REPRESENTATION_ID + } + : new String[] { + H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, + H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, + H264_MAIN_240P_VIDEO_REPRESENTATION_ID, + H264_MAIN_480P_VIDEO_REPRESENTATION_ID + }; public static final String H264_BASELINE_480P_23FPS_VIDEO_REPRESENTATION_ID = "avc-baseline-480-23"; @@ -82,8 +86,8 @@ import com.google.android.exoplayer2.util.Util; // Multiple H265 formats mandated by the Android CDD. public static final String[] H265_CDD_ADAPTIVE = new String[] { - H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, - H265_BASELINE_360P_VIDEO_REPRESENTATION_ID}; + H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, H265_BASELINE_360P_VIDEO_REPRESENTATION_ID + }; public static final String VP9_VORBIS_AUDIO_REPRESENTATION_ID = "4"; public static final String VP9_180P_VIDEO_REPRESENTATION_ID = "0"; @@ -92,9 +96,7 @@ import com.google.android.exoplayer2.util.Util; public static final String VP9_CDD_FIXED = VP9_360P_VIDEO_REPRESENTATION_ID; // Multiple VP9 formats mandated by the Android CDD. public static final String[] VP9_CDD_ADAPTIVE = - new String[] { - VP9_180P_VIDEO_REPRESENTATION_ID, - VP9_360P_VIDEO_REPRESENTATION_ID}; + new String[] {VP9_180P_VIDEO_REPRESENTATION_ID, VP9_360P_VIDEO_REPRESENTATION_ID}; // Widevine encrypted content representation ids. public static final String WIDEVINE_AAC_AUDIO_REPRESENTATION_ID = "0"; @@ -103,21 +105,25 @@ import com.google.android.exoplayer2.util.Util; public static final String WIDEVINE_H264_MAIN_240P_VIDEO_REPRESENTATION_ID = "4"; public static final String WIDEVINE_H264_MAIN_480P_VIDEO_REPRESENTATION_ID = "5"; // The highest quality H264 format mandated by the Android CDD. - public static final String WIDEVINE_H264_CDD_FIXED = Util.SDK_INT < 23 - ? WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID - : WIDEVINE_H264_MAIN_480P_VIDEO_REPRESENTATION_ID; + public static final String WIDEVINE_H264_CDD_FIXED = + Util.SDK_INT < 23 + ? WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID + : WIDEVINE_H264_MAIN_480P_VIDEO_REPRESENTATION_ID; // Multiple H264 formats mandated by the Android CDD. Note: The CDD actually mandated main profile // support from API level 23, but we opt to test only from 24 due to known issues on API level 23 // when switching between baseline and main profiles on certain devices. - public static final String[] WIDEVINE_H264_CDD_ADAPTIVE = Util.SDK_INT < 24 - ? new String[] { - WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, - WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID} - : new String[] { - WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, - WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, - WIDEVINE_H264_MAIN_240P_VIDEO_REPRESENTATION_ID, - WIDEVINE_H264_MAIN_480P_VIDEO_REPRESENTATION_ID}; + public static final String[] WIDEVINE_H264_CDD_ADAPTIVE = + Util.SDK_INT < 24 + ? new String[] { + WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, + WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID + } + : new String[] { + WIDEVINE_H264_BASELINE_240P_VIDEO_REPRESENTATION_ID, + WIDEVINE_H264_BASELINE_480P_VIDEO_REPRESENTATION_ID, + WIDEVINE_H264_MAIN_240P_VIDEO_REPRESENTATION_ID, + WIDEVINE_H264_MAIN_480P_VIDEO_REPRESENTATION_ID + }; public static final String WIDEVINE_H264_BASELINE_480P_23FPS_VIDEO_REPRESENTATION_ID = "3"; public static final String WIDEVINE_H264_BASELINE_480P_24FPS_VIDEO_REPRESENTATION_ID = "3"; @@ -131,8 +137,9 @@ import com.google.android.exoplayer2.util.Util; // Multiple H265 formats mandated by the Android CDD. public static final String[] WIDEVINE_H265_CDD_ADAPTIVE = new String[] { - WIDEVINE_H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, - WIDEVINE_H265_BASELINE_360P_VIDEO_REPRESENTATION_ID}; + WIDEVINE_H265_BASELINE_288P_VIDEO_REPRESENTATION_ID, + WIDEVINE_H265_BASELINE_360P_VIDEO_REPRESENTATION_ID + }; public static final String WIDEVINE_VP9_AAC_AUDIO_REPRESENTATION_ID = "0"; public static final String WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID = "2"; @@ -142,16 +149,16 @@ import com.google.android.exoplayer2.util.Util; // Multiple VP9 formats mandated by the Android CDD. public static final String[] WIDEVINE_VP9_CDD_ADAPTIVE = new String[] { - WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID, - WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID}; + WIDEVINE_VP9_180P_VIDEO_REPRESENTATION_ID, WIDEVINE_VP9_360P_VIDEO_REPRESENTATION_ID + }; private static final String WIDEVINE_LICENSE_URL = "https://proxy.uat.widevine.com/proxy?provider=widevine_test"; private static final String WIDEVINE_SW_CRYPTO_CONTENT_ID = "&video_id=exoplayer_test_1"; private static final String WIDEVINE_HW_SECURE_DECODE_CONTENT_ID = "&video_id=exoplayer_test_2"; - public static String getWidevineLicenseUrl(boolean videoIdRequiredInLicenseUrl, - boolean useL1Widevine) { + public static String getWidevineLicenseUrl( + boolean videoIdRequiredInLicenseUrl, boolean useL1Widevine) { if (!videoIdRequiredInLicenseUrl) { return WIDEVINE_LICENSE_URL; } else { @@ -164,7 +171,5 @@ import com.google.android.exoplayer2.util.Util; return "https://storage.googleapis.com/exoplayer-test-media-1/gen-4/"; } - private DashTestData() { - } - + private DashTestData() {} } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java index e43b2edb03..f023a73e9c 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java @@ -137,8 +137,8 @@ import java.util.List; public DashTestRunner setCanIncludeAdditionalVideoFormats( boolean canIncludeAdditionalVideoFormats) { - this.canIncludeAdditionalVideoFormats = canIncludeAdditionalVideoFormats - && ALLOW_ADDITIONAL_VIDEO_FORMATS; + this.canIncludeAdditionalVideoFormats = + canIncludeAdditionalVideoFormats && ALLOW_ADDITIONAL_VIDEO_FORMATS; return this; } @@ -165,8 +165,8 @@ import java.util.List; public DashTestRunner setWidevineInfo(String mimeType, boolean videoIdRequiredInLicenseUrl) { this.useL1Widevine = isL1WidevineAvailable(mimeType); - this.widevineLicenseUrl = DashTestData.getWidevineLicenseUrl(videoIdRequiredInLicenseUrl, - useL1Widevine); + this.widevineLicenseUrl = + DashTestData.getWidevineLicenseUrl(videoIdRequiredInLicenseUrl, useL1Widevine); return this; } @@ -190,15 +190,24 @@ import java.util.List; MetricsLogger metricsLogger = MetricsLogger.DEFAULT_FACTORY.create( InstrumentationRegistry.getInstrumentation(), tag, streamName); - return new DashHostedTest(tag, streamName, manifestUrl, metricsLogger, fullPlaybackNoSeeking, - audioFormat, canIncludeAdditionalVideoFormats, isCddLimitedRetry, actionSchedule, - offlineLicenseKeySetId, widevineLicenseUrl, useL1Widevine, dataSourceFactory, + return new DashHostedTest( + tag, + streamName, + manifestUrl, + metricsLogger, + fullPlaybackNoSeeking, + audioFormat, + canIncludeAdditionalVideoFormats, + isCddLimitedRetry, + actionSchedule, + offlineLicenseKeySetId, + widevineLicenseUrl, + useL1Widevine, + dataSourceFactory, videoFormats); } - /** - * A {@link HostedTest} for DASH playback tests. - */ + /** A {@link HostedTest} for DASH playback tests. */ private static final class DashHostedTest extends ExoHostedTest { private final String streamName; @@ -232,11 +241,21 @@ import java.util.List; * @param dataSourceFactory If not null, used to load manifest and media. * @param videoFormats The video formats. */ - private DashHostedTest(String tag, String streamName, String manifestUrl, - MetricsLogger metricsLogger, boolean fullPlaybackNoSeeking, String audioFormat, - boolean canIncludeAdditionalVideoFormats, boolean isCddLimitedRetry, - ActionSchedule actionSchedule, byte[] offlineLicenseKeySetId, String widevineLicenseUrl, - boolean useL1Widevine, DataSource.Factory dataSourceFactory, String... videoFormats) { + private DashHostedTest( + String tag, + String streamName, + String manifestUrl, + MetricsLogger metricsLogger, + boolean fullPlaybackNoSeeking, + String audioFormat, + boolean canIncludeAdditionalVideoFormats, + boolean isCddLimitedRetry, + ActionSchedule actionSchedule, + byte[] offlineLicenseKeySetId, + String widevineLicenseUrl, + boolean useL1Widevine, + DataSource.Factory dataSourceFactory, + String... videoFormats) { super(tag, fullPlaybackNoSeeking); Assertions.checkArgument(!(isCddLimitedRetry && canIncludeAdditionalVideoFormats)); this.streamName = streamName; @@ -248,8 +267,9 @@ import java.util.List; this.widevineLicenseUrl = widevineLicenseUrl; this.useL1Widevine = useL1Widevine; this.dataSourceFactory = dataSourceFactory; - trackSelector = new DashTestTrackSelector(tag, audioFormat, videoFormats, - canIncludeAdditionalVideoFormats); + trackSelector = + new DashTestTrackSelector( + tag, audioFormat, videoFormats, canIncludeAdditionalVideoFormats); if (actionSchedule != null) { setSchedule(actionSchedule); } @@ -303,9 +323,7 @@ import java.util.List; @Override protected MediaSource buildSource( - HostActivity host, - DrmSessionManager drmSessionManager, - FrameLayout overlayFrameLayout) { + HostActivity host, DrmSessionManager drmSessionManager, FrameLayout overlayFrameLayout) { DataSource.Factory dataSourceFactory = this.dataSourceFactory != null ? this.dataSourceFactory @@ -320,14 +338,15 @@ import java.util.List; protected void logMetrics(DecoderCounters audioCounters, DecoderCounters videoCounters) { metricsLogger.logMetric(MetricsLogger.KEY_TEST_NAME, streamName); metricsLogger.logMetric(MetricsLogger.KEY_IS_CDD_LIMITED_RETRY, isCddLimitedRetry); - metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_DROPPED_COUNT, - videoCounters.droppedBufferCount); - metricsLogger.logMetric(MetricsLogger.KEY_MAX_CONSECUTIVE_FRAMES_DROPPED_COUNT, + metricsLogger.logMetric( + MetricsLogger.KEY_FRAMES_DROPPED_COUNT, videoCounters.droppedBufferCount); + metricsLogger.logMetric( + MetricsLogger.KEY_MAX_CONSECUTIVE_FRAMES_DROPPED_COUNT, videoCounters.maxConsecutiveDroppedBufferCount); - metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_SKIPPED_COUNT, - videoCounters.skippedOutputBufferCount); - metricsLogger.logMetric(MetricsLogger.KEY_FRAMES_RENDERED_COUNT, - videoCounters.renderedOutputBufferCount); + metricsLogger.logMetric( + MetricsLogger.KEY_FRAMES_SKIPPED_COUNT, videoCounters.skippedOutputBufferCount); + metricsLogger.logMetric( + MetricsLogger.KEY_FRAMES_RENDERED_COUNT, videoCounters.renderedOutputBufferCount); metricsLogger.close(); } @@ -335,16 +354,22 @@ import java.util.List; protected void assertPassed(DecoderCounters audioCounters, DecoderCounters videoCounters) { if (fullPlaybackNoSeeking) { // We shouldn't have skipped any output buffers. - DecoderCountersUtil - .assertSkippedOutputBufferCount(tag + AUDIO_TAG_SUFFIX, audioCounters, 0); - DecoderCountersUtil - .assertSkippedOutputBufferCount(tag + VIDEO_TAG_SUFFIX, videoCounters, 0); + DecoderCountersUtil.assertSkippedOutputBufferCount( + tag + AUDIO_TAG_SUFFIX, audioCounters, 0); + DecoderCountersUtil.assertSkippedOutputBufferCount( + tag + VIDEO_TAG_SUFFIX, videoCounters, 0); // We allow one fewer output buffer due to the way that MediaCodecRenderer and the // underlying decoders handle the end of stream. This should be tightened up in the future. - DecoderCountersUtil.assertTotalBufferCount(tag + AUDIO_TAG_SUFFIX, audioCounters, - audioCounters.inputBufferCount - 1, audioCounters.inputBufferCount); - DecoderCountersUtil.assertTotalBufferCount(tag + VIDEO_TAG_SUFFIX, videoCounters, - videoCounters.inputBufferCount - 1, videoCounters.inputBufferCount); + DecoderCountersUtil.assertTotalBufferCount( + tag + AUDIO_TAG_SUFFIX, + audioCounters, + audioCounters.inputBufferCount - 1, + audioCounters.inputBufferCount); + DecoderCountersUtil.assertTotalBufferCount( + tag + VIDEO_TAG_SUFFIX, + videoCounters, + videoCounters.inputBufferCount - 1, + videoCounters.inputBufferCount); } try { if (!shouldSkipDroppedOutputBufferPerformanceAssertions()) { @@ -387,7 +412,10 @@ import java.util.List; public boolean includedAdditionalVideoFormats; - private DashTestTrackSelector(String tag, String audioFormatId, String[] videoFormatIds, + private DashTestTrackSelector( + String tag, + String audioFormatId, + String[] videoFormatIds, boolean canIncludeAdditionalVideoFormats) { super( ApplicationProvider.getApplicationContext(), @@ -440,8 +468,9 @@ import java.util.List; // Always select explicitly listed representations. for (String formatId : formatIds) { int trackIndex = getTrackIndex(trackGroup, formatId); - Log.d(tag, "Adding base video format: " - + Format.toLogString(trackGroup.getFormat(trackIndex))); + Log.d( + tag, + "Adding base video format: " + Format.toLogString(trackGroup.getFormat(trackIndex))); trackIndices.add(trackIndex); } @@ -449,8 +478,7 @@ import java.util.List; if (canIncludeAdditionalFormats) { for (int i = 0; i < trackGroup.length; i++) { if (!trackIndices.contains(i) && isFormatHandled(formatSupports[i])) { - Log.d(tag, "Adding extra video format: " - + Format.toLogString(trackGroup.getFormat(i))); + Log.d(tag, "Adding extra video format: " + Format.toLogString(trackGroup.getFormat(i))); trackIndices.add(i); } } @@ -473,7 +501,6 @@ import java.util.List; private static boolean isFormatHandled(int formatSupport) { return RendererCapabilities.getFormatSupport(formatSupport) == C.FORMAT_HANDLED; } - } /** @@ -483,14 +510,12 @@ import java.util.List; @RequiresApi(18) private static final class MediaDrmBuilder { - public static MediaDrm build () { + public static MediaDrm build() { try { return new MediaDrm(WIDEVINE_UUID); } catch (UnsupportedSchemeException e) { throw new IllegalStateException(e); } } - } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java index ce5ebfe303..9d962c281d 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashWidevineOfflineTest.java @@ -221,9 +221,14 @@ public final class DashWidevineOfflineTest { "License duration should be less than 30 sec. Server settings might have changed.") .that(licenseDuration) .isLessThan(30); - ActionSchedule schedule = new ActionSchedule.Builder(TAG) - .waitForPlaybackState(Player.STATE_READY) - .delay(3000).pause().delay(licenseDuration * 1000 + 2000).play().build(); + ActionSchedule schedule = + new ActionSchedule.Builder(TAG) + .waitForPlaybackState(Player.STATE_READY) + .delay(3000) + .pause() + .delay(licenseDuration * 1000 + 2000) + .play() + .build(); // DefaultDrmSessionManager should renew the license and stream play fine testRunner.setActionSchedule(schedule).run(); @@ -231,8 +236,8 @@ public final class DashWidevineOfflineTest { private void downloadLicense() throws IOException { DataSource dataSource = httpDataSourceFactory.createDataSource(); - DashManifest dashManifest = DashUtil.loadManifest(dataSource, - Uri.parse(DashTestData.WIDEVINE_H264_MANIFEST)); + DashManifest dashManifest = + DashUtil.loadManifest(dataSource, Uri.parse(DashTestData.WIDEVINE_H264_MANIFEST)); Format format = DashUtil.loadFormatWithDrmInitData(dataSource, dashManifest.getPeriod(0)); offlineLicenseKeySetId = offlineLicenseHelper.downloadLicense(format); assertThat(offlineLicenseKeySetId).isNotNull(); @@ -244,5 +249,4 @@ public final class DashWidevineOfflineTest { offlineLicenseHelper.releaseLicense(offlineLicenseKeySetId); offlineLicenseKeySetId = null; } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DebugRenderersFactory.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DebugRenderersFactory.java index 01b6ebb190..eb2341a74a 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DebugRenderersFactory.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DebugRenderersFactory.java @@ -253,9 +253,15 @@ import java.util.ArrayList; bufferCount++; long expectedTimestampUs = dequeueTimestamp(); if (expectedTimestampUs != presentationTimeUs) { - throw new IllegalStateException("Expected to dequeue video buffer with presentation " - + "timestamp: " + expectedTimestampUs + ". Instead got: " + presentationTimeUs - + " (Processed buffers since last flush: " + bufferCount + ")."); + throw new IllegalStateException( + "Expected to dequeue video buffer with presentation " + + "timestamp: " + + expectedTimestampUs + + ". Instead got: " + + presentationTimeUs + + " (Processed buffers since last flush: " + + bufferCount + + ")."); } if (outputMediaFormatChanged) { @@ -315,7 +321,5 @@ import java.util.ArrayList; minimumInsertIndex = max(minimumInsertIndex, startIndex); return timestampsList[startIndex - 1]; } - } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java index 67a6a93357..efadf41737 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/EnumerateDecodersTest.java @@ -15,7 +15,6 @@ */ package com.google.android.exoplayer2.playbacktests.gts; - import android.media.MediaCodecInfo.AudioCapabilities; import android.media.MediaCodecInfo.CodecCapabilities; import android.media.MediaCodecInfo.CodecProfileLevel; diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/LogcatMetricsLogger.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/LogcatMetricsLogger.java index ad24c61062..5148de832b 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/LogcatMetricsLogger.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/LogcatMetricsLogger.java @@ -48,5 +48,4 @@ import com.google.android.exoplayer2.util.Log; public void close() { // Do nothing. } - } diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/MetricsLogger.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/MetricsLogger.java index d4bf0a0b83..05aac2fccc 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/MetricsLogger.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/MetricsLogger.java @@ -57,8 +57,6 @@ import android.app.Instrumentation; */ void logMetric(String key, boolean value); - /** - * Closes the logger. - */ + /** Closes the logger. */ void close(); } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java index ae325cfd31..bd3d89ec4d 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java @@ -59,16 +59,11 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** Schedules a sequence of {@link Action}s for execution during a test. */ public final class ActionSchedule { - /** - * Callback to notify listener that the action schedule has finished. - */ + /** Callback to notify listener that the action schedule has finished. */ public interface Callback { - /** - * Called when action schedule finished executing all its actions. - */ + /** Called when action schedule finished executing all its actions. */ void onActionScheduleFinished(); - } private final ActionNode rootNode; @@ -104,9 +99,7 @@ public final class ActionSchedule { rootNode.schedule(player, trackSelector, surface, mainHandler); } - /** - * A builder for {@link ActionSchedule} instances. - */ + /** A builder for {@link ActionSchedule} instances. */ public static final class Builder { private final String tag; @@ -115,9 +108,7 @@ public final class ActionSchedule { private long currentDelayMs; private ActionNode previousNode; - /** - * @param tag A tag to use for logging. - */ + /** @param tag A tag to use for logging. */ public Builder(String tag) { this.tag = tag; rootNode = new ActionNode(new RootAction(tag), 0); @@ -750,12 +741,9 @@ public final class ActionSchedule { repeatIntervalMs); } } - } - /** - * A no-op root action. - */ + /** A no-op root action. */ private static final class RootAction extends Action { public RootAction(String tag) { @@ -769,9 +757,7 @@ public final class ActionSchedule { } } - /** - * An action calling a specified {@link ActionSchedule.Callback}. - */ + /** An action calling a specified {@link ActionSchedule.Callback}. */ private static final class CallbackAction extends Action { @Nullable private Callback callback; @@ -804,5 +790,4 @@ public final class ActionSchedule { // Not triggered. } } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecoderCountersUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecoderCountersUtil.java index a551345d23..19102d9fef 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecoderCountersUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/DecoderCountersUtil.java @@ -32,12 +32,13 @@ public final class DecoderCountersUtil { */ public static int getTotalBufferCount(DecoderCounters counters) { counters.ensureUpdated(); - return counters.skippedOutputBufferCount + counters.droppedBufferCount + return counters.skippedOutputBufferCount + + counters.droppedBufferCount + counters.renderedOutputBufferCount; } - public static void assertSkippedOutputBufferCount(String name, DecoderCounters counters, - int expected) { + public static void assertSkippedOutputBufferCount( + String name, DecoderCounters counters, int expected) { counters.ensureUpdated(); int actual = counters.skippedOutputBufferCount; assertWithMessage( @@ -46,8 +47,8 @@ public final class DecoderCountersUtil { .isEqualTo(expected); } - public static void assertTotalBufferCount(String name, DecoderCounters counters, int minCount, - int maxCount) { + public static void assertTotalBufferCount( + String name, DecoderCounters counters, int minCount, int maxCount) { int actual = getTotalBufferCount(counters); assertWithMessage( "Codec(" @@ -79,8 +80,8 @@ public final class DecoderCountersUtil { .isAtMost(limit); } - public static void assertConsecutiveDroppedBufferLimit(String name, DecoderCounters counters, - int limit) { + public static void assertConsecutiveDroppedBufferLimit( + String name, DecoderCounters counters, int limit) { counters.ensureUpdated(); int actual = counters.maxConsecutiveDroppedBufferCount; assertWithMessage( diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/Dumper.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/Dumper.java index 1c3611b261..90732a07bd 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/Dumper.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/Dumper.java @@ -23,12 +23,11 @@ import java.util.Locale; /** Helper utility to dump field values. */ public final class Dumper { - /** - * Provides custom dump method. - */ + /** Provides custom dump method. */ public interface Dumpable { /** * Dumps the fields of the object using the {@code dumper}. + * * @param dumper The {@link Dumper} to be used to dump fields. */ void dump(Dumper dumper); @@ -90,5 +89,4 @@ public final class Dumper { sb.append(string); return this; } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java index 1d1ee3b765..d0cfe1eaee 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoHostedTest.java @@ -84,19 +84,23 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest { * the test will not assert an expected playing time. */ public ExoHostedTest(String tag, boolean fullPlaybackNoSeeking) { - this(tag, fullPlaybackNoSeeking ? EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS - : EXPECTED_PLAYING_TIME_UNSET, true); + this( + tag, + fullPlaybackNoSeeking + ? EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS + : EXPECTED_PLAYING_TIME_UNSET, + true); } /** * @param tag A tag to use for logging. * @param expectedPlayingTimeMs The expected playing time. If set to a non-negative value, the - * test will assert that the total time spent playing the media was within - * {@link #MAX_PLAYING_TIME_DISCREPANCY_MS} of the specified value. - * {@link #EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS} should be passed to assert that the - * expected playing time equals the duration of the media being played. Else - * {@link #EXPECTED_PLAYING_TIME_UNSET} should be passed to indicate that the test should not - * assert an expected playing time. + * test will assert that the total time spent playing the media was within {@link + * #MAX_PLAYING_TIME_DISCREPANCY_MS} of the specified value. {@link + * #EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS} should be passed to assert that the expected + * playing time equals the duration of the media being played. Else {@link + * #EXPECTED_PLAYING_TIME_UNSET} should be passed to indicate that the test should not assert + * an expected playing time. * @param failOnPlayerError Whether a player error should be considered a test failure. */ public ExoHostedTest(String tag, long expectedPlayingTimeMs, boolean failOnPlayerError) { @@ -161,8 +165,10 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest { } logMetrics(audioDecoderCounters, videoDecoderCounters); if (expectedPlayingTimeMs != EXPECTED_PLAYING_TIME_UNSET) { - long playingTimeToAssertMs = expectedPlayingTimeMs == EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS - ? sourceDurationMs : expectedPlayingTimeMs; + long playingTimeToAssertMs = + expectedPlayingTimeMs == EXPECTED_PLAYING_TIME_MEDIA_DURATION_MS + ? sourceDurationMs + : expectedPlayingTimeMs; // Assert that the playback spanned the correct duration of time. long minAllowedActualPlayingTimeMs = playingTimeToAssertMs - MAX_PLAYING_TIME_DISCREPANCY_MS; long maxAllowedActualPlayingTimeMs = playingTimeToAssertMs + MAX_PLAYING_TIME_DISCREPANCY_MS; @@ -240,17 +246,13 @@ public abstract class ExoHostedTest implements AnalyticsListener, HostedTest { renderersFactory.setExtensionRendererMode(DefaultRenderersFactory.EXTENSION_RENDERER_MODE_OFF); renderersFactory.setAllowedVideoJoiningTimeMs(/* allowedVideoJoiningTimeMs= */ 0); SimpleExoPlayer player = - new SimpleExoPlayer.Builder(host, renderersFactory) - .setTrackSelector(trackSelector) - .build(); + new SimpleExoPlayer.Builder(host, renderersFactory).setTrackSelector(trackSelector).build(); player.setVideoSurface(surface); return player; } protected abstract MediaSource buildSource( - HostActivity host, - DrmSessionManager drmSessionManager, - FrameLayout overlayFrameLayout); + HostActivity host, DrmSessionManager drmSessionManager, FrameLayout overlayFrameLayout); protected void onPlayerErrorInternal(ExoPlaybackException error) { // Do nothing. Interested subclasses may override. diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java index c578eeb7a2..208007f0d4 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java @@ -314,8 +314,8 @@ public final class ExoPlayerTestRunner implements Player.Listener, ActionSchedul /** * Sets the number of times the test runner is expected to reach the {@link Player#STATE_ENDED} - * or {@link Player#STATE_IDLE}. The default is 1. This affects how long - * {@link ExoPlayerTestRunner#blockUntilEnded(long)} waits. + * or {@link Player#STATE_IDLE}. The default is 1. This affects how long {@link + * ExoPlayerTestRunner#blockUntilEnded(long)} waits. * * @param expectedPlayerEndedCount The number of times the player is expected to reach the ended * or idle state. diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java index 865c6eb8d1..6e4cb893c6 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ExtractorAsserts.java @@ -355,10 +355,13 @@ public final class ExtractorAsserts { boolean simulateUnknownLength, boolean simulatePartialReads) throws IOException { - FakeExtractorInput input = new FakeExtractorInput.Builder().setData(data) - .setSimulateIOErrors(simulateIOErrors) - .setSimulateUnknownLength(simulateUnknownLength) - .setSimulatePartialReads(simulatePartialReads).build(); + FakeExtractorInput input = + new FakeExtractorInput.Builder() + .setData(data) + .setSimulateIOErrors(simulateIOErrors) + .setSimulateUnknownLength(simulateUnknownLength) + .setSimulatePartialReads(simulatePartialReads) + .build(); if (sniffFirst) { assertSniff(extractor, input, /* expectedResult= */ true); @@ -453,8 +456,9 @@ public final class ExtractorAsserts { if (!retryFromStartIfLive) { continue; } - boolean isOnDemand = input.getLength() != C.LENGTH_UNSET - || (output.seekMap != null && output.seekMap.getDurationUs() != C.TIME_UNSET); + boolean isOnDemand = + input.getLength() != C.LENGTH_UNSET + || (output.seekMap != null && output.seekMap.getDurationUs() != C.TIME_UNSET); if (isOnDemand) { continue; } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java index 127de246a7..1ed0f4696f 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSet.java @@ -32,9 +32,7 @@ import java.util.Random; */ public final class FakeAdaptiveDataSet extends FakeDataSet { - /** - * Factory for {@link FakeAdaptiveDataSet}s. - */ + /** Factory for {@link FakeAdaptiveDataSet}s. */ public static final class Factory { private final long chunkDurationUs; @@ -67,7 +65,6 @@ public final class FakeAdaptiveDataSet extends FakeDataSet { return new FakeAdaptiveDataSet( trackGroup, mediaDurationUs, chunkDurationUs, bitratePercentStdDev, random); } - } /** {@link MediaChunkIterator} for the chunks defined by a fake adaptive data set. */ @@ -122,13 +119,17 @@ public final class FakeAdaptiveDataSet extends FakeDataSet { * @param trackGroup The {@link TrackGroup} for which the data set is to be created. * @param mediaDurationUs The total duration of the fake data set in microseconds. * @param chunkDurationUs The chunk duration to use in microseconds. - * @param bitratePercentStdDev The standard deviation used to generate the chunk sizes centered + * @param bitratePercentStdDev The standard deviation used to generate the chunk sizes centered * around the average bitrate of the {@link Format}s in the {@link TrackGroup}. The standard * deviation is given in percent (of the average size). * @param random A {@link Random} instance used to generate random chunk sizes. */ - /* package */ FakeAdaptiveDataSet(TrackGroup trackGroup, long mediaDurationUs, - long chunkDurationUs, double bitratePercentStdDev, Random random) { + /* package */ FakeAdaptiveDataSet( + TrackGroup trackGroup, + long mediaDurationUs, + long chunkDurationUs, + double bitratePercentStdDev, + Random random) { this.chunkDurationUs = chunkDurationUs; long lastChunkDurationUs = mediaDurationUs % chunkDurationUs; int fullChunks = (int) (mediaDurationUs / chunkDurationUs); @@ -147,8 +148,12 @@ public final class FakeAdaptiveDataSet extends FakeDataSet { newData.appendReadData((int) (avgChunkLength * bitrateFactors[j])); } if (lastChunkDurationUs > 0) { - int lastChunkLength = (int) (format.bitrate * bitrateFactors[bitrateFactors.length - 1] - * (mediaDurationUs % chunkDurationUs) / (8 * C.MICROS_PER_SECOND)); + int lastChunkLength = + (int) + (format.bitrate + * bitrateFactors[bitrateFactors.length - 1] + * (mediaDurationUs % chunkDurationUs) + / (8 * C.MICROS_PER_SECOND)); newData.appendReadData(lastChunkLength); } } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java index 41dd691329..f6300bc45f 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeChunkSource.java @@ -44,8 +44,8 @@ public class FakeChunkSource implements ChunkSource { protected final FakeAdaptiveDataSet.Factory dataSetFactory; protected final FakeDataSource.Factory dataSourceFactory; - public Factory(FakeAdaptiveDataSet.Factory dataSetFactory, - FakeDataSource.Factory dataSourceFactory) { + public Factory( + FakeAdaptiveDataSet.Factory dataSetFactory, FakeDataSource.Factory dataSourceFactory) { this.dataSetFactory = dataSetFactory; this.dataSourceFactory = dataSourceFactory; } @@ -134,9 +134,18 @@ public class FakeChunkSource implements ChunkSource { DataSpec dataSpec = new DataSpec(Uri.parse(uri), fakeDataChunk.byteOffset, fakeDataChunk.length); int trackType = MimeTypes.getTrackType(selectedFormat.sampleMimeType); - out.chunk = new SingleSampleMediaChunk(dataSource, dataSpec, selectedFormat, - trackSelection.getSelectionReason(), trackSelection.getSelectionData(), startTimeUs, - endTimeUs, chunkIndex, trackType, selectedFormat); + out.chunk = + new SingleSampleMediaChunk( + dataSource, + dataSpec, + selectedFormat, + trackSelection.getSelectionReason(), + trackSelection.getSelectionData(), + startTimeUs, + endTimeUs, + chunkIndex, + trackType, + selectedFormat); } } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java index d432afa3a8..8c2c33388c 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeClock.java @@ -450,6 +450,3 @@ public class FakeClock implements Clock { } } } - - - diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java index 62c2b904f8..336b0f8d4e 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java @@ -115,8 +115,8 @@ public class FakeDataSet { this.action = action; this.data = data; this.length = length; - this.byteOffset = previousSegment == null ? 0 - : previousSegment.byteOffset + previousSegment.length; + this.byteOffset = + previousSegment == null ? 0 : previousSegment.byteOffset + previousSegment.length; } public boolean isErrorSegment() { @@ -126,7 +126,6 @@ public class FakeDataSet { public boolean isActionSegment() { return action != null; } - } private final FakeDataSet dataSet; @@ -158,9 +157,7 @@ public class FakeDataSet { return this; } - /** - * Appends to the underlying data. - */ + /** Appends to the underlying data. */ public FakeData appendReadData(byte[] data) { Assertions.checkState(data.length > 0); segments.add(new Segment(data, getLastSegment())); @@ -168,8 +165,8 @@ public class FakeDataSet { } /** - * Appends a data segment of the specified length. No actual data is available and the - * {@link FakeDataSource} will perform no copy operations when this data is read. + * Appends a data segment of the specified length. No actual data is available and the {@link + * FakeDataSource} will perform no copy operations when this data is read. */ public FakeData appendReadData(int length) { Assertions.checkState(length > 0); @@ -177,17 +174,13 @@ public class FakeDataSet { return this; } - /** - * Appends an error in the underlying data. - */ + /** Appends an error in the underlying data. */ public FakeData appendReadError(IOException exception) { segments.add(new Segment(exception, getLastSegment())); return this; } - /** - * Appends an action. - */ + /** Appends an action. */ public FakeData appendReadAction(Runnable action) { segments.add(new Segment(action, getLastSegment())); return this; @@ -223,7 +216,6 @@ public class FakeDataSet { int count = segments.size(); return count > 0 ? segments.get(count - 1) : null; } - } private final HashMap dataMap; @@ -292,5 +284,4 @@ public class FakeDataSet { } return fakeDatas; } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java index ec03f0443c..0ae6627e8e 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java @@ -39,9 +39,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; */ public class FakeDataSource extends BaseDataSource { - /** - * Factory to create a {@link FakeDataSource}. - */ + /** Factory to create a {@link FakeDataSource}. */ public static class Factory implements DataSource.Factory { protected @MonotonicNonNull FakeDataSet fakeDataSet; @@ -128,8 +126,10 @@ public class FakeDataSource extends BaseDataSource { for (Segment segment : fakeData.getSegments()) { segment.bytesRead = (int) min(max(0, dataSpec.position - scannedLength), segment.length); scannedLength += segment.length; - findingCurrentSegmentIndex &= segment.isErrorSegment() ? segment.exceptionCleared - : (!segment.isActionSegment() && segment.bytesRead == segment.length); + findingCurrentSegmentIndex &= + segment.isErrorSegment() + ? segment.exceptionCleared + : (!segment.isActionSegment() && segment.bytesRead == segment.length); if (findingCurrentSegmentIndex) { currentSegmentIndex++; } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorInput.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorInput.java index cddcd2307a..e7b387cb23 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorInput.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorInput.java @@ -48,15 +48,12 @@ import java.io.IOException; */ public final class FakeExtractorInput implements ExtractorInput { - /** - * Thrown when simulating an {@link IOException}. - */ + /** Thrown when simulating an {@link IOException}. */ public static final class SimulatedIOException extends IOException { public SimulatedIOException(String message) { super(message); } - } private final byte[] data; @@ -72,8 +69,11 @@ public final class FakeExtractorInput implements ExtractorInput { private final SparseBooleanArray failedReadPositions; private final SparseBooleanArray failedPeekPositions; - private FakeExtractorInput(byte[] data, boolean simulateUnknownLength, - boolean simulatePartialReads, boolean simulateIOErrors) { + private FakeExtractorInput( + byte[] data, + boolean simulateUnknownLength, + boolean simulatePartialReads, + boolean simulateIOErrors) { this.data = data; this.simulateUnknownLength = simulateUnknownLength; this.simulatePartialReads = simulatePartialReads; @@ -222,8 +222,13 @@ public final class FakeExtractorInput implements ExtractorInput { throw new EOFException(); } if (position + length > data.length) { - throw new EOFException("Attempted to move past end of data: (" + position + " + " - + length + ") > " + data.length); + throw new EOFException( + "Attempted to move past end of data: (" + + position + + " + " + + length + + ") > " + + data.length); } return true; } @@ -235,7 +240,8 @@ public final class FakeExtractorInput implements ExtractorInput { return requestedLength == 0 ? 0 : Integer.MAX_VALUE; } int targetPosition = position + requestedLength; - if (simulatePartialReads && requestedLength > 1 + if (simulatePartialReads + && requestedLength > 1 && !partiallySatisfiedTargetPositions.get(targetPosition)) { partiallySatisfiedTargetPositions.put(targetPosition, true); return 1; @@ -273,9 +279,7 @@ public final class FakeExtractorInput implements ExtractorInput { return true; } - /** - * Builder of {@link FakeExtractorInput} instances. - */ + /** Builder of {@link FakeExtractorInput} instances. */ public static final class Builder { private byte[] data; @@ -308,10 +312,8 @@ public final class FakeExtractorInput implements ExtractorInput { } public FakeExtractorInput build() { - return new FakeExtractorInput(data, simulateUnknownLength, simulatePartialReads, - simulateIOErrors); + return new FakeExtractorInput( + data, simulateUnknownLength, simulatePartialReads, simulateIOErrors); } - } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java index 6253ae4daa..e33ff382c7 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExtractorOutput.java @@ -106,11 +106,8 @@ public final class FakeExtractorOutput implements ExtractorOutput, Dumper.Dumpab } dumper.add("numberOfTracks", numberOfTracks); for (int i = 0; i < numberOfTracks; i++) { - dumper.startBlock("track " + trackOutputs.keyAt(i)) - .add(trackOutputs.valueAt(i)) - .endBlock(); + dumper.startBlock("track " + trackOutputs.keyAt(i)).add(trackOutputs.valueAt(i)).endBlock(); } dumper.add("tracksEnded", tracksEnded); } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSource.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSource.java index 5807cbdd37..0b973631db 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSource.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeMediaSource.java @@ -317,16 +317,12 @@ public class FakeMediaSource extends BaseMediaSource { return preparedSource; } - /** - * Assert that the source and all periods have been released. - */ + /** Assert that the source and all periods have been released. */ public void assertReleased() { assertThat(releasedSource || !preparedSource).isTrue(); } - /** - * Assert that a media period for the given id has been created. - */ + /** Assert that a media period for the given id has been created. */ public void assertMediaPeriodCreated(MediaPeriodId mediaPeriodId) { assertThat(createdMediaPeriods).contains(mediaPeriodId); } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java index ae4073aa48..dc192e9f41 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTimeline.java @@ -31,9 +31,7 @@ import java.util.Arrays; /** Fake {@link Timeline} which can be setup to return custom {@link TimelineWindowDefinition}s. */ public final class FakeTimeline extends Timeline { - /** - * Definition used to define a {@link FakeTimeline}. - */ + /** Definition used to define a {@link FakeTimeline}. */ public static final class TimelineWindowDefinition { /** Default window duration in microseconds. */ @@ -106,8 +104,8 @@ public final class FakeTimeline extends Timeline { * @param isDynamic Whether the window is dynamic. * @param durationUs The duration of the window in microseconds. */ - public TimelineWindowDefinition(int periodCount, Object id, boolean isSeekable, - boolean isDynamic, long durationUs) { + public TimelineWindowDefinition( + int periodCount, Object id, boolean isSeekable, boolean isDynamic, long durationUs) { this(periodCount, id, isSeekable, isDynamic, durationUs, AdPlaybackState.NONE); } @@ -449,5 +447,4 @@ public final class FakeTimeline extends Timeline { } return windowDefinitions; } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java index a5a88da03e..7d31eb82a3 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeTrackOutput.java @@ -281,5 +281,4 @@ public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable { return result; } } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java index 49c3310d33..49f557cccc 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/HostActivity.java @@ -39,9 +39,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; /** A host activity for performing playback tests. */ public final class HostActivity extends Activity implements SurfaceHolder.Callback { - /** - * Interface for tests that run inside of a {@link HostActivity}. - */ + /** Interface for tests that run inside of a {@link HostActivity}. */ public interface HostedTest { /** @@ -74,11 +72,10 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba /** * Called on the test thread after the test has finished and been stopped. - *

- * Implementations may use this method to assert that test criteria were met. + * + *

Implementations may use this method to assert that test criteria were met. */ void onFinished(); - } private static final String TAG = "HostActivity"; @@ -99,8 +96,8 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba * Executes a {@link HostedTest} inside the host. * * @param hostedTest The test to execute. - * @param timeoutMs The number of milliseconds to wait for the test to finish. If the timeout - * is exceeded then the test will fail. + * @param timeoutMs The number of milliseconds to wait for the test to finish. If the timeout is + * exceeded then the test will fail. */ public void runTest(HostedTest hostedTest, long timeoutMs) { runTest(hostedTest, timeoutMs, /* failOnTimeoutOrForceStop= */ true); @@ -145,8 +142,8 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba hostedTest.onFinished(); Log.d(TAG, "Pass conditions checked."); } else { - String message = "Test force stopped. Activity may have been paused whilst " - + "test was in progress."; + String message = + "Test force stopped. Activity may have been paused whilst " + "test was in progress."; Log.e(TAG, message); if (failOnTimeoutOrForceStop) { fail(message); @@ -171,8 +168,8 @@ public final class HostActivity extends Activity implements SurfaceHolder.Callba requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView( getResources().getIdentifier("exo_testutils_host_activity", "layout", getPackageName())); - surfaceView = findViewById( - getResources().getIdentifier("surface_view", "id", getPackageName())); + surfaceView = + findViewById(getResources().getIdentifier("surface_view", "id", getPackageName())); surfaceView.getHolder().addCallback(this); overlayFrameLayout = findViewById(getResources().getIdentifier("overlay_frame_layout", "id", getPackageName())); diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java index 02fc8d38cd..295091ed2b 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/TestUtil.java @@ -432,5 +432,4 @@ public class TestUtil { buffer.data.flip(); return buffer; } - } diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/WebServerDispatcher.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/WebServerDispatcher.java index 956ea9501e..ee21cea874 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/WebServerDispatcher.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/WebServerDispatcher.java @@ -286,13 +286,11 @@ public class WebServerDispatcher extends Dispatcher { case "gzip": setResponseBody( response, Util.gzip(resourceData), /* chunked= */ resource.resolvesToUnknownLength); - response - .setHeader("Content-Encoding", "gzip"); + response.setHeader("Content-Encoding", "gzip"); break; case "identity": setResponseBody(response, resourceData, /* chunked= */ resource.resolvesToUnknownLength); - response - .setHeader("Content-Encoding", "identity"); + response.setHeader("Content-Encoding", "identity"); break; default: throw new IllegalStateException("Unexpected content coding: " + preferredContentCoding);