<chapter><title>VLS overview</title>

<sect1><title>VLS design</title>

<para>
The VideoLAN Server is programmed in C++, with an entirely "hand-made" 
framework. It means that VLS does not (and will not) use Standard Template 
Library classes such as iostreams or vectors. The internal VLS framework is 
supposed to be complete enough, so nothing should have to be written any more 
(except maybe for porting VLS to other operating systems).
</para>

<para>
VLS is made up of three parts: a framework (located in <filename>src/core
</filename>), common classes (in <filename>src/server </filename> and 
<filename>src/mpeg</filename>) and optional classes called <emphasis>modules
</emphasis> (in <filename>src/modules</filename>). Modules are actually classes 
inherited from common classes. Some classes that are considered as common 
classes at the moment may become modules in the future.

<mediaobject>
  <imageobject>
    <imagedata fileref="structure.eps" format="EPS" scalefit="1" scale="90">
  </imageobject>
  <imageobject>
    <imagedata fileref="structure.jpg" format="JPG">
  </imageobject>
  <textobject>
    <phrase>VLC overview</phrase>
  </textobject>
</mediaobject>

Since version 0.3.1, modules can be either <emphasis>built-in</emphasis> (i.e.
statically linked) or <emphasis>plug-in</emphasis> (i.e. dynamically loaded). 
Whether a module is built-in or plug-in is defined in <filename>configure.in
</filename>.

</para>

</sect1>

<sect1 id="l-arch"><title id="t-arch">General architecture</title>

<para>
The general architecture of the VLS is shows on the diagram below : 

<mediaobject>
   <imageobject>
    <imagedata fileref="architecture.eps" format="EPS" scalefit="1" scale="30">
   </imageobject>
   <imageobject>
    <imagedata fileref="architecture.jpg" format="JPG">
  </imageobject>
   <textobject>
      <phrase>VLC architecture</phrase>
   </textobject>
</mediaobject>
</para>

<para>
We can isolate 3 main parts : the source thread (Reader and
MpegConverter), the consumer thread (TsStreamer and the Output) and the
Management part (Input, Admin and Manager).
</para>

<para>
The Management part spawns all the needed parts and modules, when the
Vls is strarted or when a new stream is started.
</para>

<para>
The source thread reads the data through the reader as fast as possible
to fill up the SyncFifo. 
</para>

<para>
Then, the consumer thread gets the packets from
the SyncFifo and stream them. The timing of this streaming is managed
by the TsStreamer, which give them the Output module. The m_cFifo of
TS_IN_ETHER packet length is used to gather several TS Packets before
sending them together in one UDP packet (for the NetOutput module).
</para>

<para>
To improve the efficiency and avoid too many memory allocations, a pool
of TS Packet is allocated once : it is the TsProvider. That means that
at the beginning of the chain, a new TsPacket is called by the Converter
(TsProvider->GetPacket()), filled up with bytes from the reader, goes
through the TsStreamer and the Output. After being send, the TsPacket is
reset available in the TsProvider (TsProvider->ReleasePacket()).
<mediaobject>
  <imageobject>
    <imagedata fileref="provider.eps" format="EPS" scalefit="1" scale="30">
  </imageobject>
  <imageobject>
    <imagedata fileref="provider.jpg" format="JPG">
  </imageobject>
  <textobject>
    <phrase>VLC overview</phrase>
  </textobject>
</mediaobject>

</para>

<para>
The size of the TsProvider is calculated to be able to handle about 3
seconds of stream.
</para>

</sect1>

<sect1><title>Common classes overview</title>

<para>
Here is an overview of some common classes present in VLS (be careful: a class
drawn within another one is a <emphasis>member</emphasis> of that class, not a 
child) :

<mediaobject>
   <imageobject>
      <imagedata fileref="overview.eps" format="EPS" scalefit="1" scale="90">
   </imageobject>
   <imageobject>
      <imagedata fileref="overview.jpg" format="JPG">
   </imageobject>
   <textobject>
      <phrase>VLC overview</phrase>
   </textobject>
</mediaobject>
</para>

<para>
<variablelist>
  <varlistentry>
    <term>C_Vls</term>
    <listitem><para>
      It is the main class of the VideoLAN Server. Its role is to load
      modules, launch the Admin and the Manager, and forward messages between
      them.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Admin</term>
    <listitem><para>
      It is the main administration class, whose role is to control the various
      administration interfaces, and to parse and handle the commands sent to 
      these interfaces.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Telnet</term>
    <listitem><para>
      This is the telnet administration interface, the only one supported at 
      the moment.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Manager</term>
    <listitem><para>
      The Manager is one of the most important classes of VLS. It launches the
      various inputs and channels according to the configuration file 
      <filename>vls.cfg</filename>, contains a list of all the available 
      programs and a list of the currently broadcasted programs. It is this
      class which interprets the commands sent to the Admin, and can tell
      inputs to start, stop, suspend or resume streams.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Channel</term>
    <listitem><para>
      This is the parent class of all the channel (i.e. output) modules.
      Currently implemented channels are network and file.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_PgrmDirectory</term>
    <listitem><para>
      It is the list of all the programs available in the various inputs.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Broadcast</term>
    <listitem><para>
      A "broadcast" is defined by an input/program/channel combination.
      It represents a stream that is currently broadcasted by VLS.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_Input</term>
    <listitem><para>
      This is the parent class of all the input modules. An input basically
      gets a MPEG stream from a source (thanks to a "reader") and sends it to 
      a converter. Each input contains a list of the available programs it can
      provide.
    </para></listitem>
  </varlistentry> 
  <varlistentry>
    <term>C_MpegReader</term>
    <listitem><para>
      An MpegReader reads data from a source (file, DVD, ...) and delivers a
      continuous MPEG (PS or TS) stream.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_MpegConverter</term>
    <listitem><para>
      An MpegConverter converts the stream provided by the Reader into a valid
      MPEG-TS stream.
    </para></listitem>
  </varlistentry>
  <varlistentry>
    <term>C_TsStreamer</term>
    <listitem><para>
      The Streamer reads data from a Converter and sends it to a Channel at
      the right speed.
    </para></listitem>
  </varlistentry>
</variablelist>
</para>

</sect1>

</chapter>

