コード例 #1
0
ファイル: IMediaObjectImpl.cs プロジェクト: adambyram/pimaker
            public void DefineParam(int iParamNum, ParamInfo p, string sText)
            {
                Debug.Assert(iParamNum < Parms.Length && iParamNum >= 0, "Invalid parameter index");

                Parms[iParamNum] = p;
                Envelopes[iParamNum] = new MPEnvelopes(p.mpdNeutralValue, p.mopCaps, p.mpType, p.mpdMaxValue, p.mpdMaxValue);
                ParamText[iParamNum] = sText;
            }
コード例 #2
0
ファイル: ParamClass.cs プロジェクト: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // Public methods                                                            //
    ///////////////////////////////////////////////////////////////////////////////
    #region PUBLICMETHODS

    /// <summary>
    /// Defines a new param.
    /// </summary>
    /// <param name="paramNum">The zero based index of the param to set.</param>
    /// <param name="paramInfo">The <see cref="ParamInfo"/> for this parameter</param>
    /// <param name="text">The descriptive string.</param>
    public void DefineParam(int paramNum, ParamInfo paramInfo, string text)
    {
      Debug.Assert(paramNum < this.Parms.Length && paramNum >= 0, "Invalid parameter index");

      this.Parms[paramNum] = paramInfo;
      this.Envelopes[paramNum] = new MPEnvelopes(paramInfo.mpdNeutralValue, paramInfo.mopCaps, paramInfo.mpType, paramInfo.mpdMaxValue, paramInfo.mpdMaxValue);
      this.ParamText[paramNum] = text;
    }
コード例 #3
0
ファイル: IMediaObjectImpl.cs プロジェクト: adambyram/pimaker
        /// <summary>
        /// COM entry point for IMediaParamInfo.GetParamInfo
        /// </summary>
        /// <remarks>
        /// There should be no need to modify or override this method.  See 
        /// <see cref="IMediaObjectImpl.ParamDefine"/> and <see cref="IMediaObjectImpl.ParamCalcValueForTime"/>
        /// for details about how this works.
        /// </remarks>
        public int GetParamInfo(int dwParamIndex, out ParamInfo pInfo)
        {
            int hr;

            try
            {
                m_Log.Write("GetParamInfo\r\n");
                lock(this)
                {
                    // If the parameter is in range, return the ParamInfo
                    if (dwParamIndex < m_Params.Parms.Length)
                    {
                        pInfo = m_Params.Parms[dwParamIndex];
                        hr = S_OK;
                    }
                    else
                    {
                        pInfo = new ParamInfo();
                        hr = E_INVALIDARG;
                    }
                }
            }
            catch (Exception e)
            {
                // Generic handling of all exceptions.  While .NET will turn exceptions into
                // HRESULTS "automatically", I prefer to have some place I can set a breakpoint.
                hr = CatFail(e);

                // Have to have this to make the compiler happy.
                pInfo = new ParamInfo();
            }

            return hr;
        }
コード例 #4
0
ファイル: IMediaObjectImpl.cs プロジェクト: adambyram/pimaker
 /// <summary>
 /// Create a definition for a parameter that is accessible thru IMediaParamInfo
 /// and IMediaParams.
 /// </summary>
 /// <param name="iParamNum">Zero based parameter number to set the definition for</param>
 /// <param name="p">Populated ParamInfo struct</param>
 /// <param name="sText">Format string (described in MSDN under IMediaParamInfo::GetParamText)</param>
 /// <remarks>
 /// This method should be called from the constructor of the class that implements IMediaObjectImpl.  It
 /// defines a single parameter that can be set on the DMO.  You must call it once for each of the
 /// parameters defined in the call to the IMediaObjectImpl constructor.  This allows for automatic
 /// support of the IMediaParamInfo and IMediaParams methods.  See the 
 /// <see cref="IMediaObjectImpl.ParamCalcValueForTime"/> for additional details.
 /// </remarks>
 protected void ParamDefine(int iParamNum, ParamInfo p, string sText)
 {
     m_Params.DefineParam(iParamNum, p, sText);
 }
