Fix interop/API type mismatches: RtcDataChannel width, SetLocalDescription spec alignment#38
Merged
Merged
Conversation
…ption spec alignment RtcDataChannel MaxPacketLifeTime/MaxRetransmits: uint32_t -> uint16_t to match W3C spec (unsigned short) and the C# abstract ushort? declaration. SetLocalDescription: the C++/CLI override used non-nullable RtcSessionDescription which occupies a different CLR VTable slot from the abstract Nullable<RtcSessionDescription>. More fundamentally the W3C spec uses a distinct RTCLocalSessionDescriptionInit dict where 'type' is optional (not required as in RTCSessionDescriptionInit used by setRemoteDescription). A null type maps to the no-arg native SetLocalDescription() overload which lets the native stack create the description. - Add RtcLocalSessionDescriptionInit struct with RtcSdpType? Type - Add implicit conversion from RtcSessionDescription for CreateOffer/CreateAnswer ergonomics - Update SetLocalDescription abstract to accept RtcLocalSessionDescriptionInit? - Update C++/CLI to Nullable<RtcLocalSessionDescriptionInit> - Update contract test to lock in spec-correct type - Add TODO in MarshalPeerConnection.h for implementation pass Fixes #37 BugzId:37
…structs
- Both types use record struct with { get; init; } properties
- Add seealso spec links on Type and Sdp properties of both types
- Add implicit conversion RtcLocalSessionDescriptionInit -> RtcSessionDescription
(throws InvalidOperationException if Type is null)
BugzId:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #37
Changes
RtcDataChannel (uint32_t -> uint16_t)
MaxPacketLifeTime and MaxRetransmits were declared as Nullable<uint32_t> in the C++/CLI layer. The W3C spec defines both as unsigned short, matching the C# abstract ushort? (Nullable<uint16_t>). The mismatch prevented the interop overrides from satisfying their abstract VTable slots.
SetLocalDescription spec alignment + VTable fix
The C++/CLI override used RtcSessionDescription (non-nullable value type), which is a different CLR signature from the abstract Nullable. Beyond the VTable bug, the W3C spec uses two distinct dictionary types:
The optional type is meaningful: it selects between two native overloads on PeerConnectionInterface -- one that takes an explicit SessionDescriptionInterface, and one that lets the native stack create the description itself.
This PR introduces RtcLocalSessionDescriptionInit with RtcSdpType? Type, an implicit conversion from RtcSessionDescription (so CreateOffer/CreateAnswer results pass through without a cast), and updates the abstract signature, C++/CLI override, and contract test accordingly.