Skip to content

Commit 02af003

Browse files
committed
Merge branch 'feature/add_webrtc_solution_code' into 'main'
esp-webrtc_solution: Add webrtc solutions code See merge request adf/esp-webrtc-solution!1
2 parents 7c07147 + 34079a7 commit 02af003

File tree

206 files changed

+35466
-86
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+35466
-86
lines changed

.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.config
2+
*.o
3+
*.pyc
4+
5+
# gtags
6+
GTAGS
7+
GRTAGS
8+
GPATH
9+
10+
# emacs
11+
.dir-locals.el
12+
13+
# emacs temp file suffixes
14+
*~
15+
.#*
16+
\#*#
17+
# MacOS directory files
18+
.DS_Store
19+
20+
# eclipse setting
21+
.settings
22+
23+
# Example project files
24+
25+
**/sdkconfig
26+
**/sdkconfig.old
27+
**/build
28+
**/managed_components
29+
**/dependencies.lock
30+
**/dist
31+
32+
# gcov coverage reports
33+
*.gcda
34+
*.gcno
35+
coverage.info
36+
coverage_report/
37+
38+
.vscode

README.md

Lines changed: 17 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,24 @@
1-
# esp-webrtc-solution
1+
# esp_webrtc_solution
22

3+
## Introduction
34

5+
This repository provides everything needed to build a WebRTC application.
6+
It includes the `esp_webrtc` core code along with its dependent components, such as:
7+
- **`esp_capture`**: For capturing media data
8+
- **`av_render`**: For playing media data
49

5-
## Getting started
10+
Additionally, the repository contains three simple demo applications that demonstrate how to use `esp_webrtc`.
611

7-
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
12+
## Solutions
813

9-
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
14+
### 1. OpenAI Realtime Communication Solution
15+
This demo establishes a WebRTC connection to an OpenAI server for real-time communication.
16+
It showcases how to use a customized signaling mechanism to build specialized WebRTC applications.
1017

11-
## Add your files
18+
### 2. Doorbell Solution
19+
This demo implements a doorbell application that can:
20+
- Be controlled in real-time by a browser or phone
21+
- Send real-time video data to a controller while supporting two-way audio communication
1222

