graph.h
上传用户:hxb_1234
上传日期:2010-03-30
资源大小:8328k
文件大小:4k
源码类别:

VC书籍

开发平台:

Visual C++

  1. //------------------------------------------------------------------------------
  2. // File: Graph.h
  3. //
  4. // Desc: Sample code for BDA graph building.
  5. //
  6. // Copyright (c) 2000-2002, Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #ifndef GRAPH_H_INCLUDED_
  9. #define GRAPH_H_INCLUDED_
  10. #include "bdasampl.h"
  11. class CBDAFilterGraph
  12. {
  13. private:
  14.     CComPtr <ITuningSpace>   m_pITuningSpace;
  15.     CComPtr <IScanningTuner> m_pITuner;
  16.     CComPtr <IGraphBuilder>  m_pFilterGraph;         // for current graph
  17.     CComPtr <IMediaControl>  m_pIMediaControl;       // for controlling graph state
  18.     CComPtr <ICreateDevEnum> m_pICreateDevEnum;      // for enumerating system devices
  19.     CComPtr <IBaseFilter>    m_pNetworkProvider;     // for network provider filter
  20.     CComPtr <IBaseFilter>    m_pTunerDevice;         // for tuner device filter
  21.     CComPtr <IBaseFilter>    m_pDemodulatorDevice;   // for tuner device filter
  22.     CComPtr <IBaseFilter>    m_pCaptureDevice;       // for capture device filter
  23.     CComPtr <IBaseFilter>    m_pDemux;               // for demux filter
  24.     CComPtr <IBaseFilter>    m_pVideoDecoder;        // for mpeg video decoder filter
  25.     CComPtr <IBaseFilter>    m_pAudioDecoder;        // for mpeg audio decoder filter
  26.     CComPtr <IBaseFilter>    m_pTIF;                 // for transport information filter
  27.     CComPtr <IBaseFilter>    m_pMPE;                 // for multiple protocol encapsulator
  28.     CComPtr <IBaseFilter>    m_pIPSink;              // for ip sink filter
  29.     CComPtr <IBaseFilter>    m_pOVMixer;             // for overlay mixer filter
  30.     CComPtr <IBaseFilter>    m_pVRenderer;           // for video renderer filter
  31.     CComPtr <IBaseFilter>    m_pDDSRenderer;         // for sound renderer filter
  32.     //required for an ATSC network when creating a tune request
  33.     LONG                     m_lMajorChannel;
  34.     LONG                     m_lMinorChannel;
  35.     LONG                     m_lPhysicalChannel;
  36.     //registration number for the RunningObjectTable
  37.     DWORD                    m_dwGraphRegister;
  38.     NETWORK_TYPE             m_NetworkType;
  39.     HRESULT InitializeGraphBuilder();
  40.     HRESULT LoadTuningSpace();
  41.     HRESULT LoadNetworkProvider();
  42.     HRESULT LoadDemux();
  43.     HRESULT RenderDemux();
  44.     HRESULT LoadFilter(
  45.         REFCLSID clsid, 
  46.         IBaseFilter** ppFilter,
  47.         IBaseFilter* pConnectFilter, 
  48.         BOOL fIsUpstream
  49.         );
  50.     HRESULT ConnectFilters(
  51.         IBaseFilter* pFilterUpstream, 
  52.         IBaseFilter* pFilterDownstream
  53.         );
  54.     HRESULT CreateATSCTuneRequest(
  55.         LONG lPhysicalChannel,
  56.         LONG lMajorChannel, 
  57.         LONG lMinorChannel,
  58.         IATSCChannelTuneRequest**   pTuneRequest
  59.         );
  60. public:
  61.     bool            m_fGraphBuilt;
  62.     bool            m_fGraphRunning;
  63.     bool            m_fGraphFailure;
  64.     CBDAFilterGraph();   
  65.     ~CBDAFilterGraph();
  66.     HRESULT BuildGraph(
  67.         NETWORK_TYPE NetworkType
  68.         );
  69.     HRESULT RunGraph();
  70.     HRESULT StopGraph();
  71.     HRESULT TearDownGraph();
  72.     HRESULT SetVideoWindow(
  73.         HWND hwndMain
  74.         );
  75.     
  76.     HRESULT ChangeChannel(
  77.         LONG lPhysicalChannel,
  78.         LONG lMajorChannel, 
  79.         LONG lMinorChannel
  80.         );
  81.     
  82.     // Adds/removes a DirectShow filter graph from the Running Object Table,
  83.     // allowing GraphEdit to "spy" on a remote filter graph if enabled.
  84.     HRESULT AddGraphToRot(
  85.         IUnknown *pUnkGraph, 
  86.         DWORD *pdwRegister
  87.         );
  88.     void RemoveGraphFromRot(
  89.         DWORD pdwRegister
  90.         );
  91.     LONG GetMajorChannel ()    { return m_lMajorChannel;    };
  92.     LONG GetPhysicalChannel () { return m_lPhysicalChannel; };
  93.     LONG GetMinorChannel ()    { return m_lMinorChannel;    };
  94.  };
  95.  
  96.  
  97. #endif // GRAPH_H_INCLUDED_