From 18bf6ec2010ef731b417930e0a74ddcf6770afd4 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Mon, 21 May 2018 23:18:17 +0800 Subject: [PATCH] =?UTF-8?q?tcp=E5=AE=A2=E6=88=B7=E7=AB=AF=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=8C=87=E5=AE=9A=E7=BD=91=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZLToolKit | 2 +- src/Player/PlayerBase.cpp | 1 + src/Player/PlayerBase.h | 5 ++--- src/Rtmp/RtmpPlayer.cpp | 4 +++- src/Rtsp/RtspPlayer.cpp | 3 +++ 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/ZLToolKit b/ZLToolKit index f5c26c23..61a84362 160000 --- a/ZLToolKit +++ b/ZLToolKit @@ -1 +1 @@ -Subproject commit f5c26c234dfee07b9c3406fb359a3052ce19cf1f +Subproject commit 61a84362acbd196355dcf0053d2e8f7f4d12e3dd diff --git a/src/Player/PlayerBase.cpp b/src/Player/PlayerBase.cpp index 8b5e640e..85dd0edd 100644 --- a/src/Player/PlayerBase.cpp +++ b/src/Player/PlayerBase.cpp @@ -37,6 +37,7 @@ using namespace ZL::Rtsp; namespace ZL { namespace Player { +const char PlayerBase::kNetAdapter[] = "net_adapter"; PlayerBase::Ptr PlayerBase::createPlayer(const char* strUrl) { string prefix = FindField(strUrl, NULL, "://"); diff --git a/src/Player/PlayerBase.h b/src/Player/PlayerBase.h index cdb069e5..37fc4d20 100644 --- a/src/Player/PlayerBase.h +++ b/src/Player/PlayerBase.h @@ -51,7 +51,8 @@ public: RTP_MULTICAST = 2, } eRtpType; static Ptr createPlayer(const char* strUrl); - + static const char kNetAdapter[]; + PlayerBase(){}; virtual ~PlayerBase(){}; virtual void play(const char* strUrl) {}; @@ -79,8 +80,6 @@ public: virtual float getDuration() const { return 0;}; virtual float getProgress() const { return 0;}; virtual void seekTo(float fProgress) {}; - - protected: virtual void onShutdown(const SockException &ex) {}; virtual void onPlayResult(const SockException &ex) {}; diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index a6615b85..9f87b7e5 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -75,7 +75,6 @@ void RtmpPlayer::teardown() { shutdown(); } } - void RtmpPlayer::play(const char* strUrl) { teardown(); string strHost = FindField(strUrl, "://", "/"); @@ -97,6 +96,9 @@ void RtmpPlayer::play(const char* strUrl) { //服务器域名 strHost = FindField(strHost.c_str(), NULL, ":"); } + if(!(*this)[PlayerBase::kNetAdapter].empty()){ + setNetAdapter((*this)[PlayerBase::kNetAdapter]); + } startConnect(strHost, iPort); } void RtmpPlayer::onErr(const SockException &ex){ diff --git a/src/Rtsp/RtspPlayer.cpp b/src/Rtsp/RtspPlayer.cpp index de3c4458..cb28a378 100644 --- a/src/Rtsp/RtspPlayer.cpp +++ b/src/Rtsp/RtspPlayer.cpp @@ -147,6 +147,9 @@ void RtspPlayer::play(const char* strUrl, const char *strUser, const char *strPw } m_strUrl = strUrl; + if(!(*this)[PlayerBase::kNetAdapter].empty()){ + setNetAdapter((*this)[PlayerBase::kNetAdapter]); + } startConnect(ip.data(), port); } void RtspPlayer::onConnect(const SockException &err){