<?xml version="1.0" encoding="UTF-8" ?>

<chapter id="vlm"><title id="tvlm">
VLM - Multiple streaming and Video on demand
</title>

<!--
info concerning vlm : /trunk/doc/vlm.txt

TODO:
 * put some VOD examples
-->

<sect1><title>VLM</title>

<para><emphasis>VideoLAN Manager</emphasis> is a small media manager
designed to control multiple streams with <emphasis>only one instance of
VLC</emphasis>. It allows multiple streaming and video on demand (VoD).
This manager being a new feature, it can only be controlled by the telnet
interface or the http interface.</para>

<sect2><title>Interfaces</title>

<sect3><title>Telnet interface</title>

<para>You can launch the telnet interface as a common interface using
the command line :</para>

<screen>
<prompt>% </prompt><userinput>vlc --intf telnet</userinput>
</screen>

<screen>
<prompt>% </prompt><userinput>vlc --extraintf telnet</userinput>
</screen>

<para>The telnet interface can also be launched in the wxWindows
interface :</para>

<mediaobject>
  <imageobject>
    <imagedata fileref="images/streaming-howto/intf-wx-extraintf-telnet.jpg" format="JPG" />
  </imageobject>
  <textobject><para>Launching the Telnet interface - wxWindows interface</para></textobject>
  <caption><para>Launching the Telnet interface - wxWindows interface</para></caption>
</mediaobject>

<para>The default port is 4212. The default password is
"admin". These can be changed using <command>--telnet-port
&lt;integer></command> and <command>--telnet-password
&lt;string></command> command line options. They can also be changed
in the preferences panel when using the wxWindows interface in the
<emphasis>Modules</emphasis>-><emphasis>interface</emphasis>-><emphasis>
telnet</emphasis> section (check the <emphasis>Advanced
options</emphasis> checkbox).</para>

</sect3>

<sect3><title>HTTP interface</title>

<para>Launching the HTTP interface is described in the <ulink
url="http://www.videolan.org/doc/">Play-with-VLC Howto.</ulink></para>

<para>To access the vlm section of the http interface, use the following
URL: <emphasis> http://host:port/vlm.html</emphasis> (<emphasis>http://host:port/vlm/</emphasis> for VLC 0.8.4 and older).</para>

</sect3></sect2>

<sect2><title>VLM Elements</title>

<sect3><title>Medias</title>

<para>A <emphasis>Media</emphasis> is composed with a list of inputs (the video and audio
streams you want to stream), an output (how and where you want to stream
them) and some options.</para>

<para>There are two types of medias:</para>

<itemizedlist>

<listitem><para><emphasis>vod</emphasis>: A vod media is commonly used
for Video on Demand. It will be launched only if a vod client asks for
it.</para></listitem>

<listitem><para><emphasis>broadcast</emphasis>: A broadcast media is
very close to a TV program or channel. It is launched, stopped or paused
by the administrator and may be repeated several times. The client has
no control over this media.</para></listitem>

</itemizedlist>

</sect3>

<sect3><title>Schedules</title>

<para>A <emphasis>Schedule</emphasis> is a script with a date. When the
schedule date is reached, the script is launched. There are several
options available like a period or a number of repetitions.</para>

</sect3></sect2>

<sect2><title>Command line syntax</title>

<sect3><title>Command lines</title>

<itemizedlist>

<listitem><para><command>help</command> : Displays an exhaustive command
lines list</para></listitem>

<listitem><para><command>new (name) vod|broadcast|schedule
[properties]</command> : Create a new vod, broadcast or schedule
element. Element names must be unique and cannot be "media" or
"schedule". You can specify properties in this command line or later on
by using the <command>setup</command> command. </para></listitem>

<listitem><para><command>setup (name) (properties)</command> : Set
an elements property. See <xref linkend="vlmprop" endterm="tvlmprop"
/>.</para></listitem>

<listitem><para><command>show [(name)|media|schedule]</command>
: Display current element states and configurations.
<itemizedlist><listitem><para><command>show (name)</command> - Specify
an element's name to show all information concerning this
element.</para></listitem><listitem><para><command>show media</command> displays
a summary of media states.</para></listitem><listitem><para><command>show
schedule</command> displays a summary of schedule
states.</para></listitem></itemizedlist></para></listitem>

