Limit queued TCP data messages to one per stream
authorDavid Svensson Fors <davidsf@axis.com>
Thu, 28 Jun 2018 09:22:21 +0000 (11:22 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Mon, 23 Jul 2018 14:45:00 +0000 (17:45 +0300)
commit12169f1e845a45db41cc7d416ca0f101fa607176
treeafdfdb179e793e7b9a4501b5a654d729c297185e
parent287345f6ac3becdcc1dbd2397d4cbe323ddf1879
Limit queued TCP data messages to one per stream

Before, the watch backlog size in GstRTSPClient was changed
dynamically between unlimited and a fixed size, trying to avoid both
unlimited memory usage and deadlocks while waiting for place in the
queue. (Some of the deadlocks were described in a long comment in
handle_request().)

In the previous commit, we changed to a fixed backlog size of 100.
This is possible, because we now handle RTP/RTCP data messages differently
from RTSP request/response messages.

The data messages are messages tunneled over TCP. We allow at most one
queued data message per stream in GstRTSPClient at a time, and
successfully sent data messages are acked by sending a "message-sent"
callback from the GstStreamTransport. Until that ack comes, the
GstRTSPStream does not call pull_sample() on its appsink, and
therefore the streaming thread in the pipeline will not be blocked
inside GstRTSPClient, waiting for a place in the queue.

pull_sample() is called when we have both an ack and a "new-sample"
signal from the appsink. Then, we know there is a buffer to write.

RTSP request/response messages are not acked in the same way as data
messages. The rest of the 100 places in the queue are used for
them. If the queue becomes full of request/response messages, we
return an error and close the connection to the client.

Change-Id: I275310bc90a219ceb2473c098261acc78be84c97
gst/rtsp-server/rtsp-client.c
gst/rtsp-server/rtsp-stream-transport.c
gst/rtsp-server/rtsp-stream-transport.h
gst/rtsp-server/rtsp-stream.c