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
a7a94f08
Commit
a7a94f08
authored
Mar 30, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sdp相关的代码移动到主目录
parent
a3d0d3b7
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
93 行增加
和
46 行删除
+93
-46
src/Extension/AAC.cpp
+1
-1
src/Extension/Frame.cpp
+55
-15
src/Extension/Frame.h
+19
-0
src/Extension/G711.cpp
+1
-1
src/Extension/H264.cpp
+1
-1
src/Extension/H265.cpp
+1
-1
src/Extension/L16.cpp
+1
-1
src/Extension/Opus.cpp
+1
-1
webrtc/Sdp.cpp
+12
-23
webrtc/Sdp.h
+1
-2
没有找到文件。
src/Extension/AAC.cpp
查看文件 @
a7a94f08
...
...
@@ -205,7 +205,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
MPEG4-GENERIC
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
"
<<
getCodecName
()
<<
"
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
string
configStr
;
char
buf
[
4
]
=
{
0
};
...
...
src/Extension/Frame.cpp
查看文件 @
a7a94f08
...
...
@@ -11,7 +11,7 @@
#include "Frame.h"
#include "H264.h"
#include "H265.h"
#include "Common/Parser.h"
using
namespace
std
;
using
namespace
toolkit
;
...
...
@@ -106,22 +106,10 @@ Frame::Ptr Frame::getCacheAbleFrame(const Frame::Ptr &frame){
return
std
::
make_shared
<
FrameCacheAble
>
(
frame
);
}
#define SWITCH_CASE(codec_id) case codec_id : return #codec_id
const
char
*
getCodecName
(
CodecId
codecId
)
{
switch
(
codecId
)
{
SWITCH_CASE
(
CodecH264
);
SWITCH_CASE
(
CodecH265
);
SWITCH_CASE
(
CodecAAC
);
SWITCH_CASE
(
CodecG711A
);
SWITCH_CASE
(
CodecG711U
);
SWITCH_CASE
(
CodecOpus
);
SWITCH_CASE
(
CodecL16
);
default
:
return
"unknown codec"
;
}
}
TrackType
getTrackType
(
CodecId
codecId
){
switch
(
codecId
){
case
CodecVP8
:
case
CodecVP9
:
case
CodecH264
:
case
CodecH265
:
return
TrackVideo
;
case
CodecAAC
:
...
...
@@ -133,6 +121,58 @@ TrackType getTrackType(CodecId codecId){
}
}
const
char
*
getCodecName
(
CodecId
codec
){
switch
(
codec
)
{
case
CodecH264
:
return
"H264"
;
case
CodecH265
:
return
"H265"
;
case
CodecAAC
:
return
"mpeg4-generic"
;
case
CodecG711A
:
return
"PCMA"
;
case
CodecG711U
:
return
"PCMU"
;
case
CodecOpus
:
return
"opus"
;
case
CodecVP8
:
return
"VP8"
;
case
CodecVP9
:
return
"VP9"
;
case
CodecL16
:
return
"L16"
;
default
:
return
"invalid"
;
}
}
static
map
<
string
,
CodecId
,
StrCaseCompare
>
codec_map
=
{
{
"H264"
,
CodecH264
},
{
"H265"
,
CodecH265
},
{
"mpeg4-generic"
,
CodecAAC
},
{
"PCMA"
,
CodecG711A
},
{
"PCMU"
,
CodecG711U
},
{
"opus"
,
CodecOpus
},
{
"VP8"
,
CodecVP8
},
{
"VP9"
,
CodecVP9
},
{
"L16"
,
CodecL16
}
};
CodecId
getCodecId
(
const
string
&
str
){
auto
it
=
codec_map
.
find
(
str
);
return
it
==
codec_map
.
end
()
?
CodecInvalid
:
it
->
second
;
}
static
map
<
string
,
TrackType
,
StrCaseCompare
>
track_str_map
=
{
{
"video"
,
TrackVideo
},
{
"audio"
,
TrackAudio
},
{
"application"
,
TrackApplication
}
};
TrackType
getTrackType
(
const
string
&
str
)
{
auto
it
=
track_str_map
.
find
(
str
);
return
it
==
track_str_map
.
end
()
?
TrackInvalid
:
it
->
second
;
}
const
char
*
getTrackString
(
TrackType
type
){
switch
(
type
)
{
case
TrackVideo
:
return
"video"
;
case
TrackAudio
:
return
"audio"
;
case
TrackApplication
:
return
"application"
;
default:
return
"invalid"
;
}
}
const
char
*
CodecInfo
::
getCodecName
()
{
return
mediakit
::
getCodecName
(
getCodecId
());
}
...
...
src/Extension/Frame.h
查看文件 @
a7a94f08
...
...
@@ -30,6 +30,8 @@ typedef enum {
CodecG711U
,
CodecOpus
,
CodecL16
,
CodecVP8
,
CodecVP9
,
CodecMax
=
0x7FFF
}
CodecId
;
...
...
@@ -43,6 +45,23 @@ typedef enum {
}
TrackType
;
/**
* 字符串转媒体类型转
*/
TrackType
getTrackType
(
const
string
&
str
);
/**
* 媒体类型转字符串
*/
const
char
*
getTrackString
(
TrackType
type
);
/**
* 根据SDP中描述获取codec_id
* @param str
* @return
*/
CodecId
getCodecId
(
const
string
&
str
);
/**
* 获取编码器名称
*/
const
char
*
getCodecName
(
CodecId
codecId
);
...
...
src/Extension/G711.cpp
查看文件 @
a7a94f08
...
...
@@ -33,7 +33,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
(
codecId
==
CodecG711A
?
" PCMA/"
:
" PCMU/"
)
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
" "
<<
getCodecName
()
<<
"/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=control:trackID="
<<
(
int
)
TrackAudio
<<
"
\r\n
"
;
}
...
...
src/Extension/H264.cpp
查看文件 @
a7a94f08
...
...
@@ -235,7 +235,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
H264
/"
<<
90000
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
"
<<
getCodecName
()
<<
"
/"
<<
90000
<<
"
\r\n
"
;
_printer
<<
"a=fmtp:"
<<
payload_type
<<
" packetization-mode=1; profile-level-id="
;
char
strTemp
[
1024
];
...
...
src/Extension/H265.cpp
查看文件 @
a7a94f08
...
...
@@ -252,7 +252,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
H265
/"
<<
90000
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
"
<<
getCodecName
()
<<
"
/"
<<
90000
<<
"
\r\n
"
;
_printer
<<
"a=fmtp:"
<<
payload_type
<<
" "
;
_printer
<<
"sprop-vps="
;
_printer
<<
encodeBase64
(
strVPS
)
<<
"; "
;
...
...
src/Extension/L16.cpp
查看文件 @
a7a94f08
...
...
@@ -33,7 +33,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
L16
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
"
<<
getCodecName
()
<<
"
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=control:trackID="
<<
(
int
)
TrackAudio
<<
"
\r\n
"
;
}
...
...
src/Extension/Opus.cpp
查看文件 @
a7a94f08
...
...
@@ -31,7 +31,7 @@ public:
if
(
bitrate
)
{
_printer
<<
"b=AS:"
<<
bitrate
<<
"
\r\n
"
;
}
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
opus
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=rtpmap:"
<<
payload_type
<<
"
"
<<
getCodecName
()
<<
"
/"
<<
sample_rate
<<
"/"
<<
channels
<<
"
\r\n
"
;
_printer
<<
"a=control:trackID="
<<
(
int
)
TrackAudio
<<
"
\r\n
"
;
}
...
...
webrtc/Sdp.cpp
查看文件 @
a7a94f08
...
...
@@ -93,26 +93,6 @@ static bool registerAllItem(){
return
true
;
}
static
map
<
string
,
TrackType
,
StrCaseCompare
>
track_str_map
=
{
{
"video"
,
TrackVideo
},
{
"audio"
,
TrackAudio
},
{
"application"
,
TrackApplication
}
};
TrackType
getTrackType
(
const
string
&
str
)
{
auto
it
=
track_str_map
.
find
(
str
);
return
it
==
track_str_map
.
end
()
?
TrackInvalid
:
it
->
second
;
}
const
char
*
getTrackString
(
TrackType
type
){
switch
(
type
)
{
case
TrackVideo
:
return
"video"
;
case
TrackAudio
:
return
"audio"
;
case
TrackApplication
:
return
"application"
;
default:
return
"invalid"
;
}
}
static
map
<
string
,
DtlsRole
,
StrCaseCompare
>
dtls_role_map
=
{
{
"active"
,
DtlsRole
::
active
},
{
"passive"
,
DtlsRole
::
passive
},
...
...
@@ -1059,6 +1039,18 @@ const RtcCodecPlan *RtcMedia::getPlan(const char *codec) const{
return
nullptr
;
}
const
RtcCodecPlan
*
RtcMedia
::
getRelatedRtxPlan
(
uint8_t
pt
)
const
{
for
(
auto
&
item
:
plan
)
{
if
(
strcasecmp
(
item
.
codec
.
data
(),
"rtx"
)
==
0
)
{
auto
apt
=
atoi
(
item
.
getFmtp
(
"apt"
).
data
());
if
(
pt
==
apt
)
{
return
&
item
;
}
}
}
return
nullptr
;
}
void
RtcMedia
::
checkValid
()
const
{
CHECK
(
type
!=
TrackInvalid
);
CHECK
(
!
mid
.
empty
());
...
...
@@ -1071,9 +1063,6 @@ void RtcMedia::checkValid() const{
if
(
rtx_plan
)
{
//开启rtx后必须指定rtx_ssrc
CHECK
(
!
rtx_ssrc
.
empty
()
||
!
send_rtp
);
auto
apt
=
atoi
(
rtx_plan
->
getFmtp
(
"apt"
).
data
());
//开启rtx后必须指定其关联的其他的plan
CHECK
(
getPlan
(
apt
));
}
}
...
...
webrtc/Sdp.h
查看文件 @
a7a94f08
...
...
@@ -72,8 +72,6 @@ enum class SdpType {
answer
};
TrackType
getTrackType
(
const
string
&
str
);
const
char
*
getTrackString
(
TrackType
type
);
DtlsRole
getDtlsRole
(
const
string
&
str
);
const
char
*
getDtlsRoleString
(
DtlsRole
role
);
RtpDirection
getRtpDirection
(
const
string
&
str
);
...
...
@@ -591,6 +589,7 @@ public:
void
checkValid
()
const
;
const
RtcCodecPlan
*
getPlan
(
uint8_t
pt
)
const
;
const
RtcCodecPlan
*
getPlan
(
const
char
*
codec
)
const
;
const
RtcCodecPlan
*
getRelatedRtxPlan
(
uint8_t
pt
)
const
;
};
class
RtcSession
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论