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
9a2f2cbf
Commit
9a2f2cbf
authored
Apr 02, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善rtsp sdp匹配
parent
ee072191
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
53 行增加
和
15 行删除
+53
-15
webrtc/Sdp.cpp
+19
-10
webrtc/Sdp.h
+1
-1
webrtc/WebRtcTransport.cpp
+31
-1
webrtc/WebRtcTransport.h
+2
-3
没有找到文件。
webrtc/Sdp.cpp
查看文件 @
9a2f2cbf
...
...
@@ -4,7 +4,9 @@
#include "Sdp.h"
#include "Common/Parser.h"
#include "Rtsp/Rtsp.h"
#include <inttypes.h>
using
namespace
mediakit
;
using
onCreateSdpItem
=
function
<
SdpItem
::
Ptr
(
const
string
&
key
,
const
string
&
value
)
>
;
static
map
<
string
,
onCreateSdpItem
,
StrCaseCompare
>
sdpItemCreator
;
...
...
@@ -596,11 +598,11 @@ void SdpAttrFmtp::parse(const string &str) {
auto
vec
=
split
(
str
.
substr
(
pos
+
1
),
";"
);
for
(
auto
&
item
:
vec
)
{
trim
(
item
);
auto
p
r_vec
=
split
(
item
,
"="
);
if
(
pr_vec
.
size
()
!=
2
)
{
auto
p
os
=
item
.
find
(
'='
);
if
(
pos
==
string
::
npos
)
{
SDP_THROW
();
}
arr
.
emplace_back
(
std
::
make_pair
(
pr_vec
[
0
],
pr_vec
[
1
]
));
arr
.
emplace_back
(
std
::
make_pair
(
item
.
substr
(
0
,
pos
),
item
.
substr
(
pos
+
1
)
));
}
if
(
arr
.
empty
())
{
SDP_THROW
();
...
...
@@ -746,7 +748,7 @@ string SdpAttrCandidate::toString() const {
return
SdpItem
::
toString
();
}
void
RtcSession
::
loadFrom
(
const
string
&
str
)
{
void
RtcSession
::
loadFrom
(
const
string
&
str
,
bool
check
)
{
RtcSessionSdp
sdp
;
sdp
.
parse
(
str
);
...
...
@@ -887,12 +889,17 @@ void RtcSession::loadFrom(const string &str) {
auto
&
plan
=
rtc_media
.
plan
.
back
();
auto
rtpmap_it
=
rtpmap_map
.
find
(
pt
);
if
(
rtpmap_it
==
rtpmap_map
.
end
())
{
throw
std
::
invalid_argument
(
StrPrinter
<<
"该pt不存在相对于的a=rtpmap:"
<<
pt
);
plan
.
pt
=
pt
;
plan
.
codec
=
RtpPayload
::
getCodecId
(
pt
);
plan
.
sample_rate
=
RtpPayload
::
getClockRate
(
pt
);
plan
.
channel
=
RtpPayload
::
getAudioChannel
(
pt
);
}
else
{
plan
.
pt
=
rtpmap_it
->
second
.
pt
;
plan
.
codec
=
rtpmap_it
->
second
.
codec
;
plan
.
sample_rate
=
rtpmap_it
->
second
.
sample_rate
;
plan
.
channel
=
rtpmap_it
->
second
.
channel
;
}
plan
.
pt
=
rtpmap_it
->
second
.
pt
;
plan
.
codec
=
rtpmap_it
->
second
.
codec
;
plan
.
sample_rate
=
rtpmap_it
->
second
.
sample_rate
;
plan
.
channel
=
rtpmap_it
->
second
.
channel
;
auto
fmtp_it
=
fmtp_map
.
find
(
pt
);
if
(
fmtp_it
!=
fmtp_map
.
end
())
{
plan
.
fmtp
=
fmtp_it
->
second
.
arr
;
...
...
@@ -905,7 +912,9 @@ void RtcSession::loadFrom(const string &str) {
}
group
=
sdp
.
getItemClass
<
SdpAttrGroup
>
(
'a'
,
"group"
);
checkValid
();
if
(
check
)
{
checkValid
();
}
}
std
::
shared_ptr
<
SdpItem
>
wrapSdpAttr
(
SdpItem
::
Ptr
item
){
...
...
webrtc/Sdp.h
查看文件 @
9a2f2cbf
...
...
@@ -649,7 +649,7 @@ public:
vector
<
RtcMedia
>
media
;
SdpAttrGroup
group
;
void
loadFrom
(
const
string
&
sdp
);
void
loadFrom
(
const
string
&
sdp
,
bool
check
=
true
);
void
checkValid
()
const
;
string
toString
()
const
;
RtcMedia
*
getMedia
(
TrackType
type
);
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
9a2f2cbf
...
...
@@ -109,7 +109,6 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
fingerprint
.
hash
=
getFingerprint
(
fingerprint
.
algorithm
,
_dtls_transport
);
RtcConfigure
configure
;
configure
.
setDefaultSetting
(
_ice_server
->
GetUsernameFragment
(),
_ice_server
->
GetPassword
(),
RtpDirection
::
recvonly
,
fingerprint
);
configure
.
addCandidate
(
*
getIceCandidate
());
onRtcConfigure
(
configure
);
//// 生成answer sdp ////
...
...
@@ -217,6 +216,7 @@ void WebRtcTransportImp::onStartWebRTC() {
}
void
WebRtcTransportImp
::
onSendRtp
(
const
RtpPacket
::
Ptr
&
rtp
,
bool
flush
){
//需要修改pt
InfoL
<<
flush
;
}
...
...
@@ -237,6 +237,36 @@ void WebRtcTransportImp::onCheckSdp(SdpType type, RtcSession &sdp) const{
}
}
void
WebRtcTransportImp
::
onRtcConfigure
(
RtcConfigure
&
configure
)
const
{
WebRtcTransport
::
onRtcConfigure
(
configure
);
RtcSession
sdp
;
sdp
.
loadFrom
(
_src
->
getSdp
(),
false
);
configure
.
audio
.
enable
=
false
;
configure
.
video
.
enable
=
false
;
for
(
auto
&
m
:
sdp
.
media
)
{
switch
(
m
.
type
)
{
case
TrackVideo
:
{
configure
.
video
.
enable
=
true
;
configure
.
video
.
preferred_codec
=
{
getCodecId
(
m
.
plan
[
0
].
codec
)};
break
;
}
case
TrackAudio
:
{
configure
.
audio
.
enable
=
true
;
configure
.
audio
.
preferred_codec
=
{
getCodecId
(
m
.
plan
[
0
].
codec
)};
break
;
}
default
:
break
;
}
}
configure
.
addCandidate
(
*
getIceCandidate
());
}
void
WebRtcTransportImp
::
onSendSockData
(
const
char
*
buf
,
size_t
len
,
struct
sockaddr_in
*
dst
,
bool
flush
)
{
auto
ptr
=
BufferRaw
::
create
();
ptr
->
assign
(
buf
,
len
);
...
...
webrtc/WebRtcTransport.h
查看文件 @
9a2f2cbf
...
...
@@ -74,8 +74,6 @@ protected:
virtual
void
onStartWebRTC
()
=
0
;
virtual
void
onRtcConfigure
(
RtcConfigure
&
configure
)
const
{}
virtual
void
onCheckSdp
(
SdpType
type
,
RtcSession
&
sdp
)
const
;
virtual
SdpAttrCandidate
::
Ptr
getIceCandidate
()
const
=
0
;
virtual
void
onSendSockData
(
const
char
*
buf
,
size_t
len
,
struct
sockaddr_in
*
dst
,
bool
flush
=
true
)
=
0
;
virtual
void
onRtp
(
const
char
*
buf
,
size_t
len
)
=
0
;
...
...
@@ -116,8 +114,8 @@ protected:
void
onStartWebRTC
()
override
;
void
onSendSockData
(
const
char
*
buf
,
size_t
len
,
struct
sockaddr_in
*
dst
,
bool
flush
=
true
)
override
;
void
onCheckSdp
(
SdpType
type
,
RtcSession
&
sdp
)
const
override
;
void
onRtcConfigure
(
RtcConfigure
&
configure
)
const
override
;
SdpAttrCandidate
::
Ptr
getIceCandidate
()
const
override
;
void
onRtp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
override
;
...
...
@@ -125,6 +123,7 @@ private:
WebRtcTransportImp
(
const
EventPoller
::
Ptr
&
poller
);
void
onDestory
()
override
;
void
onSendRtp
(
const
RtpPacket
::
Ptr
&
rtp
,
bool
flush
);
SdpAttrCandidate
::
Ptr
getIceCandidate
()
const
;
private
:
Socket
::
Ptr
_socket
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论