Exemplo n.º 1
0
        private void TestCreateStream()
        {
            short s;
            IMFMediaType mt;
            IMFASFStreamConfig pStream, pStream2, pStream3;
            FourCC cc4 = new FourCC("YUY2");

            int hr = MFExtern.MFCreateMediaType(out mt);
            MFError.ThrowExceptionForHR(hr);

            hr = mt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = mt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            hr = m_p.CreateStream(mt, out pStream);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(pStream != null);

            hr = m_p.SetStream(pStream);
            MFError.ThrowExceptionForHR(hr);

            int i, i2;
            hr = m_p.GetStreamCount(out i);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(i == 1);

            hr = m_p.GetStream(0, out s, out pStream2);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(pStream2 != null);

            hr = m_p.GetStreamByNumber(0, out pStream3);
            MFError.ThrowExceptionForHR(hr);
            Debug.Assert(pStream2 == pStream3);

            IMFASFProfile p2;

            hr = m_p.Clone(out p2);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(p2 != null);
            hr = p2.GetStreamCount(out i);
            MFError.ThrowExceptionForHR(hr);
            hr = p2.RemoveStream(0);
            MFError.ThrowExceptionForHR(hr);
            hr = p2.GetStreamCount(out i2);
            MFError.ThrowExceptionForHR(hr);

            Debug.Assert(i2 == i - 1);
        }
Exemplo n.º 2
0
        private void GetInterface()
        {
            FourCC cc4 = new FourCC("YUY2");
            IMFMediaType mt;

            IMFASFProfile ap;

            int hr = MFExtern.MFCreateASFProfile(out ap);
            MFError.ThrowExceptionForHR(hr);
            hr = MFExtern.MFCreateMediaType(out mt);
            MFError.ThrowExceptionForHR(hr);

            hr = mt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = mt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            hr = ap.CreateStream(mt, out m_sc);
            MFError.ThrowExceptionForHR(hr);
        }
        private void Alt()
        {
            FourCC cc4 = new FourCC("YUY2");
            IMFASFProfile ap;
            IMFASFStreamPrioritization sp;
            IMFASFStreamSelector ss;
            IMFMediaType mt;
            IMFASFStreamConfig pStream;

            int hr = MFExtern.MFCreateASFProfile(out ap);
            MFError.ThrowExceptionForHR(hr);
            hr = ap.GetStreamPrioritization(out sp);
            MFError.ThrowExceptionForHR(hr);
            //ap.CreateStreamPrioritization(out sp);

            hr = MFExtern.MFCreateMediaType(out mt);
            MFError.ThrowExceptionForHR(hr);

            hr = mt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = mt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            hr = ap.CreateStream(mt, out pStream);
            MFError.ThrowExceptionForHR(hr);

            hr = ap.SetStream(pStream);
            MFError.ThrowExceptionForHR(hr);

            hr = MFExtern.MFCreateASFStreamSelector(ap, out ss);
            MFError.ThrowExceptionForHR(hr);
            short[] w = new short[1];
            w[0] = 3;
            hr = ss.GetOutputStreamNumbers(0, w);
            MFError.ThrowExceptionForHR(hr);
            Debug.Assert(w[0] != 3);
        }
        private void GetInterface()
        {
            IMFASFMutualExclusion me;
            IMFASFProfile prof;
            IMFMediaType mt;
            IMFASFStreamConfig pStream;
            FourCC cc4 = new FourCC("YUY2");

            int hr = MFExtern.MFCreateASFProfile(out prof);
            MFError.ThrowExceptionForHR(hr);

            hr = prof.CreateMutualExclusion(out me);
            MFError.ThrowExceptionForHR(hr);
            hr = prof.AddMutualExclusion(me);
            MFError.ThrowExceptionForHR(hr);

            hr = MFExtern.MFCreateMediaType(out mt);
            MFError.ThrowExceptionForHR(hr);

            hr = mt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = mt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            hr = prof.CreateStream(mt, out pStream);
            MFError.ThrowExceptionForHR(hr);

            hr = prof.SetStream(pStream);
            MFError.ThrowExceptionForHR(hr);

            hr = MFExtern.MFCreateASFStreamSelector(prof, out m_ss);
            MFError.ThrowExceptionForHR(hr);
        }
