📄 axcore.cs
字号:
#region license
/*
DirectShowLib - Provide access to DirectShow interfaces via .NET
Copyright (C) 2006
http://sourceforge.net/projects/directshownet/
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#endregion
using System;
using System.Runtime.InteropServices;
namespace DirectShowLib
{
#region Declarations
/// <summary>
/// From AM_GBF_* defines
/// </summary>
[Flags]
public enum AMGBF
{
None = 0,
PrevFrameSkipped = 1,
NotAsyncPoint = 2,
NoWait = 4,
NoDDSurfaceLock = 8
}
/// <summary>
/// From AM_VIDEO_FLAG_* defines
/// </summary>
[Flags]
public enum AMVideoFlag
{
FieldMask = 0x0003,
InterleavedFrame = 0x0000,
Field1 = 0x0001,
Field2 = 0x0002,
Field1First = 0x0004,
Weave = 0x0008,
IPBMask = 0x0030,
ISample = 0x0000,
PSample = 0x0010,
BSample = 0x0020,
RepeatField = 0x0040
}
/// <summary>
/// From AM_SAMPLE_PROPERTY_FLAGS
/// </summary>
[Flags]
public enum AMSamplePropertyFlags
{
SplicePoint = 0x01,
PreRoll = 0x02,
DataDiscontinuity = 0x04,
TypeChanged = 0x08,
TimeValid = 0x10,
MediaTimeValid = 0x20,
TimeDiscontinuity = 0x40,
FlushOnPause = 0x80,
StopValid = 0x100,
EndOfStream = 0x200,
Media = 0,
Control = 1
}
/// <summary>
/// From PIN_INFO
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Unicode)]
public struct PinInfo
{
[MarshalAs(UnmanagedType.Interface)] public IBaseFilter filter;
public PinDirection dir;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public string name;
}
/// <summary>
/// From AM_MEDIA_TYPE - When you are done with an instance of this class,
/// it should be released with FreeAMMediaType() to avoid leaking
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=1)]
public class AMMediaType
{
public Guid majorType;
public Guid subType;
[MarshalAs(UnmanagedType.Bool)] public bool fixedSizeSamples;
[MarshalAs(UnmanagedType.Bool)] public bool temporalCompression;
public int sampleSize;
public Guid formatType;
public IntPtr unkPtr; // IUnknown Pointer
public int formatSize;
public IntPtr formatPtr; // Pointer to a buff determined by formatType
}
/// <summary>
/// From PIN_DIRECTION
/// </summary>
public enum PinDirection
{
Input,
Output
}
/// <summary>
/// From AM_SEEKING_SeekingCapabilities
/// </summary>
[Flags]
public enum AMSeekingSeekingCapabilities
{
None = 0,
CanSeekAbsolute = 0x001,
CanSeekForwards = 0x002,
CanSeekBackwards = 0x004,
CanGetCurrentPos = 0x008,
CanGetStopPos = 0x010,
CanGetDuration = 0x020,
CanPlayBackwards = 0x040,
CanDoSegments = 0x080,
Source = 0x100
}
/// <summary>
/// From FILTER_STATE
/// </summary>
public enum FilterState
{
Stopped,
Paused,
Running
}
/// <summary>
/// From FILTER_INFO
/// </summary>
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]
public struct FilterInfo
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)] public string achName;
[MarshalAs(UnmanagedType.Interface)] public IFilterGraph pGraph;
}
/// <summary>
/// From AM_SEEKING_SeekingFlags
/// </summary>
[Flags]
public enum AMSeekingSeekingFlags
{
NoPositioning = 0x00,
AbsolutePositioning = 0x01,
RelativePositioning = 0x02,
IncrementalPositioning = 0x03,
PositioningBitsMask = 0x03,
SeekToKeyFrame = 0x04,
ReturnTime = 0x08,
Segment = 0x10,
NoFlush = 0x20
}
/// <summary>
/// From ALLOCATOR_PROPERTIES
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class AllocatorProperties
{
public int cBuffers;
public int cbBuffer;
public int cbAlign;
public int cbPrefix;
}
/// <summary>
/// From AM_SAMPLE2_PROPERTIES
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public class AMSample2Properties
{
public int cbData;
public AMVideoFlag dwTypeSpecificFlags;
public AMSamplePropertyFlags dwSampleFlags;
public int lActual;
public long tStart;
public long tStop;
public int dwStreamId;
public IntPtr pMediaType;
public IntPtr pbBuffer; // BYTE *
public int cbBuffer;
}
#endregion
#region Interfaces
#if ALLOW_UNTESTED_INTERFACES
[ComImport,
Guid("36b73885-c2c8-11cf-8b46-00805f6cef60"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IReferenceClock2 : IReferenceClock
{
#region IReferenceClock Methods
[PreserveSig]
new int GetTime([Out] out long pTime);
[PreserveSig]
new int AdviseTime(
[In] long baseTime,
[In] long streamTime,
[In] IntPtr hEvent, // System.Threading.WaitHandle?
[Out] out int pdwAdviseCookie
);
[PreserveSig]
new int AdvisePeriodic(
[In] long startTime,
[In] long periodTime,
[In] IntPtr hSemaphore, // System.Threading.WaitHandle?
[Out] out int pdwAdviseCookie
);
[PreserveSig]
new int Unadvise([In] int dwAdviseCookie);
#endregion
}
[ComImport,
Guid("56a8689d-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMemInputPin
{
[PreserveSig]
int GetAllocator([Out] out IMemAllocator ppAllocator);
[PreserveSig]
int NotifyAllocator(
[In] IMemAllocator pAllocator,
[In, MarshalAs(UnmanagedType.Bool)] bool bReadOnly
);
[PreserveSig]
int GetAllocatorRequirements([Out] out AllocatorProperties pProps);
[PreserveSig]
int Receive([In] IMediaSample pSample);
[PreserveSig]
int ReceiveMultiple(
[In] IntPtr pSamples, // IMediaSample[]
[In] int nSamples,
[Out] out int nSamplesProcessed
);
[PreserveSig]
int ReceiveCanBlock();
}
[ComImport,
Guid("a3d8cec0-7e5a-11cf-bbc5-00805f6cef20"),
Obsolete("This interface has been deprecated.", false),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IAMovieSetup
{
[PreserveSig]
int Register();
[PreserveSig]
int Unregister();
}
#endif
[ComImport,
Guid("56a86891-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPin
{
[PreserveSig]
int Connect(
[In] IPin pReceivePin,
[In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt
);
[PreserveSig]
int ReceiveConnection(
[In] IPin pReceivePin,
[In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt
);
[PreserveSig]
int Disconnect();
[PreserveSig]
int ConnectedTo(
[Out] out IPin ppPin);
/// <summary>
/// Release returned parameter with DsUtils.FreeAMMediaType
/// </summary>
[PreserveSig]
int ConnectionMediaType(
[Out, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt);
/// <summary>
/// Release returned parameter with DsUtils.FreePinInfo
/// </summary>
[PreserveSig]
int QueryPinInfo([Out] out PinInfo pInfo);
[PreserveSig]
int QueryDirection(out PinDirection pPinDir);
[PreserveSig]
int QueryId([Out, MarshalAs(UnmanagedType.LPWStr)] out string Id);
[PreserveSig]
int QueryAccept([In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType pmt);
[PreserveSig]
int EnumMediaTypes([Out] out IEnumMediaTypes ppEnum);
[PreserveSig]
int QueryInternalConnections(
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=1)] IPin[] ppPins,
[In, Out] ref int nPin
);
[PreserveSig]
int EndOfStream();
[PreserveSig]
int BeginFlush();
[PreserveSig]
int EndFlush();
[PreserveSig]
int NewSegment(
[In] long tStart,
[In] long tStop,
[In] double dRate
);
}
[ComImport,
Guid("36b73880-c2c8-11cf-8b46-00805f6cef60"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMediaSeeking
{
[PreserveSig]
int GetCapabilities([Out] out AMSeekingSeekingCapabilities pCapabilities);
[PreserveSig]
int CheckCapabilities([In, Out] ref AMSeekingSeekingCapabilities pCapabilities);
[PreserveSig]
int IsFormatSupported([In, MarshalAs(UnmanagedType.LPStruct)] Guid pFormat);
[PreserveSig]
int QueryPreferredFormat([Out] out Guid pFormat);
[PreserveSig]
int GetTimeFormat([Out] out Guid pFormat);
[PreserveSig]
int IsUsingTimeFormat([In, MarshalAs(UnmanagedType.LPStruct)] Guid pFormat);
[PreserveSig]
int SetTimeFormat([In, MarshalAs(UnmanagedType.LPStruct)] Guid pFormat);
[PreserveSig]
int GetDuration([Out] out long pDuration);
[PreserveSig]
int GetStopPosition([Out] out long pStop);
[PreserveSig]
int GetCurrentPosition([Out] out long pCurrent);
[PreserveSig]
int ConvertTimeFormat(
[Out] out long pTarget,
[In, MarshalAs(UnmanagedType.LPStruct)] DsGuid pTargetFormat,
[In] long Source,
[In, MarshalAs(UnmanagedType.LPStruct)] DsGuid pSourceFormat
);
[PreserveSig]
int SetPositions(
[In, Out, MarshalAs(UnmanagedType.LPStruct)] DsLong pCurrent,
[In] AMSeekingSeekingFlags dwCurrentFlags,
[In, Out, MarshalAs(UnmanagedType.LPStruct)] DsLong pStop,
[In] AMSeekingSeekingFlags dwStopFlags
);
[PreserveSig]
int GetPositions(
[Out] out long pCurrent,
[Out] out long pStop
);
[PreserveSig]
int GetAvailable(
[Out] out long pEarliest,
[Out] out long pLatest
);
[PreserveSig]
int SetRate([In] double dRate);
[PreserveSig]
int GetRate([Out] out double pdRate);
[PreserveSig]
int GetPreroll([Out] out long pllPreroll);
}
[ComImport,
Guid("56a8689a-0ad4-11ce-b03a-0020af0ba770"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IMediaSample
{
[PreserveSig]
int GetPointer([Out] out IntPtr ppBuffer); // BYTE **
[PreserveSig]
int GetSize();
[PreserveSig]
int GetTime(
[Out] out long pTimeStart,
[Out] out long pTimeEnd
);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -