Split DASH into a separate module
Issue: #2139 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=150762237
This commit is contained in:
parent
b1a2ae1856
commit
7ce8125194
@ -27,6 +27,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile project(':library-core')
|
||||
compile project(':library-dash')
|
||||
compile project(':library-hls')
|
||||
compile project(':library-smoothstreaming')
|
||||
compile project(':library-ui')
|
||||
|
44
library/dash/build.gradle
Normal file
44
library/dash/build.gradle
Normal file
@ -0,0 +1,44 @@
|
||||
// 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'
|
34
library/dash/src/androidTest/AndroidManifest.xml
Normal file
34
library/dash/src/androidTest/AndroidManifest.xml
Normal file
@ -0,0 +1,34 @@
|
||||
<?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;
|
||||
*/
|
||||
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";
|
||||
private static final String SAMPLE_MPD_3_SEGMENT_TEMPLATE =
|
||||
"dash/sample_mpd_3_segment_template";
|
||||
private static final String SAMPLE_MPD_1 = "sample_mpd_1";
|
||||
private static final String SAMPLE_MPD_2_UNKNOWN_MIME_TYPE = "sample_mpd_2_unknown_mime_type";
|
||||
private static final String SAMPLE_MPD_3_SEGMENT_TEMPLATE = "sample_mpd_3_segment_template";
|
||||
|
||||
/**
|
||||
* Simple test to ensure the sample manifests parse without any exceptions being thrown.
|
17
library/dash/src/main/AndroidManifest.xml
Normal file
17
library/dash/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<?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;
|
||||
import com.google.android.exoplayer2.extractor.mp4.FragmentedMp4Extractor;
|
||||
import com.google.android.exoplayer2.source.chunk.ChunkExtractorWrapper;
|
||||
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.DashManifestParser;
|
||||
import com.google.android.exoplayer2.source.dash.manifest.Period;
|
||||
@ -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.
|
||||
*
|
||||
* @param dataSource The {@link HttpDataSource} from which data should be loaded.
|
@ -25,5 +25,6 @@ android {
|
||||
|
||||
dependencies {
|
||||
compile project(':library-core')
|
||||
androidTestCompile project(':library-dash')
|
||||
androidTestCompile project(':library-hls')
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
// limitations under the License.
|
||||
include ':library'
|
||||
include ':library-core'
|
||||
include ':library-dash'
|
||||
include ':library-hls'
|
||||
include ':library-smoothstreaming'
|
||||
include ':library-ui'
|
||||
@ -30,6 +31,7 @@ include ':extension-vp9'
|
||||
|
||||
project(':library').projectDir = new File(settingsDir, 'library/all')
|
||||
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-smoothstreaming').projectDir = new File(settingsDir, 'library/smoothstreaming')
|
||||
project(':library-ui').projectDir = new File(settingsDir, 'library/ui')
|
||||
|
Loading…
x
Reference in New Issue
Block a user