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
c42b678c
Commit
c42b678c
authored
Apr 02, 2021
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成rtc发送
parent
4a62314b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
9 行删除
+43
-9
webrtc/Sdp.cpp
+2
-1
webrtc/WebRtcTransport.cpp
+35
-8
webrtc/WebRtcTransport.h
+6
-0
没有找到文件。
webrtc/Sdp.cpp
查看文件 @
c42b678c
...
...
@@ -1129,7 +1129,8 @@ void RtcMedia::checkValid() const{
auto
rtx_plan
=
getPlan
(
"rtx"
);
if
(
rtx_plan
)
{
//开启rtx后必须指定rtx_ssrc
CHECK
(
!
rtx_ssrc
.
empty
()
||
!
send_rtp
);
//todo 此处不确定
// CHECK(!rtx_ssrc.empty() || !send_rtp);
}
}
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
c42b678c
...
...
@@ -67,6 +67,14 @@ void WebRtcTransport::onSendSockData(const char *buf, size_t len, bool flush){
onSendSockData
(
buf
,
len
,
(
struct
sockaddr_in
*
)
tuple
,
flush
);
}
const
RtcSession
&
WebRtcTransport
::
getSdp
(
SdpType
type
)
const
{
switch
(
type
)
{
case
SdpType
:
:
offer
:
return
*
_offer_sdp
;
case
SdpType
:
:
answer
:
return
*
_answer_sdp
;
default
:
throw
std
::
invalid_argument
(
"不识别的sdp类型"
);
}
}
string
getFingerprint
(
const
string
&
algorithm_str
,
const
std
::
shared_ptr
<
RTC
::
DtlsTransport
>
&
transport
){
auto
algorithm
=
RTC
::
DtlsTransport
::
GetFingerprintAlgorithm
(
algorithm_str
);
for
(
auto
&
finger_prints
:
transport
->
GetLocalFingerprints
())
{
...
...
@@ -108,7 +116,7 @@ std::string WebRtcTransport::getAnswerSdp(const string &offer){
fingerprint
.
algorithm
=
_offer_sdp
->
media
[
0
].
fingerprint
.
algorithm
;
fingerprint
.
hash
=
getFingerprint
(
fingerprint
.
algorithm
,
_dtls_transport
);
RtcConfigure
configure
;
configure
.
setDefaultSetting
(
_ice_server
->
GetUsernameFragment
(),
_ice_server
->
GetPassword
(),
RtpDirection
::
recvonly
,
fingerprint
);
configure
.
setDefaultSetting
(
_ice_server
->
GetUsernameFragment
(),
_ice_server
->
GetPassword
(),
RtpDirection
::
sendrecv
,
fingerprint
);
onRtcConfigure
(
configure
);
//// 生成answer sdp ////
...
...
@@ -201,6 +209,9 @@ void WebRtcTransportImp::attach(const RtspMediaSource::Ptr &src) {
}
void
WebRtcTransportImp
::
onStartWebRTC
()
{
if
(
!
canSendRtp
())
{
return
;
}
_reader
=
_src
->
getRing
()
->
attach
(
_socket
->
getPoller
(),
true
);
weak_ptr
<
WebRtcTransportImp
>
weak_self
=
shared_from_this
();
_reader
->
setReadCB
([
weak_self
](
const
RtspMediaSource
::
RingDataType
&
pkt
){
...
...
@@ -215,25 +226,43 @@ void WebRtcTransportImp::onStartWebRTC() {
});
}
uint8_t
WebRtcTransportImp
::
getSendPayloadType
(
TrackType
type
)
{
for
(
auto
&
m
:
getSdp
(
SdpType
::
answer
).
media
)
{
if
(
m
.
type
==
type
)
{
return
m
.
plan
[
0
].
pt
;
}
}
return
0
;
}
void
WebRtcTransportImp
::
onSendRtp
(
const
RtpPacket
::
Ptr
&
rtp
,
bool
flush
){
//需要修改pt
InfoL
<<
flush
;
if
(
rtp
->
type
==
TrackVideo
)
{
rtp
->
getHeader
()
->
pt
=
getSendPayloadType
(
rtp
->
type
);
sendRtpPacket
(
rtp
->
data
()
+
RtpPacket
::
kRtpTcpHeaderSize
,
rtp
->
size
()
-
RtpPacket
::
kRtpTcpHeaderSize
,
flush
);
}
else
{
}
}
bool
WebRtcTransportImp
::
canSendRtp
()
const
{
auto
&
sdp
=
getSdp
(
SdpType
::
answer
);
return
sdp
.
media
[
0
].
direction
==
RtpDirection
::
sendrecv
||
sdp
.
media
[
0
].
direction
==
RtpDirection
::
sendonly
;
}
void
WebRtcTransportImp
::
onCheckSdp
(
SdpType
type
,
RtcSession
&
sdp
)
const
{
WebRtcTransport
::
onCheckSdp
(
type
,
sdp
);
if
(
type
!=
SdpType
::
answer
)
{
if
(
type
!=
SdpType
::
answer
||
!
canSendRtp
()
)
{
return
;
}
for
(
auto
&
m
:
sdp
.
media
)
{
if
(
m
.
type
==
TrackApplication
)
{
continue
;
}
m
.
rtp_ssrc
.
ssrc
=
_src
->
getSsrc
(
m
.
type
);
m
.
rtx_ssrc
.
ssrc
=
2
+
m
.
rtp_ssrc
.
ssrc
;
m
.
rtp_ssrc
.
cname
=
"zlmediakit-rtc"
;
m
.
rtx_ssrc
.
cname
=
"zlmediakit-rtc"
;
}
}
...
...
@@ -287,12 +316,10 @@ SdpAttrCandidate::Ptr WebRtcTransportImp::getIceCandidate() const{
void
WebRtcTransportImp
::
onRtp
(
const
char
*
buf
,
size_t
len
)
{
RtpHeader
*
rtp
=
(
RtpHeader
*
)
buf
;
// TraceL << (int)rtp->ssrc;
}
void
WebRtcTransportImp
::
onRtcp
(
const
char
*
buf
,
size_t
len
)
{
RtcpHeader
*
rtcp
=
(
RtcpHeader
*
)
buf
;
// TraceL << rtcpTypeToStr((RtcpType)rtcp->pt);
}
///////////////////////////////////////////////////////////////////
...
...
webrtc/WebRtcTransport.h
查看文件 @
c42b678c
...
...
@@ -79,6 +79,9 @@ protected:
virtual
void
onRtp
(
const
char
*
buf
,
size_t
len
)
=
0
;
virtual
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
=
0
;
protected
:
const
RtcSession
&
getSdp
(
SdpType
type
)
const
;
private
:
void
onSendSockData
(
const
char
*
buf
,
size_t
len
,
bool
flush
=
true
);
void
setRemoteDtlsFingerprint
(
const
RtcSession
&
remote
);
...
...
@@ -124,11 +127,14 @@ private:
void
onDestory
()
override
;
void
onSendRtp
(
const
RtpPacket
::
Ptr
&
rtp
,
bool
flush
);
SdpAttrCandidate
::
Ptr
getIceCandidate
()
const
;
uint8_t
getSendPayloadType
(
TrackType
type
);
bool
canSendRtp
()
const
;
private
:
Socket
::
Ptr
_socket
;
RtspMediaSource
::
Ptr
_src
;
RtspMediaSource
::
RingType
::
RingReader
::
Ptr
_reader
;
RtcSession
_answer_sdp
;
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论