[FFmpeg-devel] [PATCH 4/4] ffserver: Add basic documentation of the architecture

Stephan Holljes klaxa1337 at googlemail.com
Thu Apr 12 16:35:49 EEST 2018

 Documentation.txt | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation.txt

diff --git a/Documentation.txt b/Documentation.txt
new file mode 100644
index 0000000..de7b522
--- /dev/null
+++ b/Documentation.txt
@@ -0,0 +1,30 @@
+The current implementation has three different types of work that is done in
+different threads. These types are: reading a stream, accepting HTTP
+connections and writing media data to clients.
+The design tries to follow a Publisher-Subscriber-Pattern. The PublisherContext
+struct contains buffers of read media data and the list of clients. Clients
+themselves contain a buffer of media data that still has to be sent to them.
+The reading thread takes care of segmenting the stream into independent chunks
+of data and pushing it to the PublisherContext, which publishes the new Segment
+to connected clients. This publishing only adds this Segment to the client's
+The writing thread does the actual writing of data over the network. It checks
+each client's state and if there is data available that can be written to that
+client it is sent.
+The accept thread accepts new clients over HTTP and if not all client slots are
+in use, writes the stream-header and adds the client to the PublisherContext.
+A Segment is only stored in memory once and is refcounted. Buffers in the
+PublisherContext and clients contain pointers to Segments.
+Buffers are implemented using AVFifoBuffer.
+Client states are protected by pthread-mutex-locks, making it possible to run
+multiple write threads.

More information about the ffmpeg-devel mailing list