Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
NotesChapter
ExoPlayer
提交
75cc5990
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,发现更多精彩内容 >>
提交
75cc5990
编写于
2月 12, 2021
作者:
K
kimvde
提交者:
marcbaechinger
2月 22, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for MP4/QuickTime non-full meta atoms
PiperOrigin-RevId: 357160215
上级
4b1e0fa9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
28 deletion
+37
-28
RELEASENOTES.md
RELEASENOTES.md
+5
-0
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
.../google/android/exoplayer2/extractor/mp4/AtomParsers.java
+26
-5
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
...google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
+6
-23
未找到文件。
RELEASENOTES.md
浏览文件 @
75cc5990
# Release notes
### dev-v2 ###
*
Extractors:
*
Add support for MP4 and QuickTime meta atoms that are not full atoms.
### 2.13.1 (2021-02-12)
*
Live streaming:
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
浏览文件 @
75cc5990
...
...
@@ -145,12 +145,11 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
* Parses a udta atom.
*
* @param udtaAtom The udta (user data) atom to decode.
* @param isQuickTime True for QuickTime media. False otherwise.
* @return A {@link Pair} containing the metadata from the meta child atom as first value (if
* any), and the metadata from the smta child atom as second value (if any).
*/
public
static
Pair
<
@NullableType
Metadata
,
@NullableType
Metadata
>
parseUdta
(
Atom
.
LeafAtom
udtaAtom
,
boolean
isQuickTime
)
{
Atom
.
LeafAtom
udtaAtom
)
{
ParsableByteArray
udtaData
=
udtaAtom
.
data
;
udtaData
.
setPosition
(
Atom
.
HEADER_SIZE
);
@Nullable
Metadata
metaMetadata
=
null
;
...
...
@@ -159,8 +158,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
int
atomPosition
=
udtaData
.
getPosition
();
int
atomSize
=
udtaData
.
readInt
();
int
atomType
=
udtaData
.
readInt
();
// Meta boxes are regular boxes rather than full boxes in QuickTime. Ignore them for now.
if
(
atomType
==
Atom
.
TYPE_meta
&&
!
isQuickTime
)
{
if
(
atomType
==
Atom
.
TYPE_meta
)
{
udtaData
.
setPosition
(
atomPosition
);
metaMetadata
=
parseUdtaMeta
(
udtaData
,
atomPosition
+
atomSize
);
}
else
if
(
atomType
==
Atom
.
TYPE_smta
)
{
...
...
@@ -227,6 +225,28 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return
entries
.
isEmpty
()
?
null
:
new
Metadata
(
entries
);
}
/**
* Possibly skips the version and flags fields (1+3 byte) of a full meta atom.
*
* <p>Atoms of type {@link Atom#TYPE_meta} are defined to be full atoms which have four additional
* bytes for a version and a flags field (see 4.2 'Object Structure' in ISO/IEC 14496-12:2005).
* QuickTime do not have such a full box structure. Since some of these files are encoded wrongly,
* we can't rely on the file type though. Instead we must check the 4 bytes after the common
* header bytes ourselves.
*
* @param meta The 4 or more bytes following the meta atom size and type.
*/
public
static
void
maybeSkipRemainingMetaAtomHeaderBytes
(
ParsableByteArray
meta
)
{
int
startPosition
=
meta
.
getPosition
();
// The next 4 bytes can be either:
// (iso) 4 zero bytes (version + flags)
// (qt) 4 byte size of next atom
// In case of (iso) we need to skip the next 4 bytes.
if
(
meta
.
readInt
()
!=
0
)
{
meta
.
setPosition
(
startPosition
);
}
}
/**
* Parses a trak atom (defined in ISO/IEC 14496-12).
*
...
...
@@ -677,7 +697,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
@Nullable
private
static
Metadata
parseUdtaMeta
(
ParsableByteArray
meta
,
int
limit
)
{
meta
.
skipBytes
(
Atom
.
FULL_HEADER_SIZE
);
meta
.
skipBytes
(
Atom
.
HEADER_SIZE
);
maybeSkipRemainingMetaAtomHeaderBytes
(
meta
);
while
(
meta
.
getPosition
()
<
limit
)
{
int
atomPosition
=
meta
.
getPosition
();
int
atomSize
=
meta
.
readInt
();
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/Mp4Extractor.java
浏览文件 @
75cc5990
...
...
@@ -470,7 +470,7 @@ public final class Mp4Extractor implements Extractor, SeekMap {
@Nullable
Atom
.
LeafAtom
udta
=
moov
.
getLeafAtomOfType
(
Atom
.
TYPE_udta
);
if
(
udta
!=
null
)
{
Pair
<
@NullableType
Metadata
,
@NullableType
Metadata
>
udtaMetadata
=
AtomParsers
.
parseUdta
(
udta
,
isQuickTime
);
AtomParsers
.
parseUdta
(
udta
);
udtaMetaMetadata
=
udtaMetadata
.
first
;
smtaMetadata
=
udtaMetadata
.
second
;
if
(
udtaMetaMetadata
!=
null
)
{
...
...
@@ -727,29 +727,12 @@ public final class Mp4Extractor implements Extractor, SeekMap {
}
}
/**
* Possibly skips the version and flags fields (1+3 byte) of a full meta atom of the {@code
* input}.
*
* <p>Atoms of type {@link Atom#TYPE_meta} are defined to be full atoms which have four additional
* bytes for a version and a flags field (see 4.2 'Object Structure' in ISO/IEC 14496-12:2005).
* QuickTime do not have such a full box structure. Since some of these files are encoded wrongly,
* we can't rely on the file type though. Instead we must check the 8 bytes after the common
* header bytes ourselves.
*/
private
void
maybeSkipRemainingMetaAtomHeaderBytes
(
ExtractorInput
input
)
throws
IOException
{
scratch
.
reset
(
8
);
// Peek the next 8 bytes which can be either
// (iso) [1 byte version + 3 bytes flags][4 byte size of next atom]
// (qt) [4 byte size of next atom ][4 byte hdlr atom type ]
// In case of (iso) we need to skip the next 4 bytes.
input
.
peekFully
(
scratch
.
getData
(),
0
,
8
);
scratch
.
skipBytes
(
4
);
if
(
scratch
.
readInt
()
==
Atom
.
TYPE_hdlr
)
{
input
.
resetPeekPosition
();
}
else
{
input
.
skipFully
(
4
);
}
scratch
.
reset
(
4
);
input
.
peekFully
(
scratch
.
getData
(),
0
,
4
);
AtomParsers
.
maybeSkipRemainingMetaAtomHeaderBytes
(
scratch
);
input
.
skipFully
(
scratch
.
getPosition
());
input
.
resetPeekPosition
();
}
/** Processes an atom whose payload does not need to be parsed. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录