Ejemplo n.º 1
0
        public static VideoCompressor[] GetAll(bool reload)
        {
            if (compressors != null && !reload)
            {
                // Compressors are cached so if a new one gets installed, apps need restart to get update data
                return(compressors.ToArray());
            }
            compressors = new List <VideoCompressor>();
            Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
            ici.Init();
            int hr = int.MaxValue;

            for (uint i = 0; hr != 0; i++)
            {
                // Get info for compressor #i
                ici.biSize = (uint)Marshal.SizeOf(ici);
                hr         = Avi32Interop.ICInfo(Avi32Interop.ICTYPE_VIDEO, i, ref ici);
                try {
                    // Create compressor using fccHandler
                    VideoCompressor compressor = new VideoCompressor(ici.fccHandler);
                    compressors.Add(compressor);
                }
                catch (AviException) {
                }
            }
            return(compressors.ToArray());
        }
Ejemplo n.º 2
0
        private VideoCompressor(uint fccHandler)
        {
            // Init bitmap info header
            Avi32Interop.BITMAPINFOHEADER bih = new Avi32Interop.BITMAPINFOHEADER();
            bih.Init();
            bih.biBitCount    = bitCount;
            bih.biCompression = 0;
            bih.biWidth       = bih.biHeight = biHeight;
            bih.biPlanes      = 1;
            // Open compressor
            IntPtr hic = Avi32Interop.ICOpen(Avi32Interop.ICTYPE_VIDEO, fccHandler, Avi32Interop.ICMODE_QUERY);

            if (hic == IntPtr.Zero)
            {
                int errorCode = Marshal.GetLastWin32Error();
                throw new AviException("ICOpen", errorCode);
            }
            try {
                // Check if compressor supports specified format
                int hr = Avi32Interop.ICCompressQuery(hic, ref bih, IntPtr.Zero);
                if (hr != Avi32Interop.ICERR_OK)
                {
                    throw new AviException("ICCompressQuery", hr);
                }
                // Get compressor info
                Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
                ici.Init();
                hr = Avi32Interop.ICGetInfo(hic, out ici, ici.biSize);
                if (hr != 0)
                {
                    this.name = ici.szDescription;
                    // Check quality support
                    bool supportsQuality = (ici.dwFlags & Avi32Interop.VIDCF_QUALITY) == Avi32Interop.VIDCF_QUALITY;
                    if (supportsQuality)
                    {
                        if (Avi32Interop.ICERR_OK == Avi32Interop.ICGetDefaultQuality(hic, ref this.quality))
                        {
                            this.supportsQuality = true;
                        }
                    }
                    else
                    {
                        this.quality = defaultQuality;
                    }
                    this.fccHandler       = fccHandler;
                    this.fccHandlerString = FccHandlerToString(fccHandler);
                }
                else
                {
                    throw new AviException("ICGetInfo", hr);
                }
            }
            finally {
                Avi32Interop.ICClose(hic);
            }
        }
Ejemplo n.º 3
0
 private VideoCompressor(uint fccHandler)
 {
     // Init bitmap info header
      Avi32Interop.BITMAPINFOHEADER bih = new Avi32Interop.BITMAPINFOHEADER();
      bih.Init();
      bih.biBitCount = bitCount;
      bih.biCompression = 0;
      bih.biWidth = bih.biHeight = biHeight;
      bih.biPlanes = 1;
      // Open compressor
      IntPtr hic = Avi32Interop.ICOpen(Avi32Interop.ICTYPE_VIDEO, fccHandler, Avi32Interop.ICMODE_QUERY);
      if (hic == IntPtr.Zero) {
     int errorCode = Marshal.GetLastWin32Error();
     throw new AviException("ICOpen", errorCode);
      }
      try {
     // Check if compressor supports specified format
     int hr = Avi32Interop.ICCompressQuery(hic, ref bih, IntPtr.Zero);
     if (hr != Avi32Interop.ICERR_OK) {
        throw new AviException("ICCompressQuery", hr);
     }
     // Get compressor info
     Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
     ici.Init();
     hr = Avi32Interop.ICGetInfo(hic, out ici, ici.biSize);
     if (hr != 0) {
        this.name = ici.szDescription;
        // Check quality support
        bool supportsQuality = (ici.dwFlags & Avi32Interop.VIDCF_QUALITY) == Avi32Interop.VIDCF_QUALITY;
        if (supportsQuality) {
           if (Avi32Interop.ICERR_OK == Avi32Interop.ICGetDefaultQuality(hic, ref this.quality)) {
              this.supportsQuality = true;
           }
        }
        else {
           this.quality = defaultQuality;
        }
        this.fccHandler = fccHandler;
        this.fccHandlerString = FccHandlerToString(fccHandler);
     }
     else {
        throw new AviException("ICGetInfo", hr);
     }
      }
      finally {
     Avi32Interop.ICClose(hic);
      }
 }
Ejemplo n.º 4
0
 public static VideoCompressor[] GetAll(bool reload)
 {
     if (compressors != null && !reload) {
     // Compressors are cached so if a new one gets installed, apps need restart to get update data
     return compressors.ToArray();
      }
      compressors = new List<VideoCompressor>();
      Avi32Interop.ICINFO ici = new Avi32Interop.ICINFO();
      ici.Init();
      int hr = int.MaxValue;
      for (uint i = 0; hr != 0; i++) {
     // Get info for compressor #i
     ici.biSize = (uint)Marshal.SizeOf(ici);
     hr = Avi32Interop.ICInfo(Avi32Interop.ICTYPE_VIDEO, i, ref ici);
     try {
        // Create compressor using fccHandler
        VideoCompressor compressor = new VideoCompressor(ici.fccHandler);
        compressors.Add(compressor);
     }
     catch (AviException) {
     }
      }
      return compressors.ToArray();
 }