• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ICaptureGraphBuilder2类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ICaptureGraphBuilder2的典型用法代码示例。如果您正苦于以下问题:C# ICaptureGraphBuilder2类的具体用法?C# ICaptureGraphBuilder2怎么用?C# ICaptureGraphBuilder2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ICaptureGraphBuilder2类属于命名空间,在下文中一共展示了ICaptureGraphBuilder2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PropertyPageCollection

		/// <summary> Initialize collection with property pages from existing graph. </summary>
		internal PropertyPageCollection(
			ICaptureGraphBuilder2 graphBuilder, 
			IBaseFilter videoDeviceFilter, IBaseFilter audioDeviceFilter,
			IBaseFilter videoCompressorFilter, IBaseFilter audioCompressorFilter, 
			SourceCollection videoSources, SourceCollection audioSources)
		{
			addFromGraph( graphBuilder,
				videoDeviceFilter, audioDeviceFilter,
				videoCompressorFilter, audioCompressorFilter,
				videoSources, audioSources );
		}
开发者ID:rajeper,项目名称:ikarus-osd,代码行数:12,代码来源:PropertyPageCollection.cs


示例2: ShowTunerPinDialog

 public static bool ShowTunerPinDialog(ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd)
 {
     object ppint = null;
     ISpecifyPropertyPages pages = null;
     bool flag;
     DsCAUUID pPages = new DsCAUUID();
     try
     {
         Guid capture = PinCategory.Capture;
         Guid interleaved = MediaType.Interleaved;
         Guid gUID = typeof(IAMTVTuner).GUID;
         if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0)
         {
             interleaved = MediaType.Video;
             if (bld.FindInterface(ref capture, ref interleaved, flt, ref gUID, out ppint) != 0)
             {
                 return false;
             }
         }
         pages = ppint as ISpecifyPropertyPages;
         if (pages == null)
         {
             return false;
         }
         int num = pages.GetPages(out pPages);
         num = OleCreatePropertyFrame(hwnd, 30, 30, null, 1, ref ppint, pPages.cElems, pPages.pElems, 0, 0, IntPtr.Zero);
         flag = true;
     }
     catch (Exception exception)
     {
         Trace.WriteLine("!Ds.NET: ShowCapPinDialog " + exception.Message);
         flag = false;
     }
     finally
     {
         if (pPages.pElems != IntPtr.Zero)
         {
             Marshal.FreeCoTaskMem(pPages.pElems);
         }
         pages = null;
         if (ppint != null)
         {
             Marshal.ReleaseComObject(ppint);
         }
         ppint = null;
     }
     return flag;
 }
开发者ID:alienwow,项目名称:CSharpProjects,代码行数:48,代码来源:DsUtils.cs


示例3: ShowTunerPinDialog

        public static bool ShowTunerPinDialog( ICaptureGraphBuilder2 bld, IBaseFilter flt, IntPtr hwnd )
        {
            int hr;
            object comObj = null;
            ISpecifyPropertyPages	spec = null;
            DsCAUUID cauuid = new DsCAUUID();

            try
            {
                DsGuid cat  = PinCategory.Capture;
                DsGuid type = MediaType.Interleaved;
                DsGuid iid = typeof(IAMTVTuner).GUID;
                hr = bld.FindInterface( cat, type, flt, iid, out comObj );
                if( hr != 0 )
                {
                    type = MediaType.Video;
                    hr = bld.FindInterface( cat, type, flt, iid, out comObj );
                    if( hr != 0 )
                        return false;
                }
                spec = comObj as ISpecifyPropertyPages;
                if( spec == null )
                    return false;

                hr = spec.GetPages( out cauuid );
                hr = OleCreatePropertyFrame( hwnd, 30, 30, null, 1,
                    ref comObj, cauuid.cElems, cauuid.pElems, 0, 0, IntPtr.Zero );
                return true;
            }
            catch( Exception ee )
            {
                Trace.WriteLine( "!Ds.NET: ShowCapPinDialog " + ee.Message );
                return false;
            }
            finally
            {
                if( cauuid.pElems != IntPtr.Zero )
                    Marshal.FreeCoTaskMem( cauuid.pElems );

                spec = null;
                if( comObj != null )
                    Marshal.ReleaseComObject( comObj );
                comObj = null;
            }
        }
开发者ID:BackupTheBerlios,项目名称:tap-svn,代码行数:45,代码来源:DSHelp.cs


示例4: Setup

        /// <summary>
        /// グラフの生成
        /// </summary>
        /// <param name="output_file">出力ファイル</param>
        public virtual void Setup(string output_file)
        {
            this.Dispose();

            try
            {
                CxDSCameraParam param = this.Param;

                // グラフビルダー.
                // CoCreateInstance
                GraphBuilder = (IGraphBuilder)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_FilterGraph)));

                #region フィルタ追加.
                // 画像入力フィルタ.
                IBaseFilter capture = CreateVideoCapture(param);
                if (capture == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(capture, "CaptureFilter");
                IPin capture_out = DSLab.Axi.FindPin(capture, 0, PIN_DIRECTION.PINDIR_OUTPUT);
                this.CaptureFilter = capture;
                this.CaptureOutPin = capture_out;

                // サンプルグラバー.
                IBaseFilter grabber = (IBaseFilter)CreateSampleGrabber();
                if (grabber == null)
                    throw new System.IO.IOException();
                this.GraphBuilder.AddFilter(grabber, "SampleGrabber");
                this.SampleGrabber = (ISampleGrabber)grabber;
                #endregion

                #region キャプチャビルダー:
                {
                    int hr = 0;
                    CaptureBuilder = (ICaptureGraphBuilder2)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_CaptureGraphBuilder2)));
                    hr = CaptureBuilder.SetFiltergraph(GraphBuilder);

                    if (string.IsNullOrEmpty(output_file))
                    {
                        // レンダラー.
                        IBaseFilter renderer = null;
                        renderer = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid(GUID.CLSID_NullRenderer)));
                        if (renderer == null)
                            throw new System.IO.IOException();
                        this.GraphBuilder.AddFilter(renderer, "Renderer");
                        this.Renderer = renderer;

            #if true
                        // IGraphBuilder.Connect の代わりに ICaptureGraphBuilder2.RenderStream を使用する.
                        // fig) [capture]-out->-in-[sample grabber]-out->-in-[null render]
                        hr = CaptureBuilder.RenderStream(new Guid(GUID.PIN_CATEGORY_CAPTURE), new Guid(GUID.MEDIATYPE_Video), capture, grabber, renderer);

            #else
                        // ピンの取得.
                        IPin grabber_in = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_INPUT);
                        IPin grabber_out = DSLab.Axi.FindPin(grabber, 0, PIN_DIRECTION.PINDIR_OUTPUT);
                        IPin renderer_in = DSLab.Axi.FindPin(renderer, 0, PIN_DIRECTION.PINDIR_INPUT);

                        // ピンの接続.
                        GraphBuilder.Connect(capture_out, grabber_in);
                        GraphBuilder.Connect(grabber_out, renderer_in);

                        // ピンの保管.
                        //SampleGrabberInPin = grabber_in;
                        //SampleGrabberOutPin = grabber_out;
                        //RendererInPin = renderer_in;
            #endif
                    }
                    else
                    {
                        IBaseFilter mux = null;
                        IFileSinkFilter sync = null;
                        hr = CaptureBuilder.SetOutputFileName(new Guid(GUID.MEDIASUBTYPE_Avi), output_file, ref mux, ref sync);
                        hr = CaptureBuilder.RenderStream(new Guid(GUID.PIN_CATEGORY_CAPTURE), new Guid(GUID.MEDIATYPE_Video), capture, grabber, mux);
                        this.Mux = mux;
                        this.Sync = sync;
                    }
                }
                #endregion

                #region 保管: フレームサイズ.
                VIDEOINFOHEADER vinfo = DSLab.Axi.GetVideoInfo(SampleGrabber);
                this.SampleGrabberCB.BitmapInfo = vinfo.bmiHeader;
                this.SampleGrabberCB.FrameSize = new Size(
                    System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biWidth),
                    System.Math.Abs(this.SampleGrabberCB.BitmapInfo.biHeight)
                    );
                #endregion

                #region 保管: デバイス名称.
                try
                {
                    if (string.IsNullOrEmpty(param.FilterInfo.Name) == false)
                    {
                        this.DeviceName = param.FilterInfo.Name;
                    }
                    else
//.........这里部分代码省略.........
开发者ID:cogorou,项目名称:DSLab,代码行数:101,代码来源:CxDSCamera.cs


示例5: InitResolution

        void InitResolution(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, int targetWidth, int targetHeight)
        {
            object o;
            capGraph.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o);

            AMMediaType media = null;
            IAMStreamConfig videoStreamConfig = o as IAMStreamConfig;
            IntPtr ptr;
            int iC = 0, iS = 0;

            videoStreamConfig.GetNumberOfCapabilities(out iC, out iS);
            ptr = Marshal.AllocCoTaskMem(iS);
            int bestDWidth = 999999;
            int bestDHeight = 999999;
            int streamID = 0;
            for (int i = 0; i < iC; i++)
            {
                videoStreamConfig.GetStreamCaps(i, out media, ptr);
                VideoInfoHeader v;
                v = new VideoInfoHeader();
                Marshal.PtrToStructure(media.formatPtr, v);
                int dW = Math.Abs(targetWidth - v.BmiHeader.Width);
                int dH = Math.Abs(targetHeight - v.BmiHeader.Height);
                if (dW < bestDWidth && dH < bestDHeight)
                {
                    streamID = i;
                    bestDWidth = dW;
                    bestDHeight = dH;
                }
            }

            videoStreamConfig.GetStreamCaps(streamID, out media, ptr);
            int hr = videoStreamConfig.SetFormat(media);
            Marshal.FreeCoTaskMem(ptr);

            DsError.ThrowExceptionForHR(hr);
            DsUtils.FreeAMMediaType(media);
            media = null;
        }
