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 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.

@github-actions
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

@github-actions
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

@codecov
Copy link

codecov bot commented Oct 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.07%. Comparing base (cde4477) to head (7734f35).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #41527      +/-   ##
==========================================
+ Coverage   51.05%   51.07%   +0.01%     
==========================================
  Files        1384     1384              
  Lines      100886   100884       -2     
  Branches    13056    13049       -7     
==========================================
+ Hits        51512    51524      +12     
+ Misses      49374    49360      -14     

☔ 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.

@github-actions
Copy link

github-actions bot commented Oct 21, 2025

PR #41527: Size comparison from c1f377d to 054ce9d

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section c1f377d 054ce9d change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106918 1106918 0 0.0
RAM 178882 178882 0 0.0
bl702 lighting-app bl702+eth FLASH 661238 661238 0 0.0
RAM 134969 134969 0 0.0
bl702+wifi FLASH 837350 837350 0 0.0
RAM 124421 124421 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070318 1070318 0 0.0
RAM 117261 117261 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899416 899416 0 0.0
RAM 105540 105540 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983336 983336 0 0.0
RAM 109748 109748 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770804 770804 0 0.0
RAM 103312 103312 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782560 782560 0 0.0
RAM 108472 108472 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728372 728372 0 0.0
RAM 97380 97380 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712840 712840 0 0.0
RAM 97580 97580 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554514 554514 0 0.0
RAM 205752 205752 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587754 587754 0 0.0
RAM 205840 205840 0 0.0
efr32 lock-app BRD4187C FLASH 963328 963328 0 0.0
RAM 126332 126332 0 0.0
BRD4338a FLASH 757032 757024 -8 -0.0
RAM 256960 256960 0 0.0
window-app BRD4187C FLASH 1058772 1058772 0 0.0
RAM 122560 122560 0 0.0
esp32 all-clusters-app c3devkit DRAM 103440 103440 0 0.0
FLASH 1796188 1796188 0 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933232 933232 0 0.0
RAM 161317 161317 0 0.0
nxp contact mcxw71+release FLASH 692208 692208 0 0.0
RAM 61496 61496 0 0.0
lighting mcxw71+release FLASH 723720 723720 0 0.0
RAM 68156 68156 0 0.0
lock mcxw71+release FLASH 773976 773976 0 0.0
RAM 61940 61940 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1676940 1676940 0 0.0
RAM 213908 213908 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1593556 1593556 0 0.0
RAM 211116 211116 0 0.0
light cy8ckit_062s2_43012 FLASH 1460100 1460100 0 0.0
RAM 197728 197728 0 0.0
lock cy8ckit_062s2_43012 FLASH 1492652 1492652 0 0.0
RAM 225448 225448 0 0.0
qpg lighting-app qpg6200+debug FLASH 837272 837272 0 0.0
RAM 127716 127716 0 0.0
lock-app qpg6200+debug FLASH 774052 774052 0 0.0
RAM 118692 118692 0 0.0
realtek light-switch-app rtl8777g FLASH 706760 706760 0 0.0
RAM 106912 106912 0 0.0
lighting-app rtl8777g FLASH 757856 757856 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470252 470252 0 0.0
RAM 141320 141320 0 0.0
telink bridge-app tl7218x FLASH 710662 710662 0 0.0
RAM 90552 90552 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 797040 797040 0 0.0
RAM 41008 41008 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788240 788240 0 0.0
RAM 93652 93652 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 715126 715126 0 0.0
RAM 51852 51852 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748430 748430 0 0.0
RAM 70900 70900 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725278 725278 0 0.0
RAM 34600 34600 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602556 602556 0 0.0
RAM 108700 108700 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820860 820864 4 0.0
RAM 92048 92048 0 0.0

@github-actions
Copy link

PR #41527: Size comparison from c1f377d to 01e41ff

Full report (6 builds for cc32xx, nrfconnect, realtek, stm32)
platform target config section c1f377d 01e41ff change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554514 554514 0 0.0
RAM 205752 205752 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587754 587754 0 0.0
RAM 205840 205840 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933232 933232 0 0.0
RAM 161317 161317 0 0.0
realtek light-switch-app rtl8777g FLASH 706760 706760 0 0.0
RAM 106912 106912 0 0.0
lighting-app rtl8777g FLASH 757856 757856 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470252 470252 0 0.0
RAM 141320 141320 0 0.0

@github-actions
Copy link

github-actions bot commented Oct 21, 2025

PR #41527: Size comparison from 1f47e8d to 2cf966a

