Skip to content

Conversation

yufengwangca
Copy link
Contributor

@yufengwangca yufengwangca commented Oct 17, 2025

Summary

The SDK is sending ICE candidates with NULL values for SDPMid (0x1) and SDPMLineIndex (0x2), even though the SDP contains multiple media streams (audio and video with mid tags "audio" and "video").

The root cause is the ICECandidateStruct is being initialized with only the candidate string, but not setting the SDPMid and SDPMLineIndex fields

The camera-controller's WebRTCProviderClient also needs to be updated to populate SDPMid and SDPMLineIndex when sending ICE candidates to the provider. Let me check the current implementation and update it.

Related issues

Fixes: #41460

Testing

  1. Build example apps
source scripts/activate.sh
./scripts/build/build_examples.py --target linux-x64-camera build 
./scripts/build/build_examples.py --target linux-x64-camera-controller build 
  1. Launch the Camera Application:
sudo rm -rf /tmp/chip_*
./chip-camera-app
  1. Launch the Camera Controller:
    Open a separate terminal console.
    Execute the command: ./chip-camera-controller

  2. Commission the Camera Device:
    In the controller console, initiate the commissioning process using the pairing code.

pairing onnetwork 1 20202021

  1. Trigger the normal flow
    webrtc establish-session 1

Confirm the SDPMid and SDPMLineIndex are set in ICECandidates/ProvideICECandidates Commands

@Copilot Copilot AI review requested due to automatic review settings October 17, 2025 21:57
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the WebRTC implementation to properly populate SDPMid and SDPMLineIndex fields in ICE candidates instead of sending NULL values. The changes enable proper handling of multi-media streams (audio and video) by including the required SDP metadata when sending ICE candidates between camera and controller applications.

Key changes:

  • Introduced ICECandidateInfo struct to carry candidate string, mid, and mlineIndex information
  • Updated ICE candidate callbacks throughout the WebRTC stack to use structured candidate info
  • Modified command building logic to populate SDPMid and SDPMLineIndex fields in ICECandidateStruct

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
examples/camera-controller/webrtc-manager/WebRTCProviderClient.h Updated method signature and added member variables for candidate mid storage
examples/camera-controller/webrtc-manager/WebRTCProviderClient.cpp Implemented structured ICE candidate handling with SDPMid/SDPMLineIndex population
examples/camera-controller/webrtc-manager/WebRTCManager.h Added ICECandidateInfo struct and updated member variable type
examples/camera-controller/webrtc-manager/WebRTCManager.cpp Updated callback to extract mid information from libdatachannel candidates
examples/camera-app/linux/src/webrtc-transport.cpp Updated callback signature to receive structured candidate info
examples/camera-app/linux/src/webrtc-libdatachannel.cpp Modified callback to create ICECandidateInfo with extracted mid data
examples/camera-app/linux/src/clusters/webrtc-provider/webrtc-provider-manager.cpp Updated ICECandidates command building to populate SDP fields
examples/camera-app/linux/include/webrtc-transport.h Updated method signatures and member variable types
examples/camera-app/linux/include/webrtc-abstract.h Added ICECandidateInfo struct definition and updated callback type

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses an issue where SDPMid and SDPMLineIndex were not being populated for ICE candidates by introducing an ICECandidateInfo struct to carry this information through the WebRTC stack. The changes are well-contained and logical.

However, I've identified a few issues that need attention. There is a critical lifetime issue that could lead to dangling pointers and a crash. Additionally, the fix for SDPMLineIndex is incomplete as it uses a hardcoded value, which is incorrect for multi-stream scenarios. I've also noted some code duplication and a minor optimization opportunity.

My detailed comments provide suggestions to resolve these issues. Once addressed, this will be a solid improvement.

Copy link

PR #41527: Size comparison from 8bbe2ea to c238363

Full report (3 builds for realtek, stm32)
platform target config section 8bbe2ea c238363 change % change
realtek light-switch-app rtl8777g FLASH 706208 706512 304 0.0
RAM 106800 106800 0 0.0
lighting-app rtl8777g FLASH 757304 757608 304 0.0
RAM 127164 127164 0 0.0
stm32 light STM32WB5MM-DK FLASH 469772 469956 184 0.0
RAM 141248 141248 0 0.0

