├── .codespellrc ├── .gitignore ├── .gitlab-ci.yml ├── .gitlab └── ci │ ├── build_webrtc_solutions.yml │ ├── common.yml │ ├── deploy.yml │ ├── pre_check.yml │ └── rules.yml ├── .pre-commit-config.yaml ├── README.md ├── components ├── av_render │ ├── CMakeLists.txt │ ├── README.md │ ├── idf_component.yml │ ├── include │ │ ├── audio_decoder.h │ │ ├── audio_render.h │ │ ├── audio_resample.h │ │ ├── av_render.h │ │ ├── av_render_default.h │ │ ├── av_render_types.h │ │ ├── video_decoder.h │ │ └── video_render.h │ ├── libs │ │ └── esp32p4 │ │ │ └── libesp_image_i420_2_rgb565le.a │ ├── render_impl │ │ ├── CMakeLists.txt │ │ ├── i2s_render.c │ │ ├── idf_component.yml │ │ └── lcd_render.c │ └── src │ │ ├── audio_decoder.c │ │ ├── audio_render.c │ │ ├── audio_resample.c │ │ ├── av_render.c │ │ ├── color_convert.c │ │ ├── color_convert.h │ │ ├── video_decoder.c │ │ └── video_render.c ├── codec_board │ ├── CHANGELOG.md │ ├── CMakeLists.txt │ ├── LICENSE │ ├── README.md │ ├── board_cfg.txt │ ├── cfg_parse.c │ ├── codec_board.c │ ├── codec_init.c │ ├── drv │ │ ├── tca9554.c │ │ └── tca9554.h │ ├── dummy_codec.c │ ├── dummy_codec.h │ ├── idf_component.yml │ ├── include │ │ ├── codec_board.h │ │ └── codec_init.h │ └── lcd_init.c ├── esp_capture │ ├── CMakeLists.txt │ ├── README.md │ ├── idf_component.yml │ ├── include │ │ ├── esp_capture.h │ │ ├── esp_capture_audio_enc.h │ │ ├── esp_capture_defaults.h │ │ ├── esp_capture_path_simple.h │ │ ├── esp_capture_text_overlay.h │ │ ├── esp_capture_types.h │ │ └── esp_capture_video_enc.h │ ├── interface │ │ ├── esp_capture_aenc_if.h │ │ ├── esp_capture_audio_src_if.h │ │ ├── esp_capture_overlay_if.h │ │ ├── esp_capture_path_if.h │ │ ├── esp_capture_venc_if.h │ │ └── esp_capture_video_src_if.h │ └── src │ │ ├── esp_capture.c │ │ ├── esp_capture_sync.c │ │ ├── esp_capture_sync.h │ │ ├── impl │ │ ├── capture_audio_enc │ │ │ ├── CMakeLists.txt │ │ │ ├── capture_audio_enc.c │ │ │ └── idf_component.yml │ │ ├── capture_audio_src │ │ │ ├── CMakeLists.txt │ │ │ ├── capture_aud_aec_src.c │ │ │ ├── capture_audio_codec_src.c │ │ │ └── idf_component.yml │ │ ├── capture_file_src │ │ │ ├── capture_audio_file_src.c │ │ │ └── capture_video_file_src.c │ │ ├── capture_simple_path │ │ │ └── esp_capture_path_simple.c │ │ ├── capture_text_overlay │ │ │ ├── CMakeLists.txt │ │ │ ├── Kconfig │ │ │ ├── esp_capture_text_overlay.c │ │ │ ├── esp_painter_font.h │ │ │ ├── font │ │ │ │ ├── basic_font_12.c │ │ │ │ ├── basic_font_16.c │ │ │ │ ├── basic_font_20.c │ │ │ │ ├── basic_font_24.c │ │ │ │ ├── basic_font_28.c │ │ │ │ ├── basic_font_32.c │ │ │ │ ├── basic_font_36.c │ │ │ │ ├── basic_font_40.c │ │ │ │ ├── basic_font_44.c │ │ │ │ └── basic_font_48.c │ │ │ └── idf_component.yml │ │ ├── capture_video_enc │ │ │ ├── CMakeLists.txt │ │ │ ├── capture_video_enc.c │ │ │ └── idf_component.yml │ │ └── capture_video_src │ │ │ ├── CMakeLists.txt │ │ │ ├── capture_video_dvp_src.c │ │ │ ├── capture_video_v4l2_src.c │ │ │ └── idf_component.yml │ │ ├── share_q.c │ │ └── share_q.h ├── esp_webrtc │ ├── CMakeLists.txt │ ├── README.md │ ├── idf_component.yml │ ├── impl │ │ ├── apprtc_signal │ │ │ ├── CMakeLists.txt │ │ │ ├── https_client.c │ │ │ ├── https_client.h │ │ │ └── signal_default.c │ │ ├── peer_default │ │ │ ├── CHANGELOG.md │ │ │ ├── CMakeLists.txt │ │ │ ├── idf_component.yml │ │ │ ├── include │ │ │ │ └── esp_peer_default.h │ │ │ └── libs │ │ │ │ ├── esp32 │ │ │ │ └── libpeer_default.a │ │ │ │ ├── esp32p4 │ │ │ │ └── libpeer_default.a │ │ │ │ ├── esp32s2 │ │ │ │ └── libpeer_default.a │ │ │ │ └── esp32s3 │ │ │ │ └── libpeer_default.a │ │ └── whip_signal │ │ │ ├── include │ │ │ └── esp_peer_whip_signaling.h │ │ │ └── whip_signaling.c │ ├── include │ │ ├── esp_peer.h │ │ ├── esp_peer_signaling.h │ │ ├── esp_peer_types.h │ │ ├── esp_webrtc.h │ │ ├── esp_webrtc_defaults.h │ │ └── esp_webrtc_version.h │ └── src │ │ ├── esp_peer.c │ │ ├── esp_peer_signaling.c │ │ ├── esp_webrtc.c │ │ └── esp_webrtc_version.c ├── media_lib_sal │ ├── CMakeLists.txt │ ├── Kconfig.projbuild │ ├── component.mk │ ├── idf_component.yml │ ├── include │ │ ├── data_queue.h │ │ ├── media_lib_crypt.h │ │ ├── media_lib_err.h │ │ ├── media_lib_mem_trace.h │ │ ├── media_lib_netif.h │ │ ├── media_lib_os.h │ │ ├── media_lib_socket.h │ │ ├── media_lib_tls.h │ │ ├── msg_q.h │ │ └── port │ │ │ ├── media_lib_adapter.h │ │ │ ├── media_lib_crypt_reg.h │ │ │ ├── media_lib_netif_reg.h │ │ │ ├── media_lib_os_reg.h │ │ │ ├── media_lib_socket_reg.h │ │ │ └── media_lib_tls_reg.h │ ├── media_lib_adapter.c │ ├── media_lib_common.c │ ├── media_lib_common.h │ ├── media_lib_crypt.c │ ├── media_lib_netif.c │ ├── media_lib_os.c │ ├── media_lib_socket.c │ ├── media_lib_tls.c │ ├── mem_trace │ │ ├── README.md │ │ ├── media_lib_mem_his.c │ │ ├── media_lib_mem_his.h │ │ ├── media_lib_mem_trace.c │ │ └── mem_trace.pl │ └── port │ │ ├── data_queue.c │ │ ├── media_lib_crypt_default.c │ │ ├── media_lib_netif_default.c │ │ ├── media_lib_os_freertos.c │ │ ├── media_lib_socket_default.c │ │ ├── media_lib_tls_default.c │ │ └── msg_q.c └── webrtc_utils │ ├── CMakeLists.txt │ ├── webrtc_utils_time.c │ └── webrtc_utils_time.h ├── conftest.py ├── solutions ├── common │ ├── CMakeLists.txt │ ├── Kconfig │ ├── idf_component.yml │ ├── media_sys.h │ ├── network.c │ ├── network.h │ ├── patch_idf.pl │ ├── sys_state.c │ └── sys_state.h ├── doorbell_demo │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── board.c │ │ ├── common.h │ │ ├── idf_component.yml │ │ ├── join.aac │ │ ├── main.c │ │ ├── media_sys.c │ │ ├── open.aac │ │ ├── ring.aac │ │ ├── settings.h │ │ └── webrtc.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── doorbell_local │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── board.c │ │ ├── certs │ │ │ ├── prvtkey.pem │ │ │ └── servercert.pem │ │ ├── common.h │ │ ├── idf_component.yml │ │ ├── join.aac │ │ ├── main.c │ │ ├── media_sys.c │ │ ├── open.aac │ │ ├── ring.aac │ │ ├── settings.h │ │ ├── webrtc.c │ │ ├── webrtc_http_server.c │ │ ├── webrtc_http_server.h │ │ └── webrtc_test.html │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── openai_demo │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── board.c │ │ ├── common.h │ │ ├── idf_component.yml │ │ ├── main.c │ │ ├── media_sys.c │ │ ├── openai_signaling.c │ │ ├── settings.h │ │ └── webrtc.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── peer_demo │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── common.h │ │ ├── idf_component.yml │ │ ├── main.c │ │ ├── settings.h │ │ └── webrtc.c │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 ├── videocall_demo │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ │ ├── CMakeLists.txt │ │ ├── board.c │ │ ├── common.h │ │ ├── idf_component.yml │ │ ├── main.c │ │ ├── media_sys.c │ │ ├── ring.aac │ │ ├── settings.h │ │ └── webrtc.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ └── sdkconfig.defaults.esp32p4 └── whip_demo │ ├── CMakeLists.txt │ ├── README.md │ ├── main │ ├── CMakeLists.txt │ ├── board.c │ ├── common.h │ ├── idf_component.yml │ ├── main.c │ ├── media_sys.c │ ├── settings.h │ └── webrtc.c │ ├── partitions.csv │ ├── sdkconfig.defaults │ ├── sdkconfig.defaults.esp32p4 │ └── sdkconfig.defaults.esp32s3 └── tools ├── build_apps.pl ├── ci └── utils.sh └── gen_ci.py /.codespellrc: -------------------------------------------------------------------------------- 1 | [codespell] 2 | skip = build,*.yuv,alice.txt,*.rgb 3 | ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart,wheight,wel,ot 4 | write-changes = true 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 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 39 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | stages: 2 | - pre_check 3 | - build 4 | - deploy 5 | 6 | variables: 7 | GIT_STRATEGY: clone 8 | GET_SOURCES_ATTEMPTS: "10" 9 | ARTIFACT_DOWNLOAD_ATTEMPTS: "10" 10 | GIT_SUBMODULE_STRATEGY: none 11 | IDF_SKIP_CHECK_SUBMODULES: 1 12 | GIT_DEPTH: 1 13 | 14 | .common_before_scripts: &common-before_scripts | 15 | source tools/ci/utils.sh 16 | 17 | .setup_tools_and_idf_python_venv: &setup_tools_and_idf_python_venv | 18 | # must use after setup_tools_except_target_test 19 | # otherwise the export.sh won't work properly 20 | 21 | # Install esp-clang if necessary 22 | if [[ "$IDF_TOOLCHAIN" == "clang" ]]; then 23 | $IDF_PATH/tools/idf_tools.py --non-interactive install esp-clang 24 | fi 25 | 26 | source $IDF_PATH/export.sh 27 | 28 | .before_script:build: 29 | before_script: 30 | - *common-before_scripts 31 | - *setup_tools_and_idf_python_venv 32 | 33 | include: 34 | - '.gitlab/ci/rules.yml' 35 | - '.gitlab/ci/common.yml' 36 | # - '.gitlab/ci/pre_check.yml' 37 | - '.gitlab/ci/build_webrtc_solutions.yml' 38 | - '.gitlab/ci/deploy.yml' 39 | -------------------------------------------------------------------------------- /.gitlab/ci/build_webrtc_solutions.yml: -------------------------------------------------------------------------------- 1 | .build_templates: &build_templates 2 | stage: build 3 | tags: 4 | - build 5 | image: espressif/idf:latest 6 | variables: 7 | # Enable ccache for all build jobs. See configure_ci_environment.sh for more ccache related settings. 8 | IDF_CCACHE_ENABLE: "1" 9 | BATCH_BUILD: "1" 10 | V: "0" 11 | WARNING_STR: "" 12 | 13 | .build_solutions: 14 | extends: 15 | - .build_templates 16 | artifacts: 17 | expire_in: 4 days 18 | paths: 19 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/size.json 20 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/build_log.txt 21 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/*.bin 22 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/*.elf 23 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/flasher_args.json 24 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/flash_project_args 25 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/config/sdkconfig.json 26 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/sdkconfig 27 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/bootloader/*.bin 28 | - ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/partition_table/*.bin 29 | script: 30 | - export OPENAI_API_KEY=FAKE_KEY_FOR_BUILD_ONLY 31 | - cd $IDF_PATH 32 | - perl ${CI_PROJECT_DIR}/tools/build_apps.pl ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER $IDF_TARGET 33 | 34 | build_matrix: 35 | extends: .build_solutions 36 | parallel: 37 | matrix: 38 | - CI_BUILD_FOLDER: ["doorbell_demo"] 39 | IDF_TARGET: ["esp32p4", "esp32s3"] 40 | - CI_BUILD_FOLDER: ["openai_demo"] 41 | IDF_TARGET: ["esp32s3"] 42 | - CI_BUILD_FOLDER: ["peer_demo"] 43 | IDF_TARGET: ["esp32", "esp32s2", "esp32s3"] 44 | - CI_BUILD_FOLDER: ["videocall_demo"] 45 | IDF_TARGET: ["esp32p4"] 46 | - CI_BUILD_FOLDER: ["whip_demo"] 47 | IDF_TARGET: ["esp32p4"] 48 | - CI_BUILD_FOLDER: ["doorbell_local"] 49 | IDF_TARGET: ["esp32p4"] 50 | 51 | stages: 52 | - build 53 | 54 | variables: 55 | DOCKER_IMAGE: ${CI_DOCKER_REGISTRY}/esp-env-v5.4:1 56 | BASE_FRAMEWORK_PATH: "$CI_PROJECT_DIR/esp-idf" 57 | BASE_FRAMEWORK: "ssh://git@gitlab.espressif.cn:27227/espressif/esp-idf.git" 58 | IDF_VERSION_TAG: v5.4 59 | IDF_TAG_FLAG: false -------------------------------------------------------------------------------- /.gitlab/ci/common.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | DOCKER_IMAGE: ${CI_DOCKER_REGISTRY}/esp-env-v5.4:1 3 | BASE_FRAMEWORK_PATH: "$CI_PROJECT_DIR/esp-idf" 4 | BASE_FRAMEWORK: "ssh://git@gitlab.espressif.cn:27227/espressif/esp-idf.git" 5 | IDF_VERSION_TAG: v5.4 6 | IDF_TAG_FLAG: false 7 | 8 | .update_source: &update_source 9 | - source ${CI_PROJECT_DIR}/tools/ci/utils.sh 10 | - add_gitlab_ssh_keys 11 | - echo ${IDF_PATH} 12 | - cd ${IDF_PATH} 13 | - idf.py --version 14 | - fetch_idf_branch ${IDF_VERSION_TAG} 15 | - common_before_scripts 16 | - setup_tools_and_idf_python_venv 17 | - set_env_variable 18 | 19 | .build_template: 20 | stage: build 21 | image: ${CI_DOCKER_REGISTRY}/esp-env-v5.4:1 22 | tags: 23 | - multimedia_build 24 | before_script: 25 | - *update_source 26 | -------------------------------------------------------------------------------- /.gitlab/ci/deploy.yml: -------------------------------------------------------------------------------- 1 | push_to_github: 2 | stage: deploy 3 | rules: 4 | - if: 5 | '($CI_COMMIT_REF_NAME == "main" || 6 | $CI_COMMIT_BRANCH =~ /^release\/v/ || 7 | $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && 8 | $CI_PIPELINE_SOURCE != "schedule"' 9 | when: on_success 10 | image: $CI_DOCKER_REGISTRY/esp32-ci-env 11 | variables: 12 | GIT_STRATEGY: clone 13 | before_script: 14 | - echo "skip default before_script" 15 | script: 16 | - source ${CI_PROJECT_DIR}/tools/ci/utils.sh 17 | - add_github_ssh_keys 18 | - git fetch --unshallow 19 | - git remote remove github &>/dev/null || true 20 | - git remote add github ${TARGET_GITHUB_REPO} 21 | - push_to_github 22 | -------------------------------------------------------------------------------- /.gitlab/ci/rules.yml: -------------------------------------------------------------------------------- 1 | ############## 2 | # if anchors # 3 | ############## 4 | .if-web: &if-web 5 | if: '$CI_PIPELINE_SOURCE == "web"' 6 | 7 | .if-ref-main: &if-ref-main 8 | if: '$CI_COMMIT_REF_NAME == "main"' 9 | 10 | .if-trigger: &if-trigger 11 | if: '$CI_PIPELINE_SOURCE == "trigger"' 12 | 13 | .if-pipeline: &if-pipeline 14 | if: '$CI_PIPELINE_SOURCE == "pipeline"' 15 | 16 | .if-schedule: &if-schedule 17 | if: '$CI_PIPELINE_SOURCE == "schedule"' 18 | 19 | .if-merge_request_event: &if-merge_request_event 20 | if: '$CI_PIPELINE_SOURCE == "merge_request_event"' 21 | 22 | .if-open-merge-request: &if-open-merge-request 23 | if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && ($CI_PIPELINE_SOURCE == "push")' 24 | 25 | .if-dev-push: &if-dev-push 26 | if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && ($CI_PIPELINE_SOURCE == "push")' 27 | 28 | .if-protected: &if-protected 29 | if: '($CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/)' 30 | 31 | .if-label-unit_test: &if-label-unit_test 32 | if: '$BOT_LABEL_UNIT_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*unit_test(?:,[^,\n\r]+)*$/i' 33 | 34 | .if-label-example_test: &if-label-example_test 35 | if: '$BOT_LABEL_EXAMPLE_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example_test(?:,[^,\n\r]+)*$/i' 36 | 37 | .if-label-example: &if-label-example 38 | if: '$BOT_LABEL_EXAMPLE_TEST || $CI_MERGE_REQUEST_LABELS =~ /^(?:[^,\n\r]+,)*example(?:,[^,\n\r]+)*$/i' 39 | 40 | .if-idf-version-tag-v5-3: &if-idf-version-tag-v5-3 41 | if: '$IDF_VERSION_TAG == "v5.3"' 42 | variables: 43 | IMAGE: "$CI_DOCKER_REGISTRY/esp-env-v5.3:1" 44 | 45 | .rules:build:unit-test: 46 | rules: 47 | - <<: *if-protected 48 | - <<: *if-label-unit_test 49 | 50 | .rules:ref:main-schedule: 51 | rules: 52 | - <<: *if-ref-main 53 | - <<: *if-schedule 54 | 55 | .rules:ref:check-label: 56 | rules: 57 | - <<: *if-merge_request_event 58 | 59 | .rules:build:regular-board-idf-ver-tag: 60 | rules: 61 | - <<: *if-dev-push 62 | when: never 63 | - <<: *if-schedule 64 | when: never 65 | - <<: *if-idf-version-tag-v5-3 66 | 67 | .rules:build:non-regular-board-idf-ver-tag: 68 | rules: 69 | - <<: *if-dev-push 70 | when: never 71 | - <<: *if-merge_request_event 72 | when: never 73 | - <<: *if-idf-version-tag-v5-3 74 | 75 | .rules:build:protected-merge-requests-pipeline: 76 | rules: 77 | - <<: *if-trigger 78 | - <<: *if-pipeline 79 | - <<: *if-protected 80 | - <<: *if-merge_request_event 81 | 82 | .rules:build:protected-merge-requests: 83 | rules: 84 | - <<: *if-protected 85 | - <<: *if-merge_request_event 86 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | 4 | repos: 5 | - repo: https://github.com/codespell-project/codespell 6 | rev: v2.2.6 7 | hooks: 8 | - id: codespell 9 | 10 | - repo: https://github.com/pre-commit/pre-commit-hooks 11 | rev: v4.3.0 12 | hooks: 13 | - id: check-executables-have-shebangs 14 | - id: check-merge-conflict 15 | - id: double-quote-string-fixer 16 | - id: end-of-file-fixer 17 | types_or: [c, c++] 18 | - id: mixed-line-ending 19 | args: ['-f=lf'] 20 | types_or: [c, c++] 21 | - id: no-commit-to-branch 22 | name: Do not use more than one slash in the branch name 23 | args: ['--pattern', '^[^/]*/[^/]*/'] 24 | - id: no-commit-to-branch 25 | name: Do not use uppercase letters in the branch name 26 | args: ['--pattern', '^[^A-Z]*[A-Z]'] 27 | - id: trailing-whitespace 28 | types_or: [c, c++] 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # esp_webrtc_solution 2 | 3 | ## Introduction 4 | 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 9 | 10 | Additionally, the repository contains three several demo applications that demonstrate how to use `esp_webrtc`. 11 | 12 | ## Solutions 13 | 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. 17 | 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 22 | 23 | ### 3. Peer Demo 24 | This demo mainly show how to use `esp_peer` API to buildup a WebRTC application from scratch. 25 | 26 | ### 4. Video Call Solution 27 | This demo show how to use `esp_webrtc` data channel to build up video call application. 28 | 29 | ### 5. WHIP Publisher Solution 30 | This demo show how to use `esp_webrtc` to publish streaming data to WHIP server. 31 | 32 | ### 6. Doorbell Local Demo 33 | This demo sets up a local doorbell application that operates without external signaling servers. 34 | An ESP32 series board acts as the signaling server, allowing users to connect directly for WebRTC testing. 35 | -------------------------------------------------------------------------------- /components/av_render/CMakeLists.txt: -------------------------------------------------------------------------------- 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() 9 | 10 | # Add color convert ASM optimized lib 11 | IF (${IDF_TARGET} STREQUAL "esp32p4") 12 | set(TARGET_LIB_NAME "${CMAKE_CURRENT_SOURCE_DIR}/libs/${IDF_TARGET}/libesp_image_i420_2_rgb565le.a") 13 | target_link_libraries(${COMPONENT_TARGET} "-Wl,--start-group" ${TARGET_LIB_NAME} "-Wl,--end-group") 14 | ENDIF () 15 | -------------------------------------------------------------------------------- /components/av_render/README.md: -------------------------------------------------------------------------------- 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. 37 | -------------------------------------------------------------------------------- /components/av_render/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/esp_audio_codec: "~2.3.0" 4 | espressif/esp_video_codec: "~0.5.2" 5 | espressif/esp_audio_effects: "~1.1.0" 6 | -------------------------------------------------------------------------------- /components/av_render/include/audio_decoder.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 107 | -------------------------------------------------------------------------------- /components/av_render/include/audio_resample.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | 30 | #include "av_render_types.h" 31 | 32 | /** 33 | * @brief Audio resample handle 34 | */ 35 | typedef void *audio_resample_handle_t; 36 | 37 | /** 38 | * @brief Audio resample frame callback 39 | */ 40 | typedef int (*audio_resample_frame_cb)(av_render_audio_frame_t *frame, void *ctx); 41 | 42 | /** 43 | * @brief Audio resample configuration 44 | */ 45 | typedef struct { 46 | av_render_audio_frame_info_t input_info; /*!< Input frame information */ 47 | av_render_audio_frame_info_t output_info; /*!< Output frame information */ 48 | audio_resample_frame_cb resample_cb; /*!< Resample output callback */ 49 | void *ctx; /*!< User context */ 50 | } audio_resample_cfg_t; 51 | 52 | /** 53 | * @brief Open audio resample 54 | * 55 | * @param[in] cfg Audio resample configuration 56 | * 57 | * @return 58 | * - NULL No memory for resample instance 59 | * - Others Audio resample instance 60 | */ 61 | audio_resample_handle_t audio_resample_open(audio_resample_cfg_t *cfg); 62 | 63 | /** 64 | * @brief Write data to audio resample 65 | * 66 | * @param[in] h Audio resample handle 67 | * @param[in] data Data to be written 68 | * 69 | * @return 70 | * - ESP_MEDIA_ERR_OK On success 71 | * - ESP_MEDIA_ERR_NO_MEM No enough memory 72 | */ 73 | int audio_resample_write(audio_resample_handle_t h, av_render_audio_frame_t *data); 74 | 75 | /** 76 | * @brief Close audio resample 77 | * 78 | * @param[in] h Audio resample handle 79 | */ 80 | void audio_resample_close(audio_resample_handle_t h); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /components/av_render/include/av_render_default.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "av_render_types.h" 28 | #include "audio_render.h" 29 | #include "video_render.h" 30 | #include "esp_lcd_panel_ops.h" 31 | #include "esp_codec_dev.h" 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | /** 38 | * @brief Audio render reference callback 39 | */ 40 | typedef int (*audio_render_ref_cb)(uint8_t *data, int size, void *ctx); 41 | 42 | /** 43 | * @brief I2S render configuration 44 | */ 45 | typedef struct { 46 | esp_codec_dev_handle_t play_handle; /*!< Playback handle */ 47 | audio_render_ref_cb cb; /*!< Reference output callback */ 48 | bool fixed_clock; /*!< Fixed clock mode */ 49 | void *ctx; /*!< User context */ 50 | } i2s_render_cfg_t; 51 | 52 | /** 53 | * @brief LCD render configuration 54 | */ 55 | typedef struct { 56 | esp_lcd_panel_handle_t lcd_handle; /*!< LCD display handle */ 57 | bool rgb_panel; /*!< Whether RGB panel */ 58 | bool dsi_panel; /*!< Whether DSI panel */ 59 | bool use_frame_buffer; /*!< Use display frame buffer */ 60 | } lcd_render_cfg_t; 61 | 62 | /** 63 | * @brief Allocate I2S render 64 | * 65 | * @param[in] cfg I2S render configuration 66 | * 67 | * @return 68 | * - NULL No memory for I2S render instance 69 | * - Others Audio render instance 70 | */ 71 | audio_render_handle_t av_render_alloc_i2s_render(i2s_render_cfg_t *cfg); 72 | 73 | /** 74 | * @brief Allocate LCD render 75 | * 76 | * @param[in] cfg LCD render configuration 77 | * 78 | * @return 79 | * - NULL No memory for LCD render instance 80 | * - Others video render instance 81 | */ 82 | video_render_handle_t av_render_alloc_lcd_render(lcd_render_cfg_t *cfg); 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | -------------------------------------------------------------------------------- /components/av_render/libs/esp32p4/libesp_image_i420_2_rgb565le.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/components/av_render/libs/esp32p4/libesp_image_i420_2_rgb565le.a -------------------------------------------------------------------------------- /components/av_render/render_impl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | list (APPEND COMPONENT_SRCDIRS ./) 3 | set(COMPONENT_PRIV_REQUIRES esp_timer media_lib_sal esp_lcd driver) 4 | 5 | register_component() 6 | -------------------------------------------------------------------------------- /components/av_render/render_impl/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/esp_codec_dev: "~1.3.4" 4 | espressif/esp_audio_effects: "~1.1.0" 5 | av_render: 6 | path: ../ 7 | 8 | -------------------------------------------------------------------------------- /components/av_render/src/color_convert.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #ifndef COLOR_CONVERT_H 26 | #define COLOR_CONVERT_H 27 | 28 | #include "av_render_types.h" 29 | 30 | typedef void *color_convert_table_t; 31 | 32 | typedef struct { 33 | av_render_video_frame_type_t from; 34 | av_render_video_frame_type_t to; 35 | int width; 36 | int height; 37 | } color_convert_cfg_t; 38 | 39 | int convert_table_get_image_size(av_render_video_frame_type_t fmt, int width, int height); 40 | 41 | color_convert_table_t init_convert_table(color_convert_cfg_t *cfg); 42 | 43 | int convert_color(color_convert_table_t table, uint8_t *src, int src_size, uint8_t *dst, int dst_size); 44 | 45 | void deinit_convert_table(color_convert_table_t t); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /components/codec_board/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v0.5.4 4 | 5 | - Add PDM support 6 | - Add play and record support for `XD_AIOT_C3` and `ESP_SPOT` 7 | 8 | ## v0.5.3 9 | 10 | - Add support for mount SDCard on esp32 11 | - Add support for I2C manually control use `init_i2c` and `deinit_i2c` 12 | - Fixed I2S driver failed to initialized if more than one 13 | 14 | ## v0.5.0 15 | 16 | - Initial version of `codec_board` 17 | -------------------------------------------------------------------------------- /components/codec_board/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(COMPONENT_PRIV_REQUIRE driver esp_codec_dev fatfs esp_lcd) 3 | 4 | if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3") 5 | list(APPEND COMPONENT_PRIV_REQUIRE esp_driver_i2c) 6 | endif() 7 | 8 | if("${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}" VERSION_GREATER_EQUAL "5.3") 9 | list(APPEND COMPONENT_PRIV_REQUIRE esp_driver_i2c) 10 | endif() 11 | 12 | idf_component_register(SRCS "cfg_parse.c" "codec_board.c" "codec_init.c" "dummy_codec.c" 13 | "lcd_init.c" "drv/tca9554.c" 14 | INCLUDE_DIRS ./include 15 | PRIV_INCLUDE_DIRS drv 16 | REQUIRES "${COMPONENT_PRIV_REQUIRE}" 17 | EMBED_TXTFILES "board_cfg.txt") 18 | -------------------------------------------------------------------------------- /components/codec_board/LICENSE: -------------------------------------------------------------------------------- 1 | Espressif Modified MIT License 2 | 3 | Copyright (c) 2025 Espressif Systems (Shanghai) CO., LTD 4 | 5 | Permission is hereby granted for use EXCLUSIVELY with Espressif Systems products. 6 | This includes the right to use, copy, modify, merge, publish, distribute, and sublicense 7 | the Software, subject to the following conditions: 8 | 9 | 1. This Software MUST BE USED IN CONJUNCTION WITH ESPRESSIF SYSTEMS PRODUCTS. 10 | 2. The above copyright notice and this permission notice shall be included in all copies 11 | or substantial portions of the Software. 12 | 3. Redistribution of the Software in source or binary form FOR USE WITH NON-ESPRESSIF PRODUCTS 13 | is strictly prohibited. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 17 | PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 18 | FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 19 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | DEALINGS IN THE SOFTWARE. 21 | 22 | SPDX-License-Identifier: LicenseRef-Espressif-Modified-MIT 23 | -------------------------------------------------------------------------------- /components/codec_board/README.md: -------------------------------------------------------------------------------- 1 | # Codec_board 2 | 3 | ## Overview 4 | `codec_board` is a simple implementation of board support for a variety of ESP32 series boards. 5 | Its main purpose is to: 6 | - Gather board-specific peripheral settings from user. 7 | - Add drivers for the supported peripherals. 8 | - Provide high-level APIs to interact with the peripherals or abstract the peripherals into manageable handles. 9 | 10 | ## Supported Peripherals 11 | 12 | - **Codec** 13 | Currently support `ES8311`, `ES8388`, `ES7210`, `ES7243`, user can add other codec also. 14 | After `init_codec` is called, codec is abstracted into `esp_codec_dev` handle. 15 | Then use can use `esp_codec_dev` API to do playback and record. 16 | Simple configuration of codec as: 17 | ``` 18 | out: {codec: ES8311, pa: 38, use_mclk: 0, pa_gain:6} 19 | in: {codec: ES7210, i2s_port: 1} 20 | ``` 21 | 22 | - **SDcard** 23 | Users can configure SDCard related GPIO then use API `mount_sdcard` to mount sdcard to use it. 24 | SDcard configuration as: 25 | ``` 26 | sdcard: {clk: 43, cmd: 44, d0: 39, d1: 40, d2: 41, d3: 42} 27 | ``` 28 | 29 | - **Camera** 30 | Currently support DVP and MIPI camera, use can get camera settings use API `get_camera_cfg` 31 | 32 | - **LCD** 33 | Currently only support LCD on `S3_Korvo_V2` and `ESP32_P4_FUNCTION_EV`. 34 | User can get LCD handle through API `board_get_lcd_handle` after `board_lcd_init` 35 | 36 | ## Customized a New Board 37 | To reuse the pre-defined devices, follow these steps: 38 | 1. Add a new section to the [board_cfg.txt](board_cfg.txt) file and modify corresponding GPIO settings as needed. 39 | 2. Call `set_codec_board_type` with the name of the newly added section. 40 | For new devices, you will need to manually modify the code. 41 | 42 | ## Comparison with esp-bsp 43 | 44 | [esp-bsp](https://github.com/espressif/esp-bsp) supports almost all devices carried on board while this module only support media related devices. It provides a quick verification option if reusing the same device with different GPIO settings. Users can easily replace this module with `esp-bsp` by making the following substitutions: 45 | 46 | - `bsp_audio_codec_speaker_init`: Replaces `get_playback_handle` 47 | - `bsp_audio_codec_microphone_init`: Replaces `get_record_handle` 48 | - `bsp_display_new`: Replaces `board_get_lcd_handle` -------------------------------------------------------------------------------- /components/codec_board/board_cfg.txt: -------------------------------------------------------------------------------- 1 | # support in, out, in_out type 2 | # support i2c_port, i2s_port settings 3 | # support pa_gain, i2c_addr setting 4 | 5 | Board: S3_Korvo_V2 6 | i2c: {sda: 17, scl: 18} 7 | i2s: {mclk: 16, bclk: 9, ws: 45, din: 10, dout: 8} 8 | out: {codec: ES8311, pa: 48, pa_gain: 6, use_mclk: 1, pa_gain:6} 9 | in: {codec: ES7210} 10 | sdcard: {clk: 15, cmd: 7, d0: 4} 11 | camera: {type: dvp, xclk: 40, pclk: 11, vsync: 21, href: 38, d0: 13, d1: 47, d2: 14, d3: 3, d4: 12, d5: 42, d6: 41, d7: 39} 12 | lcd: { 13 | bus: spi, extend_io: tca9554, controller: st7789, spi_bus: 2, 14 | mirror_x: 1, mirror_y: 1, swap_xy: 0, color_inv: 0, 15 | width: 320, height: 240, 16 | ctrl: ext1, rst: ext2, 17 | cs: ext3, dc: 2, clk: 1, mosi: 0, cmd_bits: 8, param_bits: 8 18 | } 19 | 20 | Board: DUMMY_CODEC_BOARD 21 | i2s: {mclk: 5, bclk: 6, ws: 16, din: -1, dout: 8} 22 | out: {codec: DUMMY, pa: 15, i2c_port: -1} 23 | 24 | Board: S3_Korvo_V4 25 | i2c: {sda: 1, scl: 2} 26 | i2s: {mclk: 42, bclk: 40, ws: 41, dout: 39} 27 | i2s: {mclk: 20, bclk: 10, ws: 9, din: 11} 28 | out: {codec: ES8311, pa: 38, use_mclk: 0, pa_gain:6} 29 | in: {codec: ES7210, i2s_port: 1} 30 | sdcard: {clk: 18, cmd: 17, d0: 16} 31 | 32 | Board: LYRAT_MINI_V1 33 | i2c: {sda: 18, scl: 23} 34 | i2s: {mclk: 0, bclk: 5, ws: 25, dout: 26, din: 35} 35 | i2s: {mclk: -1, bclk: 32, ws: 33, din: 36} 36 | out: {codec: ES8311, pa: 21, use_mclk: 1, pa_gain:20} 37 | in: {codec: ES7243, i2s_port: 1} 38 | sdcard: {power: 13, clk: 14, cmd: 15, d0: 2} 39 | 40 | Board: ESP32_KORVO_V1 41 | i2c: {sda: 19, scl: 32} 42 | i2s: {mclk: 0, bclk: 25, ws: 22, dout: 13, din: -1} 43 | i2s: {mclk: 0, bclk: 27, ws: 26, dout: -1, din: 36} 44 | out: {codec: ES8311, pa: 12, use_mclk: 1, pa_gain:6} 45 | in: {codec: ES7210, i2s_port: 1} 46 | sdcard: {clk: 14, cmd: 15, d0: 2} 47 | 48 | Board: ESP32_LYRAT_V43 49 | i2c: {sda: 18, scl: 23} 50 | i2s: {mclk: -1, bclk: 5, ws: 25, dout: 26, din: 35} 51 | out: {codec: ES8388, pa: 21, use_mclk: 0, pa_gain:6} 52 | 53 | Board: ESP32S3_BOX 54 | i2c: {sda: 8, scl: 18} 55 | i2s: {mclk: 2, bclk: 17, ws: 47, dout: 15, din: 16} 56 | out: {codec: ES8311, pa: 46, use_mclk: 1, pa_gain:6} 57 | in: {codec: ES7210} 58 | 59 | Board: ESP32_S3_BOX_3 60 | i2c: {sda: 8, scl: 18, i2c_addr: 24} 61 | i2s: {mclk: 2, bclk: 17, ws: 45, din: 16, dout: 15} 62 | out: {codec: ES8311, pa: 46, use_mclk: 1, pa_gain: 6} 63 | in: {codec: ES7210} 64 | 65 | Board: ESP32_P4_DEV_V14 66 | i2c: {sda: 7, scl: 8} 67 | i2s: {mclk: 13, bclk: 12, ws: 10, dout: 9, din: 11} 68 | in_out: {codec: ES8311, pa: 53, use_mclk: 1, pa_gain:6} 69 | sdcard: {clk: 43, cmd: 44, d0: 39, d1: 40, d2: 41, d3: 42} 70 | camera: {type: mipi} 71 | lcd: { 72 | bus: mipi, ldo_chan: 3, ldo_voltage: 2500, lane_num: 2, 73 | lane_bitrate: 1000, dpi_clk: 80, bit_depth: 16, fb_num: 2 74 | dsi_hsync: 1344, dsi_vsync: 635, 75 | dsi_hbp: 160, dsi_hfp: 160, 76 | dsi_vbp: 23, dsi_vfp: 12, 77 | rst: -1, 78 | width: 1024, height: 600, 79 | } 80 | 81 | Board: ESP32S3_EYE 82 | i2c: {sda: 4, scl: 5} 83 | i2s: {mclk: -1, bclk: 41, ws: 42, dout: -1, din: 2} 84 | in: {codec: DUMMY, i2c_port: -1} 85 | sdcard: {clk: 39, cmd: 38, d0: 40} 86 | camera: {type: dvp, xclk: 15, pclk: 13, vsync: 6, href: 7, d0: 11, d1: 9, d2: 8, d3: 10, d4: 12, d5: 18, d6: 17, d7: 16} 87 | 88 | Board: XD_AIOT_C3 89 | i2c: {sda: 0, scl: 1} 90 | i2s: {mclk: 10, bclk: 8, ws: 12, dout: 11, din: 7} 91 | in_out: {codec: ES8311, pa: 13, pa_gain:6} 92 | 93 | Board: ESP_SPOT 94 | i2c: {sda: 25, scl: 26, i2c_addr: 0x18} 95 | i2s: {bclk: 7, ws: 8, dout: 9, din: 10} 96 | in_out: {codec: ES8311, pa: 23, pa_gain:6} 97 | -------------------------------------------------------------------------------- /components/codec_board/codec_board.c: -------------------------------------------------------------------------------- 1 | #include "codec_board.h" 2 | #include "esp_log.h" 3 | 4 | #define TAG "BOARD" 5 | 6 | board_section_t *get_codec_section(const char *codec_type); 7 | 8 | static board_section_t *codec; 9 | 10 | #define RET_ON_NOT_INIT() if (codec == NULL) { \ 11 | return -1; \ 12 | } 13 | 14 | void set_codec_board_type(const char *codec_type) 15 | { 16 | if (codec) { 17 | return; 18 | } 19 | codec = get_codec_section(codec_type); 20 | } 21 | 22 | int get_sdcard_config(sdcard_cfg_t *card_cfg) 23 | { 24 | RET_ON_NOT_INIT(); 25 | if (codec->sdcard_num == 0) { 26 | ESP_LOGE(TAG, "Sdcard not exits on board"); 27 | return -1; 28 | } 29 | memcpy(card_cfg, &codec->sdcard, sizeof(sdcard_cfg_t)); 30 | return 0; 31 | } 32 | 33 | int get_i2c_pin(uint8_t port, codec_i2c_pin_t *i2c_pin) 34 | { 35 | RET_ON_NOT_INIT(); 36 | if (port > codec->i2c_num) { 37 | ESP_LOGE(TAG, "I2C %d not exits on board", port); 38 | return -1; 39 | } 40 | memcpy(i2c_pin, &codec->i2c_pin[port], sizeof(codec_i2c_pin_t)); 41 | return 0; 42 | } 43 | 44 | int get_i2s_pin(uint8_t port, codec_i2s_pin_t *i2s_pin) 45 | { 46 | RET_ON_NOT_INIT(); 47 | if (port > codec->i2s_num) { 48 | ESP_LOGE(TAG, "I2S %d not exits on board", port); 49 | return -1; 50 | } 51 | memcpy(i2s_pin, &codec->i2s_pin[port], sizeof(codec_i2s_pin_t)); 52 | return 0; 53 | } 54 | 55 | int get_out_codec_cfg(codec_cfg_t *out_cfg) 56 | { 57 | RET_ON_NOT_INIT(); 58 | for (int i = 0; i < codec->codec_num; i++) { 59 | if (codec->codec[i].codec_dir & CODEC_DIR_OUT) { 60 | memcpy(out_cfg, &codec->codec[i].codec_cfg, sizeof(codec_cfg_t)); 61 | return 0; 62 | } 63 | } 64 | ESP_LOGE(TAG, "Output codec not exits on board"); 65 | return -1; 66 | } 67 | 68 | int get_in_codec_cfg(codec_cfg_t *in_cfg) 69 | { 70 | RET_ON_NOT_INIT(); 71 | for (int i = 0; i < codec->codec_num; i++) { 72 | if (codec->codec[i].codec_dir & CODEC_DIR_IN) { 73 | memcpy(in_cfg, &codec->codec[i].codec_cfg, sizeof(codec_cfg_t)); 74 | return 0; 75 | } 76 | } 77 | ESP_LOGE(TAG, "Input codec not exits on board"); 78 | return -1; 79 | } 80 | 81 | int get_camera_cfg(camera_cfg_t *cam_cfg) 82 | { 83 | RET_ON_NOT_INIT(); 84 | if (codec->camera_num == 0) { 85 | ESP_LOGE(TAG, "Camera not exits on board"); 86 | return -1; 87 | } 88 | memcpy(cam_cfg, &codec->camera, sizeof(camera_cfg_t)); 89 | return 0; 90 | } 91 | 92 | int get_lcd_cfg(lcd_cfg_t *lcd_cfg) 93 | { 94 | RET_ON_NOT_INIT(); 95 | if (codec->lcd_num) { 96 | memcpy(lcd_cfg, &codec->lcd, sizeof(lcd_cfg_t)); 97 | return 0; 98 | } 99 | ESP_LOGE(TAG, "LCD not exits on board"); 100 | return -1; 101 | } 102 | -------------------------------------------------------------------------------- /components/codec_board/dummy_codec.c: -------------------------------------------------------------------------------- 1 | 2 | #include "dummy_codec.h" 3 | 4 | typedef struct { 5 | audio_codec_if_t base; 6 | const audio_codec_gpio_if_t *gpio_if; 7 | bool is_open; 8 | bool enable; 9 | } dummy_codec_t; 10 | 11 | typedef struct { 12 | audio_codec_ctrl_if_t base; 13 | bool is_open; 14 | } dummy_codec_ctrl_t; 15 | 16 | static int dummy_codec_open(const audio_codec_if_t *h, void *cfg, int cfg_size) 17 | { 18 | dummy_codec_cfg_t *codec_cfg = (dummy_codec_cfg_t *)cfg; 19 | if (cfg_size != sizeof(dummy_codec_cfg_t) || codec_cfg->gpio_if == NULL) { 20 | return -1; 21 | } 22 | dummy_codec_t *codec = (dummy_codec_t *)h; 23 | codec->gpio_if = codec_cfg->gpio_if; 24 | codec->gpio_if->setup(codec_cfg->enable_gpio, AUDIO_GPIO_DIR_OUT, AUDIO_GPIO_MODE_FLOAT); 25 | codec->gpio_if->set(codec_cfg->enable_gpio, true); 26 | codec->is_open = true; 27 | return 0; 28 | } 29 | 30 | static bool dummy_codec_is_open(const audio_codec_if_t *h) 31 | { 32 | dummy_codec_t *codec = (dummy_codec_t *)h; 33 | return codec->is_open; 34 | } 35 | 36 | static int dummy_codec_enable(const audio_codec_if_t *h, bool enable) 37 | { 38 | dummy_codec_t *codec = (dummy_codec_t *)h; 39 | codec->enable = enable; 40 | return 0; 41 | } 42 | 43 | static int dummy_codec_set_fs(const audio_codec_if_t *h, esp_codec_dev_sample_info_t *fs) 44 | { 45 | return 0; 46 | } 47 | 48 | static int dummy_codec_close(const audio_codec_if_t *h) 49 | { 50 | dummy_codec_t *codec = (dummy_codec_t *)h; 51 | // Auto disable when codec closed 52 | if (codec->enable) { 53 | dummy_codec_enable(h, false); 54 | } 55 | codec->is_open = false; 56 | return 0; 57 | } 58 | 59 | const audio_codec_if_t *dummy_codec_new(dummy_codec_cfg_t *codec_cfg) 60 | { 61 | dummy_codec_t *codec = (dummy_codec_t *)calloc(1, sizeof(dummy_codec_t)); 62 | if (codec == NULL) { 63 | return NULL; 64 | } 65 | codec->base.open = dummy_codec_open; 66 | codec->base.is_open = dummy_codec_is_open; 67 | codec->base.enable = dummy_codec_enable; 68 | codec->base.set_fs = dummy_codec_set_fs; 69 | codec->base.close = dummy_codec_close; 70 | codec->base.open(&codec->base, codec_cfg, sizeof(dummy_codec_cfg_t)); 71 | return &codec->base; 72 | } -------------------------------------------------------------------------------- /components/codec_board/dummy_codec.h: -------------------------------------------------------------------------------- 1 | #include "esp_codec_dev.h" 2 | #include "audio_codec_ctrl_if.h" 3 | #include "audio_codec_gpio_if.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | /** 10 | * @brief Dummy codec configuration 11 | */ 12 | typedef struct { 13 | int16_t enable_gpio; /*!< Enable GPIO setting */ 14 | const audio_codec_gpio_if_t *gpio_if; /*!< GPIO interface to control gpio */ 15 | } dummy_codec_cfg_t; 16 | 17 | /** 18 | * @brief Create a dummy codec 19 | * 20 | * @note Dummy codec means use I2S to transfer audio data with out I2C control interface 21 | * 22 | * @param[in] codec_cfg Dummy codec configuration 23 | * 24 | * @return 25 | * - NULL No memory for dummy codec 26 | * - Others Dummy codec instance 27 | * 28 | */ 29 | const audio_codec_if_t *dummy_codec_new(dummy_codec_cfg_t *codec_cfg); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | -------------------------------------------------------------------------------- /components/codec_board/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | version: "0.5.4" 3 | description: Simple ESP32 series codec board realization 4 | dependencies: 5 | espressif/esp_codec_dev: "~1.3.4" 6 | esp_lcd_ek79007: 7 | version: "~1.0.2" 8 | rules: 9 | - if: "target in [esp32p4]" 10 | espressif/esp_lcd_ili9881c: 11 | version: "~1.0.1" 12 | rules: 13 | - if: "target in [esp32p4]" 14 | -------------------------------------------------------------------------------- /components/esp_capture/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Gather common sources 3 | set(component_srcdirs "src" 4 | "src/impl/capture_simple_path" 5 | "src/impl/capture_file_src" 6 | ) 7 | 8 | idf_component_register( 9 | SRC_DIRS ${component_srcdirs} 10 | INCLUDE_DIRS ./include ./interface 11 | REQUIRES media_lib_sal esp_timer 12 | ) 13 | -------------------------------------------------------------------------------- /components/esp_capture/README.md: -------------------------------------------------------------------------------- 1 | # ESP_Capture 2 | 3 | `esp_capture` is an integrated capture module for capturing audio and video data. It supports various audio and video capture devices and codecs, allowing users to easily acquire audio/video frame data or container data. 4 | 5 | ## Features 6 | 7 | - **Capture Devices**: Abstracted into audio or video sources. Users can either use existing capture devices or add custom ones via provided interfaces. 8 | - **Audio/Video Codecs**: Support for a wide range of codecs。 Users can use `menuconfig` to remove unused codecs to reduce the final binary size. 9 | - **Muxer Support**: Support Saving muxed container data to storage or send it through a network. 10 | - **Capture Path**: Simple capture paths for single audio and video codec outputs, with multiple path support under testing. 11 | 12 | --- 13 | 14 | ## Capture Devices 15 | 16 | Capture devices are abstracted into **audio sources** and **video sources**. Users can: 17 | 18 | 1. Add custom capture devices using the provided interfaces. 19 | 2. Use existing supported devices: 20 | 21 | ### Supported Audio Capture Devices: 22 | - `esp_capture_new_audio_codec_src`: Supports I2S devices using the `esp_codec_dev` handle. 23 | - `esp_capture_new_audio_aec_src`: Supports I2S devices with AEC using the `esp_codec_dev` handle. 24 | 25 | ### Supported Video Capture Devices: 26 | 1. `esp_capture_new_video_v4l2_src`: Supports MIPI CSI cameras and DVP cameras on ESP32-P4. 27 | 2. `esp_capture_new_video_dvp_src`: Supports DVP cameras on ESP32-S3 and other ESP platforms. 28 | 29 | --- 30 | 31 | ## Capture Codecs 32 | 33 | Users can register video and audio codecs via the following APIs: 34 | 35 | - `esp_video_enc_register_default` 36 | - `esp_audio_enc_register_default` 37 | 38 | ### Audio Codecs: 39 | - `G711A` 40 | - `G711U` 41 | - `AAC` 42 | - `OPUS` 43 | 44 | ### Video Codecs: 45 | - `MJPEG` 46 | - `H.264` (Baseline profile only) 47 | 48 | Unused codecs can be deselected via `menuconfig` to reduce the final image size. 49 | 50 | --- 51 | 52 | ## Muxer Support 53 | 54 | Muxers allow user mux audio and video data into container formats: 55 | 56 | - **Supported Formats**: 57 | - `MP4`: Supports saving to storage only. 58 | - `TS`: Supports saving to storage and streaming output both. 59 | 60 | --- 61 | 62 | ## Capture Path 63 | 64 | Each capture path supports one audio and video codec or muxed data output. 65 | 66 | - **Simple Capture**: Currently supports one capture path. 67 | - **Multiple Path Support**: Developped based on ESP-GMF (under testing, not released yet). 68 | 69 | --- 70 | 71 | ## Simple Usage 72 | 73 | Below are the steps to use `esp_capture` for audio and video capture: 74 | 75 | 1. **Register Codecs**: 76 | - Register audio codecs using `esp_audio_enc_register_default`. 77 | - Register video codecs using `esp_video_enc_register_default`. 78 | 79 | 2. **Select Capture Devices**: 80 | - Use `esp_capture_new_audio_codec_src` to create an audio source. 81 | - Use `esp_capture_new_video_v4l2_src` to create a video source. 82 | 83 | 3. **Build Capture Path**: 84 | - Use `esp_capture_build_simple_path` to build a capture path. 85 | - Use the path to create a capture handle with `esp_capture_open`. 86 | 87 | 4. **Setup and Enable Path**: 88 | - Configure codec settings using `esp_capture_setup_path`. 89 | - Enable the capture path using `esp_capture_enable_path`. 90 | 91 | 5. **Start Capture**: 92 | - Call `esp_capture_start` to begin capturing. 93 | 94 | 6. **Acquire and Release Frame Data**: 95 | - Call `esp_capture_acquire_path_frame` to retrieve audio, video, or muxed data. 96 | - Call `esp_capture_release_path_frame` to release the frame data when done. 97 | 98 | 7. **Stop Capture**: 99 | - Call `esp_capture_stop` to end the capture session. -------------------------------------------------------------------------------- /components/esp_capture/idf_component.yml: -------------------------------------------------------------------------------- 1 | version: "0.0.1" 2 | description: Espressif Capture Library 3 | dependencies: 4 | idf : ">=4.4" 5 | espressif/esp_muxer: "~1.1.0" 6 | -------------------------------------------------------------------------------- /components/esp_capture/include/esp_capture_audio_enc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | #include "esp_capture_aenc_if.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Create generic audio encoder instance 36 | * 37 | * @return 38 | * - NULL Not enough memory to hold audio encoder instance 39 | * - Others Audio encoder instance 40 | */ 41 | esp_capture_aenc_if_t *esp_capture_new_audio_encoder(void); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif -------------------------------------------------------------------------------- /components/esp_capture/include/esp_capture_path_simple.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_path_if.h" 28 | #include "esp_capture_aenc_if.h" 29 | #include "esp_capture_venc_if.h" 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | /** 36 | * @brief Simple capture path configuration 37 | * 38 | * @note Simple capture path consisted by one audio encoder and one video encoder 39 | * It also support bypass mode, during bypass encoder not work, 40 | * audio source data and video source data is sent to user directly. 41 | * 42 | */ 43 | typedef struct { 44 | esp_capture_aenc_if_t *aenc; /*!< Audio encoder instance */ 45 | esp_capture_venc_if_t *venc; /*!< Video encoder instance */ 46 | uint32_t aenc_frame_count; /*!< Audio encoder output frame count */ 47 | uint32_t venc_frame_count; /*!< Video encoder output frame count */ 48 | } esp_capture_simple_path_cfg_t; 49 | 50 | /** 51 | * @brief Create simple capture path instance 52 | * 53 | * @param[in] cfg Audio codec source configuration 54 | * 55 | * @return 56 | * - NULL Not enough memory to hold simple capture path instance 57 | * - Others Simple capture path instance 58 | * 59 | */ 60 | esp_capture_path_if_t *esp_capture_build_simple_path(esp_capture_simple_path_cfg_t *cfg); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | -------------------------------------------------------------------------------- /components/esp_capture/include/esp_capture_video_enc.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | #include "esp_capture_venc_if.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Create an instance for general video encoder 36 | * 37 | * @return 38 | * - NULL Not enough memory to hold video encoder instance 39 | * - Others Video encoder instance 40 | * 41 | */ 42 | esp_capture_venc_if_t *esp_capture_new_video_encoder(void); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | -------------------------------------------------------------------------------- /components/esp_capture/interface/esp_capture_aenc_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Capture audio encoder interface 35 | */ 36 | typedef struct esp_capture_aenc_if_t esp_capture_aenc_if_t; 37 | 38 | struct esp_capture_aenc_if_t { 39 | /** 40 | * @brief Clone an existing audio encoder. 41 | */ 42 | esp_capture_aenc_if_t *(*clone)(esp_capture_aenc_if_t *enc); 43 | 44 | /** 45 | * @brief Get the supported audio codecs. 46 | */ 47 | int (*get_support_codecs)(esp_capture_aenc_if_t *src, const esp_capture_codec_type_t **codecs, uint8_t *num); 48 | 49 | /** 50 | * @brief Start the audio encoder. 51 | */ 52 | int (*start)(esp_capture_aenc_if_t *src, esp_capture_audio_info_t *info); 53 | 54 | /** 55 | * @brief Get the input and output frame sizes for the audio encoder. 56 | */ 57 | int (*get_frame_size)(esp_capture_aenc_if_t *src, int *in_samples, int *out_frame_size); 58 | 59 | /** 60 | * @brief Set the bitrate for the audio encoder. 61 | */ 62 | int (*set_bitrate)(esp_capture_aenc_if_t *src, int bitrate); 63 | 64 | /** 65 | * @brief Encode an audio frame. 66 | */ 67 | int (*encode_frame)(esp_capture_aenc_if_t *src, esp_capture_stream_frame_t *raw, esp_capture_stream_frame_t *encoded); 68 | 69 | /** 70 | * @brief Stop the audio encoder. 71 | */ 72 | int (*stop)(esp_capture_aenc_if_t *src); 73 | }; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif -------------------------------------------------------------------------------- /components/esp_capture/interface/esp_capture_audio_src_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Capture audio source interface 35 | */ 36 | typedef struct esp_capture_audio_src_if_t esp_capture_audio_src_if_t; 37 | 38 | struct esp_capture_audio_src_if_t { 39 | /** 40 | * @brief Open the audio source for capturing. 41 | */ 42 | int (*open)(esp_capture_audio_src_if_t *src); 43 | 44 | /** 45 | * @brief Get the supported audio codecs. 46 | */ 47 | int (*get_support_codecs)(esp_capture_audio_src_if_t *src, const esp_capture_codec_type_t **codecs, uint8_t *num); 48 | 49 | /** 50 | * @brief Negotiate capabilities between the source and the sink. 51 | */ 52 | int (*negotiate_caps)(esp_capture_audio_src_if_t *src, esp_capture_audio_info_t *in_cap, esp_capture_audio_info_t *out_caps); 53 | 54 | /** 55 | * @brief Start capturing audio from the source. 56 | */ 57 | int (*start)(esp_capture_audio_src_if_t *src); 58 | 59 | /** 60 | * @brief Read a frame of audio data from the source. 61 | */ 62 | int (*read_frame)(esp_capture_audio_src_if_t *src, esp_capture_stream_frame_t *frame); 63 | 64 | /** 65 | * @brief Stop capturing audio from the source. 66 | */ 67 | int (*stop)(esp_capture_audio_src_if_t *src); 68 | 69 | /** 70 | * @brief Close the audio source and release resources. 71 | */ 72 | int (*close)(esp_capture_audio_src_if_t *src); 73 | }; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif -------------------------------------------------------------------------------- /components/esp_capture/interface/esp_capture_overlay_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Capture overlay interface 35 | */ 36 | typedef struct esp_capture_overlay_if_t esp_capture_overlay_if_t; 37 | 38 | struct esp_capture_overlay_if_t { 39 | /** 40 | * @brief Open the overlay interface. 41 | */ 42 | int (*open)(esp_capture_overlay_if_t *src); 43 | 44 | /** 45 | * @brief Get the overlay region and codec type. 46 | */ 47 | int (*get_overlay_region)(esp_capture_overlay_if_t *src, esp_capture_codec_type_t *codec, esp_capture_rgn_t *rgn); 48 | 49 | /** 50 | * @brief Set the alpha value for the overlay. 51 | */ 52 | int (*set_alpha)(esp_capture_overlay_if_t *src, uint8_t alpha); 53 | 54 | /** 55 | * @brief Get the current alpha value of the overlay. 56 | */ 57 | int (*get_alpha)(esp_capture_overlay_if_t *src, uint8_t *alpha); 58 | 59 | /** 60 | * @brief Acquire a frame for the overlay. 61 | */ 62 | int (*acquire_frame)(esp_capture_overlay_if_t *src, esp_capture_stream_frame_t *frame); 63 | 64 | /** 65 | * @brief Release a previously acquired frame. 66 | */ 67 | int (*release_frame)(esp_capture_overlay_if_t *src, esp_capture_stream_frame_t *frame); 68 | 69 | /** 70 | * @brief Close the overlay interface. 71 | */ 72 | int (*close)(esp_capture_overlay_if_t *src); 73 | }; 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif -------------------------------------------------------------------------------- /components/esp_capture/interface/esp_capture_venc_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Capture video encoder interface definition 35 | */ 36 | typedef struct esp_capture_venc_if_t esp_capture_venc_if_t; 37 | 38 | /** 39 | * @brief Capture video encoder interface 40 | */ 41 | struct esp_capture_venc_if_t { 42 | /** 43 | * @brief Clone of video encoder instance 44 | */ 45 | esp_capture_venc_if_t *(*clone)(esp_capture_venc_if_t *enc); 46 | 47 | /** 48 | * @brief Get supported codecs from video encoder 49 | */ 50 | int (*get_support_codecs)(esp_capture_venc_if_t *enc, const esp_capture_codec_type_t **codecs, uint8_t *num); 51 | 52 | /** 53 | * @brief Get input codecs of special output codec from video encoder 54 | */ 55 | int (*get_input_codecs)(esp_capture_venc_if_t *enc, esp_capture_codec_type_t out_codec, 56 | const esp_capture_codec_type_t **codecs, uint8_t *num); 57 | 58 | /** 59 | * @brief Start video encoder 60 | */ 61 | int (*start)(esp_capture_venc_if_t *enc, esp_capture_codec_type_t src_codec, esp_capture_video_info_t *info); 62 | 63 | /** 64 | * @brief Get frame size from video encoder 65 | */ 66 | int (*get_frame_size)(esp_capture_venc_if_t *enc, int *in_frame_size, int *out_frame_size); 67 | 68 | /** 69 | * @brief Set bitrate for video encoder 70 | */ 71 | int (*set_bitrate)(esp_capture_venc_if_t *enc, int bitrate); 72 | 73 | /** 74 | * @brief Encode video frame 75 | */ 76 | int (*encode_frame)(esp_capture_venc_if_t *enc, esp_capture_stream_frame_t *raw, esp_capture_stream_frame_t *encoded); 77 | 78 | /** 79 | * @brief Stop of video encode 80 | */ 81 | int (*stop)(esp_capture_venc_if_t *enc); 82 | }; 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif -------------------------------------------------------------------------------- /components/esp_capture/interface/esp_capture_video_src_if.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include "esp_capture_types.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Video source interface definition 35 | */ 36 | typedef struct esp_capture_video_src_if_t esp_capture_video_src_if_t; 37 | 38 | /** 39 | * @brief Video source interface 40 | */ 41 | struct esp_capture_video_src_if_t { 42 | /** 43 | * @brief Open video capture soruce 44 | */ 45 | int (*open)(esp_capture_video_src_if_t *src); 46 | 47 | /** 48 | * @brief Get supported codecs from video source 49 | */ 50 | int (*get_support_codecs)(esp_capture_video_src_if_t *src, const esp_capture_codec_type_t **codecs, uint8_t *num); 51 | 52 | /** 53 | * @brief Negotiate for video source capability 54 | */ 55 | int (*negotiate_caps)(esp_capture_video_src_if_t *src, esp_capture_video_info_t *in_cap, esp_capture_video_info_t *out_caps); 56 | 57 | /** 58 | * @brief Start of video source 59 | */ 60 | int (*start)(esp_capture_video_src_if_t *src); 61 | 62 | /** 63 | * @brief Acquire video frame from video source 64 | */ 65 | int (*acquire_frame)(esp_capture_video_src_if_t *src, esp_capture_stream_frame_t *frame); 66 | 67 | /** 68 | * @brief Release video frame from video source 69 | */ 70 | int (*release_frame)(esp_capture_video_src_if_t *src, esp_capture_stream_frame_t *frame); 71 | 72 | /** 73 | * @brief Stop of video source 74 | */ 75 | int (*stop)(esp_capture_video_src_if_t *src); 76 | 77 | /** 78 | * @brief Close of video source 79 | */ 80 | int (*close)(esp_capture_video_src_if_t *src); 81 | }; 82 | 83 | #ifdef __cplusplus 84 | } 85 | #endif -------------------------------------------------------------------------------- /components/esp_capture/src/esp_capture_sync.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include 28 | #include "esp_capture.h" 29 | 30 | typedef void *esp_capture_sync_handle_t; 31 | 32 | int esp_capture_sync_create(esp_capture_sync_mode_t type, esp_capture_sync_handle_t *handle); 33 | 34 | int esp_capture_sync_audio_update(esp_capture_sync_handle_t handle, uint32_t aud_pts); 35 | 36 | int esp_capture_sync_start(esp_capture_sync_handle_t handle); 37 | 38 | int esp_capture_sync_get_current(esp_capture_sync_handle_t handle, uint32_t *pts); 39 | 40 | int esp_capture_sync_stop(esp_capture_sync_handle_t handle); 41 | 42 | int esp_capture_sync_destroy(esp_capture_sync_handle_t handle); -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_audio_enc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(component_srcdirs "./") 3 | 4 | idf_component_register( 5 | SRC_DIRS ${component_srcdirs} 6 | INCLUDE_DIRS ./ 7 | ) 8 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_audio_enc/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp_audio_codec: "~2.3.0" 3 | esp_capture: 4 | path: ../../../../esp_capture 5 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_audio_src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(component_srcdirs "./") 3 | 4 | idf_component_register( 5 | SRC_DIRS ${component_srcdirs} 6 | INCLUDE_DIRS ./ 7 | ) -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_audio_src/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp_codec_dev: "~1.3.4" 3 | espressif/esp-sr: "1.9.5" 4 | esp_capture: 5 | path: ../../../../esp_capture 6 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_text_overlay/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_ADD_INCLUDEDIRS "../../../include" ./ "../../../interface") 2 | set(COMPONENT_SRCDIRS ./ font) 3 | set(COMPONENT_REQUIRES media_lib_sal) 4 | register_component() -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_text_overlay/Kconfig: -------------------------------------------------------------------------------- 1 | menu "Capture Text Overlay" 2 | config ESP_PAINTER_FORMAT_SIZE_MAX 3 | int "Size of format string buffer" 4 | default 128 5 | 6 | menu "fonts" 7 | config ESP_PAINTER_BASIC_FONT_12 8 | bool "Enable basic_font_12" 9 | default y 10 | 11 | config ESP_PAINTER_BASIC_FONT_16 12 | bool "Enable basic_font_16" 13 | default n 14 | 15 | config ESP_PAINTER_BASIC_FONT_20 16 | bool "Enable basic_font_20" 17 | default n 18 | 19 | config ESP_PAINTER_BASIC_FONT_24 20 | bool "Enable basic_font_24" 21 | default y 22 | 23 | config ESP_PAINTER_BASIC_FONT_28 24 | bool "Enable basic_font_28" 25 | default n 26 | 27 | config ESP_PAINTER_BASIC_FONT_32 28 | bool "Enable basic_font_32" 29 | default n 30 | 31 | config ESP_PAINTER_BASIC_FONT_36 32 | bool "Enable basic_font_36" 33 | default n 34 | 35 | config ESP_PAINTER_BASIC_FONT_40 36 | bool "Enable basic_font_40" 37 | default n 38 | 39 | config ESP_PAINTER_BASIC_FONT_44 40 | bool "Enable basic_font_44" 41 | default n 42 | 43 | config ESP_PAINTER_BASIC_FONT_48 44 | bool "Enable basic_font_48" 45 | default n 46 | endmenu 47 | endmenu 48 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_text_overlay/esp_painter_font.h: -------------------------------------------------------------------------------- 1 | /** 2 | * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD 3 | * 4 | * SPDX-License-Identifier: CC0-1.0 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct { 16 | const uint8_t *bitmap; 17 | uint16_t width; 18 | uint16_t height; 19 | } esp_painter_basic_font_t; 20 | 21 | #define esp_painter_FONT_DECLARE(font_name) extern const esp_painter_basic_font_t font_name; 22 | 23 | #if CONFIG_ESP_PAINTER_BASIC_FONT_12 24 | esp_painter_FONT_DECLARE(esp_painter_basic_font_12); 25 | #endif 26 | 27 | #if CONFIG_ESP_PAINTER_BASIC_FONT_16 28 | esp_painter_FONT_DECLARE(esp_painter_basic_font_16); 29 | #endif 30 | 31 | #if CONFIG_ESP_PAINTER_BASIC_FONT_20 32 | esp_painter_FONT_DECLARE(esp_painter_basic_font_20); 33 | #endif 34 | 35 | #if CONFIG_ESP_PAINTER_BASIC_FONT_24 36 | esp_painter_FONT_DECLARE(esp_painter_basic_font_24); 37 | #endif 38 | 39 | #if CONFIG_ESP_PAINTER_BASIC_FONT_28 40 | esp_painter_FONT_DECLARE(esp_painter_basic_font_28); 41 | #endif 42 | 43 | #if CONFIG_ESP_PAINTER_BASIC_FONT_32 44 | esp_painter_FONT_DECLARE(esp_painter_basic_font_32); 45 | #endif 46 | 47 | #if CONFIG_ESP_PAINTER_BASIC_FONT_36 48 | esp_painter_FONT_DECLARE(esp_painter_basic_font_36); 49 | #endif 50 | 51 | #if CONFIG_ESP_PAINTER_BASIC_FONT_40 52 | esp_painter_FONT_DECLARE(esp_painter_basic_font_40); 53 | #endif 54 | 55 | #if CONFIG_ESP_PAINTER_BASIC_FONT_44 56 | esp_painter_FONT_DECLARE(esp_painter_basic_font_44); 57 | #endif 58 | 59 | #if CONFIG_ESP_PAINTER_BASIC_FONT_48 60 | esp_painter_FONT_DECLARE(esp_painter_basic_font_48); 61 | #endif 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_text_overlay/idf_component.yml: -------------------------------------------------------------------------------- 1 | version: "0.0.1" 2 | description: Capture Text Overlay 3 | url: https://github.com/espressif/esp-adf-libs/tree/master 4 | dependencies: 5 | idf : ">=4.4" 6 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_video_enc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(component_srcdirs "./") 3 | 4 | idf_component_register( 5 | SRC_DIRS ${component_srcdirs} 6 | INCLUDE_DIRS ./ 7 | REQUIRES esp_driver_jpeg 8 | ) 9 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_video_enc/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp_video_codec: "~0.5.2" 3 | esp_capture: 4 | path: ../../../../esp_capture 5 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_video_src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if (${IDF_TARGET} STREQUAL "esp32s3") 2 | list(APPEND COMPONENT_SRCS capture_video_dvp_src.c) 3 | endif() 4 | 5 | if (${IDF_TARGET} STREQUAL "esp32p4") 6 | list(APPEND COMPONENT_SRCS capture_video_v4l2_src.c) 7 | list(APPEND COMPONENT_REQUIRES esp_mm) 8 | endif() 9 | 10 | idf_component_register(SRCS "${COMPONENT_SRCS}" 11 | INCLUDE_DIRS "${COMPONENT_INCLUDES}" 12 | REQUIRES ${COMPONENT_REQUIRES}) 13 | -------------------------------------------------------------------------------- /components/esp_capture/src/impl/capture_video_src/idf_component.yml: -------------------------------------------------------------------------------- 1 | dependencies: 2 | espressif/esp_video: 3 | version: "~0.8.0" 4 | rules: 5 | - if: "target in [esp32p4]" 6 | 7 | espressif/esp32-camera: 8 | version: "~2.0.15" 9 | rules: 10 | - if: "target in [esp32s3,esp32s2,esp32]" 11 | esp_capture: 12 | path: ../../../../esp_capture 13 | -------------------------------------------------------------------------------- /components/esp_webrtc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(component_srcdirs "src") 3 | 4 | # AppRTC 5 | set(signalling_srcdirs "impl/apprtc_signal" "impl/whip_signal") 6 | set(signalling_incdirs "impl/apprtc_signal" "impl/whip_signal/include") 7 | 8 | list(APPEND component_srcdirs ${signalling_srcdirs}) 9 | 10 | idf_component_register( 11 | SRC_DIRS ${component_srcdirs} 12 | INCLUDE_DIRS ./include ${signalling_incdirs} 13 | REQUIRES mbedtls json esp_http_client esp_websocket_client esp_netif media_lib_sal 14 | esp_capture webrtc_utils esp_codec_dev av_render 15 | ) 16 | -------------------------------------------------------------------------------- /components/esp_webrtc/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | description: Espressif WebRTC Library 3 | version: 0.9.0 4 | 5 | dependencies: 6 | espressif/nghttp: "~1.65.0" 7 | espressif/esp_websocket_client: "~1.4.0" 8 | espressif/esp_codec_dev: "~1.3.4" 9 | espressif/esp_libsrtp: "~1.0.0" 10 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/apprtc_signal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | file(GLOB CODES "*.c") 3 | 4 | idf_component_register( 5 | SRCS ${CODES} 6 | INCLUDE_DIRS ./ 7 | REQUIRES json esp_http_client esp_websocket_client 8 | ) 9 | 10 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/apprtc_signal/https_client.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | /** 32 | * @brief Https response data 33 | */ 34 | typedef struct { 35 | char *data; /*!< Response data */ 36 | int size; /*!< Response data size */ 37 | } http_resp_t; 38 | 39 | /** 40 | * @brief Https response callback 41 | * 42 | * @param[in] resp Body content 43 | * @param[in] ctx User context 44 | */ 45 | typedef void (*http_body_t)(http_resp_t *resp, void *ctx); 46 | 47 | /** 48 | * @brief Https header callback 49 | * 50 | * @param[in] key Header key 51 | * @param[in] key Header value 52 | * @param[in] ctx User context 53 | */ 54 | typedef void (*http_header_t)(const char *key, const char *value, void *ctx); 55 | 56 | /** 57 | * @brief Send https requests 58 | * 59 | * @note This API is run in synchronized until response or error returns 60 | * 61 | * @param[in] method HTTP method to do 62 | * @param[in] headers HTTP headers, headers are array of "Type: Info", last one need set to NULL 63 | * @param[in] url HTTPS URL 64 | * @param[in] data Content data to be sent 65 | * @param[in] header_cb Header callback 66 | * @param[in] body Body callback 67 | * @param[in] ctx User context 68 | * 69 | * @return 70 | * - 0 On success 71 | * - Others Fail to do https request 72 | */ 73 | int https_send_request(const char *method, char **headers, const char *url, char *data, http_header_t header_cb, http_body_t body_cb, void *ctx); 74 | 75 | /** 76 | * @brief Do post https request 77 | * 78 | * @note This API will internally call `https_send_request` 79 | * 80 | * @param[in] url HTTPS URL to post 81 | * @param[in] headers HTTP headers, headers are array of "Type: Info", last one need set to NULL 82 | * @param[in] data Content data to be sent 83 | * @param[in] header_cb Header callback 84 | * @param[in] body Body callback 85 | * @param[in] ctx User context 86 | * 87 | * @return 88 | * - 0 On success 89 | * - Others Fail to do https request 90 | */ 91 | int https_post(const char *url, char **headers, char *data, http_header_t header_cb, http_body_t body, void *ctx); 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## v1.1.0 4 | 5 | ### Features 6 | 7 | - Export buffer configuration for RTP and data channel 8 | - Added support for multiple data channel 9 | - Added notify for data channel open, close event 10 | 11 | ### Bug Fixes 12 | 13 | - Fixed keep alive check not take effect if peer closed unexpectly 14 | 15 | 16 | ## v1.0.0 17 | 18 | - Initial version of `peer_default` 19 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(INCLUDE_DIRS ./include) 2 | 3 | get_filename_component(BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR} NAME) 4 | add_prebuilt_library(${BASE_DIR} "${CMAKE_CURRENT_SOURCE_DIR}/libs/${IDF_TARGET}/libpeer_default.a" 5 | PRIV_REQUIRES ${BASE_DIR} esp_timer) 6 | target_link_libraries(${COMPONENT_LIB} INTERFACE "-L ${CMAKE_CURRENT_SOURCE_DIR}/libs/${IDF_TARGET}") 7 | target_link_libraries(${COMPONENT_LIB} INTERFACE peer_default) 8 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/idf_component.yml: -------------------------------------------------------------------------------- 1 | version: 1.1.0 2 | -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/libs/esp32/libpeer_default.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/components/esp_webrtc/impl/peer_default/libs/esp32/libpeer_default.a -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/libs/esp32p4/libpeer_default.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/components/esp_webrtc/impl/peer_default/libs/esp32p4/libpeer_default.a -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/libs/esp32s2/libpeer_default.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/components/esp_webrtc/impl/peer_default/libs/esp32s2/libpeer_default.a -------------------------------------------------------------------------------- /components/esp_webrtc/impl/peer_default/libs/esp32s3/libpeer_default.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/components/esp_webrtc/impl/peer_default/libs/esp32s3/libpeer_default.a -------------------------------------------------------------------------------- /components/esp_webrtc/impl/whip_signal/include/esp_peer_whip_signaling.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include 28 | #include "esp_peer_signaling.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief WHIP authorization type 36 | */ 37 | typedef enum { 38 | ESP_PEER_SIGNALING_WHIP_AUTH_TYPE_BEARER = 0, /*!< Use Bearer token */ 39 | ESP_PEER_SIGNALING_WHIP_AUTH_TYPE_BASIC = 1, /*!< Use basic authorization */ 40 | } esp_peer_signaling_whip_auth_type_t; 41 | 42 | /** 43 | * @brief WHIP signaling configuration 44 | */ 45 | typedef struct { 46 | esp_peer_signaling_whip_auth_type_t auth_type; /*!< Authorization type */ 47 | char *token; /*!< Bearer token or username:password for basic authorization */ 48 | } esp_peer_signaling_whip_cfg_t; 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /components/esp_webrtc/include/esp_peer_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Peer error code 36 | */ 37 | typedef enum { 38 | ESP_PEER_ERR_NONE = 0, /*!< None error */ 39 | ESP_PEER_ERR_INVALID_ARG = -1, /*!< Invalid argument */ 40 | ESP_PEER_ERR_NO_MEM = -2, /*!< Not enough memory */ 41 | ESP_PEER_ERR_WRONG_STATE = -3, /*!< Operate on wrong state */ 42 | ESP_PEER_ERR_NOT_SUPPORT = -4, /*!< Not supported operation */ 43 | ESP_PEER_ERR_NOT_EXISTS = -5, /*!< Not existed */ 44 | ESP_PEER_ERR_FAIL = -6, /*!< General error code */ 45 | ESP_PEER_ERR_OVER_LIMITED = -7, /*!< Overlimited */ 46 | ESP_PEER_ERR_BAD_DATA = -8, /*!< Bad input data */ 47 | } esp_peer_err_t; 48 | 49 | /** 50 | * @brief ICE server configuration 51 | */ 52 | typedef struct { 53 | char *stun_url; /*!< STUN/Relay server URL */ 54 | char *user; /*!< User name */ 55 | char *psw; /*!< User password */ 56 | } esp_peer_ice_server_cfg_t; 57 | 58 | /** 59 | * @brief Peer role 60 | */ 61 | typedef enum { 62 | ESP_PEER_ROLE_CONTROLLING, /*!< Controlling role who initialize the connection */ 63 | ESP_PEER_ROLE_CONTROLLED, /*!< Controlled role */ 64 | } esp_peer_role_t; 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /components/esp_webrtc/include/esp_webrtc_defaults.h: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * ESPRESSIF MIT License 4 | * 5 | * Copyright (c) 2025 6 | * 7 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in which case, 8 | * it is free of charge, to any person obtaining a copy of this software and associated 9 | * documentation files (the "Software"), to deal in the Software without restriction, including 10 | * without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 11 | * and/or sell copies of the Software, and to permit persons to whom the Software is furnished 12 | * to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all copies or 15 | * substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 19 | * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 20 | * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 21 | * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | * 24 | */ 25 | 26 | #pragma once 27 | 28 | #include "esp_peer.h" 29 | #include "esp_peer_signaling.h" 30 | #include "esp_peer_whip_signaling.h" 31 | 32 | #ifdef __cplusplus 33 | extern "C" { 34 | #endif 35 | 36 | /** 37 | * @brief Get APPRTC signaling implement 38 | * 39 | * @param[in] cfg Signaling configuration 40 | * @param[in] impl Implement of signaling interface 41 | * @param[out] sig Signaling handle 42 | * 43 | * @return 44 | * - NULL Not enough memory 45 | * - Others APPRTC signaling implementation 46 | */ 47 | const esp_peer_signaling_impl_t *esp_signaling_get_apprtc_impl(void); 48 | 49 | /** 50 | * @brief Get WHIP signaling implementation 51 | * 52 | * @return 53 | * - NULL Not enough memory 54 | * - Others WHIP signaling implementation 55 | */ 56 | const esp_peer_signaling_impl_t *esp_signaling_get_whip_impl(void); 57 | 58 | /** 59 | * @brief Get default peer connection implementation 60 | * @return 61 | * - NULL No default implementation, or not enough memory 62 | * - Others Default implementation 63 | */ 64 | const esp_peer_ops_t *esp_peer_get_default_impl(void); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | -------------------------------------------------------------------------------- /components/esp_webrtc/include/esp_webrtc_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | const char* esp_webrtc_get_version(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /components/esp_webrtc/src/esp_peer_signaling.c: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #include "esp_peer_signaling.h" 26 | #include 27 | #include 28 | #include 29 | 30 | typedef struct { 31 | esp_peer_signaling_handle_t sig_handle; 32 | esp_peer_signaling_impl_t impl; 33 | } signaling_wrapper_t; 34 | 35 | int esp_peer_signaling_start(esp_peer_signaling_cfg_t *cfg, const esp_peer_signaling_impl_t *impl, esp_peer_signaling_handle_t *handle) 36 | { 37 | if (cfg == NULL || impl == NULL || handle == NULL || impl->start == NULL) { 38 | return ESP_PEER_ERR_INVALID_ARG; 39 | } 40 | signaling_wrapper_t *sig = calloc(1, sizeof(signaling_wrapper_t)); 41 | if (sig == NULL) { 42 | return ESP_PEER_ERR_NO_MEM; 43 | } 44 | int ret = impl->start(cfg, &sig->sig_handle); 45 | if (ret != ESP_PEER_ERR_NONE) { 46 | free(sig); 47 | return ret; 48 | } 49 | sig->impl = *impl; 50 | *handle = sig; 51 | return ret; 52 | } 53 | 54 | int esp_peer_signaling_send_msg(esp_peer_signaling_handle_t handle, esp_peer_signaling_msg_t *msg) 55 | { 56 | if (handle == NULL || msg == NULL) { 57 | return ESP_PEER_ERR_INVALID_ARG; 58 | } 59 | signaling_wrapper_t *sig = (signaling_wrapper_t *)handle; 60 | return sig->impl.send_msg(sig->sig_handle, msg); 61 | } 62 | 63 | int esp_peer_signaling_stop(esp_peer_signaling_handle_t handle) 64 | { 65 | if (handle == NULL) { 66 | return ESP_PEER_ERR_INVALID_ARG; 67 | } 68 | signaling_wrapper_t *sig = (signaling_wrapper_t *)handle; 69 | int ret = sig->impl.stop(sig->sig_handle); 70 | free(sig); 71 | return ret; 72 | } -------------------------------------------------------------------------------- /components/esp_webrtc/src/esp_webrtc_version.c: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #define ESP_WBRTC_VERSION "0.9.0" 26 | 27 | const char* esp_webrtc_get_version(void) 28 | { 29 | return ESP_WBRTC_VERSION; 30 | } 31 | -------------------------------------------------------------------------------- /components/media_lib_sal/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}") 2 | 3 | set(COMPONENT_ADD_INCLUDEDIRS include include/port) 4 | 5 | # Edit following two lines to set component requirements (see docs) 6 | 7 | list (APPEND COMPONENT_SRCDIRS ./ ./port ./mem_trace) 8 | 9 | list(APPEND COMPONENT_REQUIRES esp-tls mbedtls esp_netif) 10 | 11 | register_component() 12 | -------------------------------------------------------------------------------- /components/media_lib_sal/Kconfig.projbuild: -------------------------------------------------------------------------------- 1 | menu "ADF Library Configuration" 2 | 3 | config MEDIA_PROTOCOL_LIB_ENABLE 4 | bool "Enable Media Protocol Library" 5 | default "y" 6 | 7 | config MEDIA_LIB_MEM_AUTO_TRACE 8 | bool "Support trace memory automatically after media_lib_sal init" 9 | default "n" 10 | 11 | config MEDIA_LIB_MEM_TRACE_DEPTH 12 | int 13 | prompt "Memory trace stack depth" if MEDIA_LIB_MEM_AUTO_TRACE 14 | depends on MEDIA_LIB_MEM_AUTO_TRACE 15 | default 3 16 | help 17 | Set memory trace depth 18 | 19 | config MEDIA_LIB_MEM_TRACE_NUM 20 | int 21 | prompt "Memory trace number" if MEDIA_LIB_MEM_AUTO_TRACE 22 | depends on MEDIA_LIB_MEM_AUTO_TRACE 23 | default 1024 24 | help 25 | Set memory trace number 26 | 27 | config MEDIA_LIB_MEM_TRACE_MODULE 28 | bool "Trace for module memory usage" 29 | depends on MEDIA_LIB_MEM_AUTO_TRACE 30 | default y 31 | 32 | config MEDIA_LIB_MEM_TRACE_LEAKAGE 33 | depends on MEDIA_LIB_MEM_AUTO_TRACE 34 | bool "Trace for memory leakage" 35 | default y 36 | 37 | config MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 38 | bool "Trace to save memory history" 39 | depends on MEDIA_LIB_MEM_AUTO_TRACE 40 | default n 41 | 42 | config MEDIA_LIB_MEM_SAVE_CACHE_SIZE 43 | int 44 | prompt "Cache buffer size to store save history" if MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 45 | depends on MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 46 | default 32768 47 | help 48 | Set cache size for memory history 49 | 50 | config MEDIA_LIB_MEM_TRACE_SAVE_PATH 51 | string "Memory trace save path" if MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 52 | depends on MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 53 | default "/sdcard/trace.log" 54 | help 55 | Set memory trace save path 56 | 57 | endmenu 58 | -------------------------------------------------------------------------------- /components/media_lib_sal/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | 6 | COMPONENT_ADD_INCLUDEDIRS := include include/port 7 | COMPONENT_SRCDIRS := . port 8 | COMPONENT_PRIV_INCLUDEDIRS := 9 | -------------------------------------------------------------------------------- /components/media_lib_sal/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | idf: 4 | version: ">=4.1.0" 5 | -------------------------------------------------------------------------------- /components/media_lib_sal/include/media_lib_err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2022 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 | 25 | #ifndef MEDIA_LIB_ERRCODE_H 26 | #define MEDIA_LIB_ERRCODE_H 27 | 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #include "esp_err.h" 33 | 34 | typedef enum { 35 | ESP_MEDIA_ERR_OK = ESP_OK, 36 | ESP_MEDIA_ERR_FAIL = ESP_FAIL, 37 | ESP_MEDIA_ERR_NO_MEM = ESP_ERR_NO_MEM, 38 | ESP_MEDIA_ERR_INVALID_ARG = ESP_ERR_INVALID_ARG, 39 | ESP_MEDIA_ERR_WRONG_STATE = ESP_ERR_INVALID_STATE, 40 | ESP_MEDIA_ERR_INVALID_SIZE = ESP_ERR_INVALID_SIZE, 41 | ESP_MEDIA_ERR_NOT_FOUND = ESP_ERR_NOT_FOUND, 42 | ESP_MEDIA_ERR_NOT_SUPPORT = ESP_ERR_NOT_SUPPORTED, 43 | ESP_MEDIA_ERR_TIMEOUT = ESP_ERR_TIMEOUT, 44 | ESP_MEDIA_ERR_INVALID_RESPONSE = ESP_ERR_INVALID_RESPONSE, 45 | ESP_MEDIA_ERR_INVALID_CRC = ESP_ERR_INVALID_CRC, 46 | ESP_MEDIA_ERR_INVALID_VERSION = ESP_ERR_INVALID_VERSION, 47 | 48 | ESP_MEDIA_ERR_BASE = 0x90000, 49 | ESP_MEDIA_ERR_READ_DATA = (ESP_MEDIA_ERR_BASE + 1), 50 | ESP_MEDIA_ERR_WRITE_DATA = (ESP_MEDIA_ERR_BASE + 2), 51 | ESP_MEDIA_ERR_BAD_DATA = (ESP_MEDIA_ERR_BASE + 3), 52 | ESP_MEDIA_ERR_EXCEED_LIMIT = (ESP_MEDIA_ERR_BASE + 4), 53 | ESP_MEDIA_ERR_CONNECT_FAIL = (ESP_MEDIA_ERR_BASE + 5), 54 | ESP_MEDIA_ERR_RESET = (ESP_MEDIA_ERR_BASE + 6) 55 | } esp_media_err_t; 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /components/media_lib_sal/include/media_lib_netif.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2023 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 | 25 | #ifndef MEDIA_LIB_NETIF_H 26 | #define MEDIA_LIB_NETIF_H 27 | 28 | #include "media_lib_netif_reg.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Wrapper for get ipv4 information 36 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 37 | * - Others: returned by wrapper function directly 38 | */ 39 | int media_lib_netif_get_ipv4_info(media_lib_net_type_t type, media_lib_ipv4_info_t *ip_info); 40 | 41 | /** 42 | * @brief Wrapper for convert ipv4 into string 43 | * @return - NULL: wrapper function not registered 44 | * - Others: returned by wrapper function directly 45 | */ 46 | char* media_lib_ipv4_ntoa(const media_lib_ipv4_addr_t *addr); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif -------------------------------------------------------------------------------- /components/media_lib_sal/include/media_lib_tls.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2022 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 | 25 | #ifndef MEDIA_LIB_TLS_H 26 | #define MEDIA_LIB_TLS_H 27 | 28 | #include "media_lib_tls_reg.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | 34 | /** 35 | * @brief Wrapper for create tls client instance 36 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 37 | * - Others: returned by wrapper function directly 38 | */ 39 | media_lib_tls_handle_t media_lib_tls_new(const char *hostname, int hostlen, int port, const media_lib_tls_cfg_t *cfg); 40 | 41 | /** 42 | * @brief Wrapper for create tls server instance 43 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 44 | * - Others: returned by wrapper function directly 45 | */ 46 | media_lib_tls_handle_t media_lib_tls_new_server(int fd, const media_lib_tls_server_cfg_t *cfg); 47 | 48 | /** 49 | * @brief Wrapper for esp_tls write 50 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 51 | * - Others: returned by wrapper function directly 52 | */ 53 | int media_lib_tls_write(media_lib_tls_handle_t tls, const void *data, size_t datalen); 54 | 55 | /** 56 | * @brief Wrapper for esp_tls read 57 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 58 | * - Others: returned by wrapper function directly 59 | */ 60 | int media_lib_tls_read(media_lib_tls_handle_t tls, void *data, size_t datalen); 61 | 62 | /** 63 | * @brief Wrapper for esp_tls getsockfd 64 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 65 | * - Others: returned by wrapper function directly 66 | */ 67 | int media_lib_tls_getsockfd(media_lib_tls_handle_t tls); 68 | 69 | /** 70 | * @brief Wrapper for esp_tls delete 71 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 72 | */ 73 | int media_lib_tls_delete(media_lib_tls_handle_t tls); 74 | 75 | /** 76 | * @brief Wrapper for esp_tls get bytes avail 77 | * @return - ESP_ERR_NOT_SUPPORTED: wrapper function not registered 78 | * - Others: returned by wrapper function directly 79 | */ 80 | int media_lib_tls_get_bytes_avail(media_lib_tls_handle_t tls); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /components/media_lib_sal/include/msg_q.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Message queue handle 35 | */ 36 | typedef struct msg_q_t* msg_q_handle_t; 37 | 38 | /** 39 | * @brief Create message queue 40 | * 41 | * @param[in] msg_number The maximum number of messages in the queue 42 | * @param[out] msg_size Message size 43 | * 44 | * @return 45 | * - NULL No resource to create message queue 46 | * - Others Message queue handle 47 | * 48 | */ 49 | msg_q_handle_t msg_q_create(int msg_number, int msg_size); 50 | 51 | /** 52 | * @brief Send message to queue 53 | * 54 | * @param[in] q Message queue handle 55 | * @param[in] msg Message to be inserted into queue 56 | * @param[in] size Message size, need not larger than msg_size when created 57 | * 58 | * @return 59 | * - 0 On success 60 | * - -1 On failure 61 | * 62 | */ 63 | int msg_q_send(msg_q_handle_t q, void *msg, int size); 64 | 65 | /** 66 | * @brief Receive message from queue 67 | * 68 | * @param[in] q Message queue handle 69 | * @param[out] msg Message to be inserted into queue 70 | * @param[in] size Message size, need not larger than msg_size when created 71 | * @param[in] no_wait If true, return immediately if no message in queue 72 | * 73 | * @return 74 | * - 0 On success 75 | * - -1 On failure 76 | * - 1 If no message in queue and no_wait is true 77 | * 78 | */ 79 | int msg_q_recv(msg_q_handle_t q, void *msg, int size, bool no_wait); 80 | 81 | /** 82 | * @brief Get items number in message queue 83 | * 84 | * @param[in] q Message queue handle 85 | * 86 | * @return 87 | * - 0 No message in queue 88 | * - Others Current queued items number 89 | * 90 | */ 91 | int msg_q_number(msg_q_handle_t q); 92 | 93 | /** 94 | * @brief Destroy message queue 95 | * 96 | * @param[in] q Message queue handle 97 | * 98 | */ 99 | void msg_q_destroy(msg_q_handle_t q); 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | -------------------------------------------------------------------------------- /components/media_lib_sal/include/port/media_lib_adapter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2021 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 | 25 | #ifndef MEDIA_LIB_ADAPTER_H 26 | #define MEDIA_LIB_ADAPTER_H 27 | 28 | #include "esp_err.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | /** 34 | * @brief Add all external library that media used using default function wrapper 35 | * 36 | * @return 37 | * - ESP_OK: on success 38 | * - ESP_ERR_INVALID_ARG: wrapper functions not OK 39 | */ 40 | esp_err_t media_lib_add_default_adapter(void); 41 | 42 | /** 43 | * @brief Add default OS wrapper fuctions 44 | * 45 | * @return 46 | * - ESP_OK: on success 47 | * - ESP_ERR_INVALID_ARG: OS wrapper functions not OK 48 | */ 49 | esp_err_t media_lib_add_default_os_adapter(void); 50 | 51 | /** 52 | * @brief Add default crypt related wrapper functions 53 | * 54 | * @return 55 | * - ESP_OK: on success 56 | * - ESP_ERR_INVALID_ARG: crypt wrapper functions not OK 57 | */ 58 | esp_err_t media_lib_add_default_crypt_adapter(void); 59 | 60 | /** 61 | * @brief Add default socket related wrapper functions 62 | * 63 | * @return 64 | * - ESP_OK: on success 65 | * - ESP_ERR_INVALID_ARG: socket wrapper functions not OK 66 | */ 67 | esp_err_t media_lib_add_default_socket_adapter(void); 68 | 69 | /** 70 | * @brief Add default tls related wrapper functions 71 | * 72 | * @return 73 | * - ESP_OK: on success 74 | * - ESP_ERR_INVALID_ARG: tls wrapper functions not OK 75 | */ 76 | esp_err_t media_lib_add_default_tls_adapter(void); 77 | 78 | /** 79 | * @brief Add default network interface related wrapper functions 80 | * 81 | * @return 82 | * - ESP_OK: on success 83 | * - ESP_ERR_INVALID_ARG: Network interface wrapper functions not OK 84 | */ 85 | esp_err_t media_lib_add_default_netif_adapter(void); 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /components/media_lib_sal/include/port/media_lib_netif_reg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2023 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 | #ifndef MEDIA_LIB_NETIF_REG_H 25 | #define MEDIA_LIB_NETIF_REG_H 26 | 27 | #include "esp_err.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | typedef struct { 34 | uint32_t addr; /*!< IPv4 address */ 35 | } media_lib_ipv4_addr_t; 36 | 37 | typedef struct { 38 | media_lib_ipv4_addr_t ip; /**< Interface IPV4 address */ 39 | media_lib_ipv4_addr_t netmask; /**< Interface IPV4 netmask */ 40 | media_lib_ipv4_addr_t gw; /**< Interface IPV4 gateway address */ 41 | } media_lib_ipv4_info_t; 42 | 43 | typedef enum { 44 | MEDIA_LIB_NET_TYPE_STA = 0, /**< Wi-Fi STA (station) interface */ 45 | MEDIA_LIB_NET_TYPE_AP, /**< Wi-Fi soft-AP interface */ 46 | MEDIA_LIB_NET_TYPE_ETH, /**< Ethernet interface */ 47 | } media_lib_net_type_t; 48 | 49 | typedef int (*__media_lib_netif_get_ipv4_info)(media_lib_net_type_t type, media_lib_ipv4_info_t *ip_info); 50 | typedef char* (*__media_lib_ipv4_ntoa)(const media_lib_ipv4_addr_t *addr); 51 | typedef struct { 52 | __media_lib_netif_get_ipv4_info get_ipv4_info; /*!< Get ipv4 information */ 53 | __media_lib_ipv4_ntoa ipv4_ntoa; 54 | } media_lib_netif_t; 55 | 56 | /** 57 | * @brief Register network interface related wrapper functions for media library 58 | * 59 | * @param netif_lib: Network interface wrapper function lists 60 | * 61 | * @return 62 | * - ESP_OK: On success 63 | * - ESP_ERR_INVALID_ARG: Some members of network interface lib not set 64 | */ 65 | esp_err_t media_lib_netif_register(media_lib_netif_t *netif_lib); 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /components/media_lib_sal/media_lib_adapter.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2021 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in 7 | * which case, it is free of charge, to any person obtaining a copy of this 8 | * software and associated documentation files (the "Software"), to deal in the 9 | * Software without restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do 12 | * so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "esp_log.h" 28 | #include "media_lib_adapter.h" 29 | #include "media_lib_mem_trace.h" 30 | 31 | #define TAG "MEDIA_ADAPTER" 32 | 33 | #ifdef CONFIG_MEDIA_LIB_MEM_AUTO_TRACE 34 | static void add_memory_trace(void) 35 | { 36 | media_lib_mem_trace_cfg_t trace_cfg = {0}; 37 | #ifdef CONFIG_MEDIA_LIB_MEM_TRACE_MODULE 38 | trace_cfg.trace_type |= MEDIA_LIB_MEM_TRACE_MODULE_USAGE; 39 | #endif 40 | #ifdef CONFIG_MEDIA_LIB_MEM_TRACE_LEAKAGE 41 | trace_cfg.trace_type |= MEDIA_LIB_MEM_TRACE_LEAK; 42 | #endif 43 | #ifdef CONFIG_MEDIA_LIB_MEM_TRACE_SAVE_HISTORY 44 | trace_cfg.trace_type |= MEDIA_LIB_MEM_TRACE_SAVE_HISTORY; 45 | trace_cfg.save_cache_size = CONFIG_MEDIA_LIB_MEM_SAVE_CACHE_SIZE; 46 | trace_cfg.save_path = CONFIG_MEDIA_LIB_MEM_TRACE_SAVE_PATH; 47 | #endif 48 | trace_cfg.stack_depth = CONFIG_MEDIA_LIB_MEM_TRACE_DEPTH; 49 | trace_cfg.record_num = CONFIG_MEDIA_LIB_MEM_TRACE_NUM; 50 | media_lib_start_mem_trace(&trace_cfg); 51 | } 52 | #endif 53 | 54 | esp_err_t media_lib_add_default_adapter(void) 55 | { 56 | esp_err_t ret; 57 | ret = media_lib_add_default_os_adapter(); 58 | if (ret != ESP_OK) { 59 | ESP_LOGE(TAG, "Fail to add os lib"); 60 | } 61 | #ifdef CONFIG_MEDIA_PROTOCOL_LIB_ENABLE 62 | ret = media_lib_add_default_crypt_adapter(); 63 | if (ret != ESP_OK) { 64 | ESP_LOGE(TAG, "Fail to add crypt lib"); 65 | } 66 | ret = media_lib_add_default_socket_adapter(); 67 | if (ret != ESP_OK) { 68 | ESP_LOGE(TAG, "Fail to add socket lib"); 69 | } 70 | ret = media_lib_add_default_tls_adapter(); 71 | if (ret != ESP_OK) { 72 | ESP_LOGE(TAG, "Fail to add tls lib"); 73 | } 74 | ret = media_lib_add_default_netif_adapter(); 75 | if (ret != ESP_OK) { 76 | ESP_LOGE(TAG, "Fail to add netif lib"); 77 | } 78 | #endif 79 | #ifdef CONFIG_MEDIA_LIB_MEM_AUTO_TRACE 80 | add_memory_trace(); 81 | #endif 82 | return ret; 83 | } 84 | -------------------------------------------------------------------------------- /components/media_lib_sal/media_lib_common.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2021 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in 7 | * which case, it is free of charge, to any person obtaining a copy of this 8 | * software and associated documentation files (the "Software"), to deal in the 9 | * Software without restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do 12 | * so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "media_lib_common.h" 28 | 29 | bool media_lib_verify(void *lib, int size) 30 | { 31 | int i; 32 | void **check = (void **)lib; 33 | if (lib == NULL) { 34 | return false; 35 | } 36 | for (i = 0; i < size / sizeof(void *); i++) { 37 | if (check[i] == NULL) { 38 | return false; 39 | } 40 | } 41 | return true; 42 | } -------------------------------------------------------------------------------- /components/media_lib_sal/media_lib_common.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2021 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in 7 | * which case, it is free of charge, to any person obtaining a copy of this 8 | * software and associated documentation files (the "Software"), to deal in the 9 | * Software without restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do 12 | * so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #ifndef MEDIA_LIB_COMMON_H 28 | #ifdef __cplusplus 29 | extern "C" { 30 | #endif 31 | 32 | #include 33 | #include 34 | #include "esp_err.h" 35 | 36 | /** 37 | * @brief verify library functions pointer all set or not 38 | * 39 | * @param lib wrapper function struct pointer 40 | * @param size wrapper struct size 41 | * @return 42 | * -true library verify OK 43 | * -false library verify Fail 44 | */ 45 | bool media_lib_verify(void *lib, int size); 46 | 47 | #define MEDIA_LIB_DEFAULT_INSTALLER(src, dst, type) \ 48 | if (media_lib_verify(src, sizeof(type)) == false) { \ 49 | return ESP_ERR_INVALID_ARG; \ 50 | } \ 51 | memcpy(dst, src, sizeof(type)); \ 52 | return ESP_OK; 53 | 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | 58 | #endif -------------------------------------------------------------------------------- /components/media_lib_sal/media_lib_netif.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in 7 | * which case, it is free of charge, to any person obtaining a copy of this 8 | * software and associated documentation files (the "Software"), to deal in the 9 | * Software without restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do 12 | * so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "media_lib_netif.h" 28 | #include "media_lib_netif_reg.h" 29 | #include "media_lib_common.h" 30 | 31 | #ifdef CONFIG_MEDIA_PROTOCOL_LIB_ENABLE 32 | 33 | static media_lib_netif_t media_netif_lib; 34 | 35 | esp_err_t media_lib_netif_register(media_lib_netif_t *netif_lib) 36 | { 37 | MEDIA_LIB_DEFAULT_INSTALLER(netif_lib, &media_netif_lib, media_lib_netif_t); 38 | } 39 | 40 | int media_lib_netif_get_ipv4_info(media_lib_net_type_t type, media_lib_ipv4_info_t *ip_info) 41 | { 42 | if (media_netif_lib.get_ipv4_info) { 43 | return media_netif_lib.get_ipv4_info(type, ip_info); 44 | } 45 | return ESP_ERR_NOT_SUPPORTED; 46 | } 47 | 48 | char* media_lib_ipv4_ntoa(const media_lib_ipv4_addr_t *addr) 49 | { 50 | if (media_netif_lib.ipv4_ntoa) { 51 | return media_netif_lib.ipv4_ntoa(addr); 52 | } 53 | return NULL; 54 | } 55 | #endif 56 | -------------------------------------------------------------------------------- /components/media_lib_sal/media_lib_tls.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2022 5 | * 6 | * Permission is hereby granted for use on all ESPRESSIF SYSTEMS products, in 7 | * which case, it is free of charge, to any person obtaining a copy of this 8 | * software and associated documentation files (the "Software"), to deal in the 9 | * Software without restriction, including without limitation the rights to use, 10 | * copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 11 | * the Software, and to permit persons to whom the Software is furnished to do 12 | * so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in 15 | * all copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | * 25 | */ 26 | 27 | #include "media_lib_tls.h" 28 | #include "media_lib_tls_reg.h" 29 | #include "media_lib_common.h" 30 | 31 | #ifdef CONFIG_MEDIA_PROTOCOL_LIB_ENABLE 32 | static media_lib_tls_t media_tls_lib; 33 | 34 | esp_err_t media_lib_tls_register(media_lib_tls_t *tls_lib) 35 | { 36 | MEDIA_LIB_DEFAULT_INSTALLER(tls_lib, &media_tls_lib, media_lib_tls_t); 37 | } 38 | 39 | media_lib_tls_handle_t media_lib_tls_new(const char *hostname, int hostlen, int port, const media_lib_tls_cfg_t *cfg) 40 | { 41 | if (media_tls_lib.tls_new) { 42 | return media_tls_lib.tls_new(hostname, hostlen, port, cfg); 43 | } 44 | return NULL; 45 | } 46 | 47 | media_lib_tls_handle_t media_lib_tls_new_server(int fd, const media_lib_tls_server_cfg_t *cfg) 48 | { 49 | if (media_tls_lib.tls_new_server) { 50 | return media_tls_lib.tls_new_server(fd, cfg); 51 | } 52 | return NULL; 53 | } 54 | 55 | int media_lib_tls_get_bytes_avail(media_lib_tls_handle_t tls) 56 | { 57 | if (media_tls_lib.tls_get_bytes_avail) { 58 | return media_tls_lib.tls_get_bytes_avail(tls); 59 | } 60 | 61 | return ESP_ERR_NOT_SUPPORTED; 62 | } 63 | 64 | int media_lib_tls_write(media_lib_tls_handle_t tls, const void *data, size_t datalen) 65 | { 66 | if (media_tls_lib.tls_write) { 67 | return media_tls_lib.tls_write(tls, data, datalen); 68 | } 69 | 70 | return ESP_ERR_NOT_SUPPORTED; 71 | } 72 | 73 | int media_lib_tls_read(media_lib_tls_handle_t tls, void *data, size_t datalen) 74 | { 75 | if (media_tls_lib.tls_read) { 76 | return media_tls_lib.tls_read(tls, data, datalen); 77 | } 78 | 79 | return ESP_ERR_NOT_SUPPORTED; 80 | } 81 | 82 | int media_lib_tls_getsockfd(media_lib_tls_handle_t tls) 83 | { 84 | if (media_tls_lib.tls_getsockfd) { 85 | return media_tls_lib.tls_getsockfd(tls); 86 | } 87 | return ESP_ERR_NOT_SUPPORTED; 88 | } 89 | 90 | int media_lib_tls_delete(media_lib_tls_handle_t tls) 91 | { 92 | if (media_tls_lib.tls_delete) { 93 | return media_tls_lib.tls_delete(tls); 94 | } 95 | return ESP_ERR_NOT_SUPPORTED; 96 | } 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /components/media_lib_sal/mem_trace/media_lib_mem_his.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2023 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 | #ifndef MEDIA_LIB_MEM_HIS_H 25 | #define MEDIA_LIB_MEM_HIS_H 26 | 27 | #include "media_lib_mem_trace.h" 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /** 34 | * @brief Start memory history trace 35 | * @param cfg: Memory trace configuration 36 | * @return - ESP_MEDIA_ERR_NO_MEM: Not enough memory 37 | * - ESP_MEDIA_ERR_FAIL: Not resource 38 | * - ESP_MEDIA_ERR_OK: On success 39 | */ 40 | int media_lib_start_mem_his(media_lib_mem_trace_cfg_t *cfg); 41 | 42 | /** 43 | * @brief Add malloc action to history 44 | * @param addr: Memory address 45 | * @param size: Memory size 46 | * @param stack_num: Call stack number to record 47 | * @param stack: Stack frames to record 48 | * @param flag: Flag to record 49 | */ 50 | void media_lib_add_mem_malloc_his(void *addr, int size, int stack_num, void *stack, uint8_t flag); 51 | 52 | /** 53 | * @brief Add free action to history 54 | * @param addr: Memory address 55 | */ 56 | void media_lib_add_mem_free_his(void *addr); 57 | 58 | /** 59 | * @brief Stop memory history trace 60 | */ 61 | void media_lib_stop_mem_his(void); 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /components/webrtc_utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(COMPONENT_ADD_INCLUDEDIRS .) 3 | 4 | # Edit following two lines to set component requirements (see docs) 5 | 6 | list (APPEND COMPONENT_SRCDIRS .) 7 | 8 | list(APPEND COMPONENT_REQUIRES esp-tls mbedtls esp_netif esp_ringbuf) 9 | 10 | register_component() 11 | -------------------------------------------------------------------------------- /components/webrtc_utils/webrtc_utils_time.c: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #include 26 | #include 27 | #include "esp_netif.h" 28 | #include "esp_netif_sntp.h" 29 | 30 | static const char *TAG = "webrtc_time_utils"; 31 | 32 | #define DATE_TIME_STRING_FORMAT (char *) "%Y%m%dT%H%M%SZ" 33 | 34 | /** 35 | * https://en.wikipedia.org/wiki/ISO_8601 36 | */ 37 | void webrtc_utils_get_time_iso8601(char time_buf[18]) 38 | { 39 | time_t now; 40 | time(&now); 41 | strftime(time_buf, 17, DATE_TIME_STRING_FORMAT, gmtime(&now)); 42 | } 43 | 44 | esp_err_t webrtc_utils_wait_for_time_sync(uint32_t timeout_ms) 45 | { 46 | /* wait for time to be set */ 47 | int retry = 0; 48 | int max_retries = timeout_ms / 2000; /* split the retries in 2 seconds each */ 49 | 50 | while (esp_netif_sntp_sync_wait(pdMS_TO_TICKS(2000)) != ESP_OK && ++retry < max_retries) { 51 | ESP_LOGI(TAG, "Waiting for system time to be set... (%d/%d)", retry, max_retries); 52 | } 53 | 54 | return ESP_OK; 55 | } 56 | 57 | esp_err_t webrtc_utils_time_sync_init() 58 | { 59 | static bool init_done = false; 60 | if (init_done) { 61 | ESP_LOGW(TAG, "Time sync is done already..."); 62 | return ESP_OK; 63 | } 64 | ESP_LOGI(TAG, "Initializing SNTP"); 65 | esp_sntp_config_t config = ESP_NETIF_SNTP_DEFAULT_CONFIG_MULTIPLE(2, 66 | ESP_SNTP_SERVER_LIST("time.windows.com", "pool.ntp.org" ) ); 67 | esp_netif_sntp_init(&config); 68 | init_done = true; 69 | return ESP_OK; 70 | } 71 | -------------------------------------------------------------------------------- /components/webrtc_utils/webrtc_utils_time.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ESPRESSIF MIT License 3 | * 4 | * Copyright (c) 2025 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 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | /** 31 | * @brief Get current time in IO8601 format 32 | * 33 | * @return char* Time string 34 | * @note Caller is supposed to free the output string 35 | */ 36 | void webrtc_utils_get_time_iso8601(char time_buf[18]); 37 | 38 | /** 39 | * @brief Wait for timeout_ms for time_sync to finish 40 | * 41 | * @param timeout_ms time in ms to wait for time_sync. Note, the actual time spent could be more 42 | * @return esp_err_t ESP_OK if success, apt error otherwise 43 | */ 44 | esp_err_t webrtc_utils_wait_for_time_sync(uint32_t timeout_ms); 45 | 46 | /** 47 | * @brief Init sntp time_sync 48 | * 49 | * @return ESP_OK on success, apt error otherwise 50 | */ 51 | esp_err_t webrtc_utils_time_sync_init(); 52 | -------------------------------------------------------------------------------- /solutions/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | set(component_srcdirs "./") 3 | 4 | set(component_requires esp_netif nvs_flash esp_wifi) 5 | 6 | if("${IDF_TARGET}" STREQUAL "esp32p4") 7 | list(APPEND component_requires "ethernet_init esp_eth") 8 | endif() 9 | 10 | idf_component_register( 11 | SRC_DIRS ./ 12 | INCLUDE_DIRS ./ 13 | REQUIRES ${component_requires} 14 | ) 15 | -------------------------------------------------------------------------------- /solutions/common/Kconfig: -------------------------------------------------------------------------------- 1 | menu "WebRTC Demo Common" 2 | 3 | config NETWORK_USE_ETHERNET 4 | bool "Network use Ethernet" 5 | default n 6 | depends on IDF_TARGET_ESP32P4 7 | help 8 | Enable this option to use Ethernet 9 | 10 | endmenu 11 | -------------------------------------------------------------------------------- /solutions/common/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | espressif/esp_wifi_remote: 4 | version: "~0.10.0" 5 | rules: 6 | - if: "target in [esp32p4]" 7 | -------------------------------------------------------------------------------- /solutions/common/media_sys.h: -------------------------------------------------------------------------------- 1 | /* Media system 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "esp_webrtc.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Build media system 20 | * 21 | * @param[in] rtc_handle WebRTC handle 22 | * 23 | * @return 24 | * - 0 On success 25 | * - Others Fail to build 26 | */ 27 | int media_sys_buildup(void); 28 | 29 | /** 30 | * @brief Get media provider 31 | * 32 | * @param[out] provider Media provider to be returned 33 | * 34 | * @return 35 | * - 0 On success 36 | * - Others Invalid argument 37 | */ 38 | int media_sys_get_provider(esp_webrtc_media_provider_t *provider); 39 | 40 | /** 41 | * @brief Play captured media directly 42 | * 43 | * @return 44 | * - 0 On success 45 | * - Others Fail to capture or play 46 | */ 47 | int test_capture_to_player(void); 48 | 49 | /** 50 | * @brief Play music 51 | * 52 | * @param[in] data Music data to be played 53 | * @param[in] size Music data size 54 | * @param[in] duration Play duration, when duration over data duration will replay 55 | * 56 | * @return 57 | * - 0 On success 58 | * - Others Fail to play 59 | */ 60 | int play_music(const uint8_t *data, int size, int duration); 61 | 62 | /** 63 | * @brief Stop music 64 | * 65 | * @return 66 | * - 0 On success 67 | * - Others Fail to stop 68 | */ 69 | int stop_music(void); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif -------------------------------------------------------------------------------- /solutions/common/network.h: -------------------------------------------------------------------------------- 1 | /* Network 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Network connect callback 20 | */ 21 | typedef int (*network_connect_cb)(bool connected); 22 | 23 | /** 24 | * @brief Initialize network 25 | * 26 | * @param[in] ssid Wifi ssid 27 | * @param[in] password Wifi password 28 | * @param[in] cb Network connect callback 29 | * 30 | * @return 31 | * - 0 On success 32 | * - Others Fail to initialized 33 | */ 34 | int network_init(const char *ssid, const char *password, network_connect_cb cb); 35 | 36 | /** 37 | * @brief Get current network mac 38 | * 39 | * @param[out] mac Network mac to store 40 | * 41 | * @return 42 | * - 0 On success 43 | * - Others Fail to initialized 44 | */ 45 | int network_get_mac(uint8_t mac[6]); 46 | 47 | /** 48 | * @brief Check network connected or not 49 | * 50 | * @return 51 | * - true Network connected 52 | * - false Network disconnected 53 | */ 54 | bool network_is_connected(void); 55 | 56 | /** 57 | * @brief Connect wifi manually 58 | * 59 | * @param[in] ssid Wifi ssid 60 | * @param[in] password Wifi password 61 | * 62 | * @return 63 | * - 0 On success 64 | * - Others Fail to connect 65 | */ 66 | int network_connect_wifi(const char *ssid, const char *password); 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif -------------------------------------------------------------------------------- /solutions/common/sys_state.h: -------------------------------------------------------------------------------- 1 | /* System state 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Show current system memory usage and cpu usage 20 | */ 21 | void sys_state_show(void); 22 | 23 | /** 24 | * @brief Trace for heap memory 25 | * 26 | * @param[in] start Start or stop trace 27 | */ 28 | void sys_state_heap_trace(bool start); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif -------------------------------------------------------------------------------- /solutions/doorbell_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | project(doorbell_demo) 17 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "webrtc.c" "main.c" "board.c" "media_sys.c" 2 | EMBED_TXTFILES "ring.aac" "open.aac" "join.aac" 3 | INCLUDE_DIRS ".") 4 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/board.c: -------------------------------------------------------------------------------- 1 | /* Do simple board initialize 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include "esp_log.h" 12 | #include "codec_init.h" 13 | #include "codec_board.h" 14 | #include "esp_codec_dev.h" 15 | #include "sdkconfig.h" 16 | #include "settings.h" 17 | 18 | static const char *TAG = "Board"; 19 | 20 | void init_board() 21 | { 22 | ESP_LOGI(TAG, "Init board."); 23 | set_codec_board_type(TEST_BOARD_NAME); 24 | // Notes when use playback and record at same time, must set reuse_dev = false 25 | codec_init_cfg_t cfg = {.reuse_dev = false}; 26 | init_codec(&cfg); 27 | } 28 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/common.h: -------------------------------------------------------------------------------- 1 | /* Door Bell Demo 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "settings.h" 13 | #include "media_sys.h" 14 | #include "network.h" 15 | #include "sys_state.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /** 22 | * @brief Initialize for board 23 | */ 24 | void init_board(void); 25 | 26 | /** 27 | * @brief Start WebRTC 28 | * 29 | * @param[in] url Signaling URL 30 | * 31 | * @return 32 | * - 0 On success 33 | * - Others Fail to start 34 | */ 35 | int start_webrtc(char *url); 36 | 37 | /** 38 | * @brief Query WebRTC status 39 | */ 40 | void query_webrtc(void); 41 | 42 | /** 43 | * @brief Stop WebRTC 44 | * 45 | * @return 46 | * - 0 On success 47 | * - Others Fail to stop 48 | */ 49 | int stop_webrtc(void); 50 | 51 | /** 52 | * @brief Send command to peer 53 | */ 54 | void send_cmd(char *cmd); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: ">=5.0" 6 | ## Import needed components only 7 | capture_audio_src: 8 | path: ../../../components/esp_capture/src/impl/capture_audio_src 9 | capture_video_src: 10 | path: ../../../components/esp_capture/src/impl/capture_video_src 11 | capture_audio_enc: 12 | path: ../../../components/esp_capture/src/impl/capture_audio_enc 13 | capture_video_enc: 14 | path: ../../../components/esp_capture/src/impl/capture_video_enc 15 | peer_default: 16 | path: ../../../components/esp_webrtc/impl/peer_default 17 | render_impl: 18 | path: ../../../components/av_render/render_impl 19 | espressif/esp_h264: 20 | version: "1.0.4" 21 | rules: 22 | - if: target in [esp32p4, esp32s3] 23 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/join.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/solutions/doorbell_demo/main/join.aac -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/open.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/solutions/doorbell_demo/main/open.aac -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/ring.aac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/espressif/esp-webrtc-solution/9512eef258a45aafcaaa309b1a67505c8b500363/solutions/doorbell_demo/main/ring.aac -------------------------------------------------------------------------------- /solutions/doorbell_demo/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "sdkconfig.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Board name setting refer to `codec_board` README.md for more details 20 | */ 21 | #if CONFIG_IDF_TARGET_ESP32P4 22 | #define TEST_BOARD_NAME "ESP32_P4_DEV_V14" 23 | #else 24 | #define TEST_BOARD_NAME "S3_Korvo_V2" 25 | #endif 26 | 27 | /** 28 | * @brief Video resolution settings 29 | */ 30 | #if CONFIG_IDF_TARGET_ESP32P4 31 | #define VIDEO_WIDTH 1920 32 | #define VIDEO_HEIGHT 1080 33 | #define VIDEO_FPS 25 34 | #else 35 | #define VIDEO_WIDTH 320 36 | #define VIDEO_HEIGHT 240 37 | #define VIDEO_FPS 10 38 | #endif 39 | 40 | /** 41 | * @brief Set for wifi ssid 42 | */ 43 | #define WIFI_SSID "XXXX" 44 | 45 | /** 46 | * @brief Set for wifi password 47 | */ 48 | #define WIFI_PASSWORD "XXXX" 49 | 50 | /** 51 | * @brief Whether enable data channel 52 | */ 53 | #define DATA_CHANNEL_ENABLED (false) 54 | 55 | #if CONFIG_IDF_TARGET_ESP32P4 56 | /** 57 | * @brief GPIO for ring button 58 | * 59 | * @note When use ESP32P4-Fuction-Ev-Board, GPIO35(boot button) is connected RMII_TXD1 60 | * When enable `NETWORK_USE_ETHERNET` will cause socket error 61 | * User must replace it to a unused GPIO instead (like GPIO27) 62 | */ 63 | #define DOOR_BELL_RING_BUTTON 35 64 | #else 65 | /** 66 | * @brief GPIO for ring button 67 | * 68 | * @note When use ESP32S3-KORVO-V3 Use ADC button as ring button 69 | */ 70 | #define DOOR_BELL_RING_BUTTON 5 71 | #endif 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 3M, 6 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | CONFIG_FREERTOS_HZ=1000 13 | 14 | # Support 2 SNTP 15 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 16 | 17 | # Enable DTLS SRTP 18 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 19 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 20 | 21 | # Use new I2C master 22 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 23 | 24 | # Enable experimental features 25 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 26 | 27 | # Use customer partition table 28 | CONFIG_PARTITION_TABLE_CUSTOM=y 29 | 30 | # Allocate LWIP and MbedTLS on SPIRAM 31 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256 32 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 33 | CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y 34 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # Flash setting 2 | CONFIG_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | CONFIG_SPIRAM_SPEED_200M=y 6 | 7 | # If you use serial JTAG turn on this option 8 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 9 | 10 | # Use camera SC2336 11 | CONFIG_CAMERA_SC2336=y 12 | CONFIG_CAMERA_SC2336_MIPI_RAW10_1920x1080_25FPS_2_LANE=y 13 | 14 | # Enable ISP pipelines 15 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 16 | 17 | # Set Slave target type 18 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 19 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 20 | 21 | # Enable following configuration if support C5 Slave, make sure GPIO matched 22 | # CONFIG_SLAVE_IDF_TARGET_ESP32C5=y 23 | # CONFIG_ESP_HOSTED_SPI_HD_HOST_INTERFACE=y 24 | # CONFIG_ESP_SPI_HD_GPIO_CS=4 25 | # CONFIG_ESP_SPI_HD_GPIO_CLK=5 26 | # CONFIG_ESP_SPI_HD_GPIO_D0=20 27 | # CONFIG_ESP_SPI_HD_GPIO_D1=21 28 | # CONFIG_ESP_SPI_HD_GPIO_D2=22 29 | # CONFIG_ESP_SPI_HD_GPIO_D3=23 30 | # CONFIG_ESP_SPI_HD_GPIO_DATA_READY=32 31 | # CONFIG_ESP_SPI_HD_GPIO_RESET_SLAVE=33 32 | # CONFIG_ESP_SPI_HD_FREQ_ESP32XX=40 33 | # CONFIG_ESP_HOSTED_SPI_HD_PRIV_INTERFACE_4_DATA_LINES=y 34 | -------------------------------------------------------------------------------- /solutions/doorbell_demo/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | 6 | CONFIG_SPIRAM_MODE_OCT=y 7 | CONFIG_SPIRAM_SPEED_120M=y 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | 10 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 11 | 12 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 13 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 14 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 16 | 17 | CONFIG_FLASHMODE_QIO=y 18 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 19 | 20 | CONFIG_ESP_WS_CLIENT_ENABLE_DYNAMIC_BUFFER=y 21 | -------------------------------------------------------------------------------- /solutions/doorbell_local/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | project(doorbell_demo) 17 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "webrtc.c" "main.c" "board.c" "media_sys.c" "webrtc_http_server.c" 2 | EMBED_TXTFILES "ring.aac" "open.aac" "join.aac" "webrtc_test.html" 3 | "certs/servercert.pem" "certs/prvtkey.pem" 4 | INCLUDE_DIRS ".") 5 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/board.c: -------------------------------------------------------------------------------- 1 | /* Do simple board initialize 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include "esp_log.h" 12 | #include "codec_init.h" 13 | #include "codec_board.h" 14 | #include "esp_codec_dev.h" 15 | #include "sdkconfig.h" 16 | #include "settings.h" 17 | 18 | static const char *TAG = "Board"; 19 | 20 | void init_board() 21 | { 22 | ESP_LOGI(TAG, "Init board."); 23 | set_codec_board_type(TEST_BOARD_NAME); 24 | // Notes when use playback and record at same time, must set reuse_dev = false 25 | codec_init_cfg_t cfg = {.reuse_dev = false}; 26 | init_codec(&cfg); 27 | } 28 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/certs/prvtkey.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN PRIVATE KEY----- 2 | MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCwYp7epz++0QkH 3 | JioMD7U7BitLgpcYPi8Cid1l7snt6Kp546iQsDBJ3l8xnRtPU7ANEsjT8KxIHmyw 4 | h/NGp94FlOKRw3ahh3yUGtowS9vdHv+S+TAfuj07NjSnKIyv5KnGZJ+fDFl4Q1tT 5 | aQJybY1Z4itirL6/2CGEm8g/iYhLNDBsRMfpDpfXe4URyWiM3Rhf7ztqZdveb9al 6 | 3pAJZIDTLWCFQI1MvQjKamkAQkES/gZj0iUZFwbGJPBj54nkuLFLKedw7DbwgrVg 7 | 0+n3fQ9b/gQepw5PxQjyobY2DsDgGZV+MFjUmaUTa+XX68SrG4wJ+DwrkdmpHReB 8 | vFi1Hg1hAgMBAAECggEAaTCnZkl/7qBjLexIryC/CBBJyaJ70W1kQ7NMYfniWwui 9 | f0aRxJgOdD81rjTvkINsPp+xPRQO6oOadjzdjImYEuQTqrJTEUnntbu924eh+2D9 10 | Mf2CAanj0mglRnscS9mmljZ0KzoGMX6Z/EhnuS40WiJTlWlH6MlQU/FDnwC6U34y 11 | JKy6/jGryfsx+kGU/NRvKSru6JYJWt5v7sOrymHWD62IT59h3blOiP8GMtYKeQlX 12 | 49om9Mo1VTIFASY3lrxmexbY+6FG8YO+tfIe0tTAiGrkb9Pz6tYbaj9FjEWOv4Vc 13 | +3VMBUVdGJjgqvE8fx+/+mHo4Rg69BUPfPSrpEg7sQKBgQDlL85G04VZgrNZgOx6 14 | pTlCCl/NkfNb1OYa0BELqWINoWaWQHnm6lX8YjrUjwRpBF5s7mFhguFjUjp/NW6D 15 | 0EEg5BmO0ePJ3dLKSeOA7gMo7y7kAcD/YGToqAaGljkBI+IAWK5Su5yldrECTQKG 16 | YnMKyQ1MWUfCYEwHtPvFvE5aPwKBgQDFBWXekpxHIvt/B41Cl/TftAzE7/f58JjV 17 | MFo/JCh9TDcH6N5TMTRS1/iQrv5M6kJSSrHnq8pqDXOwfHLwxetpk9tr937VRzoL 18 | CuG1Ar7c1AO6ujNnAEmUVC2DppL/ck5mRPWK/kgLwZSaNcZf8sydRgphsW1ogJin 19 | 7g0nGbFwXwKBgQCPoZY07Pr1TeP4g8OwWTu5F6dSvdU2CAbtZthH5q98u1n/cAj1 20 | noak1Srpa3foGMTUn9CHu+5kwHPIpUPNeAZZBpq91uxa5pnkDMp3UrLIRJ2uZyr8 21 | 4PxcknEEh8DR5hsM/IbDcrCJQglM19ZtQeW3LKkY4BsIxjDf45ymH407IQKBgE/g 22 | Ul6cPfOxQRlNLH4VMVgInSyyxWx1mODFy7DRrgCuh5kTVh+QUVBM8x9lcwAn8V9/ 23 | nQT55wR8E603pznqY/jX0xvAqZE6YVPcw4kpZcwNwL1RhEl8GliikBlRzUL3SsW3 24 | q30AfqEViHPE3XpE66PPo6Hb1ymJCVr77iUuC3wtAoGBAIBrOGunv1qZMfqmwAY2 25 | lxlzRgxgSiaev0lTNxDzZkmU/u3dgdTwJ5DDANqPwJc6b8SGYTp9rQ0mbgVHnhIB 26 | jcJQBQkTfq6Z0H6OoTVi7dPs3ibQJFrtkoyvYAbyk36quBmNRjVh6rc8468bhXYr 27 | v/t+MeGJP/0Zw8v/X2CFll96 28 | -----END PRIVATE KEY----- 29 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/certs/servercert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDKzCCAhOgAwIBAgIUBxM3WJf2bP12kAfqhmhhjZWv0ukwDQYJKoZIhvcNAQEL 3 | BQAwJTEjMCEGA1UEAwwaRVNQMzIgSFRUUFMgc2VydmVyIGV4YW1wbGUwHhcNMTgx 4 | MDE3MTEzMjU3WhcNMjgxMDE0MTEzMjU3WjAlMSMwIQYDVQQDDBpFU1AzMiBIVFRQ 5 | UyBzZXJ2ZXIgZXhhbXBsZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB 6 | ALBint6nP77RCQcmKgwPtTsGK0uClxg+LwKJ3WXuye3oqnnjqJCwMEneXzGdG09T 7 | sA0SyNPwrEgebLCH80an3gWU4pHDdqGHfJQa2jBL290e/5L5MB+6PTs2NKcojK/k 8 | qcZkn58MWXhDW1NpAnJtjVniK2Ksvr/YIYSbyD+JiEs0MGxEx+kOl9d7hRHJaIzd 9 | GF/vO2pl295v1qXekAlkgNMtYIVAjUy9CMpqaQBCQRL+BmPSJRkXBsYk8GPnieS4 10 | sUsp53DsNvCCtWDT6fd9D1v+BB6nDk/FCPKhtjYOwOAZlX4wWNSZpRNr5dfrxKsb 11 | jAn4PCuR2akdF4G8WLUeDWECAwEAAaNTMFEwHQYDVR0OBBYEFMnmdJKOEepXrHI/ 12 | ivM6mVqJgAX8MB8GA1UdIwQYMBaAFMnmdJKOEepXrHI/ivM6mVqJgAX8MA8GA1Ud 13 | EwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBADiXIGEkSsN0SLSfCF1VNWO3 14 | emBurfOcDq4EGEaxRKAU0814VEmU87btIDx80+z5Dbf+GGHCPrY7odIkxGNn0DJY 15 | W1WcF+DOcbiWoUN6DTkAML0SMnp8aGj9ffx3x+qoggT+vGdWVVA4pgwqZT7Ybntx 16 | bkzcNFW0sqmCv4IN1t4w6L0A87ZwsNwVpre/j6uyBw7s8YoJHDLRFT6g7qgn0tcN 17 | ZufhNISvgWCVJQy/SZjNBHSpnIdCUSJAeTY2mkM4sGxY0Widk8LnjydxZUSxC3Nl 18 | hb6pnMh3jRq4h0+5CZielA4/a+TdrNPv/qok67ot/XJdY3qHCCd8O2b14OVq9jo= 19 | -----END CERTIFICATE----- 20 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/common.h: -------------------------------------------------------------------------------- 1 | /* Door Bell Demo 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "settings.h" 13 | #include "media_sys.h" 14 | #include "network.h" 15 | #include "sys_state.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /** 22 | * @brief Initialize for board 23 | */ 24 | void init_board(void); 25 | 26 | /** 27 | * @brief Start WebRTC 28 | * 29 | * @param[in] url Signaling URL 30 | * 31 | * @return 32 | * - 0 On success 33 | * - Others Fail to start 34 | */ 35 | int start_webrtc(char *url); 36 | 37 | /** 38 | * @brief Query WebRTC status 39 | */ 40 | void query_webrtc(void); 41 | 42 | /** 43 | * @brief Stop WebRTC 44 | * 45 | * @return 46 | * - 0 On success 47 | * - Others Fail to stop 48 | */ 49 | int stop_webrtc(void); 50 | 51 | /** 52 | * @brief Send command to peer 53 | */ 54 | void send_cmd(char *cmd); 55 | 56 | /** 57 | * @brief Close data channel according channel index 58 | */ 59 | int close_data_channel(int idx); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: ">=5.0" 6 | ## Import needed components only 7 | capture_audio_src: 8 | path: ../../../components/esp_capture/src/impl/capture_audio_src 9 | capture_video_src: 10 | path: ../../../components/esp_capture/src/impl/capture_video_src 11 | capture_audio_enc: 12 | path: ../../../components/esp_capture/src/impl/capture_audio_enc 13 | capture_video_enc: 14 | path: ../../../components/esp_capture/src/impl/capture_video_enc 15 | peer_default: 16 | path: ../../../components/esp_webrtc/impl/peer_default 17 | render_impl: 18 | path: ../../../components/av_render/render_impl 19 | espressif/esp_h264: 20 | version: "1.0.4" 21 | rules: 22 | - if: target in [esp32p4, esp32s3] 23 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/join.aac: -------------------------------------------------------------------------------- 1 | ../../doorbell_demo/main/join.aac -------------------------------------------------------------------------------- /solutions/doorbell_local/main/open.aac: -------------------------------------------------------------------------------- 1 | ../../doorbell_demo/main/open.aac -------------------------------------------------------------------------------- /solutions/doorbell_local/main/ring.aac: -------------------------------------------------------------------------------- 1 | ../../doorbell_demo/main/ring.aac -------------------------------------------------------------------------------- /solutions/doorbell_local/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "sdkconfig.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /** 19 | * @brief Board name setting refer to `codec_board` README.md for more details 20 | */ 21 | #if CONFIG_IDF_TARGET_ESP32P4 22 | #define TEST_BOARD_NAME "ESP32_P4_DEV_V14" 23 | #else 24 | #define TEST_BOARD_NAME "S3_Korvo_V2" 25 | #endif 26 | 27 | /** 28 | * @brief Video resolution settings 29 | */ 30 | #if CONFIG_IDF_TARGET_ESP32P4 31 | #define VIDEO_WIDTH 1920 32 | #define VIDEO_HEIGHT 1080 33 | #define VIDEO_FPS 25 34 | #else 35 | #define VIDEO_WIDTH 320 36 | #define VIDEO_HEIGHT 240 37 | #define VIDEO_FPS 10 38 | #endif 39 | 40 | /** 41 | * @brief Set for wifi ssid 42 | */ 43 | #define WIFI_SSID "XXXX" 44 | 45 | /** 46 | * @brief Set for wifi password 47 | */ 48 | #define WIFI_PASSWORD "XXXX" 49 | 50 | /** 51 | * @brief Whether enable data channel 52 | */ 53 | #define DATA_CHANNEL_ENABLED (true) 54 | 55 | #if CONFIG_IDF_TARGET_ESP32P4 56 | /** 57 | * @brief GPIO for ring button 58 | * 59 | * @note When use ESP32P4-Fuction-Ev-Board, GPIO35(boot button) is connected RMII_TXD1 60 | * When enable `NETWORK_USE_ETHERNET` will cause socket error 61 | * User must replace it to a unused GPIO instead (like GPIO27) 62 | */ 63 | #define DOOR_BELL_RING_BUTTON 35 64 | #else 65 | /** 66 | * @brief GPIO for ring button 67 | * 68 | * @note When use ESP32S3-KORVO-V3 Use ADC button as ring button 69 | */ 70 | #define DOOR_BELL_RING_BUTTON 5 71 | #endif 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | -------------------------------------------------------------------------------- /solutions/doorbell_local/main/webrtc_http_server.h: -------------------------------------------------------------------------------- 1 | /* WebRTC HTTPS server signaling 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "esp_err.h" 13 | #include "esp_peer_signaling.h" 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | /** 20 | * @brief Get the HTTP signaling implementation 21 | * 22 | * @return 23 | * - NULL Not enough memory 24 | * - Others HTTPS server signaling implementation 25 | */ 26 | const esp_peer_signaling_impl_t *esp_signaling_get_http_impl(void); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif -------------------------------------------------------------------------------- /solutions/doorbell_local/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 3M, 6 | -------------------------------------------------------------------------------- /solutions/doorbell_local/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | CONFIG_FREERTOS_HZ=1000 13 | 14 | # Support 2 SNTP 15 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 16 | 17 | # Enable DTLS SRTP 18 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 19 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 20 | 21 | # Use new I2C master 22 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 23 | 24 | # Enable experimental features 25 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 26 | 27 | # Use customer partition table 28 | CONFIG_PARTITION_TABLE_CUSTOM=y 29 | 30 | # 31 | # HTTP Server 32 | # 33 | CONFIG_HTTPD_MAX_REQ_HDR_LEN=4096 34 | CONFIG_HTTPD_MAX_URI_LEN=256 35 | CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT=100 36 | 37 | # Allocate LWIP and MbedTLS on SPIRAM 38 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256 39 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 40 | CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y 41 | -------------------------------------------------------------------------------- /solutions/doorbell_local/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # Flash setting 2 | CONFIG_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | CONFIG_SPIRAM_SPEED_200M=y 6 | 7 | # If you use serial JTAG turn on this option 8 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 9 | 10 | # Use camera SC2336 11 | CONFIG_CAMERA_SC2336=y 12 | CONFIG_CAMERA_SC2336_MIPI_RAW10_1920x1080_25FPS_2_LANE=y 13 | 14 | # Enable ISP pipelines 15 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 16 | 17 | # Set Slave target type 18 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 19 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 20 | 21 | # Enable following configuration if support C5 Slave, make sure GPIO matched 22 | # CONFIG_SLAVE_IDF_TARGET_ESP32C5=y 23 | # CONFIG_ESP_HOSTED_SPI_HD_HOST_INTERFACE=y 24 | # CONFIG_ESP_SPI_HD_GPIO_CS=4 25 | # CONFIG_ESP_SPI_HD_GPIO_CLK=5 26 | # CONFIG_ESP_SPI_HD_GPIO_D0=20 27 | # CONFIG_ESP_SPI_HD_GPIO_D1=21 28 | # CONFIG_ESP_SPI_HD_GPIO_D2=22 29 | # CONFIG_ESP_SPI_HD_GPIO_D3=23 30 | # CONFIG_ESP_SPI_HD_GPIO_DATA_READY=32 31 | # CONFIG_ESP_SPI_HD_GPIO_RESET_SLAVE=33 32 | # CONFIG_ESP_SPI_HD_FREQ_ESP32XX=40 33 | # CONFIG_ESP_HOSTED_SPI_HD_PRIV_INTERFACE_4_DATA_LINES=y 34 | -------------------------------------------------------------------------------- /solutions/doorbell_local/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | 6 | CONFIG_SPIRAM_MODE_OCT=y 7 | CONFIG_SPIRAM_SPEED_120M=y 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | 10 | CONFIG_COMPILER_OPTIMIZATION_PERF=y 11 | 12 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 13 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 14 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 15 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 16 | 17 | CONFIG_FLASHMODE_QIO=y 18 | CONFIG_ESPTOOLPY_FLASHMODE_QIO=y 19 | 20 | CONFIG_ESP_WS_CLIENT_ENABLE_DYNAMIC_BUFFER=y 21 | -------------------------------------------------------------------------------- /solutions/openai_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | if(NOT DEFINED ENV{OPENAI_API_KEY}) 17 | message(FATAL_ERROR "Env variable OPENAI_API_KEY must be set") 18 | endif() 19 | 20 | add_compile_definitions(OPENAI_API_KEY="$ENV{OPENAI_API_KEY}") 21 | 22 | project(openai_demo) 23 | -------------------------------------------------------------------------------- /solutions/openai_demo/README.md: -------------------------------------------------------------------------------- 1 | # OpenAI Real-Time Chat Demo 2 | 3 | ## Overview 4 | 5 | This demo showcases the use of `esp_webrtc` to establish a real-time chat connection with OpenAI. It also demonstrates how to utilize voice commands for device control through function calls. 6 | 7 | ## Comparison with OpenAI Realtime Embedded SDK 8 | 9 | This demo provides functionality similar to the [OpenAI Realtime Embedded SDK](https://github.com/openai/openai-realtime-embedded-sdk), with several enhancements: 10 | 11 | 1. **Integrated Solution**: Eliminates the need to build media system components from scratch, offering a ready-to-use implementation. 12 | 2. **Optimized Codec**: Leverages `esp_audio_codec` for efficient OPUS encoding and decoding. 13 | 3. **Enhanced Interaction**: Includes Acoustic Echo Cancellation (AEC) for better voice interaction quality. 14 | 4. **Improved Peer Connection**: Utilizes an enhanced version of `esp_peer` for better performance and reliability. 15 | 16 | ## Hardware Requirements 17 | The default setup uses the [ESP32-S3-Korvo-2](https://docs.espressif.com/projects/esp-adf/en/latest/design-guide/dev-boards/user-guide-esp32-s3-korvo-2.html). 18 | 19 | ## How to build 20 | 21 | ### IDF version 22 | You can select either the IDF master branch or the IDF release v5.4. 23 | 24 | ### Dependencies 25 | This demo only depends on the **ESP-IDF**. All other required modules will be automatically downloaded from the [ESP-IDF Component Registry](https://components.espressif.com/). 26 | 27 | ### Change Default Settings 28 | 1. Modify the Wi-Fi SSID and password in the file in [settings.h](main/settings.h) 29 | 2. Export your OpenAI API key 30 | ```bash 31 | export OPENAI_API_KEY=XXXXXXX 32 | ``` 33 | 3. To support other boards, refer to the [codec_board README](../../components/codec_board/README.md) 34 | 35 | ### Build 36 | ``` 37 | idf.py -p YOUR_SERIAL_DEVICE flash monitor 38 | ``` 39 | 40 | ## Testing 41 | 42 | After the board boots up, it will attempt to connect to the configured Wi-Fi SSID. 43 | Once the Wi-Fi is connected successfully, it will try to connect to OpenAI server automatically. 44 | User can also use following console command to control the session. 45 | 1. `start`: start chat 46 | 2. `stop`: stop chat 47 | 3. `i`: Show system loadings 48 | 4. `wifi`: Connect to a new wifi ssid with password 49 | The demo code add some predefined function call for light on off, light color, speaker volume and door open control. 50 | User can use voice command to trigger the function call. 51 | 52 | ## Technical Details 53 | To connect to OpenAI, this example adds a customized signaling realization `esp_signaling_get_openai_signaling`. It does not use a STUN/TURN server, and thus the `on_ice_info` will have `stun_url` set to `NULL`. The SDP information is exchanged through http posts through `https_post` API. All other steps follow the typical call flow of `esp_webrtc`. 54 | For more details on the standard connection build flow, refer to the [Connection Build Flow](../../components/esp_webrtc/README.md#typical-call-sequence-of-esp_webrtc). 55 | -------------------------------------------------------------------------------- /solutions/openai_demo/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | idf_component_register(SRCS "webrtc.c" "main.c" "board.c" "media_sys.c" 3 | "openai_signaling.c" 4 | INCLUDE_DIRS ".") 5 | -------------------------------------------------------------------------------- /solutions/openai_demo/main/board.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "esp_log.h" 3 | #include "codec_init.h" 4 | #include "codec_board.h" 5 | #include "esp_codec_dev.h" 6 | #include "sdkconfig.h" 7 | #include "settings.h" 8 | 9 | static const char *TAG = "Board"; 10 | 11 | void init_board(void) 12 | { 13 | ESP_LOGI(TAG, "Init board."); 14 | set_codec_board_type(TEST_BOARD_NAME); 15 | // Notes when use playback and record at same time, must set reuse_dev = false 16 | codec_init_cfg_t cfg = { 17 | #if CONFIG_IDF_TARGET_ESP32S3 18 | .in_mode = CODEC_I2S_MODE_TDM, 19 | .in_use_tdm = true, 20 | #endif 21 | .reuse_dev = false 22 | }; 23 | init_codec(&cfg); 24 | } 25 | -------------------------------------------------------------------------------- /solutions/openai_demo/main/common.h: -------------------------------------------------------------------------------- 1 | /* Common header 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "settings.h" 17 | #include "media_sys.h" 18 | #include "network.h" 19 | #include "sys_state.h" 20 | #include "esp_webrtc.h" 21 | 22 | /** 23 | * @brief Initialize board 24 | */ 25 | void init_board(void); 26 | 27 | /** 28 | * @brief OpenAI signaling configuration 29 | * 30 | * @note Details see: https://platform.openai.com/docs/api-reference/realtime-sessions/create#realtime-sessions-create-voice 31 | */ 32 | typedef struct { 33 | char *token; /*!< OpenAI token */ 34 | char *voice; /*!< Voice to select */ 35 | } openai_signaling_cfg_t; 36 | 37 | /** 38 | * @brief Get OpenAI signaling implementation 39 | * 40 | * @return 41 | * - NULL Not enough memory 42 | * - Others OpenAI signaling implementation 43 | */ 44 | const esp_peer_signaling_impl_t *esp_signaling_get_openai_signaling(void); 45 | 46 | /** 47 | * @brief Start WebRTC 48 | * 49 | * @return 50 | * - 0 On success 51 | * - Others Fail to start 52 | */ 53 | int start_webrtc(void); 54 | 55 | /** 56 | * @brief Send text to OpenAI server 57 | * 58 | * @param[in] text Text to be sent 59 | * 60 | * @return 61 | * - 0 On success 62 | * - Others Fail to start 63 | */ 64 | int openai_send_text(char *text); 65 | 66 | /** 67 | * @brief Query WebRTC status 68 | */ 69 | void query_webrtc(void); 70 | 71 | /** 72 | * @brief Start WebRTC 73 | * 74 | * @param[in] url Signaling URL 75 | * 76 | * @return 77 | * - 0 On success 78 | * - Others Fail to start 79 | */ 80 | int stop_webrtc(void); 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | -------------------------------------------------------------------------------- /solutions/openai_demo/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: ">=5.0" 6 | capture_audio_src: 7 | path: ../../../components/esp_capture/src/impl/capture_audio_src 8 | capture_audio_enc: 9 | path: ../../../components/esp_capture/src/impl/capture_audio_enc 10 | peer_default: 11 | path: ../../../components/esp_webrtc/impl/peer_default 12 | render_impl: 13 | path: ../../../components/av_render/render_impl 14 | espressif/esp_h264: 15 | version: "1.0.4" 16 | rules: 17 | - if: target in [esp32p4, esp32s3] 18 | -------------------------------------------------------------------------------- /solutions/openai_demo/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @brief Set used board name, see `codec_board` README.md for more details 18 | */ 19 | #if CONFIG_IDF_TARGET_ESP32P4 20 | #define TEST_BOARD_NAME "ESP32_P4_DEV_V14" 21 | #else 22 | #define TEST_BOARD_NAME "S3_Korvo_V2" 23 | #endif 24 | 25 | /** 26 | * @brief If defined will use OPUS codec 27 | */ 28 | #define WEBRTC_SUPPORT_OPUS 29 | 30 | /** 31 | * @brief Whether enable data channel 32 | */ 33 | #define DATA_CHANNEL_ENABLED (true) 34 | 35 | /** 36 | * @brief Set WiFi SSID 37 | */ 38 | #define WIFI_SSID "XXXX" 39 | 40 | /** 41 | * @brief Set WiFi password 42 | */ 43 | #define WIFI_PASSWORD "XXXX" 44 | 45 | /** 46 | * @brief Set default playback volume 47 | */ 48 | #define DEFAULT_PLAYBACK_VOL (85) 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /solutions/openai_demo/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 3M, 6 | -------------------------------------------------------------------------------- /solutions/openai_demo/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | 13 | # Support 2 SNTP 14 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 15 | 16 | # Enable DTLS SRTP 17 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 18 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 19 | 20 | # Use new I2C master 21 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 22 | 23 | # Enable experimental features 24 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 25 | 26 | # Use customer partition table 27 | CONFIG_PARTITION_TABLE_CUSTOM=y 28 | 29 | # Allocate LWIP and MbedTLS on SPIRAM 30 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256 31 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 32 | CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y 33 | -------------------------------------------------------------------------------- /solutions/openai_demo/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # Flash setting 2 | CONFIG_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | CONFIG_SPIRAM_SPEED_200M=y 6 | 7 | # If you use serial JTAG turn on this option 8 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 9 | 10 | # Use camera SC2336 11 | CONFIG_CAMERA_SC2336=y 12 | CONFIG_CAMERA_SC2336_MIPI_RAW8_1920x1080_30FPS=y 13 | 14 | # Enable ISP pipelines 15 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 16 | 17 | # Set Slave target type 18 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 19 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 20 | -------------------------------------------------------------------------------- /solutions/openai_demo/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | 6 | CONFIG_SPIRAM_MODE_OCT=y 7 | CONFIG_SPIRAM_SPEED_120M=y 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | 10 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | 15 | -------------------------------------------------------------------------------- /solutions/peer_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | project(peer_demo) 17 | -------------------------------------------------------------------------------- /solutions/peer_demo/README.md: -------------------------------------------------------------------------------- 1 | # Peer Demo 2 | 3 | ## Overview 4 | 5 | This demo demonstrates how to use the `esp_peer` API to build a simple chat application on ESP32 series boards. 6 | The application sends fake audio data and chat strings over data channel at regular intervals after establishing a connection. 7 | 8 | ## Hardware Requirements 9 | 10 | This demo requires minimal hardware: any board that supports Wi-Fi connectivity is sufficient. 11 | It needs 2 boards to act as chat peers. 12 | 13 | ## How to Build 14 | 15 | ### IDF Version 16 | 17 | You can use either the IDF master branch or the IDF release v5.4. 18 | 19 | ### Dependencies 20 | 21 | This demo only depends on the **ESP-IDF**. All other required modules will be automatically downloaded from the [ESP-IDF Component Registry](https://components.espressif.com/). 22 | 23 | ### Change Default Settings 24 | 25 | Update the Wi-Fi SSID and password in the [settings.h](main/settings.h) file. 26 | 27 | ### Build and Flash 28 | 29 | Run the following command to build, flash for the demo: 30 | ```bash 31 | idf.py -p YOUR_SERIAL_DEVICE flash monitor 32 | ``` 33 | 34 | ## Testing 35 | 36 | After the board boots up, it will attempt to connect to the configured Wi-Fi network. 37 | Once the Wi-Fi connection is established successfully, you can use the following console commands to test the demo: 38 | 39 | 1. `start `: Enter the specified room and start the chat. 40 | 2. `stop`: Stop the chat. 41 | 3. `i`: Display system loading information. 42 | 4. `wifi `: Connect to a new Wi-Fi SSID with a password. 43 | 44 | ## Technical Details 45 | 46 | This demo uses the `apprtc` signaling implementation (`esp_signaling_get_apprtc_signaling`) as the default signaling. 47 | The signaling flow follows the [Connection Build Flow](../../components/esp_webrtc/README.md#typical-call-sequence-of-esp_webrtc). 48 | It provides a detailed demonstration of how to use the `esp_peer` protocol API to set up a WebRTC application. 49 | -------------------------------------------------------------------------------- /solutions/peer_demo/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | idf_component_register(SRCS "webrtc.c" "main.c" 3 | INCLUDE_DIRS ".") 4 | -------------------------------------------------------------------------------- /solutions/peer_demo/main/common.h: -------------------------------------------------------------------------------- 1 | /* Common header 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | #include "settings.h" 17 | #include "network.h" 18 | #include "sys_state.h" 19 | 20 | /** 21 | * @brief Start WebRTC 22 | * 23 | * @param[in] url Signaling url 24 | * 25 | * @return 26 | * - 0 On success 27 | * - Others Fail to start 28 | */ 29 | int start_webrtc(char *url); 30 | 31 | /** 32 | * @brief Query WebRTC Status 33 | */ 34 | void query_webrtc(void); 35 | 36 | /** 37 | * @brief Stop WebRTC 38 | * 39 | * @return 40 | * - 0 On success 41 | * - Others Fail to stop 42 | */ 43 | int stop_webrtc(void); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | -------------------------------------------------------------------------------- /solutions/peer_demo/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: '>=5.0' 6 | peer_default: 7 | path: ../../../components/esp_webrtc/impl/peer_default 8 | espressif/esp_h264: 9 | version: "1.0.4" 10 | rules: 11 | - if: target in [esp32p4, esp32s3] 12 | espressif/esp_video: 13 | version: "^0.8.0" 14 | rules: 15 | - if: target in [esp32p4] 16 | -------------------------------------------------------------------------------- /solutions/peer_demo/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @brief Set for wifi ssid 18 | */ 19 | #define WIFI_SSID "XXXX" 20 | 21 | /** 22 | * @brief Set for wifi password 23 | */ 24 | #define WIFI_PASSWORD "XXXX" 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif -------------------------------------------------------------------------------- /solutions/peer_demo/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | 13 | # Support 2 SNTP 14 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 15 | 16 | # Enable DTLS SRTP 17 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 18 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 19 | 20 | # Use new I2C master 21 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 22 | 23 | # Enable experimental features 24 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 25 | 26 | CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y 27 | 28 | CONFIG_VIDEO_DECODER_SW_H264_SUPPORT=n 29 | CONFIG_VIDEO_ENCODER_SW_H264_SUPPORT=n 30 | 31 | -------------------------------------------------------------------------------- /solutions/peer_demo/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | 4 | CONFIG_SPIRAM_SPEED_200M=y 5 | 6 | # If you use serial JTAG turn on this option 7 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 8 | 9 | # Use camera SC2336 10 | CONFIG_CAMERA_SC2336=y 11 | CONFIG_CAMERA_SC2336_MIPI_RAW10_1920x1080_25FPS_2_LANE=y 12 | 13 | # Enable ISP pipelines 14 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 15 | 16 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 17 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 18 | -------------------------------------------------------------------------------- /solutions/peer_demo/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_SPIRAM_MODE_OCT=y 3 | CONFIG_SPIRAM_SPEED_80M=y 4 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 5 | 6 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 7 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 8 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 9 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 10 | 11 | -------------------------------------------------------------------------------- /solutions/videocall_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | project(videocall_demo) 17 | -------------------------------------------------------------------------------- /solutions/videocall_demo/README.md: -------------------------------------------------------------------------------- 1 | # VideoCall Demo 2 | 3 | ## OverView 4 | This demo showcases how to use `esp_webrtc` to build a device to device video call application. The code uses a modified version of the [apprtc](https://github.com/webrtc/apprtc) as signaling server and a customized command channel. 5 | 6 | 7 | ## Hardware requirement 8 | The default setup uses the [ESP32P4-Function-Ev-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/user_guide.html), which includes a SC2336 camera. For a video call, two `ESP32P4-Function-Ev-Board` devices are required, one as the caller and the other as the callee. 9 | 10 | ## How to build 11 | 12 | ### IDF version 13 | Can select IDF master or IDF release v5.4. 14 | 15 | ### Change Default Settings 16 | 1. Modify the Wi-Fi SSID and password in the file in [settings.h](main/settings.h) 17 | 2. If you are using a different camera type or resolution, update the settings for the camera type and resolution in [settings.h](main/settings.h) 18 | 3. If you are using USB-JTAG to download, uncomment the following configuration in [sdkconfig.defaults.esp32p4](sdkconfig.defaults.esp32p4) 19 | ``` 20 | CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 21 | ``` 22 | 23 | ### Build 24 | ``` 25 | idf.py -p YOUR_SERIAL_DEVICE flash monitor 26 | ``` 27 | 28 | ## Testing 29 | 30 | After the board boots up, it will attempt to connect to the configured Wi-Fi SSID. If you want to connect to a different Wi-Fi STA, you can use the following CLI command: 31 | ``` 32 | wifi ssid psw 33 | ``` 34 | 35 | After a successful Wi-Fi connection, use the join command to join a random room. Both boards must enter the same room: 36 | ``` 37 | join mytestroom 38 | ``` 39 | 40 | ### Interactions 41 | 42 | 1. **Ring** 43 | - One board clicks the boot button or enters the `b`` command in the console to ring the peer board. 44 | - The peer board receives the `Ring` command and plays ring music. 45 | 46 | 2. **Accept:** 47 | - The peer board presses the boot button or enters the `b` command to accept the call. 48 | - The call will automatically reset after a timeout if not accepted. 49 | 50 | 3. **Hang Off:** 51 | - The peer board presses the boot button or enters the `b` command to end the ongoing call. 52 | 53 | 4. **Clear-up Test:** 54 | - On either board, enter the `leave` command to exit the room. 55 | 56 | ## Technical Details 57 | To support the video call functionality, this demo uses [apprtc](https://github.com/webrtc/apprtc) and requires separate signaling from the peer connection build logic. The peer connection is only established when a special signaling message is received from the peer. 58 | 59 | ### Key Changes in `esp_webrtc`: 60 | - **`no_auto_reconnect` Configuration**: This configuration disables the automatic building of the peer connection when the signaling connection is established. 61 | - **`esp_webrtc_enable_peer_connection` API**: A new API is introduced to manually control the connection and disconnection of the peer connection. 62 | - **Video over Data Channel**: To enable video over the data channel, use the following configuration: 63 | ``` 64 | .enable_data_channel = true, 65 | .video_over_data_channel = true, 66 | ``` 67 | All other steps follow the typical call flow of `esp_webrtc`. For more details on the standard connection build flow, refer to the [Connection Build Flow](../../components/esp_webrtc/README.md#typical-call-sequence-of-esp_webrtc). 68 | -------------------------------------------------------------------------------- /solutions/videocall_demo/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "webrtc.c" "main.c" "board.c" "media_sys.c" 2 | EMBED_TXTFILES "ring.aac" 3 | INCLUDE_DIRS ".") 4 | -------------------------------------------------------------------------------- /solutions/videocall_demo/main/board.c: -------------------------------------------------------------------------------- 1 | /* Do simple board initialize 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include "esp_log.h" 12 | #include "codec_init.h" 13 | #include "codec_board.h" 14 | #include "esp_codec_dev.h" 15 | #include "sdkconfig.h" 16 | #include "settings.h" 17 | 18 | static const char *TAG = "Board"; 19 | 20 | void init_board() 21 | { 22 | ESP_LOGI(TAG, "Init board."); 23 | set_codec_board_type(TEST_BOARD_NAME); 24 | // Notes when use playback and record at same time, must set reuse_dev = false 25 | codec_init_cfg_t cfg = {.reuse_dev = false}; 26 | init_codec(&cfg); 27 | board_lcd_init(); 28 | } 29 | -------------------------------------------------------------------------------- /solutions/videocall_demo/main/common.h: -------------------------------------------------------------------------------- 1 | /* Video Call Demo 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "settings.h" 13 | #include "media_sys.h" 14 | #include "network.h" 15 | #include "sys_state.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /** 22 | * @brief Initialize for board 23 | */ 24 | void init_board(void); 25 | 26 | /** 27 | * @brief Start WebRTC 28 | * 29 | * @param[in] url Signaling URL 30 | * 31 | * @return 32 | * - 0 On success 33 | * - Others Fail to start 34 | */ 35 | int start_webrtc(char *url); 36 | 37 | /** 38 | * @brief Query WebRTC status 39 | */ 40 | void query_webrtc(void); 41 | 42 | /** 43 | * @brief Stop WebRTC 44 | * 45 | * @return 46 | * - 0 On success 47 | * - Others Fail to stop 48 | */ 49 | int stop_webrtc(void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | -------------------------------------------------------------------------------- /solutions/videocall_demo/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: ">=4.1.0" 6 | capture_audio_src: 7 | path: ../../../components/esp_capture/src/impl/capture_audio_src 8 | capture_video_src: 9 | path: ../../../components/esp_capture/src/impl/capture_video_src 10 | capture_audio_enc: 11 | path: ../../../components/esp_capture/src/impl/capture_audio_enc 12 | capture_video_enc: 13 | path: ../../../components/esp_capture/src/impl/capture_video_enc 14 | peer_default: 15 | path: ../../../components/esp_webrtc/impl/peer_default 16 | render_impl: 17 | path: ../../../components/av_render/render_impl 18 | espressif/esp_h264: 19 | version: "1.0.4" 20 | rules: 21 | - if: target in [esp32p4, esp32s3] 22 | -------------------------------------------------------------------------------- /solutions/videocall_demo/main/ring.aac: -------------------------------------------------------------------------------- 1 | ../../doorbell_demo/main/ring.aac -------------------------------------------------------------------------------- /solutions/videocall_demo/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @brief Board name setting refer to `codec_board` README.md for more details 18 | */ 19 | #define TEST_BOARD_NAME "ESP32_P4_DEV_V14" 20 | 21 | /** 22 | * @brief Video resolution settings 23 | */ 24 | #define VIDEO_WIDTH 1024 25 | #define VIDEO_HEIGHT 600 26 | #define VIDEO_FPS 10 27 | 28 | /** 29 | * @brief Set for wifi ssid 30 | */ 31 | #define WIFI_SSID "XXXX" 32 | 33 | /** 34 | * @brief Set for wifi password 35 | */ 36 | #define WIFI_PASSWORD "XXXX" 37 | 38 | /** 39 | * @brief Whether enable data channel 40 | */ 41 | #define DATA_CHANNEL_ENABLED (true) 42 | 43 | /** 44 | * @brief GPIO for ring button 45 | * 46 | * @note When use ESP32P4-Fuction-Ev-Board, GPIO35(boot button) is connected RMII_TXD1 47 | * When enable `NETWORK_USE_ETHERNET` will cause socket error 48 | * User must replace it to a unused GPIO instead (like GPIO27) 49 | */ 50 | #define VIDEO_CALL_RING_BUTTON 35 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /solutions/videocall_demo/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 3M, 6 | -------------------------------------------------------------------------------- /solutions/videocall_demo/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | 13 | # Support 2 SNTP 14 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 15 | 16 | # Enable DTLS SRTP 17 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 18 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 19 | 20 | # Use new I2C master 21 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 22 | 23 | # Enable experimental features 24 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 25 | 26 | # Use customer partition table 27 | CONFIG_PARTITION_TABLE_CUSTOM=y 28 | 29 | # Use lare receive buffer 30 | CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64 31 | CONFIG_LWIP_MAX_UDP_PCBS=1024 32 | CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 33 | 34 | # Allocate LWIP and MbedTLS on SPIRAM 35 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256 36 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 37 | CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y 38 | -------------------------------------------------------------------------------- /solutions/videocall_demo/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | # Flash setting 2 | CONFIG_FLASHMODE_QIO=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | CONFIG_SPIRAM_SPEED_200M=y 6 | 7 | # If you use serial JTAG turn on this option 8 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 9 | 10 | # Use camera SC2336 11 | CONFIG_CAMERA_SC2336=y 12 | CONFIG_CAMERA_SC2336_MIPI_RAW8_1024x600_30FPS=y 13 | 14 | # Enable ISP pipelines 15 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 16 | 17 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 18 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 19 | -------------------------------------------------------------------------------- /solutions/whip_demo/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | # include($ENV{ADF_PATH}/CMakeLists.txt) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | 8 | if("${IDF_TARGET}" STREQUAL "esp32p4") 9 | set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/examples/ethernet/basic/components/ethernet_init") 10 | endif() 11 | 12 | list(APPEND EXTRA_COMPONENT_DIRS "../../components") 13 | 14 | list(APPEND EXTRA_COMPONENT_DIRS "../common") 15 | 16 | project(whip_demo) 17 | -------------------------------------------------------------------------------- /solutions/whip_demo/README.md: -------------------------------------------------------------------------------- 1 | # WHIP Publish Client Demo 2 | 3 | ## Overview 4 | 5 | This demo shows how to use `esp_webrtc` as a WHIP publish client to stream media to a WHIP server. 6 | 7 | ## Hardware Requirements 8 | 9 | - An [ESP32P4-Function-Ev-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32p4-function-ev-board/user_guide.html) (includes a SC2336 camera). 10 | 11 | ## WHIP Server Setup 12 | 13 | For testing, you can use [mediaMTX](https://github.com/bluenviron/mediamtx) as your WHIP server. 14 | 15 | ### Configuring mediaMTX 16 | 17 | 1. **User Authentication** 18 | In your `mediamtx.yml` file, add user accounts: 19 | ```yaml 20 | authInternalUsers: 21 | - user: username 22 | pass: password 23 | ``` 24 | 25 | 2. **STUN/Relay Server** 26 | Add a STUN (or relay) server: 27 | ```yaml 28 | webrtcICEServers2: 29 | - url: stun:stun_server:3478 30 | ``` 31 | 32 | ## How to Build 33 | 34 | ### IDF Version 35 | 36 | You may use either the IDF master branch or the IDF release v5.4. 37 | 38 | ### Configuration Steps 39 | 40 | 1. **Wi-Fi Settings** 41 | Update the Wi-Fi SSID and password in [main/settings.h](main/settings.h). 42 | 43 | 2. **WHIP Server Settings** 44 | Modify the WHIP server URL and access token in [main/settings.h](main/settings.h). 45 | 46 | 3. **Support for Other Boards** 47 | For instructions on supporting other boards, see the [codec_board README](../../components/codec_board/README.md). 48 | 49 | ### Building and Flashing 50 | 51 | Build, flash, and monitor your device with: 52 | ```bash 53 | idf.py -p YOUR_SERIAL_DEVICE flash monitor 54 | ``` 55 | 56 | ## Testing 57 | 58 | After booting, the board will: 59 | 1. Connect to the configured Wi-Fi network. 60 | 2. Automatically push the media stream to the WHIP server upon successful connection. 61 | 62 | You can also control streaming via CLI commands: 63 | - `start server_url token` : Begin streaming to the WHIP server. 64 | - `stop` : Stop streaming. 65 | - `i` : Display system information. 66 | - `wifi` : Connect to a new Wi-Fi network by specifying the SSID and password. 67 | 68 | ### Playing the Published Stream 69 | 70 | To view the stream, use `ffplay` with: 71 | ```bash 72 | ffplay rtsp://username:password@whip_server_ip:rtsp_port/push_stream_name 73 | ``` 74 | ## Technical Details 75 | 76 | This demo uses a custom signaling implementation `esp_signaling_get_whip_impl`, to exchange SDP with the WHIP server. The detail process is as follows: 77 | - The client sends an initial SDP to the WHIP server. 78 | - If the response includes a STUN server URL, the client will call `esp_peer_update_ice_info` then sends a PATCH with new candidates to notify the server. 79 | - When signaling closed it will send `DELETE` to delete the session 80 | 81 | For a complete explanation of the connection process, refer to the [Connection Build Flow](../../components/esp_webrtc/README.md#typical-call-sequence-of-esp_webrtc). 82 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "webrtc.c" "main.c" "board.c" "media_sys.c" 2 | INCLUDE_DIRS ".") 3 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/board.c: -------------------------------------------------------------------------------- 1 | /* Do simple board initialize 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include "esp_log.h" 12 | #include "codec_init.h" 13 | #include "codec_board.h" 14 | #include "esp_codec_dev.h" 15 | #include "sdkconfig.h" 16 | #include "settings.h" 17 | 18 | static const char *TAG = "Board"; 19 | 20 | void init_board() 21 | { 22 | ESP_LOGI(TAG, "Init board."); 23 | set_codec_board_type(TEST_BOARD_NAME); 24 | // Notes when use playback and record at same time, must set reuse_dev = false 25 | codec_init_cfg_t cfg = { .reuse_dev = false }; 26 | init_codec(&cfg); 27 | board_lcd_init(); 28 | } 29 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/common.h: -------------------------------------------------------------------------------- 1 | /* Video Call Demo 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "settings.h" 13 | #include "media_sys.h" 14 | #include "network.h" 15 | #include "sys_state.h" 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | /** 22 | * @brief Initialize for board 23 | */ 24 | void init_board(void); 25 | 26 | /** 27 | * @brief Start WebRTC 28 | * 29 | * @param[in] url WHIP server URL 30 | * @param[in] url Bearer token 31 | * 32 | * @return 33 | * - 0 On success 34 | * - Others Fail to start 35 | */ 36 | int start_webrtc(char *url, char *token); 37 | 38 | /** 39 | * @brief Query WebRTC status 40 | */ 41 | void query_webrtc(void); 42 | 43 | /** 44 | * @brief Stop WebRTC 45 | * 46 | * @return 47 | * - 0 On success 48 | * - Others Fail to stop 49 | */ 50 | int stop_webrtc(void); 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/idf_component.yml: -------------------------------------------------------------------------------- 1 | ## IDF Component Manager Manifest File 2 | dependencies: 3 | ## Required IDF version 4 | idf: 5 | version: ">=4.1.0" 6 | capture_audio_src: 7 | path: ../../../components/esp_capture/src/impl/capture_audio_src 8 | capture_video_src: 9 | path: ../../../components/esp_capture/src/impl/capture_video_src 10 | capture_audio_enc: 11 | path: ../../../components/esp_capture/src/impl/capture_audio_enc 12 | capture_video_enc: 13 | path: ../../../components/esp_capture/src/impl/capture_video_enc 14 | peer_default: 15 | path: ../../../components/esp_webrtc/impl/peer_default 16 | render_impl: 17 | path: ../../../components/av_render/render_impl 18 | espressif/esp_h264: 19 | version: "1.0.4" 20 | rules: 21 | - if: target in [esp32p4, esp32s3] 22 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/settings.h: -------------------------------------------------------------------------------- 1 | /* General settings 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #pragma once 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | /** 17 | * @brief Board name setting refer to `codec_board` README.md for more details 18 | */ 19 | #if CONFIG_IDF_TARGET_ESP32P4 20 | #define TEST_BOARD_NAME "ESP32_P4_DEV_V14" 21 | #else 22 | #define TEST_BOARD_NAME "S3_Korvo_V2" 23 | #endif 24 | 25 | /** 26 | * @brief Video resolution settings 27 | */ 28 | #if CONFIG_IDF_TARGET_ESP32P4 29 | #define VIDEO_WIDTH 1920 30 | #define VIDEO_HEIGHT 1080 31 | #define VIDEO_FPS 25 32 | #else 33 | #define VIDEO_WIDTH 320 34 | #define VIDEO_HEIGHT 240 35 | #define VIDEO_FPS 10 36 | #endif 37 | 38 | /** 39 | * @brief Set for wifi ssid 40 | */ 41 | #define WIFI_SSID "XXXX" 42 | 43 | /** 44 | * @brief Set for wifi password 45 | */ 46 | #define WIFI_PASSWORD "XXXX" 47 | 48 | /** 49 | * @brief WHIP server URL 50 | */ 51 | #define WHIP_SERVER "http://XXXX/whip" 52 | 53 | /** 54 | * @brief WHIP server access token 55 | */ 56 | #define WHIP_TOKEN "username:password" 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /solutions/whip_demo/main/webrtc.c: -------------------------------------------------------------------------------- 1 | /* WHIP client WebRTC application code 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include "esp_webrtc.h" 11 | #include "media_lib_os.h" 12 | #include "common.h" 13 | #include "esp_log.h" 14 | #include "esp_webrtc_defaults.h" 15 | #include "media_lib_os.h" 16 | 17 | #define TAG "WHIP_DEMO" 18 | 19 | static esp_webrtc_handle_t webrtc; 20 | 21 | static int webrtc_event_handler(esp_webrtc_event_t *event, void *ctx) 22 | { 23 | return 0; 24 | } 25 | 26 | int start_webrtc(char *url, char *token) 27 | { 28 | if (network_is_connected() == false) { 29 | ESP_LOGE(TAG, "Wifi not connected yet"); 30 | return -1; 31 | } 32 | if (url[0] == 0) { 33 | ESP_LOGE(TAG, "Room Url not set yet"); 34 | return -1; 35 | } 36 | if (webrtc) { 37 | esp_webrtc_close(webrtc); 38 | webrtc = NULL; 39 | } 40 | esp_peer_signaling_whip_cfg_t whip_cfg = { 41 | .auth_type = ESP_PEER_SIGNALING_WHIP_AUTH_TYPE_BASIC, 42 | .token = token, 43 | }; 44 | esp_webrtc_cfg_t cfg = { 45 | .peer_cfg = { 46 | .audio_info = { 47 | .codec = ESP_PEER_AUDIO_CODEC_G711A, 48 | }, 49 | .video_info = { 50 | .codec = ESP_PEER_VIDEO_CODEC_H264, 51 | .width = VIDEO_WIDTH, 52 | .height = VIDEO_HEIGHT, 53 | .fps = VIDEO_FPS, 54 | }, 55 | .audio_dir = ESP_PEER_MEDIA_DIR_SEND_ONLY, 56 | .video_dir = ESP_PEER_MEDIA_DIR_SEND_ONLY, 57 | .no_auto_reconnect = true, // No auto connect peer when signaling connected 58 | }, 59 | .signaling_cfg = { 60 | .signal_url = url, 61 | .extra_cfg = token ? &whip_cfg : NULL, 62 | .extra_size = token ? sizeof(whip_cfg) : 0, 63 | }, 64 | .peer_impl = esp_peer_get_default_impl(), 65 | .signaling_impl = esp_signaling_get_whip_impl(), 66 | }; 67 | int ret = esp_webrtc_open(&cfg, &webrtc); 68 | if (ret != 0) { 69 | ESP_LOGE(TAG, "Fail to open webrtc"); 70 | return ret; 71 | } 72 | // Set media provider 73 | esp_webrtc_media_provider_t media_provider = {}; 74 | media_sys_get_provider(&media_provider); 75 | esp_webrtc_set_media_provider(webrtc, &media_provider); 76 | 77 | // Set event handler 78 | esp_webrtc_set_event_handler(webrtc, webrtc_event_handler, NULL); 79 | 80 | // Default disable auto connect of peer connection 81 | esp_webrtc_enable_peer_connection(webrtc, true); 82 | 83 | // Start webrtc 84 | ret = esp_webrtc_start(webrtc); 85 | if (ret != 0) { 86 | ESP_LOGE(TAG, "Fail to start webrtc"); 87 | } 88 | return ret; 89 | } 90 | 91 | void query_webrtc(void) 92 | { 93 | if (webrtc) { 94 | esp_webrtc_query(webrtc); 95 | } 96 | } 97 | 98 | int stop_webrtc(void) 99 | { 100 | if (webrtc) { 101 | esp_webrtc_handle_t handle = webrtc; 102 | webrtc = NULL; 103 | ESP_LOGI(TAG, "Start to close webrtc %p", handle); 104 | esp_webrtc_close(handle); 105 | } 106 | return 0; 107 | } -------------------------------------------------------------------------------- /solutions/whip_demo/partitions.csv: -------------------------------------------------------------------------------- 1 | # Name, Type, SubType, Offset, Size, Flags 2 | # Note: if you change the phy_init or app partition offset, make sure to change the offset in Kconfig.projbuild 3 | nvs, data, nvs, 0x9000, 0x6000, 4 | phy_init, data, phy, 0xf000, 0x1000, 5 | factory, app, factory, 0x10000, 3M, 6 | -------------------------------------------------------------------------------- /solutions/whip_demo/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | 2 | # Enable SPIRAM 3 | CONFIG_SPIRAM=y 4 | 5 | # Enable GDBStub 6 | CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y 7 | 8 | # Enable FreeRTOS trace 9 | CONFIG_FREERTOS_USE_TRACE_FACILITY=y 10 | CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y 11 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y 12 | 13 | # Support 2 SNTP 14 | CONFIG_LWIP_SNTP_MAX_SERVERS=2 15 | 16 | # Enable DTLS SRTP 17 | CONFIG_MBEDTLS_SSL_PROTO_DTLS=y 18 | CONFIG_MBEDTLS_SSL_DTLS_SRTP=y 19 | 20 | # Use new I2C master 21 | CONFIG_CODEC_I2C_BACKWARD_COMPATIBLE=n 22 | 23 | # Enable experimental features 24 | CONFIG_IDF_EXPERIMENTAL_FEATURES=y 25 | 26 | # Use customer partition table 27 | CONFIG_PARTITION_TABLE_CUSTOM=y 28 | 29 | CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=64 30 | CONFIG_LWIP_MAX_UDP_PCBS=1024 31 | CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 32 | 33 | # Allocate LWIP and MbedTLS on SPIRAM 34 | CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=256 35 | CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y 36 | CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y 37 | -------------------------------------------------------------------------------- /solutions/whip_demo/sdkconfig.defaults.esp32p4: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 3 | 4 | CONFIG_SPIRAM_SPEED_200M=y 5 | 6 | # If you use serial JTAG turn on this option 7 | #CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=y 8 | 9 | # Use camera SC2336 10 | CONFIG_CAMERA_SC2336=y 11 | CONFIG_CAMERA_SC2336_MIPI_RAW10_1920x1080_25FPS_2_LANE=y 12 | 13 | # Enable ISP pipelines 14 | CONFIG_ESP_VIDEO_ENABLE_ISP_PIPELINE_CONTROLLER=y 15 | 16 | CONFIG_IDF_SLAVE_TARGET="esp32c6" 17 | CONFIG_SLAVE_IDF_TARGET_ESP32C6=y 18 | -------------------------------------------------------------------------------- /solutions/whip_demo/sdkconfig.defaults.esp32s3: -------------------------------------------------------------------------------- 1 | 2 | CONFIG_ESPTOOLPY_FLASHFREQ_120M=y 3 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y 4 | 5 | 6 | CONFIG_SPIRAM_MODE_OCT=y 7 | CONFIG_SPIRAM_SPEED_120M=y 8 | CONFIG_ESP32S3_SPIRAM_SUPPORT=y 9 | 10 | CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y 11 | CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB=y 12 | CONFIG_ESP32S3_DATA_CACHE_64KB=y 13 | CONFIG_ESP32S3_DATA_CACHE_LINE_64B=y 14 | -------------------------------------------------------------------------------- /tools/build_apps.pl: -------------------------------------------------------------------------------- 1 | use strict; 2 | use Cwd qw(cwd); 3 | use Term::ANSIColor; 4 | 5 | my %target = ( 6 | "peer_demo" => [qw/esp32 esp32s3 esp32s2/], 7 | "doorbell_demo" => [qw/esp32p4 esp32s3/], 8 | "openai_demo" => [qw/esp32s3/], 9 | "videocall_demo" => [qw/esp32p4/], 10 | "whip_demo" => [qw/esp32p4/], 11 | "doorbell_local" => [qw/esp32p4/] 12 | ); 13 | 14 | my $cur = cwd(); 15 | my ($app_folder, $target); 16 | my $build_all = 0; 17 | if (@ARGV >= 2) { 18 | $app_folder = $ARGV[0]; 19 | $target = $ARGV[1]; 20 | build_target($app_folder, $target); 21 | } else { 22 | $build_all = 1; 23 | for my $t(keys %target) { 24 | my @board = @{$target{$t}}; 25 | print "Start build for $t @board\n"; 26 | for (@board) { 27 | build_target("$cur/$t", $_); 28 | } 29 | } 30 | } 31 | 32 | sub filter_build { 33 | my $target = shift; 34 | my $build_cmd = "idf.py set-target $target 2>&1; idf.py build 2>&1"; 35 | open(my $fh, '-|', $build_cmd) or die "Failed to run build command: $!"; 36 | my @error_patterns = ( 37 | qr/\b(error|warning)\b/i, 38 | qr/failed to build/i, 39 | qr/link error/i 40 | ); 41 | while (my $line = <$fh>) { 42 | chomp $line; 43 | if (grep { $line =~ $_ } @error_patterns) { 44 | print colored($line, 'red'), "\n"; 45 | } 46 | } 47 | close($fh); 48 | } 49 | 50 | sub build_target { 51 | my ($app_dir, $target) = @_; 52 | chdir($app_dir); 53 | my $app = $app_dir; 54 | print "Build for $app_dir $target\n"; 55 | $app =~ s/.*\///; 56 | `rm -rf $_` for (qw/dependencies.lock build managed_components sdkconfig/); 57 | filter_build($target); 58 | my $f = ; 59 | if ($f) { 60 | print colored("Build for $app target $target success\n", 'green'); 61 | } else { 62 | print colored("Fail to build for $app target $target\n", 'red'); 63 | exit(-1) if ($build_all == 0); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /tools/gen_ci.py: -------------------------------------------------------------------------------- 1 | import yaml 2 | 3 | build_folders_targets = [ 4 | {"folder": "peer_demo", "targets": ["esp32", "esp32s3", "esp32s2"]}, 5 | {"folder": "openai_demo", "targets": ["esp32s3"]}, 6 | {"folder": "doorbell_demo", "targets": ["esp32s3", "esp32p4"]}, 7 | ] 8 | 9 | template = { 10 | "variables": { 11 | "DOCKER_IMAGE": "${CI_DOCKER_REGISTRY}/esp-env-v5.4:1", 12 | "BASE_FRAMEWORK_PATH": "$CI_PROJECT_DIR/esp-idf", 13 | "BASE_FRAMEWORK": "$IDF_REPOSITORY", 14 | "IDF_VERSION_TAG": "v5.4", 15 | "IDF_TAG_FLAG": False, 16 | }, 17 | "stages": ["build"], 18 | ".build_template": { 19 | "before_script": [ 20 | "export OPENAI_API_KEY=FAKE_KEY_FOR_BUILD_ONLY", 21 | ], 22 | "script": [ 23 | "run_cmd python ${BASE_FRAMEWORK_PATH}/tools/ci/ci_build_apps.py ${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER -vv -t $IDF_TARGET --pytest-apps" 24 | ], 25 | "artifacts": { 26 | "paths": [ 27 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/size.json", 28 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/build_log.txt", 29 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/*.bin", 30 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/*.elf", 31 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/flasher_args.json", 32 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/flash_project_args", 33 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/config/sdkconfig.json", 34 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/sdkconfig", 35 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/bootloader/*.bin", 36 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/build*/partition_table/*.bin", 37 | "${CI_PROJECT_DIR}/solutions/$CI_BUILD_FOLDER/*.py", 38 | ], 39 | "expire_in": "4 days", 40 | }, 41 | }, 42 | } 43 | 44 | # Generate jobs 45 | jobs = {} 46 | for entry in build_folders_targets: 47 | folder = entry["folder"] 48 | for target in entry["targets"]: 49 | job_name = f"build_{folder}_{target}" 50 | jobs[job_name] = { 51 | "stage": "build", 52 | "extends": ".build_template", 53 | "variables": { 54 | "CI_BUILD_FOLDER": folder, 55 | "IDF_TARGET": target, 56 | }, 57 | } 58 | 59 | template.update(jobs) 60 | 61 | # Save YAML to file 62 | with open("generated_ci.yml", "w") as file: 63 | yaml.dump(template, file, default_flow_style=False) --------------------------------------------------------------------------------