Compare commits

..

No commits in common. "c19f34878690234ca46ec25b176885987b2a30c4" and "88b422db08516692140f39e2eddfc9e2ce8d1dcf" have entirely different histories.

9 changed files with 16 additions and 41 deletions

@ -1 +1 @@
Subproject commit 6e727443e6ca41af91f0cc2736b7a3bea971fedf Subproject commit 9b6701d54314cdc02273f4e0006b7e2882bd999c

View File

@ -400,7 +400,6 @@ const string kProxyUrl = "proxy_url";
const string kRtspSpeed = "rtsp_speed"; const string kRtspSpeed = "rtsp_speed";
const string kLatency = "latency"; const string kLatency = "latency";
const string kPassPhrase = "passPhrase"; const string kPassPhrase = "passPhrase";
const string kCustomHeader = "custom_header";
} // namespace Client } // namespace Client
} // namespace mediakit } // namespace mediakit

View File

@ -630,8 +630,6 @@ extern const std::string kRtspSpeed;
extern const std::string kLatency; extern const std::string kLatency;
// Set SRT PassPhrase // Set SRT PassPhrase
extern const std::string kPassPhrase; extern const std::string kPassPhrase;
// 自定义rtsp/http头
extern const std::string kCustomHeader;
} // namespace Client } // namespace Client
} // namespace mediakit } // namespace mediakit

View File

@ -36,7 +36,6 @@ void HlsPlayer::fetchIndexFile() {
} }
setCompleteTimeout((*this)[Client::kTimeoutMS].as<int>()); setCompleteTimeout((*this)[Client::kTimeoutMS].as<int>());
setMethod("GET"); setMethod("GET");
addCustomHeader(this);
sendRequest(_play_url); sendRequest(_play_url);
} }

View File

@ -25,7 +25,6 @@ void TsPlayer::play(const string &url) {
setHeaderTimeout((*this)[Client::kTimeoutMS].as<int>()); setHeaderTimeout((*this)[Client::kTimeoutMS].as<int>());
setBodyTimeout((*this)[Client::kMediaTimeoutMS].as<int>()); setBodyTimeout((*this)[Client::kMediaTimeoutMS].as<int>());
setMethod("GET"); setMethod("GET");
addCustomHeader(this);
sendRequest(url); sendRequest(url);
} }

View File

@ -21,22 +21,9 @@
#include "Common/MediaSink.h" #include "Common/MediaSink.h"
#include "Extension/Frame.h" #include "Extension/Frame.h"
#include "Extension/Track.h" #include "Extension/Track.h"
#include "Common/config.h"
#include "Common/Parser.h"
namespace mediakit { namespace mediakit {
template <typename Type>
void addCustomHeader(Type *c) {
auto &custom_header = (*c)[Client::kCustomHeader];
if (!custom_header.empty()) {
auto args = mediakit::Parser::parseArgs(custom_header);
for (auto &pr : args) {
c->addHeader(pr.first, pr.second);
}
}
}
class PlayerBase : public TrackSource, public toolkit::mINI { class PlayerBase : public TrackSource, public toolkit::mINI {
public: public:
using Ptr = std::shared_ptr<PlayerBase>; using Ptr = std::shared_ptr<PlayerBase>;

View File

@ -26,7 +26,6 @@ void FlvPlayer::play(const string &url) {
setHeaderTimeout((*this)[Client::kTimeoutMS].as<int>()); setHeaderTimeout((*this)[Client::kTimeoutMS].as<int>());
setBodyTimeout((*this)[Client::kMediaTimeoutMS].as<int>()); setBodyTimeout((*this)[Client::kMediaTimeoutMS].as<int>());
setMethod("GET"); setMethod("GET");
addCustomHeader(this);
sendRequest(url); sendRequest(url);
} }

View File

@ -91,22 +91,22 @@ void RtspPlayer::play(const string &strUrl) {
_speed = (*this)[Client::kRtspSpeed].as<float>(); _speed = (*this)[Client::kRtspSpeed].as<float>();
DebugL << url._url << " " << (url._user.size() ? url._user : "null") << " " << (url._passwd.size() ? url._passwd : "null") << " " << _rtp_type; DebugL << url._url << " " << (url._user.size() ? url._user : "null") << " " << (url._passwd.size() ? url._passwd : "null") << " " << _rtp_type;
weak_ptr<RtspPlayer> weak_self = static_pointer_cast<RtspPlayer>(shared_from_this()); weak_ptr<RtspPlayer> weakSelf = static_pointer_cast<RtspPlayer>(shared_from_this());
float playTimeOutSec = (*this)[Client::kTimeoutMS].as<int>() / 1000.0f; float playTimeOutSec = (*this)[Client::kTimeoutMS].as<int>() / 1000.0f;
_play_check_timer.reset(new Timer(playTimeOutSec,[weak_self]() { _play_check_timer.reset(new Timer(
if (auto strong_self = weak_self.lock()) { playTimeOutSec,
strong_self->onPlayResult_l(SockException(Err_timeout, "play rtsp timeout"), false); [weakSelf]() {
} auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return false; return false;
}, getPoller()));
auto &adapter = (*this)[Client::kNetAdapter];
if (!adapter.empty()) {
setNetAdapter(std::move(adapter));
} }
auto &custom_header = (*this)[Client::kCustomHeader]; strongSelf->onPlayResult_l(SockException(Err_timeout, "play rtsp timeout"), false);
if (!custom_header.empty()) { return false;
_custom_header = mediakit::Parser::parseArgs(custom_header); },
getPoller()));
if (!(*this)[Client::kNetAdapter].empty()) {
setNetAdapter((*this)[Client::kNetAdapter]);
} }
startConnect(url._host, url._port, playTimeOutSec); startConnect(url._host, url._port, playTimeOutSec);
} }
@ -632,11 +632,7 @@ void RtspPlayer::sendRtspRequest(const string &cmd, const string &url, const std
key = val; key = val;
} }
} }
if (cmd == "PLAY") {
for (auto &pr : _custom_header) {
header_map.emplace(pr.first, pr.second);
}
}
sendRtspRequest(cmd, url, header_map); sendRtspRequest(cmd, url, header_map);
} }

View File

@ -203,8 +203,6 @@ private:
// 统计rtp并发送rtcp [AUTO-TRANSLATED:0ac2b665] // 统计rtp并发送rtcp [AUTO-TRANSLATED:0ac2b665]
// Statistics rtp and send rtcp // Statistics rtp and send rtcp
std::vector<RtcpContext::Ptr> _rtcp_context; std::vector<RtcpContext::Ptr> _rtcp_context;
// 用户自定义rtsp头
StrCaseMap _custom_header;
}; };
} /* namespace mediakit */ } /* namespace mediakit */