开发者ID:MattVitelli,项目名称:Nero-Augmented-Reality,代码行数:39,代码来源:CameraDevice.cs


示例6: Init

        private void Init()
        {
            graphBuilder = (IGraphBuilder)new FilterGraph();

            //Create the media control for controlling the graph
            mediaControl = (IMediaControl)graphBuilder;

            mediaEvent = (IMediaEvent)graphBuilder;
            volume = 100;
            captureGraphBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();
            // initialize the Capture Graph Builder
            int hr = captureGraphBuilder.SetFiltergraph(this.graphBuilder);
            DsError.ThrowExceptionForHR(hr);

            DeinterlaceLayoutList = new DeinterlaceList();
            DeinterlaceLayoutList.Add(new DeInterlaceAlparyLayout(this));
            DeinterlaceLayoutList.Add(new DeInterlaceDscalerLayout(this));
            DeinterlaceLayoutList.Add(new DeInterlaceFFDShowLayout(this));
            aspectRatio = 4.0f / 3.0f;
        }
开发者ID:ssnake,项目名称:utuner,代码行数:20,代码来源:tuner.cs


示例7: SourceCollection

 /// <summary> Initialize collection with sources from graph. </summary>
 internal SourceCollection(ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter, bool isVideoDevice)
 {
     addFromGraph( graphBuilder, deviceFilter, isVideoDevice );
 }
开发者ID:RejectKid,项目名称:MTG-Scanner,代码行数:5,代码来源:SourceCollection.cs


示例8: SetConfigParms

        // Set the Framerate, and video size
        private void SetConfigParms(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, int iFrameRate, int iWidth, int iHeight)
        {
            int hr;
            object o;
            AMMediaType media;

            // Find the stream config interface
            hr = capGraph.FindInterface(
                PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o );

            IAMStreamConfig videoStreamConfig = o as IAMStreamConfig;
            if (videoStreamConfig == null)
            {
                throw new Exception("Failed to get IAMStreamConfig");
            }

            // Get the existing format block
            hr = videoStreamConfig.GetFormat( out media);
            DsError.ThrowExceptionForHR( hr );

            // copy out the videoinfoheader
            VideoInfoHeader v = new VideoInfoHeader();
            Marshal.PtrToStructure( media.formatPtr, v );

            // if overriding the framerate, set the frame rate
            if (iFrameRate > 0)
            {
                v.AvgTimePerFrame = 10000000 / iFrameRate;
            }

            // if overriding the width, set the width
            if (iWidth > 0)
            {
                v.BmiHeader.Width = iWidth;
            }

            // if overriding the Height, set the Height
            if (iHeight > 0)
            {
                v.BmiHeader.Height = iHeight;
            }

            // Copy the media structure back
            Marshal.StructureToPtr( v, media.formatPtr, false );

            // Set the new format
            hr = videoStreamConfig.SetFormat( media );
            DsError.ThrowExceptionForHR( hr );

            DsUtils.FreeAMMediaType(media);
            media = null;
        }
开发者ID:eaglezhao,项目名称:tracnghiemweb,代码行数:53,代码来源:Capture.cs