13-
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15-
16-
```
17-
cd existing_repo
18-
git remote add origin https://gitlab.espressif.cn:6688/adf/esp-webrtc-solution.git
19-
git branch -M main
20-
git push -uf origin main
21-
```
22-
23-
## Integrate with your tools
24-
25-
- [ ] [Set up project integrations](https://gitlab.espressif.cn:6688/adf/esp-webrtc-solution/-/settings/integrations)
26-
27-
## Collaborate with your team
28-
29-
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33-
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34-
35-
## Test and Deploy
36-
37-
Use the built-in continuous integration in GitLab.
38-
39-
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40-
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41-
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42-
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44-
45-
***
46-
47-
# Editing this README
48-
49-
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
50-
51-
## Suggestions for a good README
52-
53-
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
54-
55-
## Name
56-
Choose a self-explaining name for your project.
57-
58-
## Description
59-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
60-
61-
## Badges
62-
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
63-
64-
## Visuals
65-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
66-
67-
## Installation
68-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
69-
70-
## Usage
71-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
72-
73-
## Support
74-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
75-
76-
## Roadmap
77-
If you have ideas for releases in the future, it is a good idea to list them in the README.
78-
79-
## Contributing
80-
State if you are open to contributions and what your requirements are for accepting them.
81-
82-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
83-
84-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
85-
86-
## Authors and acknowledgment
87-
Show your appreciation to those who have contributed to the project.
88-
89-
## License
90-
For open source projects, say how it is licensed.
91-
92-
## Project status
93-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
23+
### 3. Peer Demo
24+
This demo mainly show how to use `esp_peer` API to buildup a WebRTC application from scratch.

components/av_render/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
list (APPEND COMPONENT_SRCDIRS ./src)
3+
4+
set(COMPONENT_ADD_INCLUDEDIRS ./include)
5+
6+
set(COMPONENT_PRIV_REQUIRES media_lib_sal esp_timer esp_audio_codec esp_video_codec)
7+
8+
register_component()

components/av_render/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# AV_Render
2+
3+
`AV_Render` is a simple player designed for video and audio playback. It primarily supports "push" playback model, where the user first provides stream information and then pushes the stream data to `av_render`. The player checks the input stream's codec and uses appropriate audio and video decoders for processing. The decoded output frame data is sent to the corresponding renderer for final output (e.g., audio playback via codec, video playback on LCD).
4+
5+
## Abstraction
6+
7+
### Render Implementations
8+
9+
Users can select the appropriate renderer based on their specific use case. We also provide default implementations for common scenarios, such as:
10+
11+
- **Audio Rendering:** `av_render_alloc_i2s_render` — outputs audio through I2S.
12+
- **Video Rendering:** `av_render_alloc_lcd_render` — renders video through `esp_lcd`.
13+
14+
## Simple Usage
15+
16+
The overall flow for audio and video playback is as follows:
17+
18+
1. `av_render_open`
19+
2. `av_render_add_audio_stream`
20+
3. `av_render_add_video_stream`
21+
4. `av_render_add_audio_data`
22+
5. `av_render_add_video_data`
23+
6. `av_render_close`
24+
25+
### Resetting the Playback
26+
27+
If you want to clear the current stream and start a new one, call `av_render_reset`.
28+
29+
### Resource usage
30+
31+
Users can configure resource usage more precisely to meet their specific needs. This includes options such as whether an additional thread is required for decoding, as well as how much data can be buffered by the decoder and renderer.
32+
33+
To customize these settings, you can use the `av_render_cfg_t` configuration structure or the following API functions:
34+
35+
- `av_render_config_audio_fifo` — Configure the audio buffer size for the decoder and renderer.
36+
- `av_render_config_video_fifo` — Configure the video buffer size for the decoder and renderer.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## IDF Component Manager Manifest File
2+
dependencies:
3+
espressif/esp_audio_codec: "*"
4+
espressif/esp_video_codec: "*"
5+
espressif/esp_audio_effects: "*"
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* ESPRESSIF MIT License
3+
*
4+
* Copyright (c) 2025 <ESPRESSIF SYSTEMS (SHANGHAI) CO., LTD>
5+
*
6+
* Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case,
7+
* it is free of charge, to any person obtaining a copy of this software and associated
8+
* documentation files (the "Software"), to deal in the Software without restriction, including
9+
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
11+
* to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all copies or
14+
* substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18+
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19+
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20+
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21+
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
*
23+
*/
24+
#pragma once
25+
26+
#include "av_render_types.h"
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
/**
33+
* @brief Audio decoder frame callback
34+
*
35+
* @param[in] frame Decoded audio frame
36+
* @param[in] ctx Decoder context set by user
37+
*
38+
* @return
39+
* - 0 On success
40+
* - Others Fail to decode
41+
*/
42+
typedef int (*adec_frame_cb)(av_render_audio_frame_t *frame, void *ctx);
43+
44+
/**
45+
* @brief Audio decoder configuration
46+
*/
47+
typedef struct {
48+
av_render_audio_info_t audio_info; /*!< Audio information */
49+
adec_frame_cb frame_cb; /*!< Decoded frame callback */
50+
void *ctx; /*!< Decoder context */
51+
} adec_cfg_t;
52+
53+
/**
54+
* @brief Audio decoder handle
55+
*/
56+
typedef void *adec_handle_t;
57+
58+
/**
59+
* @brief Open audio decoder
60+
*
61+
* @param[in] cfg Audio decoder configuration
62+
*
63+
* @return
64+
* - NULL No memory for decoder instance
65+
* - Others On success
66+
*/
67+
adec_handle_t adec_open(adec_cfg_t *cfg);
68+
69+
/**
70+
* @brief Decode audio
71+
*
72+
* @param[in] h Audio decoder handle
73+
* @param[in] data Audio data to be decoded
74+
*
75+
* @return
76+
* - 0 On success
77+
* - Others Fail to decode
78+
*/
79+
int adec_decode(adec_handle_t h, av_render_audio_data_t *data);
80+
81+
/**
82+
* @brief Get decoded audio frame information
83+
*
84+
* @param[in] h Audio decoder handle
85+
* @param[out] frame_info Audio frame information
86+
*
87+
* @return
88+
* - 0 On success
89+
* - Others Fail to decode
90+
*/
91+
int adec_get_frame_info(adec_handle_t h, av_render_audio_frame_info_t *frame_info);
92+
93+
/**
94+
* @brief Close audio decoder
95+
*
96+
* @param[in] h Audio decoder handle
97+
*
98+
* @return
99+
* - 0 On success
100+
* - Others Fail to decode
101+
*/
102+
int adec_close(adec_handle_t h);
103+
104+
#ifdef __cplusplus
105+
}
106+
#endif

0 commit comments

Comments
 (0)