i have made a code in which i receive the live stream on my client from my Raspberry pi
on my Pi (server) i have used a netcat command
pi@raspberrypi ~ $ raspivid -t 0 -o - | nc -l 5001
on the receiver, i store the received data in a buffer, and then that buffer i pass it to my decoder to decode the received video stream
#define IMAGE_BUF_SIZE 20480
#define INCOMING_BUF_SIZE 8192
#define DECODER_BUFFER_SIZE 4096
int totalsize= 0, count=0,recv_size = 0, recvSize;
char imagearray[IMAGE_BUF_SIZE], incomingarry[INCOMING_BUF_SIZE];
char * buffer = imagearray;
unsigned int bufferSize =sizeof(imagearray);
do
{
do
{
recvSize = recv(socket, incomingarry, INCOMING_BUF_SIZE, 0);
count++;
}while(recvSize < INCOMING_BUF_SIZE);
for (int i=0; i<recvSize; i++)
imagearray[totalsize+i] = incomingarry[i];
totalsize = recvSize + totalsize;
recvSize = NULL;
}while(totalsize < IMAGE_BUF_SIZE);
bd.ptr = (uint8_t *)imagearray;
bd.size = sizeof(imagearray);
av_register_all();
avformat_network_init();
i am getting an error stating
"Unhandled exception at 0x6B12F048 in realtimevideo.exe: 0xC0000005: Access violation (parameters: 0x00000008)."
at line
recvSize = recv(socket, incomingarry, INCOMING_BUF_SIZE, 0);
i know that netcat is capable of sending maximum 8kb data.
n my decoder logic requires minimum 20kb of data to function.
What I have tried:
i tried different combinations of values like
#define IMAGE_BUF_SIZE 20480// 40960 //
#define INCOMING_BUF_SIZE 8192 //4096 //1024 //2048 //
#define DECODER_BUFFER_SIZE 4096 // 2048 // 8192 //
but it doesnt work.
even if the connection is successful, the decoder works for the 1st 10 frames and then displays an error stating data not available.
i feel there is an issue with the kind of buffers that i have chosen