Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ExoPlayer
提交
12513e98
E
ExoPlayer
项目概览
NotesChapter
/
ExoPlayer
与 Fork 源项目一致
从无法访问的项目Fork
通知
6
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
ExoPlayer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
12513e98
编写于
10月 13, 2017
作者:
O
Oliver Woodman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweak recently merged pull requests
上级
e6d8e5b0
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
54 addition
and
119 deletion
+54
-119
library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java
...ogle/android/exoplayer2/drm/DefaultDrmSessionManager.java
+15
-15
library/core/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java
...n/java/com/google/android/exoplayer2/drm/DrmInitData.java
+3
-6
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java
...google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java
+16
-14
library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java
...va/com/google/android/exoplayer2/drm/DrmInitDataTest.java
+9
-13
library/hls/src/androidTest/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
...yer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
+2
-44
library/hls/src/androidTest/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
...ayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
+1
-1
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
.../google/android/exoplayer2/source/hls/HlsMediaSource.java
+5
-4
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java
...oid/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java
+0
-20
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistTracker.java
...id/exoplayer2/source/hls/playlist/HlsPlaylistTracker.java
+3
-2
未找到文件。
library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java
浏览文件 @
12513e98
...
...
@@ -349,7 +349,7 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
// If there is no scheme information, assume patternless AES-CTR.
return
true
;
}
else
if
(
C
.
CENC_TYPE_cbc1
.
equals
(
schemeType
)
||
C
.
CENC_TYPE_cbcs
.
equals
(
schemeType
)
||
C
.
CENC_TYPE_cens
.
equals
(
schemeType
))
{
||
C
.
CENC_TYPE_cens
.
equals
(
schemeType
))
{
// AES-CBC and pattern encryption are supported on API 24 onwards.
return
Util
.
SDK_INT
>=
24
;
}
...
...
@@ -357,7 +357,6 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
return
true
;
}
@Override
public
DrmSession
<
T
>
acquireSession
(
Looper
playbackLooper
,
DrmInitData
drmInitData
)
{
Assertions
.
checkState
(
this
.
playbackLooper
==
null
||
this
.
playbackLooper
==
playbackLooper
);
...
...
@@ -462,34 +461,35 @@ public class DefaultDrmSessionManager<T extends ExoMediaCrypto> implements DrmSe
* @return The extracted {@link SchemeData}, or null if no suitable data is present.
*/
private
static
SchemeData
getSchemeData
(
DrmInitData
drmInitData
,
UUID
uuid
)
{
List
<
SchemeData
>
schemeDatas
=
new
ArrayList
<>();
// Look for matching PSSH boxes, or the common box in the case of ClearKey
for
(
int
i
=
0
;
i
<
drmInitData
.
schemeDataCount
;
++
i
)
{
// Look for matching scheme data (matching the Common PSSH box for ClearKey).
List
<
SchemeData
>
matchingSchemeDatas
=
new
ArrayList
<>(
drmInitData
.
schemeDataCount
);
for
(
int
i
=
0
;
i
<
drmInitData
.
schemeDataCount
;
i
++
)
{
SchemeData
schemeData
=
drmInitData
.
get
(
i
);
if
(
schemeData
.
matches
(
uuid
)
||
(
C
.
CLEARKEY_UUID
.
equals
(
uuid
)
&&
schemeData
.
matches
(
C
.
COMMON_PSSH_UUID
)))
{
s
chemeDatas
.
add
(
schemeData
);
||
(
C
.
CLEARKEY_UUID
.
equals
(
uuid
)
&&
schemeData
.
matches
(
C
.
COMMON_PSSH_UUID
)))
{
matchingS
chemeDatas
.
add
(
schemeData
);
}
}
if
(
s
chemeDatas
.
isEmpty
())
{
if
(
matchingS
chemeDatas
.
isEmpty
())
{
return
null
;
}
// For Widevine
, we prefer v1 init data on M and higher, v0 for lower
// For Widevine
PSSH boxes, prefer V1 boxes from API 23 and V0 before.
if
(
C
.
WIDEVINE_UUID
.
equals
(
uuid
))
{
for
(
SchemeData
schemeData
:
schemeDatas
)
{
int
version
=
PsshAtomUtil
.
parseVersion
(
schemeData
.
data
);
for
(
int
i
=
0
;
i
<
matchingSchemeDatas
.
size
();
i
++)
{
SchemeData
matchingSchemeData
=
matchingSchemeDatas
.
get
(
i
);
int
version
=
PsshAtomUtil
.
parseVersion
(
matchingSchemeData
.
data
);
if
(
Util
.
SDK_INT
<
23
&&
version
==
0
)
{
return
s
chemeData
;
return
matchingS
chemeData
;
}
else
if
(
Util
.
SDK_INT
>=
23
&&
version
==
1
)
{
return
s
chemeData
;
return
matchingS
chemeData
;
}
}
}
// If we don't have any special handling
for this system, we take the first scheme data found
return
s
chemeDatas
.
get
(
0
);
// If we don't have any special handling
, prefer the first matching scheme data.
return
matchingS
chemeDatas
.
get
(
0
);
}
private
static
byte
[]
getSchemeInitData
(
SchemeData
data
,
UUID
uuid
)
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/drm/DrmInitData.java
浏览文件 @
12513e98
...
...
@@ -22,8 +22,6 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.List
;
...
...
@@ -80,7 +78,6 @@ public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
// Sorting ensures that universal scheme data (i.e. data that applies to all schemes) is matched
// last. It's also required by the equals and hashcode implementations.
Arrays
.
sort
(
schemeDatas
,
this
);
this
.
schemeDatas
=
schemeDatas
;
schemeDataCount
=
schemeDatas
.
length
;
}
...
...
@@ -94,7 +91,7 @@ public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
/**
* Retrieves data for a given DRM scheme, specified by its UUID.
*
* @deprecated
This will only get the first data found for the scheme
.
* @deprecated
Use {@link #get(int)} and {@link SchemeData#matches(UUID)} instead
.
* @param uuid The DRM scheme's UUID.
* @return The initialization data for the scheme, or null if the scheme is not supported.
*/
...
...
@@ -111,8 +108,8 @@ public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
/**
* Retrieves the {@link SchemeData} at a given index.
*
* @param index index of the scheme to return. Must not exceed {@link #schemeDataCount}.
* @return The {@link SchemeData} at the index.
* @param index
The
index of the scheme to return. Must not exceed {@link #schemeDataCount}.
* @return The {@link SchemeData} at the
specified
index.
*/
public
SchemeData
get
(
int
index
)
{
return
schemeDatas
[
index
];
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/PsshAtomUtil.java
浏览文件 @
12513e98
...
...
@@ -16,7 +16,6 @@
package
com.google.android.exoplayer2.extractor.mp4
;
import
android.util.Log
;
import
android.util.Pair
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.nio.ByteBuffer
;
import
java.util.UUID
;
...
...
@@ -96,10 +95,10 @@ public final class PsshAtomUtil {
/**
* Parses the version from a PSSH atom. Version 0 and 1 PSSH atoms are supported.
* <p>
* The
UUID
is only parsed if the data is a valid PSSH atom.
* The
version
is only parsed if the data is a valid PSSH atom.
*
* @param atom The atom to parse.
* @return The parsed
UUID
. -1 if the input is not a valid PSSH atom, or if the PSSH atom has
* @return The parsed
version
. -1 if the input is not a valid PSSH atom, or if the PSSH atom has
* an unsupported version.
*/
public
static
int
parseVersion
(
byte
[]
atom
)
{
...
...
@@ -130,16 +129,15 @@ public final class PsshAtomUtil {
Log
.
w
(
TAG
,
"UUID mismatch. Expected: "
+
uuid
+
", got: "
+
parsedAtom
.
uuid
+
"."
);
return
null
;
}
return
parsedAtom
.
d
ata
;
return
parsedAtom
.
schemeD
ata
;
}
/**
* Parses the UUID and scheme specific data from a PSSH atom. Version 0 and 1 PSSH atoms are
* supported.
* Parses a PSSH atom. Version 0 and 1 PSSH atoms are supported.
*
* @param atom The atom to parse.
* @return
A pair consisting of the parsed UUID and scheme specific data. Null if the input is
*
not a valid PSSH atom, or if the PSSH atom
has an unsupported version.
* @return
The parsed PSSH atom. Null if the input is not a valid PSSH atom, or if the PSSH atom
* has an unsupported version.
*/
// TODO: Support parsing of the key ids for version 1 PSSH atoms.
private
static
PsshAtom
parsePsshAtom
(
byte
[]
atom
)
{
...
...
@@ -179,15 +177,19 @@ public final class PsshAtomUtil {
return
new
PsshAtom
(
uuid
,
atomVersion
,
data
);
}
// TODO: Consider exposing this and making parsePsshAtom public.
private
static
class
PsshAtom
{
final
UUID
uuid
;
final
int
version
;
final
byte
[]
data
;
PsshAtom
(
final
UUID
uuid
,
final
int
version
,
final
byte
[]
data
)
{
private
final
UUID
uuid
;
private
final
int
version
;
private
final
byte
[]
schemeData
;
public
PsshAtom
(
UUID
uuid
,
int
version
,
byte
[]
schemeData
)
{
this
.
uuid
=
uuid
;
this
.
version
=
version
;
this
.
data
=
d
ata
;
this
.
schemeData
=
schemeD
ata
;
}
}
}
\ No newline at end of file
}
library/core/src/test/java/com/google/android/exoplayer2/drm/DrmInitDataTest.java
浏览文件 @
12513e98
...
...
@@ -20,20 +20,18 @@ import static com.google.android.exoplayer2.C.UUID_NIL;
import
static
com
.
google
.
android
.
exoplayer2
.
C
.
WIDEVINE_UUID
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
MimeTypes
.
VIDEO_MP4
;
import
static
com
.
google
.
common
.
truth
.
Truth
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
import
android.os.Parcel
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.testutil.TestUtil
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.robolectric.RobolectricTestRunner
;
import
org.robolectric.annotation.Config
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Unit test for {@link DrmInitData}.
*/
...
...
@@ -101,7 +99,7 @@ public class DrmInitDataTest {
@Test
@Deprecated
public
void
testGet
()
{
public
void
testGet
ByUuid
()
{
// Basic matching.
DrmInitData
testInitData
=
new
DrmInitData
(
DATA_1
,
DATA_2
);
assertThat
(
testInitData
.
get
(
WIDEVINE_UUID
)).
isEqualTo
(
DATA_1
);
...
...
@@ -134,16 +132,14 @@ public class DrmInitDataTest {
}
@Test
public
void
test
DuplicateSchemeData
()
{
DrmInitData
testInitData
=
new
DrmInitData
(
DATA_1
,
DATA_1
);
public
void
test
SchemeDatasWithSameUuid
()
{
DrmInitData
testInitData
=
new
DrmInitData
(
DATA_1
,
DATA_1
B
);
assertThat
(
testInitData
.
schemeDataCount
).
isEqualTo
(
2
);
testInitData
=
new
DrmInitData
(
DATA_1
,
DATA_2
,
DATA_1B
);
assertThat
(
testInitData
.
schemeDataCount
).
isEqualTo
(
3
);
assertThat
(
getAllSchemeData
(
testInitData
)).
containsAllOf
(
DATA_1
,
DATA_1B
,
DATA_2
);
// Deprecated get method should return first entry
// Deprecated get method should return first entry.
assertThat
(
testInitData
.
get
(
WIDEVINE_UUID
)).
isEqualTo
(
DATA_1
);
assertThat
(
testInitData
.
get
(
PLAYREADY_UUID
)).
isEqualTo
(
DATA_2
);
// Test retrieval of first and second entry.
assertThat
(
testInitData
.
get
(
0
)).
isEqualTo
(
DATA_1
);
assertThat
(
testInitData
.
get
(
1
)).
isEqualTo
(
DATA_1B
);
}
@Test
...
...
library/hls/src/androidTest/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylistParserTest.java
浏览文件 @
12513e98
...
...
@@ -16,23 +16,19 @@
package
com.google.android.exoplayer2.source.hls.playlist
;
import
android.net.Uri
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
junit.framework.TestCase
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.nio.charset.Charset
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
junit.framework.TestCase
;
/**
* Test for {@link HlsMasterPlaylistParserTest}
* Test for {@link HlsMasterPlaylistParserTest}
.
*/
public
class
HlsMasterPlaylistParserTest
extends
TestCase
{
...
...
@@ -151,44 +147,6 @@ public class HlsMasterPlaylistParserTest extends TestCase {
assertEquals
(
Collections
.
emptyList
(),
playlist
.
muxedCaptionFormats
);
}
public
void
testReorderedVariantCopy
()
throws
IOException
{
HlsMasterPlaylist
playlist
=
parseMasterPlaylist
(
PLAYLIST_URI
,
MASTER_PLAYLIST
);
HlsMasterPlaylist
nonReorderedPlaylist
=
playlist
.
copyWithReorderedVariants
(
new
Comparator
<
HlsMasterPlaylist
.
HlsUrl
>()
{
@Override
public
int
compare
(
HlsMasterPlaylist
.
HlsUrl
url1
,
HlsMasterPlaylist
.
HlsUrl
url2
)
{
return
0
;
}
});
assertEquals
(
playlist
.
variants
,
nonReorderedPlaylist
.
variants
);
HlsMasterPlaylist
.
HlsUrl
preferred
=
null
;
for
(
HlsMasterPlaylist
.
HlsUrl
url
:
playlist
.
variants
)
{
if
(
preferred
==
null
||
url
.
format
.
bitrate
>
preferred
.
format
.
bitrate
)
{
preferred
=
url
;
}
}
assertNotNull
(
preferred
);
final
Comparator
comparator
=
Collections
.
reverseOrder
(
new
Comparator
<
HlsMasterPlaylist
.
HlsUrl
>()
{
@Override
public
int
compare
(
HlsMasterPlaylist
.
HlsUrl
url1
,
HlsMasterPlaylist
.
HlsUrl
url2
)
{
if
(
url1
.
format
.
bitrate
>
url2
.
format
.
bitrate
)
{
return
1
;
}
if
(
url2
.
format
.
bitrate
>
url1
.
format
.
bitrate
)
{
return
-
1
;
}
return
0
;
}
});
HlsMasterPlaylist
reorderedPlaylist
=
playlist
.
copyWithReorderedVariants
(
comparator
);
assertEquals
(
reorderedPlaylist
.
variants
.
get
(
0
),
preferred
);
}
private
static
HlsMasterPlaylist
parseMasterPlaylist
(
String
uri
,
String
playlistString
)
throws
IOException
{
Uri
playlistUri
=
Uri
.
parse
(
uri
);
...
...
library/hls/src/androidTest/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylistParserTest.java
浏览文件 @
12513e98
...
...
@@ -27,7 +27,7 @@ import java.util.Locale;
import
junit.framework.TestCase
;
/**
* Test for {@link HlsMediaPlaylistParserTest}
* Test for {@link HlsMediaPlaylistParserTest}
.
*/
public
class
HlsMediaPlaylistParserTest
extends
TestCase
{
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
浏览文件 @
12513e98
...
...
@@ -76,13 +76,14 @@ public final class HlsMediaSource implements MediaSource,
public
HlsMediaSource
(
Uri
manifestUri
,
HlsDataSourceFactory
dataSourceFactory
,
int
minLoadableRetryCount
,
Handler
eventHandler
,
AdaptiveMediaSourceEventListener
eventListener
)
{
this
(
manifestUri
,
dataSourceFactory
,
minLoadableRetryCount
,
eventHandler
,
eventListener
,
new
HlsPlaylistParser
());
this
(
manifestUri
,
dataSourceFactory
,
minLoadableRetryCount
,
eventHandler
,
eventListener
,
new
HlsPlaylistParser
());
}
public
HlsMediaSource
(
Uri
manifestUri
,
HlsDataSourceFactory
dataSourceFactory
,
int
minLoadableRetryCount
,
Handler
eventHandler
,
AdaptiveMediaSourceEventListener
eventListener
,
ParsingLoadable
.
Parser
<
HlsPlaylist
>
playlistParser
)
{
int
minLoadableRetryCount
,
Handler
eventHandler
,
AdaptiveMediaSourceEventListener
eventListener
,
ParsingLoadable
.
Parser
<
HlsPlaylist
>
playlistParser
)
{
this
.
manifestUri
=
manifestUri
;
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
minLoadableRetryCount
=
minLoadableRetryCount
;
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java
浏览文件 @
12513e98
...
...
@@ -19,7 +19,6 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
...
...
@@ -124,25 +123,6 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
muxedAudioFormat
,
muxedCaptionFormats
);
}
/**
* Returns a copy of this playlist which includes the variants sorted using the passed comparator. NOTE: the variants
* will be sorted in ascending order by default. If you wish to use descending order, you can wrap your comparator in
* {@link Collections#reverseOrder(Comparator)}.
*
* @param variantComparator the comparator to use to sort the variant list.
* @return a copy of this playlist which includes the variants sorted using the passed comparator.
*/
public
HlsMasterPlaylist
copyWithReorderedVariants
(
Comparator
<
HlsUrl
>
variantComparator
)
{
return
new
HlsMasterPlaylist
(
baseUri
,
tags
,
filterVariants
(
variants
,
variantComparator
),
audios
,
subtitles
,
muxedAudioFormat
,
muxedCaptionFormats
);
}
private
List
<
HlsUrl
>
filterVariants
(
List
<
HlsUrl
>
variants
,
Comparator
<
HlsUrl
>
variantComparator
)
{
List
<
HlsUrl
>
reorderedList
=
new
ArrayList
<>(
variants
);
Collections
.
sort
(
reorderedList
,
variantComparator
);
return
reorderedList
;
}
/**
* Creates a playlist with a single variant.
*
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistTracker.java
浏览文件 @
12513e98
...
...
@@ -140,15 +140,16 @@ public final class HlsPlaylistTracker implements Loader.Callback<ParsingLoadable
*/
public
HlsPlaylistTracker
(
Uri
initialPlaylistUri
,
HlsDataSourceFactory
dataSourceFactory
,
EventDispatcher
eventDispatcher
,
int
minRetryCount
,
PrimaryPlaylistListener
primaryPlaylistListener
,
ParsingLoadable
.
Parser
<
HlsPlaylist
>
playlistParser
)
{
PrimaryPlaylistListener
primaryPlaylistListener
,
ParsingLoadable
.
Parser
<
HlsPlaylist
>
playlistParser
)
{
this
.
initialPlaylistUri
=
initialPlaylistUri
;
this
.
dataSourceFactory
=
dataSourceFactory
;
this
.
eventDispatcher
=
eventDispatcher
;
this
.
minRetryCount
=
minRetryCount
;
this
.
primaryPlaylistListener
=
primaryPlaylistListener
;
this
.
playlistParser
=
playlistParser
;
listeners
=
new
ArrayList
<>();
initialPlaylistLoader
=
new
Loader
(
"HlsPlaylistTracker:MasterPlaylist"
);
this
.
playlistParser
=
playlistParser
;
playlistBundles
=
new
IdentityHashMap
<>();
playlistRefreshHandler
=
new
Handler
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录