1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-30 04:39:03 +01:00

Add schemas for new protocol

This commit is contained in:
Daniil Gentili 2020-03-15 19:44:00 +01:00
parent 3afa25ebb3
commit 5ef7756f82
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
2 changed files with 109 additions and 0 deletions

49
scheme.tlb Normal file
View File

@ -0,0 +1,49 @@
// Extras
extras$_ {t:Type} (## 8) [ length:(## 8) extra:t ] = Extras t;
extraStreamFlags#01 streamId:(## 8) flags:# 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 flags:# dataSavingEnabled:flags.0?true = ExtraSignaling;
extraGroupCallKey#05 key:(## 256) = ExtraSignaling;
extraGroupCallUpgrade#06 = ExtraSignaling;
// Stream info
streamInfo$_ streamId:(## 8) type:(## 8) codec:# frameDurationIgnored:(## 16) enabled:(## 8)= StreamInfo;
// Packet
packet$_ type:(## 8) ackSeq:# seq:# ackMask:# flags:(## 8) extras:flags.0?Extras<ExtraSignaling> data:payload = Packet;
payloadInit#0 peerVersion:# minVersion:# flags:# streams:Extras<StreamInfo> dataSavingEnabled:flags.0?true groupCallSupported:flags.1?true videoSendSupported:flags.2?true videoRecvSupported:flags.3?true = Payload;
payloadInitAck#1 peerVersion:# minVersion:# streams:Extras<StreamInfo> = Payload;
payloadStreamData#4
streamId:(## 6)
flags:(## 2)
length:(## flags.0 ? 11 : 8)
eFlags:(## flags.0 ? 5 : 0)
fragmented:eFlags.4?true
keyframe:eFlags.5?true
pts:#
data:bytes
extraFEC:eFlags.3?Extras<Bytes>
= Payload;
payloadPing#6 = Payload;
payloadPong#7 seq:# = Payload;
payloadNop#E = Payload;
// Deprecated
payloadStreamDataX2#8 a:payloadStreamData b:payloadStreamData = Payload;
payloadStreamDataX3#9 a:payloadStreamData b:payloadStreamData c:payloadStreamData = Payload;

60
schemeNew.tlb Normal file
View File

@ -0,0 +1,60 @@
// Simplified scheme, for the new protocol
// Try unifying all flags, lengths and so on
packet$_
seq:# ackSeq:# ackMask:#
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)
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
fragmented:eFlags.0?true // 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
extraFEC:flags.1?ExtraFEC
extraSignaling:flags.2?Extras<ExtraSignaling>
= 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:# 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 flags:# 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) streams:Extras<StreamInfo> 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;
extraNop#C = ExtraSignaling;
// Stream info
streamInfo$_ streamId:(## 8) type:(## 8) codec:# frameDurationIgnored:(## 16) enabled:(## 8)= StreamInfo;