Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Images streaming using Indy client side
#5
(05-03-2022, 06:51 AM)Ahmed Sayed Wrote: I have an issue with images being sent from server.

One issue I see is you are not synchronizing concurrent access to your TBitmap object (a Sleep() is not good enough). Your HTTPServer's OnCommandGet handler runs in a different thread than your camera's OnSampleBufferReady handler, so you need to coordinate access to the TBitmap, such as with a TCriticalSection or equivalent.

Another issue - since you are sending raw image bytes, try adding a Content-Transfer-Encoding header to each image, set to either 8bit or binary. TIdMessageDecoderMIME in modern Indy shouldn't need this header, but it may be needed for an older Indy, or non-Indy clients.

Code:
IOHandler->WriteLn("Content-Type: image/png");
IOHandler->WriteLn("Content-Transfer-Encoding: binary"); // <-- here
IOHandler->WriteLn();
IOHandler->Write(str.get());
IOHandler->WriteLn();
IOHandler->WriteLn("--imgboundary");

(05-03-2022, 06:51 AM)Ahmed Sayed Wrote: I am using Berlin Upd2 and FMX camera component.

Berlin is 6 years old, are you using an up-to-date Indy, at least?

(05-03-2022, 06:51 AM)Ahmed Sayed Wrote: The data received on client side is bigger than the one sent from the server. I don't know why?

Bigger how, exactly? Can you provide an example?

Also, have you tried connecting a standard web browser to your streaming server? Is the browser able to display the updated images?

(05-03-2022, 06:51 AM)Ahmed Sayed Wrote: When I save the image stream to a file on the server side before pushing it, it's ok and a valid image png file. But when I do save it the stream on the client side it shows that it is not a valid png file.

Then you should be able to compare the raw bytes of the 2 files and see exactly what is different between them. What is the actual difference? The first thing that comes to mind is most likely either $0A bytes being converted into $0D $0A, and/or extra $0D $0A being inserted, into the decoded output. Neither of which should happen if modern TIdMessageDecoderMIME detects that the data stream is carrying binary data.

Reply


Messages In This Thread
RE: Images streaming using Indy client side - by rlebeau - 05-03-2022, 07:47 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)