Hi,
I am trying to send a video file from Android to C using tcp/ip protocol. When android sends a video file, i am able to receive the file, but when i play the file the file is not getting played and moreover if the actual file plays a video for 2 minutes after receiving using tcp/ip the video size is about 3 hours 5 minutes and so on...
long long int receive_text(long long int socket)
{
long long int buffersize = 0, recv_size = 0, size = 0, read_size, write_size;
char textarray[8196000],errno;
char verify[15] = "text Received";
FILE *text;
read(socket, &size, sizeof(int ));
write(socket, &verify,sizeof(char));
text = fopen("/home/sosdt009/Desktop/receivedandroid.mp4","w");
if( text == NULL)
{
printf("Error has occurred. text file could not be opened \n");
return -1;
}
while(recv_size < size)
{
ioctl(socket, FIONREAD, &buffersize);
if(buffersize > 0 )
{
if(read_size = read(socket, textarray, buffersize) < 0){
printf("%s", strerror(errno));
}
write_size = fwrite(textarray,1, buffersize, text);
recv_size += read_size;
write(socket, &verify,sizeof(char));
if (read_size == write_size)
{
printf("%lld,%lld", read_size, write_size);
printf("text successfully Received! \n");
}
else
{
printf("%lld,%lld", read_size, write_size);
printf(" Data Received successfully: \n");
}
}
}
fclose(text);
return 0;
}