📄 mediaobj.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.Text;
using System.Runtime.InteropServices;
namespace DirectShowLib.DMO
{
#region Declarations
#if ALLOW_UNTESTED_INTERFACES
/// <summary>
/// From DMO_QUALITY_STATUS_FLAGS
/// </summary>
[Flags]
public enum DMOQualityStatus
{
None = 0x0,
Enabled = 0x1
}
#endif
/// <summary>
/// From _DMO_OUTPUT_DATA_BUFFER_FLAGS
/// </summary>
[Flags]
public enum DMOOutputDataBufferFlags
{
None = 0,
SyncPoint = 0x1,
Time = 0x2,
TimeLength = 0x4,
InComplete = 0x1000000
} ;
/// <summary>
/// From DMO_ENUM_FLAGS
/// </summary>
[Flags]
public enum DMOEnumerator
{
None = 0,
IncludeKeyed = 0x00000001
}
/// <summary>
/// From DMO_REGISTER_FLAGS
/// </summary>
[Flags]
public enum DMORegisterFlags
{
None = 0,
IsKeyed = 0x00000001
};
/// <summary>
/// From DMO_PROCESS_OUTPUT_FLAGS
/// </summary>
[Flags]
public enum DMOProcessOutput
{
None = 0x0,
DiscardWhenNoBuffer = 0x00000001
}
/// <summary>
/// From DMO_INPUT_DATA_BUFFER_FLAGS
/// </summary>
[Flags]
public enum DMOInputDataBuffer
{
None = 0,
SyncPoint = 0x1,
Time = 0x2,
TimeLength = 0x4
}
/// <summary>
/// From DMO_INPLACE_PROCESS_FLAGS
/// </summary>
[Flags]
public enum DMOInplaceProcess
{
Normal = 0,
Zero = 0x1
}
/// <summary>
/// From DMO_INPUT_STREAM_INFO_FLAGS
/// </summary>
[Flags]
public enum DMOInputStreamInfo
{
None = 0x0,
WholeSamples = 0x1,
SingleSamplePerBuffer = 0x2,
FixedSampleSize = 0x4,
HoldsBuffers = 0x8
}
/// <summary>
/// From DMO_OUTPUT_STREAM_INFO_FLAGS
/// </summary>
[Flags]
public enum DMOOutputStreamInfo
{
None = 0x0,
WholeSamples = 0x1,
SingleSamplePerBuffer = 0x2,
FixedSampleSize = 0x4,
Discardable = 0x8,
Optional = 0x10
}
/// <summary>
/// From _DMO_SET_TYPE_FLAGS
/// </summary>
[Flags]
public enum DMOSetType
{
None = 0x0,
TestOnly = 0x1,
Clear = 0x2
}
/// <summary>
/// From DMO_INPUT_STATUS_FLAGS
/// </summary>
[Flags]
public enum DMOInputStatusFlags
{
None = 0x0,
AcceptData = 0x1
}
/// <summary>
/// From DMO_VIDEO_OUTPUT_STREAM_FLAGS
/// </summary>
[Flags]
public enum DMOVideoOutputStream
{
None = 0x0,
NeedsPreviousSample = 0x1
}
/// <summary>
/// From DMO_PARTIAL_MEDIATYPE
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct DMOPartialMediatype
{
public Guid type;
public Guid subtype;
}
/// <summary>
/// From DMO_OUTPUT_DATA_BUFFER
/// </summary>
[StructLayout(LayoutKind.Sequential, Pack=8)]
public struct DMOOutputDataBuffer
{
[MarshalAs(UnmanagedType.Interface)]
public IMediaBuffer pBuffer;
public DMOOutputDataBufferFlags dwStatus;
public long rtTimestamp;
public long rtTimelength;
}
#endregion
#region GUIDS
sealed public class DMOCategory
{
private DMOCategory()
{
// Prevent people from trying to instantiate this class
}
/// <summary> DMOCATEGORY_AUDIO_DECODER </summary>
public static readonly Guid AudioDecoder = new Guid(0x57f2db8b, 0xe6bb, 0x4513, 0x9d, 0x43, 0xdc, 0xd2, 0xa6, 0x59, 0x31, 0x25);
/// <summary> DMOCATEGORY_AUDIO_ENCODER </summary>
public static readonly Guid AudioEncoder = new Guid(0x33D9A761, 0x90C8, 0x11d0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
/// <summary> DMOCATEGORY_VIDEO_DECODER </summary>
public static readonly Guid VideoDecoder = new Guid(0x4a69b442, 0x28be, 0x4991, 0x96, 0x9c, 0xb5, 0x00, 0xad, 0xf5, 0xd8, 0xa8);
/// <summary> DMOCATEGORY_VIDEO_ENCODER </summary>
public static readonly Guid VideoEncoder = new Guid(0x33D9A760, 0x90C8, 0x11d0, 0xBD, 0x43, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86);
/// <summary> DMOCATEGORY_AUDIO_EFFECT </summary>
public static readonly Guid AudioEffect = new Guid(0xf3602b3f, 0x0592, 0x48df, 0xa4, 0xcd, 0x67, 0x47, 0x21, 0xe7, 0xeb, 0xeb);
/// <summary> DMOCATEGORY_VIDEO_EFFECT </summary>
public static readonly Guid VideoEffect = new Guid(0xd990ee14, 0x776c, 0x4723, 0xbe, 0x46, 0x3d, 0xa2, 0xf5, 0x6f, 0x10, 0xb9);
/// <summary> DMOCATEGORY_AUDIO_CAPTURE_EFFECT </summary>
public static readonly Guid AudioCaptureEffect = new Guid(0xf665aaba, 0x3e09, 0x4920, 0xaa, 0x5f, 0x21, 0x98, 0x11, 0x14, 0x8f, 0x09);
}
#endregion
#region API Declares
sealed public class DMOUtils
{
[DllImport("msdmo.dll")]
public static extern int DMOEnum(
[MarshalAs(UnmanagedType.LPStruct)] Guid DMOCategory,
DMOEnumerator dwFlags,
int cInTypes,
[In] DMOPartialMediatype [] pInTypes,
int cOutTypes,
[In] DMOPartialMediatype [] pOutTypes,
out IEnumDMO ppEnum
);
[DllImport("msdmo.dll")]
public static extern int MoInitMediaType(
[Out] DirectShowLib.AMMediaType pmt,
int i
);
[DllImport("msdmo.dll")]
public static extern int MoCopyMediaType(
[Out, MarshalAs(UnmanagedType.LPStruct)] AMMediaType dst,
[In, MarshalAs(UnmanagedType.LPStruct)] AMMediaType src
);
[DllImport("MSDmo.dll")]
static extern public int DMORegister(
[MarshalAs(UnmanagedType.LPWStr)] string szName,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid clsidDMO,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid DMOCategory,
DMORegisterFlags dwFlags,
int cInTypes,
[In] DMOPartialMediatype [] pInTypes,
int cOutTypes,
[In] DMOPartialMediatype [] pOutTypes
);
[DllImport("MSDmo.dll")]
static extern public int DMOUnregister(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid clsidDMO,
[In, MarshalAs(UnmanagedType.LPStruct)] Guid guidCategory
);
[DllImport("MSDmo.dll")]
static extern public int DMOGetName(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid clsidDMO,
[Out, MarshalAs(UnmanagedType.LPWStr, SizeConst=80)] StringBuilder szName
);
[DllImport("MSDmo.dll")]
static extern public int DMOGetTypes(
[In, MarshalAs(UnmanagedType.LPStruct)] Guid clsidDMO,
int ulInputTypesRequested,
out int pulInputTypesSupplied,
[Out] DMOPartialMediatype [] pInTypes,
int ulOutputTypesRequested,
out int pulOutputTypesSupplied,
[Out] DMOPartialMediatype [] pOutTypes
);
private DMOUtils()
{
}
}
#endregion
#region Utility Classes
sealed public class DMOResults
{
private DMOResults()
{
// Prevent people from trying to instantiate this class
}
public const int E_InvalidStreamIndex = unchecked((int)0x80040201);
public const int E_InvalidType = unchecked((int)0x80040202);
public const int E_TypeNotSet = unchecked((int)0x80040203);
public const int E_NotAccepting = unchecked((int)0x80040204);
public const int E_TypeNotAccepted = unchecked((int)0x80040205);
public const int E_NoMoreItems = unchecked((int)0x80040206);
}
sealed public class DMOError
{
private DMOError()
{
// Prevent people from trying to instantiate this class
}
public static string GetErrorText(int hr)
{
string sRet = null;
switch(hr)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -