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
2e3cee09
Commit
2e3cee09
authored
Apr 23, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hls/mp4录像/mp4点播/ts解析/ps解析初步支持G711
parent
eb67bc83
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
91 行增加
和
7 行删除
+91
-7
src/Extension/G711.h
+13
-0
src/Record/MP4Demuxer.cpp
+15
-0
src/Record/MP4Muxer.cpp
+32
-7
src/Record/MP4Muxer.h
+1
-0
src/Record/TsMuxer.cpp
+8
-0
src/Rtp/RtpProcess.cpp
+22
-0
没有找到文件。
src/Extension/G711.h
查看文件 @
2e3cee09
...
...
@@ -64,6 +64,19 @@ class G711FrameNoCacheAble : public FrameNoCacheAble {
public
:
typedef
std
::
shared_ptr
<
G711FrameNoCacheAble
>
Ptr
;
//兼容通用接口
G711FrameNoCacheAble
(
char
*
ptr
,
uint32_t
size
,
uint32_t
dts
,
uint32_t
pts
=
0
,
int
prefixeSize
=
0
){
_ptr
=
ptr
;
_size
=
size
;
_dts
=
dts
;
_prefixSize
=
prefixeSize
;
}
//兼容通用接口
void
setCodec
(
CodecId
codecId
){
_codecId
=
codecId
;
}
G711FrameNoCacheAble
(
CodecId
codecId
,
char
*
ptr
,
uint32_t
size
,
uint32_t
dts
,
int
prefixeSize
=
0
){
_codecId
=
codecId
;
_ptr
=
ptr
;
...
...
src/Record/MP4Demuxer.cpp
查看文件 @
2e3cee09
...
...
@@ -14,6 +14,7 @@
#include "Extension/H265.h"
#include "Extension/H264.h"
#include "Extension/AAC.h"
#include "Extension/G711.h"
using
namespace
toolkit
;
namespace
mediakit
{
...
...
@@ -120,6 +121,12 @@ void MP4Demuxer::onAudioTrack(uint32_t track_id, uint8_t object, int channel_cou
_track_to_codec
.
emplace
(
track_id
,
audio
);
}
break
;
case
MOV_OBJECT_G711a
:
case
MOV_OBJECT_G711u
:{
auto
audio
=
std
::
make_shared
<
G711Track
>
(
object
==
MOV_OBJECT_G711a
?
CodecG711A
:
CodecG711U
,
sample_rate
,
channel_count
,
bit_per_sample
/
channel_count
);
_track_to_codec
.
emplace
(
track_id
,
audio
);
}
break
;
default
:
WarnL
<<
"不支持该编码类型的MP4,已忽略:"
<<
getObjectName
(
object
);
break
;
...
...
@@ -223,8 +230,16 @@ Frame::Ptr MP4Demuxer::makeFrame(uint32_t track_id, const Buffer::Ptr &buf, int6
}
return
std
::
make_shared
<
FrameWrapper
<
H265FrameNoCacheAble
>
>
(
buf
,
pts
,
dts
,
4
);
}
case
CodecAAC
:
return
std
::
make_shared
<
FrameWrapper
<
AACFrameNoCacheAble
>
>
(
buf
,
pts
,
dts
,
0
);
case
CodecG711A
:
case
CodecG711U
:
{
auto
frame
=
std
::
make_shared
<
FrameWrapper
<
G711FrameNoCacheAble
>
>
(
buf
,
pts
,
dts
,
0
);
frame
->
setCodec
(
codec
);
return
frame
;
}
default
:
return
nullptr
;
}
...
...
src/Record/MP4Muxer.cpp
查看文件 @
2e3cee09
...
...
@@ -124,22 +124,47 @@ void MP4Muxer::inputFrame(const Frame::Ptr &frame) {
void
MP4Muxer
::
addTrack
(
const
Track
::
Ptr
&
track
)
{
switch
(
track
->
getCodecId
())
{
case
CodecG711A
:
case
CodecG711U
:
{
auto
audio_track
=
dynamic_pointer_cast
<
G711Track
>
(
track
);
if
(
!
audio_track
)
{
WarnL
<<
"不是G711 Track"
;
return
;
}
if
(
!
audio_track
->
ready
())
{
WarnL
<<
"G711 Track未就绪"
;
return
;
}
auto
track_id
=
mov_writer_add_audio
(
_mov_writter
.
get
(),
track
->
getCodecId
()
==
CodecG711A
?
MOV_OBJECT_G711a
:
MOV_OBJECT_G711u
,
audio_track
->
getAudioChannel
(),
audio_track
->
getAudioSampleBit
()
*
audio_track
->
getAudioChannel
(),
audio_track
->
getAudioSampleRate
(),
nullptr
,
0
);
if
(
track_id
<
0
)
{
WarnL
<<
"添加G711 Track失败:"
<<
track_id
;
return
;
}
_codec_to_trackid
[
track
->
getCodecId
()].
track_id
=
track_id
;
}
break
;
case
CodecAAC
:
{
auto
a
ac
_track
=
dynamic_pointer_cast
<
AACTrack
>
(
track
);
if
(
!
a
ac
_track
)
{
auto
a
udio
_track
=
dynamic_pointer_cast
<
AACTrack
>
(
track
);
if
(
!
a
udio
_track
)
{
WarnL
<<
"不是AAC Track"
;
return
;
}
if
(
!
a
ac
_track
->
ready
()){
if
(
!
a
udio
_track
->
ready
()){
WarnL
<<
"AAC Track未就绪"
;
return
;
}
auto
track_id
=
mov_writer_add_audio
(
_mov_writter
.
get
(),
MOV_OBJECT_AAC
,
a
ac
_track
->
getAudioChannel
(),
a
ac_track
->
getAudioSampleBit
()
*
aac
_track
->
getAudioChannel
(),
a
ac
_track
->
getAudioSampleRate
(),
a
ac
_track
->
getAacCfg
().
data
(),
2
);
a
udio
_track
->
getAudioChannel
(),
a
udio_track
->
getAudioSampleBit
()
*
audio
_track
->
getAudioChannel
(),
a
udio
_track
->
getAudioSampleRate
(),
a
udio
_track
->
getAacCfg
().
data
(),
2
);
if
(
track_id
<
0
){
WarnL
<<
"添加AAC Track失败:"
<<
track_id
;
return
;
...
...
src/Record/MP4Muxer.h
查看文件 @
2e3cee09
...
...
@@ -15,6 +15,7 @@
#include "Common/MediaSink.h"
#include "Extension/AAC.h"
#include "Extension/G711.h"
#include "Extension/H264.h"
#include "Extension/H265.h"
#include "Common/Stamp.h"
...
...
src/Record/TsMuxer.cpp
查看文件 @
2e3cee09
...
...
@@ -39,6 +39,14 @@ void TsMuxer::addTrack(const Track::Ptr &track) {
_codec_to_trackid
[
track
->
getCodecId
()].
track_id
=
mpeg_ts_add_stream
(
_context
,
PSI_STREAM_AAC
,
nullptr
,
0
);
}
break
;
case
CodecG711A
:
case
CodecG711U
:
{
//todo 此处未区分G711a和G711u
_codec_to_trackid
[
track
->
getCodecId
()].
track_id
=
mpeg_ts_add_stream
(
_context
,
PSI_STREAM_AUDIO_G711
,
nullptr
,
0
);
}
break
;
default
:
break
;
}
...
...
src/Rtp/RtpProcess.cpp
查看文件 @
2e3cee09
...
...
@@ -14,6 +14,7 @@
#include "Util/File.h"
#include "Extension/H265.h"
#include "Extension/AAC.h"
#include "Extension/G711.h"
namespace
mediakit
{
...
...
@@ -271,6 +272,27 @@ void RtpProcess::onDecode(int stream,int codecid,int flags,int64_t pts,int64_t d
_muxer
->
inputFrame
(
std
::
make_shared
<
AACFrameNoCacheAble
>
((
char
*
)
data
,
bytes
,
dts
,
0
,
7
));
break
;
}
case
STREAM_AUDIO_G711
:
{
_dts
=
dts
;
//todo 等待陈大佬更新ts/ps解析库,现在暂时固定为G711A
auto
codec
=
CodecG711A
;
if
(
!
_codecid_audio
)
{
//获取到音频
_codecid_audio
=
codecid
;
InfoL
<<
"got audio track: G711"
;
//G711传统只支持 8000/1/16的规格,FFmpeg貌似做了扩展,但是这里不管它了
auto
track
=
std
::
make_shared
<
G711Track
>
(
codec
,
8000
,
1
,
16
);
_muxer
->
addTrack
(
track
);
}
if
(
codecid
!=
_codecid_audio
)
{
WarnL
<<
"audio track change to G711 from codecid:"
<<
getCodecName
(
_codecid_audio
);
return
;
}
_muxer
->
inputFrame
(
std
::
make_shared
<
G711FrameNoCacheAble
>
(
codec
,
(
char
*
)
data
,
bytes
,
dts
));
break
;
}
default
:
if
(
codecid
!=
0
){
WarnL
<<
"unsupported codec type:"
<<
getCodecName
(
codecid
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论