Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
VideoCapabilities.cs
Package: capsample_src.zip [view]
Upload User: wuming6209
Upload Date: 2013-06-06
Package Size: 161k
Code Size: 4k
Category:
Video Capture
Development Platform:
Visual C++
- // ------------------------------------------------------------------
- // DirectX.Capture
- //
- // History:
- // 2003-Jan-24 BL - created
- //
- // Copyright (c) 2003 Brian Low
- // ------------------------------------------------------------------
- using System;
- using System.Diagnostics;
- using System.Drawing;
- using System.Runtime.InteropServices;
- using DShowNET;
- namespace DirectX.Capture
- {
- /// <summary>
- /// Capabilities of the video device such as
- /// min/max frame size and frame rate.
- /// </summary>
- public class VideoCapabilities
- {
- // ------------------ Properties --------------------
- /// <summary> Native size of the incoming video signal. This is the largest signal the filter can digitize with every pixel remaining unique. Read-only. </summary>
- public Size InputSize;
- /// <summary> Minimum supported frame size. Read-only. </summary>
- public Size MinFrameSize;
- /// <summary> Maximum supported frame size. Read-only. </summary>
- public Size MaxFrameSize;
- /// <summary> Granularity of the output width. This value specifies the increments that are valid between MinFrameSize and MaxFrameSize. Read-only. </summary>
- public int FrameSizeGranularityX;
- /// <summary> Granularity of the output height. This value specifies the increments that are valid between MinFrameSize and MaxFrameSize. Read-only. </summary>
- public int FrameSizeGranularityY;
- /// <summary> Minimum supported frame rate. Read-only. </summary>
- public double MinFrameRate;
- /// <summary> Maximum supported frame rate. Read-only. </summary>
- public double MaxFrameRate;
- // ----------------- Constructor ---------------------
- /// <summary> Retrieve capabilities of a video device </summary>
- internal VideoCapabilities(IAMStreamConfig videoStreamConfig)
- {
- if ( videoStreamConfig == null )
- throw new ArgumentNullException( "videoStreamConfig" );
- AMMediaType mediaType = null;
- VideoStreamConfigCaps caps = null;
- IntPtr pCaps = IntPtr.Zero;
- IntPtr pMediaType;
- try
- {
- // Ensure this device reports capabilities
- int c, size;
- int hr = videoStreamConfig.GetNumberOfCapabilities( out c, out size );
- if ( hr != 0 ) Marshal.ThrowExceptionForHR( hr );
- if ( c <= 0 )
- throw new NotSupportedException( "This video device does not report capabilities." );
- if ( size > Marshal.SizeOf( typeof( VideoStreamConfigCaps ) ) )
- throw new NotSupportedException( "Unable to retrieve video device capabilities. This video device requires a larger VideoStreamConfigCaps structure." );
- if ( c > 1 )
- Debug.WriteLine("This video device supports " + c + " capability structures. Only the first structure will be used." );
- // Alloc memory for structure
- pCaps = Marshal.AllocCoTaskMem( Marshal.SizeOf( typeof( VideoStreamConfigCaps ) ) );
- // Retrieve first (and hopefully only) capabilities struct
- hr = videoStreamConfig.GetStreamCaps( 0, out pMediaType, pCaps );
- if ( hr != 0 ) Marshal.ThrowExceptionForHR( hr );
- // Convert pointers to managed structures
- mediaType = (AMMediaType) Marshal.PtrToStructure( pMediaType, typeof( AMMediaType ) );
- caps = (VideoStreamConfigCaps) Marshal.PtrToStructure( pCaps, typeof( VideoStreamConfigCaps ) );
- // Extract info
- InputSize = caps.InputSize;
- MinFrameSize = caps.MinOutputSize;
- MaxFrameSize = caps.MaxOutputSize;
- FrameSizeGranularityX = caps.OutputGranularityX;
- FrameSizeGranularityY = caps.OutputGranularityY;
- MinFrameRate = (double)10000000 / caps.MaxFrameInterval;
- MaxFrameRate = (double)10000000 / caps.MinFrameInterval;
- }
- finally
- {
- if ( pCaps != IntPtr.Zero )
- Marshal.FreeCoTaskMem( pCaps ); pCaps = IntPtr.Zero;
- if ( mediaType != null )
- DsUtils.FreeAMMediaType( mediaType ); mediaType = null;
- }
- }
- }
- }