mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-20 23:32:22 +08:00
AI automatically translates all comments in the code into English (#3917)
This commit is contained in:
@@ -36,21 +36,34 @@ public:
|
||||
/**
|
||||
* 开始推流
|
||||
* @param strUrl 视频url,支持rtsp/rtmp
|
||||
* Start streaming
|
||||
* @param strUrl Video url, supports rtsp/rtmp
|
||||
|
||||
* [AUTO-TRANSLATED:d1decdf6]
|
||||
*/
|
||||
virtual void publish(const std::string &strUrl) {};
|
||||
|
||||
/**
|
||||
* 中断推流
|
||||
* Stop streaming
|
||||
|
||||
* [AUTO-TRANSLATED:db8d228b]
|
||||
*/
|
||||
virtual void teardown() {};
|
||||
|
||||
/**
|
||||
* 摄像推流结果回调
|
||||
* Camera streaming result callback
|
||||
|
||||
* [AUTO-TRANSLATED:33825a4d]
|
||||
*/
|
||||
virtual void setOnPublished(const Event &cb) = 0;
|
||||
|
||||
/**
|
||||
* 设置断开回调
|
||||
* Set disconnect callback
|
||||
|
||||
* [AUTO-TRANSLATED:b948082c]
|
||||
*/
|
||||
virtual void setOnShutdown(const Event &cb) = 0;
|
||||
|
||||
@@ -70,6 +83,10 @@ public:
|
||||
/**
|
||||
* 开始推流
|
||||
* @param url 推流url,支持rtsp/rtmp
|
||||
* Start streaming
|
||||
* @param url Streaming url, supports rtsp/rtmp
|
||||
|
||||
* [AUTO-TRANSLATED:ffa95c22]
|
||||
*/
|
||||
void publish(const std::string &url) override {
|
||||
return _delegate ? _delegate->publish(url) : Parent::publish(url);
|
||||
@@ -77,6 +94,9 @@ public:
|
||||
|
||||
/**
|
||||
* 中断推流
|
||||
* Stop streaming
|
||||
|
||||
* [AUTO-TRANSLATED:db8d228b]
|
||||
*/
|
||||
void teardown() override {
|
||||
return _delegate ? _delegate->teardown() : Parent::teardown();
|
||||
@@ -88,6 +108,9 @@ public:
|
||||
|
||||
/**
|
||||
* 摄像推流结果回调
|
||||
* Camera streaming result callback
|
||||
|
||||
* [AUTO-TRANSLATED:33825a4d]
|
||||
*/
|
||||
void setOnPublished(const PusherBase::Event &cb) override {
|
||||
if (_delegate) {
|
||||
@@ -98,6 +121,10 @@ public:
|
||||
|
||||
/**
|
||||
* 设置断开回调
|
||||
* Set disconnect callback
|
||||
|
||||
|
||||
* [AUTO-TRANSLATED:b948082c]
|
||||
*/
|
||||
void setOnShutdown(const PusherBase::Event &cb) override {
|
||||
if (_delegate) {
|
||||
|
||||
@@ -54,18 +54,21 @@ void PusherProxy::publish(const string &dst_url) {
|
||||
|
||||
auto src = strong_self->_weak_src.lock();
|
||||
if (!err) {
|
||||
// 推流成功
|
||||
// 推流成功 [AUTO-TRANSLATED:28ce6e56]
|
||||
// Stream successfully pushed
|
||||
strong_self->_live_ticker.resetTime();
|
||||
strong_self->_live_status = 0;
|
||||
*failed_cnt = 0;
|
||||
InfoL << "Publish " << dst_url << " success";
|
||||
} else if (src && (*failed_cnt < strong_self->_retry_count || strong_self->_retry_count < 0)) {
|
||||
// 推流失败,延时重试推送
|
||||
// 推流失败,延时重试推送 [AUTO-TRANSLATED:92b094ae]
|
||||
// Stream failed, retry pushing with delay
|
||||
strong_self->_republish_count++;
|
||||
strong_self->_live_status = 1;
|
||||
strong_self->rePublish(dst_url, (*failed_cnt)++);
|
||||
} else {
|
||||
// 如果媒体源已经注销, 或达到了最大重试次数,回调关闭
|
||||
// 如果媒体源已经注销, 或达到了最大重试次数,回调关闭 [AUTO-TRANSLATED:444adf27]
|
||||
// If the media source has been deregistered, or the maximum retry count has been reached, callback to close
|
||||
strong_self->_on_close(err);
|
||||
}
|
||||
});
|
||||
@@ -77,19 +80,22 @@ void PusherProxy::publish(const string &dst_url) {
|
||||
}
|
||||
|
||||
if (*failed_cnt == 0) {
|
||||
// 第一次重推更新时长
|
||||
// 第一次重推更新时长 [AUTO-TRANSLATED:5f778703]
|
||||
// Update duration for the first re-push
|
||||
strong_self->_live_secs += strong_self->_live_ticker.elapsedTime() / 1000;
|
||||
strong_self->_live_ticker.resetTime();
|
||||
TraceL << " live secs " << strong_self->_live_secs;
|
||||
}
|
||||
|
||||
auto src = strong_self->_weak_src.lock();
|
||||
// 推流异常中断,延时重试播放
|
||||
// 推流异常中断,延时重试播放 [AUTO-TRANSLATED:e69e5a05]
|
||||
// Stream abnormally interrupted, retry playing with delay
|
||||
if (src && (*failed_cnt < strong_self->_retry_count || strong_self->_retry_count < 0)) {
|
||||
strong_self->_republish_count++;
|
||||
strong_self->rePublish(dst_url, (*failed_cnt)++);
|
||||
} else {
|
||||
// 如果媒体源已经注销, 或达到了最大重试次数,回调关闭
|
||||
// 如果媒体源已经注销, 或达到了最大重试次数,回调关闭 [AUTO-TRANSLATED:444adf27]
|
||||
// If the media source has been deregistered, or the maximum retry count has been reached, callback to close
|
||||
strong_self->_on_close(err);
|
||||
}
|
||||
});
|
||||
@@ -103,7 +109,8 @@ void PusherProxy::rePublish(const string &dst_url, int failed_cnt) {
|
||||
_timer = std::make_shared<Timer>(
|
||||
delay / 1000.0f,
|
||||
[weak_self, dst_url, failed_cnt]() {
|
||||
// 推流失败次数越多,则延时越长
|
||||
// 推流失败次数越多,则延时越长 [AUTO-TRANSLATED:bda77afe]
|
||||
// The more times the stream fails, the longer the delay
|
||||
auto strong_self = weak_self.lock();
|
||||
if (!strong_self) {
|
||||
return false;
|
||||
|
||||
@@ -22,26 +22,40 @@ class PusherProxy
|
||||
public:
|
||||
using Ptr = std::shared_ptr<PusherProxy>;
|
||||
|
||||
// 如果retry_count<0,则一直重试播放;否则重试retry_count次数
|
||||
// 默认一直重试,创建此对象时候,需要外部保证MediaSource存在
|
||||
// 如果retry_count<0,则一直重试播放;否则重试retry_count次数 [AUTO-TRANSLATED:5582d53c]
|
||||
// If retry_count < 0, then retry playback indefinitely; otherwise, retry retry_count times
|
||||
// 默认一直重试,创建此对象时候,需要外部保证MediaSource存在 [AUTO-TRANSLATED:c6159497]
|
||||
// Default is to retry indefinitely. When creating this object, the external environment needs to ensure that MediaSource exists.
|
||||
PusherProxy(const MediaSource::Ptr &src, int retry_count = -1, const toolkit::EventPoller::Ptr &poller = nullptr);
|
||||
~PusherProxy() override;
|
||||
|
||||
/**
|
||||
* 设置push结果回调,只触发一次;在publish执行之前有效
|
||||
* @param cb 回调对象
|
||||
* Set the push result callback, which is triggered only once; it is effective before publish is executed.
|
||||
* @param cb Callback object
|
||||
|
||||
* [AUTO-TRANSLATED:7cd775fb]
|
||||
*/
|
||||
void setPushCallbackOnce(const std::function<void(const toolkit::SockException &ex)> &cb);
|
||||
|
||||
/**
|
||||
* 设置主动关闭回调
|
||||
* @param cb 回调对象
|
||||
* Set the active close callback
|
||||
* @param cb Callback object
|
||||
|
||||
* [AUTO-TRANSLATED:83b7700a]
|
||||
*/
|
||||
void setOnClose(const std::function<void(const toolkit::SockException &ex)> &cb);
|
||||
|
||||
/**
|
||||
* 开始拉流播放
|
||||
* @param dstUrl 目标推流地址
|
||||
* Start pulling and playing the stream
|
||||
* @param dstUrl Target push stream address
|
||||
|
||||
* [AUTO-TRANSLATED:a9a5da08]
|
||||
*/
|
||||
void publish(const std::string &dstUrl) override;
|
||||
|
||||
@@ -50,14 +64,16 @@ public:
|
||||
uint64_t getRePublishCount();
|
||||
|
||||
private:
|
||||
// 重推逻辑函数
|
||||
// 重推逻辑函数 [AUTO-TRANSLATED:e0fa273c]
|
||||
// Repush logic function
|
||||
void rePublish(const std::string &dstUrl, int iFailedCnt);
|
||||
|
||||
private:
|
||||
int _retry_count;
|
||||
toolkit::Timer::Ptr _timer;
|
||||
toolkit::Ticker _live_ticker;
|
||||
// 0 表示正常 1 表示正在尝试推流
|
||||
// 0 表示正常 1 表示正在尝试推流 [AUTO-TRANSLATED:acb9835e]
|
||||
// 0 indicates normal, 1 indicates that the push stream is being attempted
|
||||
std::atomic<int> _live_status;
|
||||
std::atomic<uint64_t> _live_secs;
|
||||
std::atomic<uint64_t> _republish_count;
|
||||
|
||||
Reference in New Issue
Block a user