Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
a6466405
Commit
a6466405
authored
Jan 24, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复AAC rtp解码相关的bug
parent
22962a40
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
40 行增加
和
20 行删除
+40
-20
src/Extension/AAC.h
+10
-5
src/Extension/Factory.cpp
+4
-4
src/Extension/Factory.h
+3
-4
src/RtspMuxer/AACRtpCodec.cpp
+17
-3
src/RtspMuxer/AACRtpCodec.h
+4
-2
src/RtspMuxer/RtspDemuxer.cpp
+2
-2
没有找到文件。
src/Extension/AAC.h
查看文件 @
a6466405
...
...
@@ -82,7 +82,7 @@ public:
return
false
;
}
public
:
unsigned
int
syncword
;
//12 bslbf 同步字The bit string ‘1111 1111 1111’,说明一个ADTS帧的开始
unsigned
int
syncword
=
0
;
//12 bslbf 同步字The bit string ‘1111 1111 1111’,说明一个ADTS帧的开始
unsigned
int
id
;
//1 bslbf MPEG 标示符, 设置为1
unsigned
int
layer
;
//2 uimsbf Indicates which layer is used. Set to ‘00’
unsigned
int
protection_absent
;
//1 bslbf 表示是否误码校验
...
...
@@ -234,10 +234,15 @@ public:
* @param frame 数据帧
*/
void
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
{
if
(
_cfg
.
empty
()
&&
frame
->
prefixSize
()
>=
7
){
//7个字节的adts头
_cfg
=
makeAdtsConfig
(
reinterpret_cast
<
const
uint8_t
*>
(
frame
->
data
()));
onReady
();
if
(
_cfg
.
empty
()){
//未获取到aac_cfg信息
if
(
frame
->
prefixSize
()
>=
7
)
{
//7个字节的adts头
_cfg
=
makeAdtsConfig
(
reinterpret_cast
<
const
uint8_t
*>
(
frame
->
data
()));
onReady
();
}
else
{
WarnL
<<
"无法获取adts头!"
;
}
}
AudioTrack
::
inputFrame
(
frame
);
}
...
...
src/Extension/Factory.cpp
查看文件 @
a6466405
...
...
@@ -181,16 +181,16 @@ RtpCodec::Ptr Factory::getRtpEncoderById(CodecId codecId,
}
}
RtpCodec
::
Ptr
Factory
::
getRtpDecoderBy
Id
(
CodecId
codecId
)
{
switch
(
codecId
){
RtpCodec
::
Ptr
Factory
::
getRtpDecoderBy
Track
(
const
Track
::
Ptr
&
track
)
{
switch
(
track
->
getCodecId
()
){
case
CodecH264
:
return
std
::
make_shared
<
H264RtpDecoder
>
();
case
CodecH265
:
return
std
::
make_shared
<
H265RtpDecoder
>
();
case
CodecAAC
:
return
std
::
make_shared
<
AACRtpDecoder
>
();
return
std
::
make_shared
<
AACRtpDecoder
>
(
track
->
clone
()
);
default
:
WarnL
<<
"暂不支持该CodecId:"
<<
codecId
;
WarnL
<<
"暂不支持该CodecId:"
<<
track
->
getCodecId
()
;
return
nullptr
;
}
}
...
...
src/Extension/Factory.h
查看文件 @
a6466405
...
...
@@ -81,12 +81,11 @@ public:
uint8_t
ui8Interleaved
);
/**
* 根据CodecId生成Rtp解包器
* @param codecId
* @param ui32SampleRate
* 根据Track生成Rtp解包器
* @param track
* @return
*/
static
RtpCodec
::
Ptr
getRtpDecoderBy
Id
(
CodecId
codecId
);
static
RtpCodec
::
Ptr
getRtpDecoderBy
Track
(
const
Track
::
Ptr
&
track
);
////////////////////////////////rtmp相关//////////////////////////////////
...
...
src/RtspMuxer/AACRtpCodec.cpp
查看文件 @
a6466405
...
...
@@ -76,6 +76,16 @@ void AACRtpEncoder::makeAACRtp(const void *data, unsigned int len, bool mark, ui
}
/////////////////////////////////////////////////////////////////////////////////////
AACRtpDecoder
::
AACRtpDecoder
(
const
Track
::
Ptr
&
track
){
auto
aacTrack
=
dynamic_pointer_cast
<
AACTrack
>
(
track
);
if
(
!
aacTrack
||
!
aacTrack
->
ready
()){
WarnL
<<
"该aac track无效!"
;
}
else
{
_aac_cfg
=
aacTrack
->
getAacCfg
();
}
_adts
=
obtainFrame
();
}
AACRtpDecoder
::
AACRtpDecoder
()
{
_adts
=
obtainFrame
();
}
...
...
@@ -85,6 +95,9 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() {
auto
frame
=
ResourcePoolHelper
<
AACFrame
>::
obtainObj
();
frame
->
aac_frame_length
=
7
;
frame
->
iPrefixSize
=
7
;
if
(
frame
->
syncword
==
0
&&
!
_aac_cfg
.
empty
())
{
makeAdtsHeader
(
_aac_cfg
,
*
frame
);
}
return
frame
;
}
...
...
@@ -92,13 +105,13 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
RtpCodec
::
inputRtp
(
rtppack
,
false
);
int
length
=
rtppack
->
length
-
rtppack
->
offset
;
if
(
_adts
->
aac_frame_length
+
length
>
sizeof
(
AACFrame
::
buffer
))
{
if
(
_adts
->
aac_frame_length
+
length
-
4
>
sizeof
(
AACFrame
::
buffer
))
{
_adts
->
aac_frame_length
=
7
;
WarnL
<<
"aac负载数据太长"
;
return
false
;
}
memcpy
(
_adts
->
buffer
+
_adts
->
aac_frame_length
,
rtppack
->
payload
+
rtppack
->
offset
,
length
);
_adts
->
aac_frame_length
+=
length
;
memcpy
(
_adts
->
buffer
+
_adts
->
aac_frame_length
,
rtppack
->
payload
+
rtppack
->
offset
+
4
,
length
-
4
);
_adts
->
aac_frame_length
+=
(
length
-
4
)
;
if
(
rtppack
->
mark
==
true
)
{
_adts
->
sequence
=
rtppack
->
sequence
;
_adts
->
timeStamp
=
rtppack
->
timeStamp
;
...
...
@@ -114,6 +127,7 @@ void AACRtpDecoder::onGetAAC(const AACFrame::Ptr &frame) {
_adts
=
obtainFrame
();
}
}
//namespace mediakit
...
...
src/RtspMuxer/AACRtpCodec.h
查看文件 @
a6466405
...
...
@@ -37,7 +37,7 @@ class AACRtpDecoder : public RtpCodec , public ResourcePoolHelper<AACFrame> {
public
:
typedef
std
::
shared_ptr
<
AACRtpDecoder
>
Ptr
;
AACRtpDecoder
();
AACRtpDecoder
(
const
Track
::
Ptr
&
track
);
~
AACRtpDecoder
()
{}
/**
...
...
@@ -50,15 +50,17 @@ public:
TrackType
getTrackType
()
const
override
{
return
TrackAudio
;
}
CodecId
getCodecId
()
const
override
{
return
CodecAAC
;
}
protected
:
AACRtpDecoder
();
private
:
void
onGetAAC
(
const
AACFrame
::
Ptr
&
frame
);
AACFrame
::
Ptr
obtainFrame
();
private
:
AACFrame
::
Ptr
_adts
;
string
_aac_cfg
;
};
...
...
src/RtspMuxer/RtspDemuxer.cpp
查看文件 @
a6466405
...
...
@@ -90,7 +90,7 @@ void RtspDemuxer::makeAudioTrack(const SdpTrack::Ptr &audio) {
_audioTrack
=
dynamic_pointer_cast
<
AudioTrack
>
(
Factory
::
getTrackBySdp
(
audio
));
if
(
_audioTrack
){
//生成RtpCodec对象以便解码rtp
_audioRtpDecoder
=
Factory
::
getRtpDecoderBy
Id
(
_audioTrack
->
getCodecId
()
);
_audioRtpDecoder
=
Factory
::
getRtpDecoderBy
Track
(
_audioTrack
);
if
(
_audioRtpDecoder
){
//设置rtp解码器代理,生成的frame写入该Track
_audioRtpDecoder
->
addDelegate
(
_audioTrack
);
...
...
@@ -106,7 +106,7 @@ void RtspDemuxer::makeVideoTrack(const SdpTrack::Ptr &video) {
_videoTrack
=
dynamic_pointer_cast
<
VideoTrack
>
(
Factory
::
getTrackBySdp
(
video
));
if
(
_videoTrack
){
//生成RtpCodec对象以便解码rtp
_videoRtpDecoder
=
Factory
::
getRtpDecoderBy
Id
(
_videoTrack
->
getCodecId
()
);
_videoRtpDecoder
=
Factory
::
getRtpDecoderBy
Track
(
_videoTrack
);
if
(
_videoRtpDecoder
){
//设置rtp解码器代理,生成的frame写入该Track
_videoRtpDecoder
->
addDelegate
(
_videoTrack
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论