Skip to content

Implement media track capabilities and interop marshaling#70

Merged
General-Fault merged 3 commits into
mainfrom
feature/50-media-track-capabilities
Jun 18, 2026
Merged

Implement media track capabilities and interop marshaling#70
General-Fault merged 3 commits into
mainfrom
feature/50-media-track-capabilities

Conversation

@General-Fault

Copy link
Copy Markdown
Owner

Summary

Implements media track capability/settings parity across managed and interop layers, including marshaling updates and InputDeviceInfo.GetCapabilities() support. Also adds diagnostics around capability queries and expands managed/native tests for the new capability and constraint behavior.

Change Area (required)

  • API-only managed change (WebRtcNet.Api / managed-only behavior)
  • Interop / marshaling / native-boundary change
  • Docs/infra only (no behavior change)

Required Evidence (for behavioral/API changes)

1) W3C reference (required when applicable)

2) Google source reference (required when applicable)

Provide pinned references: path + revision context (commit SHA or branch/tag).

  • Source path(s):
    • api/media_stream_interface.h
    • api/media_stream_track.h
    • modules/audio_processing/include/audio_processing.h
  • Revision context (SHA/branch/tag):
    • WebRTC branch: branch-heads/7778 (repo artifact baseline used by this repository)
  • Notes on alignment:
    • Marshaling and shape decisions align to libwebrtc capability/settings model while preserving .NET API naming and nullable semantics.

3) Intended observable behavior (required when applicable)

Describe externally observable behavior (state transitions, event ordering, timing, errors).

  • Behavior summary:
    • Managed MediaTrackCapabilities/MediaTrackSettings and constraints now map sequence/scalar/nullability behavior consistently across managed and interop boundaries.
    • InputDeviceInfo.GetCapabilities() now returns populated capability information through interop rather than a placeholder/non-functional path.
    • Capability-query failures now emit diagnostics with HRESULT details.
  • Why this behavior is correct:
    • It matches Media Capture dictionary semantics and the project’s W3C-first API conformance goals for observable API shape and values.

4) Divergence from Google reference (required if diverging)

  • No divergence
  • Divergence exists (explain below)
  • Divergence details (what differs, why .NET/runtime needs require it, and which web-observable semantics are preserved):
    • N/A

Test Evidence (required)

Tests added/updated

  • WebRtcInterop.UnitTests/Marshaling/MarshalMediaTests.cpp
  • WebRtcNet.Api.UnitTests/MediaTrackConstraintTests.cs
  • WebRtcNet.Api.UnitTests/MediaTrackUnsignedNumericTypesTests.cs

Commands run + results

  • dotnet test WebRtcNet.Api.UnitTests\WebRtcNet.Api.UnitTests.csproj -> Passed (110/110 on net10.0-windows, 110/110 on net48)
  • "C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\amd64\MSBuild.exe" WebRtcInterop.UnitTests\WebRtcInterop.UnitTests.vcxproj -p:Configuration=Debug -p:Platform=x64 -nologo -> Succeeded
  • WebRtcInterop.UnitTests\bin\x64\Debug\v4.8\WebRtcInterop.UnitTests.exe -> Passed (58/58)

Change-area test gate confirmation

  • API-only managed change: ran managed NUnit tests
  • Interop/native-boundary change: ran interop unit tests (when environment available)
  • Required environment unavailable (explain below)

If environment unavailable (required when checked above)

  • Missing environment/dependency:
  • What was run instead:
  • Residual risk:

Documentation

  • I updated documentation for externally visible behavior changes.
  • No external docs impact.

Spec/Crosswalk Review (required for W3C-aligned behavior changes)

  • Reviewed docs\standards\crosswalk\webrtcnet-api-to-spec.md
  • Reviewed docs\standards\specs\index\spec-map.md
  • Refreshed/checked local spec snapshots (.\scripts\update-spec-docs.ps1) when needed

General-Fault and others added 3 commits June 16, 2026 12:14
…marshalling

- Add VideoFacingModeValue and VideoResizeModeValue wrapper types (VideoModeValues.cs)
  for extensible string-domain constraints; replace raw VideoFacingModes/VideoResizeModes
  enums in MediaTrackCapabilities, MediaTrackSettings, and MediaTrackConstraintSet
- Implement full constraint marshalling in MarshalMediaConstraints.h: native structs
  (MediaTrackConstraintSet, MediaTrackConstraints) and marshal_as<> specializations
  covering all constrainable properties
- Expand MarshalMedia.h with VideoFacingModeValue and VideoResizeModeValue marshal_as<>
  specializations; refactor existing media marshalling
- Remove reflection-based Create() calls in MediaStreamTrack.cpp; call
  MediaTrackCapabilities::Create and MediaTrackSettings::Create directly via
  InternalsVisibleTo
- Add/expand unit tests for constraint types and unsigned numeric constraint marshalling

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add Func<MediaTrackCapabilities>? delegate to InputDeviceInfo; set at
  device enumeration time, invoked lazily in GetCapabilities()
- VideoCapabilityQuery: DirectShow width/height/frameRate/aspectRatio,
  ResizeMode, FacingMode (via Media Foundation); split to own files
- AudioCapabilityQuery: WASAPI sampleRate/sampleSize/channelCount;
  hardcode autoGainControl and noiseSuppression as [true, false] per
  WebRTC APM (mirrors Blink input_device_info.cc);
  echoCancellation reports [Software, false] always -- System mode
  added later once WASAPI device effects are queried
- Remove reflection from MediaStreamTrack.cpp; use direct Create() calls
- MarshalMediaTrackCapabilities.h: remove stale DoubleRange/IntRange specs
- MediaTrackCapabilities.Create/CreateIdentity made public for C++/CLI
  ([EditorBrowsable(Never)] hides from IDE); same for MediaTrackSettings
- Rename EchoCancellationMode: All/RemoteOnly -> System/Software
  'software' = WebRTC AEC3 in app layer (raw WASAPI, always available)
  'system'   = OS/driver AEC (default WASAPI mode, device-dependent)
  boolean true = attempt System first, fall back to Software
- Update marshaling maps, C++/CLI tests, and managed tests accordingly
- Add unit tests for delegate and fallback paths (118 tests pass)

Closes #59
Related to #58 (GetSupportedConstraints -- now has data to aggregate)
Related to #51 and #68 (capability data is a prerequisite for both)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- AudioCapabilityQuery: replace silent FAILED() checks with
  InteropHResult::LogIfFailed for COM init, device lookup, IAudioClient
  activation, and GetMixFormat; add trace log with mix format details
- VideoCapabilityQuery: replace silent FAILED() checks with
  InteropHResult::LogIfFailed for MFStartup, MFCreateAttributes,
  SetGUID, MFEnumDeviceSources, and symbolic link lookup; add trace
  log with DirectShow capability count and facing mode result
- Add WebRtcLogEventId.AudioCapabilityQueryCompleted (2004) and
  VideoCapabilityQueryCompleted (2005) for structured log filtering
- Restore accidentally removed #include <winerror.h> in InteropHResult.h
- EchoCancellationMode: All/RemoteOnly -> System/Software; update
  serialized strings ('system'/'software'), marshaling maps, and tests
- EchoCancellationValue(bool): document that true attempts System first,
  falls back to Software

Closes #50

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@General-Fault General-Fault merged commit 5f7d8d4 into main Jun 18, 2026
1 check failed
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

Successfully merging this pull request may close these issues.

1 participant