本文整理汇总了C#中IFilterGraph2.RenderFile方法的典型用法代码示例。如果您正苦于以下问题:C# IFilterGraph2.RenderFile方法的具体用法?C# IFilterGraph2.RenderFile怎么用?C# IFilterGraph2.RenderFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFilterGraph2
的用法示例。
在下文中一共展示了IFilterGraph2.RenderFile方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildGraph
private void BuildGraph(string fileName)
{
int hr = 0;
try
{
graphBuilder = (IFilterGraph2)new FilterGraph();
mediaControl = (IMediaControl)graphBuilder;
mediaSeeking = (IMediaSeeking)graphBuilder;
mediaPosition = (IMediaPosition)graphBuilder;
vmr9 = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
}
catch (Exception e)
{
CloseInterfaces();
MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例2: BuildGraph
private void BuildGraph(string fileName)
{
int hr = 0;
try
{
graphBuilder = (IFilterGraph2) new FilterGraph();
mediaControl = (IMediaControl) graphBuilder;
vmr9 = (IBaseFilter) new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
mixerBitmap = (IVMRMixerBitmap9) vmr9;
menuMixer.Enabled = true;
mixerEnabled = true;
usingGDI = false;
UpdateMixerMenu();
SetMixerSettings();
}
catch(Exception e)
{
CloseInterfaces();
MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例3: InitVMR9
public void InitVMR9(string filename)
{
int hr = 0;
// Create a DirectShow FilterGraph
graphBuilder = (IFilterGraph2) new FilterGraph();
// Add it in ROT for debug purpose
rot = new DsROTEntry(graphBuilder);
// Add a notification handler (see WndProc)
hr = (graphBuilder as IMediaEventEx).SetNotifyWindow(this.Handle, WM_GRAPHNOTIFY, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
// Create a VMR9 object
vmr9 = (IBaseFilter) new VideoMixingRenderer9();
IVMRFilterConfig9 filterConfig = (IVMRFilterConfig9) vmr9;
// We want the Renderless mode!
hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
DsError.ThrowExceptionForHR(hr);
// Create the Allocator / Presenter object
allocator = new Allocator(device);
IVMRSurfaceAllocatorNotify9 vmrSurfAllocNotify = (IVMRSurfaceAllocatorNotify9) vmr9;
// Notify the VMR9 filter about our allocator
hr = vmrSurfAllocNotify.AdviseSurfaceAllocator(IntPtr.Zero, allocator);
DsError.ThrowExceptionForHR(hr);
// Notify our allocator about the VMR9 filter
hr = allocator.AdviseNotify(vmrSurfAllocNotify);
DsError.ThrowExceptionForHR(hr);
if (config.IsUsingMixing)
{
// One stream is enough for this sample
// This line also load the mixing componant
hr = filterConfig.SetNumberOfStreams(1);
DsError.ThrowExceptionForHR(hr);
IVMRMixerControl9 mixerControl = (IVMRMixerControl9) vmr9;
// Select the mixer mode : YUV or RGB
if (config.UseYUVMixing)
{
hr = mixerControl.SetMixingPrefs(VMR9MixerPrefs.RenderTargetYUV | VMR9MixerPrefs.NoDecimation | VMR9MixerPrefs.ARAdjustXorY | VMR9MixerPrefs.BiLinearFiltering);
}
else
{
hr = mixerControl.SetMixingPrefs(VMR9MixerPrefs.RenderTargetRGB | VMR9MixerPrefs.NoDecimation | VMR9MixerPrefs.ARAdjustXorY | VMR9MixerPrefs.BiLinearFiltering);
}
DsError.ThrowExceptionForHR(hr);
Debug.WriteLine("Using VMR9 mixing mode");
}
// Add the filter to the graph
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
// Render the file
hr = graphBuilder.RenderFile(filename, null);
DsError.ThrowExceptionForHR(hr);
// Run the graph
hr = (graphBuilder as IMediaControl).Run();
DsError.ThrowExceptionForHR(hr);
}
示例4: Initialize
//.........这里部分代码省略.........
string url = path;
#if false
int maxRedirects = DirectShowWebReader.MAX_REDIRECTS;
DirectShowWebReader reader = null;
while (maxRedirects != 0)
{
if (url.StartsWith("http://") || url.StartsWith("https://"))
{
try
{
// Start reading the data
reader = new DirectShowWebReader();
hr = reader.Load(url);
DsError.ThrowExceptionForHR(hr);
shouldStream = true;
break;
}
catch (DirectShowWebReader.RedirectException e)
{
log.Info("Redirect to (" + e.url + ")");
url = e.url;
maxRedirects--;
reader = null;
}
}
else
{
shouldStream = false;
reader = null;
break;
}
}
if (maxRedirects == 0)
{
log.Warn("Stopped redirection after " + DirectShowWebReader.MAX_REDIRECTS + " attempts.");
}
#else
shouldStream = DirectShowCodec.ShouldStream(url);
#endif
if(shouldStream)
{
#if false
// Add our source filter to the graph
DirectShowStreamer strm = new DirectShowStreamer(reader);
hr = graphBuilder.AddFilter(strm, DirectShowStreamer.FILTER_NAME);
DsError.ThrowExceptionForHR(hr);
streamer = strm;
streamer.SetType(reader.MajorType, reader.MinorType);
// Render the file
hr = graphBuilder.Render(strm.GetOutputPin());
DsError.ThrowExceptionForHR(hr);
#else
WMAsfReader asf = new WMAsfReader();
IBaseFilter ibf = (asf as IBaseFilter);
IFileSourceFilter ifs = (asf as IFileSourceFilter);
hr = ifs.Load(url, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
// XXXMLM - how to set buffer time?
// IWMStreamConfig2 on the output pins?
hr = graphBuilder.AddFilter(ibf, "WM ASF Reader");
DsError.ThrowExceptionForHR(hr);
IEnumPins ie;
IPin[] pins = new IPin[1];
hr = ibf.EnumPins(out ie);
int fetched = 0;
while (hr == 0)
{
hr = ie.Next(1, pins, out fetched);
if (fetched != 0)
{
hr = graphBuilder.Render(pins[0]);
DsError.ThrowExceptionForHR(hr);
}
}
#endif
}
else
{
// Render the file
hr = graphBuilder.RenderFile(url, null);
DsError.ThrowExceptionForHR(hr);
}
#if true
// Run the graph
hr = (graphBuilder as IMediaControl).Run();
DsError.ThrowExceptionForHR(hr);
// Wait for ready
hr = (graphBuilder as IMediaControl).Pause();
DsError.ThrowExceptionForHR(hr);
ps = PLAY_STATE.BUFFERING;
#endif
return true;
}
示例5: BuildGraph
private void BuildGraph(string fileName)
{
int hr = 0;
try
{
graphBuilder = (IFilterGraph2)new FilterGraph();
mediaControl = (IMediaControl)graphBuilder;
ISampleGrabber sampGrabber = null;
IBaseFilter baseGrabFlt = null;
// Get the SampleGrabber interface
sampGrabber = (ISampleGrabber)new SampleGrabber();
vmr9 = (IBaseFilter)new VideoMixingRenderer9();
ConfigureVMR9InWindowlessMode();
hr = graphBuilder.AddFilter(vmr9, "Video Mixing Renderer 9");
DsError.ThrowExceptionForHR(hr);
baseGrabFlt = (IBaseFilter)sampGrabber;
ConfigureSampleGrabber(sampGrabber);
// Add the frame grabber to the graph
hr = graphBuilder.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
mediaPosition = (IMediaPosition)graphBuilder;
m_MediaEvent = graphBuilder as IMediaEvent;
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
SaveSizeInfo(sampGrabber);
}
catch (Exception e)
{
CloseInterfaces();
MessageBox.Show("An error occured during the graph building : \r\n\r\n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
示例6: BuildGraph
public bool BuildGraph(IntPtr windowHandle, string fileName, bool isVideo)
{
currentSpeed = NormalSpeed;
int hr = 0;
try
{
graphBuilder = (IFilterGraph2)new FilterGraph();
mediaControl = (IMediaControl)graphBuilder;
mediaEvent = (IMediaEventEx)graphBuilder;
winHandle = windowHandle;
mediaEvent.SetNotifyWindow(winHandle, VideoForm.WM_DSEvent, winHandle);
if (isVideo)
{
if (IsEvrPlay)
{
ConfigureEVR();
}
else
{
ConfigureVMR();
}
}
hr = graphBuilder.RenderFile(fileName, null);
DsError.ThrowExceptionForHR(hr);
}
catch (Exception e)
{
MessageBox.Show(fileName + "\n" + e.Message);
return false;
}
return true;
}