示例9: InitCaptureInterface

        private void InitCaptureInterface()
        {
            // release com object (useless here but can't hurt)
            Cleanup(true);

            this.fmc = new FilgraphManagerClass();

            // create the cg object and add the filter graph to it
            Type t = Type.GetTypeFromCLSID(CLSID_CaptureGraphBuilder2);
            this.icgb = (ICaptureGraphBuilder2)Activator.CreateInstance(t);

            t = Type.GetTypeFromCLSID(CLSID_SampleGrabber);
            this.isg = (ISampleGrabber)Activator.CreateInstance(t);

            // source filter (the capture device)
            this.sf = (IBaseFilter)this.SourceFilterList[this.cbxDevice.SelectedIndex];
            // sample grabber filter
            this.sgf = (IBaseFilter)this.isg;

            object o = null;
            this.icgb.RemoteFindInterface(ref PIN_CATEGORY_CAPTURE, ref MEDIATYPE_Video, sf, ref IID_IAMStreamConfig, out o);
            this.iamsc = (IAMStreamConfig)o;

            // set sample grabber media type
            this.SGMediaType = new _AMMediaType();
            this.SGMediaType.majortype = MEDIATYPE_Video;
            this.SGMediaType.subtype = MEDIASUBTYPE_RGB24;
            this.SGMediaType.formattype = FORMAT_VideoInfo;
            this.isg.SetMediaType(ref SGMediaType);

            this.isg.SetOneShot(0);
            this.isg.SetBufferSamples(1);
        }
开发者ID:ClassroomPresenter,项目名称:CP3,代码行数:33,代码来源:CaptureGraphForm.cs


示例10: findCrossbars

        /// <summary>
        ///	 Retrieve a list of crossbar filters in the graph.
        ///  Most hardware devices should have a maximum of 2 crossbars, 
        ///  one for video and another for audio.
        /// </summary>
        protected ArrayList findCrossbars(ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter)
        {
            ArrayList crossbars = new ArrayList();

            Guid category = FindDirection.UpstreamOnly;
            Guid type = new Guid();
            Guid riid = typeof(IAMCrossbar).GUID;
            int hr;

            object comObj = null;
            object comObjNext = null;

            // Find the first interface, look upstream from the selected device
            hr = graphBuilder.FindInterface( ref category, ref type, deviceFilter, ref riid, out comObj );
            while ( (hr == 0) && (comObj != null) )
            {
                // If found, add to the list
                if ( comObj is IAMCrossbar )
                {
                    crossbars.Add( comObj as IAMCrossbar );

                    // Find the second interface, look upstream from the next found crossbar
                    hr = graphBuilder.FindInterface( ref category, ref type, comObj as IBaseFilter, ref riid, out comObjNext );
                    comObj = comObjNext;
                }
                else
                    comObj = null;
            }

            return( crossbars );
        }
开发者ID:RejectKid,项目名称:MTG-Scanner,代码行数:36,代码来源:SourceCollection.cs


示例11: SetConfigParms

        // Set the Framerate, and video size
        private void SetConfigParms(ICaptureGraphBuilder2 capGraph, IBaseFilter capFilter, int iSampleRate, int iChannels)
        {
            int hr;
            object o;
            AMMediaType media;

            // Find the stream config interface
            hr = capGraph.FindInterface(
                PinCategory.Capture, MediaType.Audio, capFilter, typeof(IAMStreamConfig).GUID, out o);

            IAMStreamConfig audioStreamConfig = o as IAMStreamConfig;
            if (audioStreamConfig == null) {
                throw new Exception("Failed to get IAMStreamConfig");
            }

            // Get the existing format block
            hr = audioStreamConfig.GetFormat(out media);
            DsError.ThrowExceptionForHR(hr);

            // copy out the videoinfoheader
            WaveFormatEx i = new WaveFormatEx();
            Marshal.PtrToStructure(media.formatPtr, i);

            i.wFormatTag = 0x0001; // WAVE_FORMAT_PCM
            i.wBitsPerSample = 16;
            i.nSamplesPerSec = 44100;
            i.nChannels = m_Channels;
            i.nBlockAlign = 2;
            i.nAvgBytesPerSec = (i.nSamplesPerSec * i.nBlockAlign);
            i.cbSize = 0;

            // if overriding the framerate, set the frame rate
            if (iSampleRate > 0) {
                i.nSamplesPerSec = iSampleRate;
            }

            // if overriding the width, set the width
            if (iChannels > 0) {
                i.nChannels = (short)iChannels;
            }

            // Copy the media structure back
            Marshal.StructureToPtr(i, media.formatPtr, false);

            // Set the new format
            hr = audioStreamConfig.SetFormat(media);
            DsError.ThrowExceptionForHR(hr);

            DsUtils.FreeAMMediaType(media);
            media = null;
        }
开发者ID:i-e-b,项目名称:HLS---Smooth-Encoder,代码行数:52,代码来源:AudioCapture.cs


