Commit 7ce81251 by olly Committed by Oliver Woodman

Split DASH into a separate module

Issue: #2139

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=150762237
parent b1a2ae18
Showing with 145 additions and 5 deletions
...@@ -27,6 +27,7 @@ android { ...@@ -27,6 +27,7 @@ android {
dependencies { dependencies {
compile project(':library-core') compile project(':library-core')
compile project(':library-dash')
compile project(':library-hls') compile project(':library-hls')
compile project(':library-smoothstreaming') compile project(':library-smoothstreaming')
compile project(':library-ui') compile project(':library-ui')
......
// Copyright (C) 2017 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.
apply plugin: 'com.android.library'
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
}
sourceSets {
androidTest {
java.srcDirs += "../../testutils/src/main/java/"
}
}
}
dependencies {
compile project(':library-core')
compile 'com.android.support:support-annotations:25.2.0'
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5'
}
ext {
releaseArtifact = 'exoplayer-dash'
releaseDescription = 'The ExoPlayer library DASH module.'
}
apply from: '../../publish.gradle'
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.google.android.exoplayer2.source.dash.test">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="24"/>
<application android:debuggable="true"
android:allowBackup="false"
tools:ignore="MissingApplicationIcon,HardcodedDebugMode">
<uses-library android:name="android.test.runner"/>
</application>
<instrumentation
android:targetPackage="com.google.android.exoplayer2.source.dash.test"
android:name="android.test.InstrumentationTestRunner"
tools:replace="android:targetPackage"/>
</manifest>
...@@ -28,11 +28,9 @@ import java.util.List; ...@@ -28,11 +28,9 @@ import java.util.List;
*/ */
public class DashManifestParserTest extends InstrumentationTestCase { public class DashManifestParserTest extends InstrumentationTestCase {
private static final String SAMPLE_MPD_1 = "dash/sample_mpd_1"; private static final String SAMPLE_MPD_1 = "sample_mpd_1";
private static final String SAMPLE_MPD_2_UNKNOWN_MIME_TYPE = private static final String SAMPLE_MPD_2_UNKNOWN_MIME_TYPE = "sample_mpd_2_unknown_mime_type";
"dash/sample_mpd_2_unknown_mime_type"; private static final String SAMPLE_MPD_3_SEGMENT_TEMPLATE = "sample_mpd_3_segment_template";
private static final String SAMPLE_MPD_3_SEGMENT_TEMPLATE =
"dash/sample_mpd_3_segment_template";
/** /**
* Simple test to ensure the sample manifests parse without any exceptions being thrown. * Simple test to ensure the sample manifests parse without any exceptions being thrown.
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2017 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.
-->
<manifest package="com.google.android.exoplayer2.source.dash"/>
...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor; ...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor; import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor;
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper; import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper;
import com.google.android.exoplayer2.source.chunk.InitializationChunk; import com.google.android.exoplayer2.source.chunk.InitializationChunk;
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.DashManifest;
import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser; import com.google.android.exoplayer2.source.dash.manifest.DashManifestParser;
import com.google.android.exoplayer2.source.dash.manifest.Period; import com.google.android.exoplayer2.source.dash.manifest.Period;
...@@ -65,6 +66,48 @@ public final class DashUtil { ...@@ -65,6 +66,48 @@ public final class DashUtil {
} }
/** /**
* Loads {@link DrmInitData} for a given manifest.
*
* @param dataSource The {@link HttpDataSource} from which data should be loaded.
* @param dashManifest The {@link DashManifest} of the DASH content.
* @return The loaded {@link DrmInitData}.
*/
public static DrmInitData loadDrmInitData(DataSource dataSource, DashManifest dashManifest)
throws IOException, InterruptedException {
// Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
// as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
if (dashManifest.getPeriodCount() < 1) {
return null;
}
Period period = dashManifest.getPeriod(0);
int adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_VIDEO);
if (adaptationSetIndex == C.INDEX_UNSET) {
adaptationSetIndex = period.getAdaptationSetIndex(C.TRACK_TYPE_AUDIO);
if (adaptationSetIndex == C.INDEX_UNSET) {
return null;
}
}
AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
if (adaptationSet.representations.isEmpty()) {
return null;
}
Representation representation = adaptationSet.representations.get(0);
DrmInitData drmInitData = representation.format.drmInitData;
if (drmInitData == null) {
Format sampleFormat = DashUtil.loadSampleFormat(dataSource, representation);
if (sampleFormat != null) {
drmInitData = sampleFormat.drmInitData;
}
if (drmInitData == null) {
return null;
}
}
return drmInitData;
}
/**
* Loads initialization data for the {@code representation} and returns the sample {@link
* Format}.
* Loads {@link DrmInitData} for a given period in a DASH manifest. * Loads {@link DrmInitData} for a given period in a DASH manifest.
* *
* @param dataSource The {@link HttpDataSource} from which data should be loaded. * @param dataSource The {@link HttpDataSource} from which data should be loaded.
......
...@@ -25,5 +25,6 @@ android { ...@@ -25,5 +25,6 @@ android {
dependencies { dependencies {
compile project(':library-core') compile project(':library-core')
androidTestCompile project(':library-dash')
androidTestCompile project(':library-hls') androidTestCompile project(':library-hls')
} }
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
include ':library' include ':library'
include ':library-core' include ':library-core'
include ':library-dash'
include ':library-hls' include ':library-hls'
include ':library-smoothstreaming' include ':library-smoothstreaming'
include ':library-ui' include ':library-ui'
...@@ -30,6 +31,7 @@ include ':extension-vp9' ...@@ -30,6 +31,7 @@ include ':extension-vp9'
project(':library').projectDir = new File(settingsDir, 'library/all') project(':library').projectDir = new File(settingsDir, 'library/all')
project(':library-core').projectDir = new File(settingsDir, 'library/core') project(':library-core').projectDir = new File(settingsDir, 'library/core')
project(':library-dash').projectDir = new File(settingsDir, 'library/dash')
project(':library-hls').projectDir = new File(settingsDir, 'library/hls') project(':library-hls').projectDir = new File(settingsDir, 'library/hls')
project(':library-smoothstreaming').projectDir = new File(settingsDir, 'library/smoothstreaming') project(':library-smoothstreaming').projectDir = new File(settingsDir, 'library/smoothstreaming')
project(':library-ui').projectDir = new File(settingsDir, 'library/ui') project(':library-ui').projectDir = new File(settingsDir, 'library/ui')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment