⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 des.cs

📁 DirectShowLibV1-5針對DirectShow一些函數以及指令和LIB的檔案
💻 CS
📖 第 1 页 / 共 4 页
字号:
#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;
using DirectShowLib;
using System.Text;

namespace DirectShowLib.DES
{
    #region Utility Classes

    sealed public class DESResults
    {
        private DESResults()
        {
            // Prevent people from trying to instantiate this class
        }

        public const int E_NotInTree = unchecked((int)0x80040400);
        public const int E_RenderEngineIsBroken = unchecked((int)0x80040401);
        public const int E_MustInitRenderer = unchecked((int)0x80040402);
        public const int E_NotDetermind = unchecked((int)0x80040403);
        public const int E_NoTimeline = unchecked((int)0x80040404);
        public const int S_WarnOutputReset = unchecked((int)40404);
    }


    sealed public class DESError
    {
        private DESError()
        {
            // Prevent people from trying to instantiate this class
        }

        public static string GetErrorText(int hr)
        {
            string sRet = null;

            switch(hr)
            {
                case DESResults.E_NotInTree:
                    sRet = "The object is not contained in the timeline.";
                    break;
                case DESResults.E_RenderEngineIsBroken:
                    sRet = "Operation failed because project was not rendered successfully.";
                    break;
                case DESResults.E_MustInitRenderer:
                    sRet = "Render engine has not been initialized.";
                    break;
                case DESResults.E_NotDetermind:
                    sRet = "Cannot determine requested value.";
                    break;
                case DESResults.E_NoTimeline:
                    sRet = "There is no timeline object.";
                    break;
                case DESResults.S_WarnOutputReset:
                    sRet = "The rendering portion of the graph was deleted. The application must rebuild it.";
                    break;
                default:
                    sRet = DsError.GetErrorText(hr);
                    break;
            }

            return sRet;
        }

        /// <summary>
        /// If hr has a "failed" status code (E_*), throw an exception.  Note that status
        /// messages (S_*) are not considered failure codes.  If DES or DShow error text
        /// is available, it is used to build the exception, otherwise a generic com error
        /// is thrown.
        /// </summary>
        /// <param name="hr">The HRESULT to check</param>
        public static void ThrowExceptionForHR(int hr)
        {
            // If an error has occurred
            if (hr < 0)
            {
                // If a string is returned, build a com error from it
                string buf = GetErrorText(hr);

                if (buf != null)
                {
                    throw new COMException(buf, hr);
                }
                else
                {
                    // No string, just use standard com error
                    Marshal.ThrowExceptionForHR(hr);
                }
            }
        }
    }


    #endregion

    #region Classes

    /// <summary>
    /// From CLSID_AMTimeline
    /// </summary>
    [ComImport, Guid("78530B75-61F9-11D2-8CAD-00A024580902")]
    public class AMTimeline
    {
    }

    /// <summary>
    /// From CLSID_PropertySetter
    /// </summary>
    [ComImport, Guid("ADF95821-DED7-11d2-ACBE-0080C75E246E")]
    public class PropertySetter
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineObj
    /// </summary>
    [ComImport, Guid("78530B78-61F9-11D2-8CAD-00A024580902")]
    public class AMTimelineObj
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineSrc
    /// </summary>
    [ComImport, Guid("78530B7A-61F9-11D2-8CAD-00A024580902")]
    public class AMTimelineSrc
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineTrack
    /// </summary>
    [ComImport, Guid("8F6C3C50-897B-11d2-8CFB-00A0C9441E20")]
    public class AMTimelineTrack
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineComp
    /// </summary>
    [ComImport, Guid("74D2EC80-6233-11d2-8CAD-00A024580902")]
    public class AMTimelineComp
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineGroup
    /// </summary>
    [ComImport, Guid("F6D371E1-B8A6-11d2-8023-00C0DF10D434")]
    public class AMTimelineGroup
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineTrans
    /// </summary>
    [ComImport, Guid("74D2EC81-6233-11d2-8CAD-00A024580902")]
    public class AMTimelineTrans
    {
    }

    /// <summary>
    /// From CLSID_AMTimelineEffect
    /// </summary>
    [ComImport, Guid("74D2EC82-6233-11d2-8CAD-00A024580902")]
    public class AMTimelineEffect
    {
    }

