Skip to content

Commit

Permalink
more notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Nielsen committed Feb 2, 2024
1 parent 48fef23 commit 0bc8d24
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/WinUIEx/CaptureElement.Rendering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace WinUIEx
// https://learn.microsoft.com/en-us/windows/win32/api/mfidl/nn-mfidl-imfmediasink
// https://github.com/nickluo/CameraCapture/
// https://github.com/castorix/WinUI3_DirectShow_Capture
// https://github.com/TripleSM/MediaFrameCapture/blob/main/WinUI3MediaFrameCapture/WinUI3MediaFrameCapture/MainWindow.xaml.cs - Framereader, not sink based
// https://github.com/mmaitre314/MediaCaptureWPF/blob/6b42e0c288c3ef290b47f1267b37ac7488f60483/MediaCaptureWPF/CapturePreview.cs#L41
public partial class CaptureElement
{
private static readonly Guid IID_IDXGIFactory2_Guid = new Guid("50c83a1c-e072-4c48-87b0-3630fa36a6d0");
Expand Down
13 changes: 11 additions & 2 deletions src/WinUIExSample/Pages/Home.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,18 @@ private async void LoadWebcam()
{
var allVideoDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
DeviceInformation cameraDevice = allVideoDevices.FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front) ?? allVideoDevices.FirstOrDefault();


var frameSourceGroups = await Windows.Media.Capture.Frames.MediaFrameSourceGroup.FindAllAsync();
var selectedFrameSourceGroup = frameSourceGroups.First();
mediaCapture = new Windows.Media.Capture.MediaCapture();
var settings = new MediaCaptureInitializationSettings { VideoDeviceId = cameraDevice.Id };
var settings = new MediaCaptureInitializationSettings
{
VideoDeviceId = cameraDevice.Id,
SourceGroup = selectedFrameSourceGroup,
SharingMode = MediaCaptureSharingMode.SharedReadOnly,
StreamingCaptureMode = StreamingCaptureMode.Video,
MemoryPreference = MediaCaptureMemoryPreference.Cpu
};
await mediaCapture.InitializeAsync(settings);
elm.Source = mediaCapture;
//await mediaCapture.StartPreviewAsync();
Expand Down

2 comments on commit 0bc8d24

@hhaaii
Copy link

@hhaaii hhaaii commented on 0bc8d24 May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotMorten I tried to uncomment the StartPreviewAsync line, but ran into the "Preview sink not set" exception. I assume there is still extra work yet to be done to support preview?

@dotMorten
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there's a reason it's in a branch ;-). My guess is there's some secret sauce UWP uses that we can't get at.

Please sign in to comment.