コード例 #5
0
ファイル: DmoMixer.cs プロジェクト: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the DmoMixer class.  
    /// The parameters to the base class
    /// describe the number of input and output streams, which
    /// DirectShow calls Pins, followed by the number of parameters
    /// this class supports (can be zero), and the timeformat of those
    /// parameters (should include ParamClass.TimeFormatFlags.Reference
    /// if NumParameters > 0).
    /// </summary>
    public DmoMixer()
      : base(InputPinCount, OutputPinCount, NumParams, TimeFormatFlags.Reference)
    {
      // Initialize the data members
      this.bufferFlags = 0;
      this.inputStreams = new VideoStream[InputPinCount];

      for (int i = 0; i < InputPinCount; i++)
      {
        this.inputStreams[i] = new VideoStream();
      }

      this.outputStream = new VideoStream();

      // Start describing the parameters this DMO supports.  Building this
      // structure (painful as it is) will allow the base class to automatically
      // support IMediaParamInfo & IMediaParams, which allow clients to find
      // out what parameters you support, and to set them.

      // See the MSDN
      // docs for MP_PARAMINFO for a description of the other parameters
      ParamInfo backgroundColor = new ParamInfo();
      backgroundColor.mopCaps = MPCaps.Jump;
      backgroundColor.mpdMinValue.vInt = int.MinValue;
      backgroundColor.mpdMaxValue.vInt = int.MaxValue;
      backgroundColor.mpdNeutralValue.vInt = 0;
      backgroundColor.mpType = MPType.INT;
      backgroundColor.szLabel = "BackgroundColor";
      backgroundColor.szUnitText = "Color";

      ParamDefine(0, backgroundColor, "BackgroundColor\0Color\0");

      for (int i = 0; i < InputPinCount; i++)
      {
        ParamInfo streamLeft = new ParamInfo();
        streamLeft.mopCaps = MPCaps.Jump;
        streamLeft.mpdMinValue.vFloat = 0;
        streamLeft.mpdMaxValue.vFloat = 1;
        streamLeft.mpdNeutralValue.vFloat = 0;
        streamLeft.mpType = MPType.FLOAT;
        streamLeft.szLabel = "Stream" + i.ToString() + "Left";
        streamLeft.szUnitText = "Position";

        ParamInfo streamTop = new ParamInfo();
        streamTop.mopCaps = MPCaps.Jump;
        streamTop.mpdMinValue.vFloat = 0;
        streamTop.mpdMaxValue.vFloat = 1;
        streamTop.mpdNeutralValue.vFloat = 0;
        streamTop.mpType = MPType.FLOAT;
        streamTop.szLabel = "Stream" + i.ToString() + "Top";
        streamTop.szUnitText = "Position";

        ParamInfo streamWidth = new ParamInfo();
        streamWidth.mopCaps = MPCaps.Jump;
        streamWidth.mpdMinValue.vFloat = 0;
        streamWidth.mpdMaxValue.vFloat = 1;
        streamWidth.mpdNeutralValue.vFloat = 1;
        streamWidth.mpType = MPType.FLOAT;
        streamWidth.szLabel = "Stream" + i.ToString() + "Width";
        streamWidth.szUnitText = "Position";

        ParamInfo streamHeight = new ParamInfo();
        streamHeight.mopCaps = MPCaps.Jump;
        streamHeight.mpdMinValue.vFloat = 0;
        streamHeight.mpdMaxValue.vFloat = 1;
        streamHeight.mpdNeutralValue.vFloat = 1;
        streamHeight.mpType = MPType.FLOAT;
        streamHeight.szLabel = "Stream" + i.ToString() + "Height";
        streamHeight.szUnitText = "Position";

        ParamInfo streamAlpha = new ParamInfo();
        streamAlpha.mopCaps = MPCaps.Jump;
        streamAlpha.mpdMinValue.vFloat = 0;
        streamAlpha.mpdMaxValue.vFloat = 1;
        streamAlpha.mpdNeutralValue.vFloat = 1;
        streamAlpha.mpType = MPType.FLOAT;
        streamAlpha.szLabel = "Stream" + i.ToString() + "Alpha";
        streamAlpha.szUnitText = "Alpha";

        ParamDefine((i * 5) + 1, streamLeft, "Stream" + i.ToString() + "Left\0Position\0");
        ParamDefine((i * 5) + 2, streamTop, "Stream" + i.ToString() + "Top\0Position\0");
        ParamDefine((i * 5) + 3, streamWidth, "Stream" + i.ToString() + "Width\0Position\0");
        ParamDefine((i * 5) + 4, streamHeight, "Stream" + i.ToString() + "Height\0Position\0");
        ParamDefine((i * 5) + 5, streamAlpha, "Stream" + i.ToString() + "Alpha\0Alpha\0");
      }
    }
