streaming video client/server application
18 answers - 2002 bytes -

HI,
I try to make a streaming video client server application using thr TWsocket component.
I think i have some probleme with handling all the data that is comming on the client part. my server part, I have a callback function that if fired as soon as i have a video frame is ready. this card is a mpeg4 compressor card, so the data fram is variable. From 248 bytes to 30K or 40K. So I send it in UDP. This server is a multi streaming server I can stream up to 4 channel. since i have only 1 callback for all the channel i can't do it in a thread (i think). So i do this every thime i received a frame:
I have put a TWsocket on the form.
frmTestCarteDSPR->udpServer->Proto = "udp";
frmTestCarteDSPR->udpServer->Addr = frmTestCarteDSPR->infoConnection[channelNum].ipAddr; // ip addr to the remote host
frmTestCarteDSPR->udpServer->Port = frmTestCarteDSPR->infoConnection[channelNum].ipPort; // remote port
frmTestCarteDSPR->udpServer->Connect();
size = 65535;
setsockopt(frmTestCarteDSPR->udpServer->HSocket, SL_SCKET , SSNDBUF, (const char *)&size, sizeof(size)); // change the socket buffer to 65535
frmTestCarteDSPR->udpServer->Send((unsigned char *)DataBuf,Length); // send data
frmTestCarteDSPR->udpServer->Close(); // close the socket
I would like to know if this is a good way of doing it ? is ther a simple way or a better way of doing this ?
on the client part, i do this in the udpClientDataAvailable
maxlength = udpClient->RcvdCount;
//debugStream << "data received = " << maxlength << endl;
frame = new uint8_t[maxlength];
while(byteread < maxlength)
{
Len = udpClient->Receive(&frame[byteread],1460);
byteread += Len;
}
// I continue the job for displaying the video.
is there a better way of doing this ? is it possible to receive all the data without looping ?
regards
Jonathan
No.1 | | 438 bytes |
| 
You should also set TWSocket own buffer size (Default to 1460).
frmTestCarteDSPR->udpServer->BufSize = 65536;
maxlength = udpClient->RcvdCount;
Do not rely on RcvdCount which - as Microsoft said - is not always accurate
Just receive as much data as you can into your buffer. Normally since UDP is
a datagram service, you'll get complete datagrams at once.
PS: peut aussi me joindre sur le forum
No.2 | | 979 bytes |
| 
Bonjour Francois,
j'avais oublier que tu parlais francais:)
Merci pour les infos. Je vais changer BufSize pour 65535. j'ai besoin de
faire les 2 ? ou juste Bufsize ?
merci
Jonathan
Message
From: "Francois PIETTE" <francois.piette (AT) skynet (DOT) be>
To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 12:13 PM
Subject: Re: [twsocket] streaming video client/server application
You should also set TWSocket own buffer size (Default to 1460).
frmTestCarteDSPR->udpServer->BufSize = 65536;
>
>maxlength = udpClient->RcvdCount;
>
Do not rely on RcvdCount which - as Microsoft said - is not always
accurate.
Just receive as much data as you can into your buffer. Normally since UDP
is
a datagram service, you'll get complete datagrams at once.
PS: peut aussi me joindre sur le forum
No.3 | | 1141 bytes |
| 
est-ce que je peut le faire aussi du Client ?
udpClient->Proto = "udp";
udpClient->Port = 6001;
udpClient->Addr = "0.0.0.0";
int32_t size;
size = 65535;
udpClient->Listen();
udpClient->BufSize = 65535;
setsockopt(udpClient->HSocket, SL_SCKET , SRCVBUF, (const char *)&size,
sizeof(size));
??
Jonathan
Message
From: "Francois PIETTE" <francois.piette (AT) skynet (DOT) be>
To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 12:13 PM
Subject: Re: [twsocket] streaming video client/server application
You should also set TWSocket own buffer size (Default to 1460).
frmTestCarteDSPR->udpServer->BufSize = 65536;
>
>maxlength = udpClient->RcvdCount;
>
Do not rely on RcvdCount which - as Microsoft said - is not always
accurate.
Just receive as much data as you can into your buffer. Normally since UDP
is
a datagram service, you'll get complete datagrams at once.
PS: peut aussi me joindre sur le forum
No.4 | | 4849 bytes |
| 
Hello Jonathan,
j'avais oublier que tu parlais francais:)
Yes and some other too here. But the list is English, so many people
will not understeand and can also not answer then :( So better stay in
English :)
Merci pour les infos. Je vais changer BufSize pour 65535. j'ai besoin de
faire les 2 ? ou juste Bufsize ?
The other one (RcvdCount) is not a setting. It was just a reminder to
not rely on it.
Rgds, Wilfried [TeamICS]
http://www.mestdagh.biz
Wednesday, January 31, 2007, 19:21, Jonathan Dumaresq wrote:
Bonjour Francois,
j'avais oublier que tu parlais francais:)
Merci pour les infos. Je vais changer BufSize pour 65535. j'ai besoin de
faire les 2 ? ou juste Bufsize ?
merci
Jonathan
Message
From: "Francois PIETTE" <francois.piette (AT) skynet (DOT) be>
To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 12:13 PM
Subject: Re: [twsocket] streaming video client/server application
>>
>You should also set TWSocket own buffer size (Default to 1460).
>frmTestCarteDSPR->udpServer->BufSize = 65536;
>>
maxlength = udpClient->RcvdCount;
>>
>Do not rely on RcvdCount which - as Microsoft said - is not always
>accurate.
>Just receive as much data as you can into your buffer. Normally since UDP
>is
>a datagram service, you'll get complete datagrams at once.
>>
>PS: peut aussi me joindre sur le forum
>
>--
>Participez l'effort SSL pour ICS. Visitez
>
>--
>francois.piette (AT) overbyte (DOT) be
>Auteur du freeware ICS - Internet Component Suite
>Auteur du middleware multi-tiers MidWare
>http://www.overbyte.be
>>
>>
>Message
>From: "Jonathan Dumaresq" <jdumaresq (AT) cimeq (DOT) qc.ca>
>To: <twsocket (AT) elists (DOT) org>
>Sent: Wednesday, January 31, 2007 5:13 PM
>Subject: [twsocket] streaming video client/server application
>>
>>
HI,
I try to make a streaming video client server application using thr
TWsocket component.
I think i have some probleme with handling all the data that is comming
on
the client part. my server part, I have a callback function that if
fired as soon as i have a video frame is ready. this card is a mpeg4
compressor card, so the data fram is variable. From 248 bytes to 30K or
40K. So I send it in UDP. This server is a multi streaming server I can
stream up to 4 channel. since i have only 1 callback for all the channel
i
can't do it in a thread (i think). So i do this every thime i received a
frame:
I have put a TWsocket on the form.
frmTestCarteDSPR->udpServer->Proto = "udp";
frmTestCarteDSPR->udpServer->Addr =
frmTestCarteDSPR->infoConnection[channelNum].ipAddr; // ip addr to the
remote host
frmTestCarteDSPR->udpServer->Port =
frmTestCarteDSPR->infoConnection[channelNum].ipPort; // remote port
frmTestCarteDSPR->udpServer->Connect();
size = 65535;
setsockopt(frmTestCarteDSPR->udpServer->HSocket, SL_SCKET ,
SSNDBUF,
(const char *)&size, sizeof(size)); // change the socket buffer to 65535
frmTestCarteDSPR->udpServer->Send((unsigned char *)DataBuf,Length); //
send data
frmTestCarteDSPR->udpServer->Close(); // close the socket
I would like to know if this is a good way of doing it ? is ther a
simple way or a better way of doing this ?
on the client part, i do this in the udpClientDataAvailable
maxlength = udpClient->RcvdCount;
//debugStream << "data received = " << maxlength << endl;
frame = new uint8_t[maxlength];
while(byteread < maxlength)
{
Len = udpClient->Receive(&frame[byteread],1460);
byteread += Len;
}
// I continue the job for displaying the video.
is there a better way of doing this ? is it possible to receive all the
data without looping ?
regards
Jonathan
--
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at http://www.overbyte.be
>>
>--
>To unsubscribe or change your settings for TWSocket mailing list
>please goto
>Visit our website at http://www.overbyte.be
>
No.5 | | 4722 bytes |
| 
Hello Jonathan,
est-ce que je peut le faire aussi du Client ?
Yes also the client part. If you do not you will not receive sutch large
datagram at once.
Rgds, Wilfried [TeamICS]
http://www.mestdagh.biz
Wednesday, January 31, 2007, 19:26, Jonathan Dumaresq wrote:
est-ce que je peut le faire aussi du Client ?
udpClient->Proto = "udp";
udpClient->Port = 6001;
udpClient->Addr = "0.0.0.0";
int32_t size;
size = 65535;
udpClient->Listen();
udpClient->BufSize = 65535;
setsockopt(udpClient->HSocket, SL_SCKET , SRCVBUF, (const char *)&size,
sizeof(size));
??
Jonathan
Message
From: "Francois PIETTE" <francois.piette (AT) skynet (DOT) be>
To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 12:13 PM
Subject: Re: [twsocket] streaming video client/server application
>>
>You should also set TWSocket own buffer size (Default to 1460).
>frmTestCarteDSPR->udpServer->BufSize = 65536;
>>
maxlength = udpClient->RcvdCount;
>>
>Do not rely on RcvdCount which - as Microsoft said - is not always
>accurate.
>Just receive as much data as you can into your buffer. Normally since UDP
>is
>a datagram service, you'll get complete datagrams at once.
>>
>PS: peut aussi me joindre sur le forum
>
>--
>Participez l'effort SSL pour ICS. Visitez
>
>--
>francois.piette (AT) overbyte (DOT) be
>Auteur du freeware ICS - Internet Component Suite
>Auteur du middleware multi-tiers MidWare
>http://www.overbyte.be
>>
>>
>Message
>From: "Jonathan Dumaresq" <jdumaresq (AT) cimeq (DOT) qc.ca>
>To: <twsocket (AT) elists (DOT) org>
>Sent: Wednesday, January 31, 2007 5:13 PM
>Subject: [twsocket] streaming video client/server application
>>
>>
HI,
I try to make a streaming video client server application using thr
TWsocket component.
I think i have some probleme with handling all the data that is comming
on
the client part. my server part, I have a callback function that if
fired as soon as i have a video frame is ready. this card is a mpeg4
compressor card, so the data fram is variable. From 248 bytes to 30K or
40K. So I send it in UDP. This server is a multi streaming server I can
stream up to 4 channel. since i have only 1 callback for all the channel
i
can't do it in a thread (i think). So i do this every thime i received a
frame:
I have put a TWsocket on the form.
frmTestCarteDSPR->udpServer->Proto = "udp";
frmTestCarteDSPR->udpServer->Addr =
frmTestCarteDSPR->infoConnection[channelNum].ipAddr; // ip addr to the
remote host
frmTestCarteDSPR->udpServer->Port =
frmTestCarteDSPR->infoConnection[channelNum].ipPort; // remote port
frmTestCarteDSPR->udpServer->Connect();
size = 65535;
setsockopt(frmTestCarteDSPR->udpServer->HSocket, SL_SCKET ,
SSNDBUF,
(const char *)&size, sizeof(size)); // change the socket buffer to 65535
frmTestCarteDSPR->udpServer->Send((unsigned char *)DataBuf,Length); //
send data
frmTestCarteDSPR->udpServer->Close(); // close the socket
I would like to know if this is a good way of doing it ? is ther a
simple way or a better way of doing this ?
on the client part, i do this in the udpClientDataAvailable
maxlength = udpClient->RcvdCount;
//debugStream << "data received = " << maxlength << endl;
frame = new uint8_t[maxlength];
while(byteread < maxlength)
{
Len = udpClient->Receive(&frame[byteread],1460);
byteread += Len;
}
// I continue the job for displaying the video.
is there a better way of doing this ? is it possible to receive all the
data without looping ?
regards
Jonathan
--
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at http://www.overbyte.be
>>
>--
>To unsubscribe or change your settings for TWSocket mailing list
>please goto
>Visit our website at http://www.overbyte.be
>
No.6 | | 5168 bytes |
| 
hi,
is there a way to know how much data is received ?
i will try to put thoses RcvBuf on both side to see if it work.Beacuse when
i call the Received function, it always return 1460. even if i put a count
larger than that.
regards
Jonathan
Message
From: "Wilfried Mestdagh" <wilfried (AT) mestdagh (DOT) biz>
To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 1:39 PM
Subject: Re: [twsocket] streaming video client/server application
Hello Jonathan,
>
>j'avais oublier que tu parlais francais:)
>
Yes and some other too here. But the list is English, so many people
will not understeand and can also not answer then :( So better stay in
English :)
>
>Merci pour les infos. Je vais changer BufSize pour 65535. j'ai besoin de
>faire les 2 ? ou juste Bufsize ?
>
The other one (RcvdCount) is not a setting. It was just a reminder to
not rely on it.
Rgds, Wilfried [TeamICS]
http://www.mestdagh.biz
Wednesday, January 31, 2007, 19:21, Jonathan Dumaresq wrote:
>
>Bonjour Francois,
>
>j'avais oublier que tu parlais francais:)
>
>Merci pour les infos. Je vais changer BufSize pour 65535. j'ai besoin de
>faire les 2 ? ou juste Bufsize ?
>
>merci
>
>Jonathan
>Message
>From: "Francois PIETTE" <francois.piette (AT) skynet (DOT) be>
>To: "ICS support mailing" <twsocket (AT) elists (DOT) org>
>Sent: Wednesday, January 31, 2007 12:13 PM
>Subject: Re: [twsocket] streaming video client/server application
>
>
You should also set TWSocket own buffer size (Default to 1460).
frmTestCarteDSPR->udpServer->BufSize = 65536;
maxlength = udpClient->RcvdCount;
Do not rely on RcvdCount which - as Microsoft said - is not always
accurate.
Just receive as much data as you can into your buffer. Normally since
UDP
is
a datagram service, you'll get complete datagrams at once.
PS: peut aussi me joindre sur le forum
--
Participez l'effort SSL pour ICS. Visitez
--
francois.piette (AT) overbyte (DOT) be
Auteur du freeware ICS - Internet Component Suite
Auteur du middleware multi-tiers MidWare
http://www.overbyte.be
Message
From: "Jonathan Dumaresq" <jdumaresq (AT) cimeq (DOT) qc.ca>
To: <twsocket (AT) elists (DOT) org>
Sent: Wednesday, January 31, 2007 5:13 PM
Subject: [twsocket] streaming video client/server application
HI,
I try to make a streaming video client server application using thr
TWsocket component.
I think i have some probleme with handling all the data that is comming
on
the client part. my server part, I have a callback function that if
fired as soon as i have a video frame is ready. this card is a mpeg4
compressor card, so the data fram is variable. From 248 bytes to 30K or
40K. So I send it in UDP. This server is a multi streaming server I can
stream up to 4 channel. since i have only 1 callback for all the
channel
i
can't do it in a thread (i think). So i do this every thime i received
a
frame:
I have put a TWsocket on the form.
frmTestCarteDSPR->udpServer->Proto = "udp";
frmTestCarteDSPR->udpServer->Addr =
frmTestCarteDSPR->infoConnection[channelNum].ipAddr; // ip addr to the
remote host
frmTestCarteDSPR->udpServer->Port =
frmTestCarteDSPR->infoConnection[channelNum].ipPort; // remote port
frmTestCarteDSPR->udpServer->Connect();
size = 65535;
setsockopt(frmTestCarteDSPR->udpServer->HSocket, SL_SCKET ,
SSNDBUF,
(const char *)&size, sizeof(size)); // change the socket buffer to
65535
frmTestCarteDSPR->udpServer->Send((unsigned char *)DataBuf,Length);
//
send data
frmTestCarteDSPR->udpServer->Close(); // close the socket
I would like to know if this is a good way of doing it ? is ther a
simple way or a better way of doing this ?
on the client part, i do this in the udpClientDataAvailable
maxlength = udpClient->RcvdCount;
//debugStream << "data received = " << maxlength << endl;
frame = new uint8_t[maxlength];
while(byteread < maxlength)
{
Len = udpClient->Receive(&frame[byteread],1460);
byteread += Len;
}
// I continue the job for displaying the video.
is there a better way of doing this ? is it possible to receive all the
data without looping ?
regards
Jonathan
--
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto
Visit our website at http://www.overbyte.be
--
No.7 | | 694 bytes |
| 
is there a way to know how much data is received ?
The only reliable way is to read data until no more is available (The
component is asynchronous and will /not/ block on the Receive call. It will
simply returns the number of available bytes or -1 if no data available (0
is returned for a TCP connection when remote has close the connection).
i will try to put thoses RcvBuf on both side to see if it work.Beacuse
when
i call the Received function, it always return 1460. even if i put a count
larger than that.
You have to set BufSize at least equal to the largest datagram you handle.
btw: Please trim your replies to get only the relevant part.
No.8 | | 626 bytes |
| 
The only reliable way is to read data until no more is available (The
component is asynchronous and will /not/ block on the Receive call. It
will
simply returns the number of available bytes or -1 if no data available (0
is returned for a TCP connection when remote has close the connection).
So the way i do it in the event, is ok ? i just have to put 65535 in the
count size if i set the bufsize to 65535 ?
You have to set BufSize at least equal to the largest datagram you handle.
65535 is it the maximum for upd datagram ? I think yes but just to be sure.
regards
Jonathan
No.9 | | 957 bytes |
| 
Jonathan Dumaresq wrote:
>The only reliable way is to read data until no more is available (The
>component is asynchronous and will /not/ block on the Receive call.
>It will
>simply returns the number of available bytes or -1 if no data
>available (0 is returned for a TCP connection when remote has close
>the connection).
So the way i do it in the event, is ok ? i just have to put 65535 in
the count size if i set the bufsize to 65535 ?
>You have to set BufSize at least equal to the largest datagram you
>handle.
65535 is it the maximum for upd datagram ? I think yes but just to be
sure.
Winsock fragmentation will probably prevent receiving such large
packets in a single Receive-call, data will probably be fragmented
into MTU fragments (AFAIR?).
Arno Garrels [TeamICS]
regards
Jonathan
No.10 | | 798 bytes |
| 
>So the way i do it in the event, is ok ? i just have to put 65535 in
>the count size if i set the bufsize to 65535 ?
Probably better to use 65536 (065535) = 64K.
>65535 is it the maximum for upd datagram ? I think yes but just to be
>sure.
I don't know. Probably it is 65536. To be verifyed on MSDN.
Winsock fragmentation will probably prevent receiving such large
packets in a single Receive-call, data will probably be fragmented
into MTU fragments (AFAIR?).
Winsock will reassemble the datagram and deliver it in one chunk. Probably
winsock buffer need to be large enough to contain a single datagram. IM
that is how UDP differ from TCP: datagram boundaries are respected.
No.11 | | 371 bytes |
| 
Winsock will reassemble the datagram and deliver it in one chunk. Probably
winsock buffer need to be large enough to contain a single datagram. IM
that is how UDP differ from TCP: datagram boundaries are respected.
i'll try that and keep you updated on my progress.
BufSize should be called before or after the connect or listen ?
Jonathan
No.12 | | 108 bytes |
| 
BufSize should be called before or after the connect or listen ?
I would say before sending anything.
No.13 | | 838 bytes |
| 
I would say before sending anything.
good
this is working now. thanx for your help everybody.
I have another question. When I receive the data from the udp port, i have
an event that is raised "DataAvailable". than i read the data of the
udp_datagram. This is all done in a thread. I use the sample threat example
from Francois. but for udp. Now when i have receive this datagram, i would
like to know what is the best way to tell the main app that i have received
this datagram ? The main problem is that the function that treat this
datagram is blocking and is a little long to execute it's my video decoder.
For now what i do is i post a message to my application everytime i receive
a udp datagram. I don't know if i could do this in a better way ?
regards
Jonathan
No.14 | | 1249 bytes |
| 
Jonathan Dumaresq wrote:
>I would say before sending anything.
good
this is working now. thanx for your help everybody.
I have another question. When I receive the data from the udp port, i
have an event that is raised "DataAvailable". than i read the data
of the udp_datagram. This is all done in a thread. I use the sample
threat example
>from Francois. but for udp. Now when i have receive this datagram, i
>would
like to know what is the best way to tell the main app that i have
received this datagram ? The main problem is that the function that
treat this datagram is blocking and is a little long to execute it's
my video decoder. For now what i do is i post a message to my
application everytime i receive a udp datagram. I don't know if i
could do this in a better way ?
I think it is K, but propably you need to pause receiving when receiving
is much faster than decoding to prevent infinite grow of your buffers.
Also the message queue queues only a limited number of messages, if
it is full SendMessage()/PostMessage() will fail.
Arno Garrels [TeamICS]
regards
Jonathan
No.15 | | 1491 bytes |
| 
Arno Garrels wrote:
Jonathan Dumaresq wrote:
I would say before sending anything.
>
>good
>
>this is working now. thanx for your help everybody.
>
>I have another question. When I receive the data from the udp port, i
>have an event that is raised "DataAvailable". than i read the data
>of the udp_datagram. This is all done in a thread. I use the sample
>threat example
from Francois. but for udp. Now when i have receive this datagram, i
would
>like to know what is the best way to tell the main app that i have
>received this datagram ? The main problem is that the function that
>treat this datagram is blocking and is a little long to execute it's
>my video decoder. For now what i do is i post a message to my
>application everytime i receive a udp datagram. I don't know if i
>could do this in a better way ?
I think it is K, but propably you need to pause receiving when
receiving is much faster than decoding to prevent infinite grow of
your buffers. Also the message queue queues only a limited number of
messages, if it is full SendMessage()/PostMessage() will fail.
Correction: PostMessage() will fail, SendMessage() probably not since
it calls the window procedure directly.
Arno Garrels [TeamICS]
>
>regards
>
>Jonathan
No.16 | | 416 bytes |
| 
Hello Arno,
propably you need to pause receiving when receiving
is much faster than decoding to prevent infinite grow of your buffers.
The problem is UDP. When winsock buffer is full UDP packets are trown
away. Maybe no problem ? Maybe better to store on disk to not loose
anything and give to the decoder at speed he can handle ?
Rgds, Wilfried [TeamICS]
http://www.mestdagh.biz
No.17 | | 638 bytes |
| 
Wilfried Mestdagh wrote:
Hello Arno,
>propably you need to pause receiving when receiving
>is much faster than decoding to prevent infinite grow of your
>buffers.
The problem is UDP. When winsock buffer is full UDP packets are trown
away. Maybe no problem ?
Ahh, missed that, so I think you need some protocol for this kind of
streaming may be RTCP and RTP, both are used for instance in SIP.
Maybe better to store on disk to not loose
anything and give to the decoder at speed he can handle ?
Rgds, Wilfried [TeamICS]
http://www.mestdagh.biz
No.18 | | 1066 bytes |
| 
Thanx for the postmessage thing. I will try to use sendmessage instead.
propably you need to pause receiving when receiving
is much faster than decoding to prevent infinite grow of your
buffers.
the decoding pas is very close on my athlon xp to the time a receive udp
packet. I don't know right now how many packet / second i receive. I will
try to evaluate this better.
>>
>The problem is UDP. When winsock buffer is full UDP packets are trown
>away. Maybe no problem ?
the probleme is if a datagram is 20K and i receive only 19K this can be a
problem (i'm not very sure of how the decoding process work) but if i loose
the complete datagram is not a problem.
As for the rtp, is near impossible since i need 0 ms of delay or buffer.
As another question, is it possible to use twsocket in blocked mode with
receivefrom() ? if yes, can this be faster that trigging the onavalaibledata
?
regards
Jonathan