예제 #1
0
 /// <summary>
 /// Creates a new Resampler based on the DMO Resampler
 /// </summary>
 public DmoResampler()
 {
     mediaComObject = new ResamplerMediaComObject();
     mediaObject = new MediaObject((IMediaObject)mediaComObject);
     propertyStoreInterface = (IPropertyStore)mediaComObject;
     resamplerPropsInterface = (IWMResamplerProps)mediaComObject;
 }
예제 #2
0
 /// <summary>
 /// Creates a new Resampler based on the DMO Resampler
 /// </summary>
 public DmoResampler()
 {
     mediaComObject = new ResamplerMediaComObject();
     mediaObject = new MediaObject((IMediaObject)mediaComObject);
     propertyStoreInterface = (IPropertyStore)mediaComObject;
     resamplerPropsInterface = (IWMResamplerProps)mediaComObject;
 }
예제 #3
0
 public DmoResampler()
 {
     this.mediaComObject          = new ResamplerMediaComObject();
     this.mediaObject             = new MediaObject((IMediaObject)this.mediaComObject);
     this.propertyStoreInterface  = (IPropertyStore)this.mediaComObject;
     this.resamplerPropsInterface = (IWMResamplerProps)this.mediaComObject;
 }
예제 #4
0
        private void CreateH264Decoder()
        {
            HResult hr;
            // create H.264 decoder

            var comobject = new ResamplerMediaComObject();

            decodertransform = (IMFTransform)comobject;

            // setup input media type for decoder
            MFExtern.MFCreateMediaType(out decinputmediatype);

            // setup media type manualy
            IMFMediaType testdecinputmediatype, testdecoutputmediatype;

            decinputmediatype.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            decinputmediatype.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, MFMediaType.H264);
            decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, (int)MFVideoInterlaceMode.Progressive);

            MFExtern.MFSetAttributeSize(decinputmediatype, MFAttributesClsid.MF_MT_FRAME_SIZE, VIDEO_SAMPLE_WIDTH, VIDEO_SAMPLE_HEIGHT);
            uint fixedSampleSize = VIDEO_SAMPLE_WIDTH * (16 * ((VIDEO_SAMPLE_HEIGHT + 15) / 16)) + VIDEO_SAMPLE_WIDTH * (VIDEO_SAMPLE_HEIGHT / 2);//for Y, U and V

            decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_SAMPLE_SIZE, fixedSampleSize);
            decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_DEFAULT_STRIDE, VIDEO_SAMPLE_WIDTH);
            decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_FIXED_SIZE_SAMPLES, 1);
            decinputmediatype.SetUINT32(MFAttributesClsid.MF_MT_ALL_SAMPLES_INDEPENDENT, 1);
            MFExtern.MFSetAttributeRatio(decinputmediatype, MFAttributesClsid.MF_MT_PIXEL_ASPECT_RATIO, 1, 1);

            hr = decodertransform.SetInputType(0, decinputmediatype, 0);

            decodertransform.GetInputAvailableType(0, 0, out testdecinputmediatype);

            // setup media type for output of decoder
            MFExtern.MFCreateMediaType(out decoutputmediatype);
            decoutputmediatype.SetGUID(MFAttributesClsid.MF_MT_MAJOR_TYPE, MFMediaType.Video);
            decoutputmediatype.SetGUID(MFAttributesClsid.MF_MT_SUBTYPE, MFMediaType.IYUV);
            MFExtern.MFSetAttributeSize(decoutputmediatype, MFAttributesClsid.MF_MT_FRAME_SIZE, VIDEO_SAMPLE_WIDTH, VIDEO_SAMPLE_HEIGHT);
            MFExtern.MFSetAttributeRatio(decoutputmediatype, MFAttributesClsid.MF_MT_FRAME_RATE, 30, 1);
            MFExtern.MFSetAttributeRatio(decoutputmediatype, MFAttributesClsid.MF_MT_PIXEL_ASPECT_RATIO, 1, 1);
            decoutputmediatype.SetUINT32(MFAttributesClsid.MF_MT_INTERLACE_MODE, 2);

            hr = decodertransform.SetOutputType(0, decoutputmediatype, 0);
            decodertransform.GetOutputAvailableType(0, 0, out testdecoutputmediatype);

            decodertransform.GetInputStatus(0, out mftStatus);
            if (mftStatus != MFTInputStatusFlags.AcceptData)
            {
                Debug.WriteLine("DECODER NOT ACCEPT INPUT DATA");
                return;
            }
            else
            {
                Debug.WriteLine("PROCESS INPUT DONE>>>> " + mftStatus);
            }

            decodertransform.ProcessMessage(MFTMessageType.CommandFlush, (IntPtr)null);
            decodertransform.ProcessMessage(MFTMessageType.NotifyBeginStreaming, (IntPtr)null);
            decodertransform.ProcessMessage(MFTMessageType.NotifyStartOfStream, (IntPtr)null);
        }
예제 #5
0
 /// <summary>
 /// Dispose code - experimental at the moment
 /// Was added trying to track down why Resampler crashes NUnit
 /// This code not currently being called by ResamplerDmoStream
 /// </summary>
 public void Dispose()
 {
     if(propertyStoreInterface != null)
     {
         Marshal.ReleaseComObject(propertyStoreInterface);
         propertyStoreInterface = null;
     }
     if(resamplerPropsInterface != null)
     {
         Marshal.ReleaseComObject(resamplerPropsInterface);
         resamplerPropsInterface = null;
     }
     if (mediaObject != null)
     {
         mediaObject.Dispose();
         mediaObject = null;
     }
     if (mediaComObject != null)
     {
         Marshal.ReleaseComObject(mediaComObject);
         mediaComObject = null;
     }
 }
예제 #6
0
 /// <summary>
 /// Dispose code - experimental at the moment
 /// Was added trying to track down why Resampler crashes NUnit
 /// This code not currently being called by ResamplerDmoStream
 /// </summary>
 public void Dispose()
 {
     if(propertyStoreInterface != null)
     {
         Marshal.ReleaseComObject(propertyStoreInterface);
         propertyStoreInterface = null;
     }
     if(resamplerPropsInterface != null)
     {
         Marshal.ReleaseComObject(resamplerPropsInterface);
         resamplerPropsInterface = null;
     }
     if (mediaObject != null)
     {
         mediaObject.Dispose();
         mediaObject = null;
     }
     if (mediaComObject != null)
     {
         Marshal.ReleaseComObject(mediaComObject);
         mediaComObject = null;
     }
 }
예제 #7
0
 public void Dispose()
 {
     if (this.propertyStoreInterface != null)
     {
         Marshal.ReleaseComObject(this.propertyStoreInterface);
         this.propertyStoreInterface = null;
     }
     if (this.resamplerPropsInterface != null)
     {
         Marshal.ReleaseComObject(this.resamplerPropsInterface);
         this.resamplerPropsInterface = null;
     }
     if (this.mediaObject != null)
     {
         this.mediaObject.Dispose();
         this.mediaObject = null;
     }
     if (this.mediaComObject != null)
     {
         Marshal.ReleaseComObject(this.mediaComObject);
         this.mediaComObject = null;
     }
 }