2022-06-11 21:37:41 +08:00
|
|
|
|
#include "Util/util.h"
|
|
|
|
|
#include <memory>
|
2022-11-29 11:07:13 +08:00
|
|
|
|
#include "Common/Parser.h"
|
|
|
|
|
#include "Common/config.h"
|
2022-06-03 16:47:53 +08:00
|
|
|
|
#include "SrtTransportImp.hpp"
|
|
|
|
|
|
|
|
|
|
namespace SRT {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
SrtTransportImp::SrtTransportImp(const EventPoller::Ptr &poller)
|
2023-04-22 23:30:22 +08:00
|
|
|
|
: SrtTransport(poller) {
|
|
|
|
|
}
|
2022-06-03 16:47:53 +08:00
|
|
|
|
|
|
|
|
|
SrtTransportImp::~SrtTransportImp() {
|
2022-06-03 21:17:01 +08:00
|
|
|
|
uint64_t duration = _alive_ticker.createdTime() / 1000;
|
2022-09-07 11:06:39 +08:00
|
|
|
|
WarnP(this) << (_is_pusher ? "srt 推流器(" : "srt 播放器(") << _media_info.shortUrl() << ")断开,耗时(s):" << duration;
|
2022-06-03 21:17:01 +08:00
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 流量统计事件广播
|
2022-06-03 21:17:01 +08:00
|
|
|
|
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
|
|
|
|
|
if (_total_bytes >= iFlowThreshold * 1024) {
|
2022-06-06 20:40:04 +08:00
|
|
|
|
NoticeCenter::Instance().emitEvent(
|
2022-06-24 16:28:16 +08:00
|
|
|
|
Broadcast::kBroadcastFlowReport, _media_info, _total_bytes, duration, !_is_pusher,
|
2022-06-06 20:40:04 +08:00
|
|
|
|
static_cast<SockInfo &>(*this));
|
2022-06-03 21:17:01 +08:00
|
|
|
|
}
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 09:52:20 +08:00
|
|
|
|
void SrtTransportImp::onHandShakeFinished(std::string &streamid, struct sockaddr_storage *addr) {
|
2022-09-21 19:21:49 +08:00
|
|
|
|
SrtTransport::onHandShakeFinished(streamid,addr);
|
2022-06-07 09:52:20 +08:00
|
|
|
|
// TODO parse stream id like this zlmediakit.com/live/test?token=1213444&type=push
|
|
|
|
|
if (!_addr) {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
_addr.reset(new sockaddr_storage(*((sockaddr_storage *)addr)));
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
_is_pusher = false;
|
|
|
|
|
TraceL << " stream id " << streamid;
|
2022-06-11 21:37:41 +08:00
|
|
|
|
if (!parseStreamid(streamid)) {
|
|
|
|
|
onShutdown(SockException(Err_shutdown, "stream id not vaild"));
|
2022-06-07 09:52:20 +08:00
|
|
|
|
return;
|
2022-06-04 13:30:59 +08:00
|
|
|
|
}
|
2022-06-03 16:47:53 +08:00
|
|
|
|
|
|
|
|
|
auto params = Parser::parseArgs(_media_info._param_strs);
|
2022-06-11 21:37:41 +08:00
|
|
|
|
if (params["m"] == "publish") {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
_is_pusher = true;
|
|
|
|
|
_decoder = DecoderImp::createDecoder(DecoderImp::decoder_ts, this);
|
|
|
|
|
emitOnPublish();
|
2022-06-07 09:52:20 +08:00
|
|
|
|
} else {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
_is_pusher = false;
|
2022-06-04 11:23:18 +08:00
|
|
|
|
emitOnPlay();
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
//
|
|
|
|
|
bool SrtTransportImp::parseStreamid(std::string &streamid) {
|
|
|
|
|
|
|
|
|
|
if (!toolkit::start_with(streamid, "#!::")) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
_media_info._schema = SRT_SCHEMA;
|
|
|
|
|
|
|
|
|
|
std::string real_streamid = streamid.substr(4);
|
|
|
|
|
std::string vhost, app, stream_name;
|
|
|
|
|
|
|
|
|
|
auto params = Parser::parseArgs(real_streamid, ",", "=");
|
|
|
|
|
|
|
|
|
|
for (auto it : params) {
|
|
|
|
|
if (it.first == "h") {
|
|
|
|
|
vhost = it.second;
|
|
|
|
|
} else if (it.first == "r") {
|
|
|
|
|
auto tmps = toolkit::split(it.second, "/");
|
|
|
|
|
if (tmps.size() < 2) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
app = tmps[0];
|
|
|
|
|
stream_name = tmps[1];
|
|
|
|
|
} else {
|
|
|
|
|
if (_media_info._param_strs.empty()) {
|
|
|
|
|
_media_info._param_strs = it.first + "=" + it.second;
|
|
|
|
|
} else {
|
|
|
|
|
_media_info._param_strs += "&" + it.first + "=" + it.second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (app == "" || stream_name == "") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vhost != "") {
|
|
|
|
|
_media_info._vhost = vhost;
|
|
|
|
|
} else {
|
|
|
|
|
_media_info._vhost = DEFAULT_VHOST;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_media_info._app = app;
|
|
|
|
|
_media_info._streamid = stream_name;
|
|
|
|
|
|
2022-09-07 11:06:39 +08:00
|
|
|
|
TraceL << " mediainfo=" << _media_info.shortUrl() << " params=" << _media_info._param_strs;
|
2022-06-11 21:37:41 +08:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-04 20:51:49 +08:00
|
|
|
|
void SrtTransportImp::onSRTData(DataPacket::Ptr pkt) {
|
2022-06-07 09:52:20 +08:00
|
|
|
|
if (!_is_pusher) {
|
|
|
|
|
WarnP(this) << "this is a player data ignore";
|
2022-06-03 16:47:53 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (_decoder) {
|
|
|
|
|
_decoder->input(reinterpret_cast<const uint8_t *>(pkt->payloadData()), pkt->payloadSize());
|
2022-09-21 19:21:49 +08:00
|
|
|
|
//TraceL<<" size "<<pkt->payloadSize();
|
2022-06-07 09:52:20 +08:00
|
|
|
|
} else {
|
|
|
|
|
WarnP(this) << " not reach this";
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
void SrtTransportImp::onShutdown(const SockException &ex) {
|
2022-10-16 19:49:56 +08:00
|
|
|
|
if (_decoder) {
|
|
|
|
|
_decoder->flush();
|
|
|
|
|
}
|
2022-06-03 16:47:53 +08:00
|
|
|
|
SrtTransport::onShutdown(ex);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-18 20:36:47 +08:00
|
|
|
|
bool SrtTransportImp::close(mediakit::MediaSource &sender) {
|
|
|
|
|
std::string err = StrPrinter << "close media: " << sender.getUrl();
|
2022-06-03 16:47:53 +08:00
|
|
|
|
weak_ptr<SrtTransportImp> weak_self = static_pointer_cast<SrtTransportImp>(shared_from_this());
|
|
|
|
|
getPoller()->async([weak_self, err]() {
|
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (strong_self) {
|
|
|
|
|
strong_self->onShutdown(SockException(Err_shutdown, err));
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 主动关闭推流,那么不延时注销
|
2022-06-03 16:47:53 +08:00
|
|
|
|
strong_self->_muxer = nullptr;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
// 获取媒体源类型
|
2022-06-07 09:52:20 +08:00
|
|
|
|
mediakit::MediaOriginType SrtTransportImp::getOriginType(mediakit::MediaSource &sender) const {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
return MediaOriginType::srt_push;
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
// 获取媒体源url或者文件路径
|
2022-06-07 09:52:20 +08:00
|
|
|
|
std::string SrtTransportImp::getOriginUrl(mediakit::MediaSource &sender) const {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
return _media_info._full_url;
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
// 获取媒体源客户端相关信息
|
2022-06-07 09:52:20 +08:00
|
|
|
|
std::shared_ptr<SockInfo> SrtTransportImp::getOriginSock(mediakit::MediaSource &sender) const {
|
|
|
|
|
return static_pointer_cast<SockInfo>(getSession());
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrtTransportImp::emitOnPublish() {
|
|
|
|
|
std::weak_ptr<SrtTransportImp> weak_self = static_pointer_cast<SrtTransportImp>(shared_from_this());
|
|
|
|
|
Broadcast::PublishAuthInvoker invoker = [weak_self](const std::string &err, const ProtocolOption &option) {
|
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-08-11 18:36:17 +08:00
|
|
|
|
strong_self->getPoller()->async([weak_self, err, option](){
|
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (err.empty()) {
|
|
|
|
|
strong_self->_muxer = std::make_shared<MultiMediaSourceMuxer>(strong_self->_media_info._vhost,
|
|
|
|
|
strong_self->_media_info._app,
|
|
|
|
|
strong_self->_media_info._streamid,0.0f,
|
|
|
|
|
option);
|
|
|
|
|
strong_self->_muxer->setMediaListener(strong_self);
|
|
|
|
|
strong_self->doCachedFunc();
|
|
|
|
|
InfoP(strong_self) << "允许 srt 推流";
|
|
|
|
|
} else {
|
|
|
|
|
WarnP(strong_self) << "禁止 srt 推流:" << err;
|
|
|
|
|
strong_self->onShutdown(SockException(Err_refused, err));
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-06-03 16:47:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 触发推流鉴权事件
|
2022-06-06 20:40:04 +08:00
|
|
|
|
auto flag = NoticeCenter::Instance().emitEvent(
|
|
|
|
|
Broadcast::kBroadcastMediaPublish, MediaOriginType::srt_push, _media_info, invoker,
|
|
|
|
|
static_cast<SockInfo &>(*this));
|
2022-06-03 16:47:53 +08:00
|
|
|
|
if (!flag) {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 该事件无人监听,默认不鉴权
|
2022-06-03 16:47:53 +08:00
|
|
|
|
invoker("", ProtocolOption());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 09:52:20 +08:00
|
|
|
|
void SrtTransportImp::emitOnPlay() {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
std::weak_ptr<SrtTransportImp> weak_self = static_pointer_cast<SrtTransportImp>(shared_from_this());
|
2022-06-07 09:52:20 +08:00
|
|
|
|
Broadcast::AuthInvoker invoker = [weak_self](const string &err) {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
strong_self->getPoller()->async([strong_self, err] {
|
|
|
|
|
if (err != "") {
|
|
|
|
|
strong_self->onShutdown(SockException(Err_refused, err));
|
|
|
|
|
} else {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
strong_self->doPlay();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-06 20:40:04 +08:00
|
|
|
|
auto flag = NoticeCenter::Instance().emitEvent(
|
|
|
|
|
Broadcast::kBroadcastMediaPlayed, _media_info, invoker, static_cast<SockInfo &>(*this));
|
2022-06-07 09:52:20 +08:00
|
|
|
|
if (!flag) {
|
2022-06-03 16:47:53 +08:00
|
|
|
|
doPlay();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-04 11:23:18 +08:00
|
|
|
|
|
2022-06-07 09:52:20 +08:00
|
|
|
|
void SrtTransportImp::doPlay() {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 异步查找直播流
|
2022-06-04 11:23:18 +08:00
|
|
|
|
MediaInfo info = _media_info;
|
|
|
|
|
info._schema = TS_SCHEMA;
|
2022-06-07 09:52:20 +08:00
|
|
|
|
std::weak_ptr<SrtTransportImp> weak_self = static_pointer_cast<SrtTransportImp>(shared_from_this());
|
2022-06-04 11:23:18 +08:00
|
|
|
|
MediaSource::findAsync(info, getSession(), [weak_self](const MediaSource::Ptr &src) {
|
2022-06-03 22:47:52 +08:00
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 本对象已经销毁
|
2022-06-07 09:52:20 +08:00
|
|
|
|
TraceL << "本对象已经销毁";
|
2022-06-03 22:47:52 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-04 11:23:18 +08:00
|
|
|
|
if (!src) {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 未找到该流
|
2022-06-07 09:52:20 +08:00
|
|
|
|
TraceL << "未找到该流";
|
2022-06-04 11:23:18 +08:00
|
|
|
|
strong_self->onShutdown(SockException(Err_shutdown));
|
|
|
|
|
} else {
|
2022-06-07 09:52:20 +08:00
|
|
|
|
TraceL << "找到该流";
|
2022-06-04 11:23:18 +08:00
|
|
|
|
auto ts_src = dynamic_pointer_cast<TSMediaSource>(src);
|
|
|
|
|
assert(ts_src);
|
|
|
|
|
ts_src->pause(false);
|
|
|
|
|
strong_self->_ts_reader = ts_src->getRing()->attach(strong_self->getPoller());
|
2022-08-30 21:24:25 +08:00
|
|
|
|
weak_ptr<Session> weak_session = strong_self->getSession();
|
|
|
|
|
strong_self->_ts_reader->setGetInfoCB([weak_session]() { return weak_session.lock(); });
|
2022-06-04 11:23:18 +08:00
|
|
|
|
strong_self->_ts_reader->setDetachCB([weak_self]() {
|
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 本对象已经销毁
|
2022-06-04 11:23:18 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-06-03 22:47:52 +08:00
|
|
|
|
strong_self->onShutdown(SockException(Err_shutdown));
|
2022-06-04 11:23:18 +08:00
|
|
|
|
});
|
|
|
|
|
strong_self->_ts_reader->setReadCB([weak_self](const TSMediaSource::RingDataType &ts_list) {
|
|
|
|
|
auto strong_self = weak_self.lock();
|
|
|
|
|
if (!strong_self) {
|
2022-06-11 21:37:41 +08:00
|
|
|
|
// 本对象已经销毁
|
2022-06-04 11:23:18 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
size_t i = 0;
|
|
|
|
|
auto size = ts_list->size();
|
|
|
|
|
ts_list->for_each([&](const TSPacket::Ptr &ts) { strong_self->onSendTSData(ts, ++i == size); });
|
|
|
|
|
});
|
2022-06-07 09:52:20 +08:00
|
|
|
|
}
|
2022-06-04 11:23:18 +08:00
|
|
|
|
});
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
std::string SrtTransportImp::get_peer_ip() {
|
|
|
|
|
if (!_addr) {
|
|
|
|
|
return "::";
|
|
|
|
|
}
|
|
|
|
|
return SockUtil::inet_ntoa((sockaddr *)_addr.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t SrtTransportImp::get_peer_port() {
|
|
|
|
|
if (!_addr) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return SockUtil::inet_port((sockaddr *)_addr.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string SrtTransportImp::get_local_ip() {
|
|
|
|
|
auto s = getSession();
|
|
|
|
|
if (s) {
|
|
|
|
|
return s->get_local_ip();
|
|
|
|
|
}
|
|
|
|
|
return "::";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint16_t SrtTransportImp::get_local_port() {
|
2022-06-07 09:52:20 +08:00
|
|
|
|
auto s = getSession();
|
2022-06-03 16:47:53 +08:00
|
|
|
|
if (s) {
|
|
|
|
|
return s->get_local_port();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string SrtTransportImp::getIdentifier() const {
|
|
|
|
|
return _media_info._streamid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrtTransportImp::inputFrame(const Frame::Ptr &frame) {
|
|
|
|
|
if (_muxer) {
|
2022-06-26 00:54:31 +08:00
|
|
|
|
//TraceL<<"before type "<<frame->getCodecName()<<" dts "<<frame->dts()<<" pts "<<frame->pts();
|
|
|
|
|
auto frame_tmp = std::make_shared<FrameStamp>(frame, _type_to_stamp[frame->getTrackType()],false);
|
2023-03-25 20:32:21 +08:00
|
|
|
|
if(_type_to_stamp.size()>1){
|
|
|
|
|
// 有音视频,检查是否时间戳是否差距过大
|
|
|
|
|
auto diff = _type_to_stamp[TrackType::TrackVideo].getRelativeStamp() - _type_to_stamp[TrackType::TrackAudio].getRelativeStamp();
|
|
|
|
|
if(std::abs(diff) > 5000){
|
|
|
|
|
// 超过5s,应该同步 TODO
|
|
|
|
|
WarnL << _media_info._full_url<<" video or audio not sync : "<<diff;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-26 00:54:31 +08:00
|
|
|
|
//TraceL<<"after type "<<frame_tmp->getCodecName()<<" dts "<<frame_tmp->dts()<<" pts "<<frame_tmp->pts();
|
|
|
|
|
return _muxer->inputFrame(frame_tmp);
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
if (_cached_func.size() > 200) {
|
|
|
|
|
WarnL << "cached frame of track(" << frame->getCodecName() << ") is too much, now dropped";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
auto frame_cached = Frame::getCacheAbleFrame(frame);
|
|
|
|
|
lock_guard<recursive_mutex> lck(_func_mtx);
|
2022-06-26 00:54:31 +08:00
|
|
|
|
_cached_func.emplace_back([this, frame_cached]() {
|
|
|
|
|
//TraceL<<"before type "<<frame_cached->getCodecName()<<" dts "<<frame_cached->dts()<<" pts "<<frame_cached->pts();
|
|
|
|
|
auto frame_tmp = std::make_shared<FrameStamp>(frame_cached, _type_to_stamp[frame_cached->getTrackType()],false);
|
|
|
|
|
//TraceL<<"after type "<<frame_tmp->getCodecName()<<" dts "<<frame_tmp->dts()<<" pts "<<frame_tmp->pts();
|
|
|
|
|
_muxer->inputFrame(frame_tmp);
|
|
|
|
|
});
|
2022-06-03 16:47:53 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrtTransportImp::addTrack(const Track::Ptr &track) {
|
2022-06-26 00:54:31 +08:00
|
|
|
|
_type_to_stamp.emplace(track->getTrackType(),Stamp());
|
2022-06-03 16:47:53 +08:00
|
|
|
|
if (_muxer) {
|
|
|
|
|
return _muxer->addTrack(track);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lock_guard<recursive_mutex> lck(_func_mtx);
|
2022-06-07 09:52:20 +08:00
|
|
|
|
_cached_func.emplace_back([this, track]() { _muxer->addTrack(track); });
|
2022-06-03 16:47:53 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrtTransportImp::addTrackCompleted() {
|
|
|
|
|
if (_muxer) {
|
|
|
|
|
_muxer->addTrackCompleted();
|
|
|
|
|
} else {
|
|
|
|
|
lock_guard<recursive_mutex> lck(_func_mtx);
|
2022-06-07 09:52:20 +08:00
|
|
|
|
_cached_func.emplace_back([this]() { _muxer->addTrackCompleted(); });
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
2022-06-26 00:54:31 +08:00
|
|
|
|
if(_type_to_stamp.size() >1){
|
|
|
|
|
_type_to_stamp[TrackType::TrackAudio].syncTo(_type_to_stamp[TrackType::TrackVideo]);
|
|
|
|
|
}
|
2022-06-03 16:47:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrtTransportImp::doCachedFunc() {
|
|
|
|
|
lock_guard<recursive_mutex> lck(_func_mtx);
|
|
|
|
|
for (auto &func : _cached_func) {
|
|
|
|
|
func();
|
|
|
|
|
}
|
|
|
|
|
_cached_func.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-07 09:52:20 +08:00
|
|
|
|
int SrtTransportImp::getLatencyMul() {
|
|
|
|
|
GET_CONFIG(int, latencyMul, kLatencyMul);
|
2022-06-14 19:49:45 +08:00
|
|
|
|
if (latencyMul <= 0) {
|
|
|
|
|
WarnL << "config srt " << kLatencyMul << " not vaild";
|
|
|
|
|
return 4;
|
|
|
|
|
}
|
2022-06-07 09:52:20 +08:00
|
|
|
|
return latencyMul;
|
2022-06-06 19:55:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 00:39:42 +08:00
|
|
|
|
float SrtTransportImp::getTimeOutSec() {
|
|
|
|
|
GET_CONFIG(float, timeOutSec, kTimeOutSec);
|
|
|
|
|
if (timeOutSec <= 0) {
|
|
|
|
|
WarnL << "config srt " << kTimeOutSec << " not vaild";
|
|
|
|
|
return 5.0;
|
|
|
|
|
}
|
|
|
|
|
return timeOutSec;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 22:51:11 +08:00
|
|
|
|
int SrtTransportImp::getPktBufSize() {
|
|
|
|
|
// kPktBufSize
|
|
|
|
|
GET_CONFIG(int, pktBufSize, kPktBufSize);
|
2022-06-14 19:49:45 +08:00
|
|
|
|
if (pktBufSize <= 0) {
|
|
|
|
|
WarnL << "config srt " << kPktBufSize << " not vaild";
|
|
|
|
|
return 8912;
|
|
|
|
|
}
|
2022-06-11 22:51:11 +08:00
|
|
|
|
return pktBufSize;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-03 16:47:53 +08:00
|
|
|
|
} // namespace SRT
|