<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-ietf-cellar-control-01" sortRefs="true" tocDepth="4" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="false" consensus="true">

<front>
<title abbrev="Matroska Control Track">Matroska Media Container Control Track Specifications</title><seriesInfo value="draft-ietf-cellar-control-01" stream="IETF" status="standard" name="Internet Draft"></seriesInfo>
<author initials="S." surname="Lhomme" fullname="Steve Lhomme"><organization></organization><address><postal><street></street>
</postal><email>slhomme@matroska.org</email>
</address></author><author initials="M." surname="Bunkus" fullname="Moritz Bunkus"><organization></organization><address><postal><street></street>
</postal><email>moritz@bunkus.org</email>
</address></author><author initials="D." surname="Rice" fullname="Dave Rice"><organization></organization><address><postal><street></street>
</postal><email>dave@dericed.com</email>
</address></author><date year="2022" month="May" day="1"></date>
<area>art</area>
<workgroup>cellar</workgroup>
<keyword>binary</keyword>
<keyword>storage</keyword>
<keyword>matroska</keyword>
<keyword>ebml</keyword>
<keyword>webm</keyword>
<keyword>codec</keyword>

<abstract>
<t>This document defines the Control Track usage found in the Matroska container.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
</section>

<section anchor="status-of-this-document"><name>Status of this document</name>
<t>This document is a work-in-progress specification defining the Matroska file format as part
of the <eref target="https://datatracker.ietf.org/wg/cellar/charter/">IETF Cellar working group</eref>.
It uses basic elements and concept already defined in the Matroska specifications defined by this workgroup.</t>
</section>

<section anchor="security-considerations"><name>Security Considerations</name>
<t>This document inherits security considerations from the EBML and Matroska documents.</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>
<t>To be determined.</t>
</section>

<section anchor="notation-and-conventions"><name>Notation and Conventions</name>
<t>The key words &quot;<bcp14>MUST</bcp14>&quot;, &quot;<bcp14>MUST NOT</bcp14>&quot;,
&quot;<bcp14>REQUIRED</bcp14>&quot;, &quot;<bcp14>SHALL</bcp14>&quot;, &quot;<bcp14>SHALL NOT</bcp14>&quot;,
&quot;<bcp14>SHOULD</bcp14>&quot;, &quot;<bcp14>SHOULD NOT</bcp14>&quot;,
&quot;<bcp14>RECOMMENDED</bcp14>&quot;, &quot;<bcp14>NOT RECOMMENDED</bcp14>&quot;,
&quot;<bcp14>MAY</bcp14>&quot;, and &quot;<bcp14>OPTIONAL</bcp14>&quot; in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref>
when, and only when, they appear in all capitals, as shown here.</t>
</section>

<section anchor="edition-flags"><name>Edition Flags</name>

<section anchor="editionflaghidden"><name>EditionFlagHidden</name>
<t>When the <tt>EditionFlagHidden</tt> flag is set to <tt>false</tt> it means the <tt>Edition</tt> is visible and selectable
in a <tt>Matroska Player</tt>.
All <tt>ChapterAtoms Elements</tt> <bcp14>MUST</bcp14> be interpreted with their own <tt>ChapterFlagHidden</tt> flags.</t>
<table anchor="chapterVisibility"><name>ChapterAtom visibility to the user</name>
<thead>
<tr>
<th align="left">ChapterFlagHidden</th>
<th align="left">False</th>
<th align="left">True</th>
<th align="left">visible</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Chapter 1</td>
<td align="left">X</td>
<td align="left"></td>
<td align="left">yes</td>
</tr>

