コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VideoAdapterInfo" /> class.
        /// </summary>
        /// <param name="index">The index of the video adapter within a list.</param>
        /// <param name="adapter">The DXGI adapter from which to retrieve all information.</param>
        /// <param name="featureSet">The supported feature set for the video adapter.</param>
        /// <param name="outputs">The list of outputs attached to the video adapter.</param>
        /// <param name="deviceType">The type of video adapter.</param>
        public VideoAdapterInfo(int index,
                                Adapter2 adapter,
                                FeatureSet featureSet,
                                Dictionary <string, VideoOutputInfo> outputs,
                                VideoDeviceType deviceType)
        {
            _adapterDesc = adapter.Description2;
            Memory       = new GorgonVideoAdapterMemory(_adapterDesc.DedicatedSystemMemory, _adapterDesc.SharedSystemMemory, _adapterDesc.DedicatedVideoMemory);
            PciInfo      = new GorgonVideoAdapterPciInfo(_adapterDesc.DeviceId, _adapterDesc.Revision, _adapterDesc.SubsystemId, _adapterDesc.VendorId);

            // Ensure that any trailing nulls are removed. This is unlikely to happen with D3D 11.x, but if we ever jump up to 12, we have to
            // watch out for this as SharpDX does not strip the nulls.
            Name            = _adapterDesc.Description.Replace("\0", string.Empty);
            Index           = index;
            VideoDeviceType = deviceType;

            // Put a reference to the adapter on the output.
            // This will be handy for backtracking later.  Also it allows us to validate the output so that we are certain it's applied on the correct
            // video adapter, allowin mixing & matching will likely end in tears.
            var finalOutputs = new Dictionary <string, IGorgonVideoOutputInfo>(StringComparer.OrdinalIgnoreCase);

            foreach (KeyValuePair <string, VideoOutputInfo> output in outputs)
            {
                output.Value.Adapter     = this;
                finalOutputs[output.Key] = output.Value;
            }

            Outputs    = new GorgonVideoAdapterOutputList(finalOutputs);
            FeatureSet = featureSet;
        }
コード例 #2
0
        private void streamPipe_StreamHeaderReceived(object sender, IStreamHeader e)
        {
            _headerType = e.DeviceType;
            switch (e.DeviceType)
            {
            case VideoDeviceType.Hikv:
            {
                _headerReceived = true;
                HikM4Header header = new HikM4Header()
                {
                    Type = HikM4Decoder.HeaderType,
                    Data = (e as HikvStreamHeader).Buffer
                };
                HikM4Header = header;
                onHikM4HeaderReceived(new HikM4HeaderEventArgs(header));
                //初始化包头
                if (_decode)
                {
                    _hikm4Decoder.InputData(header.Type, header.Data);
                }
            }
            break;

            case VideoDeviceType.Ffmpeg:
            {
                _headerReceived = true;
                FfmpegStreamHeader tH     = e as FfmpegStreamHeader;
                FfmpegHeader       header = new FfmpegHeader()
                {
                    CodecID = (Constants.AVCodecID)tH.CodecID,
                    Width   = 0,
                    Height  = 0
                };
                FfmpegHeader = header;
                onFfmpegHeaderReceived(new FfmpegHeaderEventArgs(header));
                //初始化包头
                if (_decode)
                {
                    _ffmpegDecoder.Init(header.CodecID, header.Width, header.Height);
                }
            }
            break;

            default:
                break;
            }
        }
