MediaFrameSource MediaFrameSource MediaFrameSource MediaFrameSource Class

Definition

Represents a source of media frames, such as a color or infrared camera.

public : sealed class MediaFrameSource : IMediaFrameSource
public sealed class MediaFrameSource : IMediaFrameSource
Public NotInheritable Class MediaFrameSource Implements IMediaFrameSource
// This class does not provide a public constructor.
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

To get an instance of MediaFrameSource, you must first initialize the MediaCapture object with a MediaFrameSourceGroup that includes your desired media frame source. You do this by setting the SourceGroup of the MediaCaptureInitializationSettings object you pass into MediaCapture.InitializeAsync. Next, use the MediaFrameSourceInfo.Id property associated with the desired frame source as the key in the MediaCapture object's FrameSources dictionary to get an instance of the MediaFrameSource object.

For how-to guidance on using MediaFrameSource to capture frames, see Process media frames with MediaFrameReader.

Properties

Controller Controller Controller Controller

Gets the MediaFrameSourceController for the MediaFrameSource.

public : MediaFrameSourceController Controller { get; }
public MediaFrameSourceController Controller { get; }
Public ReadOnly Property Controller As MediaFrameSourceController
var mediaFrameSourceController = mediaFrameSource.controller;

Remarks

The MediaFrameSourceController object allows you to get and set properties of a media frame source and to get a VideoDeviceController, which provides camera controls such as exposure, focus, and zoom.

CurrentFormat CurrentFormat CurrentFormat CurrentFormat

Gets a value indicating the current frame format of the MediaFrameSource.

public : MediaFrameFormat CurrentFormat { get; }
public MediaFrameFormat CurrentFormat { get; }
Public ReadOnly Property CurrentFormat As MediaFrameFormat
var mediaFrameFormat = mediaFrameSource.currentFormat;
Value
MediaFrameFormat MediaFrameFormat MediaFrameFormat MediaFrameFormat

A value indicating the current frame format of the media frame source.

Remarks

To be notified when the current frame format of the media frame source changes, handle the FormatChanged event.

Info Info Info Info

Gets the MediaFrameSourceInfo object that provides information about the MediaFrameSource.

public : MediaFrameSourceInfo Info { get; }
public MediaFrameSourceInfo Info { get; }
Public ReadOnly Property Info As MediaFrameSourceInfo
var mediaFrameSourceInfo = mediaFrameSource.info;
Value
MediaFrameSourceInfo MediaFrameSourceInfo MediaFrameSourceInfo MediaFrameSourceInfo

The MediaFrameSourceInfo object that provides information about the media frame source.

SupportedFormats SupportedFormats SupportedFormats SupportedFormats

Gets a read-only list of MediaFrameFormat objects representing the frame formats supported by the MediaFrameSource.

public : IVectorView<MediaFrameFormat> SupportedFormats { get; }
public IReadOnlyList<MediaFrameFormat> SupportedFormats { get; }
Public ReadOnly Property SupportedFormats As IReadOnlyList<MediaFrameFormat>
var iReadOnlyList = mediaFrameSource.supportedFormats;
Value
IVectorView<MediaFrameFormat> IReadOnlyList<MediaFrameFormat> IReadOnlyList<MediaFrameFormat> IReadOnlyList<MediaFrameFormat>

A read-only list of frame formats supported by the media frame source.

Remarks

Get the list of supported frame formats for a media frame source by accessing the SupportedFormats property.

Get the current frame format of the media frame source by accessing the CurrentFormat property. Set the current frame format by calling SetFormatAsync.

Methods

SetFormatAsync(MediaFrameFormat) SetFormatAsync(MediaFrameFormat) SetFormatAsync(MediaFrameFormat) SetFormatAsync(MediaFrameFormat)

Asynchronously sets the frame format of the MediaFrameSource.

public : IAsyncAction SetFormatAsync(MediaFrameFormat format)
public IAsyncAction SetFormatAsync(MediaFrameFormat format)
Public Function SetFormatAsync(format As MediaFrameFormat) As IAsyncAction
var iAsyncAction = mediaFrameSource.setFormatAsync(format);
Parameters
format
MediaFrameFormat MediaFrameFormat MediaFrameFormat MediaFrameFormat

The new frame format for the media frame source.

Returns

Remarks

This method is an alternative to MediaCapture.SetEncodingPropertiesAsync, but unlike SetEncodingPropertiesAsync, this method can be used with any stream, not just the color camera preview, record, and photo capture streams.

Get the list of supported frame formats for a media frame source by accessing the SupportedFormats property.

Get the current frame format of the media frame source by accessing the CurrentFormat property.

TryGetCameraIntrinsics(MediaFrameFormat) TryGetCameraIntrinsics(MediaFrameFormat) TryGetCameraIntrinsics(MediaFrameFormat) TryGetCameraIntrinsics(MediaFrameFormat)

Attempts to retrieve the media frame source's camera intrinsics, which describe a camera's distortion model, for the specified MediaFrameFormat.

public : CameraIntrinsics TryGetCameraIntrinsics(MediaFrameFormat format)
public CameraIntrinsics TryGetCameraIntrinsics(MediaFrameFormat format)
Public Function TryGetCameraIntrinsics(format As MediaFrameFormat) As CameraIntrinsics
var cameraIntrinsics = mediaFrameSource.tryGetCameraIntrinsics(format);
Parameters
format
MediaFrameFormat MediaFrameFormat MediaFrameFormat MediaFrameFormat

The media frame format for which the camera intrinsics should be retrieved.

Returns

An object representing the camera intrinsics for the frame source, if they can be retrieved; otherwise, null.

Events

FormatChanged FormatChanged FormatChanged FormatChanged

Occurs when the current frame format of the MediaFrameSource changes.

public : event TypedEventHandler FormatChanged<MediaFrameSource,  object>
public event TypedEventHandler FormatChanged<MediaFrameSource,  object>
Public Event TypedEventHandler FormatChanged( Of ( Of MediaFrameSource ), ( Of  object ))
function onFormatChanged(eventArgs){/* Your code */}


mediaFrameSource.addEventListener("formatChanged", onFormatChanged);
mediaFrameSource.removeEventListener("formatChanged", onFormatChanged);

Remarks

Get the current frame format of the media frame source by accessing the CurrentFormat property.

See Also