<tr>
<td align="left">Chapter 2</td>
<td align="left"></td>
<td align="left">X</td>
<td align="left">no</td>
</tr>
</tbody>
</table><t>When the <tt>EditionFlagHidden</tt> flag is set to <tt>true</tt> the <tt>Edition</tt> is hidden and <bcp14>SHOULD NOT</bcp14> be
selectable in a <tt>Matroska Player</tt>.
If all <tt>Editions</tt> <tt>EditionFlagHidden</tt> flags are set to <tt>true</tt>, there is no visible <tt>Edition</tt>.
In this case all <tt>ChapterAtoms Elements</tt> <bcp14>MUST</bcp14> also be interpreted as if their <tt>ChapterFlagHidden</tt>
flag is also set to <tt>true</tt>, regardless with their own <tt>ChapterFlagHidden</tt> flags.</t>
<table anchor="chapterVisibilityHidden"><name>ChapterAtom visibility in hidden editions</name>
<thead>
<tr>
<th align="left">ChapterFlagHidden</th>
<th align="left">False</th>
<th align="left">True</th>
<th align="left">visible</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Chapter 1</td>
<td align="left">X</td>
<td align="left"></td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">Chapter 2</td>
<td align="left"></td>
<td align="left">X</td>
<td align="left">no</td>
</tr>
</tbody>
</table></section>

<section anchor="editionflagdefault"><name>EditionFlagDefault</name>
<t>It is <bcp14>RECOMMENDED</bcp14> that no more than one <tt>Edition</tt> have an <tt>EditionFlagDefault Flag</tt>
set to <tt>true</tt>. The first <tt>Edition</tt> with both the <tt>EditionFlagDefault Flag</tt> set to <tt>true</tt>
and the <tt>EditionFlagHidden Flag</tt> set to <tt>false</tt> is the Default Edition. When all
<tt>EditionFlagDefault Flags</tt> are set to <tt>false</tt>, then the first <tt>Edition</tt> with the
<tt>EditionFlagHidden Flag</tt> set to <tt>false</tt> is the Default Edition. The Default Edition
is the edition that should be used for playback by default.</t>
</section>

<section anchor="default-edition"><name>Default Edition</name>
<t>The <tt>Default Edition</tt> is the <tt>Edition</tt> that a <tt>Matroska Player</tt> <bcp14>SHOULD</bcp14> use for playback by default.</t>
<t>The first <tt>Edition</tt> with both the <tt>EditionFlagDefault</tt> flag set to <tt>true</tt> and the <tt>EditionFlagHidden</tt>
flag set to <tt>false</tt> is the <tt>Default Edition</tt>.
When all <tt>EditionFlagDefault</tt> flags are set to <tt>false</tt> and all <tt>EditionFlagHidden</tt> flag set to <tt>true</tt>,
then the first <tt>Edition</tt> is the <tt>Default Edition</tt>.
When all <tt>EditionFlagHidden</tt> flags are set to <tt>true</tt>, then the first <tt>Edition</tt> with the
<tt>EditionFlagDefault</tt> flag set to <tt>true</tt> is the <tt>Default Edition</tt>.
When all <tt>EditionFlagDefault</tt> flags are set to <tt>false</tt>, then the first <tt>Edition</tt> with the
<tt>EditionFlagHidden</tt> flag set to <tt>false</tt> is the <tt>Default Edition</tt>.
When there is no <tt>Edition</tt> with a <tt>EditionFlagDefault</tt> flag are set to <tt>true</tt> and a
<tt>EditionFlagHidden</tt> flags are set to <tt>false</tt>, then the first <tt>Edition</tt> with the <tt>EditionFlagHidden</tt>
flag set to <tt>false</tt> is the <tt>Default Edition</tt>.</t>
<t>In other words, in case the <tt>Default Edition</tt> is not obvious, the first <tt>Edition</tt> with a
<tt>EditionFlagHidden</tt> flag set to <tt>false</tt> <bcp14>SHOULD</bcp14> be preferred.</t>
<table anchor="defaultEditionSomeVisibleAllDefault"><name>Default edition, some visible, all default</name>
<thead>
<tr>
<th align="left">Edition</th>
<th align="left">FlagHidden</th>
<th align="left">FlagDefault</th>
<th align="left">Default Edition</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Edition 1</td>
<td align="left">true</td>
<td align="left">true</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 2</td>
<td align="left">true</td>
<td align="left">true</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 3</td>
<td align="left">false</td>
<td align="left">true</td>
<td align="left">X</td>
</tr>
</tbody>
</table><table anchor="defaultEditionAllHiddenNoDefault"><name>Default edition, all hidden, no default</name>
<thead>
<tr>
<th align="left">Edition</th>
<th align="left">FlagHidden</th>
<th align="left">FlagDefault</th>
<th align="left">Default Edition</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Edition 1</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left">X</td>
</tr>

