/// <summary> /// Enums the windows. /// </summary> /// <param name="hWnd">The h WND.</param> /// <param name="lParam">The l parameter.</param> /// <returns></returns> protected bool EnumWindows(IntPtr hWnd, IntPtr lParam) { int size = GetWindowTextLength(hWnd); if (size++ > 0 && IsWindowVisible(hWnd)) { StringBuilder sb = new StringBuilder(size); GetWindowText(hWnd, sb, size); CaptureSettings captureSettings = new CaptureSettings { m_Adapter = 0, m_Output = 0 }; RECT rct; GetWindowRect(hWnd, out rct); captureSettings.m_Rect = new DsRect(rct.Left, rct.Top, rct.Right, rct.Bottom); CaptureItem captureItem = new CaptureItem(sb.ToString(), captureSettings); captureMethodCombo.Items.Add(captureItem); } return(true); }
/// <summary> /// Initializes the capture monitors. /// </summary> private void InitializeCaptureMonitors() { var factory = new Factory1(); for (int i = 0; i < factory.GetAdapterCount(); i++) { for (int j = 0; j < factory.GetAdapter(i).GetOutputCount(); j++) { var output = factory.GetAdapter(i).GetOutput(j); CaptureSettings settings = new CaptureSettings(); settings.m_Adapter = i; settings.m_Output = j; settings.m_Rect = new DsRect( output.Description.DesktopBounds.Left, output.Description.DesktopBounds.Top, output.Description.DesktopBounds.Right, output.Description.DesktopBounds.Bottom ); CaptureItem captureItem = new CaptureItem(output.Description.DeviceName, settings); captureMethodCombo.Items.Add(captureItem); } } }
/// <summary> /// Initializes a new instance of the <see cref="DesktopStream"/> class. /// </summary> /// <param name="_name">The _name.</param> /// <param name="_filter">The _filter.</param> public DesktopStream(string _name, BaseSourceFilter _filter) : base(_name, _filter) { m_Factory = new Factory1(); m_nAvgTimePerFrame = UNITS / 30; // 30 FPS m_lLastSampleTime = 0L; m_CaptureSettings = m_DefaultSettings; ChangeCaptureSettings(m_CaptureSettings); }
/// <summary> /// Handles the SelectedIndexChanged event of the captureMethodCombo control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private void captureMethodCombo_SelectedIndexChanged(object sender, EventArgs e) { CaptureSettings newSettings = ((CaptureItem)captureMethodCombo.SelectedItem).m_CaptureSettings; adapterTxtBox.Text = newSettings.m_Adapter.ToString(); outputTxtBox.Text = newSettings.m_Output.ToString(); topTextBox.Text = newSettings.m_Rect.top.ToString(); leftTextBox.Text = newSettings.m_Rect.left.ToString(); rightTextBox.Text = newSettings.m_Rect.right.ToString(); bottomTextBox.Text = newSettings.m_Rect.bottom.ToString(); Dirty = true; }
/// <summary> /// Changes the capture settings. /// </summary> /// <param name="newSettings">The new settings.</param> /// <returns></returns> public HRESULT ChangeCaptureSettings(CaptureSettings newSettings) { lock (m_Filter.FilterLock) { if (m_Filter.IsActive) { return(VFW_E_WRONG_STATE); } m_CaptureSettings = newSettings; if (m_Adapter != null) { m_Adapter.Dispose(); } m_Adapter = m_Factory.GetAdapter1(m_CaptureSettings.m_Adapter); if (m_Adapter == null) { return(E_POINTER); } if (m_Device != null) { m_Device.Dispose(); } m_Device = new Device(m_Adapter); if (m_Device == null) { return(E_POINTER); } if (m_Output != null) { m_Output.Dispose(); } m_Output = m_Adapter.GetOutput(m_CaptureSettings.m_Output).QueryInterface <Output1>(); if (m_Output == null) { return(E_POINTER); } Texture2DDescription textureDesc = new Texture2DDescription { CpuAccessFlags = CpuAccessFlags.Read, BindFlags = BindFlags.None, Format = Format.B8G8R8A8_UNorm, Width = m_nWidth, Height = m_nHeight, OptionFlags = ResourceOptionFlags.None, MipLevels = 1, ArraySize = 1, SampleDescription = { Count = 1, Quality = 0 }, Usage = ResourceUsage.Staging }; if (m_ScreenTexture != null) { m_ScreenTexture.Dispose(); } m_ScreenTexture = new Texture2D(m_Device, textureDesc); if (m_ScreenTexture == null) { return(E_POINTER); } if (m_DuplicatedOutput != null) { m_DuplicatedOutput.Dispose(); } m_DuplicatedOutput = m_Output.DuplicateOutput(m_Device); if (m_DuplicatedOutput == null) { return(E_POINTER); } return((HRESULT)ReconnectPin()); } }
/// <summary> /// Changes the capture settings. /// </summary> /// <param name="newSettings">The new settings.</param> /// <returns></returns> public HRESULT ChangeCaptureSettings(CaptureSettings newSettings) { return(((DesktopStream)Pins[0]).ChangeCaptureSettings(newSettings)); }
/// <summary> /// Initializes a new instance of the <see cref="CaptureItem"/> class. /// </summary> /// <param name="name">The name.</param> /// <param name="settings">The settings.</param> public CaptureItem(string name, CaptureSettings settings) { m_Name = name; m_CaptureSettings = settings; }