Copy link

github-actions bot commented Oct 17, 2025

PR #41527: Size comparison from 8bbe2ea to 2623a2d

Full report (36 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section 8bbe2ea 2623a2d change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106314 1106504 190 0.0
RAM 178802 178802 0 0.0
bl702 lighting-app bl702+eth FLASH 660904 661094 190 0.0
RAM 134881 134881 0 0.0
bl702+wifi FLASH 837016 837206 190 0.0
RAM 124349 124349 0 0.0
bl706+mfd+rpc+littlefs FLASH 1069984 1070174 190 0.0
RAM 117189 117189 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 898826 899016 190 0.0
RAM 105468 105468 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983002 983192 190 0.0
RAM 109676 109676 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770324 770508 184 0.0
RAM 103240 103240 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782080 782264 184 0.0
RAM 108400 108400 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 727900 728076 176 0.0
RAM 97308 97308 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712344 712520 176 0.0
RAM 97508 97508 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554026 554218 192 0.0
RAM 205504 205504 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587278 587458 180 0.0
RAM 205768 205768 0 0.0
efr32 lock-app BRD4187C FLASH 962880 963040 160 0.0
RAM 126268 126268 0 0.0
BRD4338a FLASH 756080 756520 440 0.1
RAM 256888 256888 0 0.0
window-app BRD4187C FLASH 1057812 1058260 448 0.0
RAM 122464 122464 0 0.0
esp32 all-clusters-app c3devkit DRAM 103192 103192 0 0.0
FLASH 1795828 1795988 160 0.0
IRAM 83862 83862 0 0.0
nxp contact mcxw71+release FLASH 691360 691672 312 0.0
RAM 61424 61424 0 0.0
lighting mcxw71+release FLASH 722856 723184 328 0.0
RAM 68084 68084 0 0.0
lock mcxw71+release FLASH 773128 773440 312 0.0
RAM 61868 61868 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1675932 1676388 456 0.0
RAM 213660 213660 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1592540 1592988 448 0.0
RAM 210956 210956 0 0.0
light cy8ckit_062s2_43012 FLASH 1459156 1459596 440 0.0
RAM 197656 197656 0 0.0
lock cy8ckit_062s2_43012 FLASH 1491708 1492148 440 0.0
RAM 225376 225376 0 0.0
qpg lighting-app qpg6200+debug FLASH 836520 836696 176 0.0
RAM 127644 127644 0 0.0
lock-app qpg6200+debug FLASH 773220 773396 176 0.0
RAM 118620 118620 0 0.0
realtek light-switch-app rtl8777g FLASH 706208 706512 304 0.0
RAM 106800 106800 0 0.0
lighting-app rtl8777g FLASH 757304 757608 304 0.0
RAM 127164 127164 0 0.0
stm32 light STM32WB5MM-DK FLASH 469772 469956 184 0.0
RAM 141248 141248 0 0.0
telink bridge-app tl7218x FLASH 710402 710542 140 0.0
RAM 90436 90436 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 796788 796940 152 0.0
RAM 40936 40936 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 787988 788140 152 0.0
RAM 93580 93580 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 714914 715054 140 0.0
RAM 51736 51736 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748218 748358 140 0.0
RAM 70784 70784 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725066 725206 140 0.0
RAM 34484 34484 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602304 602456 152 0.0
RAM 108628 108628 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820608 820764 156 0.0
RAM 91976 91976 0 0.0

Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.03%. Comparing base (c15b122) to head (2623a2d).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41527      +/-   ##
==========================================
+ Coverage   51.02%   51.03%   +0.01%     
==========================================
  Files        1386     1385       -1     
  Lines      100982   100943      -39     
  Branches    13077    13059      -18     
==========================================
- Hits        51526    51520       -6     
+ Misses      49456    49423      -33     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] SDPMid and SDPMLineIndex are consistently null

1 participant