MultiSourceMediaFrameReference MultiSourceMediaFrameReference MultiSourceMediaFrameReference MultiSourceMediaFrameReference Class

Definition

A wrapper class that provides access to time-correlated frames obtained from one or more MediaFrameSource objects. Call TryGetFrameReferenceBySourceId to get the MediaFrameReference representing a frame from a particular media frame source.

public : sealed class MultiSourceMediaFrameReference : IClosable, IMultiSourceMediaFrameReferencepublic sealed class MultiSourceMediaFrameReference : IDisposable, IMultiSourceMediaFrameReferencePublic NotInheritable Class MultiSourceMediaFrameReference Implements IDisposable, IMultiSourceMediaFrameReference// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

To get an instance of MultiSourceMediaFrameReference from a media frame source, create a MultiSourceMediaFrameReader by calling CreateMultiSourceFrameReaderAsync on a MediaCapture object, passing in the MediaFrameSource objects from which you want to read. After starting by calling StartAsync, call TryAcquireLatestFrame to get a MultiSourceMediaFrameReference which contains the latest correlated frames from the media frame sources.

Get the time-correlated media frame from a particular media frame source by calling MultiSourceMediaFrameReference.TryGetFrameReferenceBySourceId and passing in the value of the MediaFrameSourceInfo.Id property for the desired media frame source.

Each MultiSourceMediaFrameReader maintains a circular buffer of MediaFrameReference objects obtained from MultiSourceMediaFrameReference.TryGetFrameReferenceBySourceId. After all of the MediaFrameReference objects in the buffer have been used, subsequent calls to TryAcquireLatestFrame will cause the system to call Close (or Dispose in C#) on the oldest buffer object in order to reuse it. Once the object has been disposed, you can no longer use it to access the frame data. For this reason, you should not store the MediaFrameReference object longer than you actually need to process the frame. If your app scenario requires you to keep a reference to the data for longer, you should use one of the APIs provided to get the underlying data. These methods include:

Important

If you access the SoftwareBitmap or Direct3DSurface objects provided by the VideoMediaFrame property of a MediaFrameReference, the system creates a strong reference to these objects, which means that they will not be disposed when you call Dispose on the containing MediaFrameReference. You must explicitly call the Dispose method of the SoftwareBitmap or Direct3DSurface directly for the objects to be immediately disposed. Otherwise, the garbage collector will eventually free the memory for these objects, but you can't know when this will occur, and if the number of allocated bitmaps or surfaces exceeds the maximum amount allowed by the system, the flow of new frames will stop.

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

Methods

Close() Close() Close() Close()

Disposes of the object and associated resources.

public : void Close()This member is not implemented in C#This member is not implemented in VB.Net// You can use this method in JavaScript.

Remarks

The Close method is used by Universal Windows app using JavaScript. For apps written using the .NET Framework 4.5 in C# and VB.NET, the Close method is exposed as the Dispose() method on the MediaFrameReference object. For apps written in C++, the Close method will be called when using the delete keyword on the object.

Dispose() Dispose() Dispose() Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

This member is not implemented in C++void Dispose()Sub Disposevoid Dispose()

TryGetFrameReferenceBySourceId(String) TryGetFrameReferenceBySourceId(String) TryGetFrameReferenceBySourceId(String) TryGetFrameReferenceBySourceId(String)

Attempts to get a time-correlated MediaFrameReference for the specified media frame source.

public : MediaFrameReference TryGetFrameReferenceBySourceId(PlatForm::String sourceId)public MediaFrameReference TryGetFrameReferenceBySourceId(String sourceId)Public Function TryGetFrameReferenceBySourceId(sourceId As String) As MediaFrameReference// You can use this method in JavaScript.
Parameters
sourceId
PlatForm::String String String String

The Id property of the MediaFrameSourceInfo object representing the media frame source from which a frame reference should be retreived.

Returns

See Also