blob: f1d664570d816cf1fb470bcc807c0c9fc60ba856 [file] [log] [blame]
Alex Perry5f474f22020-02-01 12:14:24 -08001// Typescript namespaces are weird when coming from multiple files. We generate
2// all transitive dependencies into the same file in typescript so we can
3// include all 'aos' flatbuffers we care about here.
4include "aos/configuration.fbs";
5include "aos/network/connect.fbs";
6
Alex Perryb3b50792020-01-18 16:13:45 -08007namespace aos.web_proxy;
8
9// SDP is Session Description Protocol. We only handle OFFER (starting a
10// transaction) and ANSWER responding to an offer.
11enum SdpType : byte {
12 OFFER,
13 ANSWER
14}
15
16// The SDP payload is an opaque string that describes what (media/data) we
17// want to transmit.
18table WebSocketSdp {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080019 type:SdpType (id: 0);
20 payload:string (id: 1);
Alex Perryb3b50792020-01-18 16:13:45 -080021}
22
23// ICE is way for different peers to learn how to connect to each other.
24// Because we will only be running in a local network, we don't have to support
25// advaced features.
26table WebSocketIce {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080027 candidate:string (id: 0);
Brian Silverman225c5072021-11-17 19:56:31 -080028 sdp_mid:string (id: 1);
29 sdp_m_line_index:int (id: 2);
Alex Perryb3b50792020-01-18 16:13:45 -080030}
31
32union Payload {WebSocketSdp, WebSocketIce}
33
34// We only send a single type of message on the websocket to simplify parsing.
35table WebSocketMessage {
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080036 payload:Payload (id: 1);
Alex Perryb3b50792020-01-18 16:13:45 -080037}
Alex Perry5f474f22020-02-01 12:14:24 -080038
39// WebRTC has size limits on the messages sent on datachannels. This message
40// ensures that parts are recieved in the correct order. If there is any
41// mismatch, all the existing work should be dropped and restart when reasonable
42// data starts again.
43table MessageHeader {
44 // Index of the channel in config
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080045 channel_index:uint (id: 0);
Alex Perry5f474f22020-02-01 12:14:24 -080046
47 // How many packets will be required for the message being sent.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080048 packet_count:uint (id: 1);
Alex Perry5f474f22020-02-01 12:14:24 -080049 // What index into the the total packets for the multipart message, this
50 // header is parts of.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080051 packet_index:uint (id: 2);
Alex Perry5f474f22020-02-01 12:14:24 -080052
53 // Total number of bytes in the message
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080054 length:uint (id: 3);
Alex Perry5f474f22020-02-01 12:14:24 -080055
56 // Index into the sequence of messages. This will not always increase.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080057 queue_index:uint (id: 4);
Alex Perry5f474f22020-02-01 12:14:24 -080058
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080059 data:[ubyte] (id: 5);
James Kuszmaul48413bf2020-09-01 19:19:05 -070060
61 // Time at which the message was sent, in nanoseconds.
Ravago Jonesfb6a7a52020-11-14 13:47:46 -080062 monotonic_sent_time:long (id: 6);
Alex Perry5f474f22020-02-01 12:14:24 -080063}
James Kuszmaul71a81932020-12-15 21:08:01 -080064
65enum TransferMethod : byte {
66 SUBSAMPLE,
James Kuszmaul1a29c082022-02-03 14:02:47 -080067 LOSSLESS,
James Kuszmaul71a81932020-12-15 21:08:01 -080068}
69
70table ChannelRequest {
71 channel:Channel (id: 0);
72 method:TransferMethod (id: 1);
73}
74
James Kuszmaula5822682021-12-23 18:39:28 -080075// This is used to communicate the most recently received message by the client.
76// This allows the server to avoid overloading the client (which we've had
77// issues with in the past).
78table ChannelState {
79 // queue_index and packet_index correspond to the similarly named fields in
80 // MessageHeader.
81 queue_index:uint (id: 0);
82 packet_index:uint (id: 1);
83}
84
James Kuszmaul71a81932020-12-15 21:08:01 -080085table SubscriberRequest {
86 // The channels that we want transfered to this client.
87 channels_to_transfer:[ChannelRequest] (id: 0);
88}