Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 1 | // 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. |
| 4 | include "aos/configuration.fbs"; |
| 5 | include "aos/network/connect.fbs"; |
| 6 | |
Alex Perry | b3b5079 | 2020-01-18 16:13:45 -0800 | [diff] [blame] | 7 | namespace aos.web_proxy; |
| 8 | |
| 9 | // SDP is Session Description Protocol. We only handle OFFER (starting a |
| 10 | // transaction) and ANSWER responding to an offer. |
| 11 | enum 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. |
| 18 | table WebSocketSdp { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 19 | type:SdpType (id: 0); |
| 20 | payload:string (id: 1); |
Alex Perry | b3b5079 | 2020-01-18 16:13:45 -0800 | [diff] [blame] | 21 | } |
| 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. |
| 26 | table WebSocketIce { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 27 | candidate:string (id: 0); |
Brian Silverman | 225c507 | 2021-11-17 19:56:31 -0800 | [diff] [blame] | 28 | sdp_mid:string (id: 1); |
| 29 | sdp_m_line_index:int (id: 2); |
Alex Perry | b3b5079 | 2020-01-18 16:13:45 -0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | union Payload {WebSocketSdp, WebSocketIce} |
| 33 | |
| 34 | // We only send a single type of message on the websocket to simplify parsing. |
| 35 | table WebSocketMessage { |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 36 | payload:Payload (id: 1); |
Alex Perry | b3b5079 | 2020-01-18 16:13:45 -0800 | [diff] [blame] | 37 | } |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 38 | |
| 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. |
| 43 | table MessageHeader { |
| 44 | // Index of the channel in config |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 45 | channel_index:uint (id: 0); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 46 | |
| 47 | // How many packets will be required for the message being sent. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 48 | packet_count:uint (id: 1); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 49 | // What index into the the total packets for the multipart message, this |
| 50 | // header is parts of. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 51 | packet_index:uint (id: 2); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 52 | |
| 53 | // Total number of bytes in the message |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 54 | length:uint (id: 3); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 55 | |
| 56 | // Index into the sequence of messages. This will not always increase. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 57 | queue_index:uint (id: 4); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 58 | |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 59 | data:[ubyte] (id: 5); |
James Kuszmaul | 48413bf | 2020-09-01 19:19:05 -0700 | [diff] [blame] | 60 | |
| 61 | // Time at which the message was sent, in nanoseconds. |
Ravago Jones | fb6a7a5 | 2020-11-14 13:47:46 -0800 | [diff] [blame] | 62 | monotonic_sent_time:long (id: 6); |
Alex Perry | 5f474f2 | 2020-02-01 12:14:24 -0800 | [diff] [blame] | 63 | } |
James Kuszmaul | 71a8193 | 2020-12-15 21:08:01 -0800 | [diff] [blame] | 64 | |
| 65 | enum TransferMethod : byte { |
| 66 | SUBSAMPLE, |
James Kuszmaul | 1a29c08 | 2022-02-03 14:02:47 -0800 | [diff] [blame] | 67 | LOSSLESS, |
James Kuszmaul | 71a8193 | 2020-12-15 21:08:01 -0800 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | table ChannelRequest { |
| 71 | channel:Channel (id: 0); |
| 72 | method:TransferMethod (id: 1); |
| 73 | } |
| 74 | |
James Kuszmaul | a582268 | 2021-12-23 18:39:28 -0800 | [diff] [blame] | 75 | // 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). |
| 78 | table 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 Kuszmaul | 71a8193 | 2020-12-15 21:08:01 -0800 | [diff] [blame] | 85 | table SubscriberRequest { |
| 86 | // The channels that we want transfered to this client. |
| 87 | channels_to_transfer:[ChannelRequest] (id: 0); |
| 88 | } |