mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-05 02:38:10 +08:00
添加rtp pause接口,目前默认3分钟
This commit is contained in:
@@ -903,6 +903,20 @@ void installWebApi() {
|
|||||||
val["local_ip"] = process->get_local_ip();
|
val["local_ip"] = process->get_local_ip();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api_regist1("/index/api/setRtpPause", [](API_ARGS1){
|
||||||
|
CHECK_SECRET();
|
||||||
|
CHECK_ARGS("stream_id", "pause");
|
||||||
|
|
||||||
|
auto process = RtpSelector::Instance().getProcess(allArgs["stream_id"], false);
|
||||||
|
if (!process) {
|
||||||
|
val["code"] = "-1";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pause = allArgs["pause"];
|
||||||
|
process->setRtpPause(pause);
|
||||||
|
});
|
||||||
|
|
||||||
api_regist1("/index/api/openRtpServer",[](API_ARGS1){
|
api_regist1("/index/api/openRtpServer",[](API_ARGS1){
|
||||||
CHECK_SECRET();
|
CHECK_SECRET();
|
||||||
CHECK_ARGS("port", "enable_tcp", "stream_id");
|
CHECK_ARGS("port", "enable_tcp", "stream_id");
|
||||||
|
|||||||
@@ -180,6 +180,15 @@ void RtpProcess::addTrack(const Track::Ptr & track){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RtpProcess::alive() {
|
bool RtpProcess::alive() {
|
||||||
|
if(_paused) {
|
||||||
|
if(_pause_rtp_time.elapsedTime()/ 1000 < 180){
|
||||||
|
return true;
|
||||||
|
}else {
|
||||||
|
WarnL << _media_info._streamid << ", pause timeout.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GET_CONFIG(int,timeoutSec,RtpProxy::kTimeoutSec)
|
GET_CONFIG(int,timeoutSec,RtpProxy::kTimeoutSec)
|
||||||
if(_last_rtp_time.elapsedTime() / 1000 < timeoutSec){
|
if(_last_rtp_time.elapsedTime() / 1000 < timeoutSec){
|
||||||
return true;
|
return true;
|
||||||
@@ -241,6 +250,12 @@ void RtpProcess::setListener(const std::weak_ptr<MediaSourceEvent> &listener){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RtpProcess::setRtpPause(bool pause)
|
||||||
|
{
|
||||||
|
_paused = pause;
|
||||||
|
_pause_rtp_time.resetTime();
|
||||||
|
}
|
||||||
|
|
||||||
void RtpProcess::emitOnPublish() {
|
void RtpProcess::emitOnPublish() {
|
||||||
weak_ptr<RtpProcess> weak_self = shared_from_this();
|
weak_ptr<RtpProcess> weak_self = shared_from_this();
|
||||||
Broadcast::PublishAuthInvoker invoker = [weak_self](const string &err, bool enableHls, bool enableMP4) {
|
Broadcast::PublishAuthInvoker invoker = [weak_self](const string &err, bool enableHls, bool enableMP4) {
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ public:
|
|||||||
int totalReaderCount();
|
int totalReaderCount();
|
||||||
void setListener(const std::weak_ptr<MediaSourceEvent> &listener);
|
void setListener(const std::weak_ptr<MediaSourceEvent> &listener);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 设置rtp流暂停
|
||||||
|
*/
|
||||||
|
void setRtpPause(bool pause);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void onRtpSorted(const RtpPacket::Ptr &rtp, int track_index) override ;
|
void onRtpSorted(const RtpPacket::Ptr &rtp, int track_index) override ;
|
||||||
void inputFrame(const Frame::Ptr &frame) override;
|
void inputFrame(const Frame::Ptr &frame) override;
|
||||||
@@ -95,6 +100,9 @@ private:
|
|||||||
uint64_t _total_bytes = 0;
|
uint64_t _total_bytes = 0;
|
||||||
Socket::Ptr _sock;
|
Socket::Ptr _sock;
|
||||||
function<void()> _on_detach;
|
function<void()> _on_detach;
|
||||||
|
|
||||||
|
bool _paused = false;
|
||||||
|
Ticker _pause_rtp_time;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//namespace mediakit
|
}//namespace mediakit
|
||||||
|
|||||||
Reference in New Issue
Block a user