Exemplo n.º 5
0
        private void TestVF()
        {
            int hr;
            IMFVideoMediaType vmt;
            MFMediaEqual me;
            int i;
            MFVideoFormat vf;
            IMFMediaType mt, mt2, mt3;
            FourCC cc4 = new FourCC("YUY2");

            hr = MFExtern.MFCreateMediaType(out mt);
            MFError.ThrowExceptionForHR(hr);

            hr = mt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = mt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            hr = MFExtern.MFCreateMFVideoFormatFromMFMediaType(mt, out vf, out i);
            MFError.ThrowExceptionForHR(hr);
            int cc = MFExtern.MFGetUncompressedVideoFormat(vf);

            hr = MFExtern.MFCreateMediaType(out mt2);
            MFError.ThrowExceptionForHR(hr);
            hr = MFExtern.MFInitMediaTypeFromMFVideoFormat(mt2, vf, i);
            MFError.ThrowExceptionForHR(hr);

            int iRet = mt.IsEqual(mt2, out me);
            Debug.Assert(iRet == 0);

            AMMediaType amt = new AMMediaType();
            hr = MFExtern.MFInitAMMediaTypeFromMFMediaType(mt, Guid.Empty, amt);
            MFError.ThrowExceptionForHR(hr);

            AMMediaType amt2;
            hr = MFExtern.MFCreateAMMediaTypeFromMFMediaType(mt, MFRepresentation.VideoInfo2, out amt2);
            MFError.ThrowExceptionForHR(hr);

            hr = MFExtern.MFCreateMediaType(out mt3);
            MFError.ThrowExceptionForHR(hr);
            hr = MFExtern.MFInitMediaTypeFromAMMediaType(mt3, amt2);
            MFError.ThrowExceptionForHR(hr);

            iRet = mt.IsEqual(mt3, out me);
            Debug.Assert(iRet == 0);

            hr = MFExtern.MFCreateVideoMediaType(vf, out vmt);

            VideoInfoHeader vih = new VideoInfoHeader();
            Marshal.PtrToStructure(amt.formatPtr, vih);

            IMFMediaType mt4;
            hr = MFExtern.MFCreateMediaType(out mt4);
            MFError.ThrowExceptionForHR(hr);
            hr = MFExtern.MFInitMediaTypeFromVideoInfoHeader(mt4, vih, amt.formatSize, Guid.Empty);
            MFError.ThrowExceptionForHR(hr);

            iRet = mt.IsEqual(mt4, out me);
            Debug.Assert(iRet == 1 && me == (MediaFoundation.MFMediaEqual.MajorTypes | MediaFoundation.MFMediaEqual.FormatUserData));

            VideoInfoHeader2 vih2 = new VideoInfoHeader2();
            Marshal.PtrToStructure(amt2.formatPtr, vih2);

            IMFMediaType mt5;
            hr = MFExtern.MFCreateMediaType(out mt5);
            MFError.ThrowExceptionForHR(hr);
            hr = MFExtern.MFInitMediaTypeFromVideoInfoHeader2(mt5, vih2, amt2.formatSize, Guid.Empty);
            MFError.ThrowExceptionForHR(hr);

            iRet = mt.IsEqual(mt5, out me);
            Debug.Assert(iRet == 1 && me == (MediaFoundation.MFMediaEqual.MajorTypes | MediaFoundation.MFMediaEqual.FormatUserData));

            IntPtr ip;
            hr = vmt.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, cc4.ToMediaSubtype());
            MFError.ThrowExceptionForHR(hr);
            hr = vmt.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            MFError.ThrowExceptionForHR(hr);

            vf = vmt.GetVideoFormat();

            // This statement seems to cause crashes in 64bit code.  The crash comes on leaving DoTests.
            // Since this doesn't occur in 32 bit, and since this is a deprecated method, I don't think
            // I care.
            vmt.GetVideoRepresentation(MFRepresentation.VideoInfo, out ip, 10);

            AMMediaType amt5 = new AMMediaType();
            Marshal.PtrToStructure(ip, amt5);
            Debug.Assert(amt5.formatType == MFRepresentation.VideoInfo);
            hr = vmt.FreeRepresentation(MFRepresentation.VideoInfo, ip);
            MFError.ThrowExceptionForHR(hr);
        }