|
| 1 | +# API Outline |
| 2 | + |
| 3 | +```javascript |
| 4 | +interface RtpPacket { |
| 5 | + constructor(required RtpPacketInit); |
| 6 | + readonly attribute bool marker; |
| 7 | + readonly attribute octet payloadType; |
| 8 | + readonly attribute unsigned short sequenceNumber; |
| 9 | + readonly attribute unsigned long timestamp; |
| 10 | + readonly attribute unsigned long ssrc; |
| 11 | + readonly attribute sequence<unsigned long> csrcs; |
| 12 | + readonly attribute sequence<RtpHeaderExtension> headerExtensions; |
| 13 | + |
| 14 | + // Write payload to the specified (Shared-)ArrayBuffer/ArrayBufferView, |
| 15 | + // allowing for BYOB. |
| 16 | + undefined copyPayloadTo(AllowSharedBufferSource destination); |
| 17 | + |
| 18 | + // OPTIONAL: Duplicate with header extensions, but conveniently parsed |
| 19 | + readonly attribute DOMString? mid; |
| 20 | + readonly attribute DOMString? rid; |
| 21 | + attribute octet? audioLevel; |
| 22 | + attribute octet? videoRotation; |
| 23 | + readonly attribute unsigned long long? remoteSendTimestamp; |
| 24 | + |
| 25 | + // OPTIONAL: Extra information that may be useful to know |
| 26 | + readonly attribute DOMHighResTimeStamp receivedTime; |
| 27 | + readonly attribute unsigned long sequenceNumberRolloverCount; |
| 28 | + |
| 29 | + void setHeaderExtension(RtpHeaderExtension); |
| 30 | +} |
| 31 | + |
| 32 | +interface RtpHeaderExtension { |
| 33 | + constructor(required RtpHeaderExtensionInit); |
| 34 | + readonly attribute DOMString uri; |
| 35 | + readonly attribute ArrayBuffer value; |
| 36 | + undefined copyValueTo(AllowSharedBufferSource destination); |
| 37 | +} |
| 38 | + |
| 39 | +dictionary RtpPacketInit { |
| 40 | + bool marker = false; |
| 41 | + required octet payloadType; |
| 42 | + required unsigned long timestamp; |
| 43 | + sequence<unsigned long> csrcs = []; |
| 44 | + // Cannot be MID, RID, or congestion control sequence number |
| 45 | + sequence<RtpHeaderExtensionInit> headerExtensions = []; |
| 46 | + required AllowSharedBufferSource payload; |
| 47 | + |
| 48 | + // Convenience for adding to headerExtensions |
| 49 | + octet audioLevel; |
| 50 | + octet videoRotation; |
| 51 | +} |
| 52 | + |
| 53 | +dictionary RtpHeaderExtensionInit { |
| 54 | + required DOMString uri; |
| 55 | + required AllowSharedBufferSource value; |
| 56 | +} |
| 57 | + |
| 58 | +``` |
| 59 | +### PeerConnection, RtpSendStream, RtpReceiveStream Extensions |
| 60 | +
|
| 61 | +```javascript |
| 62 | +partial interface PeerConnection { |
| 63 | + // There may be an RtpTransport with no RtpSenders and no RtpReceivers. |
| 64 | + readonly attribute RtpTransport? rtpTransport; |
| 65 | +} |
| 66 | + |
| 67 | +// Add this to RTCConfiguration |
| 68 | +dictionary RTCConfiguration { |
| 69 | + // Means "continue to encode and packetize packets, but don't send them. |
| 70 | + // Instead give them to me via onpacketizedrtpavailable/readPacketizedRtp |
| 71 | + // and I will send them." |
| 72 | + // TODO: Think of a better name |
| 73 | + bool customPacer; |
| 74 | +} |
| 75 | + |
| 76 | +partial interface RtpSender { |
| 77 | + // shared between RtpSenders in the same BUNDLE group |
| 78 | + readonly attribute RtpTransport? rtpTransport; |
| 79 | + Promise<sequence<RtpSendStream>> replaceSendStreams(); |
| 80 | +} |
| 81 | + |
| 82 | +partial interface RtpReceiver { |
| 83 | + // shared between RtpSenders in the same BUNDLE group |
| 84 | + readonly attribute RtpTransport? rtpTransport; |
| 85 | + Promise<sequence<RtpReceiveStream>> replaceReceiveStreams(); |
| 86 | +} |
| 87 | + |
| 88 | +interface RtpTransport { |
| 89 | + Promise<RtpSendStream> addRtpSendStream(RtpSendStreamInit); |
| 90 | + Promise<RtpReceiveStream> addRtpReceiveStream(RtpReceiveStreamInit); |
| 91 | + attribute EventHandler onrtpsent; // RtpSent |
| 92 | + attribute EventHandler onrtpacksreceived; // RtpAcks |
| 93 | + attribute EventHandler onpacketizedrtpavailable; // No payload. Call readPacketizedRtp |
| 94 | + sequence<RtpPacket> readPacketizedRtp(maxNumberOfPackets); |
| 95 | + |
| 96 | + readonly attribute unsigned long bandwidthEstimate; // bps |
| 97 | + readonly attribute unsigned long allocatedBandwidth; // bps |
| 98 | + attribute unsigned long customAllocatedBandwidth; // writable |
| 99 | + // Means "when doing bitrate allocation and rate control, don't use more than this" |
| 100 | + attribute unsigned long customMaxBandwidth; |
| 101 | + // Means "make each packet smaller by this much so I can put custom stuff in each packet" |
| 102 | + attribute unsigned long customPerPacketOverhead; |
| 103 | +} |
| 104 | + |
| 105 | +// RFC 8888 or Transport-cc feedback |
| 106 | +interface RtpAcks { |
| 107 | + readonly attribute sequence<RtpAck> acks; |
| 108 | + readonly attribute unsigned long long remoteSendTimestamp; |
| 109 | + readonly attribute DOMHighResTimeStamp receivedTime; |
| 110 | + readonly attribute ExplicitCongestionNotification explicitCongestionNotification; // AKA "ECN" |
| 111 | +} |
| 112 | + |
| 113 | +interface RtpAck { |
| 114 | + // Correlated with RtpSent.ackId |
| 115 | + readonly attribute unsigned long long ackId; |
| 116 | + readonly attribute unsigned long long remoteReceiveTimestamp; |
| 117 | +} |
| 118 | + |
| 119 | +// See RFC 3991 and RFC 3168 |
| 120 | +enum ExplicitCongestionNotification { |
| 121 | + // ECT = ECN-Capable Transport |
| 122 | + "unset", // AKA "Not-ECT"; Bits: 00 |
| 123 | + "scalable-congestion-not-experienced", // AKA "ECT(1)" or "Scalable" or "L4S" ; Bits: 01 |
| 124 | + "classic-congestion-not-experienced", // AKA "ECT(0)" or "Classic" or "not L4S"; Bits: 10 |
| 125 | + "congestion-experienced" // AKA "CE" or "ECN-marked" or "marked"; Bits: 11 |
| 126 | +} |
| 127 | + |
| 128 | +[Exposed=(Window,Worker), Transferable] |
| 129 | +interface RtpSendStream { |
| 130 | + readonly attribute DOMString mid?; // Shared among many RtpSendStreams |
| 131 | + readonly attribute DOMString rid?; // Unique to RtpSendStream (scoped to MID) |
| 132 | + readonly attribute unsigned long ssrc; |
| 133 | + readonly attribute unsigned long rtxSsrc; |
| 134 | + |
| 135 | + attribute EventHandler onpacketizedrtp; |
| 136 | + sequence<RtpPacket> readPacketizedRtp(long maxNumberOfPackets); |
| 137 | + |
| 138 | + // https://github.com/w3c/webrtc-rtptransport/issues/32 |
| 139 | + void sendRtp(RtpPacket packet); |
| 140 | + Promise<RtpSendResult> sendRtp(RtpPacketInit packet, RtpSendOptions options); |
| 141 | + |
| 142 | + // Amount allocated by the browser |
| 143 | + readonly attribute unsigned long allocatedBandwidth; |
| 144 | +} |
| 145 | + |
| 146 | +interface RtpSendResult { |
| 147 | + readonly attribute RtpSent sent?; |
| 148 | + readonly attribute RtpUnsentReason unsent?; |
| 149 | +} |
| 150 | + |
| 151 | +interface RtpSent { |
| 152 | + readonly attribute DOMHighResTimeStamp time; |
| 153 | + |
| 154 | + // Can be correlated with acks |
| 155 | + readonly attribute unsigned long long ackId?; |
| 156 | + readonly attribute unsigned long long size; |
| 157 | +} |
| 158 | + |
| 159 | +enum RtpUnsentReason { |
| 160 | + "overuse", |
| 161 | + "transport-unavailable", |
| 162 | +}; |
| 163 | + |
| 164 | +dictionary RtpSendOptions { |
| 165 | + DOMHighResTimeStamp sendTime; |
| 166 | +} |
| 167 | + |
| 168 | +[Exposed=(Window,Worker), Transferable] |
| 169 | +interface RtpReceiveStream { |
| 170 | + readonly attribute DOMString mid?; // Shared among many RtpReceivetreams |
| 171 | + readonly attribute DOMString rid?; // Unique to RtpReceiveStream (scoped to MID) |
| 172 | + readonly attribute sequence<unsigned long> ssrcs; |
| 173 | + readonly attribute sequence<unsigned long> rtxSsrcs; |
| 174 | + |
| 175 | + attribute EventHandler onreceivedrtp; |
| 176 | + sequence<RtpPacket> readReceivedRtp(long maxNumberOfPackets); |
| 177 | + |
| 178 | + void receiveRtp(RtpPacket packet) |
| 179 | +} |
| 180 | +``` |
0 commit comments