<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Multiparty Jingle (Muji)</title>
  <abstract>
    This specification defines an XMPP protocol extension for initiating and
    managing multiparty voice and video conferences within an XMPP MUC
  </abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0272</number>
  <status>Experimental</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0045</spec>
    <spec>XEP-0166</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>muji</shortname>
  <author>
    <firstname>Sjoerd</firstname>
    <surname>Simons</surname>
    <email>sjoerd.simons@collabora.co.uk</email>
    <jid>sjoerd.simons@collabora.co.uk</jid>
  </author>
  <author>
    <firstname>Dafydd</firstname>
    <surname>Harries</surname>
    <email>dafydd.harries@collabora.co.uk</email>
    <jid>dafydd.harries@collabora.co.uk</jid>
  </author>
  
  <author>
    <firstname>Marvin</firstname>
    <surname>Wißfeld</surname>
    <email>xmpp@larma.de</email>
    <jid>jabber@larma.de</jid>
  </author>

  <revision>
    <version>0.2.0</version>
    <date>2024-08-21</date>
    <initials>lmw</initials>
    <remark><ul>
      <li>Send Jingle IQs to real JID</li>
      <li>Define how to use with XEP-0482</li>
      <li>Adjust namespace</li>
    </ul></remark>
  </revision>
  <revision>
    <version>0.1.2</version>
    <date>2022-08-06</date>
    <initials>melvo</initials>
    <remark>Fix typos / grammar / examples and use 'Muji' instead of 'muji' consistently</remark>
  </revision>
  <revision>
    <version>0.1.1</version>
    <date>2018-11-03</date>
    <initials>pep</initials>
    <remark>Fix a bunch of typos, batch-style.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2009-09-11</date>
    <initials>psa</initials>
    <remark><p>Initial published version as accepted for publication by the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.0.2</version>
    <date>2009-06-09</date>
    <initials>sjoerd</initials>
    <remark><p>Second rough draft.</p></remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">
  <p>
    <span class="ref"><link url="https://xmpp.org/extensions/xep-0166.html">Jingle (XEP-0166)</link></span> <note>XEP-0166: Jingle &lt;<link url="https://xmpp.org/extensions/xep-0166.html">https://xmpp.org/extensions/xep-0166.html</link>&gt;.</note> is used to negotiate peer to peer media sessions.
    Muji (short for Multiparty Jingle) is a way to coordinate Jingle sessions
    between a group of people.
    Muji conferences are held in <span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> rooms.
  </p>
</section1>

<section1 topic="How it Works" anchor="howitworks">

  <p>
    A Muji conference has a number of contents, each of which has unique name,
    content type, and an encoding.
    Each participant may provide a stream for each content, and communicates
    which contents they are willing to provide streams for, along with encoding
    information, in their MUC presence.
    This serves two purposes. Firstly, so that each participant knows which
    contents every other participant provides.
    Secondly, so that there is a global payload type (PT) mapping for the
    various contents, so that clients only need to encode and payload each
    content that they provide once.
  </p>

  <p>
    Participants are not required to participate all the contents that are
    available.
    For example, a Muji client might choose to only request audio streams.
  </p>

</section1>

