Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FGManagerBDA.h « mplayerc « apps « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d95930021aee57c9141ab7455f3661e7b7eb0016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
 * $Id$
 *
 * (C) 2006-2010 see AUTHORS
 *
 * This file is part of mplayerc.
 *
 * Mplayerc is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * Mplayerc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */


#pragma once

#include <bdatypes.h>
#include <bdamedia.h>
#include <bdaiface.h>

#include "FGManager.h"


class CDVBStream
{
public :
	CDVBStream() :
		m_ulMappedPID(0)
	{
	}

	CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE * pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc=MEDIA_ELEMENTARY_STREAM) :
		m_Name(strName),
		m_bFindExisting(bFindExisting),
		m_pmt(pmt),
		m_nMsc(nMsc),
		m_ulMappedPID(0)
	{}

	LPWSTR					GetName()			/*const*/
	{
		return m_Name;
	};
	const AM_MEDIA_TYPE*	GetMediaType()		/*const*/
	{
		return m_pmt;
	};
	bool					GetFindExisting()	const
	{
		return m_bFindExisting;
	};
	IBaseFilter*			GetFilter()
	{
		return m_pFilter;
	};

	void					SetPin(IPin* pPin)
	{
		CComPtr<IPin>		pPinOut;
		PIN_INFO			PinInfo;

		m_pMap = pPin;
		if (m_pMap &&
			SUCCEEDED (pPin->ConnectedTo (&pPinOut)) &&
			SUCCEEDED (pPinOut->QueryPinInfo (&PinInfo)))
		{
			m_pFilter.Attach (PinInfo.pFilter);
		}
	}

	HRESULT Map (ULONG ulPID)
	{
		CheckPointer (m_pMap, E_UNEXPECTED);
		ClearMaps();
		m_ulMappedPID = ulPID;
		return m_pMap->MapPID (1, &ulPID, m_nMsc);
	}

	HRESULT Unmap (ULONG ulPID)
	{
		CheckPointer (m_pMap, E_UNEXPECTED);
		m_ulMappedPID = 0;
		return m_pMap->UnmapPID (1, &ulPID);
	}

	ULONG GetMappedPID() const
	{
		return m_ulMappedPID;
	}

private :
	CComQIPtr<IMPEG2PIDMap>	m_pMap;
	CComPtr<IBaseFilter>	m_pFilter;
	const AM_MEDIA_TYPE*	m_pmt;
	bool					m_bFindExisting;
	LPWSTR					m_Name;
	MEDIA_SAMPLE_CONTENT	m_nMsc;
	ULONG					m_ulMappedPID;

	void ClearMaps()
	{
		HRESULT					hr;
		CComPtr<IEnumPIDMap>	pEnumMap;

		if (SUCCEEDED(hr = m_pMap->EnumPIDMap(&pEnumMap)))
		{
			PID_MAP maps[8];
			ULONG	nbPids = 0;

			if (pEnumMap->Next(_countof(maps), maps, &nbPids)==S_OK)
			{
				for (ULONG i=0; i<nbPids; i++)
				{
					ULONG	pid = maps[i].ulPID;

					m_pMap->UnmapPID(1, &pid);
				}
			}
		}
	}
};


class CFGManagerBDA : public CFGManagerPlayer, IBDATuner, IAMStreamSelect
{
public:
	CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd);
	~CFGManagerBDA();

	// IGraphBuilder
	STDMETHODIMP RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList);

	// IFilterGraph
	STDMETHODIMP ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt);

	// IBDATuner
	STDMETHODIMP SetChannel	(int nChannelPrefNumber);
	STDMETHODIMP SetAudio	(int nAudioIndex);
	STDMETHODIMP SetFrequency(ULONG freq);
	STDMETHODIMP Scan(ULONG ulFrequency, HWND hWnd);
	STDMETHODIMP GetStats (BOOLEAN& bPresent, BOOLEAN& bLocked, LONG& lStrength, LONG& lQuality);

	// IAMStreamSelect
	STDMETHODIMP Count(DWORD* pcStreams);
	STDMETHODIMP Enable(long lIndex, DWORD dwFlags);
	STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFlags, LCID* plcid, DWORD* pdwGroup, WCHAR** ppszName, IUnknown** ppObject, IUnknown** ppUnk);

	DECLARE_IUNKNOWN;
	STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);

private :

	CComQIPtr<IBDA_DeviceControl>			m_pBDAControl;
	CComPtr<IBDA_FrequencyFilter>			m_pBDAFreq;
	CComPtr<IBDA_SignalStatistics>			m_pBDAStats;
	CAtlMap<DVB_STREAM_TYPE, CDVBStream>	m_DVBStreams;

	DVB_STREAM_TYPE							m_nCurVideoType;
	DVB_STREAM_TYPE							m_nCurAudioType;
	CString									m_BDANetworkProvider;

	HRESULT			CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName);
	HRESULT			ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter);
	HRESULT			CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBaseFilter>& pMpeg2Demux);
	HRESULT			SetChannelInternal (CDVBChannel* pChannel);
	HRESULT			SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType);
	HRESULT			ChangeState(FILTER_STATE nRequested);
	FILTER_STATE	GetState();

	template <class ITF>
	HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf)
	{
		CComPtr<IUnknown>	pUnk;
		HRESULT				hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);

		if (SUCCEEDED(hr))
		{
			hr = pUnk.QueryInterface(&pItf);
		}
		return !pItf ? E_NOINTERFACE : hr;
	}

	HRESULT		SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
};