<listitem><para><command>del (name)|all|media|schedule</command>
: Delete an element or a group of elements. If the
element wasn't stopped, it is first stopped before being
deleted.<itemizedlist><listitem><para><command>del
(name)</command> - Delete the (name)
element.</para></listitem><listitem><para><command>del all</command>
- Delete all elements</para></listitem><listitem><para><command>del
media</command> - Delete all media
elements.</para></listitem><listitem><para><command>del
schedule</command> - Delete all schedule
elements</para></listitem></itemizedlist></para></listitem>

<listitem><para><command>control (name) [instance_name]
(command)</command> : Change the state of the (instance_name) instance
of the (name) media. If (instance_name) isn't specified, the control
command affects the default instance. See <xref linkend="vlmctrl"
endterm="tvlmctrl" /> for available control commands.</para></listitem>

<listitem><para><command>save (config_file)</command> : Save all media
and schedule configurations in the specified config file. The config
file path is relative to the directory in which vlc was launched. If
the file exists it will be overwritten. Note that states, such as
playing, paused or stop, are not saved. See <xref linkend="vlmconf"
endterm="tvlmconf" /> for more info.</para></listitem>

<listitem><para><command>load (config_file)</command> : Load a
configuration file. The config file path is relative to the directory in
which vlc was launched. See <xref linkend="vlmconf" endterm="tvlmconf"/>
for more info.</para></listitem>

</itemizedlist>

</sect3>

<sect3 id="vlmprop"><title id="tvlmprop">Media Properties</title>

<note><para>Except the "append" property, all properties can be followed
by another one.</para></note>

<itemizedlist>

<listitem><para><command>input (input_name)</command> : Add an input to
the end of the media's input list.</para></listitem>

<listitem><para><command>output (output_name)</command> : Define the
media's output. The syntax is the same as the vlc ":sout=..." vlc
option but you do not have to put the ":sout=..." string. See <xref
linkend="cmdline" endterm="tcmdline" /> for more information concerning
stream outputs (sout).<note><para>You do not have to specify an output
for vod elements.</para></note></para></listitem>

<listitem><para><command>option (option_name)[=value]</command> : Adds
the (option_name) to the media option list. The syntax is equivalent
to the ":(option)=..." option , but you do not have to put the ":"
string. Options are global: they are applied to all inputs of the
media.</para></listitem>

<listitem><para><command>enabled|disabled</command> : Enable or Disable
the media. If a media is disabled, it cannot be streamed, paused,
launched by a schedule, or played as VoD.</para></listitem>

<listitem><para><command>loop|unloop (broadcast only)</command> : If
a media with the "loop" option receives the "play" command, it will
automatically restart to play the input list once the end of the input
list is reached. <note><para><command>loop|unloop</command> is only used
for broadcast media types.</para></note></para></listitem>

<listitem><para><command>mux (mux_name)</command> : This option
should only be specified if you want the elementary streams to
be sent encapsulated instead of raw. The (mux_name) should be
specified as a four characters length identifier such as mp2t for
MPEG TS or mp2p for MPEG PS. See <xref linkend="smc" endterm="tsmc"
/>.<note><para>The <command>mux</command> property is only used for vod
media types.</para></note></para></listitem>

</itemizedlist>

</sect3>

<sect3><title>Schedule Properties</title>

<itemizedlist>

<listitem><para><command>enabled|disabled</command> : A disabled
schedule will never be launched.</para></listitem>

<listitem><para><command>append
(command_until_rest_of_the_line)</command> : Add a command to the
command line lit. The command line can be every command VLM can
understand.<note><para>The rest of the line will be considered as
part of the command line. You cannot put another option after the
<command>append</command> one.</para></note></para></listitem>

<listitem><para><command>date
(year)/(month)/(day)-(hour):(minutes):(seconds)|now</command>
: Specify the first date the schedule should
be launched. You can specify a date using the
<command>(year)/(month)/(day)-(hour):(minutes):(seconds)</command>
format (example: 2004/11/16-00:43:12) or using the
<command>now</command> keyword. If <command>now</command> is used, the
schedule will be launched as soon as possible (i.e. as soon as it is
enabled) and the current date will be used as the first date of the
schedule.</para></listitem>

