예제 #1
0
        public static IMFAttributes CreateAttributes(int initialSize)
        {
            IMFAttributes result;

            MediaFoundationInterop.MFCreateAttributes(out result, initialSize);
            return(result);
        }
예제 #2
0
        public static IMFMediaBuffer CreateMemoryBuffer(int bufferSize)
        {
            IMFMediaBuffer result;

            MediaFoundationInterop.MFCreateMemoryBuffer(bufferSize, out result);
            return(result);
        }
예제 #3
0
        public static IMFSample CreateSample()
        {
            IMFSample result;

            MediaFoundationInterop.MFCreateSample(out result);
            return(result);
        }
예제 #4
0
        public static IMFMediaType CreateMediaType()
        {
            IMFMediaType result;

            MediaFoundationInterop.MFCreateMediaType(out result);
            return(result);
        }
예제 #5
0
        public static IMFSourceReader CreateSourceReaderFromByteStream(IMFByteStream byteStream)
        {
            IMFSourceReader result;

            MediaFoundationInterop.MFCreateSourceReaderFromByteStream(byteStream, null, out result);
            return(result);
        }
예제 #6
0
 public static void Shutdown()
 {
     if (MediaFoundationApi.initialized)
     {
         MediaFoundationInterop.MFShutdown();
         MediaFoundationApi.initialized = false;
     }
 }
예제 #7
0
 public static IMFByteStream CreateByteStream(object stream)
 {
     if (stream is IStream)
     {
         IMFByteStream result;
         MediaFoundationInterop.MFCreateMFByteStreamOnStream(stream as IStream, out result);
         return(result);
     }
     throw new ArgumentException("Stream must be IStream in desktop apps");
 }
예제 #8
0
 public static void Startup()
 {
     if (!MediaFoundationApi.initialized)
     {
         int             num       = 2;
         OperatingSystem oSVersion = Environment.OSVersion;
         if (oSVersion.Version.Major == 6 && oSVersion.Version.Minor == 0)
         {
             num = 1;
         }
         MediaFoundationInterop.MFStartup(num << 16 | 112, 0);
         MediaFoundationApi.initialized = true;
     }
 }
예제 #9
0
        public static IMFMediaType CreateMediaTypeFromWaveFormat(WaveFormat waveFormat)
        {
            IMFMediaType iMFMediaType = MediaFoundationApi.CreateMediaType();

            try
            {
                MediaFoundationInterop.MFInitMediaTypeFromWaveFormatEx(iMFMediaType, waveFormat, Marshal.SizeOf(waveFormat));
            }
            catch (Exception)
            {
                Marshal.ReleaseComObject(iMFMediaType);
                throw;
            }
            return(iMFMediaType);
        }
예제 #10
0
        public static IEnumerable <IMFActivate> EnumerateTransforms(Guid category)
        {
            IntPtr intPtr;
            int    num;

            MediaFoundationInterop.MFTEnumEx(category, _MFT_ENUM_FLAG.MFT_ENUM_FLAG_ALL, null, null, out intPtr, out num);
            IMFActivate[] array = new IMFActivate[num];
            for (int i = 0; i < num; i++)
            {
                IntPtr pUnk = Marshal.ReadIntPtr(new IntPtr(intPtr.ToInt64() + (long)(i * Marshal.SizeOf(intPtr))));
                array[i] = (IMFActivate)Marshal.GetObjectForIUnknown(pUnk);
            }
            IMFActivate[] array2 = array;
            for (int j = 0; j < array2.Length; j++)
            {
                IMFActivate iMFActivate = array2[j];
                yield return(iMFActivate);
            }
            array2 = null;
            Marshal.FreeCoTaskMem(intPtr);
            yield break;
        }