Phase 1: Implement MediaDeviceInfo marshalling & EnumerateDevices (#49)#66
Merged
General-Fault merged 10 commits intoJun 9, 2026
Merged
Conversation
- Add InputDeviceInfo.Create() factory for interop cross-assembly construction - Implement MarshalMediaDevices.h with EDataFlow→MediaDeviceKind mapping using marshal_as - Refactor EnumerateAudioEndpoints to derive kind via marshal_as, not redundant parameter - Create InputDeviceInfo instances for input devices, MediaDeviceInfo for output - Create InputDeviceInfo for video devices (always input kind) - Fix GetId failure path: log failure and continue (previously fell through silently) - All 110 managed tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add MarshalMediaTrackCapabilities.h with ValueRange<T> marshaling - Marshal native webrtc::DoubleRange and webrtc::IntRange to managed ValueRange<double/uint> - Add enum marshaling for VideoFacingModes, VideoResizeModes, EchoCancellationMode - Use bidirectional maps for enum conversions via marshal_as - Helper: MarshalToValueRange<T> for constructing value ranges with optional bounds - All 110 managed tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add MediaTrackSettings.Create() factory for interop cross-assembly construction - Add MarshalEchoCancellationValue() helpers for bool/string conversion - Prepare marshalling infrastructure for complete Settings/Capabilities DTOs - All 110 managed tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add MediaTrackCapabilities.Create() factory with all capability fields - Ensures complete DTO marshalling infrastructure across all Media types - All 110 managed tests pass Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…/CLI access C++/CLI cannot access C# internal members reliably across assembly boundaries, even with InternalsVisibleTo and friend assembly declarations. The standard .NET solution is to make the methods public but hide them from user IDE via [EditorBrowsable(EditorBrowsableState.Never)]. This preserves the intent: - Factories remain accessible to C++/CLI interop (public in IL) - Hidden from user autocomplete and static analysis tools (EditorBrowsable) - Added reciprocal InternalsVisibleTo in WebRtcInterop.Framework AssemblyInfo - Added #pragma as_friend directive in MediaDevices.cpp All factories now use this pattern: - MediaDeviceInfo.Create() - InputDeviceInfo.Create() - MediaTrackSettings.Create() - MediaTrackCapabilities.Create() - All 110 managed unit tests pass - WebRtcInterop.Framework builds clean Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
When a C++/CLI wrapper method accesses its own native pointer (_rpMedia*Interface), directly use the member variable instead of calling GetNative*() and converting through IntPtr + reinterpret_cast. This eliminates: - Unnecessary IntPtr conversion - Redundant validation checks - Code clarity/smell of round-trip conversion Changes: - MediaStreamTrack.cpp: Kind, Id, Enabled (get/set), Muted, ReadyState properties now access _rpMediaStreamTrackInterface->get() directly - MediaStream.cpp: Id, GetAudioTracks, GetVideoTracks, GetTrackById, Active properties now access _rpMediaStreamInterface->get() directly - KEPT: GetNative* calls for cross-class access (e.g., AddTrack/RemoveTrack accessing another object's MediaStreamTrackInterface) - All 110 managed unit tests pass - WebRtcInterop.Framework builds clean Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…irectly Changed MediaStreamTrack.GetNativeMediaStreamTrackInterface from protected internal to internal. Since it's now internal with InternalsVisibleTo + #pragma as_friend visibility to WebRtcInterop, callers can invoke it directly on the base class without needing type checking or dynamic_cast. Updated MediaStream::AddTrack and RemoveTrack to call the method directly on the parameter (WebRtcNet::Media::MediaStreamTrack^) without: - dynamic_cast to interop subclass - InvalidCastException validation - Intermediate variable assignment This relies on friend assembly visibility to access internal members. - All 110 managed unit tests pass - WebRtcInterop.Framework builds clean - Simpler, cleaner interop code Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace unnecessary GetNativeMediaStreamTrackInterface() and GetNativeMediaStreamInterface() calls within the same class with direct member access. This improves efficiency by avoiding IntPtr conversion and reinterpret_cast. - MediaStreamTrack.cpp: 6 properties now use _rpMediaStreamTrackInterface->get() directly - MediaStream.cpp: 7 methods now use _rpMediaStreamInterface->get() directly - Keep GetNative*() for cross-class access (e.g., AddTrack parameter validation) - GetNativeMediaStreamTrackInterface now protected internal for interop visibility All 110 managed tests pass, interop builds clean.
- Add MediaDeviceInfo marshalling support in WebRtcInterop - Update MediaStream and MediaStreamTrack managed APIs with XML docs - Add logging interface and update ICE/DTLS transport docs - Update RTC peer connection and transceiver with conformant behavior fixes #49
- Remove duplicate summary and param tags from GetNativeDataChannelHandle - Keeps the more complete documentation version
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.
Summary
Implement MediaDeviceInfo marshalling infrastructure and the EnumerateDevices() method to query native audio/video devices. This completes Phase 1 of Media Capture support.
Change Area (required)
WebRtcNet.Api/ managed-only behavior)Required Evidence (for behavioral/API changes)
1) W3C reference (required when applicable)
2) Google source reference (required when applicable)
webrtc/src/api/media_devices.handwebrtc/src/modules/video_capture/3) Intended observable behavior (required when applicable)
Behavior summary:
EnumerateDevices()returns a Task<IEnumerable> containing audio input/output and video input devicesWhy this behavior is correct: Matches W3C MediaDevices.enumerateDevices() contract while adapting to .NET task model and Windows COM/DirectShow device APIs
4) Divergence from Google reference (required if diverging)
Test Evidence (required)
Tests added/updated
Commands run + results
Change-area test gate confirmation
Documentation
Spec/Crosswalk Review (required for W3C-aligned behavior changes)
docs\standards\crosswalk\webrtcnet-api-to-spec.mddocs\standards\specs\index\spec-map.md.\scripts\update-spec-docs.ps1) when neededCloses #49