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 个修改的文件
包含
37 行增加
和
17 行删除
+37
-17
src/Extension/AAC.h
+7
-2
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:
...
@@ -82,7 +82,7 @@ public:
return
false
;
return
false
;
}
}
public
:
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
id
;
//1 bslbf MPEG 标示符, 设置为1
unsigned
int
layer
;
//2 uimsbf Indicates which layer is used. Set to ‘00’
unsigned
int
layer
;
//2 uimsbf Indicates which layer is used. Set to ‘00’
unsigned
int
protection_absent
;
//1 bslbf 表示是否误码校验
unsigned
int
protection_absent
;
//1 bslbf 表示是否误码校验
...
@@ -234,10 +234,15 @@ public:
...
@@ -234,10 +234,15 @@ public:
* @param frame 数据帧
* @param frame 数据帧
*/
*/
void
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
{
void
inputFrame
(
const
Frame
::
Ptr
&
frame
)
override
{
if
(
_cfg
.
empty
()
&&
frame
->
prefixSize
()
>=
7
){
if
(
_cfg
.
empty
()){
//未获取到aac_cfg信息
if
(
frame
->
prefixSize
()
>=
7
)
{
//7个字节的adts头
//7个字节的adts头
_cfg
=
makeAdtsConfig
(
reinterpret_cast
<
const
uint8_t
*>
(
frame
->
data
()));
_cfg
=
makeAdtsConfig
(
reinterpret_cast
<
const
uint8_t
*>
(
frame
->
data
()));
onReady
();
onReady
();
}
else
{
WarnL
<<
"无法获取adts头!"
;
}
}
}
AudioTrack
::
inputFrame
(
frame
);
AudioTrack
::
inputFrame
(
frame
);
}
}
...
...
src/Extension/Factory.cpp
查看文件 @
a6466405
...
@@ -181,16 +181,16 @@ RtpCodec::Ptr Factory::getRtpEncoderById(CodecId codecId,
...
@@ -181,16 +181,16 @@ RtpCodec::Ptr Factory::getRtpEncoderById(CodecId codecId,
}
}
}
}
RtpCodec
::
Ptr
Factory
::
getRtpDecoderBy
Id
(
CodecId
codecId
)
{
RtpCodec
::
Ptr
Factory
::
getRtpDecoderBy
Track
(
const
Track
::
Ptr
&
track
)
{
switch
(
codecId
){
switch
(
track
->
getCodecId
()
){
case
CodecH264
:
case
CodecH264
:
return
std
::
make_shared
<
H264RtpDecoder
>
();
return
std
::
make_shared
<
H264RtpDecoder
>
();
case
CodecH265
:
case
CodecH265
:
return
std
::
make_shared
<
H265RtpDecoder
>
();
return
std
::
make_shared
<
H265RtpDecoder
>
();
case
CodecAAC
:
case
CodecAAC
:
return
std
::
make_shared
<
AACRtpDecoder
>
();
return
std
::
make_shared
<
AACRtpDecoder
>
(
track
->
clone
()
);
default
:
default
:
WarnL
<<
"暂不支持该CodecId:"
<<
codecId
;
WarnL
<<
"暂不支持该CodecId:"
<<
track
->
getCodecId
()
;
return
nullptr
;
return
nullptr
;
}
}
}
}
...
...
src/Extension/Factory.h
查看文件 @
a6466405
...
@@ -81,12 +81,11 @@ public:
...
@@ -81,12 +81,11 @@ public:
uint8_t
ui8Interleaved
);
uint8_t
ui8Interleaved
);
/**
/**
* 根据CodecId生成Rtp解包器
* 根据Track生成Rtp解包器
* @param codecId
* @param track
* @param ui32SampleRate
* @return
* @return
*/
*/
static
RtpCodec
::
Ptr
getRtpDecoderBy
Id
(
CodecId
codecId
);
static
RtpCodec
::
Ptr
getRtpDecoderBy
Track
(
const
Track
::
Ptr
&
track
);
////////////////////////////////rtmp相关//////////////////////////////////
////////////////////////////////rtmp相关//////////////////////////////////
...
...
src/RtspMuxer/AACRtpCodec.cpp
查看文件 @
a6466405
...
@@ -76,6 +76,16 @@ void AACRtpEncoder::makeAACRtp(const void *data, unsigned int len, bool mark, ui
...
@@ -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
()
{
AACRtpDecoder
::
AACRtpDecoder
()
{
_adts
=
obtainFrame
();
_adts
=
obtainFrame
();
}
}
...
@@ -85,6 +95,9 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() {
...
@@ -85,6 +95,9 @@ AACFrame::Ptr AACRtpDecoder::obtainFrame() {
auto
frame
=
ResourcePoolHelper
<
AACFrame
>::
obtainObj
();
auto
frame
=
ResourcePoolHelper
<
AACFrame
>::
obtainObj
();
frame
->
aac_frame_length
=
7
;
frame
->
aac_frame_length
=
7
;
frame
->
iPrefixSize
=
7
;
frame
->
iPrefixSize
=
7
;
if
(
frame
->
syncword
==
0
&&
!
_aac_cfg
.
empty
())
{
makeAdtsHeader
(
_aac_cfg
,
*
frame
);
}
return
frame
;
return
frame
;
}
}
...
@@ -92,13 +105,13 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
...
@@ -92,13 +105,13 @@ bool AACRtpDecoder::inputRtp(const RtpPacket::Ptr &rtppack, bool key_pos) {
RtpCodec
::
inputRtp
(
rtppack
,
false
);
RtpCodec
::
inputRtp
(
rtppack
,
false
);
int
length
=
rtppack
->
length
-
rtppack
->
offset
;
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
;
_adts
->
aac_frame_length
=
7
;
WarnL
<<
"aac负载数据太长"
;
WarnL
<<
"aac负载数据太长"
;
return
false
;
return
false
;
}
}
memcpy
(
_adts
->
buffer
+
_adts
->
aac_frame_length
,
rtppack
->
payload
+
rtppack
->
offset
,
length
);
memcpy
(
_adts
->
buffer
+
_adts
->
aac_frame_length
,
rtppack
->
payload
+
rtppack
->
offset
+
4
,
length
-
4
);
_adts
->
aac_frame_length
+=
length
;
_adts
->
aac_frame_length
+=
(
length
-
4
)
;
if
(
rtppack
->
mark
==
true
)
{
if
(
rtppack
->
mark
==
true
)
{
_adts
->
sequence
=
rtppack
->
sequence
;
_adts
->
sequence
=
rtppack
->
sequence
;
_adts
->
timeStamp
=
rtppack
->
timeStamp
;
_adts
->
timeStamp
=
rtppack
->
timeStamp
;
...
@@ -114,6 +127,7 @@ void AACRtpDecoder::onGetAAC(const AACFrame::Ptr &frame) {
...
@@ -114,6 +127,7 @@ void AACRtpDecoder::onGetAAC(const AACFrame::Ptr &frame) {
_adts
=
obtainFrame
();
_adts
=
obtainFrame
();
}
}
}
//namespace mediakit
}
//namespace mediakit
...
...
src/RtspMuxer/AACRtpCodec.h
查看文件 @
a6466405
...
@@ -37,7 +37,7 @@ class AACRtpDecoder : public RtpCodec , public ResourcePoolHelper<AACFrame> {
...
@@ -37,7 +37,7 @@ class AACRtpDecoder : public RtpCodec , public ResourcePoolHelper<AACFrame> {
public
:
public
:
typedef
std
::
shared_ptr
<
AACRtpDecoder
>
Ptr
;
typedef
std
::
shared_ptr
<
AACRtpDecoder
>
Ptr
;
AACRtpDecoder
();
AACRtpDecoder
(
const
Track
::
Ptr
&
track
);
~
AACRtpDecoder
()
{}
~
AACRtpDecoder
()
{}
/**
/**
...
@@ -50,15 +50,17 @@ public:
...
@@ -50,15 +50,17 @@ public:
TrackType
getTrackType
()
const
override
{
TrackType
getTrackType
()
const
override
{
return
TrackAudio
;
return
TrackAudio
;
}
}
CodecId
getCodecId
()
const
override
{
CodecId
getCodecId
()
const
override
{
return
CodecAAC
;
return
CodecAAC
;
}
}
protected
:
AACRtpDecoder
();
private
:
private
:
void
onGetAAC
(
const
AACFrame
::
Ptr
&
frame
);
void
onGetAAC
(
const
AACFrame
::
Ptr
&
frame
);
AACFrame
::
Ptr
obtainFrame
();
AACFrame
::
Ptr
obtainFrame
();
private
:
private
:
AACFrame
::
Ptr
_adts
;
AACFrame
::
Ptr
_adts
;
string
_aac_cfg
;
};
};
...
...
src/RtspMuxer/RtspDemuxer.cpp
查看文件 @
a6466405
...
@@ -90,7 +90,7 @@ void RtspDemuxer::makeAudioTrack(const SdpTrack::Ptr &audio) {
...
@@ -90,7 +90,7 @@ void RtspDemuxer::makeAudioTrack(const SdpTrack::Ptr &audio) {
_audioTrack
=
dynamic_pointer_cast
<
AudioTrack
>
(
Factory
::
getTrackBySdp
(
audio
));
_audioTrack
=
dynamic_pointer_cast
<
AudioTrack
>
(
Factory
::
getTrackBySdp
(
audio
));
if
(
_audioTrack
){
if
(
_audioTrack
){
//生成RtpCodec对象以便解码rtp
//生成RtpCodec对象以便解码rtp
_audioRtpDecoder
=
Factory
::
getRtpDecoderBy
Id
(
_audioTrack
->
getCodecId
()
);
_audioRtpDecoder
=
Factory
::
getRtpDecoderBy
Track
(
_audioTrack
);
if
(
_audioRtpDecoder
){
if
(
_audioRtpDecoder
){
//设置rtp解码器代理,生成的frame写入该Track
//设置rtp解码器代理,生成的frame写入该Track
_audioRtpDecoder
->
addDelegate
(
_audioTrack
);
_audioRtpDecoder
->
addDelegate
(
_audioTrack
);
...
@@ -106,7 +106,7 @@ void RtspDemuxer::makeVideoTrack(const SdpTrack::Ptr &video) {
...
@@ -106,7 +106,7 @@ void RtspDemuxer::makeVideoTrack(const SdpTrack::Ptr &video) {
_videoTrack
=
dynamic_pointer_cast
<
VideoTrack
>
(
Factory
::
getTrackBySdp
(
video
));
_videoTrack
=
dynamic_pointer_cast
<
VideoTrack
>
(
Factory
::
getTrackBySdp
(
video
));
if
(
_videoTrack
){
if
(
_videoTrack
){
//生成RtpCodec对象以便解码rtp
//生成RtpCodec对象以便解码rtp
_videoRtpDecoder
=
Factory
::
getRtpDecoderBy
Id
(
_videoTrack
->
getCodecId
()
);
_videoRtpDecoder
=
Factory
::
getRtpDecoderBy
Track
(
_videoTrack
);
if
(
_videoRtpDecoder
){
if
(
_videoRtpDecoder
){
//设置rtp解码器代理,生成的frame写入该Track
//设置rtp解码器代理,生成的frame写入该Track
_videoRtpDecoder
->
addDelegate
(
_videoTrack
);
_videoRtpDecoder
->
addDelegate
(
_videoTrack
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论