コード例 #3
0
 public DirectStreamLinker(Uri uri)
 {
     StreamUri = uri;
     if (uri.Scheme.ToLower().Equals("hikv"))
     {
         _vType   = VideoDeviceType.Hikv;
         _hikInfo = new HikvUrlInfo(uri.AbsoluteUri);
     }
     else if (uri.Scheme.ToLower().Equals("rtsp"))
     {
         _vType = VideoDeviceType.Ffmpeg;
     }
     else
     {
         throw new ArgumentException("不能识别的Url模式:" + uri.Scheme);
     }
 }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonVideoDevice"/> class.
        /// </summary>
        /// <param name="adapter">DXGI video adapter.</param>
        /// <param name="deviceType">Type of video device.</param>
        /// <param name="index">Index of the device.</param>
        internal GorgonVideoDevice(GI.Adapter1 adapter, VideoDeviceType deviceType, int index)
        {
            VideoDeviceType = deviceType;

            Index = index;
            DedicatedSystemMemory = adapter.Description1.DedicatedSystemMemory;
            DedicatedVideoMemory  = adapter.Description1.DedicatedVideoMemory;
            DeviceID             = adapter.Description1.DeviceId;
            HardwareFeatureLevel = DeviceFeatureLevel.Unsupported;
            UUID               = adapter.Description1.Luid;
            Revision           = adapter.Description1.Revision;
            SharedSystemMemory = adapter.Description1.SharedSystemMemory;
            SubSystemID        = adapter.Description1.SubsystemId;
            VendorID           = adapter.Description1.VendorId;

            switch (deviceType)
            {
            case VideoDeviceType.Software:
                Name = Resources.GORGFX_DEVICE_NAME_WARP;
                HardwareFeatureLevel = SupportedFeatureLevel = DeviceFeatureLevel.SM4_1;
                break;

            case VideoDeviceType.ReferenceRasterizer:
                Name = Resources.GORGFX_DEVICE_NAME_REFRAST;
                HardwareFeatureLevel = SupportedFeatureLevel = DeviceFeatureLevel.SM5;
                break;

            default:
                Name = adapter.Description1.Description;
                EnumerateFeatureLevels(D3D.Device.GetSupportedFeatureLevel(adapter));
                break;
            }


            Outputs = new GorgonNamedObjectReadOnlyCollection <GorgonVideoOutput>(false, new GorgonVideoOutput[] { });
        }
コード例 #5
0
        /// <summary>
        /// Function to return a device object for this video device.
        /// </summary>
        /// <returns>The new device object, adapter and factory.</returns>
        internal Tuple <GI.Factory1, GI.Adapter1, D3D.Device> GetDevice(VideoDeviceType deviceType, DeviceFeatureLevel featureLevel)
        {
            GI.Factory1 factory;
            GI.Adapter1 adapter;
            D3D.Device  device;

            switch (deviceType)
            {
#if DEBUG
            case VideoDeviceType.ReferenceRasterizer:
                device = new D3D.Device(D3DCommon.DriverType.Reference,
                                        D3D.DeviceCreationFlags.Debug,
                                        D3DCommon.FeatureLevel.Level_11_0)
                {
                    DebugName = string.Format("{0} D3D11 Device", Name)
                };

                using (var giDevice = device.QueryInterface <GI.Device1>())
                {
                    adapter = giDevice.GetParent <GI.Adapter1>();   //giDevice.Adapter;
                    factory = adapter.GetParent <GI.Factory1>();
                }
                break;
#endif
            case VideoDeviceType.Software:
                // WARP devices can only do SM4_1 or lower.
                if (featureLevel >= DeviceFeatureLevel.SM5)
                {
                    featureLevel = DeviceFeatureLevel.SM4_1;
                }
#if DEBUG
                device = new D3D.Device(D3DCommon.DriverType.Warp,
                                        D3D.DeviceCreationFlags.Debug,
                                        GetFeatureLevel(featureLevel))
                {
                    DebugName = string.Format("{0} D3D11 Device", Name)
                };
#else
                device = new D3D.Device(D3DCommon.DriverType.Warp,
                                        D3D.DeviceCreationFlags.None,
                                        GetFeatureLevel(featureLevel));
#endif
                using (var giDevice = device.QueryInterface <GI.Device1>())
                {
                    adapter = giDevice.GetParent <GI.Adapter1>();
                    factory = adapter.GetParent <GI.Factory1>();
                }
                break;

            default:
                factory = new GI.Factory1();
                adapter = factory.GetAdapter1(Index);
#if DEBUG
                device = new D3D.Device(adapter,
                                        D3D.DeviceCreationFlags.Debug,
                                        GetFeatureLevel(featureLevel))
                {
                    DebugName = string.Format("{0} D3D11 Device", Name)
                };
#else
                device = new D3D.Device(adapter, D3D.DeviceCreationFlags.None, GetFeatureLevel(HardwareFeatureLevel));
#endif
                break;
            }

            return(new Tuple <GI.Factory1, GI.Adapter1, D3D.Device>(factory, adapter, device));
        }