<tr>
<td align="left">Edition 2</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 3</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>
</tbody>
</table><table anchor="defaultEditionAllHiddenWithDefault"><name>Default edition, all hidden, with default</name>
<thead>
<tr>
<th align="left">Edition</th>
<th align="left">FlagHidden</th>
<th align="left">FlagDefault</th>
<th align="left">Default Edition</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Edition 1</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 2</td>
<td align="left">true</td>
<td align="left">true</td>
<td align="left">X</td>
</tr>

<tr>
<td align="left">Edition 3</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>
</tbody>
</table><table anchor="defaultEditionSomeVisibleNoDefault"><name>Default edition, some visible, no default</name>
<thead>
<tr>
<th align="left">Edition</th>
<th align="left">FlagHidden</th>
<th align="left">FlagDefault</th>
<th align="left">Default Edition</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Edition 1</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 2</td>
<td align="left">false</td>
<td align="left">false</td>
<td align="left">X</td>
</tr>

<tr>
<td align="left">Edition 3</td>
<td align="left">false</td>
<td align="left">false</td>
<td align="left"></td>
</tr>
</tbody>
</table><table anchor="defaultEditionSomeVisibleSomeDefault"><name>Default edition, some visible, some default</name>
<thead>
<tr>
<th align="left">Edition</th>
<th align="left">FlagHidden</th>
<th align="left">FlagDefault</th>
<th align="left">Default Edition</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Edition 1</td>
<td align="left">true</td>
<td align="left">false</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 2</td>
<td align="left">true</td>
<td align="left">true</td>
<td align="left"></td>
</tr>

<tr>
<td align="left">Edition 3</td>
<td align="left">false</td>
<td align="left">false</td>
<td align="left">X</td>
</tr>
</tbody>
</table></section>
</section>

<section anchor="chapter-flags"><name>Chapter Flags</name>
<t>If a <tt>Control Track</tt> toggles the parent's <tt>ChapterFlagHidden</tt>
flag to <tt>false</tt>, then only the parent <tt>ChapterAtom</tt> and its second child <tt>ChapterAtom</tt>
<bcp14>MUST</bcp14> be interpreted as if <tt>ChapterFlagHidden</tt> is set to <tt>false</tt>. The first child
<tt>ChapterAtom</tt>, which has the <tt>ChapterFlagHidden</tt> flag set to <tt>true</tt>, retains its value
until its value is toggled to <tt>false</tt> by a <tt>Control Track</tt>.</t>
<t>The <tt>ChapterFlagEnabled</tt> value can be toggled by control tracks.</t>

<section anchor="chapterflagenabled"><name>ChapterFlagEnabled</name>
<t>If the <tt>ChapterFlagEnabled</tt> flag is set to <tt>false</tt> a <tt>Matroska Player</tt> <bcp14>MUST NOT</bcp14> use this
<tt>Chapter</tt> and all his <tt>Nested Chapters</tt>.
For <tt>Simple Chapters</tt>, a <tt>Matroska Player</tt> <bcp14>MAY</bcp14> display this enabled <tt>Chapter</tt> with a marker in
the timeline.
For <tt>Ordered Chapters</tt> a <tt>Matroska Player</tt> <bcp14>MUST</bcp14> use the duration of this enabled <tt>Chapter</tt>.</t>
<table>
<thead>
<tr>
<th align="left">Chapter + Nested Chapter</th>
<th align="left">ChapterFlagEnabled</th>
<th align="left">used</th>
</tr>
</thead>

<tbody>
<tr>
<td align="left">Chapter 1</td>
<td align="left">true</td>
<td align="left">yes</td>
</tr>

<tr>
<td align="left">+Nested Chapter 1.1</td>
<td align="left">true</td>
<td align="left">yes</td>
</tr>

<tr>
<td align="left">+Nested Chapter 1.2</td>
<td align="left">false</td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">++Nested Chapter 1.2.1</td>
<td align="left">true</td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">++Nested Chapter 1.2.2</td>
<td align="left">false</td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">Chapter 2</td>
<td align="left">false</td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">+Nested Chapter 2.1</td>
<td align="left">true</td>
<td align="left">no</td>
</tr>