<section1 topic="Joining a Conference" anchor="joining">
  <p>
    Joining a conference is done in two stages. The first step is to
    declare that preparations are being done to either join or start a Muji
    session inside the MUC. This is indicated by the client sending a presence
    stanza to the MUC with a preparing element in the Muji section.
  </p>

  <code><![CDATA[
<presence from='wiccarocks@shakespeare.lit/laptop'
  to='darkcave@chat.shakespeare.lit/oldhag'>
  <c xmlns="http://jabber.org/protocol/caps"
    node="http://telepathy.freedesktop.org/wiki/Muji"
    ver="48QdBuXRCJFb8qIzgy1FOHSGO0U="
    hash="sha-1" />
  <muji xmlns='urn:xmpp:jingle:muji:0'>
    <preparing />
  </muji>
</presence>
]]></code>

  <p>
    The client MUST then wait until the MUC rebroadcasts its presence message,
    after which it MUST wait for all other participants that had a preparing
    element in their presence to finish preparation. Afterwards it should finish
    its own preparation by updating its presence with the contents it wants to
    take part in.
  </p>
  <code><![CDATA[
<presence from='wiccarocks@shakespeare.lit/laptop'
  to='darkcave@chat.shakespeare.lit/oldhag'>
  <c xmlns="http://jabber.org/protocol/caps"
    node="http://telepathy.freedesktop.org/wiki/Muji"
    ver="48QdBuXRCJFb8qIzgy1FOHSGO0U="
    hash="sha-1" />
  <muji xmlns='urn:xmpp:jingle:muji:0'>
    <content creator='initiator' name='video'>
      <description xmlns='urn:xmpp:jingle:apps:rtp:0' media='video'>
        <payload-type id='97' name='theora' clockrate='90000'/>
      </description>
    </content>
    <content creator='initiator' name='voice'>
      <description xmlns='urn:xmpp:jingle:apps:rtp:0' media='audio'>
        <payload-type id='97' name='speex' clockrate='8000'/>
        <payload-type id='18' name='G729'/>
      </description>
    </content>
  </muji>
</presence>
]]></code>

  <p>
  When a client adds a payload ID to a content description, it MUST have the
  same codec name and receiving parameters as the corresponding entries in
  other participants' payload maps for that content. For instance, if Alice
  defines a payload type with ID 98, codec Speex and a clock rate of 8000
  for a content called “voice0”, then Bob must define payload type 98
  identically or not at all for that content.
  </p>

  <p>
  Furthermore, each content description MUST include at least one payload type
  that every other participant supports. In other words, the intersection of
  payload type mappings in descriptions for a content must not be the empty
  set. This avoids clients having to encode the same stream multiple times,
  which can be very costly, and also allows sending the encoded data only once
  where the transport makes this possible (e.g. IP multicast).
  </p>

  <p>
  Once a client has constructed content descriptions and advertised them in
  its MUC presence, it MUST initiate a Jingle session with every other
  participant. The requirement that it is the joining participant that
  initiates sessions avoids race conditions.
  </p>

  <p>
    Jingle sessions are initiated between the real JIDs of participants, since IQ routing is not guaranteed to work in
    <span class="ref"><link url="https://xmpp.org/extensions/xep-0045.html">Multi-User Chat (XEP-0045)</link></span> <note>XEP-0045: Multi-User Chat &lt;<link url="https://xmpp.org/extensions/xep-0045.html">https://xmpp.org/extensions/xep-0045.html</link>&gt;.</note> and in <span class="ref"><link url="https://xmpp.org/extensions/xep-0369.html">Mediated Information eXchange (MIX) (XEP-0369)</link></span> <note>XEP-0369: Mediated Information eXchange (MIX) &lt;<link url="https://xmpp.org/extensions/xep-0369.html">https://xmpp.org/extensions/xep-0369.html</link>&gt;.</note>. To indicate that a Jingle session-initiate belongs to a MUJI conference, a &lt;muji&gt;
    element is placed in the &lt;jingle&gt; element. The receiver SHOULD only assume that a Jingle session-initiate
    belongs to a Muji conference if the sender is actually part of the referenced MUC. Content names inside Muji-related
    Jingle sessions always refer to the content with the same name inside the Muji conference.
  </p>

  <example caption="Jingle session-initiate referencing a Muji conference"><![CDATA[
<iq to='wiccarocks@shakespeare.lit/laptop' type='set' id='id1'>
  <jingle xmlns='urn:xmpp:jingle:1'
          action='session-initiate'
          initiator='hag66@shakespeare.lit/mobile'
          sid='sid1'>
    <muji room='darkcave@chat.shakespeare.lit' xmlns='urn:xmpp:jingle:muji:0' />
    <content creator='initiator' name='this-is-a-stub'>
      <description xmlns='urn:xmpp:jingle:apps:stub:0'/>
      <transport xmlns='urn:xmpp:jingle:transports:stub:0'/>
    </content>
  </jingle>
</iq>
]]></example>
</section1>

<section1 topic="Leaving a Conference" anchor="leaving">
  <p>
  To leave a conference the Muji information MUST first be removed from the
  participant's presence; subsequently it SHOULD terminate all Jingle sessions
  related to that conference. Updating the presence first reduces the
  likelihood of situations where new participants initiate sessions with
  participants who are leaving the conference.
  </p>
</section1>

