1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1575, use RTMP redirect as tcUrl and redirect2 as RTMP URL. 3.0.100

This commit is contained in:
winlin 2020-01-16 14:28:05 +08:00
parent 7240fe3040
commit 0e750ab3eb
8 changed files with 47 additions and 17 deletions

View file

@ -2415,17 +2415,20 @@ srs_error_t SrsRtmpServer::response_connect_app(SrsRequest *req, const char* ser
}
#define SRS_RTMP_REDIRECT_TIMEOUT (3 * SRS_UTIME_SECONDS)
srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string host, int port, bool& accepted)
srs_error_t SrsRtmpServer::redirect(SrsRequest* r, string url, bool& accepted)
{
srs_error_t err = srs_success;
if (true) {
string url = srs_generate_rtmp_url(host, port, r->host, r->vhost, r->app, r->stream, r->param);
SrsAmf0Object* ex = SrsAmf0Any::object();
ex->set("code", SrsAmf0Any::number(302));
ex->set("redirect", SrsAmf0Any::str(url.c_str()));
// The redirect is tcUrl while redirect2 is RTMP URL.
// https://github.com/ossrs/srs/issues/1575#issuecomment-574999798
string tcUrl = srs_path_dirname(url);
ex->set("redirect", SrsAmf0Any::str(tcUrl.c_str()));
ex->set("redirect2", SrsAmf0Any::str(url.c_str()));
SrsOnStatusCallPacket* pkt = new SrsOnStatusCallPacket();
pkt->data->set(StatusLevel, SrsAmf0Any::str(StatusLevelError));

View file

@ -707,9 +707,9 @@ public:
// @param server_ip the ip of server.
virtual srs_error_t response_connect_app(SrsRequest* req, const char* server_ip = NULL);
// Redirect the connection to another rtmp server.
// @param the hostname or ip of target.
// @param a RTMP url to redirect to.
// @param whether the client accept the redirect.
virtual srs_error_t redirect(SrsRequest* r, std::string host, int port, bool& accepted);
virtual srs_error_t redirect(SrsRequest* r, std::string url, bool& accepted);
// Reject the connect app request.
virtual void response_connect_reject(SrsRequest* req, const char* desc);
// Response client the onBWDone message.