Full report (9 builds for cc13x4_26x4, cc32xx, realtek, stm32)
platform target config section 1f47e8d 2cf966a change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770636 770636 0 0.0
RAM 103304 103304 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782368 782368 0 0.0
RAM 108472 108472 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728196 728196 0 0.0
RAM 97364 97364 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712656 712656 0 0.0
RAM 97580 97580 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554330 554330 0 0.0
RAM 205736 205736 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587578 587578 0 0.0
RAM 205832 205832 0 0.0
realtek light-switch-app rtl8777g FLASH 706584 706584 0 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757672 757672 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470076 470076 0 0.0
RAM 141304 141304 0 0.0

@github-actions
Copy link

github-actions bot commented Oct 21, 2025

PR #41527: Size comparison from cde4477 to 7734f35

Full report (37 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, efr32, esp32, nrfconnect, nxp, psoc6, qpg, realtek, stm32, telink)
platform target config section cde4477 7734f35 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1106622 1106622 0 0.0
RAM 178874 178874 0 0.0
bl702 lighting-app bl702+eth FLASH 661198 661198 0 0.0
RAM 134969 134969 0 0.0
bl702+wifi FLASH 837310 837310 0 0.0
RAM 124405 124405 0 0.0
bl706+mfd+rpc+littlefs FLASH 1070278 1070278 0 0.0
RAM 117261 117261 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 899120 899120 0 0.0
RAM 105524 105524 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 983040 983040 0 0.0
RAM 109740 109740 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 770636 770636 0 0.0
RAM 103304 103304 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 782368 782368 0 0.0
RAM 108472 108472 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 728196 728196 0 0.0
RAM 97364 97364 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 712656 712656 0 0.0
RAM 97580 97580 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 554330 554286 -44 -0.0
RAM 205736 205736 0 0.0
lock CC3235SF_LAUNCHXL FLASH 587578 587534 -44 -0.0
RAM 205832 205832 0 0.0
efr32 lock-app BRD4187C FLASH 963160 963160 0 0.0
RAM 126328 126328 0 0.0
BRD4338a FLASH 756712 756712 0 0.0
RAM 256952 256952 0 0.0
window-app BRD4187C FLASH 1058460 1058452 -8 -0.0
RAM 122556 122556 0 0.0
esp32 all-clusters-app c3devkit DRAM 103424 103424 0 0.0
FLASH 1796056 1796056 0 0.0
IRAM 83862 83862 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 933064 933064 0 0.0
RAM 161313 161313 0 0.0
nxp contact mcxw71+release FLASH 691896 691896 0 0.0
RAM 61496 61496 0 0.0
lighting mcxw71+release FLASH 723400 723400 0 0.0
RAM 68140 68140 0 0.0
lock mcxw71+release FLASH 773664 773664 0 0.0
RAM 61932 61932 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1676628 1676612 -16 -0.0
RAM 213900 213900 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1593244 1593228 -16 -0.0
RAM 211108 211108 0 0.0
light cy8ckit_062s2_43012 FLASH 1459788 1459788 0 0.0
RAM 197728 197728 0 0.0
lock cy8ckit_062s2_43012 FLASH 1492340 1492324 -16 -0.0
RAM 225440 225440 0 0.0
qpg lighting-app qpg6200+debug FLASH 837088 837088 0 0.0
RAM 127708 127708 0 0.0
lock-app qpg6200+debug FLASH 773868 773868 0 0.0
RAM 118684 118684 0 0.0
realtek light-switch-app rtl8777g FLASH 706584 706584 0 0.0
RAM 106904 106904 0 0.0
lighting-app rtl8777g FLASH 757672 757672 0 0.0
RAM 127236 127236 0 0.0
stm32 light STM32WB5MM-DK FLASH 470076 470076 0 0.0
RAM 141304 141304 0 0.0
telink bridge-app tl7218x FLASH 710558 710558 0 0.0
RAM 90544 90544 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 796912 796912 0 0.0
RAM 41000 41000 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 788112 788112 0 0.0
RAM 93644 93644 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 714998 714998 0 0.0
RAM 51844 51844 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 748302 748302 0 0.0
RAM 70892 70892 0 0.0
light-switch-app-ota-factory-data tl3218x_retention FLASH 725150 725150 0 0.0
RAM 34592 34592 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 602428 602428 0 0.0
RAM 108692 108692 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 820732 820736 4 0.0
RAM 92040 92040 0 0.0

Copy link
Contributor

@samadDotDev samadDotDev left a comment

Choose a reason for hiding this comment

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

Tested with smartthings controller and validated that the PR atleast addresses the linked issue. As mentioned here, this however, surfaced a few other issues (which are not necessarily a regression from this PR) that we can track separately and address in a follow up:

  1. #41584
  2. #41585

@mergify mergify bot merged commit 63d896f into project-chip:master Oct 23, 2025
75 checks passed
@yufengwangca yufengwangca deleted the pr/camera/sdp_mid branch October 24, 2025 05:22
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

4 participants