C# Class ScreenToGif.Webcam.DirectX.CaptureWebcam

Gets the video output of a webcam or other video device.
Inheritance: EditStreaming.ISampleGrabberCB, IDisposable
显示文件 Open project: dbremner/ScreenToGif Class Usage Examples

Protected Properties

Property Type Description
ActualGraphState GraphState
CaptureGraphBuilder ExtendStreaming.ICaptureGraphBuilder2
GraphBuilder ExtendStreaming.IGraphBuilder
IsPreviewRendered bool
MediaControl ControlStreaming.IMediaControl
SampGrabber EditStreaming.ISampleGrabber
VideoCompressor Filter
VideoCompressorFilter CoreStreaming.IBaseFilter
VideoDeviceFilter CoreStreaming.IBaseFilter
VideoStreamConfig ExtendStreaming.IAMStreamConfig
VideoWindow ControlStreaming.IVideoWindow
WantPreviewRendered bool

Public Methods

Method Description
BufferCB ( double SampleTime, IntPtr pBuffer, int BufferLen ) : int
CaptureWebcam ( Filter videoDevice ) : System

Default constructor of the Capture class.

Dispose ( ) : void

Closes and cleans the video previewing.

GetFrame ( ) : Bitmap

Gets the current frame from the buffer.

PrepareCapture ( ) : void

Prepares the capture of frames.

SampleCB ( double SampleTime, CoreStreaming pSample ) : int
StartPreview ( ) : void

Starts the video preview from the video source.

StopPreview ( ) : void

Stops the video previewing.

Protected Methods

Method Description
CreateGraph ( ) : void

Create a new filter graph and add filters (devices, compressors, misc), but leave the filters unconnected. Call RenderGraph() to connect the filters.

DerenderGraph ( ) : void

Disconnect and remove all filters except the device and compressor filters. This is the opposite of renderGraph(). Soem properties such as FrameRate can only be set when the device output pins are not connected.

DestroyGraph ( ) : void

Completely tear down a filter graph and release all associated resources.

OnPreviewWindowResize ( object sender, EventArgs e ) : void

Resize the preview when the PreviewWindow is resized

RemoveDownstream ( CoreStreaming filter, bool removeFirstFilter ) : void

Removes all filters downstream from a filter from the graph. This is called only by DerenderGraph() to remove everything from the graph except the devices and compressors. The parameter "removeFirstFilter" is used to keep a compressor (that should be immediately downstream of the device) if one is begin used.

RenderGraph ( ) : void

Connects the filters of a previously created graph (created by CreateGraph()). Once rendered the graph is ready to be used. This method may also destroy streams if we have streams we no longer want.

StartPreviewIfNeeded ( ) : void

Setup and start the preview window if the user has requested it (by setting PreviewWindow).

Method Details

BufferCB() public method

public BufferCB ( double SampleTime, IntPtr pBuffer, int BufferLen ) : int
SampleTime double
pBuffer System.IntPtr
BufferLen int
return int

CaptureWebcam() public method

Default constructor of the Capture class.
If no video device is provided.
public CaptureWebcam ( Filter videoDevice ) : System
videoDevice Filter The video device to be the source.
return System

CreateGraph() protected method

Create a new filter graph and add filters (devices, compressors, misc), but leave the filters unconnected. Call RenderGraph() to connect the filters.
protected CreateGraph ( ) : void
return void

DerenderGraph() protected method

Disconnect and remove all filters except the device and compressor filters. This is the opposite of renderGraph(). Soem properties such as FrameRate can only be set when the device output pins are not connected.
protected DerenderGraph ( ) : void
return void

DestroyGraph() protected method

Completely tear down a filter graph and release all associated resources.
protected DestroyGraph ( ) : void
return void

Dispose() public method

Closes and cleans the video previewing.
public Dispose ( ) : void
return void

GetFrame() public method

Gets the current frame from the buffer.
public GetFrame ( ) : Bitmap
return System.Drawing.Bitmap

OnPreviewWindowResize() protected method

Resize the preview when the PreviewWindow is resized
protected OnPreviewWindowResize ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void

PrepareCapture() public method

Prepares the capture of frames.
public PrepareCapture ( ) : void
return void

RemoveDownstream() protected method

Removes all filters downstream from a filter from the graph. This is called only by DerenderGraph() to remove everything from the graph except the devices and compressors. The parameter "removeFirstFilter" is used to keep a compressor (that should be immediately downstream of the device) if one is begin used.
protected RemoveDownstream ( CoreStreaming filter, bool removeFirstFilter ) : void
filter CoreStreaming
removeFirstFilter bool
return void

RenderGraph() protected method

Connects the filters of a previously created graph (created by CreateGraph()). Once rendered the graph is ready to be used. This method may also destroy streams if we have streams we no longer want.
protected RenderGraph ( ) : void
return void

SampleCB() public method

public SampleCB ( double SampleTime, CoreStreaming pSample ) : int
SampleTime double
pSample CoreStreaming
return int

StartPreview() public method

Starts the video preview from the video source.
public StartPreview ( ) : void
return void

StartPreviewIfNeeded() protected method

Setup and start the preview window if the user has requested it (by setting PreviewWindow).
protected StartPreviewIfNeeded ( ) : void
return void

StopPreview() public method

Stops the video previewing.
public StopPreview ( ) : void
return void

Property Details

ActualGraphState protected_oe property

State of the internal filter graph.
protected GraphState ActualGraphState
return GraphState

CaptureGraphBuilder protected_oe property

DShow Filter: building graphs for capturing video.
protected ExtendStreaming.ICaptureGraphBuilder2 CaptureGraphBuilder
return ExtendStreaming.ICaptureGraphBuilder2

GraphBuilder protected_oe property

DShow Filter: Graph builder.
protected ExtendStreaming.IGraphBuilder GraphBuilder
return ExtendStreaming.IGraphBuilder

IsPreviewRendered protected_oe property

When graphState==Rendered, have we rendered the preview stream?
protected bool IsPreviewRendered
return bool

MediaControl protected_oe property

DShow Filter: Start/Stop the filter graph -> copy of graphBuilder.
protected ControlStreaming.IMediaControl MediaControl
return ControlStreaming.IMediaControl

SampGrabber protected_oe property

protected EditStreaming.ISampleGrabber SampGrabber
return EditStreaming.ISampleGrabber

VideoCompressor protected_oe property

Property Backer: Video compression filter.
protected Filter,ScreenToGif.Webcam.DirectX VideoCompressor
return Filter

VideoCompressorFilter protected_oe property

DShow Filter: selected video compressor.
protected CoreStreaming.IBaseFilter VideoCompressorFilter
return CoreStreaming.IBaseFilter

VideoDeviceFilter protected_oe property

DShow Filter: selected video device.
protected CoreStreaming.IBaseFilter VideoDeviceFilter
return CoreStreaming.IBaseFilter

VideoStreamConfig protected_oe property

DShow Filter: configure frame rate, size.
protected ExtendStreaming.IAMStreamConfig VideoStreamConfig
return ExtendStreaming.IAMStreamConfig

VideoWindow protected_oe property

DShow Filter: Control preview window -> copy of graphBuilder.
protected ControlStreaming.IVideoWindow VideoWindow
return ControlStreaming.IVideoWindow

WantPreviewRendered protected_oe property

Do we need the preview stream rendered (VideoDevice and PreviewWindow != null)
protected bool WantPreviewRendered
return bool