コード例 #6
0
ファイル: DmoFlip.cs プロジェクト: OmerMor/DirectShowLib-FORK
        /// <summary>
        /// The constructor.  The parameters to the base class
        /// describe the number of input and output streams, which
        /// DirectShow calls Pins, followed by the number of parameters
        /// this class supports (can be zero), and the timeformat of those
        /// parameters (should include ParamClass.TimeFormatFlags.Reference
        /// if NumParameters > 0).
        /// </summary>
        public DmoFlip()
            : base(InputPinCount, OutputPinCount, NumParams, TimeFormatFlags.Reference)
        {
            m_Log.Write("Constructor\r\n");

            // Initialize the data members
            m_Width = 0;
            m_Height = 0;
            m_Stride = 0;
            m_BPP = 0;
            m_TimeStamp = 0;
            m_TimeLength = 0;
            m_cbInData = 0;
            m_Flags = 0;
            m_InBuffer = IntPtr.Zero;
            m_pBuffer = null;

            // Start describing the parameters this DMO supports.  Building this
            // structure (painful as it is) will allow the base class to automatically
            // support IMediaParamInfo & IMediaParams, which allow clients to find
            // out what parameters you support, and to set them.

            // Our parameter has a minimum value of zero, and a max of
            // FlipMode.LAST, and a default of DEFAULTMODE;  See the MSDN
            // docs for MP_PARAMINFO for a description of the other parameters
            ParamInfo p = new ParamInfo();

            p.mopCaps = MPCaps.Jump;
            p.mpdMinValue.vInt = 0;
            p.mpdMaxValue.vInt = (int)FlipMode.LAST;
            p.mpdNeutralValue.vInt = (int)DEFAULTMODE;
            p.mpType = MPType.ENUM;
            p.szLabel = "";
            p.szUnitText = "FlipMode";

            // Parameter #0, using the struct, and a format string (described in MSDN
            // under IMediaParamInfo::GetParamText).  Note that when marshaling strings,
            // .NET will add another \0
            ParamDefine(0, p, "FlipMode\0\0None\0FlipY\0FlipX\0FlipY|FlipX\0");
        }
コード例 #7
0
ファイル: DmoOverlay.cs プロジェクト: DeSciL/Ogama
    ///////////////////////////////////////////////////////////////////////////////
    // Construction and Initializing methods                                     //
    ///////////////////////////////////////////////////////////////////////////////
    #region CONSTRUCTION

    /// <summary>
    /// Initializes a new instance of the DmoOverlay class.  
    /// The parameters to the base class
    /// describe the number of input and output streams, which
    /// DirectShow calls Pins, followed by the number of parameters
    /// this class supports (can be zero), and the timeformat of those
    /// parameters (should include ParamClass.TimeFormatFlags.Reference
    /// if NumParameters > 0).
    /// </summary>
    public DmoOverlay()
      : base(InputPinCount, OutputPinCount, NumParams, TimeFormatFlags.Reference)
    {
      // Initialize the data members
      this.streamWidth = 0;
      this.streamHeight = 0;
      this.streamStride = 0;
      this.streamBBP = 0;
      this.bufferTimeStamp = 0;
      this.bufferTimeLength = 0;
      this.bufferByteCount = 0;
      this.bufferFlags = 0;
      this.bufferPointer = IntPtr.Zero;
      this.buffer = null;

      // Start describing the parameters this DMO supports.  Building this
      // structure (painful as it is) will allow the base class to automatically
      // support IMediaParamInfo & IMediaParams, which allow clients to find
      // out what parameters you support, and to set them.

      // See the MSDN
      // docs for MP_PARAMINFO for a description of the other parameters
      ParamInfo gazeX = new ParamInfo();
      gazeX.mopCaps = MPCaps.Jump;
      gazeX.mpdMinValue.vInt = 0;
      gazeX.mpdMaxValue.vInt = 2000;
      gazeX.mpdNeutralValue.vInt = 1;
      gazeX.mpType = MPType.INT;
      gazeX.szLabel = "GazeX";
      gazeX.szUnitText = "Pixel";

      ParamInfo gazeY = new ParamInfo();
      gazeY.mopCaps = MPCaps.Jump;
      gazeY.mpdMinValue.vInt = 0;
      gazeY.mpdMaxValue.vInt = 2000;
      gazeY.mpdNeutralValue.vInt = 1;
      gazeY.mpType = MPType.INT;
      gazeY.szLabel = "GazeY";
      gazeY.szUnitText = "Pixel";

      ParamInfo mouseX = new ParamInfo();
      mouseX.mopCaps = MPCaps.Jump;
      mouseX.mpdMinValue.vInt = 0;
      mouseX.mpdMaxValue.vInt = 2000;
      mouseX.mpdNeutralValue.vInt = 1;
      mouseX.mpType = MPType.INT;
      mouseX.szLabel = "MouseX";
      mouseX.szUnitText = "Pixel";

      ParamInfo mouseY = new ParamInfo();
      mouseY.mopCaps = MPCaps.Jump;
      mouseY.mpdMinValue.vInt = 0;
      mouseY.mpdMaxValue.vInt = 2000;
      mouseY.mpdNeutralValue.vInt = 1;
      mouseY.mpType = MPType.INT;
      mouseY.szLabel = "MouseY";
      mouseY.szUnitText = "Pixel";

      // Parameter #0, using the struct, and a format string (described in MSDN
      // under IMediaParamInfo::GetParamText).  Note that when marshaling strings,
      // .NET will add another \0
      ParamDefine(0, gazeX, "GazeX\0Pixel\0");
      ParamDefine(1, gazeY, "GazeY\0Pixel\0");
      ParamDefine(2, mouseX, "MouseX\0Pixel\0");
      ParamDefine(3, mouseY, "MouseY\0Pixel\0");

      // Initialize the buffers for the gaze and mouse cursor overlay bitmaps.
      Bitmap circleBitmap = (Bitmap)Properties.Resources.Circle;
      Rectangle circleRect = new Rectangle(0, 0, circleBitmap.Width, circleBitmap.Height);
      this.gazeCursorSize = circleRect.Size;
      this.gazeCursorData = circleBitmap.LockBits(circleRect, ImageLockMode.ReadOnly, circleBitmap.PixelFormat);

      // Get the address of the first line.
      IntPtr gazeCursorScan0Pointer = this.gazeCursorData.Scan0;

      // Declare an array to hold the bytes of the bitmap.
      int gazeCursorBytes = this.gazeCursorData.Stride * this.gazeCursorData.Height;
      this.gazeCursorArgbValues = new byte[gazeCursorBytes];

      // Copy the RGB values into the array.
      Marshal.Copy(gazeCursorScan0Pointer, this.gazeCursorArgbValues, 0, gazeCursorBytes);

      Bitmap arrowBitmap = Properties.Resources.Arrow;
      Rectangle cursorRect = new Rectangle(0, 0, arrowBitmap.Width, arrowBitmap.Height);
      this.mouseCursorSize = cursorRect.Size;
      this.mouseCursorData = arrowBitmap.LockBits(cursorRect, ImageLockMode.ReadOnly, arrowBitmap.PixelFormat);

      // Get the address of the first line.
      IntPtr mouseCursorScan0Pointer = this.mouseCursorData.Scan0;

      // Declare an array to hold the bytes of the bitmap.
      int mouseCursorBytes = this.mouseCursorData.Stride * this.mouseCursorData.Height;
      this.mouseCursorArgbValues = new byte[mouseCursorBytes];

      // Copy the RGB values into the array.
      Marshal.Copy(mouseCursorScan0Pointer, this.mouseCursorArgbValues, 0, mouseCursorBytes);
    }