<tr>
<td align="left">+Nested Chapter 2.2</td>
<td align="left">true</td>
<td align="left">no</td>
</tr>
</tbody>
</table></section>
</section>

<section anchor="matroska-schema"><name>Matroska Schema</name>
<t>Extra elements used to handle Control Tracks and advanced selection features:</t>

<section anchor="segment"><name>Segment</name>

<section anchor="chapters"><name>Chapters</name>

<section anchor="editionentry"><name>EditionEntry</name>

<section anchor="editionflaghidden-element"><name>EditionFlagHidden Element</name>

<dl>
<dt>name:</dt>
<dd>EditionFlagHidden</dd>
<dt>path:</dt>
<dd><tt>\Segment\Chapters\EditionEntry\EditionFlagHidden</tt></dd>
<dt>id:</dt>
<dd>0x45BD</dd>
<dt>minOccurs:</dt>
<dd>1</dd>
<dt>maxOccurs:</dt>
<dd>1</dd>
<dt>range:</dt>
<dd>0-1</dd>
<dt>default:</dt>
<dd>0</dd>
<dt>type:</dt>
<dd>uinteger</dd>
<dt>definition:</dt>
<dd>Set to 1 if an edition is hidden. Hidden editions <bcp14>SHOULD NOT</bcp14> be available to the user interface
(but still to Control Tracks; see <xref target="chapter-flags"></xref> on Chapter flags).</dd>
</dl>

<section anchor="chapterflagenabled-element"><name>ChapterFlagEnabled Element</name>

<dl>
<dt>name:</dt>
<dd>ChapterFlagEnabled</dd>
<dt>path:</dt>
<dd><tt>\Segment\Chapters\EditionEntry\+ChapterAtom\ChapterFlagEnabled</tt></dd>
<dt>id:</dt>
<dd>0x4598</dd>
<dt>minOccurs:</dt>
<dd>1</dd>
<dt>maxOccurs:</dt>
<dd>1</dd>
<dt>range:</dt>
<dd>0-1</dd>
<dt>default:</dt>
<dd>1</dd>
<dt>type:</dt>
<dd>uinteger</dd>
<dt>definition:</dt>
<dd>Set to 1 if the chapter is enabled. It can be enabled/disabled by a Control Track.
When disabled, the movie <bcp14>SHOULD</bcp14> skip all the content between the TimeStart and TimeEnd of this chapter; see <xref target="chapter-flags"></xref> on Chapter flags.</dd>
</dl>
</section>

<section anchor="chaptertrack-element"><name>ChapterTrack Element</name>

<dl>
<dt>name:</dt>
<dd>ChapterTrack</dd>
<dt>path:</dt>
<dd><tt>\Segment\Chapters\EditionEntry\+ChapterAtom\ChapterTrack</tt></dd>
<dt>id:</dt>
<dd>0x8F</dd>
<dt>maxOccurs:</dt>
<dd>1</dd>
<dt>type:</dt>
<dd>master</dd>
<dt>definition:</dt>
<dd>List of tracks on which the chapter applies. If this Element is not present, all tracks apply</dd>
</dl>
</section>

<section anchor="chaptertrackuid-element"><name>ChapterTrackUID Element</name>

<dl>
<dt>name:</dt>
<dd>ChapterTrackUID</dd>
<dt>path:</dt>
<dd><tt>\Segment\Chapters\EditionEntry\+ChapterAtom\ChapterTrack\ChapterTrackUID</tt></dd>
<dt>id:</dt>
<dd>0x89</dd>
<dt>minOccurs:</dt>
<dd>1</dd>
<dt>range:</dt>
<dd>not 0</dd>
<dt>type:</dt>
<dd>uinteger</dd>
<dt>definition:</dt>
<dd>UID of the Track to apply this chapter to.
In the absence of a control track, choosing this chapter will select the listed Tracks and deselect unlisted tracks.
Absence of this Element indicates that the Chapter <bcp14>SHOULD</bcp14> be applied to any currently used Tracks.</dd>
</dl>
</section>
</section>
</section>
</section>
</section>
</section>

