I have server and client connection with srt socket (by Haivision https://github.com/Haivision/srt).
The connection is established as expected, but then, when communication begins, an odd error appears.
My packet structure is-
width: 2 bytes
height: 2 bytes
image: widthheight3 (3 bytes, rgb, for each pixel)
when trying to receive the first 2 bytes representing the width, I get this message printed in the console:
“LiveCC: buffer size: 2 is too small for the maximum possible 1316”
I could not fix that problem, it’s crusial for the code flow to read the first 4 bytes before the rest of the data, but the srt just does not seem to be able to handle smaller amounts then 1316 bytes, and I don’t know way. If anyone understats more about the protocol implementation and could help me work it out, that would be great.
here’s my code that fails:
// _sock is the srt socket
typedef std::vector<Pixel> Image;
Image Viewer::receiveImage(uint16_t& width, uint16_t& height)
{
int receivedBytes;
char buffer[sizeof(uint16_t)];
receivedBytes = srt_recvmsg(_sock, buffer, sizeof(buffer)); // here the error gets printed
width = static_cast<uint16_t>(*buffer);
receivedBytes = srt_recvmsg(_sock, buffer, sizeof(buffer)); // here the error gets printed
height = static_cast<uint16_t>(*buffer);
Image image(width * height * BITS_IN_BYTE);
receivedBytes = srt_recvmsg(_sock, (char*)image.data(), image.size());
if (receivedBytes <= 0)
{
throw std::runtime_error("Failed to receive stream from Sharer");
}
image.resize(receivedBytes);
return image;
}