示例12: SetVideoCaptureParameters

        /// <summary>
        /// Sets the capture parameters for the video capture device
        /// </summary>
        private bool SetVideoCaptureParameters(ICaptureGraphBuilder2 capGraph, IBaseFilter captureFilter, Guid mediaSubType)
        {
            /* The stream config interface */
            object streamConfig;

            /* Get the stream's configuration interface */
            int hr = capGraph.FindInterface(PinCategory.Capture,
                                            MediaType.Video,
                                            captureFilter,
                                            typeof(IAMStreamConfig).GUID,
                                            out streamConfig);

            DsError.ThrowExceptionForHR(hr);

            var videoStreamConfig = streamConfig as IAMStreamConfig;

            /* If QueryInterface fails... */
            if (videoStreamConfig == null)
            {
                throw new Exception("Failed to get IAMStreamConfig");
            }

            /* The media type of the video */
            AMMediaType media;

            /* Get the AMMediaType for the video out pin */
            hr = videoStreamConfig.GetFormat(out media);
            DsError.ThrowExceptionForHR(hr);

            /* Make the VIDEOINFOHEADER 'readable' */
            var videoInfo = new VideoInfoHeader();
            Marshal.PtrToStructure(media.formatPtr, videoInfo);

            /* Setup the VIDEOINFOHEADER with the parameters we want */
            videoInfo.AvgTimePerFrame = DSHOW_ONE_SECOND_UNIT / FPS;
            videoInfo.BmiHeader.Width = DesiredWidth;
            videoInfo.BmiHeader.Height = DesiredHeight;

            if (mediaSubType != Guid.Empty)
            {
                int fourCC = 0;
                byte[] b = mediaSubType.ToByteArray();
                fourCC = b[0];
                fourCC |= b[1] << 8;
                fourCC |= b[2] << 16;
                fourCC |= b[3] << 24;

                videoInfo.BmiHeader.Compression = fourCC;
                media.subType = mediaSubType;
            }

            /* Copy the data back to unmanaged memory */
            Marshal.StructureToPtr(videoInfo, media.formatPtr, false);

            /* Set the format */
            hr = videoStreamConfig.SetFormat(media);

            /* We don't want any memory leaks, do we? */
            DsUtils.FreeAMMediaType(media);

            if (hr < 0)
                return false;

            return true;
        }
开发者ID:JayBeavers,项目名称:WPF-MediaKit,代码行数:68,代码来源:VideoCapturePlayer.cs


示例13: InitTuner

        private void InitTuner(ICaptureGraphBuilder2 captureGraphBuilder)
        {
            Object o;
            var hr = captureGraphBuilder.FindInterface(null, null, videoDevice, typeof(IAMTVTuner).GUID, out o);
            if (hr >= 0)
            {

                tuner = (IAMTVTuner)o;
                //tuner.put_Mode(AMTunerModeType.TV);
                o = null;
                //find crossbar
                var list = findCrossbars(captureGraphBuilder, (IBaseFilter)tuner);
                /*hr = captureGraphBuilder.FindInterface(null, null, (IBaseFilter)Tuner, typeof(IAMCrossbar).GUID, out o);
                if (hr >= 0)
                {
                    crossbar = (IAMCrossbar)o;
                    InitCrossbar();
                }
                else
                    crossbar = null;
                */
                if (list.Count > 0)
                {
                    crossbar = (IAMCrossbar)list[0];
                    InitCrossbar();

                }
                o = null;
                // find amtvaudio
                hr = captureGraphBuilder.FindInterface(null, null, videoDevice, typeof(IAMTVAudio).GUID, out o);
                if (hr >= 0)
                {
                    TVAudio = (IAMTVAudio)o;

                }
                o = null;
                // find IAMAnalogVideoDecoder
                hr = captureGraphBuilder.FindInterface(null, null, videoDevice, typeof(IAMAnalogVideoDecoder).GUID, out o);

                if (hr >= 0)
                {
                    analogVideoDecoder = (o as IAMAnalogVideoDecoder);
                    AnalogVideoStandard avs;
                    analogVideoDecoder.get_TVFormat(out avs);

                }

                o = null;
            }
            else
                tuner = null;
        }
开发者ID:ssnake,项目名称:utuner,代码行数:52,代码来源:tuner.cs


