VideoSink Class

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Exposes the capture graph for video devices. Derive from this class to receive video information and to obtain the capture graph through VideoSink.CaptureSource.

Inheritance Hierarchy

System.Object
  System.Windows.Media.VideoSink

Namespace:  System.Windows.Media
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public MustInherit Class VideoSink
public abstract class VideoSink

The VideoSink type exposes the following members.

Constructors

  Name Description
Public methodSupported by Silverlight for Windows Phone VideoSink Initializes a new instance of the VideoSink class.

Top

Properties

  Name Description
Public propertySupported by Silverlight for Windows Phone AllocationMode Specifies how the camera video buffer is maintained on Silverlight for Windows Phone.
Public propertySupported by Silverlight for Windows Phone CaptureSource Gets or sets a capture source that is associated with this VideoSink.

Top

Methods

  Name Description
Public methodSupported by Silverlight for Windows Phone Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone Finalize Frees resources that are used by the VideoSink class. (Overrides Object.Finalize().)
Public methodSupported by Silverlight for Windows Phone GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public methodSupported by Silverlight for Windows Phone GetType Gets the Type of the current instance. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodSupported by Silverlight for Windows Phone OnCaptureStarted When overridden in a derived class, is invoked when a video device starts capturing video data.
Protected methodSupported by Silverlight for Windows Phone OnCaptureStopped When overridden in a derived class, is invoked when a video device stops capturing video data.
Protected methodSupported by Silverlight for Windows Phone OnFormatChange When overridden in a derived class, is invoked when a video device reports a video format change.
Protected methodSupported by Silverlight for Windows Phone OnSample When overridden in a derived class, is invoked when a video device captures a complete video sample.
Public methodSupported by Silverlight for Windows Phone ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Remarks

To obtain video information from a video input device in Silverlight, you derive a custom video sink from VideoSink, which exposes several virtual callbacks:

When you derive from VideoSink, you must provide overrides for the callbacks in order to compile. However, you can have a functional VideoSink that has empty callback overrides and can use only the methods of the CaptureSource from VideoSink.CaptureSource. For more information, see CaptureSource.

Implementing VideoSink Overrides

To work with raw video from a capture graph, you must override OnSample and provide an implementation in your video sink that converts the sampleData to your destination format. You usually use the numbers that are obtained from the VideoFormat properties to convert a bit stream to a supported video format. A typical logic design for sample processing uses a series of nested loops and attempts type matches for appropriate data types for frames and pixels.

If you provide a meaningful override of OnSample, you should also provide a meaningful override of OnFormatChange. The information for VideoFormat that is associated with this sink might change between the time that the device was first connected and the time of capture. Handling OnFormatChange is the only way that you know the true format information at run time.

OnCaptureStarted and OnCaptureStopped are useful as UI change notifications to advise users that audio is currently being captured or that capture has stopped. You can also use the notifications as sentinels to block certain other actions in your application while the capture is ongoing.

Platform Notes

Silverlight for Windows Phone Silverlight for Windows Phone

 It is recommended to not use VideoSink (with ARBG format) if you intend to save the video to a file by collecting video data to a buffer and writing your own encoder. Use FileSink instead.

If you want to save video capture to an MP4 file in order to play back at a later time, it is recommended to use FileSink.

Version Information

Silverlight

Supported in: 5, 4

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference