Haivision / srt

Secure, Reliable, Transport
https://www.srtalliance.org
Mozilla Public License 2.0
3.12k stars 851 forks source link

How to handle client and server have different SRTO_PAYLOADSIZE setting? #2013

Closed quink-black closed 3 years ago

quink-black commented 3 years ago

For srt_sendmsg(u, buf, len, ...), len should not larger than the SRTO_PAYLOADSIZE setting.

For srt_recvmsg(), the description in API-functions.md seems not quite right:

In live mode, the function behaves as in file/message mode, although the number of bytes retrieved will be at most the size of SRTO_PAYLOADSIZE.

From my understanding and test, it depends on the peers SRTO_PAYLOADSIZE.

Looks like SRT protocol doesn't have a negotiation mechanism on SRTO_PAYLOADSIZE. The client and server can have different setting on SRTO_PAYLOADSIZE. Limit sending with SRT_LIVE_DEF_PLSIZE and prepared to receive SRT_LIVE_MAX_PLSIZE is the best practice, right?

maxsharabayko commented 3 years ago

@quink-black SRT protocol only negotiates MSS (MTU) size. SRTO_PAYLOADSIZE is used by the sender mainly to check that the size of the message submitted in srt_sendmsg(..) does not exceed the configured value. The receiver will read a message with any size of payload if I remember correctly. Also, the receiver may be using (worth checking the code) the pre-configured SRTO_PAYLOADSIZE to calculate some stats, e.g. missing bytes byteRcvDropTotal.

quink-black commented 3 years ago

So https://github.com/Haivision/srt/blob/master/docs/API/API-functions.md#srt_recvmsg is incorrect

In live mode, the function behaves as in file/message mode, although the number of bytes retrieved will be at most the size of SRTO_PAYLOADSIZE. In this mode, however, with default settings of SRTO_TSBPDMODE and SRTO_TLPKTDROP, the message will be received only when its time to play has come, and until then it will be kept in the receiver buffer. Also, when the time to play has come for a message that is next to the currently lost one, it will be delivered and the lost one dropped.

maxsharabayko commented 3 years ago

Rather not precise enough.

although the number of bytes retrieved will be at most the size of SRTO_PAYLOADSIZE

where SRTO_PAYLOADSIZE is the value configured on the sender side.

Worth confirming the actual behavior though, as I am taking this from my memory.