New upstream version 19.0.3+dfsg1

This commit is contained in:
Sebastian Ramacher 2017-06-29 21:01:10 +02:00
parent 3708b8e092
commit 1f1bbb3518
534 changed files with 13862 additions and 2459 deletions

View file

@ -378,6 +378,64 @@ static inline bool can_shutdown_stream(struct rtmp_stream *stream,
return timeout || packet->sys_dts_usec >= (int64_t)stream->stop_ts;
}
static void set_output_error(struct rtmp_stream *stream)
{
const char *msg = NULL;
#ifdef _WIN32
switch (stream->rtmp.last_error_code)
{
case WSAETIMEDOUT:
msg = obs_module_text("ConnectionTimedOut");
break;
case WSAEACCES:
msg = obs_module_text("PermissionDenied");
break;
case WSAECONNABORTED:
msg = obs_module_text("ConnectionAborted");
break;
case WSAECONNRESET:
msg = obs_module_text("ConnectionReset");
break;
case WSAHOST_NOT_FOUND:
msg = obs_module_text("HostNotFound");
break;
case WSANO_DATA:
msg = obs_module_text("NoData");
break;
case WSAEADDRNOTAVAIL:
msg = obs_module_text("AddressNotAvailable");
break;
}
#else
switch (stream->rtmp.last_error_code)
{
case ETIMEDOUT:
msg = obs_module_text("ConnectionTimedOut");
break;
case EACCES:
msg = obs_module_text("PermissionDenied");
break;
case ECONNABORTED:
msg = obs_module_text("ConnectionAborted");
break;
case ECONNRESET:
msg = obs_module_text("ConnectionReset");
break;
case HOST_NOT_FOUND:
msg = obs_module_text("HostNotFound");
break;
case NO_DATA:
msg = obs_module_text("NoData");
break;
case EADDRNOTAVAIL:
msg = obs_module_text("AddressNotAvailable");
break;
}
#endif
obs_output_set_last_error(stream->output, msg);
}
static void *send_thread(void *data)
{
struct rtmp_stream *stream = data;
@ -428,6 +486,7 @@ static void *send_thread(void *data)
stream->rtmp.m_bCustomSend = false;
}
set_output_error(stream);
RTMP_Close(&stream->rtmp);
if (!stopping(stream)) {
@ -571,8 +630,10 @@ static int init_send(struct rtmp_stream *stream)
int one = 1;
#ifdef _WIN32
if (ioctlsocket(stream->rtmp.m_sb.sb_socket, FIONBIO, &one)) {
stream->rtmp.last_error_code = WSAGetLastError();
#else
if (ioctl(stream->rtmp.m_sb.sb_socket, FIONBIO, &one)) {
stream->rtmp.last_error_code = errno;
#endif
warn("Failed to set non-blocking socket");
return OBS_OUTPUT_ERROR;
@ -644,6 +705,7 @@ static int init_send(struct rtmp_stream *stream)
if (!send_meta_data(stream, idx++, &next)) {
warn("Disconnected while attempting to connect to "
"server.");
set_output_error(stream);
return OBS_OUTPUT_DISCONNECTED;
}
}
@ -718,7 +780,7 @@ static int try_connect(struct rtmp_stream *stream)
info("Connecting to RTMP URL %s...", stream->path.array);
memset(&stream->rtmp.Link, 0, sizeof(stream->rtmp.Link));
RTMP_Init(&stream->rtmp);
if (!RTMP_SetupURL(&stream->rtmp, stream->path.array))
return OBS_OUTPUT_BAD_PATH;
@ -767,8 +829,11 @@ static int try_connect(struct rtmp_stream *stream)
win32_log_interface_type(stream);
#endif
if (!RTMP_Connect(&stream->rtmp, NULL))
if (!RTMP_Connect(&stream->rtmp, NULL)) {
set_output_error(stream);
return OBS_OUTPUT_CONNECT_FAILED;
}
if (!RTMP_ConnectStream(&stream->rtmp, 0))
return OBS_OUTPUT_INVALID_STREAM;
@ -798,7 +863,6 @@ static bool init_connect(struct rtmp_stream *stream)
os_atomic_set_bool(&stream->disconnected, false);
stream->total_bytes_sent = 0;
stream->dropped_frames = 0;
stream->min_drop_dts_usec= 0;
stream->min_priority = 0;
settings = obs_output_get_settings(stream->output);
@ -876,7 +940,6 @@ static inline bool add_packet(struct rtmp_stream *stream,
{
circlebuf_push_back(&stream->packets, packet,
sizeof(struct encoder_packet));
stream->last_dts_usec = packet->dts_usec;
return true;
}
@ -886,7 +949,7 @@ static inline size_t num_buffered_packets(struct rtmp_stream *stream)
}
static void drop_frames(struct rtmp_stream *stream, const char *name,
int highest_priority, int64_t *p_min_dts_usec)
int highest_priority, bool pframes)
{
struct circlebuf new_buf = {0};
uint64_t last_drop_dts_usec = 0;
@ -922,8 +985,8 @@ static void drop_frames(struct rtmp_stream *stream, const char *name,
if (stream->min_priority < highest_priority)
stream->min_priority = highest_priority;
*p_min_dts_usec = last_drop_dts_usec;
if (!num_frames_dropped)
return;
stream->dropped_frames += num_frames_dropped;
#ifdef _DEBUG
@ -934,6 +997,23 @@ static void drop_frames(struct rtmp_stream *stream, const char *name,
#endif
}
static bool find_first_video_packet(struct rtmp_stream *stream,
struct encoder_packet *first)
{
size_t count = stream->packets.size / sizeof(*first);
for (size_t i = 0; i < count; i++) {
struct encoder_packet *cur = circlebuf_data(&stream->packets,
i * sizeof(*first));
if (cur->type == OBS_ENCODER_VIDEO && !cur->keyframe) {
*first = *cur;
return true;
}
}
return false;
}
static void check_to_drop_frames(struct rtmp_stream *stream, bool pframes)
{
struct encoder_packet first;
@ -942,9 +1022,6 @@ static void check_to_drop_frames(struct rtmp_stream *stream, bool pframes)
const char *name = pframes ? "p-frames" : "b-frames";
int priority = pframes ?
OBS_NAL_PRIORITY_HIGHEST : OBS_NAL_PRIORITY_HIGH;
int64_t *p_min_dts_usec = pframes ?
&stream->pframe_min_drop_dts_usec :
&stream->min_drop_dts_usec;
int64_t drop_threshold = pframes ?
stream->pframe_drop_threshold_usec :
stream->drop_threshold_usec;
@ -955,10 +1032,7 @@ static void check_to_drop_frames(struct rtmp_stream *stream, bool pframes)
return;
}
circlebuf_peek_front(&stream->packets, &first, sizeof(first));
/* do not drop frames if frames were just dropped within this time */
if (first.dts_usec < *p_min_dts_usec)
if (!find_first_video_packet(stream, &first))
return;
/* if the amount of time stored in the buffered packets waiting to be
@ -972,7 +1046,7 @@ static void check_to_drop_frames(struct rtmp_stream *stream, bool pframes)
if (buffer_duration_usec > drop_threshold) {
debug("buffer_duration_usec: %" PRId64, buffer_duration_usec);
drop_frames(stream, name, priority, p_min_dts_usec);
drop_frames(stream, name, priority, pframes);
}
}
@ -991,6 +1065,7 @@ static bool add_video_packet(struct rtmp_stream *stream,
stream->min_priority = 0;
}
stream->last_dts_usec = packet->dts_usec;
return add_packet(stream, packet);
}
@ -1090,6 +1165,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 +1187,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
};