示例14: InitAMStreamConfig

        private void InitAMStreamConfig(ICaptureGraphBuilder2 captureGraphBuilder2, IBaseFilter aDev)
        {
            Object o;
            if (AMStreamConfig != null)
            {
               // IBaseFilter bf = (IBaseFilter)AMStreamConfig;
              //  RemoveFilter(ref bf);
            }
            var hr = captureGraphBuilder2.FindInterface(PinCategory.Capture, MediaType.Video, aDev, typeof(IAMStreamConfig).GUID, out o);
            DsError.ThrowExceptionForHR(hr);
            AMStreamConfig = o as IAMStreamConfig;

            if (AMStreamConfig == null)
            {
                throw new Exception("Failed to get IAMStreamConfig");
            }
        }
开发者ID:ssnake,项目名称:utuner,代码行数:17,代码来源:tuner.cs


示例15: addFromGraph

        // -------------------- Protected Methods -----------------------
        /// <summary> Populate the collection from a filter graph. </summary>
        protected void addFromGraph( ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter, bool isVideoDevice )
        {
            Trace.Assert( graphBuilder != null );

            ArrayList crossbars = findCrossbars( graphBuilder, deviceFilter );
            foreach ( IAMCrossbar crossbar in crossbars )
            {
                ArrayList sources = findCrossbarSources( graphBuilder, crossbar, isVideoDevice );
                InnerList.AddRange( sources );
            }

            if ( !isVideoDevice )
            {
                if ( InnerList.Count == 0 )
                {
                    ArrayList sources = findAudioSources( graphBuilder, deviceFilter );
                    InnerList.AddRange( sources );

                }
            }
        }
开发者ID:RejectKid,项目名称:MTG-Scanner,代码行数:23,代码来源:SourceCollection.cs


示例16: findAudioSources

        protected ArrayList findAudioSources(ICaptureGraphBuilder2 graphBuilder, IBaseFilter deviceFilter)
        {
            ArrayList sources = new ArrayList();
            IAMAudioInputMixer audioInputMixer = deviceFilter as IAMAudioInputMixer;
            if ( audioInputMixer != null )
            {
                // Get a pin enumerator off the filter
                IEnumPins pinEnum;
                int hr = deviceFilter.EnumPins( out pinEnum );
                pinEnum.Reset();
                if( (hr == 0) && (pinEnum != null) )
                {
                    // Loop through each pin
                    IPin[] pins = new IPin[1];
                    int f;
                    do
                    {
                        // Get the next pin
                        hr = pinEnum.Next( 1, pins, out f );
                        if( (hr == 0) && (pins[0] != null) )
                        {
                            // Is this an input pin?
                            PinDirection dir = PinDirection.Output;
                            hr = pins[0].QueryDirection( out dir );
                            if( (hr == 0) && (dir == (PinDirection.Input)) )
                            {
                                // Add the input pin to the sources list
                                AudioSource source = new AudioSource( pins[0] );
                                sources.Add( source );
                            }
                            pins[0] = null;
                        }
                    }
                    while( hr == 0 );

                    Marshal.ReleaseComObject( pinEnum ); pinEnum = null;
                }
            }

            // If there is only one source, don't return it
            // because there is nothing for the user to choose.
            // (Hopefully that single source is already enabled).
            if ( sources.Count == 1 )
                sources.Clear();

            return( sources );
        }
开发者ID:RejectKid,项目名称:MTG-Scanner,代码行数:47,代码来源:SourceCollection.cs