<listitem><para><command>period
(years_aka_12_months)/(months_aka_30_days)/(days)-(hours):(minutes):(sec
onds)</command> : Specify the period of time a schedule must wait
for launching itself another time. (Months are considered as 30
days, Years as 12 months) If a period is specified without a
<command>repeat</command> property, the schedule will be launched
endlessly.</para></listitem>

<listitem><para><command>repeat (number_of_repetitions)</command> :
Specify the number of times the schedule will be launched again. For
example, if a schedule has <command>repeat 11</command>, it will be
launched 12 times.</para></listitem>

</itemizedlist>

</sect3>

<sect3 id="vlmctrl"><title id="tvlmctrl">Control Commands</title>

<itemizedlist>

<listitem><para><command>play</command> : Stat a broadcast media. The
media begins to launch the first item of the input list, then launches
the next one and so on. (like a play list)</para></listitem>

<listitem><para><command>pause</command> : Put the broadcast media in
paused status.</para></listitem>

<listitem><para><command>stop</command> : Stop the broadcast
media.</para></listitem>

<listitem><para><command>seek (percentage)</command> : Seek in the
current playing item of the input list.</para></listitem>

</itemizedlist>

</sect3></sect2>

<sect2 id="vlmconf"><title id="tvlmconf">Configuration Files </title>

<para>A VLM configuration file is a list of command lines : one line
corresponds to one command line.</para>

<para>To create a configuration file, just edit a text file and type
a list of VLM commands. Beware of recursive calls: you an put a
<command>load (file)</command> in a configuration file which can lead to
recursive inclusion of the same file and result in VLC's crash.</para>

<para>As of versions > 0.8.1, any line where the first non white space
character is a # is considered as a comment.</para>

</sect2></sect1>

<sect1><title>Examples</title>

<para>This section provides several small vlm configuration files.</para>

<sect2><title>Multiple streaming</title>

<sect3><title>Simple broadcasting</title>

<programlisting>
new channel1 broadcast enabled
setup channel1 input http://host.mydomain/movie.mpeg
setup channel1 output #rtp{mux=ts,dst=239.255.1.1,port=5004,sdp=sap://,name="Channel 1"}

new channel2 broadcast enabled
setup channel2 input rtp://@239.255.12.42:1234
setup channel2 output #rtp{mux=ts,dst=239.255.1.2,port=5004,sdp=sap://,name="Channel 2"}

control channel1 play
control channel2 play
</programlisting>

</sect3>

<sect3><title>Scheduled broadcasting</title>

<programlisting>
new my_media broadcast enabled
setup my_media input my_video.mpeg input my_other_movie.mpeg
setup my_media output #rtp{mux=ts,dst=239.255.1.1,port=5004,sdp=sap://,name="My Media"}

new my_sched schedule enabled
setup my_sched date 2012/12/12-12:12:12
setup my_sched append control my_media play
</programlisting>

</sect3></sect2>

<sect2><title>Video On Demand</title>

<sect3><title>Basic example</title>

<para>First launch the vlc</para>
<screen><prompt>% </prompt><userinput>vlc --ttl 12 -vvv --color -I telnet --telnet-password videolan --rtsp-host 0.0.0.0:5554</userinput></screen>
<para>where:</para>
<itemizedlist>
<listitem><para><emphasis>12</emphasis>
 is the value of the TTL (Time To
Live) of your IP packets (which means that the stream will be
able to cross 11 routers).
</para></listitem>
<listitem><para><emphasis>telnet</emphasis>
 launches the telnet interface of the vlc.
</para></listitem>
<listitem><para><emphasis>videolan</emphasis>
 is the password to connect to the telnet interface.
</para></listitem>
<listitem><para><emphasis>0.0.0.0</emphasis>
 is the host address. 
</para></listitem>
<listitem><para><emphasis>5554</emphasis>
 is the port on which you stream.
</para></listitem>
</itemizedlist>

<para>Then you connect to the vlc telnet interface and create the vod object</para>
<programlisting>
new Test vod enabled
setup Test input my_video.mpg
</programlisting>
<para>You can access to the stream with:</para>
<screen>
<prompt>% </prompt><userinput>vlc rtsp://server:5554/Test</userinput>
</screen>
<para>where:</para>
<itemizedlist><listitem><para><emphasis>server</emphasis> is the address of the streaming server (IP or DNS)</para></listitem></itemizedlist>

</sect3>

</sect2>

</sect1>

</chapter>