コード例 #8
0
ファイル: IMediaObjectImpl.cs プロジェクト: DeSciL/Ogama
 /// <summary>
 /// Create a definition for a parameter that is accessible thru IMediaParamInfo
 /// and IMediaParams.
 /// </summary>
 /// <param name="paramNum">Zero based parameter number to set the definition for</param>
 /// <param name="p">Populated ParamInfo struct</param>
 /// <param name="text">Format string (described in MSDN under IMediaParamInfo::GetParamText)</param>
 /// <remarks>
 /// This method should be called from the constructor of the class that implements IMediaObjectImpl.  It
 /// defines a single parameter that can be set on the DMO.  You must call it once for each of the
 /// parameters defined in the call to the IMediaObjectImpl constructor.  This allows for automatic
 /// support of the IMediaParamInfo and IMediaParams methods.  See the 
 /// <see cref="IMediaObjectImpl.ParamCalcValueForTime"/> for additional details.
 /// </remarks>
 protected void ParamDefine(int paramNum, ParamInfo p, string text)
 {
   this.paramsClass.DefineParam(paramNum, p, text);
 }
コード例 #9
0
ファイル: IMediaObjectImpl.cs プロジェクト: DeSciL/Ogama
    /// <summary>
    /// COM entry point for IMediaParamInfo.GetParamInfo
    /// </summary>
    /// <param name="paramIndex">[in] Zero-based index of the parameter.</param>
    /// <param name="info">[out] Pointer to an <see cref="ParamInfo"/> structure
    /// that is filled with the parameter information.</param>
    /// <returns>Returns an HRESULT value.</returns>
    /// <remarks>
    /// There should be no need to modify or override this method.  See 
    /// <see cref="IMediaObjectImpl.ParamDefine"/> and <see cref="IMediaObjectImpl.ParamCalcValueForTime"/>
    /// for details about how this works.
    /// </remarks>
    public int GetParamInfo(int paramIndex, out ParamInfo info)
    {
      int hr;

      try
      {
        lock (this)
        {
          // If the parameter is in range, return the ParamInfo
          if (paramIndex < this.paramsClass.Parms.Length)
          {
            info = this.paramsClass.Parms[paramIndex];
            hr = SOK;
          }
          else
          {
            info = new ParamInfo();
            hr = EINVALIDARG;
          }
        }
      }
      catch (Exception e)
      {
        // Generic handling of all exceptions.  While .NET will turn exceptions into
        // HRESULTS "automatically", I prefer to have some place I can set a breakpoint.
        hr = this.CatFail(e);

        // Have to have this to make the compiler happy.
        info = new ParamInfo();
      }

      return hr;
    }