on_play/on_publish hook 新增protocol字段 (#4133 #4143)

对于webhook  涉及到media info的相关信息,增加protocol 的字段,表明是基于什么协议传输的
This commit is contained in:
xiongguangjie
2025-02-13 15:18:47 +08:00
committed by GitHub
parent 8a4d548427
commit 2a85dffdf9
7 changed files with 19 additions and 0 deletions

View File

@@ -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;

View File

@@ -388,6 +388,7 @@ public:
public:
uint16_t port = 0;
std::string protocol;
std::string full_url;
std::string schema;
std::string host;

View File

@@ -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<HttpSession> weak_self = static_pointer_cast<HttpSession>(shared_from_this());

View File

@@ -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;

View File

@@ -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");

View File

@@ -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<GB28181Process>(_media_info, this);
}

View File

@@ -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()) {