1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-26 12:14:39 +01:00
libtgvoip/schemeNew.tlb

61 lines
2.8 KiB
Plaintext

// Simplified scheme, for the new protocol
// Try unifying all flags, lengths and so on
packet$_
streamId:(## 2) // Max 2 streams, we don't need much anyway (0 and 3 are reserved values)
// If 0, is a pure-service message
// If 1, is an audio packet
// If 2, is a video packet
// If 3, is packet from one of the group call streams
flags:(## 6)
seq:# ackSeq:# ackMask:# // Different sequence for each streamId
streamIdExtended:(streamId == 3 ? (## 8) : false) // Extended stream ID for group calls
length:(## flags.0 ? 11 : (streamId > 0 ? 8 : 0))
eFlags:(## flags.0 ? 5 : 0) // We shouldn't typically need this, but since we have the space why not use it
fragmentIndex:eFlags.0?(## 8) // Logically, this flag can only appear on *big* fragmented messages
fragmentCount:eFlags.0?(## 8) // Logically, this flag can only appear on *big* fragmented messages
keyframe:eFlags.1?true // This flag can only appear for video streams (typically *big* messages, see ^)
data:bytes // No PTS, simply use the seq
recvTS:flags.1?int
extraFEC:flags.2?ExtraFEC
extraSignaling:flags.3?Extras<ExtraSignaling>
reserved:flags.4?true:true // Always true, allows us to distinguish from legacy packets if the maxLayer is wrong.
= Packet;
// ExtraFEC
extraFEC$_ mask:(## 8) [ length:(## 8) _:bytes ] = ExtraFEC;
// Extras
extras$_ {t:Type} (## 8) [ length:(## 8) extra:t ] = Extras t;
extraStreamFlags#01 streamId:(## 8) flags:(## 8) enabled:flags.0?true dtx:flags.1?true extraEC:flags.2?true paused:flags.3?true = ExtraSignaling;
extraStreamCsd#02 streamId:(## 8) width:(## 16) height:(## 16) count:(## 8) [ length:(## 8) codecSpecificData:bytes ] = ExtraSignaling;
extraLanEndpoint#03 address:# port:(## 16) = ExtraSignaling;
extraIpv6Endpoint#07 address:(## 128) port:(## 16) = ExtraSignaling;
extraNetworkChanged#04 streamId:(## 8) flags:(## 8) dataSavingEnabled:flags.0?true = ExtraSignaling;
extraGroupCallKey#05 key:(## 256) = ExtraSignaling;
extraGroupCallUpgrade#06 = ExtraSignaling;
// All signaling starting from here can only be done on packets with streamID 0 (only signaling, no data).
// New init/initACK
extraInit#08 peerVersion:# minVersion:# flags:(## 8) audioCodecs:Extras<int> decoders:Extras<int> maxResolution:(## 8) dataSavingEnabled:flags.0?true groupCallSupported:flags.1?true videoSendSupported:flags.2?true videoRecvSupported:flags.3?true = ExtraSignaling;
extraInitAck#09 peerVersion:# minVersion:# streams:Extras<StreamInfo> = ExtraSignaling;
// Misc signaling
extraPing#A = ExtraSignaling;
extraPong#B seq:# = ExtraSignaling;
// Stream info
streamInfo$_ streamId:(## 8) type:(## 8) codec:# frameDurationIgnored:(## 16) enabled:(## 8)= StreamInfo;