Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
8 years ago
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7ee1df33d11d2a4b6165539f954cac60c8ef958c
7ee1df33
1 parent
ffe0a442
for #738, parse mp4 udta(user data) box.
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
100 行增加
和
0 行删除
trunk/src/kernel/srs_kernel_mp4.cpp
trunk/src/kernel/srs_kernel_mp4.hpp
trunk/src/kernel/srs_kernel_mp4.cpp
查看文件 @
7ee1df3
...
...
@@ -189,6 +189,7 @@ int SrsMp4Box::discovery(SrsBuffer* buf, SrsMp4Box** ppbox)
case
SrsMp4BoxTypeAVCC
:
box
=
new
SrsMp4AvccBox
();
break
;
case
SrsMp4BoxTypeMP4A
:
box
=
new
SrsMp4AudioSampleEntry
();
break
;
case
SrsMp4BoxTypeESDS
:
box
=
new
SrsMp4EsdsBox
();
break
;
case
SrsMp4BoxTypeUDTA
:
box
=
new
SrsMp4UserDataBox
();
break
;
default
:
ret
=
ERROR_MP4_BOX_ILLEGAL_TYPE
;
srs_error
(
"MP4 illegal box type=%d. ret=%d"
,
type
,
ret
);
...
...
@@ -624,6 +625,21 @@ SrsMp4MovieBox::~SrsMp4MovieBox()
{
}
int
SrsMp4MovieBox
::
nb_header
()
{
return
SrsMp4Box
::
nb_header
();
}
int
SrsMp4MovieBox
::
encode_header
(
SrsBuffer
*
buf
)
{
return
SrsMp4Box
::
encode_header
(
buf
);
}
int
SrsMp4MovieBox
::
decode_header
(
SrsBuffer
*
buf
)
{
return
SrsMp4Box
::
decode_header
(
buf
);
}
SrsMp4MovieHeaderBox
::
SrsMp4MovieHeaderBox
()
{
type
=
SrsMp4BoxTypeMVHD
;
...
...
@@ -2621,6 +2637,55 @@ int SrsMp4SampleSizeBox::decode_header(SrsBuffer* buf)
return
ret
;
}
SrsMp4UserDataBox
::
SrsMp4UserDataBox
()
{
type
=
SrsMp4BoxTypeUDTA
;
nb_data
=
0
;
data
=
NULL
;
}
SrsMp4UserDataBox
::~
SrsMp4UserDataBox
()
{
srs_freepa
(
data
);
}
int
SrsMp4UserDataBox
::
nb_header
()
{
return
SrsMp4Box
::
nb_header
()
+
nb_data
;
}
int
SrsMp4UserDataBox
::
encode_header
(
SrsBuffer
*
buf
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
SrsMp4Box
::
encode_header
(
buf
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
if
(
nb_data
)
{
buf
->
write_bytes
((
char
*
)
data
,
nb_data
);
}
return
ret
;
}
int
SrsMp4UserDataBox
::
decode_header
(
SrsBuffer
*
buf
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
SrsMp4Box
::
decode_header
(
buf
))
!=
ERROR_SUCCESS
)
{
return
ret
;
}
nb_data
=
left_space
(
buf
);
if
(
nb_data
)
{
data
=
new
uint8_t
[
nb_data
];
buf
->
read_bytes
((
char
*
)
data
,
nb_data
);
}
return
ret
;
}
#define SRS_MP4_BUF_SIZE 4096
SrsMp4Decoder
::
SrsMp4Decoder
()
...
...
@@ -2693,6 +2758,14 @@ int SrsMp4Decoder::initialize(ISrsReader* r)
return
ret
;
}
// Parse the MOOV.
SrsMp4MovieBox
*
moov
=
dynamic_cast
<
SrsMp4MovieBox
*>
(
box
);
return
parse_moov
(
moov
);
}
int
SrsMp4Decoder
::
parse_moov
(
SrsMp4MovieBox
*
moov
)
{
int
ret
=
ERROR_SUCCESS
;
return
ret
;
}
...
...
trunk/src/kernel/srs_kernel_mp4.hpp
查看文件 @
7ee1df3
...
...
@@ -80,6 +80,7 @@ enum SrsMp4BoxType
SrsMp4BoxTypeAVCC
=
0x61766343
,
// 'avcC'
SrsMp4BoxTypeMP4A
=
0x6d703461
,
// 'mp4a'
SrsMp4BoxTypeESDS
=
0x65736473
,
// 'esds'
SrsMp4BoxTypeUDTA
=
0x75647461
,
// 'udta'
SrsMp4BoxTypeVIDE
=
0x76696465
,
// 'vide'
SrsMp4BoxTypeSOUN
=
0x736f756e
,
// 'soun'
...
...
@@ -262,6 +263,10 @@ class SrsMp4MovieBox : public SrsMp4Box
public
:
SrsMp4MovieBox
();
virtual
~
SrsMp4MovieBox
();
protected
:
virtual
int
nb_header
();
virtual
int
encode_header
(
SrsBuffer
*
buf
);
virtual
int
decode_header
(
SrsBuffer
*
buf
);
};
/**
...
...
@@ -1206,6 +1211,26 @@ protected:
};
/**
* 8.10.1 User Data Box (udta)
* ISO_IEC_14496-12-base-format-2012.pdf, page 78
* This box contains objects that declare user information about the containing box and its data (presentation or
* track).
*/
class
SrsMp4UserDataBox
:
public
SrsMp4Box
{
public
:
int
nb_data
;
uint8_t
*
data
;
public
:
SrsMp4UserDataBox
();
virtual
~
SrsMp4UserDataBox
();
protected
:
virtual
int
nb_header
();
virtual
int
encode_header
(
SrsBuffer
*
buf
);
virtual
int
decode_header
(
SrsBuffer
*
buf
);
};
/**
* The MP4 demuxer.
*/
class
SrsMp4Decoder
...
...
@@ -1229,6 +1254,8 @@ public:
*/
virtual
int
initialize
(
ISrsReader
*
r
);
private
:
virtual
int
parse_moov
(
SrsMp4MovieBox
*
box
);
private
:
// Load the next box from reader.
// @param required_box_type The box type required, 0 for any box.
virtual
int
load_next_box
(
SrsMp4Box
**
ppbox
,
uint32_t
required_box_type
);
...
...
请
注册
或
登录
后发表评论