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
b5ea9fac
Commit
b5ea9fac
authored
6 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配ZLToolKit(更新定时器)
parent
cc7556b5
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
42 行增加
和
18 行删除
+42
-18
ZLToolKit
+1
-1
src/Player/MediaPlayer.cpp
+2
-2
src/Player/MediaPlayer.h
+1
-1
src/Player/PlayerProxy.cpp
+3
-3
src/Rtmp/RtmpPlayer.cpp
+2
-2
src/Rtmp/RtmpPlayer.h
+1
-1
src/Rtmp/RtmpPusher.cpp
+1
-1
src/Rtsp/RtspPlayer.cpp
+3
-3
src/Rtsp/RtspSession.cpp
+25
-2
src/Rtsp/RtspSession.h
+2
-0
tests/test_benchmark.cpp
+0
-1
tests/test_server.cpp
+1
-1
没有找到文件。
ZLToolKit
@
01c9f814
Subproject commit
8c1a0f88a0b8e332c3eaf04dbb9a8f2402b267ba
Subproject commit
01c9f8141b43fe270aa0d646d115df98aa6c5e14
This diff is collapsed.
Click to expand it.
src/Player/MediaPlayer.cpp
查看文件 @
b5ea9fac
...
...
@@ -46,12 +46,12 @@ void MediaPlayer::play(const char* strUrl) {
_parser
->
play
(
strUrl
);
}
TaskExecutor
::
Ptr
MediaPlayer
::
getExecuto
r
(){
EventPoller
::
Ptr
MediaPlayer
::
getPolle
r
(){
auto
parser
=
dynamic_pointer_cast
<
SocketHelper
>
(
_parser
);
if
(
!
parser
){
return
nullptr
;
}
return
parser
->
get
Executo
r
();
return
parser
->
get
Polle
r
();
}
void
MediaPlayer
::
pause
(
bool
bPause
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Player/MediaPlayer.h
查看文件 @
b5ea9fac
...
...
@@ -46,7 +46,7 @@ public:
void
play
(
const
char
*
strUrl
)
override
;
void
pause
(
bool
bPause
)
override
;
void
teardown
()
override
;
TaskExecutor
::
Ptr
getExecuto
r
();
EventPoller
::
Ptr
getPolle
r
();
};
...
...
This diff is collapsed.
Click to expand it.
src/Player/PlayerProxy.cpp
查看文件 @
b5ea9fac
...
...
@@ -136,9 +136,9 @@ void PlayerProxy::rePlay(const string &strUrl,int iFailedCnt){
bool
PlayerProxy
::
close
()
{
//通知其停止推流
weak_ptr
<
PlayerProxy
>
weakSlef
=
dynamic_pointer_cast
<
PlayerProxy
>
(
shared_from_this
());
auto
executor
=
getExecuto
r
();
if
(
executo
r
)
{
executo
r
->
async_first
([
weakSlef
]()
{
auto
poller
=
getPolle
r
();
if
(
polle
r
)
{
polle
r
->
async_first
([
weakSlef
]()
{
auto
stronSelf
=
weakSlef
.
lock
();
if
(
stronSelf
)
{
stronSelf
->
_mediaMuxer
.
reset
();
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpPlayer.cpp
查看文件 @
b5ea9fac
...
...
@@ -116,7 +116,7 @@ void RtmpPlayer::onConnect(const SockException &err){
strongSelf
->
_onPlayResult
(
SockException
(
Err_timeout
,
"play rtmp timeout"
));
strongSelf
->
teardown
();
return
false
;
},
get
Executo
r
()));
},
get
Polle
r
()));
startClientSession
([
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
...
...
@@ -230,7 +230,7 @@ inline void RtmpPlayer::send_pause(bool bPause) {
uint32_t
timeStamp
=
::
time
(
NULL
);
strongSelf
->
sendUserControl
(
CONTROL_PING_REQUEST
,
timeStamp
);
return
true
;
},
get
Executo
r
()));
},
get
Polle
r
()));
}
}
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpPlayer.h
查看文件 @
b5ea9fac
...
...
@@ -88,7 +88,7 @@ private:
return
false
;
}
return
true
;
},
get
Executo
r
()));
},
get
Polle
r
()));
}
onPlayResult
(
ex
);
}
...
...
This diff is collapsed.
Click to expand it.
src/Rtmp/RtmpPusher.cpp
查看文件 @
b5ea9fac
...
...
@@ -121,7 +121,7 @@ void RtmpPusher::onConnect(const SockException &err){
strongSelf
->
onPublishResult
(
SockException
(
Err_timeout
,
"publish rtmp timeout"
));
strongSelf
->
teardown
();
return
false
;
},
get
Executo
r
()));
},
get
Polle
r
()));
startClientSession
([
weakSelf
](){
auto
strongSelf
=
weakSelf
.
lock
();
if
(
!
strongSelf
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtspPlayer.cpp
查看文件 @
b5ea9fac
...
...
@@ -153,7 +153,7 @@ void RtspPlayer::onConnect(const SockException &err){
strongSelf
->
onPlayResult_l
(
SockException
(
Err_timeout
,
"play rtsp timeout"
));
strongSelf
->
teardown
();
return
false
;
},
get
Executo
r
()));
},
get
Polle
r
()));
}
void
RtspPlayer
::
onRecv
(
const
Buffer
::
Ptr
&
pBuf
)
{
...
...
@@ -352,7 +352,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int uiTrackIndex)
return
false
;
}
return
strongSelf
->
sendOptions
();
},
get
Executo
r
()));
},
get
Polle
r
()));
pause
(
false
);
}
...
...
@@ -603,7 +603,7 @@ void RtspPlayer::onPlayResult_l(const SockException &ex) {
return
false
;
}
return
true
;
},
get
Executo
r
()));
},
get
Polle
r
()));
}
onPlayResult
(
ex
);
}
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtspSession.cpp
查看文件 @
b5ea9fac
...
...
@@ -70,19 +70,42 @@ static unordered_map<string, weak_ptr<RtspSession> > g_mapGetter;
//对g_mapGetter上锁保护
static
recursive_mutex
g_mtxGetter
;
//rtsp会话个数统计
static
recursive_mutex
g_mtxSessionCounter
;
static
unordered_map
<
string
,
atomic
<
uint32_t
>
>
g_mapSessionCounter
;
static
int
kSockFlags
=
SOCKET_DEFAULE_FLAGS
|
FLAG_MORE
;
uint32_t
RtspSession
::
getSessionCountOnInterface
(
const
string
&
ifr
){
lock_guard
<
recursive_mutex
>
lck
(
g_mtxSessionCounter
);
if
(
ifr
.
empty
()){
int
i
=
0
;
for
(
auto
&
pr
:
g_mapSessionCounter
){
i
+=
pr
.
second
;
}
return
i
;
}
return
g_mapSessionCounter
[
ifr
];
}
RtspSession
::
RtspSession
(
const
Socket
::
Ptr
&
pSock
)
:
TcpSession
(
pSock
)
{
//设置10秒发送缓存
pSock
->
setSendBufSecond
(
1
0
);
pSock
->
setSendBufSecond
(
3
0
);
//设置15秒发送超时时间
pSock
->
setSendTimeOutSecond
(
1
5
);
pSock
->
setSendTimeOutSecond
(
4
5
);
DebugL
<<
get_peer_ip
();
lock_guard
<
recursive_mutex
>
lck
(
g_mtxSessionCounter
);
++
(
g_mapSessionCounter
[
get_local_ip
()]);
}
RtspSession
::~
RtspSession
()
{
DebugL
<<
get_peer_ip
();
lock_guard
<
recursive_mutex
>
lck
(
g_mtxSessionCounter
);
--
(
g_mapSessionCounter
[
get_local_ip
()]);
}
void
RtspSession
::
onError
(
const
SockException
&
err
)
{
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtspSession.h
查看文件 @
b5ea9fac
...
...
@@ -28,6 +28,7 @@
#define SESSION_RTSPSESSION_H_
#include <set>
#include <atomic>
#include <vector>
#include <unordered_map>
#include "Util/util.h"
...
...
@@ -79,6 +80,7 @@ public:
void
onRecv
(
const
Buffer
::
Ptr
&
pBuf
)
override
;
void
onError
(
const
SockException
&
err
)
override
;
void
onManager
()
override
;
static
uint32_t
getSessionCountOnInterface
(
const
string
&
ifr
);
protected
:
//RtspSplitter override
/**
...
...
This diff is collapsed.
Click to expand it.
tests/test_benchmark.cpp
查看文件 @
b5ea9fac
...
...
@@ -33,7 +33,6 @@
#include "Network/sockutil.h"
#include "Poller/EventPoller.h"
#include "Player/PlayerProxy.h"
#include "Thread/WorkThreadPool.h"
using
namespace
std
;
using
namespace
toolkit
;
...
...
This diff is collapsed.
Click to expand it.
tests/test_server.cpp
查看文件 @
b5ea9fac
...
...
@@ -266,7 +266,7 @@ int main(int argc,char *argv[]) {
//指定RTP over TCP(播放rtsp时有效)
(
*
player
)[
RtspPlayer
::
kRtpType
]
=
PlayerBase
::
RTP_TCP
;
//开始播放,如果播放失败或者播放中止,将会自动重试若干次,重试次数在配置文件中配置,默认一直重试
player
->
play
(
url
);
//
player->play(url);
//需要保存PlayerProxy,否则作用域结束就会销毁该对象
proxyMap
.
emplace
(
to_string
(
i
),
player
);
++
i
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论