-
Notifications
You must be signed in to change notification settings - Fork 415
MSC4143: MatrixRTC #4143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
toger5
wants to merge
24
commits into
main
Choose a base branch
from
toger5/matrixRTC
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,170
−0
Open
MSC4143: MatrixRTC #4143
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9cbe448
draft
toger5 b2b4e5e
lowercase filename
toger5 8c1340a
add note about this relying on MSC3757
toger5 8c800a6
remove the m.prefix from fields.
toger5 1dcbfce
update
toger5 813a21a
add foci_preferred well known section
toger5 d65e42e
update to reference to msc [MSC4158](https://github.com/matrix-org/ma…
toger5 4ab679a
add a "Reliability requirements for the room state" section
toger5 6d84256
use current state key format
toger5 d68e942
add `expires_after`
toger5 3b19b49
add section about send order (delayed leave event -> join event)
toger5 a278ff8
language fixes
ara4n f97e4e6
clarify that non-empty delayed membership events are invalid
ara4n b626d51
Latest
hughns ec9fa8b
json5 for legibility
hughns 50db42a
be more specific on `member.id`
toger5 9bc444c
add id to session
toger5 33231dc
calrify that the state key cannot be used as the source of truth for …
toger5 cea4cdd
Update proposals/4143-matrix-rtc.md
toger5 d61969a
clarify what is part of this MSC and what can be found in other MSC's
toger5 4ad3961
major rewrite addressing a lot of feedback from offline discussions.
fkwp 1fbd843
json5 code block formats
toger5 60e23d9
add unstable m.rtc.slot prefix.
toger5 680ef7d
fix grammar & link the MSC
ara4n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| # MSC4143: MatrixRTC | ||
|
|
||
| This MSC defines the modules with which the matrix real time system is build with. | ||
|
|
||
| The MatrixRTC specification is separated into different modules. | ||
|
|
||
| - The MatrixRTC room state that defines the state of the real time application.\ | ||
| It is the source of truth for: | ||
| - Who is part of a session | ||
| - Who is connected via what technology/backend | ||
| - Metadata per device used by other participants to decide whether the streams | ||
| from this source are of interest / need to be subscribed. | ||
| - The RTC backend. | ||
| - It defines how to connect the participating peers. | ||
| - Livekit is the standard for this as of writing. | ||
| - Defines how to connect to a server/other peers, how to update the connection, | ||
| how to subscribe to different streams... | ||
| - Another planned backend is a full mesh implementation based on MSC3401. | ||
| - The RTCSession types (application) have their own per application spec. | ||
| - Calls can be done with an application of type `m.call` see (TODO: link call msc) | ||
| - The application defines all the details of the RTC experience: | ||
| - How to interpret the metadata of the member events. | ||
| - What streams to connect to. | ||
| - What data in which format to sent over the RTC channels. | ||
|
|
||
| This MSC will focus on the matrix room state which can be seen as the most high | ||
| level signalling of a call: | ||
|
|
||
| ## Proposal | ||
|
|
||
| Each RTC session is made out of a collection of `m.rtc.member` events. | ||
| Each `m.rtc.member` event defines the application type: `application` | ||
| and a `call_id`. And is stored in a state event of type `m.rtc.member`. | ||
| The first element of the state key is the `userId` and the second the `deviceId`. | ||
| (see [this proposal for state keys](https://github.com/matrix-org/matrix-spec-proposals/pull/3757#issuecomment-2099010555) | ||
| for context about second/first state key.) | ||
|
|
||
| ### The MatrixRTC room state | ||
|
|
||
| Everything required for working MatrixRTC | ||
| (current session, sessions history, join/leave events, ...) only | ||
| require one event type. | ||
|
|
||
| A complete `m.rtc.member` state event looks like this: | ||
|
|
||
| ```json | ||
| // event type: m.rtc.member | ||
| // event key: ["@user:matrix.domain", "DEVICEID"] | ||
| { | ||
| "m.application": "m.my_session_type", | ||
| "m.call_id": "", | ||
| "focus_active": {...FOCUS_A}, | ||
| "foci_preferred": [ | ||
| {...FOCUS_1}, | ||
| {...FOCUS_2} | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| giving us the information, that user: `@user:matrix.domain` with device `DEVICEID` | ||
| is part of an RTCSession of type `m.call` in the scope/sub-session `""` (empty | ||
| string as call id) connected over `FOCUS_A`. This is all information that is needed | ||
| for another room member to detect the running session and join it. | ||
|
|
||
| There is **no event** to represent a session. This event would include shared | ||
| information where it is not trivial to decide who has authority over it. | ||
| Instead the session is a computed value based on `m.rtc.member` events. | ||
| The list of events with the same `m.application` and `m.call_id` represent one session. | ||
| This array allows to compute fields like participant count, start time ... | ||
|
|
||
| Sending an empty `m.rtc.member` event represents a leave action. | ||
| Sending a well formatted `m.rtc.member` represents a join action. | ||
|
|
||
| Based on the value of `m.application`, the event might include additional parameters | ||
| required to provide additional session parameters. | ||
|
|
||
| > A thirdRoom like experience could include the information of an approximate position | ||
| on the map, so that clients can omit connecting to participants that are not in their | ||
| area of interest. | ||
|
|
||
| #### Historic sessions | ||
|
|
||
| Since there is no singe entry for a historic session (because of the owner ship discussion), | ||
| historic sessions need to be computed and most likely cached on the client. | ||
|
|
||
| Each state event can either mark a join or leave: | ||
|
|
||
| - join: `prev_state.m.application != current_state.m.application` && | ||
| `prev_state.m.call_id != current_state.m.call_id` && | ||
| `current_state.m.application != undefined` | ||
| (where an empty `m.rtc.member` event would imply `state.m.application == undefined`) | ||
| - leave: `prev_state.m.application != current_state.m.application` && | ||
| `prev_state.m.call_id != current_state.m.call_id` && | ||
| `current_state.m.application == undefined` | ||
|
|
||
| Based on this one can find user sessions. (The range between a join and a leave | ||
| event) of specific times. | ||
| The collection of all overlapping user sessions with the same `call_id` and | ||
| `application` define one MatrixRTC history event. | ||
|
|
||
| ### The RTC backend | ||
|
|
||
| `foci_active` and `foci_preferred` are used to communicate | ||
|
|
||
| - how a user is connected to the session (`foci_active`) | ||
| - what connection method this user knows about would like to connect with. | ||
|
|
||
| The only enforced parameter of a `foci_preferred` or `foci_active` is `type`. | ||
| Based on the focus type a different amount of parameters might be needed to, | ||
| communicate how to connect to other users. | ||
| `foci_preferred` and `foci_active` can have different parameters so that it is, | ||
| possible to use a combination of the two to figure our that everyone is connected | ||
| with each other. | ||
|
|
||
| Only users with the same type can connect in one session. If a frontend does | ||
| not support the used type they cannot connect. | ||
|
|
||
| Each focus type will get its own MSC in which the detailed procedure to get from | ||
| the foci information to working webRTC connections to the streams of all the | ||
| participants is explained. | ||
|
|
||
| - [`livekit`](www.example.com) TODO: create `livekit` focus MSC and add link here. | ||
| - [`full_mesh`](https://github.com/matrix-org/matrix-spec-proposals/pull/3401) | ||
| TODO: create `full-mesh` focus MSC based on[MSC3401](https://github.com/matrix-org/matrix-spec-proposals/pull/3401) | ||
| and add link here. | ||
|
|
||
| ### The RTCSession types (application) | ||
|
|
||
| Each session type might have its own specification in how the different streams | ||
| are interpreted and even what focus type to use. This makes this proposal extremely | ||
| flexible. A Jitsi conference could be added by introducing a new `m.application` | ||
| and a new focus type and would be MatrixRTC compatible. It would not be compatible | ||
| with applications that do not use the Jitsi focus but clients would know that there | ||
| is an ongoing session of unknown type and unknown focus and could display/represent | ||
| this in the user interface. | ||
|
|
||
| To make it easy for clients to support different RTC session types, the recommended | ||
| approach is to provide a matrix widget for each session type, so that client developers | ||
| can use the widget as the first implementation if they want to support this RTC | ||
| session type. | ||
|
|
||
| Each application should get its own MSC in which the all the additional | ||
| fields are explained and how the communication with the possible foci is | ||
| defined: | ||
|
|
||
| - [`m.call`](www.example.com) TODO: create `m.call` MSC and add link here. | ||
|
|
||
| ## Potential issues | ||
| ## Alternatives | ||
| ## Security considerations |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.