本文整理汇总了C#中IVideoWindow.put_MessageDrain方法的典型用法代码示例。如果您正苦于以下问题:C# IVideoWindow.put_MessageDrain方法的具体用法?C# IVideoWindow.put_MessageDrain怎么用?C# IVideoWindow.put_MessageDrain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IVideoWindow
的用法示例。
在下文中一共展示了IVideoWindow.put_MessageDrain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Play
public bool Play(string fileName, Form form)
{
_form = form;
Log.WriteFile("play:{0}", fileName);
_graphBuilder = (IFilterGraph2)new FilterGraph();
_rotEntry = new DsROTEntry(_graphBuilder);
TsReader reader = new TsReader();
_tsReader = (IBaseFilter)reader;
Log.Info("TSReaderPlayer:add TsReader to graph");
_graphBuilder.AddFilter(_tsReader, "TsReader");
#region load file in TsReader
Log.WriteFile("load file in Ts");
IFileSourceFilter interfaceFile = (IFileSourceFilter)_tsReader;
if (interfaceFile == null)
{
Log.WriteFile("TSReaderPlayer:Failed to get IFileSourceFilter");
return false;
}
int hr = interfaceFile.Load(fileName, null);
if (hr != 0)
{
Log.WriteFile("TSReaderPlayer:Failed to load file");
return false;
}
#endregion
#region render pin
Log.Info("TSReaderPlayer:render TsReader outputs");
IEnumPins enumPins;
_tsReader.EnumPins(out enumPins);
IPin[] pins = new IPin[2];
int fetched;
while (enumPins.Next(1, pins, out fetched) == 0)
{
if (fetched != 1) break;
PinDirection direction;
pins[0].QueryDirection(out direction);
if (direction == PinDirection.Input)
{
Release.ComObject(pins[0]);
continue;
}
_graphBuilder.Render(pins[0]);
Release.ComObject(pins[0]);
}
Release.ComObject(enumPins);
#endregion
_videoWin = _graphBuilder as IVideoWindow;
if (_videoWin != null)
{
_videoWin.put_Visible(OABool.True);
_videoWin.put_Owner(form.Handle);
_videoWin.put_WindowStyle(
(WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren));
_videoWin.put_MessageDrain(form.Handle);
_videoWin.SetWindowPosition(form.ClientRectangle.X, form.ClientRectangle.Y, form.ClientRectangle.Width,
form.ClientRectangle.Height);
}
Log.WriteFile("run graph");
_mediaCtrl = (IMediaControl)_graphBuilder;
hr = _mediaCtrl.Run();
Log.WriteFile("TSReaderPlayer:running:{0:X}", hr);
return true;
}
示例2: loadVideo
private void loadVideo(String videoPath)
{
videoFilepath = videoPath;
videoFileName.Text = getDisplayVideoName();
if (graph != null)
{
graph = null;
}
if (mediaControl != null)
{
// Stop media playback
this.mediaControl.Stop();
mediaControl = null;
}
if (videoWindow != null)
{
videoWindow.put_Owner(IntPtr.Zero);
videoWindow = null;
}
if (mediaSeeking != null)
{
mediaSeeking = null;
}
if (basicAudio != null)
{
basicAudio = null;
}
GC.Collect();
/* if (mediaPosition != null)
{
mediaPosition = null;
}*/
graph = (IGraphBuilder)new FilterGraph();
mediaControl = (IMediaControl)graph;
//mediaPosition = (IMediaPosition)graph;
videoWindow = (IVideoWindow)graph;
mediaSeeking = (IMediaSeeking)graph;
basicAudio = (IBasicAudio)graph;
AviSplitter spliter = new AviSplitter();
graph.AddFilter((IBaseFilter)spliter, null);
graph.RenderFile(videoPath, null);
graph.SetDefaultSyncSource();
/*
* AMSeekingSeekingCapabilities cap = AMSeekingSeekingCapabilities.CanGetCurrentPos;
if (mediaSeeking.CheckCapabilities(ref cap) > 0)
{
this.consoleErreur.AppendText("Impossible de recuperer la position de la frame");
}
* */
videoWindow.put_Owner(videoPanel.Handle);
videoWindow.put_MessageDrain(videoPanel.Handle);
videoWindow.put_WindowStyle(WindowStyle.Child);
videoWindow.put_WindowStyleEx(WindowStyleEx.ControlParent);
videoWindow.put_Left(0);
videoWindow.put_Top(0);
videoWindow.put_Width(videoPanel.Width);
videoWindow.put_Height(videoPanel.Height);
//positionTrackbar.Enabled = true;
speedTrackBar.Enabled = true;
mediaSeeking.SetTimeFormat(TimeFormat.Frame);
double rate;
mediaSeeking.GetRate(out rate);
rateText.Text = rate.ToString();
speedTrackBar.Value = (int)(speedTrackBar.Maximum * rate / 2);
trackBar1.Value = trackBar1.Maximum / 2;
this.basicAudio.put_Volume(-5000 + 5000 * trackBar1.Value / trackBar1.Maximum);
//mediaPosition.put_Rate(0.5);
running = false;
frameChanged = false;
}
示例3: Play
//.........这里部分代码省略.........
mpeg2ProgramStream.unkPtr = IntPtr.Zero;
mpeg2ProgramStream.sampleSize = 0;
mpeg2ProgramStream.temporalCompression = false;
mpeg2ProgramStream.fixedSizeSamples = true;
mpeg2ProgramStream.formatType = FormatType.None;
mpeg2ProgramStream.formatSize = 0;
mpeg2ProgramStream.formatPtr = IntPtr.Zero;
hr = interfaceFile.Load(fileName, mpeg2ProgramStream);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9:Failed to load file");
return false;
}
#region connect tsfilesource->demux
Log.WriteFile("connect tsfilesource->demux");
Log.WriteFile("TSStreamBufferPlayer9:connect tsfilesource->mpeg2 demux");
IPin pinTsOut = DsFindPin.ByDirection((IBaseFilter)_tsFileSource, PinDirection.Output, 0);
if (pinTsOut == null)
{
Log.WriteFile("TSStreamBufferPlayer9:failed to find output pin of tsfilesource");
return false;
}
IPin pinDemuxIn = DsFindPin.ByDirection(_mpegDemux, PinDirection.Input, 0);
if (pinDemuxIn == null)
{
Log.WriteFile("TSStreamBufferPlayer9:failed to find output pin of tsfilesource");
return false;
}
hr = _graphBuilder.Connect(pinTsOut, pinDemuxIn);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9:failed to connect tsfilesource->mpeg2 demux:{0:X}", hr);
return false;
}
Release.ComObject(pinTsOut);
Release.ComObject(pinDemuxIn);
#endregion
#region map demux pids
Log.WriteFile("map mpeg2 pids");
IMPEG2StreamIdMap pStreamId = (IMPEG2StreamIdMap)_pinVideo;
hr = pStreamId.MapStreamId(0xe0, MPEG2Program.ElementaryStream, 0, 0);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9: failed to map pid 0xe0->video pin");
return false;
}
pStreamId = (IMPEG2StreamIdMap)_pinAudio;
hr = pStreamId.MapStreamId(0xc0, MPEG2Program.ElementaryStream, 0, 0);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9: failed to map pid 0xc0->audio pin");
return false;
}
#endregion
#region render demux audio/video pins
Log.WriteFile("render pins");
hr = _graphBuilder.Render(_pinAudio);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9:failed to render video output pin:{0:X}", hr);
}
hr = _graphBuilder.Render(_pinVideo);
if (hr != 0)
{
Log.WriteFile("TSStreamBufferPlayer9:failed to render audio output pin:{0:X}", hr);
}
#endregion
#endregion
_videoWin = _graphBuilder as IVideoWindow;
if (_videoWin != null)
{
_videoWin.put_Visible(OABool.True);
_videoWin.put_Owner(form.Handle);
_videoWin.put_WindowStyle(
(WindowStyle)((int)WindowStyle.Child + (int)WindowStyle.ClipSiblings + (int)WindowStyle.ClipChildren));
_videoWin.put_MessageDrain(form.Handle);
_videoWin.SetWindowPosition(190, 250, 150, 150);
}
Log.WriteFile("run graph");
_mediaCtrl = (IMediaControl)_graphBuilder;
hr = _mediaCtrl.Run();
Log.WriteFile("TSStreamBufferPlayer9:running:{0:X}", hr);
return true;
}