hello dear network experts,
i am currently having trouble implementing some small application that
receives an mjpeg stream via tcp/ip and parallely multicasts the decoded
jpegs as rgb images via udp into the local network.
the application starts a dedicated reception thread for the mjpeg stream
and consequently receives everything coming. once a full jpeg frame is
detected, it is decoded and put into a queue that is secured via mutexes
and semaphores. i am able to receive and process 30fps constantly (not
more, because the sending camera is not able to send any faster). the
jpegs are each ~90kb large.
parallely, my main application thread waits for any incoming images from
the camera (which by then is already decoded into a plain rgb image with
size 640x480x3 channels = 921600 bytes), splits it into small fragments
and sends all fragments (including a small preceding descriptor) over an
udp multicast socket.
it seems this slows down the tcp/ip reception.
i am absolutely sure to use a 1 gigabit lan. all cables, connections and
devices are checked and verified. the tcp stream of the camera image,
basically comes in as ~4000 byte packages. the udp datagrams i send are
50000 bytes large in maximum. i also tested smaller datagrams (down to
100 bytes) but it always comes down to a framrate drop down to ~23 frames
per second.
hence, all i am sending over my network is receiving jpegs (appox 90000
bytes big each) via tcp/ip and sending the decoded jpegs (as plain rgbs
with 921600 bytes each) via udp multicast) and the i already encounter
limits on my ethernet.
don't get me wrong, i also thought, that this might be due to cpu
processing. i have a dualcore, the whole program only uses 16% cpu from
either one, not both. and the main slow down is measurable during the recv
()-call of the tcp-/ip connection, not the processing of the data! the
more i send over udp multicast, the longer the recv()-call takes, and if
i send everything i receive, i drop down to 23 fps.
i believe i handle the multicast sending wrong or am missing something in
the tcp connection implementation. could you please give me a hint? i
reall don't have a clue where to keep looking!
best
mikey79
|