Пример #1
0
        /// <summary>
        /// Creates the parameter connection for the gaze and mouse location
        /// properties of the dmo filter.
        /// </summary>
        /// <param name="dmoWrapperFilter">
        /// The <see cref="IBaseFilter"/> interface
        /// of the dmo wrapper filter.
        /// </param>
        private void SetDMOParams(IBaseFilter dmoWrapperFilter)
        {
            if (dmoWrapperFilter == null)
            {
                return;
            }

            int hr;

            this.dmoParams = dmoWrapperFilter as IMediaParams;

            this.gazeX      = new MPData();
            this.gazeX.vInt = 0;
            hr = this.dmoParams.SetParam(0, this.gazeX);
            DMOError.ThrowExceptionForHR(hr);

            this.gazeY      = new MPData();
            this.gazeY.vInt = 0;
            hr = this.dmoParams.SetParam(1, this.gazeY);
            DMOError.ThrowExceptionForHR(hr);

            this.mouseX      = new MPData();
            this.mouseX.vInt = 0;
            hr = this.dmoParams.SetParam(2, this.mouseX);
            DMOError.ThrowExceptionForHR(hr);

            this.mouseY      = new MPData();
            this.mouseY.vInt = 0;
            hr = this.dmoParams.SetParam(3, this.mouseY);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #2
0
        private void TestFlushEnvelope()
        {
            int hr;

            hr = m_imp.FlushEnvelope(0, 0, long.MaxValue);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #3
0
        private void TestAddEnvelope()
        {
            int hr;

            MPEnvelopeSegment [] pSeg = new MPEnvelopeSegment[2];
            MPData mp1 = new MPData();
            MPData mp2 = new MPData();

            mp1.vFloat = 40;
            mp2.vFloat = 60;

            pSeg[0].flags    = MPFlags.Standard;
            pSeg[0].iCurve   = MPCaps.Jump;
            pSeg[0].rtStart  = 0;
            pSeg[0].rtEnd    = 1000000;
            pSeg[0].valStart = mp1;
            pSeg[0].valEnd   = mp2;

            pSeg[1].flags    = MPFlags.Standard;
            pSeg[1].iCurve   = MPCaps.Jump;
            pSeg[1].rtStart  = 1000001;
            pSeg[1].rtEnd    = 2000000;
            pSeg[1].valStart = mp2;
            pSeg[1].valEnd   = mp1;

            hr = m_imp.AddEnvelope(0, 2, pSeg);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #4
0
        private void TestTime()
        {
            int hr;

            hr = m_imp.SetTimeFormat(MediaParamTimeFormat.Reference, 33);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #5
0
        private void TestOutputType()
        {
            int          hr;
            AMMediaType  pmt  = new AMMediaType();
            AMMediaType  pmt2 = new AMMediaType();
            WaveFormatEx w    = new WaveFormatEx();

            hr = m_imo.GetOutputType(0, 0, pmt);
            Debug.WriteLine(DsToString.AMMediaTypeToString(pmt));

            Marshal.PtrToStructure(pmt.formatPtr, w);
            //pmt.sampleSize = 44100;
            //pmt.fixedSizeSamples = true;

            hr = m_imo.SetOutputType(0, pmt, DMOSetType.Clear);
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imo.SetOutputType(0, pmt, DMOSetType.TestOnly);
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imo.SetOutputType(0, pmt, DMOSetType.None);
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imo.GetOutputCurrentType(0, pmt2);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(pmt2.majorType == pmt.majorType, "GetOutputCurrentType");
        }
Пример #6
0
        private void TestDiscontinuity()
        {
            int hr;

            hr = m_imo.Discontinuity(0);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #7
0
        ///////////////////////////////////////////////////////////////////////////////
        // Small helping Methods                                                     //
        ///////////////////////////////////////////////////////////////////////////////
        #region HELPER

        /// <summary>
        /// Returns the <see cref="Guid"/> for the given filter of
        /// given category.
        /// </summary>
        /// <param name="filterName">Name of the filter to search.</param>
        /// <param name="category">Category of filter to search.</param>
        /// <returns>The <see cref="Guid"/> for the given filter of
        /// given category.</returns>
        private Guid FindGuid(string filterName, Guid category)
        {
            int hr;

            IEnumDMO enumDMO;

            Guid[]   g2 = new Guid[1];
            string[] sn = new string[1];

            hr = DMOUtils.DMOEnum(category, 0, 0, null, 0, null, out enumDMO);
            DMOError.ThrowExceptionForHR(hr);

            try
            {
                do
                {
                    hr = enumDMO.Next(1, g2, sn, IntPtr.Zero);
                }while (hr == 0 && sn[0] != filterName);

                // Handle any serious errors
                DMOError.ThrowExceptionForHR(hr);

                if (hr != 0)
                {
                    throw new Exception("Cannot find " + filterName);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(enumDMO);
            }

            return(g2[0]);
        }
Пример #8
0
        private void TestTimeFormats()
        {
            int  hr;
            int  i;
            Guid g;
            Guid g2;
            int  t;

            hr = m_impi.GetNumTimeFormats(out i);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(i == 1, "GetNumTimeFormats");

            hr = m_impi.GetCurrentTimeFormat(out g, out t);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(g == MediaParamTimeFormat.Reference, "GetCurrentTimeFormat");

            for (int x = 0; x < i; x++)
            {
                hr = m_impi.GetSupportedTimeFormat(x, out g2);
                DMOError.ThrowExceptionForHR(hr);

                Debug.Assert(g2 == MediaParamTimeFormat.Reference, "GetSupportedTimeFormat");
            }
        }
Пример #9
0
        private void TestProcess()
        {
            const int iSize = 44100;

            int         hr;
            int         iCurSize;
            IntPtr      ip;
            AMMediaType pmt = new AMMediaType();

            DMOOutputDataBuffer [] pOutBuf = new DMOOutputDataBuffer[1];

            hr = m_imo.GetInputType(0, 0, pmt);
            hr = m_imo.SetInputType(0, pmt, DMOSetType.None);

            hr = m_imo.GetOutputType(0, 0, pmt);
            hr = m_imo.SetOutputType(0, pmt, DMOSetType.None);

            hr = m_imo.AllocateStreamingResources();
            DMOError.ThrowExceptionForHR(hr);

            DoBuff d = new DoBuff(iSize);

            d.SetLength(iSize);
            d.GetBufferAndLength(out ip, out iCurSize);

            hr = m_imoip.Process(iSize, ip, 0, DMOInplaceProcess.Normal);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #10
0
        /// <summary>
        /// Updates the GazeOverlay DMO filter parameters with the new positions
        /// of the gaze and mouse locations.
        /// </summary>
        /// <param name="gazeLocation">
        /// A <see cref="Point"/> with the new gaze location.
        /// </param>
        /// <param name="mouseLocation">
        /// A <see cref="Point"/> with the new mouse location.
        /// </param>
        public void UpdateDMOParams(Point gazeLocation, Point mouseLocation)
        {
            if (this.dmoParams == null || this.mediaControl == null)
            {
                return;
            }

            int hr;

            this.gazeX.vInt = gazeLocation.X;
            hr = this.dmoParams.SetParam(0, this.gazeX);
            DMOError.ThrowExceptionForHR(hr);

            this.gazeY.vInt = gazeLocation.Y;
            hr = this.dmoParams.SetParam(1, this.gazeY);
            DMOError.ThrowExceptionForHR(hr);

            this.mouseX.vInt = mouseLocation.X;
            hr = this.dmoParams.SetParam(2, this.mouseX);
            DMOError.ThrowExceptionForHR(hr);

            this.mouseY.vInt = mouseLocation.Y;
            hr = this.dmoParams.SetParam(3, this.mouseY);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #11
0
        /// <summary>
        /// Finds the <see cref="Guid"/> for the given
        /// category and object
        /// </summary>
        /// <param name="gn">
        /// A string containing the name of the DMO.
        /// </param>
        /// <param name="cat">
        /// A <see cref="Guid"/> with the dmo category.
        /// </param>
        /// <returns>
        /// The <see cref="Guid"/> of the found DMO.
        /// </returns>
        private Guid FindGuid(string gn, Guid cat)
        {
            int hr;

            IEnumDMO dmoEnum;
            var      g2 = new Guid[1];
            var      sn = new string[1];

            hr = DMOUtils.DMOEnum(cat, 0, 0, null, 0, null, out dmoEnum);
            DMOError.ThrowExceptionForHR(hr);

            try
            {
                do
                {
                    hr = dmoEnum.Next(1, g2, sn, IntPtr.Zero);
                }while (hr == 0 && sn[0] != gn);

                // Handle any serious errors
                DMOError.ThrowExceptionForHR(hr);

                if (hr != 0)
                {
                    throw new Exception("Cannot find " + gn);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(dmoEnum);
            }

            return(g2[0]);
        }
Пример #12
0
        private void TestFlush()
        {
            int hr;

            hr = m_imo.Flush();
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #13
0
        private void TestLatency()
        {
            int  hr;
            long l;

            hr = m_imoip.GetLatency(out l);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #14
0
        private void TestLock()
        {
            int hr;

            hr = m_imo.Lock(false);
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imo.Lock(true);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #15
0
        private void TestGetInputSizeInfo()
        {
            int hr;
            int iSize, iAlign, iLook;

            hr = m_imo.GetInputSizeInfo(0, out iSize, out iLook, out iAlign);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(iSize == 4 && iAlign == 1 && iLook == 0, "GetInputSizeInfo");
        }
Пример #16
0
        private void TestGetStreamCount()
        {
            int hr;
            int iIn, iOut;

            hr = m_imo.GetStreamCount(out iIn, out iOut);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(iIn == 1 && iOut == 1, "GetStreamCount");
        }
Пример #17
0
        private void TestName()
        {
            int           hr;
            StringBuilder sb = new StringBuilder(80);

            hr = DMOUtils.DMOGetName(new Guid("{efe6629c-81f7-4281-bd91-c9d604a95af6}"), sb);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(sb.ToString() == "Chorus", "DMOGetName");
        }
Пример #18
0
        private void TestResources()
        {
            int hr;

            hr = m_imo.AllocateStreamingResources();
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imo.FreeStreamingResources();
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #19
0
        private void TestGetInputStatus()
        {
            int hr;
            DMOInputStatusFlags f;

            hr = m_imo.GetInputStatus(0, out f);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(f == DMOInputStatusFlags.AcceptData, "GetInputStatus");
        }
Пример #20
0
        private void TestGetOutputStreamInfo()
        {
            int hr;
            int iSize, iAlign;

            hr = m_imo.GetOutputSizeInfo(0, out iSize, out iAlign);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(iSize == 4 && iAlign == 1, "GetOutputSizeInfo");
        }
Пример #21
0
        private void TestGetInputStreamInfo()
        {
            int hr;
            DMOInputStreamInfo f;

            hr = m_imo.GetInputStreamInfo(0, out f);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(f == DMOInputStreamInfo.None, "GetInputStreamInfo");
        }
Пример #22
0
        private void TestGetParamCount()
        {
            int hr;
            int i;

            hr = m_impi.GetParamCount(out i);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(i == 7, "GetParamCount");
        }
Пример #23
0
        private void TestParamInfo()
        {
            int       hr;
            ParamInfo pInfo = new ParamInfo();

            hr = m_impi.GetParamInfo(0, out pInfo);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(pInfo.szUnitText == "%", "GetParamInfo");
        }
Пример #24
0
        private void TestRegister()
        {
            int      hr;
            IEnumDMO idmo;
            Guid     g  = Guid.NewGuid();
            Guid     g2 = Guid.NewGuid();

            Debug.WriteLine(g);
            Debug.WriteLine(g2);

            DMOPartialMediatype [] pIn = new DMOPartialMediatype[2];
            pIn[0]         = new DMOPartialMediatype();
            pIn[0].type    = g2;
            pIn[0].subtype = MediaSubType.RGB24;

            pIn[1]         = new DMOPartialMediatype();
            pIn[1].type    = g2;
            pIn[1].subtype = MediaSubType.RGB32;

            DMOPartialMediatype [] pOut = new DMOPartialMediatype[2];
            pOut[0]         = new DMOPartialMediatype();
            pOut[0].type    = g2;
            pOut[0].subtype = MediaSubType.RGB24;

            pOut[1]         = new DMOPartialMediatype();
            pOut[1].type    = g2;
            pOut[1].subtype = MediaSubType.RGB32;

            hr = DMOUtils.DMORegister("asdffdsa", g, DMOCategory.VideoEffect, DMORegisterFlags.None,
                                      pIn.Length,
                                      pIn,
                                      pOut.Length,
                                      pOut
                                      );

            Debug.Assert(hr == 0, "DMORegister");

            DMOPartialMediatype [] tIn = new DMOPartialMediatype[1];
            tIn[0].type    = g2;
            tIn[0].subtype = MediaSubType.RGB32;

            hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.IncludeKeyed, tIn.Length, tIn, 0, null, out idmo);
            DMOError.ThrowExceptionForHR(hr);

            int iCnt1 = CountEm(idmo);

            Debug.Assert(iCnt1 == 1, "DMORegister");

            hr = DMOUtils.DMOUnregister(g, DMOCategory.VideoEffect);
            DMOError.ThrowExceptionForHR(hr);

            int iCnt2 = CountEm(idmo);

            Debug.Assert(iCnt2 == 0, "DMOUnregister");
        }
Пример #25
0
        private void BuildGraph(string sFileName, bool bLeft)
        {
            int               hr;
            IBaseFilter       ibfFile          = null;
            IBaseFilter       ibfFilter        = null;
            IBaseFilter       ibfRender        = null;
            IDMOWrapperFilter dmoWrapperFilter = null;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            graphBuilder = (IFilterGraph2) new FilterGraph();
#if DEBUG
            m_rot = new DsROTEntry(graphBuilder);
#endif

            hr = icgb.SetFiltergraph(graphBuilder);
            DsError.ThrowExceptionForHR(hr);

            // Add a DMO Wrapper Filter
            ibfFilter        = (IBaseFilter) new DMOWrapperFilter();
            dmoWrapperFilter = (IDMOWrapperFilter)ibfFilter;

            // Since I know the guid of the DMO I am looking for, I can do this.
            hr = dmoWrapperFilter.Init(new Guid("{EAB6CBA9-78DD-4ae4-9A69-1CE1C55369F6}"), DMOCategory.AudioEffect);
            DMOError.ThrowExceptionForHR(hr);

            // Add it to the Graph
            hr = graphBuilder.AddFilter(ibfFilter, "DMO Filter");
            DsError.ThrowExceptionForHR(hr);

            ibfRender = (IBaseFilter) new AudioRender();
            hr        = graphBuilder.AddFilter(ibfRender, "Renderer");
            DsError.ThrowExceptionForHR(hr);

            ibfFile = (IBaseFilter) new AsyncReader();
            hr      = graphBuilder.AddFilter(ibfFile, "Reader");
            DsError.ThrowExceptionForHR(hr);

            IFileSourceFilter ifileSink = (IFileSourceFilter)ibfFile;
            hr = ifileSink.Load(sFileName, null);
            DsError.ThrowExceptionForHR(hr);

            hr = icgb.RenderStream(null, null, ibfFile, null, ibfFilter);
            DsError.ThrowExceptionForHR(hr);

            IPin iPin = DsFindPin.ByDirection(ibfFilter, PinDirection.Output, bLeft ? 0 : 1);

            hr = icgb.RenderStream(null, null, iPin, null, ibfRender);
            DsError.ThrowExceptionForHR(hr);

            Marshal.ReleaseComObject(ibfRender);
            Marshal.ReleaseComObject(dmoWrapperFilter);
            Marshal.ReleaseComObject(iPin);
        }
Пример #26
0
        private void TestClone()
        {
            int  hr;
            long l;
            IMediaObjectInPlace pMO;

            hr = m_imoip.Clone(out pMO);
            DMOError.ThrowExceptionForHR(hr);

            hr = pMO.GetLatency(out l);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #27
0
        private void button3_Click(object sender, System.EventArgs e)
        {
            int    hr;
            MPData o;

            hr = m_param.GetParam(0, out o);
            DMOError.ThrowExceptionForHR(hr);

            o.vInt ^= 1;

            hr = m_param.SetParam(0, o);
            DMOError.ThrowExceptionForHR(hr);
        }
Пример #28
0
        private void TestParam()
        {
            int    hr;
            MPData pData = new MPData();

            pData.vFloat = 51;

            hr = m_imp.SetParam(0, pData);
            DMOError.ThrowExceptionForHR(hr);

            hr = m_imp.GetParam(0, out pData);
            DMOError.ThrowExceptionForHR(hr);

            Debug.Assert(pData.vFloat == 51, "GetParam");
        }
Пример #29
0
        private void Configure()
        {
            int hr;

            DMOWrapperFilter  dmoFilter        = new DMOWrapperFilter();
            IDMOWrapperFilter dmoWrapperFilter = (IDMOWrapperFilter)dmoFilter;

            // Chorus - {efe6629c-81f7-4281-bd91-c9d604a95af6}
            // DmoFlip - {7EF28FD7-E88F-45bb-9CDD-8A62956F2D75}
            //hr = dmoWrapperFilter.Init(new Guid("{7EF28FD7-E88F-45bb-9CDD-8A62956F2D75}"), DMOCategory.AudioEffect);
            hr = dmoWrapperFilter.Init(new Guid("{efe6629c-81f7-4281-bd91-c9d604a95af6}"), DMOCategory.AudioEffect);
            DMOError.ThrowExceptionForHR(hr);

            m_impi = dmoWrapperFilter as IMediaParamInfo;
        }
Пример #30
0
        private void junk()
        {
            int      hr;
            IEnumDMO idmo;

            Guid []   g      = new Guid[1];
            string [] sn     = new string[1];
            int       iCount = 0;

            hr = DMOUtils.DMOEnum(Guid.Empty, DMOEnumerator.None, 0, null, 0, null, out idmo);
            DMOError.ThrowExceptionForHR(hr);

            do
            {
                DMOWrapperFilter  dmoFilter        = new DMOWrapperFilter();
                IDMOWrapperFilter dmoWrapperFilter = (IDMOWrapperFilter)dmoFilter;

                hr = idmo.Next(1, g, sn, IntPtr.Zero);
                DMOError.ThrowExceptionForHR(hr);

                if (hr > 0)
                {
                    break;
                }

                hr = dmoWrapperFilter.Init(g[0], Guid.Empty);

                if (hr >= 0)
                {
                    m_impi = dmoWrapperFilter as IMediaParamInfo;
                    if (m_impi != null)
                    {
                        hr = m_impi.GetParamCount(out iCount);
                    }
                    else
                    {
                        iCount = 0;
                    }

                    if (iCount > 0)
                    {
                        Debug.WriteLine(string.Format("{0} {1} {2}", sn[0], iCount, g[0]));
                    }
                }
            } while (iCount >= 0);
        }