]> git.sesse.net Git - vlc/blob - modules/access/bda/bdagraph.h
d6c7e2fc9660249ddb40099bdc8c1fe73344ae53
[vlc] / modules / access / bda / bdagraph.h
1 /*****************************************************************************
2  * bdagraph.h : DirectShow BDA graph builder header for vlc
3  *****************************************************************************
4  * Copyright ( C ) 2007 the VideoLAN team
5  *
6  * Author: Ken Self <kenself(at)optusnet(dot)com(dot)au>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * ( at your option ) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26
27 #include "bda.h"
28
29 using namespace std;
30 #ifndef _MSC_VER
31 #   include <wtypes.h>
32 #   include <unknwn.h>
33 #   include <ole2.h>
34 #   include <limits.h>
35 #   ifdef _WINGDI_
36 #      undef _WINGDI_
37 #   endif
38 #   define _WINGDI_ 1
39 #   define AM_NOVTABLE
40 #   define _OBJBASE_H_
41 #   undef _X86_
42 #   define _I64_MAX LONG_LONG_MAX
43 #   define LONGLONG long long
44 /* Work-around a bug in w32api-2.5 */
45 /* #   define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE */
46 #endif
47
48 /* Needed to call CoInitializeEx */
49 #define _WIN32_DCOM
50
51 #include <dshow.h>
52 #include <comcat.h>
53 #include "bdadefs.h"
54
55 class BDAOutput
56 {
57 public:
58     BDAOutput( access_t * );
59     ~BDAOutput();
60
61     void    Push( block_t * );
62     block_t *Pop();
63     void    Empty();
64
65 private:
66     access_t    *p_access;
67     vlc_mutex_t lock;
68     vlc_cond_t  wait;
69     block_t     *p_first;
70     block_t     **pp_next;
71 };
72
73 /* The main class for building the filter graph */
74 class BDAGraph : public ISampleGrabberCB
75 {
76 public:
77     BDAGraph( access_t* p_access );
78     virtual ~BDAGraph();
79
80     /* */
81     int SubmitATSCTuneRequest();
82     int SubmitDVBTTuneRequest();
83     int SubmitDVBCTuneRequest();
84     int SubmitDVBSTuneRequest();
85
86     /* */
87     block_t *Pop();
88
89 private:
90     /* ISampleGrabberCB methods */
91     ULONG ul_cbrc;
92     STDMETHODIMP_( ULONG ) AddRef( ) { return ++ul_cbrc; }
93     STDMETHODIMP_( ULONG ) Release( ) { return --ul_cbrc; }
94     STDMETHODIMP QueryInterface( REFIID riid, void** p_p_object )
95         { return E_NOTIMPL; }
96     STDMETHODIMP SampleCB( double d_time, IMediaSample* p_sample );
97     STDMETHODIMP BufferCB( double d_time, BYTE* p_buffer, long l_buffer_len );
98
99     access_t* p_access;
100     CLSID     guid_network_type;
101     long      l_tuner_used;        /* Index of the Tuning Device */
102     /* registration number for the RunningObjectTable */
103     DWORD     d_graph_register;
104
105     BDAOutput       output;
106
107     IMediaControl*  p_media_control;
108     IGraphBuilder*  p_filter_graph;
109     ITuningSpace*   p_tuning_space;
110     ITuneRequest*   p_tune_request;
111
112     ICreateDevEnum* p_system_dev_enum;
113     IBaseFilter*    p_network_provider;
114     IScanningTuner* p_scanning_tuner;
115     IBaseFilter*    p_tuner_device;
116     IBaseFilter*    p_capture_device;
117     IBaseFilter*    p_sample_grabber;
118     IBaseFilter*    p_mpeg_demux;
119     IBaseFilter*    p_transport_info;
120     ISampleGrabber* p_grabber;
121
122     HRESULT CreateTuneRequest( );
123     HRESULT Build( );
124     HRESULT FindFilter( REFCLSID clsid, long* i_moniker_used,
125         IBaseFilter* p_upstream, IBaseFilter** p_p_downstream );
126     HRESULT Connect( IBaseFilter* p_filter_upstream,
127         IBaseFilter* p_filter_downstream );
128     HRESULT Start( );
129     HRESULT Destroy( );
130     HRESULT Register( );
131     void Deregister( );
132 };