MediaCapture.CaptureDeviceExclusiveControlStatusChanged Event not triggered when legacy app accesses camera stream

Nick Sullivan 6 Reputation points
2020-02-27T20:42:40.703+00:00

CONTEXT: I would like to know when any other app grabs hold of the RGB camera stream, so I can stop streaming the IR stream of an RGB-IR device (IR LEDs cause an undesirable effect on the RGB stream).

The best way I could think was to monitor ExclusiveControl being grabbed on the RGB stream. This works with newer apps (e.g. Camera app), which presumably use the Windows.Media.Capture API. However, for legacy apps (e.g. AmCap, YouCam), this event only gets triggered when the app lets go of the stream (i.e. NOT when starting up). I assume these apps are using the UVC API to access it, hence the difference.

Can you confirm whether this is a bug or not, and when it might be resolved? If you have an alternative suggestion on how to monitor the RGB stream, please let me know!


In order to work past the fact that CaptureDeviceExclusiveControlStatusChanged() does not trigger on camera startup for legacy apps, I tried hooking into FormatChanged. This appears to work, but will only trigger if I have a MediaFrameReader instance streaming. Is this necessary? I feel I should be able to hook in and receive notifications without having to turn the camera on.

FYI: I have also filed this on the Feedback Hub, here: https://aka.ms/AA7iqpf
However, I did not get feedback previously when I have filed there.

Universal Windows Platform (UWP)
{count} vote

1 answer

Sort by: Most helpful
  1. James Dailey - MSFT 336 Reputation points Microsoft Employee
    2020-02-29T00:13:07.123+00:00

    Unfortunately the CaptureDeviceExclusiveControlStatusChanged event will not work the way you are expecting. This is due to the code we added in the creators update to allow for UVC devices to be shared between apps. This sharing is completely automatic in the UWP space but legacy apps are unaware of this functionality for backward compatibility reasons. In other words there is no default communication plumed between the UVC sharing service in UWP and legacy media APIs. So there is no way to guarantee that CaptureDeviceExclusiveControlStatusChanged will get triggered if the RGB camera is allocated by a legacy media API.

    1 person found this answer helpful.