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

RealMediaGraph.h « mplayerc « apps « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9cb3209cd1100ccf5961a425b4e72efe2c7aa76e (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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
/*
 * $Id$
 *
 * (C) 2003-2006 Gabest
 * (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 "BaseGraph.h"

#include "AllocatorCommon7.h"
#include "AllocatorCommon.h"

#include <realmedia/pntypes.h>
#include <realmedia/pnwintyp.h>
#include <realmedia/pncom.h>
#include <realmedia/rmapckts.h>
#include <realmedia/rmacomm.h>
#include <realmedia/rmamon.h>
#include <realmedia/rmafiles.h>
#include <realmedia/rmaengin.h>
#include <realmedia/rmacore.h>
#include <realmedia/rmaclsnk.h>
#include <realmedia/rmaerror.h>
#include <realmedia/rmaauth.h>
#include <realmedia/rmawin.h>
#include <realmedia/rmasite2.h>
#include <realmedia/rmaausvc.h>
#include <realmedia/rmavsurf.h>


namespace DSObjects
{

class CRealMediaGraph;

class CRealMediaPlayer
	: public CUnknown
	, public IRMAErrorSink
	, public IRMAClientAdviseSink
	, public IRMAAuthenticationManager
	, public IRMASiteSupplier
	, public IRMAPassiveSiteWatcher
	, public IRMAAudioHook

{
protected:
	friend class CRealMediaGraph;
	CRealMediaGraph* m_pRMG; // IMPORTANT: do not ever AddRef on this from here

	HWND m_hWndParent;
	CSize m_VideoSize;
	bool m_fVideoSizeChanged;

	//

	DWORD m_wndStyle;
	CPlayerWindow m_wndWindowFrame, m_wndDestFrame;

	//

	FPRMCREATEENGINE		m_fpCreateEngine;
	FPRMCLOSEENGINE			m_fpCloseEngine;
	FPRMSETDLLACCESSPATH	m_fpSetDLLAccessPath;
	HMODULE					m_hRealMediaCore;

	CComPtr<IRMAClientEngine> m_pEngine;
	CComPtr<IRMAPlayer> m_pPlayer;
	CComQIPtr<IRMAAudioPlayer, &IID_IRMAAudioPlayer> m_pAudioPlayer;
	CComPtr<IRMAVolume> m_pVolume;
	CComQIPtr<IRMASiteManager, &IID_IRMASiteManager> m_pSiteManager;
	CComQIPtr<IRMACommonClassFactory, &IID_IRMACommonClassFactory> m_pCommonClassFactory;

	CComQIPtr<IRMASite, &IID_IRMASite> m_pTheSite;
	CComQIPtr<IRMASite2, &IID_IRMASite2> m_pTheSite2;
	CMap<UINT32, UINT32&, IRMASite*, IRMASite*&> m_CreatedSites;

	//

	OAFilterState m_State, m_UserState;
	REFERENCE_TIME m_nCurrent, m_nDuration;

	UINT16 m_unPercentComplete;

	//

public:
	CRealMediaPlayer(HWND hWndParent, CRealMediaGraph* pRMG);
	virtual ~CRealMediaPlayer();

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

	bool Init();
	void Deinit();

	virtual CSize GetVideoSize()
	{
		return(m_VideoSize);
	}
	virtual void SetWindowRect(CRect r) {}
	virtual void SetDestRect(CRect r) {}
	virtual bool CreateSite(IRMASite** pSite) = 0;
	virtual void DestroySite(IRMASite* pSite) = 0;

	// IRMAErrorSink
	STDMETHODIMP ErrorOccurred(const UINT8 unSeverity, const UINT32 ulRMACode, const UINT32 ulUserCode, const char* pUserString, const char* pMoreInfoURL);

	// IRMAClientAdviseSink
	STDMETHODIMP OnPosLength(UINT32 ulPosition, UINT32 ulLength);
	STDMETHODIMP OnPresentationOpened();
	STDMETHODIMP OnPresentationClosed();
	STDMETHODIMP OnStatisticsChanged();
	STDMETHODIMP OnPreSeek(UINT32 ulOldTime, UINT32 ulNewTime);
	STDMETHODIMP OnPostSeek(UINT32 ulOldTime, UINT32 ulNewTime);
	STDMETHODIMP OnStop();
	STDMETHODIMP OnPause(UINT32 ulTime);
	STDMETHODIMP OnBegin(UINT32 ulTime);
	STDMETHODIMP OnBuffering(UINT32 ulFlags, UINT16 unPercentComplete);
	STDMETHODIMP OnContacting(const char* pHostName);

	// IRMAAuthenticationManager
	STDMETHODIMP HandleAuthenticationRequest(IRMAAuthenticationManagerResponse* pResponse);

	// IRMASiteSupplier
	STDMETHODIMP SitesNeeded(UINT32 uRequestID, IRMAValues* pSiteProps);
	STDMETHODIMP SitesNotNeeded(UINT32 uRequestID);
	STDMETHODIMP BeginChangeLayout();
	STDMETHODIMP DoneChangeLayout();

	// IRMAPassiveSiteWatcher
	STDMETHODIMP PositionChanged(PNxPoint* pos);
	STDMETHODIMP SizeChanged(PNxSize* size);

	// IRMAAudioHook
	STDMETHODIMP OnBuffer(RMAAudioData* pAudioInData, RMAAudioData* pAudioOutData);
	STDMETHODIMP OnInit(RMAAudioFormat* pFormat);
};

class CRealMediaPlayerWindowed
	: public CRealMediaPlayer
{
public:
	CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGraph* pRMG);
	virtual ~CRealMediaPlayerWindowed();

	void SetWindowRect(CRect r);
	void SetDestRect(CRect r);

	bool CreateSite(IRMASite** pSite);
	void DestroySite(IRMASite* pSite);
};

class CRealMediaPlayerWindowless
	: public CRealMediaPlayer
{
	CComPtr<ISubPicAllocatorPresenter> m_pRMAP;

public:
	CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
	virtual ~CRealMediaPlayerWindowless();

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

	bool CreateSite(IRMASite** pSite);
	void DestroySite(IRMASite* pSite);

	STDMETHODIMP SizeChanged(PNxSize* size);
};

class CRealMediaGraph : public CBaseGraph
{
	CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface

	CStringW m_fn;

public:
	CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
	virtual ~CRealMediaGraph();

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

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

	// IMediaControl
	STDMETHODIMP Run();
	STDMETHODIMP Pause();
	STDMETHODIMP Stop();
	STDMETHODIMP GetState(LONG msTimeout, OAFilterState* pfs);

	// IMediaSeeking
	STDMETHODIMP GetDuration(LONGLONG* pDuration);
	STDMETHODIMP GetCurrentPosition(LONGLONG* pCurrent);
	STDMETHODIMP SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags);

	// IVideoWindow
	STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);

	// IBasicVideo
	STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);
	STDMETHODIMP GetVideoSize(long* pWidth, long* pHeight);

	// IBasicAudio
	STDMETHODIMP put_Volume(long lVolume);
	STDMETHODIMP get_Volume(long* plVolume);

	// IAMOpenProgress
	STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);

	// IGraphEngine
	STDMETHODIMP_(engine_t) GetEngine();
};

}
using namespace DSObjects;