<section1 topic="Adding a Content Type" anchor="addcontent">
  <p>
    Adding a stream follows a process similar to the joining of a conference. As a
    first step, an updated presence stanza MUST be sent which contains a
    preparing element as part of the Muji section.
  </p>

  <code><![CDATA[
    <presence from='wiccarocks@shakespeare.lit/laptop'
      to='darkcave@chat.shakespeare.lit/oldhag'>
      <c xmlns="http://jabber.org/protocol/caps"
        node="http://telepathy.freedesktop.org/wiki/Muji"
        ver="48QdBuXRCJFb8qIzgy1FOHSGO0U="
        hash="sha-1" />
      <muji xmlns='urn:xmpp:jingle:muji:0'>
        <content creator='initiator' name='voice'>
          <description xmlns='urn:xmpp:jingle:apps:rtp:0' media='audio'>
            <payload-type id='97' name='speex' clockrate='8000'/>
            <payload-type id='18' name='G729'/>
          </description>
        </content>
        <preparing/>
      </muji>
    </presence>
]]></code>

  <p>
    The client MUST then wait until the MUC rebroadcasts its presence message,
    after which it MUST wait for all other participants that had a preparing
    element in their presence to finish their changes.
  </p>

  <p>
    Afterwards the client should add the new content to the Muji section of its
    presence and add the content to all the Jingle sessions it had with
    participants it shared the content with.
  </p>

  <code><![CDATA[
    <presence from='wiccarocks@shakespeare.lit/laptop'
      to='darkcave@chat.shakespeare.lit/oldhag'>
      <c xmlns="http://jabber.org/protocol/caps"
        node="http://telepathy.freedesktop.org/wiki/Muji"
        ver="48QdBuXRCJFb8qIzgy1FOHSGO0U="
        hash="sha-1" />
      <muji xmlns='urn:xmpp:jingle:muji:0'>
        <content creator='initiator' name='video'>
          <description xmlns='urn:xmpp:jingle:apps:rtp:0' media='video'>
            <payload-type id='97' name='theora' clockrate='90000'/>
          </description>
        </content>
        <content creator='initiator' name='voice'>
          <description xmlns='urn:xmpp:jingle:apps:rtp:0' media='audio'>
            <payload-type id='97' name='speex' clockrate='8000'/>
            <payload-type id='18' name='G729'/>
          </description>
        </content>
      </muji>
    </presence>
]]></code>
</section1>

<section1 topic="Removing a Content Type" anchor="removecontent">
  <p>
  To remove a content type, the participant SHOULD first send an updated presence
  without the content in its Muji section. Afterwards, it MUST remove the content from
  all the Jingle sessions it has open.
  </p>
</section1>

<section1 topic="Relays and Mixers" anchor="relaysmixer">

  <p>
    When scaling to conferences with a big number of participants
    it's no longer viable for all participants to have direct
    connections.

    On connections where upstream bandwidth is the limiting factor, an RTP
    relay which is able to relay the stream to multiple participants on
    the behalf of the clients and which forwards the streams of other
    participants back to the client can be used.

    If the limiting factor is either CPU or downstream bandwidth then a mixer
    can be used, which receives the media streams from other participants and
    mixes them on behalf of the client, so that the client only has to deal
    with receiving and decoding a single stream for each media type. On the
    sending side a mixer acts like a relay and relays the clients stream to all
    other participants.

    Both these services can either be provided by dedicated services or by
    other clients.
  </p>
</section1>

<section1 topic="Call Invites">
  <p>
    To invite someone to a Muji conference, a <span class="ref"><link url="https://xmpp.org/extensions/xep-0482.html">Call Invites (XEP-0482)</link></span><note>XEP-0482: Call Invites &lt;<link url="https://xmpp.org/extensions/xep-0482.html">https://xmpp.org/extensions/xep-0482.html</link>&gt;.</note> &lt;invite&gt; is sent containing a &lt;muji&gt; element in the
    urn:xmpp:jingle:muji:0 namespace with a 'room' attribute specifying the JID of the Muji MUC.
  </p>
  <example caption="Invite to a MUJI conference"><![CDATA[
<message to='user@example.com' type='chat'>
  <invite xmlns='urn:xmpp:call-invites:0'>
    <muji xmlns='urn:xmpp:jingle:muji:0' room='room@conference.example.com' />
  </invite>
</message>>]]></example>
</section1>
</xep>