示例17: SetupGraph

        public void SetupGraph(DsDevice dev, bool runOCR, VideoFormatHelper.SupportedVideoFormat selectedFormat, ref float iFrameRate, ref int iWidth, ref int iHeight)
        {
            try
            {
                filterGraph = (IFilterGraph2)new FilterGraph();
                mediaCtrl = filterGraph as IMediaControl;

                capBuilder = (ICaptureGraphBuilder2)new CaptureGraphBuilder2();

                samplGrabber = (ISampleGrabber)new SampleGrabber();

                int hr = capBuilder.SetFiltergraph(filterGraph);
                DsError.ThrowExceptionForHR(hr);

                if (Settings.Default.VideoGraphDebugMode)
                {
                    if (rot != null)
                    {
                        rot.Dispose();
                        rot = null;
                    }
                    rot = new DsROTEntry(filterGraph);
                }

                SetupGraphInternal(dev, selectedFormat, ref iFrameRate, ref iWidth, ref iHeight);

                // Now that sizes are fixed/known, store the sizes
                SaveSizeInfo(samplGrabber);

                crossbar = CrossbarHelper.SetupTunerAndCrossbar(capBuilder, capFilter);

                latestBitmap = new Bitmap(iWidth, iHeight, PixelFormat.Format24bppRgb);
                fullRect = new Rectangle(0, 0, latestBitmap.Width, latestBitmap.Height);

                NativeHelpers.SetupCamera(
                    Settings.Default.CameraModel,
                    iWidth, iHeight,
                    Settings.Default.HorizontalFlip,
                    Settings.Default.VerticalFlip,
                    Settings.Default.IsIntegrating,
                    (float)Settings.Default.MinSignatureDiffRatio,
                    (float)Settings.Default.MinSignatureDiff,
                    Settings.Default.GammaDiff,
                    Settings.Default.ForceNewFrameOnLockedRate,
                    dev.Name,
                    selectedFormat.AsSerialized(),
                    selectedFormat.FrameRate);

                NativeHelpers.SetupAav(Settings.Default.RecordStatusSectionOnly ? AavImageLayout.StatusSectionOnly : Settings.Default.AavImageLayout, Settings.Default.AavCompression);

                ocrEnabled = false;
                string errorMessage;

                if (runOCR)
                {
                    OcrConfiguration ocrConfig = OcrSettings.Instance[Settings.Default.SelectedOcrConfiguration];

                    errorMessage = NativeHelpers.SetupBasicOcrMetrix(ocrConfig);
                    if (errorMessage != null && callbacksObject != null)
                        callbacksObject.OnError(-1, errorMessage);
                    else
                    {
                        NativeHelpers.SetupOcr(ocrConfig);
                        ocrEnabled = true;
                    }
                }
                else
                {
                    errorMessage = NativeHelpers.SetupTimestampPreservation(false, 0, 0);
                    if (errorMessage != null && callbacksObject != null)
                        callbacksObject.OnError(-1, errorMessage);
                }
            }
            catch
            {
                CloseResources();

                if (callbacksObject != null)
                    callbacksObject.OnError(-1, "Error initialising the camera. The selected video mode may not be supported by the camera.");

                throw;
            }
        }
开发者ID:hpavlov,项目名称:occurec,代码行数:83,代码来源:DirectShowCapture.cs


示例18: findCrossbarSources

        /// <summary>
        ///  Populate the internal InnerList with sources/physical connectors
        ///  found on the crossbars. Each instance of this class is limited
        ///  to video only or audio only sources ( specified by the isVideoDevice
        ///  parameter on the constructor) so we check each source before adding
        ///  it to the list.
        /// </summary>
        protected ArrayList findCrossbarSources(ICaptureGraphBuilder2 graphBuilder, IAMCrossbar crossbar, bool isVideoDevice)
        {
            ArrayList sources = new ArrayList();
            int hr;
            int numOutPins;
            int numInPins;
            hr = crossbar.get_PinCounts( out numOutPins, out numInPins );
            if ( hr < 0 )
                Marshal.ThrowExceptionForHR( hr );

            // We loop through every combination of output and input pin
            // to see which combinations match.

            // Loop through output pins
            for ( int cOut = 0; cOut < numOutPins; cOut++ )
            {
                // Loop through input pins
                for ( int cIn = 0; cIn < numInPins; cIn++ )
                {
                    // Can this combination be routed?
                    hr = crossbar.CanRoute( cOut, cIn );
                    if ( hr == 0 )
                    {
                        // Yes, this can be routed
                        int relatedPin;
                        PhysicalConnectorType connectorType;
                        hr = crossbar.get_CrossbarPinInfo( true, cIn, out relatedPin, out connectorType );
                        if ( hr < 0 )
                            Marshal.ThrowExceptionForHR( hr );

                        // Is this the correct type?, If so add to the InnerList
                        CrossbarSource source = new CrossbarSource( crossbar, cOut, cIn, connectorType );
                        if ( connectorType < PhysicalConnectorType.Audio_Tuner )
                            if ( isVideoDevice )
                                sources.Add( source );
                        else
                            if ( !isVideoDevice )
                                sources.Add( source );
                    }
                }
            }

            // Some silly drivers (*cough* Nvidia *cough*) add crossbars
            // with no real choices. Every input can only be routed to
            // one output. Loop through every Source and see if there
            // at least one other Source with the same output pin.
            int refIndex = 0;
            while ( refIndex < sources.Count )
            {
                bool found = false;
                CrossbarSource refSource = (CrossbarSource) sources[refIndex];
                for ( int c = 0; c < sources.Count; c++ )
                {
                    CrossbarSource s = (CrossbarSource) sources[c];
                    if ( ( refSource.OutputPin == s.OutputPin ) && ( refIndex != c ) )
                    {
                        found = true;
                        break;
                    }
                }
                if ( found )
                    refIndex++;
                else
                    sources.RemoveAt( refIndex );
            }

            return( sources );
        }
