-
Notifications
You must be signed in to change notification settings - Fork 362
Support for Espressif chipsets via ESP-IDF #2142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release-v1.14.0
Are you sure you want to change the base?
Support for Espressif chipsets via ESP-IDF #2142
Conversation
d9ab49b
to
b3e9d05
Compare
@sirknightj @unicornss do you have comments on this? I would like to speed up the porting process as per your comments, so that the repo can then be used in-time for ESP-IDF based open-source solutions, viz., esp-rainmaker and esp-matter etc. |
4ff89b5
to
b96ece0
Compare
You may want to review the reference integration for the Realtek Ameba Pro2 Mini board at: https://github.com/awslabs/freertos-webrtc-reference-on-amebapro-for-amazon-kinesis-video-streams. This reference integration utilizes our OS-agnostic libraries. You can adopt a similar approach to develop an integration for the ESP platform. |
This solution in my particular PR is the working one. Only requiring the discussion on the final structure of the code to make it acceptable. The approach you have shared is completely different take from what I've achieved. The particular ameba implementation does not use this repo, and hence I cannot go yet another implementation approach using multiple components. My goal is to get this repo adopted on ESP platforms and make the existing sources/APIs generic enough as is to be able to be used for ESP chipsets. |
6ad13b1
to
7f787a0
Compare
278e573
to
ea74bf0
Compare
### Install pkg-config | ||
|
||
```bash | ||
sudo apt-get install pkg-config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would recommend adding the sudo apt-get update
step just in case.
- AWS_KVS_LOG_LEVEL | ||
|
||
- You may override the above settings in `main/app_main.c` file of the example also. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest also adding the commands to use the idf.py to:
- Connect the board to your computer (micro usb)
- Build the project
- Flash project onto the ESP board (and any buttons that need to be pressed or held down during the flash, any LED indicators that we can look for)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also some links to troubleshooting documentation in case there is something blocking USB access in the computer (the board is not reachable)
|
||
- ESP_WIFI_SSID | ||
- ESP_WIFI_PASSWORD | ||
- ESP_MAXIMUM_RETRY |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the majority of the fields here are self explanatory, except ESP_MAXIMUM_RETRY.
Perhaps we can make a table with the options along with a description.
@@ -0,0 +1,92 @@ | |||
@startuml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw this which you might want to look at -- to get these displayed in one of the readmes: https://github.com/Zingam/UML-in-Markdown
Alternatively, GitHub supports mermaid diagrams - https://github.blog/developer-skills/github/include-diagrams-markdown-files-mermaid/
- AWS_SECRET_ACCESS_KEY | ||
- AWS_DEFAULT_REGION | ||
- AWS_KVS_CHANNEL | ||
- AWS_KVS_LOG_LEVEL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw some sample frames in one of the folders, would it make sense to have an option to use the camera sensor vs. pre-generated frames?
frame.frameData = pSampleConfiguration->pVideoFrameBuffer; | ||
frame.size = frameSize; | ||
|
||
CHK_STATUS(app_media_read_frame_from_disk(frame.frameData, &frameSize, filePath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the frames being read from here
- Handle partial writes by sending data in multiple iterations - Use retries when message send fails - Track and handle message receive if in parts using `receiveMessage` var
- Retries increased from 3 to 10 - Consider ENOMEM or PBUF errors also for retries These changes help to retain sockets longer for embedded devices
- Use dynamically allocated WSS URL - Use dynamic allocations for singaling payload - Use required only allocations in LwsApiCalls instead large static arrays
- Added ifaddr altenate for ESP-IDF - Created abstracted API for IDF_CMAKE platform to query local IP - Do not treat SO_SNDBUF not available as fatal
- Use custom thread implementation for receiveLwsMessageWrapper - Custom thread implementation for connectionListener
- esp_hosted + esp_wifi_remote enabled chipsets not having wifi/BT to use it via n/w adapter - network_coprocessor component can be use with network_adapter
- Cleanly added the support under esp_port directory - Added ESP specific components, submodules and an webrtc_classic example - Added `app_common` needed as a common functionality for webrtc example/s. - Added network_adapter example: Needed when we want to use the webrtc_classic on P4+C6 board
- Added esp_websocket_client over libwebsockets for ESP-IDF - Using this as default for ESP port as it provides better flexibility for ESP-IDF
- It helps packing and unpacking of signaling messages - These serialized messages then can be transfered on any transport
- Added streaming_only and signaling_only examples - streaming_only can be flashed on P4 and signaling only on C6 - The message exchange between the two happens over webrtc_bridge
- esp_port/README.md: Added complete description and setup guide for ESP chipsets - esp_port/README.md: Describe two solutions: webrtc_classic and split mode - Added puml diagrams under esp_port/docs showcasing the workflow in both modes - Added a README under example/app_common/spiffs/certs/
- Patch1: Support LWIP in split_mode. Allows port filtering in lwip_opts.h - Patch2: Work-around for STATUS define. KVS too uses `STATUS` for return values. Guard the IDF STATUS under `#ifndef STATUS`
- e.g., config structure can be inited with most common config and fine tuned thereon ```c WebRtcAppConfig webrtcConfig = WEBRTC_APP_CONFIG_DEFAULT(); ``` - Bugfix: make a copy of `awsCredentialOptions` so that it can be re-used out of scope
…webrtcAppRun - This allows us keep webrtcAppInit lighter and move webrtcAppRun to different task
… examples as well
- Application should not need to take care of fitting the message received from webrtc_bridge into SDK's structure format - The message will simply be deserialized and passed to SDK using `webrtcAppSignalingMessageReceived` API - Messages from SDK are received via callback and we can send to webrtc_bridge from application - hosted: Fixed build for IDF release/v5.5
…leio - This is helpful where our cert files are actually in NVS - Also updated the README for esp_webrtc_utils component - app_webrtc.c: Use fileIO wrapper functions instead of direct file ops
…ient - We simply store the server time globally when we do http requests - Use that gloabal time for aws signature and Date header while websocket connect
- Can be useful for provisioning workflows OR any other use cases where host needs BT
- Aggressive timeout makes board reboot prematurely. - Wait for max 10 seconds before SDIO transport is ready
- New API `webrtcAppCreateAndSendOffer`, can be called to initiate the offer - Also, spin the mediaSender thread in handlerAnswer
- Works in Viewer mode of KVS WebRTC - The camera registers to a room and initiates the sdp offer - The client can join the room(this sends the sdp answer to camera) - peer connection is established and feed can be viewed
- TURN servers are not `MUST` for the peer connection - The device can still continue with the STUN server - In cases where, server is configured to not allow IceServers, we can continue
- Application should not need to take care of fitting the message received from webrtc_bridge into SDK's structure format - The message will simply be deserialized and passed to SDK using `webrtcAppSignalingMessageReceived` API - Messages from SDK are received via callback and we can send to webrtc_bridge from application
- New API `webrtcAppCreateAndSendOffer`, can be called to initiate the offer - Also, spin the mediaSender thread in handlerAnswer
- Attempt reconnections from webrtc task when disconnections happen - Reconnections are handled with new task in LwsApiCalls.c - Workflow was broken with LwsApiCallsESP.c: We now handle it from webrtc_task itself - Do not reboot the device when using wifi-set CLI command
ea74bf0
to
f65eeca
Compare
*** This is a placeholder PR: Not to be merged ****
This PR is meant to showcase the work which will bring the support for ESP-IDF build support and hence the Espressif chipsets.
Structure:
esp_port
directory.Setup ESP-IDF
Setup ESP_IDF with release/v5.4 branch: https://docs.espressif.com/projects/esp-idf/en/stable/esp32/get-started/linux-macos-setup.html
BUILD
Flash the code on chip and run monitor
The work is under progress, will keep rebasing as and when common functionality code keeps getting into main repository.
@sirknightj @unicornss
We have two options:
esp_port
maintained by Espressif with some suitable name under espressif/ organisation. It will useamazon-kinesis-video-sdk-c
as a submodule or need developer to set path of cloned repo.We can keep this PR for discussion ground continue discussion on other aspects of how best we can go about this. I prefer the option 1, simply because it remains maintained under single roof without needing to constant rebasing.