Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to switch image topics? #61

Open
bthall16 opened this issue Jun 12, 2021 · 0 comments
Open

How to switch image topics? #61

bthall16 opened this issue Jun 12, 2021 · 0 comments

Comments

@bthall16
Copy link

I'm curious if/how I can switch the topic being streamed from the WebRTC server node? viewer.js is made to load a single image topic once on page load. I'm interested in using this library for a React app, where the user can switch between a list of topics without requiring a page refresh.

My thought, using what's available in webrtc_ros.js, was to call removeRemoteStream followed by sendConfigure when the user switches topics, followed by addRemoteStream with the new topic and again followed by sendConfigure. This doesn't appear to work though, causing Chrome to log an error to the console:

Uncaught (in promise) DOMException: Failed to execute 'setLocalDescription' on 'RTCPeerConnection': Failed to set local answer sdp: Called in wrong state: stable

This could just be a race condition between removing the old stream and adding a new one. If I instead use buttons in the React app to manually remove the stream, then separately select a new topic, there doesn't appear to be an issue. I don't have a definitive reason but my assumption is the delay between when I click the buttons is enough time for things to settle, whereas immediately trying to add the remote stream after removing the current one is too quick.

I'll also note that switching topics in this way seems to only be possible by configuring the peer connection using { sdpSemantics: 'plan-b' }. Using the default (and modern) unified-plan value, switching topics isn't possible at all, with the Chrome console showing:

[Deprecation] "Complex" Plan B SDP detected! Chrome will switch the default sdpSemantics in M72, around January 2019 from 'plan-b' to the standardized 'unified-plan' format and this peer connection is relying on the default sdpSemantics. This SDP is not compatible with Unified Plan and will be rejected by clients expecting Unified Plan. For more information about how to prepare for the switch, see https://webrtc.org/web-apis/chrome/unified-plan/.
---
onRemoteSdpError DOMException: Failed to set remote offer sdp: Media section has more than one track specified with a=ssrc lines which is not supported with Unified Plan.

Chrome definitely doesn't like using plan-b semantics though, warning:

[Deprecation] Plan B SDP semantics, which is used when constructing an RTCPeerConnection with {sdpSemantics:"plan-b"}, is a legacy version of the Session Description Protocol that has severe compatibility issues on modern browsers. The standardized SDP format, "unified-plan", has been used by default since M72 (January, 2019). Dropping support for Plan B is targeted for M93 (Canary: July 15, 2021; Stable: August 24, 2021).

I appreciate any help with this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant