From 722e05b8baced6e52b11b43fb8aeedc6a61b01ae Mon Sep 17 00:00:00 2001 From: olly Date: Wed, 20 Jul 2016 02:41:11 -0700 Subject: [PATCH] Some brevity/consistency renaming in source package SmoothStreaming -> Ss MediaPresentationDescription -> DashManifest DashSingleSegmentIndex -> SingleSegmentIndex Moved DASH and Ss manifest classes to matching manifest packages for consistency. For Hls the package is called playlist still, since that's what they're widely known as. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=127925961 --- .../exoplayer2/demo/PlayerActivity.java | 15 ++--- .../source/dash/DashChunkSourceTest.java | 42 ++++++------ .../dash/manifest/DashManifestParserTest.java | 45 +++++++++++++ .../dash/{mpd => manifest}/RangedUriTest.java | 2 +- .../{mpd => manifest}/RepresentationTest.java | 4 +- .../{mpd => manifest}/UrlTemplateTest.java | 2 +- ...ediaPresentationDescriptionParserTest.java | 50 --------------- .../SmoothStreamingManifestParserTest.java | 45 ------------- .../manifest/SsManifestParserTest.java | 44 +++++++++++++ .../source/dash/DashChunkSource.java | 10 +-- .../source/dash/DashMediaPeriod.java | 14 ++-- .../source/dash/DashMediaSource.java | 24 +++---- .../source/dash/DashSegmentIndex.java | 2 +- .../source/dash/DashWrappingSegmentIndex.java | 2 +- .../source/dash/DefaultDashChunkSource.java | 23 ++++--- .../dash/{mpd => manifest}/AdaptationSet.java | 2 +- .../DashManifest.java} | 6 +- .../DashManifestParser.java} | 33 +++++----- .../source/dash/{mpd => manifest}/Period.java | 2 +- .../dash/{mpd => manifest}/RangedUri.java | 2 +- .../{mpd => manifest}/Representation.java | 10 +-- .../dash/{mpd => manifest}/SegmentBase.java | 2 +- .../SingleSegmentIndex.java} | 6 +- .../dash/{mpd => manifest}/UrlTemplate.java | 2 +- .../{mpd => manifest}/UtcTimingElement.java | 2 +- ...kSource.java => DefaultSsChunkSource.java} | 23 +++---- ...ingChunkSource.java => SsChunkSource.java} | 10 +-- ...ingMediaSource.java => SsMediaSource.java} | 64 ++++++++++--------- .../SsManifest.java} | 6 +- .../SsManifestParser.java} | 51 ++++++++------- .../android/exoplayer2/testutil/TestUtil.java | 8 ++- 31 files changed, 274 insertions(+), 279 deletions(-) create mode 100644 library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java rename library/src/androidTest/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/RangedUriTest.java (97%) rename library/src/androidTest/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/RepresentationTest.java (91%) rename library/src/androidTest/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/UrlTemplateTest.java (97%) delete mode 100644 library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParserTest.java delete mode 100644 library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParserTest.java create mode 100644 library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/AdaptationSet.java (94%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd/MediaPresentationDescription.java => manifest/DashManifest.java} (91%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd/MediaPresentationDescriptionParser.java => manifest/DashManifestParser.java} (96%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/Period.java (97%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/RangedUri.java (98%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/Representation.java (96%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/SegmentBase.java (99%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd/DashSingleSegmentIndex.java => manifest/SingleSegmentIndex.java} (89%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/UrlTemplate.java (99%) rename library/src/main/java/com/google/android/exoplayer2/source/dash/{mpd => manifest}/UtcTimingElement.java (94%) rename library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/{DefaultSmoothStreamingChunkSource.java => DefaultSsChunkSource.java} (92%) rename library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/{SmoothStreamingChunkSource.java => SsChunkSource.java} (73%) rename library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/{SmoothStreamingMediaSource.java => SsMediaSource.java} (83%) rename library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/{SmoothStreamingManifest.java => manifest/SsManifest.java} (97%) rename library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/{SmoothStreamingManifestParser.java => manifest/SsManifestParser.java} (93%) diff --git a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java index 00c5084227..50cd15c840 100644 --- a/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java +++ b/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java @@ -43,8 +43,8 @@ import com.google.android.exoplayer2.source.chunk.FormatEvaluator.AdaptiveEvalua import com.google.android.exoplayer2.source.dash.DashMediaSource; import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource; import com.google.android.exoplayer2.source.hls.HlsMediaSource; -import com.google.android.exoplayer2.source.smoothstreaming.DefaultSmoothStreamingChunkSource; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingMediaSource; +import com.google.android.exoplayer2.source.smoothstreaming.DefaultSsChunkSource; +import com.google.android.exoplayer2.source.smoothstreaming.SsMediaSource; import com.google.android.exoplayer2.text.CaptionStyleCompat; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.SubtitleLayout; @@ -349,16 +349,13 @@ public class PlayerActivity extends Activity implements SurfaceHolder.Callback, int type = Util.inferContentType(lastPathSegment); switch (type) { case Util.TYPE_SS: - DefaultSmoothStreamingChunkSource.Factory factory = - new DefaultSmoothStreamingChunkSource.Factory(mediaDataSourceFactory, - formatEvaluatorFactory); - return new SmoothStreamingMediaSource(uri, manifestDataSourceFactory, factory, mainHandler, - eventLogger); + DefaultSsChunkSource.Factory factory = new DefaultSsChunkSource.Factory( + mediaDataSourceFactory, formatEvaluatorFactory); + return new SsMediaSource(uri, manifestDataSourceFactory, factory, mainHandler, eventLogger); case Util.TYPE_DASH: DefaultDashChunkSource.Factory factory2 = new DefaultDashChunkSource.Factory( mediaDataSourceFactory, formatEvaluatorFactory); - return new DashMediaSource(uri, mediaDataSourceFactory, factory2, mainHandler, - eventLogger); + return new DashMediaSource(uri, mediaDataSourceFactory, factory2, mainHandler, eventLogger); case Util.TYPE_HLS: return new HlsMediaSource(uri, mediaDataSourceFactory, formatEvaluatorFactory, mainHandler, eventLogger); diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/DashChunkSourceTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/DashChunkSourceTest.java index 05e02826cd..13eb93096d 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/DashChunkSourceTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/DashChunkSourceTest.java @@ -74,7 +74,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase { } public void testGetAvailableRangeOnLiveWithTimeline() { - MediaPresentationDescription mpd = buildLiveMpdWithTimeline(LIVE_DURATION_MS, 0); + DashManifest mpd = buildLiveMpdWithTimeline(LIVE_DURATION_MS, 0); DashChunkSource chunkSource = buildDashChunkSource(mpd); TimeRange availableRange = chunkSource.getAvailableRange(); checkAvailableRange(availableRange, 0, LIVE_DURATION_MS * 1000); @@ -90,7 +90,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase { } public void testGetSeekRangeOnMultiPeriodLiveWithTimeline() { - MediaPresentationDescription mpd = buildMultiPeriodLiveMpdWithTimeline(); + DashManifest mpd = buildMultiPeriodLiveMpdWithTimeline(); DashChunkSource chunkSource = buildDashChunkSource(mpd); TimeRange availableRange = chunkSource.getAvailableRange(); checkAvailableRange(availableRange, 0, MULTI_PERIOD_LIVE_DURATION_MS * 1000); @@ -113,13 +113,13 @@ public class DashChunkSourceTest extends InstrumentationTestCase { } public void testSegmentRequestSequenceOnMultiPeriodLiveWithTimeline() { - MediaPresentationDescription mpd = buildMultiPeriodLiveMpdWithTimeline(); + DashManifest mpd = buildMultiPeriodLiveMpdWithTimeline(); DashChunkSource chunkSource = buildDashChunkSource(mpd); checkSegmentRequestSequenceOnMultiPeriodLive(chunkSource); } public void testSegmentRequestSequenceOnMultiPeriodLiveWithTemplate() { - MediaPresentationDescription mpd = buildMultiPeriodLiveMpdWithTemplate(); + DashManifest mpd = buildMultiPeriodLiveMpdWithTemplate(); DashChunkSource chunkSource = buildDashChunkSource(mpd); checkSegmentRequestSequenceOnMultiPeriodLive(chunkSource); } @@ -208,30 +208,30 @@ public class DashChunkSourceTest extends InstrumentationTestCase { return Representation.newInstance(null, 0, REGULAR_VIDEO, segmentBase); } - private static MediaPresentationDescription buildMpd(long durationMs, + private static DashManifest buildMpd(long durationMs, List representations, boolean live, boolean limitTimeshiftBuffer) { AdaptationSet adaptationSet = new AdaptationSet(0, AdaptationSet.TYPE_VIDEO, representations); Period period = new Period(null, 0, Collections.singletonList(adaptationSet)); - return new MediaPresentationDescription(AVAILABILITY_START_TIME_MS, durationMs, -1, live, -1, + return new DashManifest(AVAILABILITY_START_TIME_MS, durationMs, -1, live, -1, (limitTimeshiftBuffer) ? LIVE_TIMESHIFT_BUFFER_DEPTH_MS : -1, null, null, Collections.singletonList(period)); } - private static MediaPresentationDescription buildMultiPeriodMpd(long durationMs, + private static DashManifest buildMultiPeriodMpd(long durationMs, List periods, boolean live, boolean limitTimeshiftBuffer) { - return new MediaPresentationDescription(AVAILABILITY_START_TIME_MS, durationMs, -1, live, -1, + return new DashManifest(AVAILABILITY_START_TIME_MS, durationMs, -1, live, -1, (limitTimeshiftBuffer) ? LIVE_TIMESHIFT_BUFFER_DEPTH_MS : -1, null, null, periods); } - private static MediaPresentationDescription buildVodMpd() { + private static DashManifest buildVodMpd() { List representations = new ArrayList<>(); representations.add(buildVodRepresentation(TALL_VIDEO)); representations.add(buildVodRepresentation(WIDE_VIDEO)); return buildMpd(VOD_DURATION_MS, representations, false, false); } - private static MediaPresentationDescription buildMultiPeriodVodMpd() { + private static DashManifest buildMultiPeriodVodMpd() { List periods = new ArrayList<>(); long timeMs = 0; long periodDurationMs = VOD_DURATION_MS; @@ -246,21 +246,21 @@ public class DashChunkSourceTest extends InstrumentationTestCase { return buildMultiPeriodMpd(timeMs, periods, false, false); } - private static MediaPresentationDescription buildLiveMpdWithTimeline(long durationMs, + private static DashManifest buildLiveMpdWithTimeline(long durationMs, long timelineStartTimeMs) { Representation representation = buildSegmentTimelineRepresentation( durationMs - timelineStartTimeMs, timelineStartTimeMs); return buildMpd(durationMs, Collections.singletonList(representation), true, false); } - private static MediaPresentationDescription buildLiveMpdWithTemplate(long durationMs, + private static DashManifest buildLiveMpdWithTemplate(long durationMs, boolean limitTimeshiftBuffer) { Representation representation = buildSegmentTemplateRepresentation(); return buildMpd(durationMs, Collections.singletonList(representation), true, limitTimeshiftBuffer); } - private static MediaPresentationDescription buildMultiPeriodLiveMpdWithTimeline() { + private static DashManifest buildMultiPeriodLiveMpdWithTimeline() { List periods = new ArrayList<>(); long periodStartTimeMs = 0; long periodDurationMs = LIVE_DURATION_MS; @@ -275,7 +275,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase { return buildMultiPeriodMpd(periodDurationMs, periods, true, false); } - private static MediaPresentationDescription buildMultiPeriodLiveMpdWithTemplate() { + private static DashManifest buildMultiPeriodLiveMpdWithTemplate() { List periods = new ArrayList<>(); long periodStartTimeMs = 0; long periodDurationMs = LIVE_DURATION_MS; @@ -290,14 +290,14 @@ public class DashChunkSourceTest extends InstrumentationTestCase { return buildMultiPeriodMpd(MULTI_PERIOD_LIVE_DURATION_MS, periods, true, false); } - private static DashChunkSource buildDashChunkSource(MediaPresentationDescription mpd) { + private static DashChunkSource buildDashChunkSource(DashManifest mpd) { return buildDashChunkSource(mpd, false, 0); } - private static DashChunkSource buildDashChunkSource(MediaPresentationDescription mpd, + private static DashChunkSource buildDashChunkSource(DashManifest mpd, boolean startAtLiveEdge, long liveEdgeLatencyMs) { @SuppressWarnings("unchecked") - ManifestFetcher manifestFetcher = mock(ManifestFetcher.class); + ManifestFetcher manifestFetcher = mock(ManifestFetcher.class); when(manifestFetcher.getManifest()).thenReturn(mpd); DashChunkSource chunkSource = new DashChunkSource(manifestFetcher, mpd, AdaptationSet.TYPE_VIDEO, mock(DataSource.class), null, @@ -331,7 +331,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase { private static void checkLiveEdgeConsistencyWithTimeline(long durationMs, long timelineStartMs, long liveEdgeLatencyMs, long seekPositionMs, long availableRangeStartMs, long availableRangeEndMs, long chunkStartTimeMs, long chunkEndTimeMs) { - MediaPresentationDescription mpd = buildLiveMpdWithTimeline(durationMs, timelineStartMs); + DashManifest mpd = buildLiveMpdWithTimeline(durationMs, timelineStartMs); checkLiveEdgeConsistency(mpd, liveEdgeLatencyMs, seekPositionMs, availableRangeStartMs, availableRangeEndMs, chunkStartTimeMs, chunkEndTimeMs); } @@ -339,7 +339,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase { private static void checkLiveEdgeConsistencyWithTemplateAndUnlimitedTimeshift(long durationMs, long liveEdgeLatencyMs, long availablePositionMs, long availableRangeEndMs, long chunkStartTimeMs, long chunkEndTimeMs) { - MediaPresentationDescription mpd = buildLiveMpdWithTemplate(durationMs, false); + DashManifest mpd = buildLiveMpdWithTemplate(durationMs, false); checkLiveEdgeConsistency(mpd, liveEdgeLatencyMs, availablePositionMs, 0, availableRangeEndMs, chunkStartTimeMs, chunkEndTimeMs); } @@ -347,12 +347,12 @@ public class DashChunkSourceTest extends InstrumentationTestCase { private static void checkLiveEdgeConsistencyWithTemplateAndLimitedTimeshift(long durationMs, long liveEdgeLatencyMs, long seekPositionMs, long availableRangeStartMs, long availableRangeEndMs, long chunkStartTimeMs, long chunkEndTimeMs) { - MediaPresentationDescription mpd = buildLiveMpdWithTemplate(durationMs, true); + DashManifest mpd = buildLiveMpdWithTemplate(durationMs, true); checkLiveEdgeConsistency(mpd, liveEdgeLatencyMs, seekPositionMs, availableRangeStartMs, availableRangeEndMs, chunkStartTimeMs, chunkEndTimeMs); } - private static void checkLiveEdgeConsistency(MediaPresentationDescription mpd, + private static void checkLiveEdgeConsistency(DashManifest mpd, long liveEdgeLatencyMs, long seekPositionMs, long availableRangeStartMs, long availableRangeEndMs, long chunkStartTimeMs, long chunkEndTimeMs) { DashChunkSource chunkSource = buildDashChunkSource(mpd, true, liveEdgeLatencyMs); diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java new file mode 100644 index 0000000000..d547f73c8e --- /dev/null +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParserTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.source.dash.manifest; + +import com.google.android.exoplayer2.testutil.TestUtil; + +import android.net.Uri; +import android.test.InstrumentationTestCase; + +import java.io.IOException; + +/** + * Unit tests for {@link DashManifestParser}. + */ +public class DashManifestParserTest extends InstrumentationTestCase { + + private static final String SAMPLE_MPD_1 = "dash/sample_mpd_1"; + private static final String SAMPLE_MPD_2_UNKNOWN_MIME_TYPE = + "dash/sample_mpd_2_unknown_mime_type"; + + /** + * Simple test to ensure the sample manifests parse without any exceptions being thrown. + */ + public void testParseMediaPresentationDescription() throws IOException { + DashManifestParser parser = new DashManifestParser(); + parser.parse(Uri.parse("https://example.com/test.mpd"), + TestUtil.getInputStream(getInstrumentation(), SAMPLE_MPD_1)); + parser.parse(Uri.parse("https://example.com/test.mpd"), + TestUtil.getInputStream(getInstrumentation(), SAMPLE_MPD_2_UNKNOWN_MIME_TYPE)); + } + +} diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RangedUriTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java similarity index 97% rename from library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RangedUriTest.java rename to library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java index 28821d92e5..b517da127b 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RangedUriTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RangedUriTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import junit.framework.TestCase; diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RepresentationTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RepresentationTest.java similarity index 91% rename from library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RepresentationTest.java rename to library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RepresentationTest.java index 18e8cb7f9f..564585596c 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/RepresentationTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/RepresentationTest.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.Format; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SingleSegmentBase; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase; import com.google.android.exoplayer2.util.MimeTypes; import junit.framework.TestCase; diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplateTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java similarity index 97% rename from library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplateTest.java rename to library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java index d3275a92a2..1959d33172 100644 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplateTest.java +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplateTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import junit.framework.TestCase; diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParserTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParserTest.java deleted file mode 100644 index 366e3ec0bf..0000000000 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParserTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.source.dash.mpd; - -import android.net.Uri; -import android.test.InstrumentationTestCase; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Unit tests for {@link MediaPresentationDescriptionParser}. - */ -public class MediaPresentationDescriptionParserTest extends InstrumentationTestCase { - - private static final String SAMPLE_MPD_1 = "dash/sample_mpd_1"; - private static final String SAMPLE_MPD_2_UNKNOWN_MIME_TYPE = - "dash/sample_mpd_2_unknown_mime_type"; - - public void testParseMediaPresentationDescription() throws IOException { - MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser(); - InputStream inputStream = - getInstrumentation().getContext().getResources().getAssets().open(SAMPLE_MPD_1); - // Simple test to ensure that the sample manifest parses without throwing any exceptions. - parser.parse(Uri.parse("https://example.com/test.mpd"), inputStream); - } - - public void testParseMediaPresentationDescriptionWithUnknownMimeType() throws IOException { - MediaPresentationDescriptionParser parser = new MediaPresentationDescriptionParser(); - InputStream inputStream = getInstrumentation().getContext().getResources().getAssets() - .open(SAMPLE_MPD_2_UNKNOWN_MIME_TYPE); - // Simple test to ensure that the sample manifest with an unknown mime type parses without - // throwing any exceptions. - parser.parse(Uri.parse("https://example.com/test.mpd"), inputStream); - } - -} diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParserTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParserTest.java deleted file mode 100644 index 0e117b759a..0000000000 --- a/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParserTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2016 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.source.smoothstreaming; - -import android.net.Uri; -import android.test.InstrumentationTestCase; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Unit tests for {@link SmoothStreamingManifestParser}. - */ -public class SmoothStreamingManifestParserTest extends InstrumentationTestCase { - - private static final String SAMPLE_ISMC_1 = "smoothstreaming/sample_ismc_1"; - private static final String SAMPLE_ISMC_2 = "smoothstreaming/sample_ismc_2"; - - public void testParseSmoothStreamingManifest() throws IOException { - SmoothStreamingManifestParser parser = new SmoothStreamingManifestParser(); - // Simple test to ensure that the sample manifest parses without throwing any exceptions. - // SystemID UUID in the manifest is not wrapped in braces. - InputStream inputStream1 = - getInstrumentation().getContext().getResources().getAssets().open(SAMPLE_ISMC_1); - parser.parse(Uri.parse("https://example.com/test.ismc"), inputStream1); - // Simple test to ensure that the sample manifest parses without throwing any exceptions. - // SystemID UUID in the manifest is wrapped in braces. - InputStream inputStream2 = - getInstrumentation().getContext().getResources().getAssets().open(SAMPLE_ISMC_2); - parser.parse(Uri.parse("https://example.com/test.ismc"), inputStream2); - } -} diff --git a/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java b/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java new file mode 100644 index 0000000000..57c440a3a7 --- /dev/null +++ b/library/src/androidTest/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.google.android.exoplayer2.source.smoothstreaming.manifest; + +import com.google.android.exoplayer2.testutil.TestUtil; + +import android.net.Uri; +import android.test.InstrumentationTestCase; + +import java.io.IOException; + +/** + * Unit tests for {@link SsManifestParser}. + */ +public final class SsManifestParserTest extends InstrumentationTestCase { + + private static final String SAMPLE_ISMC_1 = "smoothstreaming/sample_ismc_1"; + private static final String SAMPLE_ISMC_2 = "smoothstreaming/sample_ismc_2"; + + /** + * Simple test to ensure the sample manifests parse without any exceptions being thrown. + */ + public void testParseSmoothStreamingManifest() throws IOException { + SsManifestParser parser = new SsManifestParser(); + parser.parse(Uri.parse("https://example.com/test.ismc"), + TestUtil.getInputStream(getInstrumentation(), SAMPLE_ISMC_1)); + parser.parse(Uri.parse("https://example.com/test.ismc"), + TestUtil.getInputStream(getInstrumentation(), SAMPLE_ISMC_2)); + } + +} diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashChunkSource.java index 1015731cfc..17a85d4993 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashChunkSource.java @@ -17,7 +17,7 @@ package com.google.android.exoplayer2.source.dash; import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.chunk.ChunkSource; -import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; +import com.google.android.exoplayer2.source.dash.manifest.DashManifest; import com.google.android.exoplayer2.upstream.Loader; /** @@ -27,12 +27,12 @@ public interface DashChunkSource extends ChunkSource { interface Factory { - DashChunkSource createDashChunkSource(Loader manifestLoader, - MediaPresentationDescription manifest, int periodIndex, int adaptationSetIndex, - TrackGroup trackGroup, int[] tracks, long elapsedRealtimeOffsetMs); + DashChunkSource createDashChunkSource(Loader manifestLoader, DashManifest manifest, + int periodIndex, int adaptationSetIndex, TrackGroup trackGroup, int[] tracks, + long elapsedRealtimeOffsetMs); } - void updateManifest(MediaPresentationDescription newManifest, int periodIndex); + void updateManifest(DashManifest newManifest, int periodIndex); } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java index a9d57127e3..efd977f229 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java @@ -25,10 +25,10 @@ import com.google.android.exoplayer2.source.SequenceableLoader; import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.chunk.ChunkSampleStream; -import com.google.android.exoplayer2.source.dash.mpd.AdaptationSet; -import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; -import com.google.android.exoplayer2.source.dash.mpd.Period; -import com.google.android.exoplayer2.source.dash.mpd.Representation; +import com.google.android.exoplayer2.source.dash.manifest.AdaptationSet; +import com.google.android.exoplayer2.source.dash.manifest.DashManifest; +import com.google.android.exoplayer2.source.dash.manifest.Period; +import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.Loader; @@ -58,11 +58,11 @@ import java.util.List; private CompositeSequenceableLoader sequenceableLoader; private Callback callback; private Allocator allocator; - private MediaPresentationDescription manifest; + private DashManifest manifest; private int index; private Period period; - public DashMediaPeriod(MediaPresentationDescription manifest, int index, + public DashMediaPeriod(DashManifest manifest, int index, DashChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, EventDispatcher eventDispatcher, long elapsedRealtimeOffset, Loader loader) { this.manifest = manifest; @@ -79,7 +79,7 @@ import java.util.List; trackGroupAdaptationSetIndices = trackGroupsAndAdaptationSetIndices.second; } - public void updateManifest(MediaPresentationDescription manifest, int index) { + public void updateManifest(DashManifest manifest, int index) { this.manifest = manifest; this.index = index; period = manifest.getPeriod(index); diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java index 14cad6688c..acb3c4f283 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaSource.java @@ -21,9 +21,9 @@ import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener; import com.google.android.exoplayer2.source.AdaptiveMediaSourceEventListener.EventDispatcher; import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; -import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescriptionParser; -import com.google.android.exoplayer2.source.dash.mpd.UtcTimingElement; +import com.google.android.exoplayer2.source.dash.manifest.DashManifest; +import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser; +import com.google.android.exoplayer2.source.dash.manifest.UtcTimingElement; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.Loader; import com.google.android.exoplayer2.upstream.ParsingLoadable; @@ -59,7 +59,7 @@ public final class DashMediaSource implements MediaSource { private final DashChunkSource.Factory chunkSourceFactory; private final int minLoadableRetryCount; private final EventDispatcher eventDispatcher; - private final MediaPresentationDescriptionParser manifestParser; + private final DashManifestParser manifestParser; private final ManifestCallback manifestCallback; private DataSource dataSource; @@ -68,7 +68,7 @@ public final class DashMediaSource implements MediaSource { private Uri manifestUri; private long manifestLoadStartTimestamp; private long manifestLoadEndTimestamp; - private MediaPresentationDescription manifest; + private DashManifest manifest; private Handler manifestRefreshHandler; private DashMediaPeriod[] periods; private long elapsedRealtimeOffset; @@ -88,7 +88,7 @@ public final class DashMediaSource implements MediaSource { this.chunkSourceFactory = chunkSourceFactory; this.minLoadableRetryCount = minLoadableRetryCount; eventDispatcher = new EventDispatcher(eventHandler, eventListener); - manifestParser = new MediaPresentationDescriptionParser(); + manifestParser = new DashManifestParser(); manifestCallback = new ManifestCallback(); } @@ -138,7 +138,7 @@ public final class DashMediaSource implements MediaSource { // Loadable callbacks. - /* package */ void onManifestLoadCompleted(ParsingLoadable loadable, + /* package */ void onManifestLoadCompleted(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) { eventDispatcher.loadCompleted(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); @@ -162,7 +162,7 @@ public final class DashMediaSource implements MediaSource { } } - /* package */ int onManifestLoadError(ParsingLoadable loadable, + /* package */ int onManifestLoadError(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error) { boolean isFatal = error instanceof ParserException; eventDispatcher.loadError(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, @@ -278,22 +278,22 @@ public final class DashMediaSource implements MediaSource { } private final class ManifestCallback implements - Loader.Callback> { + Loader.Callback> { @Override - public void onLoadCompleted(ParsingLoadable loadable, + public void onLoadCompleted(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs) { onManifestLoadCompleted(loadable, elapsedRealtimeMs, loadDurationMs); } @Override - public void onLoadCanceled(ParsingLoadable loadable, + public void onLoadCanceled(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, boolean released) { DashMediaSource.this.onLoadCanceled(loadable, elapsedRealtimeMs, loadDurationMs); } @Override - public int onLoadError(ParsingLoadable loadable, + public int onLoadError(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error) { return onManifestLoadError(loadable, elapsedRealtimeMs, loadDurationMs, error); } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashSegmentIndex.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashSegmentIndex.java index c32b46f680..2f907dee97 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashSegmentIndex.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashSegmentIndex.java @@ -16,7 +16,7 @@ package com.google.android.exoplayer2.source.dash; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.source.dash.mpd.RangedUri; +import com.google.android.exoplayer2.source.dash.manifest.RangedUri; /** * Indexes the segments within a media stream. diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java index a0b0d424a9..716c9ad844 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DashWrappingSegmentIndex.java @@ -16,7 +16,7 @@ package com.google.android.exoplayer2.source.dash; import com.google.android.exoplayer2.extractor.ChunkIndex; -import com.google.android.exoplayer2.source.dash.mpd.RangedUri; +import com.google.android.exoplayer2.source.dash.manifest.RangedUri; /** * An implementation of {@link DashSegmentIndex} that wraps a {@link ChunkIndex} parsed from a diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 9d3dfdb16b..cc14c31e1a 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -33,9 +33,9 @@ import com.google.android.exoplayer2.source.chunk.FormatEvaluator.Evaluation; import com.google.android.exoplayer2.source.chunk.InitializationChunk; import com.google.android.exoplayer2.source.chunk.MediaChunk; import com.google.android.exoplayer2.source.chunk.SingleSampleMediaChunk; -import com.google.android.exoplayer2.source.dash.mpd.MediaPresentationDescription; -import com.google.android.exoplayer2.source.dash.mpd.RangedUri; -import com.google.android.exoplayer2.source.dash.mpd.Representation; +import com.google.android.exoplayer2.source.dash.manifest.DashManifest; +import com.google.android.exoplayer2.source.dash.manifest.RangedUri; +import com.google.android.exoplayer2.source.dash.manifest.Representation; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.HttpDataSource.InvalidResponseCodeException; @@ -66,9 +66,9 @@ public class DefaultDashChunkSource implements DashChunkSource { } @Override - public DashChunkSource createDashChunkSource(Loader manifestLoader, - MediaPresentationDescription manifest, int periodIndex, int adaptationSetIndex, - TrackGroup trackGroup, int[] tracks, long elapsedRealtimeOffsetMs) { + public DashChunkSource createDashChunkSource(Loader manifestLoader, DashManifest manifest, + int periodIndex, int adaptationSetIndex, TrackGroup trackGroup, int[] tracks, + long elapsedRealtimeOffsetMs) { FormatEvaluator adaptiveEvaluator = tracks.length > 1 ? formatEvaluatorFactory.createFormatEvaluator() : null; DataSource dataSource = dataSourceFactory.createDataSource(); @@ -89,7 +89,7 @@ public class DefaultDashChunkSource implements DashChunkSource { private final long elapsedRealtimeOffsetUs; private final Evaluation evaluation; - private MediaPresentationDescription manifest; + private DashManifest manifest; private boolean lastChunkWasInitialization; private IOException fatalError; @@ -108,10 +108,9 @@ public class DefaultDashChunkSource implements DashChunkSource { * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, specified * as the server's unix time minus the local elapsed time. If unknown, set to 0. */ - public DefaultDashChunkSource(Loader manifestLoader, MediaPresentationDescription manifest, - int periodIndex, int adaptationSetIndex, TrackGroup trackGroup, int[] tracks, - DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator, - long elapsedRealtimeOffsetMs) { + public DefaultDashChunkSource(Loader manifestLoader, DashManifest manifest, int periodIndex, + int adaptationSetIndex, TrackGroup trackGroup, int[] tracks, DataSource dataSource, + FormatEvaluator adaptiveFormatEvaluator, long elapsedRealtimeOffsetMs) { this.manifestLoader = manifestLoader; this.manifest = manifest; this.adaptationSetIndex = adaptationSetIndex; @@ -143,7 +142,7 @@ public class DefaultDashChunkSource implements DashChunkSource { } @Override - public void updateManifest(MediaPresentationDescription newManifest, int periodIndex) { + public void updateManifest(DashManifest newManifest, int periodIndex) { try { manifest = newManifest; long periodDurationUs = getPeriodDurationUs(periodIndex); diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/AdaptationSet.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java similarity index 94% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/AdaptationSet.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java index 144c614d7c..9a0e6499eb 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/AdaptationSet.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/AdaptationSet.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import java.util.Collections; import java.util.List; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescription.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java similarity index 91% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescription.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java index 93342306ea..fefe576d81 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescription.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import android.net.Uri; @@ -23,7 +23,7 @@ import java.util.List; /** * Represents a DASH media presentation description (mpd). */ -public class MediaPresentationDescription { +public class DashManifest { public final long availabilityStartTime; @@ -43,7 +43,7 @@ public class MediaPresentationDescription { private final List periods; - public MediaPresentationDescription(long availabilityStartTime, long duration, long minBufferTime, + public DashManifest(long availabilityStartTime, long duration, long minBufferTime, boolean dynamic, long minUpdatePeriod, long timeShiftBufferDepth, UtcTimingElement utcTiming, Uri location, List periods) { this.availabilityStartTime = availabilityStartTime; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParser.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java similarity index 96% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParser.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java index 77a55b0285..3e1cf1ba4c 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/MediaPresentationDescriptionParser.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; @@ -21,10 +21,10 @@ import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SegmentList; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SegmentTemplate; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SegmentTimelineElement; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SingleSegmentBase; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentList; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTemplate; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SegmentTimelineElement; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase; import com.google.android.exoplayer2.upstream.ParsingLoadable; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.MimeTypes; @@ -55,8 +55,8 @@ import java.util.regex.Pattern; /** * A parser of media presentation description files. */ -public class MediaPresentationDescriptionParser extends DefaultHandler - implements ParsingLoadable.Parser { +public class DashManifestParser extends DefaultHandler + implements ParsingLoadable.Parser { private static final String TAG = "MpdParser"; @@ -66,16 +66,16 @@ public class MediaPresentationDescriptionParser extends DefaultHandler private final XmlPullParserFactory xmlParserFactory; /** - * Equivalent to calling {@code new MediaPresentationDescriptionParser(null)}. + * Equivalent to calling {@code new DashManifestParser(null)}. */ - public MediaPresentationDescriptionParser() { + public DashManifestParser() { this(null); } /** * @param contentId An optional content identifier to include in the parsed manifest. */ - public MediaPresentationDescriptionParser(String contentId) { + public DashManifestParser(String contentId) { this.contentId = contentId; try { xmlParserFactory = XmlPullParserFactory.newInstance(); @@ -87,7 +87,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler // MPD parsing. @Override - public MediaPresentationDescription parse(Uri uri, InputStream inputStream) throws IOException { + public DashManifest parse(Uri uri, InputStream inputStream) throws IOException { try { XmlPullParser xpp = xmlParserFactory.newPullParser(); xpp.setInput(inputStream, null); @@ -102,7 +102,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler } } - protected MediaPresentationDescription parseMediaPresentationDescription(XmlPullParser xpp, + protected DashManifest parseMediaPresentationDescription(XmlPullParser xpp, String baseUrl) throws XmlPullParserException, IOException, ParseException { long availabilityStartTime = parseDateTime(xpp, "availabilityStartTime", -1); long durationMs = parseDuration(xpp, "mediaPresentationDuration", -1); @@ -165,11 +165,10 @@ public class MediaPresentationDescriptionParser extends DefaultHandler dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods); } - protected MediaPresentationDescription buildMediaPresentationDescription( - long availabilityStartTime, long durationMs, long minBufferTimeMs, boolean dynamic, - long minUpdateTimeMs, long timeShiftBufferDepthMs, UtcTimingElement utcTiming, - Uri location, List periods) { - return new MediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs, + protected DashManifest buildMediaPresentationDescription(long availabilityStartTime, + long durationMs, long minBufferTimeMs, boolean dynamic, long minUpdateTimeMs, + long timeShiftBufferDepthMs, UtcTimingElement utcTiming, Uri location, List periods) { + return new DashManifest(availabilityStartTime, durationMs, minBufferTimeMs, dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods); } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Period.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java similarity index 97% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Period.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java index bca0d34f13..1a4d101b4a 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Period.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Period.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import java.util.Collections; import java.util.List; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/RangedUri.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java similarity index 98% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/RangedUri.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java index fbf6cfd3d8..4dc2f21442 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/RangedUri.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/RangedUri.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.UriUtil; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Representation.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java similarity index 96% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Representation.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java index 88e44dcd8c..770aca793c 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/Representation.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/Representation.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.source.dash.DashSegmentIndex; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.MultiSegmentBase; -import com.google.android.exoplayer2.source.dash.mpd.SegmentBase.SingleSegmentBase; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.MultiSegmentBase; +import com.google.android.exoplayer2.source.dash.manifest.SegmentBase.SingleSegmentBase; import android.net.Uri; @@ -156,7 +156,7 @@ public abstract class Representation { public final long contentLength; private final RangedUri indexUri; - private final DashSingleSegmentIndex segmentIndex; + private final SingleSegmentIndex segmentIndex; /** * @param contentId Identifies the piece of content to which this representation belongs. @@ -198,7 +198,7 @@ public abstract class Representation { // 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 DashSingleSegmentIndex(new RangedUri(segmentBase.uri, null, 0, contentLength)); + : new SingleSegmentIndex(new RangedUri(segmentBase.uri, null, 0, contentLength)); } @Override diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/SegmentBase.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java similarity index 99% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/SegmentBase.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java index 957600fbbf..d4f7ae0f0d 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/SegmentBase.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SegmentBase.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.source.dash.DashSegmentIndex; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/DashSingleSegmentIndex.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java similarity index 89% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/DashSingleSegmentIndex.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java index 9075930db6..083046d073 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/DashSingleSegmentIndex.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/SingleSegmentIndex.java @@ -13,21 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import com.google.android.exoplayer2.source.dash.DashSegmentIndex; /** * A {@link DashSegmentIndex} that defines a single segment. */ -/* package */ final class DashSingleSegmentIndex implements DashSegmentIndex { +/* package */ final class SingleSegmentIndex implements DashSegmentIndex { private final RangedUri uri; /** * @param uri A {@link RangedUri} defining the location of the segment data. */ - public DashSingleSegmentIndex(RangedUri uri) { + public SingleSegmentIndex(RangedUri uri) { this.uri = uri; } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplate.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java similarity index 99% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplate.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java index 4caf73a5b8..c47eec90a1 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UrlTemplate.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UrlTemplate.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; import java.util.Locale; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UtcTimingElement.java b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java similarity index 94% rename from library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UtcTimingElement.java rename to library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java index 3aecaf957f..79e7452459 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/dash/mpd/UtcTimingElement.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/dash/manifest/UtcTimingElement.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.dash.mpd; +package com.google.android.exoplayer2.source.dash.manifest; /** * Represents a UTCTiming element. diff --git a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSmoothStreamingChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java similarity index 92% rename from library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSmoothStreamingChunkSource.java rename to library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java index f65a10f26b..1c8acef2d1 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSmoothStreamingChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/DefaultSsChunkSource.java @@ -30,7 +30,8 @@ import com.google.android.exoplayer2.source.chunk.ContainerMediaChunk; import com.google.android.exoplayer2.source.chunk.FormatEvaluator; import com.google.android.exoplayer2.source.chunk.FormatEvaluator.Evaluation; import com.google.android.exoplayer2.source.chunk.MediaChunk; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.StreamElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement; import com.google.android.exoplayer2.upstream.DataSource; import com.google.android.exoplayer2.upstream.DataSpec; import com.google.android.exoplayer2.upstream.Loader; @@ -43,11 +44,11 @@ import java.util.Arrays; import java.util.List; /** - * A default {@link SmoothStreamingChunkSource} implementation. + * A default {@link SsChunkSource} implementation. */ -public class DefaultSmoothStreamingChunkSource implements SmoothStreamingChunkSource { +public class DefaultSsChunkSource implements SsChunkSource { - public static final class Factory implements SmoothStreamingChunkSource.Factory { + public static final class Factory implements SsChunkSource.Factory { private final FormatEvaluator.Factory formatEvaluatorFactory; private final DataSource.Factory dataSourceFactory; @@ -59,13 +60,13 @@ public class DefaultSmoothStreamingChunkSource implements SmoothStreamingChunkSo } @Override - public SmoothStreamingChunkSource createChunkSource(Loader manifestLoader, - SmoothStreamingManifest manifest, int elementIndex, TrackGroup trackGroup, int[] tracks, + public SsChunkSource createChunkSource(Loader manifestLoader, SsManifest manifest, + int elementIndex, TrackGroup trackGroup, int[] tracks, TrackEncryptionBox[] trackEncryptionBoxes) { FormatEvaluator adaptiveEvaluator = tracks.length > 1 ? formatEvaluatorFactory.createFormatEvaluator() : null; DataSource dataSource = dataSourceFactory.createDataSource(); - return new DefaultSmoothStreamingChunkSource(manifestLoader, manifest, elementIndex, + return new DefaultSsChunkSource(manifestLoader, manifest, elementIndex, trackGroup, tracks, dataSource, adaptiveEvaluator, trackEncryptionBoxes); } @@ -82,7 +83,7 @@ public class DefaultSmoothStreamingChunkSource implements SmoothStreamingChunkSo private final Evaluation evaluation; private final FormatEvaluator adaptiveFormatEvaluator; - private SmoothStreamingManifest manifest; + private SsManifest manifest; private int currentManifestChunkOffset; private IOException fatalError; @@ -97,8 +98,8 @@ public class DefaultSmoothStreamingChunkSource implements SmoothStreamingChunkSo * @param adaptiveFormatEvaluator For adaptive tracks, selects from the available formats. * @param trackEncryptionBoxes Track encryption boxes for the stream. */ - public DefaultSmoothStreamingChunkSource(Loader manifestLoader, SmoothStreamingManifest manifest, - int elementIndex, TrackGroup trackGroup, int[] tracks, DataSource dataSource, + public DefaultSsChunkSource(Loader manifestLoader, SsManifest manifest, int elementIndex, + TrackGroup trackGroup, int[] tracks, DataSource dataSource, FormatEvaluator adaptiveFormatEvaluator, TrackEncryptionBox[] trackEncryptionBoxes) { this.manifestLoader = manifestLoader; this.manifest = manifest; @@ -136,7 +137,7 @@ public class DefaultSmoothStreamingChunkSource implements SmoothStreamingChunkSo } @Override - public void updateManifest(SmoothStreamingManifest newManifest) { + public void updateManifest(SsManifest newManifest) { StreamElement currentElement = manifest.streamElements[elementIndex]; int currentElementChunkCount = currentElement.chunkCount; StreamElement newElement = newManifest.streamElements[elementIndex]; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingChunkSource.java b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsChunkSource.java similarity index 73% rename from library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingChunkSource.java rename to library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsChunkSource.java index 7772a28e5f..b43961a347 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingChunkSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsChunkSource.java @@ -18,21 +18,21 @@ package com.google.android.exoplayer2.source.smoothstreaming; import com.google.android.exoplayer2.extractor.mp4.TrackEncryptionBox; import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.chunk.ChunkSource; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; import com.google.android.exoplayer2.upstream.Loader; /** * A {@link ChunkSource} for SmoothStreaming. */ -public interface SmoothStreamingChunkSource extends ChunkSource { +public interface SsChunkSource extends ChunkSource { interface Factory { - SmoothStreamingChunkSource createChunkSource(Loader manifestLoader, - SmoothStreamingManifest manifest, int elementIndex, TrackGroup trackGroup, int[] tracks, - TrackEncryptionBox[] trackEncryptionBoxes); + SsChunkSource createChunkSource(Loader manifestLoader, SsManifest manifest, int elementIndex, + TrackGroup trackGroup, int[] tracks, TrackEncryptionBox[] trackEncryptionBoxes); } - void updateManifest(SmoothStreamingManifest newManifest); + void updateManifest(SsManifest newManifest); } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java similarity index 83% rename from library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingMediaSource.java rename to library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java index c1c5bee8c6..cbe0f5c7e0 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaSource.java @@ -29,8 +29,10 @@ import com.google.android.exoplayer2.source.SequenceableLoader; import com.google.android.exoplayer2.source.TrackGroup; import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.source.chunk.ChunkSampleStream; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.ProtectionElement; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.StreamElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifestParser; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.upstream.Allocator; import com.google.android.exoplayer2.upstream.DataSource; @@ -51,9 +53,9 @@ import java.util.List; /** * A SmoothStreaming {@link MediaSource}. */ -public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSource, - SequenceableLoader.Callback>, - Loader.Callback> { +public final class SsMediaSource implements MediaPeriod, MediaSource, + SequenceableLoader.Callback>, + Loader.Callback> { /** * The default minimum number of times to retry loading data prior to failing. @@ -65,18 +67,18 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc private final Uri manifestUri; private final DataSource.Factory dataSourceFactory; - private final SmoothStreamingChunkSource.Factory chunkSourceFactory; + private final SsChunkSource.Factory chunkSourceFactory; private final int minLoadableRetryCount; private final EventDispatcher eventDispatcher; - private final SmoothStreamingManifestParser manifestParser; + private final SsManifestParser manifestParser; private DataSource manifestDataSource; private Loader manifestLoader; - private ChunkSampleStream[] sampleStreams; + private ChunkSampleStream[] sampleStreams; private CompositeSequenceableLoader sequenceableLoader; private long manifestLoadStartTimestamp; - private SmoothStreamingManifest manifest; + private SsManifest manifest; private Callback callback; private Allocator allocator; @@ -87,15 +89,15 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc private TrackGroupArray trackGroups; private int[] trackGroupElementIndices; - public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, - SmoothStreamingChunkSource.Factory chunkSourceFactory, Handler eventHandler, + public SsMediaSource(Uri manifestUri, DataSource.Factory manifestDataSourceFactory, + SsChunkSource.Factory chunkSourceFactory, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { this(manifestUri, manifestDataSourceFactory, chunkSourceFactory, DEFAULT_MIN_LOADABLE_RETRY_COUNT, eventHandler, eventListener); } - public SmoothStreamingMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, - SmoothStreamingChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, + public SsMediaSource(Uri manifestUri, DataSource.Factory dataSourceFactory, + SsChunkSource.Factory chunkSourceFactory, int minLoadableRetryCount, Handler eventHandler, AdaptiveMediaSourceEventListener eventListener) { this.manifestUri = Util.toLowerInvariant(manifestUri.getLastPathSegment()).equals("manifest") ? manifestUri : Uri.withAppendedPath(manifestUri, "Manifest"); @@ -103,7 +105,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc this.chunkSourceFactory = chunkSourceFactory; this.minLoadableRetryCount = minLoadableRetryCount; this.eventDispatcher = new EventDispatcher(eventHandler, eventListener); - manifestParser = new SmoothStreamingManifestParser(); + manifestParser = new SsManifestParser(); } // MediaSource implementation. @@ -162,12 +164,12 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc public SampleStream[] selectTracks(List oldStreams, List newSelections, long positionUs) { int newEnabledSourceCount = sampleStreams.length + newSelections.size() - oldStreams.size(); - ChunkSampleStream[] newSampleStreams = + ChunkSampleStream[] newSampleStreams = newSampleStreamArray(newEnabledSourceCount); int newEnabledSourceIndex = 0; // Iterate over currently enabled streams, either releasing them or adding them to the new list. - for (ChunkSampleStream sampleStream : sampleStreams) { + for (ChunkSampleStream sampleStream : sampleStreams) { if (oldStreams.contains(sampleStream)) { sampleStream.release(); } else { @@ -206,7 +208,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc @Override public long getBufferedPositionUs() { long bufferedPositionUs = Long.MAX_VALUE; - for (ChunkSampleStream sampleStream : sampleStreams) { + for (ChunkSampleStream sampleStream : sampleStreams) { long rendererBufferedPositionUs = sampleStream.getBufferedPositionUs(); if (rendererBufferedPositionUs != C.END_OF_SOURCE_US) { bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs); @@ -217,7 +219,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc @Override public long seekToUs(long positionUs) { - for (ChunkSampleStream sampleStream : sampleStreams) { + for (ChunkSampleStream sampleStream : sampleStreams) { sampleStream.seekToUs(positionUs); } return positionUs; @@ -231,7 +233,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc manifestLoader = null; } if (sampleStreams != null) { - for (ChunkSampleStream sampleStream : sampleStreams) { + for (ChunkSampleStream sampleStream : sampleStreams) { sampleStream.release(); } sampleStreams = null; @@ -256,15 +258,15 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc @Override public void onContinueLoadingRequested( - ChunkSampleStream sampleStream) { + ChunkSampleStream sampleStream) { callback.onContinueLoadingRequested(this); } // Loader.Callback implementation @Override - public void onLoadCompleted(ParsingLoadable loadable, - long elapsedRealtimeMs, long loadDurationMs) { + public void onLoadCompleted(ParsingLoadable loadable, long elapsedRealtimeMs, + long loadDurationMs) { eventDispatcher.loadCompleted(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); manifest = loadable.getResult(); @@ -281,7 +283,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc prepared = true; callback.onPeriodPrepared(this); } else { - for (ChunkSampleStream sampleStream : sampleStreams) { + for (ChunkSampleStream sampleStream : sampleStreams) { sampleStream.getChunkSource().updateManifest(manifest); } callback.onContinueLoadingRequested(this); @@ -290,14 +292,14 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc } @Override - public void onLoadCanceled(ParsingLoadable loadable, - long elapsedRealtimeMs, long loadDurationMs, boolean released) { + public void onLoadCanceled(ParsingLoadable loadable, long elapsedRealtimeMs, + long loadDurationMs, boolean released) { eventDispatcher.loadCompleted(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded()); } @Override - public int onLoadError(ParsingLoadable loadable, long elapsedRealtimeMs, + public int onLoadError(ParsingLoadable loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error) { boolean isFatal = error instanceof ParserException; eventDispatcher.loadError(loadable.dataSpec, loadable.type, elapsedRealtimeMs, loadDurationMs, @@ -322,13 +324,13 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc } private void startLoadingManifest() { - ParsingLoadable loadable = new ParsingLoadable<>(manifestDataSource, + ParsingLoadable loadable = new ParsingLoadable<>(manifestDataSource, manifestUri, C.DATA_TYPE_MANIFEST, manifestParser); long elapsedRealtimeMs = manifestLoader.startLoading(loadable, this, minLoadableRetryCount); eventDispatcher.loadStarted(loadable.dataSpec, loadable.type, elapsedRealtimeMs); } - private void buildTrackGroups(SmoothStreamingManifest manifest) { + private void buildTrackGroups(SsManifest manifest) { int trackGroupCount = 0; trackGroupElementIndices = new int[manifest.streamElements.length]; TrackGroup[] trackGroupArray = new TrackGroup[manifest.streamElements.length]; @@ -350,11 +352,11 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc trackGroups = new TrackGroupArray(trackGroupArray); } - private ChunkSampleStream buildSampleStream(TrackSelection selection, + private ChunkSampleStream buildSampleStream(TrackSelection selection, long positionUs) { int[] selectedTracks = selection.getTracks(); int streamElementIndex = trackGroupElementIndices[selection.group]; - SmoothStreamingChunkSource chunkSource = chunkSourceFactory.createChunkSource(manifestLoader, + SsChunkSource chunkSource = chunkSourceFactory.createChunkSource(manifestLoader, manifest, streamElementIndex, trackGroups.get(selection.group), selectedTracks, trackEncryptionBoxes); return new ChunkSampleStream<>(manifest.streamElements[streamElementIndex].type, chunkSource, @@ -362,7 +364,7 @@ public final class SmoothStreamingMediaSource implements MediaPeriod, MediaSourc } @SuppressWarnings("unchecked") - private static ChunkSampleStream[] newSampleStreamArray(int length) { + private static ChunkSampleStream[] newSampleStreamArray(int length) { return new ChunkSampleStream[length]; } diff --git a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifest.java b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java similarity index 97% rename from library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifest.java rename to library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java index c5b2f3dd9f..01a59530d6 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifest.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.smoothstreaming; +package com.google.android.exoplayer2.source.smoothstreaming.manifest; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; @@ -32,7 +32,7 @@ import java.util.UUID; * @see * IIS Smooth Streaming Client Manifest Format */ -public class SmoothStreamingManifest { +public class SsManifest { /** * The client manifest major version. @@ -92,7 +92,7 @@ public class SmoothStreamingManifest { * protected. * @param streamElements The contained stream elements. */ - public SmoothStreamingManifest(int majorVersion, int minorVersion, long timescale, long duration, + public SsManifest(int majorVersion, int minorVersion, long timescale, long duration, long dvrWindowLength, int lookAheadCount, boolean isLive, ProtectionElement protectionElement, StreamElement[] streamElements) { this.majorVersion = majorVersion; diff --git a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParser.java b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java similarity index 93% rename from library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParser.java rename to library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java index 6288de80bd..db99636205 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/SmoothStreamingManifestParser.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.google.android.exoplayer2.source.smoothstreaming; +package com.google.android.exoplayer2.source.smoothstreaming.manifest; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.Format; @@ -21,8 +21,8 @@ import com.google.android.exoplayer2.ParserException; import com.google.android.exoplayer2.drm.DrmInitData; import com.google.android.exoplayer2.drm.DrmInitData.SchemeData; import com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.ProtectionElement; -import com.google.android.exoplayer2.source.smoothstreaming.SmoothStreamingManifest.StreamElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.ProtectionElement; +import com.google.android.exoplayer2.source.smoothstreaming.manifest.SsManifest.StreamElement; import com.google.android.exoplayer2.upstream.ParsingLoadable; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.CodecSpecificDataUtil; @@ -52,12 +52,11 @@ import java.util.UUID; * @see * IIS Smooth Streaming Client Manifest Format */ -public class SmoothStreamingManifestParser implements - ParsingLoadable.Parser { +public class SsManifestParser implements ParsingLoadable.Parser { private final XmlPullParserFactory xmlParserFactory; - public SmoothStreamingManifestParser() { + public SsManifestParser() { try { xmlParserFactory = XmlPullParserFactory.newInstance(); } catch (XmlPullParserException e) { @@ -66,13 +65,13 @@ public class SmoothStreamingManifestParser implements } @Override - public SmoothStreamingManifest parse(Uri uri, InputStream inputStream) throws IOException { + public SsManifest parse(Uri uri, InputStream inputStream) throws IOException { try { XmlPullParser xmlParser = xmlParserFactory.newPullParser(); xmlParser.setInput(inputStream, null); - SmoothStreamMediaParser smoothStreamMediaParser = - new SmoothStreamMediaParser(null, uri.toString()); - return (SmoothStreamingManifest) smoothStreamMediaParser.parse(xmlParser); + SmoothStreamingMediaParser smoothStreamingMediaParser = + new SmoothStreamingMediaParser(null, uri.toString()); + return (SsManifest) smoothStreamingMediaParser.parse(xmlParser); } catch (XmlPullParserException e) { throw new ParserException(e); } @@ -163,12 +162,12 @@ public class SmoothStreamingManifestParser implements } private ElementParser newChildParser(ElementParser parent, String name, String baseUri) { - if (TrackElementParser.TAG.equals(name)) { - return new TrackElementParser(parent, baseUri); - } else if (ProtectionElementParser.TAG.equals(name)) { - return new ProtectionElementParser(parent, baseUri); - } else if (StreamElementParser.TAG.equals(name)) { - return new StreamElementParser(parent, baseUri); + if (QualityLevelParser.TAG.equals(name)) { + return new QualityLevelParser(parent, baseUri); + } else if (ProtectionParser.TAG.equals(name)) { + return new ProtectionParser(parent, baseUri); + } else if (StreamIndexParser.TAG.equals(name)) { + return new StreamIndexParser(parent, baseUri); } return null; } @@ -322,7 +321,7 @@ public class SmoothStreamingManifestParser implements } - private static class SmoothStreamMediaParser extends ElementParser { + private static class SmoothStreamingMediaParser extends ElementParser { public static final String TAG = "SmoothStreamingMedia"; @@ -345,7 +344,7 @@ public class SmoothStreamingManifestParser implements private boolean isLive; private ProtectionElement protectionElement; - public SmoothStreamMediaParser(ElementParser parent, String baseUri) { + public SmoothStreamingMediaParser(ElementParser parent, String baseUri) { super(parent, baseUri, TAG); lookAheadCount = -1; protectionElement = null; @@ -387,13 +386,13 @@ public class SmoothStreamingManifestParser implements } } } - return new SmoothStreamingManifest(majorVersion, minorVersion, timescale, duration, - dvrWindowLength, lookAheadCount, isLive, protectionElement, streamElementArray); + return new SsManifest(majorVersion, minorVersion, timescale, duration, dvrWindowLength, + lookAheadCount, isLive, protectionElement, streamElementArray); } } - private static class ProtectionElementParser extends ElementParser { + private static class ProtectionParser extends ElementParser { public static final String TAG = "Protection"; public static final String TAG_PROTECTION_HEADER = "ProtectionHeader"; @@ -404,7 +403,7 @@ public class SmoothStreamingManifestParser implements private UUID uuid; private byte[] initData; - public ProtectionElementParser(ElementParser parent, String baseUri) { + public ProtectionParser(ElementParser parent, String baseUri) { super(parent, baseUri, TAG); } @@ -450,7 +449,7 @@ public class SmoothStreamingManifestParser implements } } - private static class StreamElementParser extends ElementParser { + private static class StreamIndexParser extends ElementParser { public static final String TAG = "StreamIndex"; private static final String TAG_STREAM_FRAGMENT = "c"; @@ -492,7 +491,7 @@ public class SmoothStreamingManifestParser implements private long lastChunkDuration; - public StreamElementParser(ElementParser parent, String baseUri) { + public StreamIndexParser(ElementParser parent, String baseUri) { super(parent, baseUri, TAG); this.baseUri = baseUri; formats = new LinkedList<>(); @@ -599,7 +598,7 @@ public class SmoothStreamingManifestParser implements } - private static class TrackElementParser extends ElementParser { + private static class QualityLevelParser extends ElementParser { public static final String TAG = "QualityLevel"; @@ -616,7 +615,7 @@ public class SmoothStreamingManifestParser implements private Format format; - public TrackElementParser(ElementParser parent, String baseUri) { + public QualityLevelParser(ElementParser parent, String baseUri) { super(parent, baseUri, TAG); } 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 ed08f3bff0..5d7c0f80c0 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 @@ -180,8 +180,12 @@ public class TestUtil { public static byte[] getByteArray(Instrumentation instrumentation, String fileName) throws IOException { - InputStream is = instrumentation.getContext().getResources().getAssets().open(fileName); - return Util.toByteArray(is); + return Util.toByteArray(getInputStream(instrumentation, fileName)); + } + + public static InputStream getInputStream(Instrumentation instrumentation, String fileName) + throws IOException { + return instrumentation.getContext().getResources().getAssets().open(fileName); } public static String getString(Instrumentation instrumentation, String fileName)