obs-outputs: Add connect time callback for rtmp output

This commit is contained in:
jp9000 2017-04-24 03:27:27 -07:00
parent f6517d2be3
commit 585b3ed945
3 changed files with 14 additions and 0 deletions

View File

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

View File

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

View File

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