mirror of
https://github.com/androidx/media.git
synced 2025-05-07 23:50:44 +08:00
parent
21c1b8ca06
commit
a74fd17e92
45
library/src/androidTest/assets/smoothstreaming/sample_ismc_1
Executable file
45
library/src/androidTest/assets/smoothstreaming/sample_ismc_1
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<SmoothStreamingMedia MajorVersion="2" MinorVersion="0"
|
||||||
|
Duration="2300000000" TimeScale="10000000">
|
||||||
|
<Protection>
|
||||||
|
<ProtectionHeader SystemID="9A04F079-9840-4286-AB92-E65BE0885F95">
|
||||||
|
<!-- Base 64-Encoded data omitted for clarity -->
|
||||||
|
</ProtectionHeader>
|
||||||
|
</Protection>
|
||||||
|
|
||||||
|
<StreamIndex
|
||||||
|
Type = "video"
|
||||||
|
Chunks = "115"
|
||||||
|
QualityLevels = "2"
|
||||||
|
MaxWidth = "720"
|
||||||
|
MaxHeight = "480"
|
||||||
|
TimeScale="10000000"
|
||||||
|
Url =
|
||||||
|
"QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start_time})"
|
||||||
|
Name = "video"
|
||||||
|
>
|
||||||
|
<QualityLevel Index="0" Bitrate="1536000" FourCC="WVC1"
|
||||||
|
MaxWidth="720" MaxHeight="480"
|
||||||
|
CodecPrivateData = "270000010FCBEE1670EF8A16783BF180C9089CC4AFA11C0000010E1207F840"
|
||||||
|
>
|
||||||
|
<CustomAttributes>
|
||||||
|
<Attribute Name = "Compatibility" Value = "Desktop" />
|
||||||
|
</CustomAttributes>
|
||||||
|
</QualityLevel>
|
||||||
|
|
||||||
|
|
||||||
|
<QualityLevel Index="5" Bitrate="307200" FourCC="WVC1"
|
||||||
|
MaxWidth="720" MaxHeight="480"
|
||||||
|
CodecPrivateData = "270000010FCBEE1670EF8A16783BF180C9089CC4AFA11C0000010E1207F840">
|
||||||
|
<CustomAttributes>
|
||||||
|
<Attribute Name = "Compatibility" Value = "Handheld" />
|
||||||
|
</CustomAttributes>
|
||||||
|
</QualityLevel>
|
||||||
|
|
||||||
|
|
||||||
|
<c t = "0" d = "19680000" />
|
||||||
|
<c n = "1" t = "19680000" d="8980000" />
|
||||||
|
|
||||||
|
</StreamIndex>
|
||||||
|
</SmoothStreamingMedia>
|
||||||
|
|
45
library/src/androidTest/assets/smoothstreaming/sample_ismc_2
Executable file
45
library/src/androidTest/assets/smoothstreaming/sample_ismc_2
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<SmoothStreamingMedia MajorVersion="2" MinorVersion="0"
|
||||||
|
Duration="2300000000" TimeScale="10000000">
|
||||||
|
<Protection>
|
||||||
|
<ProtectionHeader SystemID="{9A04F079-9840-4286-AB92-E65BE0885F95}">
|
||||||
|
<!-- Base 64-Encoded data omitted for clarity -->
|
||||||
|
</ProtectionHeader>
|
||||||
|
</Protection>
|
||||||
|
|
||||||
|
<StreamIndex
|
||||||
|
Type = "video"
|
||||||
|
Chunks = "115"
|
||||||
|
QualityLevels = "2"
|
||||||
|
MaxWidth = "720"
|
||||||
|
MaxHeight = "480"
|
||||||
|
TimeScale="10000000"
|
||||||
|
Url =
|
||||||
|
"QualityLevels({bitrate},{CustomAttributes})/Fragments(video={start_time})"
|
||||||
|
Name = "video"
|
||||||
|
>
|
||||||
|
<QualityLevel Index="0" Bitrate="1536000" FourCC="WVC1"
|
||||||
|
MaxWidth="720" MaxHeight="480"
|
||||||
|
CodecPrivateData = "270000010FCBEE1670EF8A16783BF180C9089CC4AFA11C0000010E1207F840"
|
||||||
|
>
|
||||||
|
<CustomAttributes>
|
||||||
|
<Attribute Name = "Compatibility" Value = "Desktop" />
|
||||||
|
</CustomAttributes>
|
||||||
|
</QualityLevel>
|
||||||
|
|
||||||
|
|
||||||
|
<QualityLevel Index="5" Bitrate="307200" FourCC="WVC1"
|
||||||
|
MaxWidth="720" MaxHeight="480"
|
||||||
|
CodecPrivateData = "270000010FCBEE1670EF8A16783BF180C9089CC4AFA11C0000010E1207F840">
|
||||||
|
<CustomAttributes>
|
||||||
|
<Attribute Name = "Compatibility" Value = "Handheld" />
|
||||||
|
</CustomAttributes>
|
||||||
|
</QualityLevel>
|
||||||
|
|
||||||
|
|
||||||
|
<c t = "0" d = "19680000" />
|
||||||
|
<c n = "1" t = "19680000" d="8980000" />
|
||||||
|
|
||||||
|
</StreamIndex>
|
||||||
|
</SmoothStreamingMedia>
|
||||||
|
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 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.exoplayer.smoothstreaming;
|
||||||
|
|
||||||
|
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("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("https://example.com/test.ismc", inputStream2);
|
||||||
|
}
|
||||||
|
}
|
@ -404,6 +404,7 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
|
|||||||
if (TAG_PROTECTION_HEADER.equals(parser.getName())) {
|
if (TAG_PROTECTION_HEADER.equals(parser.getName())) {
|
||||||
inProtectionHeader = true;
|
inProtectionHeader = true;
|
||||||
String uuidString = parser.getAttributeValue(null, KEY_SYSTEM_ID);
|
String uuidString = parser.getAttributeValue(null, KEY_SYSTEM_ID);
|
||||||
|
uuidString = stripCurlyBraces(uuidString);
|
||||||
uuid = UUID.fromString(uuidString);
|
uuid = UUID.fromString(uuidString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,6 +428,12 @@ public class SmoothStreamingManifestParser implements UriLoadable.Parser<SmoothS
|
|||||||
return new ProtectionElement(uuid, PsshAtomUtil.buildPsshAtom(uuid, initData));
|
return new ProtectionElement(uuid, PsshAtomUtil.buildPsshAtom(uuid, initData));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String stripCurlyBraces(String uuidString) {
|
||||||
|
if (uuidString.charAt(0) == '{' && uuidString.charAt(uuidString.length() - 1) == '}') {
|
||||||
|
uuidString = uuidString.substring(1, uuidString.length() - 1);
|
||||||
|
}
|
||||||
|
return uuidString;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class StreamElementParser extends ElementParser {
|
private static class StreamElementParser extends ElementParser {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user