<section anchor="menu-specifications"><name>Menu Specifications</name>
<t>This document is a <em>draft of the Menu system</em> that will be the default one in <tt>Matroska</tt>.
As it will just be composed of a Control Track, it will be seen as a &quot;codec&quot; and could be
replaced later by something else if needed.</t>
<t>A menu is like what you see on DVDs, when you have some screens to select the audio format,
subtitles or scene selection.</t>

<section anchor="requirements"><name>Requirements</name>
<t>What we'll try to have is a system that can do almost everything done on a DVD, or more,
or better, or drop the unused features if necessary.</t>
<t>As the name suggests, a Control Track is a track that can control the playback of the file
and/or all the playback features. To make it as simple as possible for <tt>Matroska Players</tt>,
the Control Track will just give orders to the <tt>Matroska Player</tt> and get the actions
associated with the highlights/hotspots.</t>

<section anchor="highlights-hotspots"><name>Highlights/Hotspots</name>
<t>A highlight is basically a rectangle/key associated with an action UID. When that
rectangle/key is activated, the <tt>Matroska Player</tt> send the UID of the action to the
Control Track handler (codec). The fact that it can also be a key means that even for
audio only files, a keyboard shortcut or button panel could be used for menus.
But in that case, the hotspot will have to be associated with a name to display.</t>
<t>This highlight is sent from the Control Track to the <tt>Matroska Player</tt>. Then the
<tt>Matroska Player</tt> has to handle that highlight until it's deactivated; see <xref target="playback-features"></xref>.</t>
<t>The highlight contains a UID of the action, a displayable name (UTF-8), an associated
key (list of keys to be defined, probably up/down/left/right/select), a screen position/range
and an image to display. The image will be displayed either when the user place
the mouse over the rectangle (or any other shape), or when an option of the screen
is selected (not activated). There could be a second image used when the option is activated.
And there could be a third image that can serve as background. This way you could have
a still image (like in some DVDs) for the menu and behind that image blank video (small bitrate).</t>
<t>When a highlight is activated by the user, the <tt>Matroska Player</tt> has to send the UID of
the action to the Control Track. Then the Control Track codec will handle the action
and possibly give new orders to the <tt>Matroska Player</tt>.</t>
<t>The format used for storing images <bcp14>SHOULD</bcp14> be extensible. For the moment we'll use
PNG and BMP, both with alpha channel.</t>
</section>

<section anchor="playback-features"><name>Playback features</name>
<t>All the following features will be sent from the Control Track to the <tt>Matroska Player</tt> :</t>

<ul>
<li>Jump to chapter (UID, prev, next, number)</li>
<li>Disable all tracks of a kind (audio, video, subtitle)</li>
<li>Enable track UID (the kind doesn't matter)</li>
<li>Define/Disable a highlight</li>
<li>Enable/Disable jumping</li>
<li>Enable/Disable track selection of a kind</li>
<li>Select Edition ID (see chapters)</li>
<li>Pause playback</li>
<li>Stop playback</li>
<li>Enable/Disable a Chapter UID</li>
<li>Hide/Unhide a Chapter UID</li>
</ul>
<t>All the actions will be written in a normal Matroska track, with a timestamp.
A &quot;Menu Frame&quot; <bcp14>SHOULD</bcp14> be able to contain more that one action/highlight for a given
timestamp. (to be determined, EBML format structure)</t>
</section>

<section anchor="player-requirements"><name>Player requirements</name>
<t>Some <tt>Matroska Players</tt> might not support the control track. That mean they will play
the active/looped parts as part of the data. So I suggest putting the active/looped
parts of a movie at the end of a movie. When a Menu-aware <tt>Matroska Player</tt> encounter
the default Control Track of a <tt>Matroska</tt> file, the first order <bcp14>SHOULD</bcp14> be to jump at
the start of the active/looped part of the movie.</t>
</section>
</section>

<section anchor="working-graph"><name>Working Graph</name>

<artwork>Matroska Source file -&gt; Control Track &lt;-&gt; Player.
                     -&gt; other tracks   -&gt; rendered
</artwork>
</section>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
</references>

</back>

</rfc>
