Skip to content

Commit 7eeb60c

Browse files
authored
Merge branch 'master' into create_TC_IDM_3_2_python3_test
2 parents b9463af + ad60c95 commit 7eeb60c

File tree

106 files changed

+8632
-716
lines changed

Some content is hidden

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

106 files changed

+8632
-716
lines changed

config/esp32/components/chip/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ menu "CHIP Device Layer"
11611161
int "MRP local active retry interval for Thread network in milliseconds"
11621162
depends on ENABLE_MATTER_OVER_THREAD
11631163
range 0 3600000
1164-
default 800
1164+
default 2000
11651165
help
11661166
Base retry interval of the present Thread node when it is in the active state.
11671167

@@ -1177,7 +1177,7 @@ menu "CHIP Device Layer"
11771177
int "MRP local idle retry interval for Thread network in milliseconds"
11781178
depends on ENABLE_MATTER_OVER_THREAD
11791179
range 0 3600000
1180-
default 800
1180+
default 2000
11811181
help
11821182
Base retry interval of the present Thread node when it is in the idle state.
11831183

@@ -1193,7 +1193,7 @@ menu "CHIP Device Layer"
11931193
int "MRP retransmission delta timeout for Thread network in milliseconds"
11941194
depends on ENABLE_MATTER_OVER_THREAD
11951195
range 0 3600000
1196-
default 500
1196+
default 1500
11971197
help
11981198
A constant value added to the calculated retransmission timeout.
11991199

examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5775,7 +5775,7 @@ cluster AudioOutput = 1291 {
57755775

57765776
/** This cluster provides an interface for launching content on a media player device such as a TV or Speaker. */
57775777
cluster ApplicationLauncher = 1292 {
5778-
revision 1; // NOTE: Default/not specifically set
5778+
revision 2;
57795779

57805780
enum StatusEnum : enum8 {
57815781
kSuccess = 0;
@@ -5790,7 +5790,7 @@ cluster ApplicationLauncher = 1292 {
57905790
kApplicationPlatform = 0x1;
57915791
}
57925792

5793-
shared struct ApplicationStruct {
5793+
struct ApplicationStruct {
57945794
int16u catalogVendorID = 0;
57955795
char_string applicationID = 1;
57965796
}
@@ -5826,17 +5826,17 @@ cluster ApplicationLauncher = 1292 {
58265826
optional octet_string data = 1;
58275827
}
58285828

5829-
/** Upon receipt, this SHALL launch the specified app with optional data. The TV Device SHALL launch and bring to foreground the identified application in the command if the application is not already launched and in foreground. The TV Device SHALL update state attribute on the Application Basic cluster of the Endpoint corresponding to the launched application. This command returns a Launch Response. */
5829+
/** Upon receipt of this command, the server SHALL launch the application with optional data. */
58305830
command LaunchApp(LaunchAppRequest): LauncherResponse = 0;
5831-
/** Upon receipt on a Video Player endpoint this SHALL stop the specified application if it is running. */
5831+
/** Upon receipt of this command, the server SHALL stop the application if it is running. */
58325832
command StopApp(StopAppRequest): LauncherResponse = 1;
5833-
/** Upon receipt on a Video Player endpoint this SHALL hide the specified application if it is running and visible. */
5833+
/** Upon receipt of this command, the server SHALL hide the application. */
58345834
command HideApp(HideAppRequest): LauncherResponse = 2;
58355835
}
58365836

58375837
/** This cluster provides information about an application running on a TV or media player device which is represented as an endpoint. */
58385838
cluster ApplicationBasic = 1293 {
5839-
revision 1; // NOTE: Default/not specifically set
5839+
revision 1;
58405840

58415841
enum ApplicationStatusEnum : enum8 {
58425842
kStopped = 0;
@@ -5845,7 +5845,7 @@ cluster ApplicationBasic = 1293 {
58455845
kActiveVisibleNotFocus = 3;
58465846
}
58475847

5848-
shared struct ApplicationStruct {
5848+
struct ApplicationStruct {
58495849
int16u catalogVendorID = 0;
58505850
char_string applicationID = 1;
58515851
}

examples/camera-app/linux/include/webrtc-abstract.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ enum class MediaType : uint8_t
4242
Video,
4343
};
4444

45+
struct ICECandidateInfo
46+
{
47+
std::string candidate;
48+
std::string mid;
49+
int mlineIndex;
50+
};
51+
4552
using OnLocalDescriptionCallback = std::function<void(const std::string & sdp, SDPType type)>;
46-
using OnICECandidateCallback = std::function<void(const std::string & candidate)>;
53+
using OnICECandidateCallback = std::function<void(const ICECandidateInfo & candidateInfo)>;
4754
using OnConnectionStateCallback = std::function<void(bool connected)>;
4855
using OnTrackCallback = std::function<void(std::shared_ptr<WebRTCTrack> track)>;
4956

examples/camera-app/linux/include/webrtc-transport.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ class WebrtcTransport : public Transport
105105

106106
void SetSdpAnswer(std::string localSdp) { mLocalSdp = localSdp; }
107107

108-
std::vector<std::string> GetCandidates() { return mLocalCandidates; }
108+
const std::vector<ICECandidateInfo> & GetCandidates() { return mLocalCandidates; }
109109

110-
void SetCandidates(std::vector<std::string> candidates) { mLocalCandidates = candidates; }
110+
void SetCandidates(std::vector<ICECandidateInfo> candidates) { mLocalCandidates = candidates; }
111111

112112
void AddRemoteCandidate(const std::string & candidate, const std::string & mid);
113113

@@ -119,7 +119,7 @@ class WebrtcTransport : public Transport
119119

120120
// WebRTC Callbacks
121121
void OnLocalDescription(const std::string & sdp, SDPType type);
122-
void OnICECandidate(const std::string & candidate);
122+
void OnICECandidate(const ICECandidateInfo & candidateInfo);
123123
void OnConnectionStateChanged(bool connected);
124124
void OnTrack(std::shared_ptr<WebRTCTrack> track);
125125

@@ -138,7 +138,7 @@ class WebrtcTransport : public Transport
138138

139139
std::string mLocalSdp;
140140
SDPType mLocalSdpType;
141-
std::vector<std::string> mLocalCandidates;
141+
std::vector<ICECandidateInfo> mLocalCandidates;
142142

143143
RequestArgs mRequestArgs;
144144
OnTransportLocalDescriptionCallback mOnLocalDescription = nullptr;

examples/camera-app/linux/src/clusters/webrtc-provider/webrtc-provider-manager.cpp

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -887,42 +887,47 @@ void WebRTCProviderManager::OnConnectionStateChanged(bool connected, const uint1
887887
}
888888
else
889889
{
890-
WebrtcTransport * transport = GetTransport(sessionId);
891-
if (transport == nullptr)
892-
{
890+
// Schedule cleanup on Matter thread to ensure proper locking when calling RemoveSession.
891+
// Safe to capture 'this' by value: WebRTCProviderManager is a member of the global CameraDevice
892+
// object which has static storage duration and lives for the entire program lifetime.
893+
DeviceLayer::SystemLayer().ScheduleLambda([this, sessionId]() {
894+
WebrtcTransport * transport = GetTransport(sessionId);
895+
if (transport == nullptr)
896+
{
897+
ChipLogProgress(Camera,
898+
"Transport not found for session %u during disconnect; session may have already been cleaned up",
899+
sessionId);
900+
return;
901+
}
893902

894-
ChipLogProgress(Camera,
895-
"Transport not found for session %u during disconnect; session may have already been cleaned up",
896-
sessionId);
897-
return;
898-
}
903+
// Connection was closed/disconnected by the peer - clean up the session
904+
ChipLogProgress(Camera, "Peer connection closed for session %u, cleaning up resources", sessionId);
899905

900-
// Connection was closed/disconnected by the peer - clean up the session
901-
ChipLogProgress(Camera, "Peer connection closed for session %u, cleaning up resources", sessionId);
906+
// Release the Video and Audio Streams from the CameraAVStreamManagement
907+
// cluster and update the reference counts.
908+
ReleaseAudioVideoStreams(sessionId);
902909

903-
// Release the Video and Audio Streams from the CameraAVStreamManagement
904-
// cluster and update the reference counts.
905-
ReleaseAudioVideoStreams(sessionId);
906-
907-
// Capture args before unregistering in case the transport is invalidated
908-
WebrtcTransport::RequestArgs args = transport->GetRequestArgs();
910+
// Capture args before unregistering in case the transport is invalidated
911+
WebrtcTransport::RequestArgs args = transport->GetRequestArgs();
909912

910-
// Unregister the transport from the media controller
911-
UnregisterWebrtcTransport(sessionId);
913+
// Unregister the transport from the media controller
914+
UnregisterWebrtcTransport(sessionId);
912915

913-
// Remove from session maps
914-
mSessionIdMap.erase(ScopedNodeId(args.peerNodeId, args.fabricIndex));
916+
// Remove from session maps
917+
mSessionIdMap.erase(ScopedNodeId(args.peerNodeId, args.fabricIndex));
915918

916-
// Remove from current sessions list in the WebRTC Transport Provider
917-
if (mWebRTCTransportProvider != nullptr)
918-
{
919-
mWebRTCTransportProvider->RemoveSession(sessionId);
920-
}
919+
// Remove from current sessions list in the WebRTC Transport Provider
920+
// This MUST be called on the Matter thread with the stack lock held
921+
if (mWebRTCTransportProvider != nullptr)
922+
{
923+
mWebRTCTransportProvider->RemoveSession(sessionId);
924+
}
921925

922-
// Finally, remove and destroy the transport
923-
mWebrtcTransportMap.erase(sessionId);
926+
// Finally, remove and destroy the transport
927+
mWebrtcTransportMap.erase(sessionId);
924928

925-
ChipLogProgress(Camera, "Session %u cleanup completed", sessionId);
929+
ChipLogProgress(Camera, "Session %u cleanup completed", sessionId);
930+
});
926931
}
927932
}
928933

@@ -975,7 +980,9 @@ CHIP_ERROR WebRTCProviderManager::SendICECandidatesCommand(Messaging::ExchangeMa
975980
ChipLogError(Camera, "WebTransport not found for the sessionId: %u", sessionId);
976981
return CHIP_ERROR_INTERNAL;
977982
}
978-
std::vector<std::string> localCandidates = transport->GetCandidates();
983+
984+
const std::vector<ICECandidateInfo> & localCandidates = transport->GetCandidates();
985+
979986
// Build the command
980987
WebRTCTransportRequestor::Commands::ICECandidates::Type command;
981988

@@ -986,9 +993,31 @@ CHIP_ERROR WebRTCProviderManager::SendICECandidatesCommand(Messaging::ExchangeMa
986993
}
987994

988995
std::vector<ICECandidateStruct> iceCandidateStructList;
989-
for (const auto & candidate : localCandidates)
996+
for (const auto & candidateInfo : localCandidates)
990997
{
991-
ICECandidateStruct iceCandidate = { CharSpan::fromCharString(candidate.c_str()) };
998+
ICECandidateStruct iceCandidate;
999+
iceCandidate.candidate = CharSpan(candidateInfo.candidate.data(), candidateInfo.candidate.size());
1000+
1001+
// Set SDPMid if available
1002+
if (!candidateInfo.mid.empty())
1003+
{
1004+
iceCandidate.SDPMid.SetNonNull(CharSpan(candidateInfo.mid.data(), candidateInfo.mid.size()));
1005+
}
1006+
else
1007+
{
1008+
iceCandidate.SDPMid.SetNull();
1009+
}
1010+
1011+
// Set SDPMLineIndex if valid
1012+
if (candidateInfo.mlineIndex >= 0)
1013+
{
1014+
iceCandidate.SDPMLineIndex.SetNonNull(static_cast<uint16_t>(candidateInfo.mlineIndex));
1015+
}
1016+
else
1017+
{
1018+
iceCandidate.SDPMLineIndex.SetNull();
1019+
}
1020+
9921021
iceCandidateStructList.push_back(iceCandidate);
9931022
}
9941023

examples/camera-app/linux/src/webrtc-libdatachannel.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,38 @@ class LibDataChannelPeerConnection : public WebRTCPeerConnection
291291
void SetCallbacks(OnLocalDescriptionCallback onLocalDescription, OnICECandidateCallback onICECandidate,
292292
OnConnectionStateCallback onConnectionState, OnTrackCallback onTrack) override
293293
{
294-
mPeerConnection->onLocalDescription(
295-
[onLocalDescription](rtc::Description desc) { onLocalDescription(std::string(desc), RtcTypeToSDPType(desc.type())); });
294+
mPeerConnection->onLocalDescription([onLocalDescription, onICECandidate](rtc::Description desc) {
295+
// First, notify about the local description
296+
onLocalDescription(std::string(desc), RtcTypeToSDPType(desc.type()));
296297

297-
mPeerConnection->onLocalCandidate([onICECandidate](rtc::Candidate candidate) { onICECandidate(std::string(candidate)); });
298+
// Extract any candidates embedded in the SDP description
299+
std::vector<rtc::Candidate> candidates = desc.candidates();
300+
ChipLogProgress(Camera, "Extracted %lu candidates from SDP description", candidates.size());
301+
302+
for (const auto & candidate : candidates)
303+
{
304+
ICECandidateInfo candidateInfo;
305+
candidateInfo.candidate = std::string(candidate);
306+
candidateInfo.mid = candidate.mid();
307+
candidateInfo.mlineIndex = -1; // libdatachannel doesn't provide mlineIndex
308+
309+
ChipLogProgress(Camera, "[From SDP] Candidate: %s, mid: %s", candidateInfo.candidate.c_str(),
310+
candidateInfo.mid.c_str());
311+
312+
onICECandidate(candidateInfo);
313+
}
314+
});
315+
316+
mPeerConnection->onLocalCandidate([onICECandidate](rtc::Candidate candidate) {
317+
ICECandidateInfo candidateInfo;
318+
candidateInfo.candidate = std::string(candidate);
319+
candidateInfo.mid = candidate.mid();
320+
321+
// Note: libdatachannel doesn't directly provide mlineIndex, so we use -1 to indicate it is not present.
322+
candidateInfo.mlineIndex = -1;
323+
324+
onICECandidate(candidateInfo);
325+
});
298326

299327
mPeerConnection->onStateChange([onConnectionState](rtc::PeerConnection::State state) {
300328
ChipLogProgress(Camera, "[PeerConnection State: %s]", GetPeerConnectionStateStr(state));

examples/camera-app/linux/src/webrtc-transport.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void WebrtcTransport::Start()
146146
mPeerConnection = CreateWebRTCPeerConnection();
147147

148148
mPeerConnection->SetCallbacks([this](const std::string & sdp, SDPType type) { this->OnLocalDescription(sdp, type); },
149-
[this](const std::string & candidate) { this->OnICECandidate(candidate); },
149+
[this](const ICECandidateInfo & candidateInfo) { this->OnICECandidate(candidateInfo); },
150150
[this](bool connected) { this->OnConnectionStateChanged(connected); },
151151
[this](std::shared_ptr<WebRTCTrack> track) { this->OnTrack(track); });
152152
}
@@ -208,12 +208,13 @@ bool WebrtcTransport::ClosePeerConnection()
208208
return true;
209209
}
210210

211-
void WebrtcTransport::OnICECandidate(const std::string & candidate)
211+
void WebrtcTransport::OnICECandidate(const ICECandidateInfo & candidateInfo)
212212
{
213213
ChipLogProgress(Camera, "ICE Candidate received for sessionID: %u", mRequestArgs.sessionId);
214-
mLocalCandidates.push_back(candidate);
214+
mLocalCandidates.push_back(candidateInfo);
215215
ChipLogProgress(Camera, "Local Candidate:");
216-
ChipLogProgress(Camera, "%s", candidate.c_str());
216+
ChipLogProgress(Camera, "%s", candidateInfo.candidate.c_str());
217+
ChipLogProgress(Camera, " mid: %s, mlineIndex: %d", candidateInfo.mid.c_str(), candidateInfo.mlineIndex);
217218
}
218219

219220
void WebrtcTransport::OnConnectionStateChanged(bool connected)

examples/camera-controller/webrtc-manager/WebRTCManager.cpp

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,38 @@ CHIP_ERROR WebRTCManager::Connnect(Controller::DeviceCommissioner & commissioner
277277
mLocalDescription = std::string(desc);
278278
ChipLogProgress(Camera, "Local Description:");
279279
ChipLogProgress(Camera, "%s", mLocalDescription.c_str());
280+
281+
// Extract any candidates embedded in the SDP description
282+
std::vector<rtc::Candidate> candidates = desc.candidates();
283+
ChipLogProgress(Camera, "Extracted %lu candidates from SDP description", candidates.size());
284+
285+
for (const auto & candidate : candidates)
286+
{
287+
ICECandidateInfo candidateInfo;
288+
candidateInfo.candidate = std::string(candidate);
289+
candidateInfo.mid = candidate.mid();
290+
candidateInfo.mlineIndex = -1; // libdatachannel doesn't provide mlineIndex
291+
292+
ChipLogProgress(Camera, "[From SDP] Candidate: %s, mid: %s", candidateInfo.candidate.c_str(),
293+
candidateInfo.mid.c_str());
294+
295+
mLocalCandidates.push_back(candidateInfo);
296+
}
280297
});
281298

282299
mPeerConnection->onLocalCandidate([this](rtc::Candidate candidate) {
283-
std::string candidateStr = std::string(candidate);
284-
mLocalCandidates.push_back(candidateStr);
300+
ICECandidateInfo candidateInfo;
301+
candidateInfo.candidate = std::string(candidate);
302+
candidateInfo.mid = candidate.mid();
303+
304+
// Note: libdatachannel doesn't directly provide mlineIndex, so we use -1 to indicate it is not present.
305+
candidateInfo.mlineIndex = -1;
306+
285307
ChipLogProgress(Camera, "Local Candidate:");
286-
ChipLogProgress(Camera, "%s", candidateStr.c_str());
308+
ChipLogProgress(Camera, "%s", candidateInfo.candidate.c_str());
309+
ChipLogProgress(Camera, " mid: %s, mlineIndex: %d", candidateInfo.mid.c_str(), candidateInfo.mlineIndex);
310+
311+
mLocalCandidates.push_back(candidateInfo);
287312
});
288313

289314
mPeerConnection->onStateChange([this](rtc::PeerConnection::State state) {

examples/camera-controller/webrtc-manager/WebRTCManager.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@
2626
#include <webrtc-manager/WebRTCProviderClient.h>
2727
#include <webrtc-manager/WebRTCRequestorDelegate.h>
2828

29+
struct ICECandidateInfo
30+
{
31+
std::string candidate;
32+
std::string mid;
33+
int mlineIndex;
34+
};
35+
2936
class WebRTCManager
3037
{
3138
public:
@@ -87,8 +94,8 @@ class WebRTCManager
8794
uint16_t mPendingSessionId = 0;
8895
std::string mLocalDescription;
8996

90-
// Local vector to store the ICE Candidate strings coming from the WebRTC stack
91-
std::vector<std::string> mLocalCandidates;
97+
// Local vector to store the ICE Candidate info coming from the WebRTC stack
98+
std::vector<ICECandidateInfo> mLocalCandidates;
9299

93100
std::shared_ptr<rtc::Track> mTrack;
94101
std::shared_ptr<rtc::Track> mAudioTrack;

0 commit comments

Comments
 (0)