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
34365a2f
Commit
34365a2f
authored
Oct 16, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增webrtc echo test双向会话示例
parent
f0e896a5
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
95 行增加
和
1 行删除
+95
-1
server/WebApi.cpp
+9
-0
webrtc/WebRtcEchoTest.cpp
+38
-0
webrtc/WebRtcEchoTest.h
+38
-0
webrtc/WebRtcPlayer.h
+1
-1
webrtc/WebRtcTransport.cpp
+8
-0
webrtc/WebRtcTransport.h
+1
-0
没有找到文件。
server/WebApi.cpp
查看文件 @
34365a2f
...
...
@@ -40,6 +40,7 @@
#ifdef ENABLE_WEBRTC
#include "../webrtc/WebRtcPlayer.h"
#include "../webrtc/WebRtcPusher.h"
#include "../webrtc/WebRtcEchoTest.h"
#endif
using
namespace
toolkit
;
...
...
@@ -1271,6 +1272,14 @@ void installWebApi() {
return
;
}
if
(
!
strcasecmp
(
type
.
data
(),
"echo"
))
{
auto
rtc
=
WebRtcEchoTest
::
create
(
EventPollerPool
::
Instance
().
getPoller
());
val
[
"sdp"
]
=
rtc
->
getAnswerSdp
(
offer_sdp
);
val
[
"type"
]
=
"answer"
;
invoker
(
200
,
headerOut
,
val
.
toStyledString
());
return
;
}
throw
ApiRetException
(
"不支持该类型"
,
API
::
InvalidArgs
);
});
#endif
...
...
webrtc/WebRtcEchoTest.cpp
0 → 100644
查看文件 @
34365a2f
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#include "WebRtcEchoTest.h"
WebRtcEchoTest
::
Ptr
WebRtcEchoTest
::
create
(
const
EventPoller
::
Ptr
&
poller
)
{
WebRtcEchoTest
::
Ptr
ret
(
new
WebRtcEchoTest
(
poller
),
[](
WebRtcEchoTest
*
ptr
)
{
ptr
->
onDestory
();
delete
ptr
;
});
ret
->
onCreate
();
return
ret
;
}
WebRtcEchoTest
::
WebRtcEchoTest
(
const
EventPoller
::
Ptr
&
poller
)
:
WebRtcTransportImp
(
poller
)
{}
void
WebRtcEchoTest
::
onRtcConfigure
(
RtcConfigure
&
configure
)
const
{
WebRtcTransportImp
::
onRtcConfigure
(
configure
);
configure
.
audio
.
direction
=
configure
.
video
.
direction
=
RtpDirection
::
sendrecv
;
}
void
WebRtcEchoTest
::
onRtp
(
const
char
*
buf
,
size_t
len
,
uint64_t
stamp_ms
)
{
updateTicker
();
sendRtpPacket
(
buf
,
len
,
true
,
nullptr
);
}
void
WebRtcEchoTest
::
onRtcp
(
const
char
*
buf
,
size_t
len
)
{
sendRtcpPacket
(
buf
,
len
,
true
,
nullptr
);
}
webrtc/WebRtcEchoTest.h
0 → 100644
查看文件 @
34365a2f
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
* may be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ZLMEDIAKIT_WEBRTCECHOTEST_H
#define ZLMEDIAKIT_WEBRTCECHOTEST_H
#include "WebRtcTransport.h"
class
WebRtcEchoTest
:
public
WebRtcTransportImp
{
public
:
using
Ptr
=
std
::
shared_ptr
<
WebRtcEchoTest
>
;
~
WebRtcEchoTest
()
override
=
default
;
static
Ptr
create
(
const
EventPoller
::
Ptr
&
poller
);
protected
:
///////WebRtcTransportImp override///////
void
onRtcConfigure
(
RtcConfigure
&
configure
)
const
override
;
void
onRtp
(
const
char
*
buf
,
size_t
len
,
uint64_t
stamp_ms
)
override
;
void
onRtcp
(
const
char
*
buf
,
size_t
len
)
override
;
void
onRecvRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
)
override
{};
void
onBeforeEncryptRtp
(
const
char
*
buf
,
int
&
len
,
void
*
ctx
)
override
{};
void
onBeforeEncryptRtcp
(
const
char
*
buf
,
int
&
len
,
void
*
ctx
)
override
{};
private
:
WebRtcEchoTest
(
const
EventPoller
::
Ptr
&
poller
);
};
#endif //ZLMEDIAKIT_WEBRTCECHOTEST_H
webrtc/WebRtcPlayer.h
查看文件 @
34365a2f
...
...
@@ -24,7 +24,7 @@ protected:
void
onStartWebRTC
()
override
;
void
onDestory
()
override
;
void
onRtcConfigure
(
RtcConfigure
&
configure
)
const
override
;
void
onRecvRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
)
{};
void
onRecvRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
)
override
{};
private
:
WebRtcPlayer
(
const
EventPoller
::
Ptr
&
poller
,
const
RtspMediaSource
::
Ptr
&
src
,
const
MediaInfo
&
info
);
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
34365a2f
...
...
@@ -435,6 +435,10 @@ void WebRtcTransportImp::onCheckAnswer(RtcSession &sdp) {
if
(
m
.
type
==
TrackApplication
)
{
continue
;
}
if
(
!
m
.
rtp_rtx_ssrc
.
empty
())
{
//已经生成了ssrc
continue
;
}
//添加answer sdp的ssrc信息
m
.
rtp_rtx_ssrc
.
emplace_back
();
auto
&
ssrc
=
m
.
rtp_rtx_ssrc
.
back
();
...
...
@@ -668,6 +672,10 @@ void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, Medi
InfoL
<<
"create rtp receiver of ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
<<
", codec:"
<<
track
.
plan_rtp
->
codec
;
}
void
WebRtcTransportImp
::
updateTicker
()
{
_alive_ticker
.
resetTime
();
}
void
WebRtcTransportImp
::
onRtp
(
const
char
*
buf
,
size_t
len
,
uint64_t
stamp_ms
)
{
_bytes_usage
+=
len
;
_alive_ticker
.
resetTime
();
...
...
webrtc/WebRtcTransport.h
查看文件 @
34365a2f
...
...
@@ -189,6 +189,7 @@ protected:
void
onDestory
()
override
;
void
onShutdown
(
const
SockException
&
ex
)
override
;
virtual
void
onRecvRtp
(
MediaTrack
&
track
,
const
string
&
rid
,
RtpPacket
::
Ptr
rtp
)
=
0
;
void
updateTicker
();
private
:
SdpAttrCandidate
::
Ptr
getIceCandidate
()
const
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论