    /// <summary>
    /// From CLSID_RenderEngine
    /// </summary>
    [ComImport, Guid("64D8A8E0-80A2-11d2-8CF3-00A0C9441E20")]
    public class RenderEngine
    {
    }

    /// <summary>
    /// From CLSID_SmartRenderEngine
    /// </summary>
    [ComImport, Guid("498B0949-BBE9-4072-98BE-6CCAEB79DC6F")]
    public class SmartRenderEngine
    {
    }

    /// <summary>
    /// From CLSID_AudMixer
    /// </summary>
    [ComImport, Guid("036A9790-C153-11d2-9EF7-006008039E37")]
    public class AudMixer
    {
    }

    /// <summary>
    /// From CLSID_Xml2Dex
    /// </summary>
    [ComImport, Guid("18C628EE-962A-11D2-8D08-00A0C9441E20")]
    public class Xml2Dex
    {
    }

    /// <summary>
    /// From CLSID_MediaLocator
    /// </summary>
    [ComImport, Guid("CC1101F2-79DC-11D2-8CE6-00A0C9441E20")]
    public class MediaLocator
    {
    }

    /// <summary>
    /// From CLSID_MediaDet
    /// </summary>
    [ComImport, Guid("65BD0711-24D2-4ff7-9324-ED2E5D3ABAFA")]
    public class MediaDet
    {
    }

    /// <summary>
    /// From CLSID_DxtCompositor
    /// </summary>
    [ComImport, Guid("BB44391D-6ABD-422f-9E2E-385C9DFF51FC")]
    public class DxtCompositor
    {
    }

    /// <summary>
    /// From CLSID_DxtAlphaSetter
    /// </summary>
    [ComImport, Guid("506D89AE-909A-44f7-9444-ABD575896E35")]
    public class DxtAlphaSetter
    {
    }

    /// <summary>
    /// From CLSID_DxtJpeg
    /// </summary>
    [ComImport, Guid("DE75D012-7A65-11D2-8CEA-00A0C9441E20")]
    public class DxtJpeg
    {
    }

    /// <summary>
    /// From CLSID_ColorSource
    /// </summary>
    [ComImport, Guid("0cfdd070-581a-11d2-9ee6-006008039e37")]
    public class ColorSource
    {
    }

    /// <summary>
    /// From CLSID_DxtKey
    /// </summary>
    [ComImport, Guid("C5B19592-145E-11d3-9F04-006008039E37")]
    public class DxtKey
    {
    }


    #endregion

    #region Declarations

#if ALLOW_UNTESTED_INTERFACES

    /// <summary>
    /// From unnamed enum
    /// </summary>
    public enum DXTKeys
    {
        RGB,
        NonRed,
        Luminance,
        Alpha,
        Hue
    }


#endif

    /// <summary>
    /// From TIMELINE_MAJOR_TYPE
    /// </summary>
    [Flags]
    public enum TimelineMajorType
    {
        None = 0,
        Composite = 1,
        Effect = 0x10,
        Group = 0x80,
        Source = 4,
        Track= 2,
        Transition = 8
    }


    /// <summary>
    /// From unnamed enum
    /// </summary>
    public enum TimelineInsertMode
    {
        Insert = 1,
        Overlay = 2
    }


    /// <summary>
    /// From unnamed enum
    /// </summary>
    [Flags]
    public enum SFNValidateFlags
    {
        None         = 0x00000000,
        Check        = 0x00000001,
        Popup        = 0x00000002,
        TellMe       = 0x00000004,
        Replace      = 0x00000008,
        UseLocal     = 0x000000010,
        NoFind       = 0x000000020,
        IgnoreMuted  = 0x000000040,
        End
    }


