本文整理汇总了C#中GraphState类的典型用法代码示例。如果您正苦于以下问题:C# GraphState类的具体用法?C# GraphState怎么用?C# GraphState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphState类属于命名空间,在下文中一共展示了GraphState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HasCorrectFinalStates
public void HasCorrectFinalStates()
{
var m1Start = new GraphState () {
StateNumber = 0,
IsFinal = true
};
var m2Start = new GraphState () {
StateNumber = 1,
IsFinal = true
};
var m1 = new Graph () {
StartState = m1Start
};
var m2 = new Graph () {
StartState = m2Start
};
var ndfa = m1.Concat (m2);
var finals = ndfa.FindFinalStates (ndfa.StartState);
finals.Count.Should ().Be (1);
finals [0].Should ().Be (m1Start);
}
开发者ID:tvand7093,项目名称:Xpressional,代码行数:25,代码来源:GraphTests.cs
示例2: CreatesCorrectConnection
public void CreatesCorrectConnection()
{
var m1Start = new GraphState () {
StateNumber = 0,
IsFinal = true
};
var m2Start = new GraphState () {
StateNumber = 1,
IsFinal = true
};
var m1 = new Graph () {
StartState = m1Start
};
var m2 = new Graph () {
StartState = m2Start
};
var ndfa = m1.Concat (m2);
ndfa.StartState.Out[0].Start.Should ().Be (m2Start);
ndfa.StartState.Out[0].End.Should ().Be (m1Start);
ndfa.StartState.Out[0].ConnectedBy.Letter.Should ().Be (Word.Epsilon.Letter);
ndfa.StartState.Out[0].ConnectedBy.Mapping.Should ().Be (Word.Epsilon.Mapping);
}
开发者ID:tvand7093,项目名称:Xpressional,代码行数:27,代码来源:GraphTests.cs
示例3: PrintStatesOutputs
/// <summary>
/// Recursive call to loop over states and print them.
/// </summary>
/// <param name="currentState">Current state.</param>
/// <param name="visited">List of states visited.</param>
/// <param name="output">List of state outputs.</param>
void PrintStatesOutputs(GraphState currentState,
List<GraphState> visited, List<string> output)
{
//add this node to the visited list
visited.Add (currentState);
//for each connection, recurse and add the output to our master list.
foreach (var state in currentState.Out) {
//add the connection friendly string to the master list.
output.Add(state.ToString());
if (!visited.Contains (state.End)) {
//not seen, so keep going.
PrintStatesOutputs(state.End, visited, output);
}
}
}
开发者ID:tvand7093,项目名称:Xpressional,代码行数:22,代码来源:OutputManager.cs
示例4: CreatesOneConnection
public void CreatesOneConnection()
{
var m1Start = new GraphState () {
StateNumber = 0,
IsFinal = true
};
var m2Start = new GraphState () {
StateNumber = 1,
IsFinal = true
};
var m1 = new Graph () {
StartState = m1Start
};
var m2 = new Graph () {
StartState = m2Start
};
var ndfa = m1.Concat (m2);
ndfa.StartState.Out.Count.Should ().Be (1);
}
开发者ID:tvand7093,项目名称:Xpressional,代码行数:23,代码来源:GraphTests.cs
示例5: renderGraph
//.........这里部分代码省略.........
this.InitVideoRenderer();
this.AddDeInterlaceFilter();
// When capture pin is used, preview works immediately,
// however this conflicts with file saving.
// An alternative is to use VMR9
cat = PinCategory.Preview;
med = MediaType.Video;
// #if NEWCODE
if(this.InitSampleGrabber())
{
Debug.WriteLine("SampleGrabber added to graph.");
#if DSHOWNET
hr = captureGraphBuilder.RenderStream(ref cat, ref med, videoDeviceFilter, this.baseGrabFlt, this.videoRendererFilter);
#else
hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), videoDeviceFilter, this.baseGrabFlt, this.videoRendererFilter);
#endif
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
else
// #endif NEWCODE
{
#if DSHOWNET
hr = captureGraphBuilder.RenderStream(ref cat, ref med, videoDeviceFilter, null, this.videoRendererFilter);
#else
hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), videoDeviceFilter, null, this.videoRendererFilter);
#endif
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
// Special option to enable rendering audio via PCI bus
if((this.AudioViaPci)&&(audioDeviceFilter != null))
{
cat = PinCategory.Preview;
med = MediaType.Audio;
#if DSHOWNET
hr = captureGraphBuilder.RenderStream( ref cat, ref med, audioDeviceFilter, null, null );
#else
hr = captureGraphBuilder.RenderStream(DsGuid.FromGuid(cat), DsGuid.FromGuid(med), audioDeviceFilter, null, null);
#endif
if( hr < 0 )
{
Marshal.ThrowExceptionForHR( hr );
}
}
else
if( (this.AudioViaPci)&&
(this.audioDeviceFilter == null)&&(this.videoDeviceFilter != null) )
{
cat = PinCategory.Preview;
med = MediaType.Audio;
#if DSHOWNET
hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, null, null );
#else
hr = captureGraphBuilder.RenderStream(cat, med, videoDeviceFilter, null, null);
#endif
if( hr < 0 )
{
Marshal.ThrowExceptionForHR( hr );
}
}
// Get the IVideoWindow interface
videoWindow = (IVideoWindow) graphBuilder;
// Set the video window to be a child of the main window
hr = videoWindow.put_Owner( previewWindow.Handle );
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
// Set video window style
#if DSHOWNET
hr = videoWindow.put_WindowStyle( WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
#else
hr = videoWindow.put_WindowStyle(WindowStyle.Child | WindowStyle.ClipChildren | WindowStyle.ClipSiblings);
#endif
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
// Position video window in client rect of owner window
previewWindow.Resize += new EventHandler( onPreviewWindowResize );
onPreviewWindowResize( this, null );
// Make the video window visible, now that it is properly positioned
#if DSHOWNET
hr = videoWindow.put_Visible( DsHlp.OATRUE );
#else
hr = videoWindow.put_Visible( OABool.True );
#endif
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
isPreviewRendered = true;
didSomething = true;
// #if NEWCODE
SetMediaSampleGrabber();
// #endif NEWCODE
}
if ( didSomething )
graphState = GraphState.Rendered;
}
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:101,代码来源:Capture.cs
示例6: Stop
/// <summary>
/// Stop the current capture capture. If there is no
/// current capture, this method will succeed.
/// </summary>
public void Stop()
{
// Stop the graph if it is running
// If we have a preview running we should only stop the
// capture stream. However, if we have a preview stream
// we need to re-render the graph anyways because we
// need to get rid of the capture stream. To re-render
// we need to stop the entire graph
if ( mediaControl != null )
{
mediaControl.Stop();
}
// Config is true when the parametres of the device are to be changed
wantCaptureRendered = false;
wantPreviewRendered = true;
// Update the state
if ( graphState == GraphState.Capturing )
{
graphState = GraphState.Rendered;
if ( CaptureComplete != null )
CaptureComplete( this, null );
}
// Para que cuando volvamos a capturar frames no haya problemas
firstFrame = true;
// So we destroy the capture stream IF
// we need a preview stream. If we don't
// this will leave the graph as it is.
renderStream = false;
try { renderGraph(); }
catch {}
try { startPreviewIfNeeded(); }
catch {}
}
开发者ID:iManbot,项目名称:monoslam,代码行数:43,代码来源:Capture.cs
示例7: CloseInterfaces
// Shut down capture
private void CloseInterfaces()
{
int hr;
lock (this)
{
if (m_State != GraphState.Exiting)
{
m_State = GraphState.Exiting;
// Release the thread (if the thread was started)
if (m_mre != null)
{
m_mre.Set();
}
}
if (m_mediaCtrl != null)
{
// Stop the graph
hr = m_mediaCtrl.Stop();
m_mediaCtrl = null;
}
if (m_sampGrabber != null)
{
Marshal.ReleaseComObject(m_sampGrabber);
m_sampGrabber = null;
}
if (m_FilterGraph != null)
{
Marshal.ReleaseComObject(m_FilterGraph);
m_FilterGraph = null;
}
}
GC.Collect();
}
开发者ID:hpavlov,项目名称:occurec,代码行数:39,代码来源:DxPlayer.cs
示例8: Start
// start playing
public void Start()
{
// If we aren't already playing (or shutting down)
if (m_State == GraphState.Stopped || m_State == GraphState.Paused)
{
m_FrameCounter = 0;
int hr = m_mediaCtrl.Run();
DsError.ThrowExceptionForHR(hr);
m_State = GraphState.Running;
}
}
开发者ID:hpavlov,项目名称:occurec,代码行数:14,代码来源:DxPlayer.cs
示例9: Dispose
// Release everything.
public void Dispose()
{
CloseInterfaces();
m_State = GraphState.Exiting;
}
开发者ID:hpavlov,项目名称:occurec,代码行数:6,代码来源:DxPlayer.cs
示例10: Resume
public void Resume()
{
IMediaControl mediaCtrl = m_FilterGraph as IMediaControl;
int hr = mediaCtrl.Run();
DsError.ThrowExceptionForHR(hr);
m_State = GraphState.Running;
}
开发者ID:sachindeshpande,项目名称:TRapperProject,代码行数:9,代码来源:Capture.cs
示例11: Dispose
/// <summary> release everything. </summary>
public void Dispose()
{
ConsoleLogger.logMessage("In Dispose");
m_State = GraphState.Stopped;
CloseInterfaces();
if (bitmapOverlay != null)
bitmapOverlay.Dispose();
if (fontOverlay != null)
fontOverlay.Dispose();
if (transparentBrush != null)
transparentBrush.Dispose();
if (transparentFont != null)
transparentFont.Dispose();
}
开发者ID:sachindeshpande,项目名称:TRapperProject,代码行数:16,代码来源:Capture.cs
示例12: createGraph
protected void createGraph()
{
if ((this.videoDevice == null) && (this.audioDevice == null))
{
throw new ArgumentException("The video and/or audio device have not been set. Please set one or both to valid capture devices.\n");
}
if (this.graphState < GraphState.Created)
{
object obj2;
GC.Collect();
this.graphBuilder = (IGraphBuilder) Activator.CreateInstance(System.Type.GetTypeFromCLSID(Clsid.FilterGraph, true));
Guid clsid = Clsid.CaptureGraphBuilder2;
Guid gUID = typeof(ICaptureGraphBuilder2).GUID;
this.captureGraphBuilder = (ICaptureGraphBuilder2) DsBugWO.CreateDsInstance(ref clsid, ref gUID);
int errorCode = this.captureGraphBuilder.SetFiltergraph(this.graphBuilder);
if (errorCode < 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
if (this.VideoDevice != null)
{
this.videoDeviceFilter = (IBaseFilter) Marshal.BindToMoniker(this.VideoDevice.MonikerString);
errorCode = this.graphBuilder.AddFilter(this.videoDeviceFilter, "Video Capture Device");
if (errorCode < 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
}
if (this.AudioDevice != null)
{
this.audioDeviceFilter = (IBaseFilter) Marshal.BindToMoniker(this.AudioDevice.MonikerString);
errorCode = this.graphBuilder.AddFilter(this.audioDeviceFilter, "Audio Capture Device");
if (errorCode < 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
}
if (this.VideoCompressor != null)
{
this.videoCompressorFilter = (IBaseFilter) Marshal.BindToMoniker(this.VideoCompressor.MonikerString);
errorCode = this.graphBuilder.AddFilter(this.videoCompressorFilter, "Video Compressor");
if (errorCode < 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
}
if (this.AudioCompressor != null)
{
this.audioCompressorFilter = (IBaseFilter) Marshal.BindToMoniker(this.AudioCompressor.MonikerString);
errorCode = this.graphBuilder.AddFilter(this.audioCompressorFilter, "Audio Compressor");
if (errorCode < 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
}
Guid capture = PinCategory.Capture;
Guid interleaved = MediaType.Interleaved;
Guid riid = typeof(IAMStreamConfig).GUID;
if (this.captureGraphBuilder.FindInterface(ref capture, ref interleaved, this.videoDeviceFilter, ref riid, out obj2) != 0)
{
interleaved = MediaType.Video;
if (this.captureGraphBuilder.FindInterface(ref capture, ref interleaved, this.videoDeviceFilter, ref riid, out obj2) != 0)
{
obj2 = null;
}
}
this.videoStreamConfig = obj2 as IAMStreamConfig;
obj2 = null;
capture = PinCategory.Capture;
interleaved = MediaType.Audio;
riid = typeof(IAMStreamConfig).GUID;
if (this.captureGraphBuilder.FindInterface(ref capture, ref interleaved, this.audioDeviceFilter, ref riid, out obj2) != 0)
{
obj2 = null;
}
this.audioStreamConfig = obj2 as IAMStreamConfig;
this.mediaControl = (IMediaControl) this.graphBuilder;
if (this.videoSources != null)
{
this.videoSources.Dispose();
}
this.videoSources = null;
if (this.audioSources != null)
{
this.audioSources.Dispose();
}
this.audioSources = null;
if (this.propertyPages != null)
{
this.propertyPages.Dispose();
}
this.propertyPages = null;
this.videoCaps = null;
this.audioCaps = null;
obj2 = null;
capture = PinCategory.Capture;
interleaved = MediaType.Interleaved;
riid = typeof(IAMTVTuner).GUID;
if (this.captureGraphBuilder.FindInterface(ref capture, ref interleaved, this.videoDeviceFilter, ref riid, out obj2) != 0)
{
//.........这里部分代码省略.........
开发者ID:alienwow,项目名称:CSharpProjects,代码行数:101,代码来源:Capture.cs
示例13: Stop
public void Stop()
{
this.wantCaptureRendered = false;
if (this.mediaControl != null)
{
this.mediaControl.Stop();
}
if (this.graphState == GraphState.Capturing)
{
this.graphState = GraphState.Rendered;
if (this.CaptureComplete != null)
{
this.CaptureComplete(this, null);
}
}
try
{
this.renderGraph();
}
catch
{
}
try
{
this.startPreviewIfNeeded();
}
catch
{
}
}
开发者ID:alienwow,项目名称:CSharpProjects,代码行数:30,代码来源:Capture.cs
示例14: Start
public void Start()
{
this.assertStopped();
this.wantCaptureRendered = true;
this.renderGraph();
int errorCode = this.mediaControl.Run();
if (errorCode != 0)
{
Marshal.ThrowExceptionForHR(errorCode);
}
this.graphState = GraphState.Capturing;
}
开发者ID:alienwow,项目名称:CSharpProjects,代码行数:12,代码来源:Capture.cs
示例15: derenderGraph
/// <summary>
/// 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.
/// </summary>
protected void derenderGraph()
{
// Stop the graph if it is running (ignore errors)
if ( mediaControl != null )
mediaControl.Stop();
// Free the preview window (ignore errors)
if ( videoWindow != null )
{
videoWindow.put_Visible( DsHlp.OAFALSE );
videoWindow.put_Owner( IntPtr.Zero );
videoWindow = null;
}
//ELIMINAR RECURSOS CAPTURA <<<<<<<<<================================================
/*if ( mediaEvt != null )
{
int hr = mediaEvt.SetNotifyWindow( IntPtr.Zero, WM_GRAPHNOTIFY, IntPtr.Zero );
mediaEvt = null;
}*/
// Remove the Resize event handler
if ( PreviewWindow != null )
previewWindow.Resize -= new EventHandler( onPreviewWindowResize );
if ( (int)graphState >= (int)GraphState.Rendered )
{
// Update the state
graphState = GraphState.Created;
isCaptureRendered = false;
isPreviewRendered = false;
// Disconnect all filters downstream of the
// video and audio devices. If we have a compressor
// then disconnect it, but don't remove it
if ( videoDeviceFilter != null )
removeDownstream( videoDeviceFilter, (videoCompressor==null) );
if ( audioDeviceFilter != null )
removeDownstream( audioDeviceFilter, (audioCompressor==null) );
// These filters should have been removed by the
// calls above. (Is there anyway to check?)
muxFilter = null;
fileWriterFilter = null;
//ELIMINAR RECURSOS CAPTURA <<<<<<<<<================================================
baseGrabFlt = null;
}
}
开发者ID:iManbot,项目名称:monoslam,代码行数:57,代码来源:Capture.cs
示例16: renderGraph
/// <summary>
/// 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.
/// </summary>
protected void renderGraph()
{
Guid cat;
Guid med;
int hr;
bool didSomething = false;
const int WS_CHILD = 0x40000000;
const int WS_CLIPCHILDREN = 0x02000000;
const int WS_CLIPSIBLINGS = 0x04000000;
assertStopped();
// Ensure required properties set
if ( filename == null )
throw new ArgumentException( "The Filename property has not been set to a file.\n" );
// Stop the graph
if ( mediaControl != null )
mediaControl.Stop();
// Create the graph if needed (group should already be created)
createGraph();
// Derender the graph if we have a capture or preview stream
// that we no longer want. We can't derender the capture and
// preview streams seperately.
// Notice the second case will leave a capture stream intact
// even if we no longer want it. This allows the user that is
// not using the preview to Stop() and Start() without
// rerendering the graph.
if ( !wantPreviewRendered && isPreviewRendered )
derenderGraph();
if ( !wantCaptureRendered && isCaptureRendered )
if ( wantPreviewRendered )
{
derenderGraph();
graphState = GraphState.Null;
createGraph();
}
// Video Capture
// ===================================================================================
if ( wantCaptureRendered && !isCaptureRendered )
{
// Render the file writer portion of graph (mux -> file)
Guid mediaSubType = MediaSubType.Avi;
hr = captureGraphBuilder.SetOutputFileName( ref mediaSubType, Filename, out muxFilter, out fileWriterFilter );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
if ( VideoDevice != null )
{
// Try interleaved first, because if the device supports it,
// it's the only way to get audio as well as video
cat = PinCategory.Capture;
med = MediaType.Interleaved;
hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, videoCompressorFilter, muxFilter);
if( hr < 0 )
{
med = MediaType.Video;
hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, videoCompressorFilter, muxFilter);
//if ( hr == -2147220969 ) throw new DeviceInUseException( "Video device", hr );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
}
// Render audio (audio -> mux)
if ( AudioDevice != null )
{
cat = PinCategory.Capture;
med = MediaType.Audio;
hr = captureGraphBuilder.RenderStream( ref cat, ref med, audioDeviceFilter, audioCompressorFilter, muxFilter );
if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
isCaptureRendered = true;
didSomething = true;
}
// Render preview stream and launch the baseGrabFlt to capture frames
// ===================================================================================
if ( wantPreviewRendered && renderStream && !isPreviewRendered )
{
// Render preview (video.PinPreview -> baseGrabFlt -> renderer)
// At this point intelligent connect is used, because my webcams don't have a preview pin and
// a capture pin, so Smart Tee filter will be used. I have tested it using GraphEdit.
// I can type hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, null, baseGrabFlt);
// because baseGrabFlt is a transform filter, like videoCompressorFilter.
cat = PinCategory.Preview;
med = MediaType.Video;
hr = captureGraphBuilder.RenderStream( ref cat, ref med, videoDeviceFilter, baseGrabFlt, null );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
// Get the IVideoWindow interface
//.........这里部分代码省略.........
开发者ID:iManbot,项目名称:monoslam,代码行数:101,代码来源:Capture.cs
示例17: createGraph
// --------------------- Private Methods -----------------------
/// <summary>
/// Create a new filter graph and add filters (devices, compressors,
/// misc), but leave the filters unconnected. Call renderGraph()
/// to connect the filters.
/// </summary>
protected void createGraph()
{
Guid cat;
Guid med;
int hr;
Type comType = null;
object comObj = null;
// Ensure required properties are set
if ( videoDevice == null && audioDevice == null )
throw new ArgumentException( "The video and/or audio device have not been set. Please set one or both to valid capture devices.\n" );
// Skip if we are already created
if ( (int)graphState < (int)GraphState.Created )
{
// Garbage collect, ensure that previous filters are released
GC.Collect();
// Make a new filter graph
graphBuilder = (IGraphBuilder) Activator.CreateInstance( Type.GetTypeFromCLSID( Clsid.FilterGraph, true ) );
// Get the Capture Graph Builder
Guid clsid = Clsid.CaptureGraphBuilder2;
Guid riid = typeof(ICaptureGraphBuilder2).GUID;
captureGraphBuilder = (ICaptureGraphBuilder2) DsBugWO.CreateDsInstance( ref clsid, ref riid );
// sampGrabber, ISampleGrabber to capture frames
comType=Type.GetTypeFromCLSID( Clsid.SampleGrabber, true );
if(comType==null)
throw new NotImplementedException (@"DirectShow SampleGrabber not installed/registered");
comObj=Activator.CreateInstance( comType );
sampGrabber = (ISampleGrabber) comObj; comObj = null;
// Link the CaptureGraphBuilder to the filter graph
hr = captureGraphBuilder.SetFiltergraph( graphBuilder );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
// Begin set up of SampGrabber <<<<<<----------------------------------------------------
AMMediaType media = new AMMediaType();
media.majorType= MediaType.Video;
media.subType = MediaSubType.RGB24;
media.formatType = FormatType.VideoInfo;
hr = sampGrabber.SetMediaType( media );
//if( hr<0 ) Marshal.ThrowExceptionForHR( hr );
// Finish set up of SampGrabber <<<<<<----------------------------------------------------
// Add the graph to the Running Object Table so it can be
// viewed with GraphEdit
#if DEBUG
DsROT.AddGraphToRot( graphBuilder, out rotCookie );
#endif
// Get the video device and add it to the filter graph
if ( VideoDevice != null )
{
videoDeviceFilter = (IBaseFilter) Marshal.BindToMoniker( VideoDevice.MonikerString );
hr = graphBuilder.AddFilter( videoDeviceFilter, "Video Capture Device" );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
// Add SampGrabber Filter <<<<<<----------------------------------------------------
mediaEvt = (IMediaEventEx) graphBuilder;
baseGrabFlt = (IBaseFilter) sampGrabber;
hr = graphBuilder.AddFilter( baseGrabFlt, "DS.NET Grabber" );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
// Get the audio device and add it to the filter graph
if ( AudioDevice != null )
{
audioDeviceFilter = (IBaseFilter) Marshal.BindToMoniker( AudioDevice.MonikerString );
hr = graphBuilder.AddFilter( audioDeviceFilter, "Audio Capture Device" );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
// Get the video compressor and add it to the filter graph
if ( VideoCompressor != null )
{
videoCompressorFilter = (IBaseFilter) Marshal.BindToMoniker( VideoCompressor.MonikerString );
hr = graphBuilder.AddFilter( videoCompressorFilter, "Video Compressor" );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
// Get the audio compressor and add it to the filter graph
if ( AudioCompressor != null )
{
audioCompressorFilter = (IBaseFilter) Marshal.BindToMoniker( AudioCompressor.MonikerString );
hr = graphBuilder.AddFilter( audioCompressorFilter, "Audio Compressor" );
//if( hr < 0 ) Marshal.ThrowExceptionForHR( hr );
}
// Retrieve the stream control interface for the video device
// FindInterface will also add any required filters
//.........这里部分代码省略.........
开发者ID:iManbot,项目名称:monoslam,代码行数:101,代码来源:Capture.cs
示例18: derenderGraph
/// <summary>
/// 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.
/// </summary>
protected void derenderGraph()
{
// Stop the graph if it is running (ignore errors)
if ( mediaControl != null )
mediaControl.Stop();
// Free the preview window (ignore errors)
if ( videoWindow != null )
{
#if DSHOWNET
videoWindow.put_Visible(DsHlp.OAFALSE);
#else
videoWindow.put_Visible(OABool.False);
#endif
videoWindow.put_Owner( IntPtr.Zero );
videoWindow = null;
}
// Remove the Resize event handler
if ( PreviewWindow != null )
previewWindow.Resize -= new EventHandler( onPreviewWindowResize );
if ( (int)graphState >= (int)GraphState.Rendered )
{
// Update the state
graphState = GraphState.Created;
isCaptureRendered = false;
isPreviewRendered = false;
// Disconnect all filters downstream of the
// video and audio devices. If we have a compressor
// then disconnect it, but don't remove it
if (videoDeviceFilter != null)
{
try
{
removeDownstream(videoDeviceFilter, (videoCompressor == null));
}
catch
{
Debug.WriteLine("Error removeDownstream videoDeviceFilter");
}
}
if (audioDeviceFilter != null)
{
try
{
removeDownstream(audioDeviceFilter, (audioCompressor == null));
}
catch
{
Debug.WriteLine("Error removeDownstream audioDeviceFilter");
}
}
// These filters should have been removed by the
// calls above. (Is there anyway to check?)
muxFilter = null;
fileWriterFilter = null;
this.videoRendererFilter = null;
this.deInterlaceFilter = null;
}
}
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:70,代码来源:Capture.cs
示例19: destroyGraph
/// <summary>
/// Completely tear down a filter graph and
/// release all associated resources.
/// </summary>
protected void destroyGraph()
{
// Derender the graph (This will stop the graph
// and release preview window. It also destroys
// half of the graph which is unnecessary but
// harmless here.) (ignore errors)
try{ derenderGraph(); } catch {}
// Update the state after derender because it
// depends on correct status. But we also want to
// update the state as early as possible in case
// of error.
graphState = GraphState.Null;
isCaptureRendered = false;
isPreviewRendered = false;
// Remove graph from the ROT
#if DSHOWNET
if ( rotCookie != 0 )
{
DsROT.RemoveGraphFromRot( ref rotCookie );
rotCookie = 0;
}
#else
if (rotCookie != null)
{
rotCookie.Dispose();
rotCookie = null;
}
#endif
// Remove filters from the graph
// This should be unnecessary but the Nvidia WDM
// video driver cannot be used by this application
// again unless we remove it. Ideally, we should
// simply enumerate all the filters in the graph
// and remove them. (ignore errors)
if ( muxFilter != null )
graphBuilder.RemoveFilter( muxFilter );
if ( videoCompressorFilter != null )
graphBuilder.RemoveFilter( videoCompressorFilter );
if ( audioCompressorFilter != null )
graphBuilder.RemoveFilter( audioCompressorFilter );
if ( videoDeviceFilter != null )
graphBuilder.RemoveFilter( videoDeviceFilter );
if ( audioDeviceFilter != null )
graphBuilder.RemoveFilter( audioDeviceFilter );
if(this.videoRendererFilter != null)
{
this.graphBuilder.RemoveFilter(this.videoRendererFilter);
}
// Clean up properties
if ( videoSources != null )
videoSources.Dispose(); videoSources = null;
if ( audioSources != null )
audioSources.Dispose(); audioSources = null;
this.PropertyPages = null; // Disposal done within PropertyPages
if ( tuner != null )
tuner.Dispose(); tuner = null;
// #if NEWCODE
if(this.tvAudio != null)
{
Marshal.ReleaseComObject(this.tvAudio); tvAudio = null;
}
if(this.dxUtils != null)
{
this.dxUtils.Dispose();
this.dxUtils = null;
}
// #endif
// Cleanup
if ( graphBuilder != null )
Marshal.ReleaseComObject( graphBuilder ); graphBuilder = null;
if ( captureGraphBuilder != null )
Marshal.ReleaseComObject( captureGraphBuilder ); captureGraphBuilder = null;
if ( muxFilter != null )
Marshal.ReleaseComObject( muxFilter ); muxFilter = null;
if ( fileWriterFilter != null )
Marshal.ReleaseComObject( fileWriterFilter ); fileWriterFilter = null;
if ( videoDeviceFilter != null )
Marshal.ReleaseComObject( videoDeviceFilter ); videoDeviceFilter = null;
if ( audioDeviceFilter != null )
Marshal.ReleaseComObject( audioDeviceFilter ); audioDeviceFilter = null;
if ( videoCompressorFilter != null )
Marshal.ReleaseComObject( videoCompressorFilter ); videoCompressorFilter = null;
if ( audioCompressorFilter != null )
Marshal.ReleaseComObject( audioCompressorFilter ); audioCompressorFilter = null;
// #if NEWCODE
this.DisposeSampleGrabber();
// #endif
//.........这里部分代码省略.........
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:101,代码来源:Capture.cs
示例20: derenderGraph
protected void derenderGraph()
{
if (this.mediaControl != null)
{
this.mediaControl.Stop();
}
if (this.videoWindow != null)
{
this.videoWindow.put_Visible(0);
this.videoWindow.put_Owner(IntPtr.Zero);
this.videoWindow = null;
}
if (this.PreviewWindow != null)
{
this.previewWindow.Resize -= new EventHandler(this.onPreviewWindowResize);
}
if (this.graphState >= GraphState.Rendered)
{
this.graphState = GraphState.Created;
this.isCaptureRendered = false;
this.isPreviewRendered = false;
if (this.videoDeviceFilter != null)
{
this.removeDownstream(this.videoDeviceFilter, this.videoCompressor == null);
}
if (this.audioDeviceFilter != null)
{
this.removeDownstream(this.audioDeviceFilter, this.audioCompressor == null);
}
this.muxFilter = null;
this.fileWriterFilter = null;
}
}
开发者ID:alienwow,项目名称:CSharpProjects,代码行数:33,代码来源:Capture.cs
注:本文中的GraphState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论