开发者ID:RejectKid,项目名称:MTG-Scanner,代码行数:75,代码来源:SourceCollection.cs


示例19: SetConfigParms

        private void SetConfigParms(ICaptureGraphBuilder2 capBuilder, IBaseFilter capFilter, VideoFormatHelper.SupportedVideoFormat selectedFormat, ref float iFrameRate, ref int iWidth, ref int iHeight)
        {
            object o;
            AMMediaType media;
            IAMStreamConfig videoStreamConfig;
            IAMVideoControl videoControl = capFilter as IAMVideoControl;

            int hr = capBuilder.FindInterface(PinCategory.Capture, MediaType.Video, capFilter, typeof(IAMStreamConfig).GUID, out o);

            videoStreamConfig = o as IAMStreamConfig;
            try
            {
                if (videoStreamConfig == null)
                {
                    throw new Exception("Failed to get IAMStreamConfig");
                }

                int iCount = 0, iSize = 0;
                hr = videoStreamConfig.GetNumberOfCapabilities(out iCount, out iSize);
                DsError.ThrowExceptionForHR(hr);

                VideoInfoHeader vMatching = null;
                VideoFormatHelper.SupportedVideoFormat entry = null;

                IntPtr taskMemPointer = Marshal.AllocCoTaskMem(iSize);

                AMMediaType pmtConfig = null;
                for (int iFormat = 0; iFormat < iCount; iFormat++)
                {
                    IntPtr ptr = IntPtr.Zero;

                    hr = videoStreamConfig.GetStreamCaps(iFormat, out pmtConfig, taskMemPointer);
                    DsError.ThrowExceptionForHR(hr);

                    vMatching = (VideoInfoHeader)Marshal.PtrToStructure(pmtConfig.formatPtr, typeof(VideoInfoHeader));

                    if (vMatching.BmiHeader.BitCount > 0)
                    {
                        entry = new VideoFormatHelper.SupportedVideoFormat()
                        {
                            Width = vMatching.BmiHeader.Width,
                            Height = vMatching.BmiHeader.Height,
                            BitCount = vMatching.BmiHeader.BitCount,
                            FrameRate = 10000000.0 / vMatching.AvgTimePerFrame
                        };

                        if (entry.Matches(selectedFormat))
                        {
                            // WE FOUND IT !!!
                            break;
                        }
                    }

                    vMatching = null;
                }

                if (vMatching != null)
                {
                    hr = videoStreamConfig.SetFormat(pmtConfig);
                    DsError.ThrowExceptionForHR(hr);

                    iFrameRate = 10000000/vMatching.AvgTimePerFrame;
                    iWidth = vMatching.BmiHeader.Width;
                    iHeight = vMatching.BmiHeader.Height;
                }
                else
                {
                    hr = videoStreamConfig.GetFormat(out media);
                    DsError.ThrowExceptionForHR(hr);

                    // Copy out the videoinfoheader
                    VideoInfoHeader v = new VideoInfoHeader();
                    Marshal.PtrToStructure(media.formatPtr, v);

                    if (selectedFormat != null && iWidth == 0 && iHeight == 0)
                    {
                        // Use the config from the selected format
                        iWidth = selectedFormat.Width;
                        iHeight = selectedFormat.Height;
                        iFrameRate = (float) selectedFormat.FrameRate;
                    }

                    // If overriding the framerate, set the frame rate
                    if (iFrameRate > 0)
                    {
                        int newAvgTimePerFrame = (int)Math.Round(10000000 / iFrameRate);
                        Trace.WriteLine(string.Format("Overwriting VideoInfoHeader.AvgTimePerFrame from {0} to {1}", v.AvgTimePerFrame, newAvgTimePerFrame));
                        v.AvgTimePerFrame = newAvgTimePerFrame;
                    }
                    else
                        iFrameRate = 10000000 / v.AvgTimePerFrame;

                    // If overriding the width, set the width
                    if (iWidth > 0)
                    {
                        Trace.WriteLine(string.Format("Overwriting VideoInfoHeader.BmiHeader.Width from {0} to {1}", v.BmiHeader.Width, iWidth));
                        v.BmiHeader.Width = iWidth;
                    }
                    else
                        iWidth = v.BmiHeader.Width;
//.........这里部分代码省略.........
开发者ID:hpavlov,项目名称:occurec,代码行数:101,代码来源:DirectShowCapture.cs


示例20: SetConfigParms

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ICard类代码示例发布时间:2022-05-24
下一篇:
C# ICaptureDetails类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap