]> git.sesse.net Git - vlc/blob - modules/access/dtv/bdagraph.hpp
dvdnav: also white-list *.img files (fixes #4951)
[vlc] / modules / access / dtv / bdagraph.hpp
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 using namespace std;
28 #ifndef _MSC_VER
29 #   include <wtypes.h>
30 #   include <unknwn.h>
31 #   include <ole2.h>
32 #   include <limits.h>
33 #   ifdef _WINGDI_
34 #      undef _WINGDI_
35 #   endif
36 #   define _WINGDI_ 1
37 #   define AM_NOVTABLE
38 #   define _OBJBASE_H_
39 #   undef _X86_
40 #   define _I64_MAX LONG_LONG_MAX
41 #   define LONGLONG long long
42 /* Work-around a bug in w32api-2.5 */
43 /* #   define QACONTAINERFLAGS QACONTAINERFLAGS_SOMETHINGELSE */
44 #endif
45
46 /* Needed to call CoInitializeEx */
47 #define _WIN32_DCOM
48
49 #include <dshow.h>
50 #include <comcat.h>
51 #include "dtv/bdadefs.h"
52
53 class BDAOutput
54 {
55 public:
56     BDAOutput( vlc_object_t * );
57     ~BDAOutput();
58
59     void    Push( block_t * );
60     ssize_t Pop(void *, size_t);
61     void    Empty();
62
63 private:
64     vlc_object_t *p_access;
65     vlc_mutex_t   lock;
66     vlc_cond_t    wait;
67     block_t      *p_first;
68     block_t     **pp_next;
69 };
70
71 /* The main class for building the filter graph */
72 class BDAGraph : public ISampleGrabberCB
73 {
74 public:
75     BDAGraph( vlc_object_t * );
76     virtual ~BDAGraph();
77
78     /* */
79     int SubmitTuneRequest(void);
80
81     int SetCQAM(long);
82     int SetATSC(long);
83     int SetDVBT(long, uint32_t, uint32_t, long, int, uint32_t, int);
84     int SetDVBC(long, const char *, long);
85     int SetDVBS(long, long, uint32_t, int, char, long, long, long);
86
87     /* */
88     ssize_t Pop(void *, size_t);
89
90 private:
91     /* ISampleGrabberCB methods */
92     ULONG ul_cbrc;
93     STDMETHODIMP_( ULONG ) AddRef( ) { return ++ul_cbrc; }
94     STDMETHODIMP_( ULONG ) Release( ) { return --ul_cbrc; }
95     STDMETHODIMP QueryInterface( REFIID /*riid*/, void** /*p_p_object*/ )
96         { return E_NOTIMPL; }
97     STDMETHODIMP SampleCB( double d_time, IMediaSample* p_sample );
98     STDMETHODIMP BufferCB( double d_time, BYTE* p_buffer, long l_buffer_len );
99
100     vlc_object_t *p_access;
101     CLSID     guid_network_type;
102     long      l_tuner_used;        /* Index of the Tuning Device */
103     /* registration number for the RunningObjectTable */
104     DWORD     d_graph_register;
105
106     BDAOutput       output;
107
108     IMediaControl*  p_media_control;
109     IGraphBuilder*  p_filter_graph;
110     ITuningSpace*   p_tuning_space;
111     ITuneRequest*   p_tune_request;
112
113     ICreateDevEnum* p_system_dev_enum;
114     IBaseFilter*    p_network_provider;
115     IScanningTuner* p_scanning_tuner;
116     IBaseFilter*    p_tuner_device;
117     IBaseFilter*    p_capture_device;
118     IBaseFilter*    p_sample_grabber;
119     IBaseFilter*    p_mpeg_demux;
120     IBaseFilter*    p_transport_info;
121     ISampleGrabber* p_grabber;
122
123     HRESULT CreateTuneRequest( );
124     HRESULT Build( );
125     HRESULT FindFilter( REFCLSID clsid, long* i_moniker_used,
126         IBaseFilter* p_upstream, IBaseFilter** p_p_downstream );
127     HRESULT Connect( IBaseFilter* p_filter_upstream,
128         IBaseFilter* p_filter_downstream );
129     HRESULT Start( );
130     HRESULT Destroy( );
131     HRESULT Register( );
132     void Deregister( );
133 };