00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "stdafx.h"
00023 #include "basegraph.h"
00024 #include "..\..\DSUtil\DSUtil.h"
00025
00026
00027
00028
00029
00030 BOOL CPlayerWindow::PreCreateWindow(CREATESTRUCT& cs)
00031 {
00032 if(!CWnd::PreCreateWindow(cs))
00033 return FALSE;
00034
00035 cs.style &= ~WS_BORDER;
00036 cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
00037 ::LoadCursor(NULL, IDC_HAND), NULL, NULL);
00038
00039 return TRUE;
00040 }
00041
00042 BEGIN_MESSAGE_MAP(CPlayerWindow, CWnd)
00043 ON_WM_ERASEBKGND()
00044 END_MESSAGE_MAP()
00045
00046 BOOL CPlayerWindow::OnEraseBkgnd(CDC* pDC)
00047 {
00048 for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
00049 {
00050 if(!pChild->IsWindowVisible()) continue;
00051
00052 CRect r;
00053 pChild->GetClientRect(&r);
00054 pChild->MapWindowPoints(this, &r);
00055 pDC->ExcludeClipRect(&r);
00056 }
00057
00058 CRect r;
00059 GetClientRect(&r);
00060 pDC->FillSolidRect(&r, 0);
00061
00062 return TRUE;
00063 }
00064
00065
00066
00067
00068
00069 CBaseGraph::CBaseGraph()
00070 : CUnknown(NAME("CBaseGraph"), NULL)
00071 , m_hNotifyWnd(NULL)
00072 {
00073 }
00074
00075 CBaseGraph::~CBaseGraph()
00076 {
00077 }
00078
00079 STDMETHODIMP CBaseGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
00080 {
00081 CheckPointer(ppv, E_POINTER);
00082
00083 return
00084 QI(IFilterGraph)
00085 QI(IGraphBuilder)
00086 QI(IMediaControl)
00087 QI(IMediaSeeking)
00088 QI(IMediaEventEx)
00089 QI(IVideoWindow)
00090 QI(IBasicVideo)
00091 QI(IBasicAudio)
00092 QI(IAMOpenProgress)
00093 QI(IGraphEngine)
00094 __super::NonDelegatingQueryInterface(riid, ppv);
00095 }
00096
00097 void CBaseGraph::ClearMessageQueue()
00098 {
00099 while(!m_msgqueue.IsEmpty())
00100 {
00101 GMSG msg = m_msgqueue.RemoveHead();
00102 FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
00103 }
00104 }
00105
00106
00107 void CBaseGraph::NotifyEvent(long lEventCode, LONG_PTR lParam1, LONG_PTR lParam2)
00108 {
00109 if(!m_hNotifyWnd) return;
00110
00111 GMSG msg;
00112 msg.m_lEventCode = lEventCode;
00113 msg.m_lParam1 = lParam1;
00114 msg.m_lParam2 = lParam2;
00115 m_msgqueue.AddTail(msg);
00116
00117 PostMessage((HWND)m_hNotifyWnd, m_lNotifyMsg, 0, m_lNotifyInstData);
00118 }
00119
00120
00121 STDMETHODIMP CBaseGraph::GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
00122 STDMETHODIMP CBaseGraph::GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo) {return E_NOTIMPL;}
00123 STDMETHODIMP CBaseGraph::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, UINT cNames, LCID lcid, DISPID* rgDispId) {return E_NOTIMPL;}
00124 STDMETHODIMP CBaseGraph::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) {return E_NOTIMPL;}
00125
00126
00127 STDMETHODIMP CBaseGraph::AddFilter(IBaseFilter* pFilter, LPCWSTR pName) {return E_NOTIMPL;}
00128 STDMETHODIMP CBaseGraph::RemoveFilter(IBaseFilter* pFilter) {return E_NOTIMPL;}
00129 STDMETHODIMP CBaseGraph::EnumFilters(IEnumFilters** ppEnum) {return E_NOTIMPL;}
00130 STDMETHODIMP CBaseGraph::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter) {return E_NOTIMPL;}
00131 STDMETHODIMP CBaseGraph::ConnectDirect(IPin* ppinOut, IPin* ppinIn, const AM_MEDIA_TYPE* pmt) {return E_NOTIMPL;}
00132 STDMETHODIMP CBaseGraph::Reconnect(IPin* ppin) {return E_NOTIMPL;}
00133 STDMETHODIMP CBaseGraph::Disconnect(IPin* ppin) {return E_NOTIMPL;}
00134 STDMETHODIMP CBaseGraph::SetDefaultSyncSource() {return E_NOTIMPL;}
00135
00136
00137 STDMETHODIMP CBaseGraph::Connect(IPin* ppinOut, IPin* ppinIn) {return E_NOTIMPL;}
00138 STDMETHODIMP CBaseGraph::Render(IPin* ppinOut) {return E_NOTIMPL;}
00139 STDMETHODIMP CBaseGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList) {return E_NOTIMPL;}
00140 STDMETHODIMP CBaseGraph::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrFilterName, IBaseFilter** ppFilter) {*ppFilter = NULL; return RenderFile(lpcwstrFileName, NULL);}
00141 STDMETHODIMP CBaseGraph::SetLogFile(DWORD_PTR hFile) {return E_NOTIMPL;}
00142 STDMETHODIMP CBaseGraph::Abort() {return E_NOTIMPL;}
00143 STDMETHODIMP CBaseGraph::ShouldOperationContinue() {return E_NOTIMPL;}
00144
00145
00146 STDMETHODIMP CBaseGraph::Run() {return E_NOTIMPL;}
00147 STDMETHODIMP CBaseGraph::Pause() {return E_NOTIMPL;}
00148 STDMETHODIMP CBaseGraph::Stop() {return E_NOTIMPL;}
00149 STDMETHODIMP CBaseGraph::GetState(LONG msTimeout, OAFilterState* pfs) {return E_NOTIMPL;}
00150 STDMETHODIMP CBaseGraph::RenderFile(BSTR strFilename) {return E_NOTIMPL;}
00151 STDMETHODIMP CBaseGraph::AddSourceFilter(BSTR strFilename, IDispatch** ppUnk) {return E_NOTIMPL;}
00152 STDMETHODIMP CBaseGraph::get_FilterCollection(IDispatch** ppUnk) {return E_NOTIMPL;}
00153 STDMETHODIMP CBaseGraph::get_RegFilterCollection(IDispatch** ppUnk) {return E_NOTIMPL;}
00154 STDMETHODIMP CBaseGraph::StopWhenReady() {return Stop();}
00155
00156
00157 STDMETHODIMP CBaseGraph::GetEventHandle(OAEVENT* hEvent) {return E_NOTIMPL;}
00158 STDMETHODIMP CBaseGraph::GetEvent(long* lEventCode, LONG_PTR* lParam1, LONG_PTR* lParam2, long msTimeout)
00159 {
00160 if(m_msgqueue.IsEmpty()) return E_FAIL;
00161
00162 GMSG msg = m_msgqueue.RemoveHead();
00163 if(lEventCode) *lEventCode = msg.m_lEventCode;
00164 if(lParam1) *lParam1 = msg.m_lParam1;
00165 if(lParam2) *lParam2 = msg.m_lParam2;
00166
00167 return S_OK;
00168 }
00169 STDMETHODIMP CBaseGraph::WaitForCompletion(long msTimeout, long* pEvCode) {return E_NOTIMPL;}
00170 STDMETHODIMP CBaseGraph::CancelDefaultHandling(long lEvCode) {return E_NOTIMPL;}
00171 STDMETHODIMP CBaseGraph::RestoreDefaultHandling(long lEvCode) {return E_NOTIMPL;}
00172 STDMETHODIMP CBaseGraph::FreeEventParams(long lEvCode, LONG_PTR lParam1, LONG_PTR lParam2)
00173 {
00174 if(EC_BG_ERROR == lEvCode)
00175 {
00176 if(lParam1) CoTaskMemFree((void*)lParam1);
00177 }
00178
00179 return S_OK;
00180 }
00181
00182
00183 STDMETHODIMP CBaseGraph::SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData)
00184 {
00185 m_hNotifyWnd = hwnd;
00186 m_lNotifyMsg = lMsg;
00187 m_lNotifyInstData = lInstanceData;
00188
00189 if(!IsWindow((HWND)m_hNotifyWnd))
00190 {
00191 m_hNotifyWnd = NULL;
00192 return E_FAIL;
00193 }
00194
00195 return S_OK;
00196 }
00197 STDMETHODIMP CBaseGraph::SetNotifyFlags(long lNoNotifyFlags) {return E_NOTIMPL;}
00198 STDMETHODIMP CBaseGraph::GetNotifyFlags(long* lplNoNotifyFlags) {return E_NOTIMPL;}
00199
00200
00201 STDMETHODIMP CBaseGraph::GetCapabilities(DWORD* pCapabilities)
00202 {
00203 return pCapabilities ? *pCapabilities = AM_SEEKING_CanSeekAbsolute|AM_SEEKING_CanGetCurrentPos|AM_SEEKING_CanGetDuration, S_OK : E_POINTER;
00204 }
00205 STDMETHODIMP CBaseGraph::CheckCapabilities(DWORD* pCapabilities)
00206 {
00207 CheckPointer(pCapabilities, E_POINTER);
00208
00209 if(*pCapabilities == 0) return S_OK;
00210
00211 DWORD caps;
00212 GetCapabilities(&caps);
00213
00214 DWORD caps2 = caps & *pCapabilities;
00215
00216 return caps2 == 0 ? E_FAIL : caps2 == *pCapabilities ? S_OK : S_FALSE;
00217 }
00218 STDMETHODIMP CBaseGraph::IsFormatSupported(const GUID* pFormat)
00219 {
00220 return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
00221 }
00222 STDMETHODIMP CBaseGraph::QueryPreferredFormat(GUID* pFormat)
00223 {
00224 return GetTimeFormat(pFormat);
00225 }
00226 STDMETHODIMP CBaseGraph::GetTimeFormat(GUID* pFormat)
00227 {
00228 return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
00229 }
00230 STDMETHODIMP CBaseGraph::IsUsingTimeFormat(const GUID* pFormat)
00231 {
00232 return IsFormatSupported(pFormat);
00233 }
00234 STDMETHODIMP CBaseGraph::SetTimeFormat(const GUID* pFormat)
00235 {
00236 return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
00237 }
00238 STDMETHODIMP CBaseGraph::GetDuration(LONGLONG* pDuration) {return E_NOTIMPL;}
00239 STDMETHODIMP CBaseGraph::GetStopPosition(LONGLONG* pStop) {return E_NOTIMPL;}
00240 STDMETHODIMP CBaseGraph::GetCurrentPosition(LONGLONG* pCurrent) {return E_NOTIMPL;}
00241 STDMETHODIMP CBaseGraph::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
00242 STDMETHODIMP CBaseGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {return E_NOTIMPL;}
00243 STDMETHODIMP CBaseGraph::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {return E_NOTIMPL;}
00244 STDMETHODIMP CBaseGraph::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {return E_NOTIMPL;}
00245 STDMETHODIMP CBaseGraph::SetRate(double dRate) {return E_NOTIMPL;}
00246 STDMETHODIMP CBaseGraph::GetRate(double* pdRate) {return E_NOTIMPL;}
00247 STDMETHODIMP CBaseGraph::GetPreroll(LONGLONG* pllPreroll) {return E_NOTIMPL;}
00248
00249
00250 STDMETHODIMP CBaseGraph::put_Caption(BSTR strCaption) {return E_NOTIMPL;}
00251 STDMETHODIMP CBaseGraph::get_Caption(BSTR* strCaption) {return E_NOTIMPL;}
00252 STDMETHODIMP CBaseGraph::put_WindowStyle(long WindowStyle) {return E_NOTIMPL;}
00253 STDMETHODIMP CBaseGraph::get_WindowStyle(long* WindowStyle) {return E_NOTIMPL;}
00254 STDMETHODIMP CBaseGraph::put_WindowStyleEx(long WindowStyleEx) {return E_NOTIMPL;}
00255 STDMETHODIMP CBaseGraph::get_WindowStyleEx(long* WindowStyleEx) {return E_NOTIMPL;}
00256 STDMETHODIMP CBaseGraph::put_AutoShow(long AutoShow) {return E_NOTIMPL;}
00257 STDMETHODIMP CBaseGraph::get_AutoShow(long* AutoShow) {return E_NOTIMPL;}
00258 STDMETHODIMP CBaseGraph::put_WindowState(long WindowState) {return E_NOTIMPL;}
00259 STDMETHODIMP CBaseGraph::get_WindowState(long* WindowState) {return E_NOTIMPL;}
00260 STDMETHODIMP CBaseGraph::put_BackgroundPalette(long BackgroundPalette) {return E_NOTIMPL;}
00261 STDMETHODIMP CBaseGraph::get_BackgroundPalette(long* pBackgroundPalette) {return E_NOTIMPL;}
00262 STDMETHODIMP CBaseGraph::put_Visible(long Visible) {return E_NOTIMPL;}
00263 STDMETHODIMP CBaseGraph::get_Visible(long* pVisible) {return E_NOTIMPL;}
00264 STDMETHODIMP CBaseGraph::put_Left(long Left) {return E_NOTIMPL;}
00265 STDMETHODIMP CBaseGraph::get_Left(long* pLeft) {return E_NOTIMPL;}
00266 STDMETHODIMP CBaseGraph::put_Width(long Width) {return E_NOTIMPL;}
00267 STDMETHODIMP CBaseGraph::get_Width(long* pWidth) {return E_NOTIMPL;}
00268 STDMETHODIMP CBaseGraph::put_Top(long Top) {return E_NOTIMPL;}
00269 STDMETHODIMP CBaseGraph::get_Top(long* pTop) {return E_NOTIMPL;}
00270 STDMETHODIMP CBaseGraph::put_Height(long Height) {return E_NOTIMPL;}
00271 STDMETHODIMP CBaseGraph::get_Height(long* pHeight) {return E_NOTIMPL;}
00272 STDMETHODIMP CBaseGraph::put_Owner(OAHWND Owner) {return E_NOTIMPL;}
00273 STDMETHODIMP CBaseGraph::get_Owner(OAHWND* Owner) {return E_NOTIMPL;}
00274 STDMETHODIMP CBaseGraph::put_MessageDrain(OAHWND Drain) {return E_NOTIMPL;}
00275 STDMETHODIMP CBaseGraph::get_MessageDrain(OAHWND* Drain) {return E_NOTIMPL;}
00276 STDMETHODIMP CBaseGraph::get_BorderColor(long* Color) {return E_NOTIMPL;}
00277 STDMETHODIMP CBaseGraph::put_BorderColor(long Color) {return E_NOTIMPL;}
00278 STDMETHODIMP CBaseGraph::get_FullScreenMode(long* FullScreenMode) {return E_NOTIMPL;}
00279 STDMETHODIMP CBaseGraph::put_FullScreenMode(long FullScreenMode) {return E_NOTIMPL;}
00280 STDMETHODIMP CBaseGraph::SetWindowForeground(long Focus) {return E_NOTIMPL;}
00281 STDMETHODIMP CBaseGraph::NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam) {return E_NOTIMPL;}
00282 STDMETHODIMP CBaseGraph::SetWindowPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
00283 STDMETHODIMP CBaseGraph::GetWindowPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
00284 STDMETHODIMP CBaseGraph::GetMinIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
00285 STDMETHODIMP CBaseGraph::GetMaxIdealImageSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
00286 STDMETHODIMP CBaseGraph::GetRestorePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
00287 STDMETHODIMP CBaseGraph::HideCursor(long HideCursor) {return E_NOTIMPL;}
00288 STDMETHODIMP CBaseGraph::IsCursorHidden(long* CursorHidden) {return E_NOTIMPL;}
00289
00290
00291 STDMETHODIMP CBaseGraph::get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {return E_NOTIMPL;}
00292 STDMETHODIMP CBaseGraph::get_BitRate(long* pBitRate) {return E_NOTIMPL;}
00293 STDMETHODIMP CBaseGraph::get_BitErrorRate(long* pBitErrorRate) {return E_NOTIMPL;}
00294 STDMETHODIMP CBaseGraph::get_VideoWidth(long* pVideoWidth) {return E_NOTIMPL;}
00295 STDMETHODIMP CBaseGraph::get_VideoHeight(long* pVideoHeight) {return E_NOTIMPL;}
00296 STDMETHODIMP CBaseGraph::put_SourceLeft(long SourceLeft) {return E_NOTIMPL;}
00297 STDMETHODIMP CBaseGraph::get_SourceLeft(long* pSourceLeft) {return E_NOTIMPL;}
00298 STDMETHODIMP CBaseGraph::put_SourceWidth(long SourceWidth) {return E_NOTIMPL;}
00299 STDMETHODIMP CBaseGraph::get_SourceWidth(long* pSourceWidth) {return E_NOTIMPL;}
00300 STDMETHODIMP CBaseGraph::put_SourceTop(long SourceTop) {return E_NOTIMPL;}
00301 STDMETHODIMP CBaseGraph::get_SourceTop(long* pSourceTop) {return E_NOTIMPL;}
00302 STDMETHODIMP CBaseGraph::put_SourceHeight(long SourceHeight) {return E_NOTIMPL;}
00303 STDMETHODIMP CBaseGraph::get_SourceHeight(long* pSourceHeight) {return E_NOTIMPL;}
00304 STDMETHODIMP CBaseGraph::put_DestinationLeft(long DestinationLeft) {return E_NOTIMPL;}
00305 STDMETHODIMP CBaseGraph::get_DestinationLeft(long* pDestinationLeft) {return E_NOTIMPL;}
00306 STDMETHODIMP CBaseGraph::put_DestinationWidth(long DestinationWidth) {return E_NOTIMPL;}
00307 STDMETHODIMP CBaseGraph::get_DestinationWidth(long* pDestinationWidth) {return E_NOTIMPL;}
00308 STDMETHODIMP CBaseGraph::put_DestinationTop(long DestinationTop) {return E_NOTIMPL;}
00309 STDMETHODIMP CBaseGraph::get_DestinationTop(long* pDestinationTop) {return E_NOTIMPL;}
00310 STDMETHODIMP CBaseGraph::put_DestinationHeight(long DestinationHeight) {return E_NOTIMPL;}
00311 STDMETHODIMP CBaseGraph::get_DestinationHeight(long* pDestinationHeight) {return E_NOTIMPL;}
00312 STDMETHODIMP CBaseGraph::SetSourcePosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
00313 STDMETHODIMP CBaseGraph::GetSourcePosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
00314 STDMETHODIMP CBaseGraph::SetDefaultSourcePosition() {return E_NOTIMPL;}
00315 STDMETHODIMP CBaseGraph::SetDestinationPosition(long Left, long Top, long Width, long Height) {return E_NOTIMPL;}
00316 STDMETHODIMP CBaseGraph::GetDestinationPosition(long* pLeft, long* pTop, long* pWidth, long* pHeight) {return E_NOTIMPL;}
00317 STDMETHODIMP CBaseGraph::SetDefaultDestinationPosition() {return E_NOTIMPL;}
00318 STDMETHODIMP CBaseGraph::GetVideoSize(long* pWidth, long* pHeight) {return E_NOTIMPL;}
00319 STDMETHODIMP CBaseGraph::GetVideoPaletteEntries(long StartIndex, long Entries, long* pRetrieved, long* pPalette) {return E_NOTIMPL;}
00320 STDMETHODIMP CBaseGraph::GetCurrentImage(long* pBufferSize, long* pDIBImage) {return E_NOTIMPL;}
00321 STDMETHODIMP CBaseGraph::IsUsingDefaultSource() {return E_NOTIMPL;}
00322 STDMETHODIMP CBaseGraph::IsUsingDefaultDestination() {return E_NOTIMPL;}
00323
00324
00325 STDMETHODIMP CBaseGraph::put_Volume(long lVolume) {return E_NOTIMPL;}
00326 STDMETHODIMP CBaseGraph::get_Volume(long* plVolume) {return E_NOTIMPL;}
00327 STDMETHODIMP CBaseGraph::put_Balance(long lBalance) {return E_NOTIMPL;}
00328 STDMETHODIMP CBaseGraph::get_Balance(long* plBalance) {return E_NOTIMPL;}
00329
00330
00331 STDMETHODIMP CBaseGraph::QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent) {return E_NOTIMPL;}
00332 STDMETHODIMP CBaseGraph::AbortOperation() {return E_NOTIMPL;}
00333
00334
00335 STDMETHODIMP_(engine_t) CBaseGraph::GetEngine() {return DirectShow;}