mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 12:11:36 +08:00
更新zltoolkit,适配最新代码
This commit is contained in:
parent
64553797bd
commit
cdf97e7605
@ -1 +1 @@
|
|||||||
Subproject commit 7e40c751659d5c1ec623699732284c12e0a4feb8
|
Subproject commit d134fbb9fe0b108dddb66a7bfa35b7b438426411
|
@ -139,7 +139,7 @@ API_EXPORT void API_CALL mk_tcp_session_send(const mk_tcp_session ctx, const cha
|
|||||||
API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ctx, mk_buffer buffer) {
|
API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ctx, mk_buffer buffer) {
|
||||||
assert(ctx && buffer);
|
assert(ctx && buffer);
|
||||||
try {
|
try {
|
||||||
std::weak_ptr<Session> weak_session = ((SessionForC *) ctx)->shared_from_this();
|
std::weak_ptr<SocketHelper> weak_session = ((SessionForC *) ctx)->shared_from_this();
|
||||||
auto ref = mk_buffer_ref(buffer);
|
auto ref = mk_buffer_ref(buffer);
|
||||||
((SessionForC *) ctx)->async([weak_session, ref]() {
|
((SessionForC *) ctx)->async([weak_session, ref]() {
|
||||||
auto session_session = weak_session.lock();
|
auto session_session = weak_session.lock();
|
||||||
@ -149,7 +149,7 @@ API_EXPORT void API_CALL mk_tcp_session_send_buffer_safe(const mk_tcp_session ct
|
|||||||
mk_buffer_unref(ref);
|
mk_buffer_unref(ref);
|
||||||
});
|
});
|
||||||
} catch (std::exception &ex) {
|
} catch (std::exception &ex) {
|
||||||
WarnL << "can not got the strong pionter of this mk_tcp_session:" << ex.what();
|
WarnL << "can not got the strong pointer of this mk_tcp_session:" << ex.what();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +271,7 @@ void TcpClientForC::onRecv(const Buffer::Ptr &pBuf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TcpClientForC::onErr(const SockException &ex) {
|
void TcpClientForC::onError(const SockException &ex) {
|
||||||
if(_events.on_mk_tcp_client_disconnect){
|
if(_events.on_mk_tcp_client_disconnect){
|
||||||
_events.on_mk_tcp_client_disconnect(_client,ex.getErrCode(),ex.what());
|
_events.on_mk_tcp_client_disconnect(_client,ex.getErrCode(),ex.what());
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public:
|
|||||||
TcpClientForC(mk_tcp_client_events *events) ;
|
TcpClientForC(mk_tcp_client_events *events) ;
|
||||||
~TcpClientForC() override ;
|
~TcpClientForC() override ;
|
||||||
void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
|
void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
void onManager() override;
|
void onManager() override;
|
||||||
void onConnect(const toolkit::SockException &ex) override;
|
void onConnect(const toolkit::SockException &ex) override;
|
||||||
void setClient(mk_tcp_client client);
|
void setClient(mk_tcp_client client);
|
||||||
|
@ -176,7 +176,7 @@ void HttpClient::onRecv(const Buffer::Ptr &pBuf) {
|
|||||||
HttpRequestSplitter::input(pBuf->data(), pBuf->size());
|
HttpRequestSplitter::input(pBuf->data(), pBuf->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HttpClient::onErr(const SockException &ex) {
|
void HttpClient::onError(const SockException &ex) {
|
||||||
onResponseCompleted_l(ex);
|
onResponseCompleted_l(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ protected:
|
|||||||
//// TcpClient override ////
|
//// TcpClient override ////
|
||||||
void onConnect(const toolkit::SockException &ex) override;
|
void onConnect(const toolkit::SockException &ex) override;
|
||||||
void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
|
void onRecv(const toolkit::Buffer::Ptr &pBuf) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
void onFlush() override;
|
void onFlush() override;
|
||||||
void onManager() override;
|
void onManager() override;
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ static void accessFile(Session &sender, const Parser &parser, const MediaInfo &m
|
|||||||
replace(const_cast<string &>(media_info._streamid), kHlsSuffix, "");
|
replace(const_cast<string &>(media_info._streamid), kHlsSuffix, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
weak_ptr<Session> weakSession = sender.shared_from_this();
|
weak_ptr<Session> weakSession = static_pointer_cast<Session>(sender.shared_from_this());
|
||||||
//判断是否有权限访问该文件
|
//判断是否有权限访问该文件
|
||||||
canAccessPath(sender, parser, media_info, false, [cb, file_path, parser, is_hls, media_info, weakSession](const string &err_msg, const HttpServerCookie::Ptr &cookie) {
|
canAccessPath(sender, parser, media_info, false, [cb, file_path, parser, is_hls, media_info, weakSession](const string &err_msg, const HttpServerCookie::Ptr &cookie) {
|
||||||
auto strongSession = weakSession.lock();
|
auto strongSession = weakSession.lock();
|
||||||
|
@ -612,7 +612,7 @@ void HttpSession::sendResponse(int code,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//发送http body
|
//发送http body
|
||||||
AsyncSenderData::Ptr data = std::make_shared<AsyncSenderData>(shared_from_this(), body, bClose);
|
AsyncSenderData::Ptr data = std::make_shared<AsyncSenderData>(static_pointer_cast<Session>(shared_from_this()), body, bClose);
|
||||||
getSock()->setOnFlush([data]() { return AsyncSender::onSocketFlushed(data); });
|
getSock()->setOnFlush([data]() { return AsyncSender::onSocketFlushed(data); });
|
||||||
AsyncSender::onSocketFlushed(data);
|
AsyncSender::onSocketFlushed(data);
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* tcp连接断开
|
* tcp连接断开
|
||||||
*/
|
*/
|
||||||
void onErr(const toolkit::SockException &ex) override {
|
void onError(const toolkit::SockException &ex) override {
|
||||||
// tcp断开或者shutdown导致的断开
|
// tcp断开或者shutdown导致的断开
|
||||||
onWebSocketException(ex);
|
onWebSocketException(ex);
|
||||||
}
|
}
|
||||||
@ -350,7 +350,7 @@ private:
|
|||||||
// 握手成功之后的中途断开
|
// 握手成功之后的中途断开
|
||||||
_onRecv = nullptr;
|
_onRecv = nullptr;
|
||||||
if (auto strong_ref = _weak_delegate.lock()) {
|
if (auto strong_ref = _weak_delegate.lock()) {
|
||||||
strong_ref->onErr(ex);
|
strong_ref->onError(ex);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ void RtmpPlayer::play(const string &url) {
|
|||||||
startConnect(host_url, port, play_timeout_sec);
|
startConnect(host_url, port, play_timeout_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtmpPlayer::onErr(const SockException &ex){
|
void RtmpPlayer::onError(const SockException &ex){
|
||||||
//定时器_pPlayTimer为空后表明握手结束了
|
//定时器_pPlayTimer为空后表明握手结束了
|
||||||
onPlayResult_l(ex, !_play_timer);
|
onPlayResult_l(ex, !_play_timer);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ protected:
|
|||||||
//form Tcpclient
|
//form Tcpclient
|
||||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||||
void onConnect(const toolkit::SockException &err) override;
|
void onConnect(const toolkit::SockException &err) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
//from RtmpProtocol
|
//from RtmpProtocol
|
||||||
void onRtmpChunk(RtmpPacket::Ptr chunk_data) override;
|
void onRtmpChunk(RtmpPacket::Ptr chunk_data) override;
|
||||||
void onStreamDry(uint32_t stream_index) override;
|
void onStreamDry(uint32_t stream_index) override;
|
||||||
|
@ -97,7 +97,7 @@ void RtmpPusher::publish(const string &url) {
|
|||||||
startConnect(host_url, port);
|
startConnect(host_url, port);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtmpPusher::onErr(const SockException &ex){
|
void RtmpPusher::onError(const SockException &ex){
|
||||||
//定时器_pPublishTimer为空后表明握手结束了
|
//定时器_pPublishTimer为空后表明握手结束了
|
||||||
onPublishResult_l(ex, !_publish_timer);
|
onPublishResult_l(ex, !_publish_timer);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ protected:
|
|||||||
//for Tcpclient override
|
//for Tcpclient override
|
||||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||||
void onConnect(const toolkit::SockException &err) override;
|
void onConnect(const toolkit::SockException &err) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
|
|
||||||
//for RtmpProtocol override
|
//for RtmpProtocol override
|
||||||
void onRtmpChunk(RtmpPacket::Ptr chunk_data) override;
|
void onRtmpChunk(RtmpPacket::Ptr chunk_data) override;
|
||||||
|
@ -131,7 +131,7 @@ void RtspPlayer::onRecv(const Buffer::Ptr& buf) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtspPlayer::onErr(const SockException &ex) {
|
void RtspPlayer::onError(const SockException &ex) {
|
||||||
//定时器_pPlayTimer为空后表明握手结束了
|
//定时器_pPlayTimer为空后表明握手结束了
|
||||||
onPlayResult_l(ex,!_play_check_timer);
|
onPlayResult_l(ex,!_play_check_timer);
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ protected:
|
|||||||
/////////////TcpClient override/////////////
|
/////////////TcpClient override/////////////
|
||||||
void onConnect(const toolkit::SockException &err) override;
|
void onConnect(const toolkit::SockException &err) override;
|
||||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onPlayResult_l(const toolkit::SockException &ex , bool handshake_done);
|
void onPlayResult_l(const toolkit::SockException &ex , bool handshake_done);
|
||||||
|
@ -118,7 +118,7 @@ void RtspPusher::onPublishResult_l(const SockException &ex, bool handshake_done)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtspPusher::onErr(const SockException &ex) {
|
void RtspPusher::onError(const SockException &ex) {
|
||||||
//定时器_pPublishTimer为空后表明握手结束了
|
//定时器_pPublishTimer为空后表明握手结束了
|
||||||
onPublishResult_l(ex, !_publish_timer);
|
onPublishResult_l(ex, !_publish_timer);
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ protected:
|
|||||||
//for Tcpclient override
|
//for Tcpclient override
|
||||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||||
void onConnect(const toolkit::SockException &err) override;
|
void onConnect(const toolkit::SockException &err) override;
|
||||||
void onErr(const toolkit::SockException &ex) override;
|
void onError(const toolkit::SockException &ex) override;
|
||||||
|
|
||||||
//RtspSplitter override
|
//RtspSplitter override
|
||||||
void onWholeRtspPacket(Parser &parser) override ;
|
void onWholeRtspPacket(Parser &parser) override ;
|
||||||
|
@ -100,7 +100,7 @@ void SrtSession::onRecv(const Buffer::Ptr &buffer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_transport) {
|
if (_transport) {
|
||||||
_transport->setSession(shared_from_this());
|
_transport->setSession(static_pointer_cast<Session>(shared_from_this()));
|
||||||
}
|
}
|
||||||
InfoP(this);
|
InfoP(this);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ protected:
|
|||||||
DebugL << pBuf->toString();
|
DebugL << pBuf->toString();
|
||||||
}
|
}
|
||||||
//被动断开连接回调
|
//被动断开连接回调
|
||||||
void onErr(const SockException &ex) override {
|
void onError(const SockException &ex) override {
|
||||||
WarnL << ex;
|
WarnL << ex;
|
||||||
}
|
}
|
||||||
//tcp连接成功后每2秒触发一次该事件
|
//tcp连接成功后每2秒触发一次该事件
|
||||||
|
@ -520,7 +520,7 @@ namespace RTC
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
this->selectedTuple = storedTuple;
|
this->selectedTuple = storedTuple;
|
||||||
this->lastSelectedTuple = storedTuple->shared_from_this();
|
this->lastSelectedTuple = static_pointer_cast<RTC::TransportTuple>(storedTuple->shared_from_this());
|
||||||
|
|
||||||
// Notify the listener.
|
// Notify the listener.
|
||||||
this->listener->OnIceServerSelectedTuple(this, this->selectedTuple);
|
this->listener->OnIceServerSelectedTuple(this, this->selectedTuple);
|
||||||
|
@ -47,7 +47,7 @@ void WebRtcPlayer::onStartWebRTC() {
|
|||||||
playSrc->pause(false);
|
playSrc->pause(false);
|
||||||
_reader = playSrc->getRing()->attach(getPoller(), true);
|
_reader = playSrc->getRing()->attach(getPoller(), true);
|
||||||
weak_ptr<WebRtcPlayer> weak_self = static_pointer_cast<WebRtcPlayer>(shared_from_this());
|
weak_ptr<WebRtcPlayer> weak_self = static_pointer_cast<WebRtcPlayer>(shared_from_this());
|
||||||
weak_ptr<Session> weak_session = getSession();
|
weak_ptr<Session> weak_session = static_pointer_cast<Session>(getSession());
|
||||||
_reader->setGetInfoCB([weak_session]() { return weak_session.lock(); });
|
_reader->setGetInfoCB([weak_session]() { return weak_session.lock(); });
|
||||||
_reader->setReadCB([weak_self](const RtspMediaSource::RingDataType &pkt) {
|
_reader->setReadCB([weak_self](const RtspMediaSource::RingDataType &pkt) {
|
||||||
auto strong_self = weak_self.lock();
|
auto strong_self = weak_self.lock();
|
||||||
|
@ -108,7 +108,7 @@ void WebRtcSession::onError(const SockException &err) {
|
|||||||
if (!_transport) {
|
if (!_transport) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto self = shared_from_this();
|
auto self = static_pointer_cast<WebRtcSession>(shared_from_this());
|
||||||
auto transport = std::move(_transport);
|
auto transport = std::move(_transport);
|
||||||
getPoller()->async([transport, self]() mutable {
|
getPoller()->async([transport, self]() mutable {
|
||||||
//延时减引用,防止使用transport对象时,销毁对象
|
//延时减引用,防止使用transport对象时,销毁对象
|
||||||
|
@ -230,7 +230,7 @@ void WebRtcTransport::sendSockData(const char *buf, size_t len, RTC::TransportTu
|
|||||||
|
|
||||||
Session::Ptr WebRtcTransport::getSession() const {
|
Session::Ptr WebRtcTransport::getSession() const {
|
||||||
auto tuple = _ice_server->GetSelectedTuple(true);
|
auto tuple = _ice_server->GetSelectedTuple(true);
|
||||||
return tuple ? tuple->shared_from_this() : nullptr;
|
return tuple ? static_pointer_cast<Session>(tuple->shared_from_this()) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcTransport::sendRtcpRemb(uint32_t ssrc, size_t bit_rate) {
|
void WebRtcTransport::sendRtcpRemb(uint32_t ssrc, size_t bit_rate) {
|
||||||
@ -1209,7 +1209,7 @@ void play_plugin(Session &sender, const WebRtcArgs &args, const WebRtcPluginMana
|
|||||||
MediaInfo info(args["url"]);
|
MediaInfo info(args["url"]);
|
||||||
bool preferred_tcp = args["preferred_tcp"];
|
bool preferred_tcp = args["preferred_tcp"];
|
||||||
|
|
||||||
auto session_ptr = sender.shared_from_this();
|
auto session_ptr = static_pointer_cast<Session>(sender.shared_from_this());
|
||||||
Broadcast::AuthInvoker invoker = [cb, info, session_ptr, preferred_tcp](const string &err) mutable {
|
Broadcast::AuthInvoker invoker = [cb, info, session_ptr, preferred_tcp](const string &err) mutable {
|
||||||
if (!err.empty()) {
|
if (!err.empty()) {
|
||||||
cb(WebRtcException(SockException(Err_other, err)));
|
cb(WebRtcException(SockException(Err_other, err)));
|
||||||
|
Loading…
Reference in New Issue
Block a user