示例#1
0
        private H264Encoder(Activate activate)
        {
            Activate     = activate;
            FriendlyName = activate.Get(TransformAttributeKeys.MftFriendlyNameAttribute);
            Clsid        = activate.Get(TransformAttributeKeys.MftTransformClsidAttribute);
            Flags        = (TransformEnumFlag)activate.Get(TransformAttributeKeys.TransformFlagsAttribute);
            var list       = new List <string>();
            var inputTypes = activate.Get(TransformAttributeKeys.MftInputTypesAttributes);

            for (int j = 0; j < inputTypes.Length; j += 32)                                                                           // two guids
            {
                var majorType = new Guid(Enumerable.Range(0, 16).Select(index => Marshal.ReadByte(inputTypes, j + index)).ToArray()); // Should be video in this context
                var subType   = new Guid(Enumerable.Range(0, 16).Select(index => Marshal.ReadByte(inputTypes, j + 16 + index)).ToArray());
                list.Add(GetFourCC(subType));
            }

            list.Sort();
            InputTypes = list;
            try
            {
                using (var tf = activate.ActivateObject <Transform>())
                {
                    IsBuiltin         = IsBuiltinEncoder(tf);
                    IsDirect3D11Aware = IsDirect3D11AwareEncoder(tf);
                    IsHardwareBased   = IsHardwareBasedEncoder(tf);
                }
            }
            catch
            {
                // do nothing
            }

            using (var key = Registry.ClassesRoot.OpenSubKey(Path.Combine("CLSID", Clsid.ToString("B"), "InprocServer32")))
            {
                if (key != null)
                {
                    DllPath = key.GetValue(null) as string;
                }
            }
        }