mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-13 13:37:49 +08:00
Handling rtsp authentication like ffmpeg, Compatible with some rtsp servers (#4154)
This commit is contained in:
parent
b66806deb6
commit
12a2f7d491
@ -174,12 +174,12 @@ bool RtspPlayer::handleAuthenticationFailure(const string ¶msStr) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RtspPlayer::handleResponse(const string &cmd, const Parser &parser) {
|
bool RtspPlayer::handleResponse(const std::string &cmd, const Parser &parser, send_method_handler handler) {
|
||||||
string authInfo = parser["WWW-Authenticate"];
|
string authInfo = parser["WWW-Authenticate"];
|
||||||
// 发送DESCRIBE命令后的回复 [AUTO-TRANSLATED:39629cf0]
|
// 发送DESCRIBE命令后的回复 [AUTO-TRANSLATED:39629cf0]
|
||||||
// The response after sending the DESCRIBE command
|
// The response after sending the DESCRIBE command
|
||||||
if ((parser.status() == "401") && handleAuthenticationFailure(authInfo)) {
|
if ((parser.status() == "401") && handleAuthenticationFailure(authInfo)) {
|
||||||
sendOptions();
|
(this->*handler)();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (parser.status() == "302" || parser.status() == "301") {
|
if (parser.status() == "302" || parser.status() == "301") {
|
||||||
@ -197,7 +197,7 @@ bool RtspPlayer::handleResponse(const string &cmd, const Parser &parser) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RtspPlayer::handleResDESCRIBE(const Parser &parser) {
|
void RtspPlayer::handleResDESCRIBE(const Parser &parser) {
|
||||||
if (!handleResponse("DESCRIBE", parser)) {
|
if (!handleResponse("DESCRIBE", parser, &RtspPlayer::sendDescribe)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_content_base = parser["Content-Base"];
|
_content_base = parser["Content-Base"];
|
||||||
@ -428,7 +428,7 @@ void RtspPlayer::sendDescribe() {
|
|||||||
|
|
||||||
void RtspPlayer::sendOptions() {
|
void RtspPlayer::sendOptions() {
|
||||||
_on_response = [this](const Parser &parser) {
|
_on_response = [this](const Parser &parser) {
|
||||||
if (!handleResponse("OPTIONS", parser)) {
|
if (!handleResponse("OPTIONS", parser, &RtspPlayer::sendOptions)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取服务器支持的命令 [AUTO-TRANSLATED:8a6a12f1]
|
// 获取服务器支持的命令 [AUTO-TRANSLATED:8a6a12f1]
|
||||||
|
|||||||
@ -124,7 +124,8 @@ private:
|
|||||||
void handleResDESCRIBE(const Parser &parser);
|
void handleResDESCRIBE(const Parser &parser);
|
||||||
bool handleAuthenticationFailure(const std::string &wwwAuthenticateParamsStr);
|
bool handleAuthenticationFailure(const std::string &wwwAuthenticateParamsStr);
|
||||||
void handleResPAUSE(const Parser &parser, int type);
|
void handleResPAUSE(const Parser &parser, int type);
|
||||||
bool handleResponse(const std::string &cmd, const Parser &parser);
|
using send_method_handler = void (RtspPlayer::*)(void);
|
||||||
|
bool handleResponse(const std::string &cmd, const Parser &parser, send_method_handler handler);
|
||||||
|
|
||||||
void sendOptions();
|
void sendOptions();
|
||||||
void sendSetup(unsigned int track_idx);
|
void sendSetup(unsigned int track_idx);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user