提交 585b3ed9 编写于 作者: J jp9000

obs-outputs: Add connect time callback for rtmp output

上级 f6517d2b
......@@ -32,6 +32,8 @@
#include "rtmp_sys.h"
#include "log.h"
#include <util/platform.h>
#ifdef CRYPTO
#ifdef __APPLE__
......@@ -773,6 +775,8 @@ RTMP_Connect0(RTMP *r, struct sockaddr * service, socklen_t addrlen)
}
}
uint64_t connect_start = os_gettime_ns();
if (connect(r->m_sb.sb_socket, service, addrlen) < 0)
{
int err = GetSockError();
......@@ -789,6 +793,8 @@ RTMP_Connect0(RTMP *r, struct sockaddr * service, socklen_t addrlen)
return FALSE;
}
r->connect_time_ms = (int)((os_gettime_ns() - connect_start) / 1000000);
if (r->Link.socksport)
{
RTMP_Log(RTMP_LOGDEBUG, "%s ... SOCKS negotiation", __FUNCTION__);
......
......@@ -324,6 +324,7 @@ extern "C"
RTMPPacket m_write;
RTMPSockBuf m_sb;
RTMP_LNK Link;
int connect_time_ms;
} RTMP;
int RTMP_ParseURL(const char *url, int *protocol, AVal *host,
......
......@@ -1090,6 +1090,12 @@ static float rtmp_stream_congestion(void *data)
return stream->min_priority > 0 ? 1.0f : stream->congestion;
}
static int rtmp_stream_connect_time(void *data)
{
struct rtmp_stream *stream = data;
return stream->rtmp.connect_time_ms;
}
struct obs_output_info rtmp_output_info = {
.id = "rtmp_output",
.flags = OBS_OUTPUT_AV |
......@@ -1106,5 +1112,6 @@ struct obs_output_info rtmp_output_info = {
.get_properties = rtmp_stream_properties,
.get_total_bytes = rtmp_stream_total_bytes_sent,
.get_congestion = rtmp_stream_congestion,
.get_connect_time_ms= rtmp_stream_connect_time,
.get_dropped_frames = rtmp_stream_dropped_frames
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册