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
3efda8fd
Commit
3efda8fd
authored
Apr 18, 2020
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
根据playload type生成track
parent
bacf8f10
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
48 行增加
和
30 行删除
+48
-30
src/Extension/Factory.cpp
+8
-0
src/Rtsp/Rtsp.cpp
+14
-5
src/Rtsp/Rtsp.h
+26
-25
没有找到文件。
src/Extension/Factory.cpp
查看文件 @
3efda8fd
...
@@ -84,6 +84,14 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
...
@@ -84,6 +84,14 @@ Track::Ptr Factory::getTrackBySdp(const SdpTrack::Ptr &track) {
return
std
::
make_shared
<
H265Track
>
(
vps
,
sps
,
pps
,
0
,
0
,
0
);
return
std
::
make_shared
<
H265Track
>
(
vps
,
sps
,
pps
,
0
,
0
,
0
);
}
}
//可以根据传统的payload type 获取编码类型以及采样率等信息
CodecId
codec_id
=
RtpPayload
::
getCodecId
(
track
->
_pt
);
switch
(
codec_id
){
case
CodecG711A
:
case
CodecG711U
:
return
std
::
make_shared
<
G711Track
>
(
codec_id
,
track
->
_samplerate
,
track
->
_channel
,
16
);
default
:
break
;
}
WarnL
<<
"暂不支持该sdp:"
<<
track
->
getName
();
WarnL
<<
"暂不支持该sdp:"
<<
track
->
getName
();
return
nullptr
;
return
nullptr
;
}
}
...
...
src/Rtsp/Rtsp.cpp
查看文件 @
3efda8fd
...
@@ -16,7 +16,7 @@ namespace mediakit{
...
@@ -16,7 +16,7 @@ namespace mediakit{
int
RtpPayload
::
getClockRate
(
int
pt
){
int
RtpPayload
::
getClockRate
(
int
pt
){
switch
(
pt
){
switch
(
pt
){
#define SWITCH_CASE(name, type, value, clock_rate, channel) case value : return clock_rate;
#define SWITCH_CASE(name, type, value, clock_rate, channel
, codec_id
) case value : return clock_rate;
RTP_PT_MAP
(
SWITCH_CASE
)
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
#undef SWITCH_CASE
default
:
return
90000
;
default
:
return
90000
;
...
@@ -25,7 +25,7 @@ int RtpPayload::getClockRate(int pt){
...
@@ -25,7 +25,7 @@ int RtpPayload::getClockRate(int pt){
TrackType
RtpPayload
::
getTrackType
(
int
pt
){
TrackType
RtpPayload
::
getTrackType
(
int
pt
){
switch
(
pt
){
switch
(
pt
){
#define SWITCH_CASE(name, type, value, clock_rate, channel) case value : return type;
#define SWITCH_CASE(name, type, value, clock_rate, channel
, codec_id
) case value : return type;
RTP_PT_MAP
(
SWITCH_CASE
)
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
#undef SWITCH_CASE
default
:
return
TrackInvalid
;
default
:
return
TrackInvalid
;
...
@@ -34,7 +34,7 @@ TrackType RtpPayload::getTrackType(int pt){
...
@@ -34,7 +34,7 @@ TrackType RtpPayload::getTrackType(int pt){
int
RtpPayload
::
getAudioChannel
(
int
pt
){
int
RtpPayload
::
getAudioChannel
(
int
pt
){
switch
(
pt
){
switch
(
pt
){
#define SWITCH_CASE(name, type, value, clock_rate, channel) case value : return channel;
#define SWITCH_CASE(name, type, value, clock_rate, channel
, codec_id
) case value : return channel;
RTP_PT_MAP
(
SWITCH_CASE
)
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
#undef SWITCH_CASE
default
:
return
1
;
default
:
return
1
;
...
@@ -43,13 +43,22 @@ int RtpPayload::getAudioChannel(int pt){
...
@@ -43,13 +43,22 @@ int RtpPayload::getAudioChannel(int pt){
const
char
*
RtpPayload
::
getName
(
int
pt
){
const
char
*
RtpPayload
::
getName
(
int
pt
){
switch
(
pt
){
switch
(
pt
){
#define SWITCH_CASE(name, type, value, clock_rate, channel) case value : return #name;
#define SWITCH_CASE(name, type, value, clock_rate, channel
, codec_id
) case value : return #name;
RTP_PT_MAP
(
SWITCH_CASE
)
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
#undef SWITCH_CASE
default
:
return
"unknown payload type"
;
default
:
return
"unknown payload type"
;
}
}
}
}
CodecId
RtpPayload
::
getCodecId
(
int
pt
)
{
switch
(
pt
)
{
#define SWITCH_CASE(name, type, value, clock_rate, channel, codec_id) case value : return codec_id;
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
default
:
return
CodecInvalid
;
}
}
static
void
getAttrSdp
(
const
map
<
string
,
string
>
&
attr
,
_StrPrinter
&
printer
){
static
void
getAttrSdp
(
const
map
<
string
,
string
>
&
attr
,
_StrPrinter
&
printer
){
const
map
<
string
,
string
>::
value_type
*
ptr
=
nullptr
;
const
map
<
string
,
string
>::
value_type
*
ptr
=
nullptr
;
for
(
auto
&
pr
:
attr
){
for
(
auto
&
pr
:
attr
){
...
@@ -70,7 +79,7 @@ static void getAttrSdp(const map<string, string> &attr, _StrPrinter &printer){
...
@@ -70,7 +79,7 @@ static void getAttrSdp(const map<string, string> &attr, _StrPrinter &printer){
string
SdpTrack
::
getName
()
const
{
string
SdpTrack
::
getName
()
const
{
switch
(
_pt
){
switch
(
_pt
){
#define SWITCH_CASE(name, type, value, clock_rate, channel) case value : return #name;
#define SWITCH_CASE(name, type, value, clock_rate, channel
, codec_id
) case value : return #name;
RTP_PT_MAP
(
SWITCH_CASE
)
RTP_PT_MAP
(
SWITCH_CASE
)
#undef SWITCH_CASE
#undef SWITCH_CASE
default
:
return
_codec
;
default
:
return
_codec
;
...
...
src/Rtsp/Rtsp.h
查看文件 @
3efda8fd
...
@@ -34,33 +34,33 @@ typedef enum {
...
@@ -34,33 +34,33 @@ typedef enum {
}
eRtpType
;
}
eRtpType
;
#define RTP_PT_MAP(XX) \
#define RTP_PT_MAP(XX) \
XX(PCMU, TrackAudio, 0, 8000, 1) \
XX(PCMU, TrackAudio, 0, 8000, 1
, CodecG711U
) \
XX(GSM, TrackAudio , 3, 8000, 1) \
XX(GSM, TrackAudio , 3, 8000, 1
, CodecInvalid
) \
XX(G723, TrackAudio, 4, 8000, 1) \
XX(G723, TrackAudio, 4, 8000, 1
, CodecInvalid
) \
XX(DVI4_8000, TrackAudio, 5, 8000, 1) \
XX(DVI4_8000, TrackAudio, 5, 8000, 1
, CodecInvalid
) \
XX(DVI4_16000, TrackAudio, 6, 16000, 1) \
XX(DVI4_16000, TrackAudio, 6, 16000, 1
, CodecInvalid
) \
XX(LPC, TrackAudio, 7, 8000, 1) \
XX(LPC, TrackAudio, 7, 8000, 1
, CodecInvalid
) \
XX(PCMA, TrackAudio, 8, 8000, 1) \
XX(PCMA, TrackAudio, 8, 8000, 1
, CodecG711A
) \
XX(G722, TrackAudio, 9, 8000, 1) \
XX(G722, TrackAudio, 9, 8000, 1
, CodecInvalid
) \
XX(L16_Stereo, TrackAudio, 10, 44100, 2) \
XX(L16_Stereo, TrackAudio, 10, 44100, 2
, CodecInvalid
) \
XX(L16_Mono, TrackAudio, 11, 44100, 1) \
XX(L16_Mono, TrackAudio, 11, 44100, 1
, CodecInvalid
) \
XX(QCELP, TrackAudio, 12, 8000, 1) \
XX(QCELP, TrackAudio, 12, 8000, 1
, CodecInvalid
) \
XX(CN, TrackAudio, 13, 8000, 1) \
XX(CN, TrackAudio, 13, 8000, 1
, CodecInvalid
) \
XX(MPA, TrackAudio, 14, 90000, 1) \
XX(MPA, TrackAudio, 14, 90000, 1
, CodecInvalid
) \
XX(G728, TrackAudio, 15, 8000, 1) \
XX(G728, TrackAudio, 15, 8000, 1
, CodecInvalid
) \
XX(DVI4_11025, TrackAudio, 16, 11025, 1) \
XX(DVI4_11025, TrackAudio, 16, 11025, 1
, CodecInvalid
) \
XX(DVI4_22050, TrackAudio, 17, 22050, 1) \
XX(DVI4_22050, TrackAudio, 17, 22050, 1
, CodecInvalid
) \
XX(G729, TrackAudio, 18, 8000, 1) \
XX(G729, TrackAudio, 18, 8000, 1
, CodecInvalid
) \
XX(CelB, TrackVideo, 25, 90000, 1) \
XX(CelB, TrackVideo, 25, 90000, 1
, CodecInvalid
) \
XX(JPEG, TrackVideo, 26, 90000, 1) \
XX(JPEG, TrackVideo, 26, 90000, 1
, CodecInvalid
) \
XX(nv, TrackVideo, 28, 90000, 1) \
XX(nv, TrackVideo, 28, 90000, 1
, CodecInvalid
) \
XX(H261, TrackVideo, 31, 90000, 1) \
XX(H261, TrackVideo, 31, 90000, 1
, CodecInvalid
) \
XX(MPV, TrackVideo, 32, 90000, 1) \
XX(MPV, TrackVideo, 32, 90000, 1
, CodecInvalid
) \
XX(MP2T, TrackVideo, 33, 90000, 1) \
XX(MP2T, TrackVideo, 33, 90000, 1
, CodecInvalid
) \
XX(H263, TrackVideo, 34, 90000, 1) \
XX(H263, TrackVideo, 34, 90000, 1
, CodecInvalid
) \
typedef
enum
{
typedef
enum
{
#define ENUM_DEF(name, type, value, clock_rate, channel) PT_ ## name = value,
#define ENUM_DEF(name, type, value, clock_rate, channel
, codec_id
) PT_ ## name = value,
RTP_PT_MAP
(
ENUM_DEF
)
RTP_PT_MAP
(
ENUM_DEF
)
#undef ENUM_DEF
#undef ENUM_DEF
PT_MAX
=
128
PT_MAX
=
128
...
@@ -88,6 +88,7 @@ public:
...
@@ -88,6 +88,7 @@ public:
static
TrackType
getTrackType
(
int
pt
);
static
TrackType
getTrackType
(
int
pt
);
static
int
getAudioChannel
(
int
pt
);
static
int
getAudioChannel
(
int
pt
);
static
const
char
*
getName
(
int
pt
);
static
const
char
*
getName
(
int
pt
);
static
CodecId
getCodecId
(
int
pt
);
private
:
private
:
RtpPayload
()
=
delete
;
RtpPayload
()
=
delete
;
~
RtpPayload
()
=
delete
;
~
RtpPayload
()
=
delete
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论