Hi guys,
I apologize in advance for my free pascal newbeness,
I have what should be an easy program to write with Lazarus and Synapse,
but I can't figure out what receive method I should use.
Let me describe the context :
- I have a camera which send a UDP stream, which is basically a MJPEG video
stream composed by approximately 10 JPEG images per second of 25kB each
- each datagram starts with 4 bytes giving its size (header+ JPEG)
- The 16th byte gives the position of the starting of the JPEG (FFD8)
- The end of the datagram is also the end of the JPEG (FFD9)
So what I try to achieve :
- use a UDP socket to receive the datagrams
- find out the size of every datagrams
- cut the interesting part (the JPG)
- display them
I've looked at the UDP Server example on the synapse howto (
http://www.synapse.ararat.cz/doku.php/public:howto:udpserver), but I'm a
bit lost identifying what method I should use. If I use RecvPacket, I can
see that the Socket is working, but I presume that working with String and
Lines is not the right way of doing it.
To be a bit more precise :
- How could I define a buffer big enough to receive 25KB ? I've thought
using the RecvBuffer function (
http://synapse.ararat.cz/doc/help/blcksock.TBlockSocket.html#RecvBuffer),
but I don't understand how to define a 25KB "Tmemory" buffer ... I've tried
something like :
type
Tlargebuf = array[0..30000] of byte;
Plargebuf = ^Tlargebuf;
...
var
largeBuf:Plargebuf;
size:integer;
...
size:= UDPReceiveSocket.RecvBuffer(largeBuf, 30000);
if (UDPReceiveSocket.LastError = 0) and (size > 0) then
Memo1.Lines.Add('size : '+ inttoStr(size));
To check if I could get this datagram (and have it's size), but size is
always -1.
- What would be the fastest receive method to be able to split the datagram
without having to use string ?
Thanks in advance for your help,
Rgds,
Clement
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public