    /// <summary>
    /// From SCompFmt0
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack=4)]
    public class SCompFmt0
    {
        public int nFormatId;
        public AMMediaType MediaType;
    }


    /// <summary>
    /// From unnamed enum
    /// </summary>
    public enum ResizeFlags
    {
        Stretch,
        Crop,
        PreserveAspectRatio,
        PreserveAspectRatioNoLetterBox
    }


    /// <summary>
    /// From DEXTERF_TRACK_SEARCH_FLAGS
    /// </summary>
    public enum DexterFTrackSearchFlags
    {
        Bounding = -1,
        ExactlyAt = 0,
        Forwards = 1
    }


    /// <summary>
    /// From DEXTER_PARAM
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack=4)]
    public struct DexterParam
    {
        [MarshalAs(UnmanagedType.BStr)]  public string Name;
        public int dispID;
        public int nValues;
    }


    /// <summary>
    /// From unnamed enum
    /// </summary>
    public enum ConnectFDynamic
    {
        None = 0x00000000,
        Sources = 0x00000001,
        Effects = 0x00000002
    }


    /// <summary>
    /// From DEXTER_VALUE
    /// </summary>
    [StructLayout(LayoutKind.Sequential, Pack=8)]
    public struct DexterValue
    {
        [MarshalAs(UnmanagedType.Struct)] public object v;
        public long rt;
        public Dexterf dwInterp;
    }


    /// <summary>
    /// From DEXTERF
    /// </summary>
    public enum Dexterf
    {
        Jump,
        Interpolate
    }


    /// <summary>
    /// From DEX_IDS_* defines
    /// </summary>
    public enum DESErrorCode
    {
        BadSourceName = 1400,
        BadSourceName2 = 1401,
        MissingSourceName = 1402,
        UnknownSource = 1403,
        InstallProblem = 1404,
        NoSourceNames = 1405,
        BadMediaType = 1406,
        StreamNumber = 1407,
        OutOfMemory = 1408,
        DIBSeqNotAllSame = 1409,
        ClipTooShort = 1410,
        InvalidDXT = 1411,
        InvalidDefaultDXTT = 1412,
        No3D = 1413,
        BrokenDXT = 1414,
        NoSuchProperty = 1415,
        IllegalPropertyVal = 1416,
        InvalidXML = 1417,
        CantFindFilter = 1418,
        DiskWriteError = 1419,
        InvalidAudioFX = 1420,
        CantFindCompressor = 1421,
        TimelineParse = 1426,
        GraphError = 1427,
        GridError = 1428,
        InterfaceError = 1429
    }


    #endregion

    #region Interfaces

#if ALLOW_UNTESTED_INTERFACES

    [ComImport,
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
    Guid("E31FB81B-1335-11D1-8189-0000F87557DB")]
    public interface IDXEffect
    {
        [PreserveSig]
        int get_Capabilities(
            out int pVal
            );

        [PreserveSig]
        int get_Progress(
            out float pVal
            );

        [PreserveSig]
        int put_Progress(
            float newVal
            );

        [PreserveSig]
        int get_StepResolution(
            out float pVal
            );

        [PreserveSig]
        int get_Duration(
            out float pVal
            );

        [PreserveSig]
        int put_Duration(
            float newVal
            );
    }

    [ComImport,
    Guid("4EE9EAD9-DA4D-43D0-9383-06B90C08B12B"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IDxtAlphaSetter : IDXEffect
    {
        #region IDXEffect Methods

        [PreserveSig]
        new int get_Capabilities(
            out int pVal
            );

        [PreserveSig]
        new int get_Progress(
            out float pVal
            );

        [PreserveSig]
        new int put_Progress(
            float newVal
            );

        [PreserveSig]
        new int get_StepResolution(
            out float pVal
            );

        [PreserveSig]
        new int get_Duration(
            out float pVal
            );

        [PreserveSig]
        new int put_Duration(
            float newVal
            );

        #endregion

        [PreserveSig]
        int get_Alpha(
            out int pVal
            );

        [PreserveSig]
        int put_Alpha(
            int newVal
            );

        [PreserveSig]
        int get_AlphaRamp(
            out double pVal
            );

        [PreserveSig]
        int put_AlphaRamp(
            double newVal
            );
    }

    [ComImport,
    Guid("BB44391E-6ABD-422F-9E2E-385C9DFF51FC"),
    InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IDxtCompositor : IDXEffect
    {
        #region IDXEffect

        [PreserveSig]
        new int get_Capabilities(
            out int pVal
            );

        [PreserveSig]
        new int get_Progress(
            out float pVal
            );

        [PreserveSig]
        new int put_Progress(
            float newVal
            );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -