From dca995e8145e94620be2d097c7a55a2830575f47 Mon Sep 17 00:00:00 2001 From: Underground78 Date: Sat, 28 Sep 2013 17:30:14 +0200 Subject: [MPC-HC] Tray icon: Add an optional custom callback for "show property page" events. --- common/DSUtilLite/BaseTrayIcon.cpp | 22 ++++++++++++++++++---- common/DSUtilLite/BaseTrayIcon.h | 2 ++ common/includes/LAVSplitterSettings.h | 10 ++++++++++ decoder/LAVAudio/LAVAudio.cpp | 11 +++++++++++ decoder/LAVAudio/LAVAudio.h | 8 +++++++- decoder/LAVAudio/LAVAudioSettings.h | 10 ++++++++++ decoder/LAVVideo/LAVVideo.cpp | 12 ++++++++++++ decoder/LAVVideo/LAVVideo.h | 9 ++++++++- decoder/LAVVideo/LAVVideoSettings.h | 10 ++++++++++ demuxer/LAVSplitter/LAVSplitter.cpp | 11 +++++++++++ demuxer/LAVSplitter/LAVSplitter.h | 5 +++++ 11 files changed, 104 insertions(+), 6 deletions(-) diff --git a/common/DSUtilLite/BaseTrayIcon.cpp b/common/DSUtilLite/BaseTrayIcon.cpp index 5ff69d05..77373749 100644 --- a/common/DSUtilLite/BaseTrayIcon.cpp +++ b/common/DSUtilLite/BaseTrayIcon.cpp @@ -184,12 +184,26 @@ HRESULT CBaseTrayIcon::CreateTrayIconData() HRESULT CBaseTrayIcon::OpenPropPage() { CheckPointer(m_pFilter, E_UNEXPECTED); + HRESULT hr = E_UNEXPECTED; + m_bPropPageOpen = TRUE; - RECT desktopRect; - GetWindowRect(GetDesktopWindow(), &desktopRect); - SetWindowPos(m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET, 0, 0, SWP_NOZORDER | SWP_NOSIZE); - CBaseDSPropPage::ShowPropPageDialog(m_pFilter, m_hWnd); + if (!m_fpCustomOpenPropPage) { + RECT desktopRect; + GetWindowRect(GetDesktopWindow(), &desktopRect); + SetWindowPos(m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET, 0, 0, SWP_NOZORDER | SWP_NOSIZE); + CBaseDSPropPage::ShowPropPageDialog(m_pFilter, m_hWnd); + hr = S_OK; + } else { + hr = m_fpCustomOpenPropPage(m_pFilter); + } m_bPropPageOpen = FALSE; + + return hr; +} + +HRESULT CBaseTrayIcon::SetCustomOpenPropPage(HRESULT (*fpCustomOpenPropPage)(IBaseFilter* pFilter)) +{ + m_fpCustomOpenPropPage = fpCustomOpenPropPage; return S_OK; } diff --git a/common/DSUtilLite/BaseTrayIcon.h b/common/DSUtilLite/BaseTrayIcon.h index d5a3872f..8805e1d2 100644 --- a/common/DSUtilLite/BaseTrayIcon.h +++ b/common/DSUtilLite/BaseTrayIcon.h @@ -28,6 +28,7 @@ public: virtual ~CBaseTrayIcon(void); static BOOL ProcessBlackList(); + HRESULT SetCustomOpenPropPage(HRESULT (*fpCustomOpenPropPage)(IBaseFilter* pFilter)); protected: virtual HRESULT CreateTrayIconData(); @@ -56,6 +57,7 @@ private: HANDLE m_hThread = 0; HWND m_hWnd = 0; BOOL m_bPropPageOpen = FALSE; + HRESULT (*m_fpCustomOpenPropPage)(IBaseFilter* pFilter) = nullptr; WCHAR m_wszClassName[64]; const WCHAR *m_wszName = nullptr; diff --git a/common/includes/LAVSplitterSettings.h b/common/includes/LAVSplitterSettings.h index 29f1164e..8b50d490 100644 --- a/common/includes/LAVSplitterSettings.h +++ b/common/includes/LAVSplitterSettings.h @@ -25,6 +25,10 @@ DEFINE_GUID(IID_ILAVFSettings, 0x774a919d, 0xea95, 0x4a87, 0x8a, 0x1e, 0xf4, 0x8a, 0xbe, 0x84, 0x99, 0xc7); +// {77C1027F-BF53-458F-82CE-9DD88A2C300B} +DEFINE_GUID(IID_ILAVFSettingsMPCHCCustom, +0x77c1027f, 0xbf53, 0x458f, 0x82, 0xce, 0x9d, 0xd8, 0x8a, 0x2c, 0x30, 0xb); + typedef enum LAVSubtitleMode { LAVSubtitleMode_NoSubs, LAVSubtitleMode_ForcedOnly, @@ -190,3 +194,9 @@ interface __declspec(uuid("774A919D-EA95-4A87-8A1E-F48ABE8499C7")) ILAVFSettings // Get the maximum queue size, in number of packets STDMETHOD_(DWORD, GetMaxQueueSize)() = 0; }; + +DECLARE_INTERFACE_IID_(ILAVFSettingsMPCHCCustom, IUnknown, "77C1027F-BF53-458F-82CE-9DD88A2C300B") +{ + // Set a custom callback function to handle the property page + STDMETHOD(SetPropertyPageCallback)(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) = 0; +}; diff --git a/decoder/LAVAudio/LAVAudio.cpp b/decoder/LAVAudio/LAVAudio.cpp index fc603348..8a5267fe 100644 --- a/decoder/LAVAudio/LAVAudio.cpp +++ b/decoder/LAVAudio/LAVAudio.cpp @@ -134,6 +134,7 @@ STDMETHODIMP CLAVAudio::CreateTrayIcon() if (CBaseTrayIcon::ProcessBlackList()) return S_FALSE; m_pTrayIcon = new CBaseTrayIcon(this, TEXT(LAV_AUDIO), IDI_ICON1); + m_pTrayIcon->SetCustomOpenPropPage(m_fpPropPageCallback); return S_OK; } @@ -424,6 +425,7 @@ STDMETHODIMP CLAVAudio::NonDelegatingQueryInterface(REFIID riid, void** ppv) QI(ISpecifyPropertyPages) QI(ISpecifyPropertyPages2) QI2(ILAVAudioSettings) + QI2(ILAVAudioSettingsMPCHCCustom) QI2(ILAVAudioStatus) __super::NonDelegatingQueryInterface(riid, ppv); } @@ -802,6 +804,15 @@ STDMETHODIMP_(BOOL) CLAVAudio::GetOutput51LegacyLayout() return m_settings.Output51Legacy; } +// ILAVAudioSettingsMPCHCCustom +STDMETHODIMP CLAVAudio::SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) +{ + m_fpPropPageCallback = fpPropPageCallback; + if (m_pTrayIcon) + m_pTrayIcon->SetCustomOpenPropPage(fpPropPageCallback); + return S_OK; +} + // ILAVAudioStatus BOOL CLAVAudio::IsSampleFormatSupported(LAVAudioSampleFormat sfCheck) { diff --git a/decoder/LAVAudio/LAVAudio.h b/decoder/LAVAudio/LAVAudio.h index b5e5c81b..65c5437c 100644 --- a/decoder/LAVAudio/LAVAudio.h +++ b/decoder/LAVAudio/LAVAudio.h @@ -79,7 +79,9 @@ struct BufferDetails { struct DTSDecoder; -class __declspec(uuid("E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491")) CLAVAudio : public CTransformFilter, public ISpecifyPropertyPages2, public ILAVAudioSettings, public ILAVAudioStatus +class __declspec(uuid("E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491")) CLAVAudio : public CTransformFilter, public ISpecifyPropertyPages2, + public ILAVAudioSettings, public ILAVAudioSettingsMPCHCCustom, + public ILAVAudioStatus { public: CLAVAudio(LPUNKNOWN pUnk, HRESULT* phr); @@ -138,6 +140,9 @@ public: STDMETHODIMP SetOutput51LegacyLayout(BOOL b51Legacy); STDMETHODIMP_(BOOL) GetOutput51LegacyLayout(); + // ILAVAudioSettingsMPCHCCustom + STDMETHODIMP SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)); + // ILAVAudioStatus STDMETHODIMP_(BOOL) IsSampleFormatSupported(LAVAudioSampleFormat sfCheck); STDMETHODIMP GetDecodeDetails(const char **pCodec, const char **pDecodeFormat, int *pnChannels, int *pSampleRate, DWORD *pChannelMask); @@ -353,4 +358,5 @@ private: } m_raData; CBaseTrayIcon *m_pTrayIcon = nullptr; + HRESULT (*m_fpPropPageCallback)(IBaseFilter* pFilter) = nullptr; }; diff --git a/decoder/LAVAudio/LAVAudioSettings.h b/decoder/LAVAudio/LAVAudioSettings.h index 1bbb0d9d..3198f097 100644 --- a/decoder/LAVAudio/LAVAudioSettings.h +++ b/decoder/LAVAudio/LAVAudioSettings.h @@ -23,6 +23,10 @@ DEFINE_GUID(IID_ILAVAudioSettings, 0x4158a22b, 0x6553, 0x45d0, 0x80, 0x69, 0x24, 0x71, 0x6f, 0x8f, 0xf1, 0x71); +// {40A1D048-D41B-4D53-B737-FF9F99A245A0} +DEFINE_GUID(IID_ILAVAudioSettingsMPCHCCustom, + 0x40a1d048, 0xd41b, 0x4d53, 0xb7, 0x37, 0xff, 0x9f, 0x99, 0xa2, 0x45, 0xa0); + // {A668B8F2-BA87-4F63-9D41-768F7DE9C50E} DEFINE_GUID(IID_ILAVAudioStatus, 0xa668b8f2, 0xba87, 0x4f63, 0x9d, 0x41, 0x76, 0x8f, 0x7d, 0xe9, 0xc5, 0xe); @@ -195,6 +199,12 @@ interface __declspec(uuid("4158A22B-6553-45D0-8069-24716F8FF171")) ILAVAudioSett STDMETHOD(SetOutput51LegacyLayout)(BOOL b51Legacy) = 0; }; +DECLARE_INTERFACE_IID_(ILAVAudioSettingsMPCHCCustom, IUnknown, "40A1D048-D41B-4D53-B737-FF9F99A245A0") +{ + // Set a custom callback function to handle the property page + STDMETHOD(SetPropertyPageCallback)(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) = 0; +}; + // LAV Audio Status Interface // Get the current playback stats interface __declspec(uuid("A668B8F2-BA87-4F63-9D41-768F7DE9C50E")) ILAVAudioStatus : public IUnknown diff --git a/decoder/LAVVideo/LAVVideo.cpp b/decoder/LAVVideo/LAVVideo.cpp index 2cacd37d..9d582bd0 100644 --- a/decoder/LAVVideo/LAVVideo.cpp +++ b/decoder/LAVVideo/LAVVideo.cpp @@ -55,6 +55,7 @@ void CALLBACK CLAVVideo::StaticInit(BOOL bLoading, const CLSID *clsid) CLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr) : CTransformFilter(NAME("LAV Video Decoder"), 0, __uuidof(CLAVVideo)) , m_Decoder(this) + , m_fpPropPageCallback(NULL) { *phr = S_OK; m_pInput = new CVideoInputPin(TEXT("CVideoInputPin"), this, phr, L"Input"); @@ -114,6 +115,7 @@ HRESULT CLAVVideo::CreateTrayIcon() if (CBaseTrayIcon::ProcessBlackList()) return S_FALSE; m_pTrayIcon = new CBaseTrayIcon(this, TEXT(LAV_VIDEO), IDI_ICON1); + m_pTrayIcon->SetCustomOpenPropPage(m_fpPropPageCallback); return S_OK; } @@ -410,6 +412,7 @@ STDMETHODIMP CLAVVideo::NonDelegatingQueryInterface(REFIID riid, void** ppv) QI(ISpecifyPropertyPages2) QI(IPropertyBag) QI2(ILAVVideoSettings) + QI2(ILAVVideoSettingsMPCHCCustom) QI2(ILAVVideoStatus) __super::NonDelegatingQueryInterface(riid, ppv); } @@ -2517,3 +2520,12 @@ STDMETHODIMP CLAVVideo::GetHWAccelActiveDevice(BSTR *pstrDeviceName) { return m_Decoder.GetHWAccelActiveDevice(pstrDeviceName); } + +// ILAVVideoSettingsMPCHCCustom +STDMETHODIMP CLAVVideo::SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) +{ + m_fpPropPageCallback = fpPropPageCallback; + if (m_pTrayIcon) + m_pTrayIcon->SetCustomOpenPropPage(fpPropPageCallback); + return S_OK; +} diff --git a/decoder/LAVVideo/LAVVideo.h b/decoder/LAVVideo/LAVVideo.h index 2fcd68cd..d1563a4a 100644 --- a/decoder/LAVVideo/LAVVideo.h +++ b/decoder/LAVVideo/LAVVideo.h @@ -55,7 +55,10 @@ typedef struct { REFERENCE_TIME rtStop; } TimingCache; -class __declspec(uuid("EE30215D-164F-4A92-A4EB-9D4C13390F9F")) CLAVVideo : public CTransformFilter, public ISpecifyPropertyPages2, public ILAVVideoSettings, public ILAVVideoStatus, public ILAVVideoCallback, public IPropertyBag +class __declspec(uuid("EE30215D-164F-4A92-A4EB-9D4C13390F9F")) CLAVVideo : public CTransformFilter, public ISpecifyPropertyPages2, + public ILAVVideoSettings, public ILAVVideoStatus, + public ILAVVideoCallback, public IPropertyBag, + public ILAVVideoSettingsMPCHCCustom { public: CLAVVideo(LPUNKNOWN pUnk, HRESULT* phr); @@ -138,6 +141,9 @@ public: STDMETHODIMP SetH264MVCDecodingOverride(BOOL bEnabled); + // ILAVVideoSettingsMPCHCCustom + STDMETHODIMP SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)); + // ILAVVideoStatus STDMETHODIMP_(const WCHAR *) GetActiveDecoderName() { return m_Decoder.GetDecoderName(); } STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName); @@ -312,6 +318,7 @@ private: DWORD m_dwGPUDeviceIndex = DWORD_MAX; CBaseTrayIcon *m_pTrayIcon = nullptr; + HRESULT (*m_fpPropPageCallback)(IBaseFilter* pFilter) = nullptr; #ifdef DEBUG FloatingAverage m_pixFmtTimingAvg; diff --git a/decoder/LAVVideo/LAVVideoSettings.h b/decoder/LAVVideo/LAVVideoSettings.h index 8a5a93a8..b72272e8 100644 --- a/decoder/LAVVideo/LAVVideoSettings.h +++ b/decoder/LAVVideo/LAVVideoSettings.h @@ -23,6 +23,10 @@ DEFINE_GUID(IID_ILAVVideoSettings, 0xfa40d6e9, 0x4d38, 0x4761, 0xad, 0xd2, 0x71, 0xa9, 0xec, 0x5f, 0xd3, 0x2f); +// {F3BB90A3-B1CE-48C1-954C-3A506A33DE25} +DEFINE_GUID(IID_ILAVVideoSettingsMPCHCCustom, +0xf3bb90a3, 0xb1ce, 0x48c1, 0x95, 0x4c, 0x3a, 0x50, 0x6a, 0x33, 0xde, 0x25); + // {1CC2385F-36FA-41B1-9942-5024CE0235DC} DEFINE_GUID(IID_ILAVVideoStatus, 0x1cc2385f, 0x36fa, 0x41b1, 0x99, 0x42, 0x50, 0x24, 0xce, 0x2, 0x35, 0xdc); @@ -386,6 +390,12 @@ interface __declspec(uuid("FA40D6E9-4D38-4761-ADD2-71A9EC5FD32F")) ILAVVideoSett STDMETHOD(SetH264MVCDecodingOverride)(BOOL bEnabled) = 0; }; +DECLARE_INTERFACE_IID_(ILAVVideoSettingsMPCHCCustom, IUnknown, "F3BB90A3-B1CE-48C1-954C-3A506A33DE25") +{ + // Set a custom callback function to handle the property page + STDMETHOD(SetPropertyPageCallback)(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) = 0; +}; + // LAV Video status interface interface __declspec(uuid("1CC2385F-36FA-41B1-9942-5024CE0235DC")) ILAVVideoStatus : public IUnknown { diff --git a/demuxer/LAVSplitter/LAVSplitter.cpp b/demuxer/LAVSplitter/LAVSplitter.cpp index 4cf7ae21..e48941ef 100644 --- a/demuxer/LAVSplitter/LAVSplitter.cpp +++ b/demuxer/LAVSplitter/LAVSplitter.cpp @@ -117,6 +117,7 @@ STDMETHODIMP CLAVSplitter::CreateTrayIcon() if (CBaseTrayIcon::ProcessBlackList()) return S_FALSE; m_pTrayIcon = new CLAVSplitterTrayIcon(this, TEXT(LAV_SPLITTER), IDI_ICON1); + m_pTrayIcon->SetCustomOpenPropPage(m_fpPropPageCallback); return S_OK; } @@ -315,6 +316,7 @@ STDMETHODIMP CLAVSplitter::NonDelegatingQueryInterface(REFIID riid, void** ppv) QI(ISpecifyPropertyPages2) QI2(ILAVFSettings) QI2(ILAVFSettingsInternal) + QI2(ILAVFSettingsMPCHCCustom) QI(IObjectWithSite) QI(IBufferInfo) __super::NonDelegatingQueryInterface(riid, ppv); @@ -1870,6 +1872,15 @@ STDMETHODIMP_(std::set&) CLAVSplitter::GetInputFormats() return m_InputFormats; } +// ILAVFSettingsMPCHCCustom +STDMETHODIMP CLAVSplitter::SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)) +{ + m_fpPropPageCallback = fpPropPageCallback; + if (m_pTrayIcon) + m_pTrayIcon->SetCustomOpenPropPage(fpPropPageCallback); + return S_OK; +} + CLAVSplitterSource::CLAVSplitterSource(LPUNKNOWN pUnk, HRESULT* phr) : CLAVSplitter(pUnk, phr) { diff --git a/demuxer/LAVSplitter/LAVSplitter.h b/demuxer/LAVSplitter/LAVSplitter.h index 59822a5f..8b58f485 100644 --- a/demuxer/LAVSplitter/LAVSplitter.h +++ b/demuxer/LAVSplitter/LAVSplitter.h @@ -61,6 +61,7 @@ class __declspec(uuid("171252A0-8820-4AFE-9DF8-5C92B2D66B04")) CLAVSplitter , public IAMStreamSelect , public IAMOpenProgress , public ILAVFSettingsInternal + , public ILAVFSettingsMPCHCCustom , public ISpecifyPropertyPages2 , public IObjectWithSite , public IBufferInfo @@ -175,6 +176,9 @@ public: STDMETHODIMP SetMaxQueueSize(DWORD dwMaxSize); STDMETHODIMP_(DWORD) GetMaxQueueSize(); + // ILAVFSettingsMPCHCCustom + STDMETHODIMP SetPropertyPageCallback(HRESULT (*fpPropPageCallback)(IBaseFilter* pFilter)); + // ILAVSplitterSettingsInternal STDMETHODIMP_(LPCSTR) GetInputFormat() { if (m_pDemuxer) return m_pDemuxer->GetContainerFormat(); return nullptr; } STDMETHODIMP_(std::set&) GetInputFormats(); @@ -298,6 +302,7 @@ private: IUnknown *m_pSite = nullptr; CBaseTrayIcon *m_pTrayIcon = nullptr; + HRESULT (*m_fpPropPageCallback)(IBaseFilter* pFilter) = nullptr; }; class __declspec(uuid("B98D13E7-55DB-4385-A33D-09FD1BA26338")) CLAVSplitterSource : public CLAVSplitter -- cgit v1.2.3