diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 503e640e..0510ea90 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -229,6 +229,11 @@ void dumpMediaTuple(const MediaTuple &tuple, Json::Value& item); static ArgsType make_json(const MediaInfo &args) { ArgsType body; body["schema"] = args.schema; + if(!args.protocol.empty()){ + body["protocol"] = args.protocol; + }else{ + body["protocol"] = args.schema; + } dumpMediaTuple(args, body); body["params"] = args.params; return body; diff --git a/src/Common/MediaSource.h b/src/Common/MediaSource.h index 8469bc2d..cab80a90 100644 --- a/src/Common/MediaSource.h +++ b/src/Common/MediaSource.h @@ -388,6 +388,7 @@ public: public: uint16_t port = 0; + std::string protocol; std::string full_url; std::string schema; std::string host; diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 0b89d182..7bc3755c 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -213,6 +213,7 @@ bool HttpSession::checkWebSocket() { if (Sec_WebSocket_Key.empty()) { return false; } + _is_websocket = true; auto Sec_WebSocket_Accept = encodeBase64(SHA1::encode_bin(Sec_WebSocket_Key + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11")); KeyValue headerOut; @@ -305,6 +306,12 @@ bool HttpSession::checkLiveStream(const string &schema, const string &url_suffix return false; } + if (_is_websocket) { + _media_info.protocol = overSsl() ? "wss" : "ws"; + } else { + _media_info.protocol = overSsl() ? "https" : "http"; + } + bool close_flag = !strcasecmp(_parser["Connection"].data(), "close"); weak_ptr weak_self = static_pointer_cast(shared_from_this()); diff --git a/src/Http/HttpSession.h b/src/Http/HttpSession.h index 27544318..b714e4b6 100644 --- a/src/Http/HttpSession.h +++ b/src/Http/HttpSession.h @@ -158,6 +158,7 @@ protected: private: bool _is_live_stream = false; bool _live_over_websocket = false; + bool _is_websocket = false; // 超时时间 [AUTO-TRANSLATED:f15e2672] // Timeout size_t _keep_alive_sec = 0; diff --git a/src/Rtmp/RtmpSession.cpp b/src/Rtmp/RtmpSession.cpp index 6fc3c216..93bb9a76 100644 --- a/src/Rtmp/RtmpSession.cpp +++ b/src/Rtmp/RtmpSession.cpp @@ -96,6 +96,8 @@ void RtmpSession::onCmd_connect(AMFDecoder &dec) { // 赋值rtmp app _media_info.app = params["app"].as_string(); + _media_info.protocol = overSsl() ? "rtmps" : "rtmp"; + bool ok = true; //(app == APP_NAME); AMFValue version(AMF_OBJECT); version.set("fmsVer", "FMS/3,0,1,123"); diff --git a/src/Rtp/RtpProcess.cpp b/src/Rtp/RtpProcess.cpp index 61079161..46fbb2b5 100644 --- a/src/Rtp/RtpProcess.cpp +++ b/src/Rtp/RtpProcess.cpp @@ -127,6 +127,7 @@ bool RtpProcess::inputRtp(bool is_udp, const Socket::Ptr &sock, const char *data fwrite((uint8_t *) data, len, 1, _save_file_rtp.get()); } if (!_process) { + _media_info.protocol = is_udp ? "udp" : "tcp"; _process = std::make_shared(_media_info, this); } diff --git a/src/Rtsp/RtspSession.cpp b/src/Rtsp/RtspSession.cpp index 6fa88b7e..324df6dd 100644 --- a/src/Rtsp/RtspSession.cpp +++ b/src/Rtsp/RtspSession.cpp @@ -134,6 +134,7 @@ void RtspSession::onWholeRtspPacket(Parser &parser) { _content_base = rtsp._url; _media_info.parse(parser.fullUrl()); _media_info.schema = RTSP_SCHEMA; + _media_info.protocol = overSsl() ? "rtsps" : "rtsp"; } using rtsp_request_handler = void (RtspSession::*)(const Parser &parser); @@ -206,6 +207,7 @@ void RtspSession::handleReq_ANNOUNCE(const Parser &parser) { //去除.sdp后缀,防止EasyDarwin推流器强制添加.sdp后缀 full_url = full_url.substr(0, full_url.length() - 4); _media_info.parse(full_url); + _media_info.protocol = overSsl() ? "rtsps" : "rtsp"; } if (_media_info.app.empty() || _media_info.stream.empty()) {