grishka / libtgvoip

VoIP library for Telegram clients
The Unlicense
389 stars 158 forks source link

libtgvoip as layer for custom P2P communication #84

Closed zevlg closed 5 years ago

zevlg commented 5 years ago

Is it possible somehow to use libtgvoip for custom P2P communication?

I'd like to use it not only for phone/video calls, but also for collaborative editing and teledildonics using custom telegram client.

Thanks

danog commented 5 years ago

Ye it shouldn't be too difficult, I was actually working on something for this but what is teledild... NOPENOPENOPENOPENOPE

grishka commented 5 years ago

It is but you'll have to modify the protocol and make sure both sides use compatible clients. Probably negotiate your custom features in the INIT/INIT_ACK sequence.

Teledildonics... It's a funny word and an interesting use for Telegram calls that never crossed my mind.

zevlg commented 5 years ago

@grishka hmm, nice! But is this possible to do so without modifications to libtgvoip, just by using its API ?

grishka commented 5 years ago

No, you need to at least do something to add a stream for your custom data so it could be distinct from voice. Then you'll need to come up with what you do when packet losses happen. I'd suggest looking at video/VideoPacketSender.cpp and implementing a PacketSender for your data in a similar fashion. Ah, and one more thing to keep in mind: MTU. If your packet exceeds ~1200 bytes after all headers and encryption, there's a good chance it will be lost when going through the internets (as opposed to your LAN).

zevlg commented 5 years ago

Thanks, packets loss/reordering is not a problem in my case, collaborative editing/teledildonics protocols does have techniques to handle it.

Ah, and one more thing to keep in mind: MTU

Yeah, I know about packets fragmentation

One more thing. Could it be possible to encode data as sounds (like old dial-up modems), transmit them as ordinary calls and make libtgvoip not to play the sound, but rather call some callback, so custom telegram client could decide what to do with the sound instead of just feeding it to sound card?

grishka commented 5 years ago

Yes, just add -DTGVOIP_USE_CALLBACK_AUDIO_IO to compiler flags or --enable-audio-callback if you use automake. This is mostly intended for bots like @danog's Magnaluna. This would be a very inefficient use of bandwidth, but who am I to stop you anyway :D