Hello, following purchasing and reviewing the book, I have a few questions.
Most samples utilize the Espressive provided Web Server implementation which is very basic. I have only seen one or two samples using the AsyncWebServer library. I am using the AsyncWebServer library in my projects and very happy with it.
Why most samples are not using this impressive library?
Is it becuase it takes more memory (any details?) or becuase it performs slower (any details?) or maybe something else?
I will highly appreciate your explanation.
Thanks, Motti
Hi Motti.
The video streaming web server and the way the image is decoded and sent to the client was developed using the other Web Server library. At the moment, the AsyncWebServer library didn’t have any example implemented with those functionalities. Otherwise, we would have used only the AsyncWebServer library.
Regards,
Sara
Hi Sara,
Thanks for your reply.
In module 4, unit 2, of the ESP32-CAM projects book, you are using the AsyncWebServer library. Based on reading your building ESP32 web server book, I switched to that library and it works well for me. I also developed my own WiFi manager with my own enhancements, including my own OTA (the one you are using in the book does not look nicely integrated as it forces the ElegantOTA logo).
I have tried to understand the sample code from module 4 unit 2, and I see that you are going into the AsyncWebServer library’s non-documented internals, modifying internal parameters, etc. Also, the way the video stream is being sent to the web client is not explained in the book.
Can you please help and point me to documentation about (1) How the video stream is being handled and sent to the web client, and (2) Explanation about your use of the AsyncWebServer library internals?
I will very highly appreciate that.
Thanks a lot, Motti
I have that book (ESP32-CAM Projects) and I don’t see where the code is using “AsyncWebServer library’s non-documented internals, modifying internal parameters, etc”. Maybe I have a newer version? All I see is the code using API’s provided by the library. Could you point out exactly where the code is doing what you are saying? All libraries abstract the internal code to useful API’s to make using the ESP32 easier.
The documentation for the camera comes directly from Espressif’s Github. Documentation for AsyncWebServer’s Github.
Hi Steve,
I am referring to the new defined class: class AsyncJpegStreamResponse: public AsyncAbstractResponse {…
The code inside accesses internal AyncWebServer variables (_callback, _code, _contentLength, _contentType, _sendContentLength, _chunked), re-implements internal functions (e.g. _sourceValid), etc.
Best would be to only call exposed APIs and there should be a good reason for bypassing that and going internally. I was asking about that and about how the images are being transferred (the mechanism).
Thanks, Motti
To me it looks like Rui is extending the class to do what he wants. This is one of the things you can do in C++. As the class is protected you can grab internal variables and override functions. It somewhat looks like the code Espressif themselves wrote to do the same sort of thing except Rui is using the AsyncWebServer library.
I will leave it to Rui to explain what/why he is doing there.
Yes, that is what is being done.
Rui/Sara, is it possible for you to explain the code? Thanks!
Hi Motti.
I’m sorry for the delay in my response (I was out of the office).
That example was based on this example provided by the AsyncWebServer library developer:
So, we’ve just copied that implemented class and used it to send the video streaming.
We needed to copy the class because it is not implemented in the library by default.
Is there any specific section of that class that you want to know more about?
You can also try to post a question in the link that I\’ve sent you.
Regards, Sara
Hi Sara,
Thanks for your answer.
Issue is that either the original source you linked to and your version of the code does not explain what is being done in the code, how the image/video is being transferred over HTTP (the protocol), etc. I assumed that the book will go into details about image and video transfer, etc. but it is not. That is what I am missing. Is it possible for you to add such explanation?
I also tried to implement video transfer using the WebSocket plug-in of AsyncWebServer (I assumed that the WebSocket protocol puts less load as it goes directly to TCP without the HTTP overhead) and as it looks, the plug-in is buggy when trying to transfer large amount of data (e.g. video) and keeps crashing… I also found similar complaints on the Internet and people complaining that the library author does not maintain it and it is old…not good at all!
So I will highly appreciate your help with:
(1) Explanation of image and video transfer protocol over HTTP
In your experience,
(2) What is the speediest way to safely transfer video over the network (HTTP, WebSocket, etc.)?
(3) What library do you recommend that provides the best speed and stability for both HTTP and WebSocket (AsyncWebServer, Espressif httpd library, etc.)?
Thanks a lot, Motti
Hello Motti,
1) We’ll definitely consider adding an in-detph explanation on how the image is transferred (not video) over HTTP in a future eBook update. Thanks for the suggestion.
At the moment, even though all the functions are defined in your code, you can think of it like a library (so you shouldn’t change the methods that generate and send the stream of images).
2) we haven’t tested it for speed, but I think both methods are fairly similar. It usually more important if your ESP32-CAM is fairly close to your router or has an antenna to ensure faster response to the client.
3) I think they both provide approximate speed, but the Espressif httpd library is currently my preferred method due to more support and development.
You may like to look into RTSP. There is a library available and an example. The only issue is you need to use an RTSP client like VLC. Other issues seem to be with available memory which limits frame size and horsepower which limits frame rate.
Thanks Rui and Steve for answering!
Hi Rui,
I chose the AsyncWebServer and using it extensively following reading your ESP32 Web Server book… From your answer above I understand that even though that book uses the AsyncWebServer, you prefer using the Espressif httpd server. I will look into that and if it does work good, I will probably switch to using it, as the AsyncWebServer WebSocket plug-in is buggy and only usable if you transfer a small amount of data (it can’t send a stream of images reliably).
Hi Steve,
The info you sent looks interesting. I will research it.