1 /*******************************************************************************
3 * This file is part of the Ogg Vorbis DirectShow filter collection *
5 * Copyright (c) 2001, Tobias Waldvogel *
6 * All rights reserved. *
8 * Redistribution and use in source and binary forms, with or without *
9 * modification, are permitted provided that the following conditions are met: *
11 * - Redistributions of source code must retain the above copyright notice, *
12 * this list of conditions and the following disclaimer. *
14 * - Redistributions in binary form must reproduce the above copyright notice, *
15 * this list of conditions and the following disclaimer in the documentation *
16 * and/or other materials provided with the distribution. *
18 * - The names of the contributors may not be used to endorse or promote *
19 * products derived from this software without specific prior written *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" *
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE *
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF *
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN *
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) *
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
32 * POSSIBILITY OF SUCH DAMAGE. *
34 *******************************************************************************/
36 #include "OggSplitterDS.h"
37 #include "..\resource.h"
42 COggSplitPropPage::COggSplitPropPage(LPUNKNOWN pUnk
, HRESULT
*phr
) :
43 CBasePropertyPage(NAME("Vorbis Compressor property page"), pUnk
,
44 IDD_PROPPAGE_SPLITTER
, IDS_PROPPAGE_SPLITTER_TITLE
)
46 m_pPersistPropertyBag
= NULL
;
50 HRESULT
COggSplitPropPage::OnConnect(IUnknown
*pUnknown
)
52 return pUnknown
->QueryInterface(IID_IPersistPropertyBag
, (void **)&m_pPersistPropertyBag
);
55 HRESULT
COggSplitPropPage::OnDisconnect()
57 if (m_pPersistPropertyBag
)
59 m_pPersistPropertyBag
->Release();
60 m_pPersistPropertyBag
= NULL
;
65 void COggSplitPropPage::DeleteFourCC(char* wzFOURCC
)
70 while (SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_GETTEXT
,
71 (LPARAM
)iIndex
, (WPARAM
)szBuffer
) != LB_ERR
)
73 if (strncmp(szBuffer
, wzFOURCC
, 4) == 0)
75 SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_DELETESTRING
, (LPARAM
)iIndex
, 0);
82 void COggSplitPropPage::SetProperty(const char* pProp
, char* pVal
)
88 mbstowcs(wzName
, pProp
, sizeof(wzName
));
91 V
.bstrVal
= SysAllocStringLen(NULL
, strlen(pVal
));
92 mbstowcs(V
.bstrVal
, pVal
, strlen(pVal
)+1);
94 m_pPersistPropertyBag
->QueryInterface(IID_IPropertyBag
, (void**)&pPBag
);
95 pPBag
->Write(wzName
, &V
);
100 BOOL
COggSplitPropPage::OnReceiveMessage(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
108 if (uMsg
== WM_COMMAND
)
110 if ((LOWORD(wParam
) == IDC_SEARCH_KEYFRAME
&& HIWORD(wParam
) == BN_CLICKED
) ||
111 (LOWORD(wParam
) == IDC_ALWAYS_ENABLE_ALL
&& HIWORD(wParam
) == BN_CLICKED
) ||
112 (LOWORD(wParam
) == IDC_SHOWTRAYICON
&& HIWORD(wParam
) == BN_CLICKED
))
115 m_pPageSite
->OnStatusChange(PROPPAGESTATUS_DIRTY
);
119 if (LOWORD(wParam
) == IDC_ENABLE_ALL_STREAMS
&& HIWORD(wParam
) == BN_CLICKED
)
121 SetProperty(idEnableAllStreams
, "1");
126 if (LOWORD(wParam
) == IDC_FOURCC_MAPPINGS
&& HIWORD(wParam
) == LBN_SELCHANGE
)
130 iIndex
= SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_GETCURSEL
, 0, 0);
131 EnableWindow(GetDlgItem(m_Dlg
, IDC_FOURCC_SET
), iIndex
>= 0);
132 EnableWindow(GetDlgItem(m_Dlg
, IDC_FOURCC_DEL
), iIndex
>= 0);
136 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)&szEmpty
);
137 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)&szEmpty
);
141 SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_GETTEXT
, (LPARAM
)iIndex
, (WPARAM
)szMap
);
142 pPos
= strstr(szMap
, " -> ");
144 if (pPos
!= NULL
) *pPos
= '\0';
146 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)szMap
);
148 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)(pPos
+6));
150 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)&szEmpty
);
154 if (LOWORD(wParam
) == IDC_SRC_FOURCC
&& HIWORD(wParam
) == EN_CHANGE
)
156 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_GETTEXT
, 20, (WPARAM
)szMap
);
157 EnableWindow(GetDlgItem(m_Dlg
, IDC_FOURCC_SET
), *szMap
!= '\0');
158 EnableWindow(GetDlgItem(m_Dlg
, IDC_FOURCC_DEL
), *szMap
!= '\0');
162 if (LOWORD(wParam
) == IDC_FOURCC_SET
&& HIWORD(wParam
) == BN_CLICKED
)
166 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_GETTEXT
, 20, (WPARAM
)szSrc
);
167 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_GETTEXT
, 20, (WPARAM
)szDst
);
168 for (i
=strlen(szSrc
); i
<4; i
++)
171 for (i
=strlen(szDst
); i
<4; i
++)
176 wsprintf(szMap
, "%s -> %s", szSrc
, szDst
);
177 SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_ADDSTRING
, 0, (LPARAM
)szMap
);
179 SetProperty(szSrc
, szDst
);
183 if (LOWORD(wParam
) == IDC_FOURCC_DEL
&& HIWORD(wParam
) == BN_CLICKED
)
187 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_GETTEXT
, 20, (WPARAM
)szSrc
);
188 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_GETTEXT
, 20, (WPARAM
)szDst
);
189 for (i
=strlen(szSrc
); i
<4; i
++)
192 for (i
=strlen(szDst
); i
<4; i
++)
198 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)&szEmpty
);
199 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, WM_SETTEXT
, 0, (WPARAM
)&szEmpty
);
201 SetProperty(szSrc
, "");
208 return CBasePropertyPage::OnReceiveMessage(hwnd
, uMsg
, wParam
, lParam
);
211 HRESULT
COggSplitPropPage::OnActivate(void)
213 SendDlgItemMessage(m_Dlg
, IDC_SRC_FOURCC
, EM_LIMITTEXT
, 4, 0);
214 SendDlgItemMessage(m_Dlg
, IDC_DST_FOURCC
, EM_LIMITTEXT
, 4, 0);
215 return m_pPersistPropertyBag
->Save(this, TRUE
, TRUE
);
218 HRESULT
COggSplitPropPage::OnApplyChanges(void)
220 return m_pPersistPropertyBag
->Load(this, NULL
);
223 HRESULT STDMETHODCALLTYPE
COggSplitPropPage::Read(LPCOLESTR pszPropName
, VARIANT
*pVar
, IErrorLog
*pErrorLog
)
227 wcstombs(szName
, pszPropName
, sizeof(szName
));
230 if (strcmp(szName
, idSeekToKeyFrame
) == 0)
233 pVar
->boolVal
= (SendDlgItemMessage(m_Dlg
, IDC_SEARCH_KEYFRAME
, BM_GETSTATE
, 0, 0) & BST_CHECKED
) != 0;
236 if (strcmp(szName
, idAlwaysEnableAllStreams
) == 0)
239 pVar
->boolVal
= (SendDlgItemMessage(m_Dlg
, IDC_ALWAYS_ENABLE_ALL
, BM_GETSTATE
, 0, 0) & BST_CHECKED
) != 0;
242 if (strcmp(szName
, idShowTrayIcon
) == 0)
245 pVar
->boolVal
= (SendDlgItemMessage(m_Dlg
, IDC_SHOWTRAYICON
, BM_GETSTATE
, 0, 0) & BST_CHECKED
) != 0;
252 HRESULT STDMETHODCALLTYPE
COggSplitPropPage::Write(LPCOLESTR pszPropName
, VARIANT
*pVar
)
256 wcstombs(szName
, pszPropName
, sizeof(szName
));
258 if (strcmp(szName
, idSeekToKeyFrame
) == 0)
262 VariantChangeType(pVar
, pVar
, 0, VT_BOOL
);
263 CheckState
= pVar
->boolVal
? BST_CHECKED
: BST_UNCHECKED
;
264 SendDlgItemMessage(m_Dlg
, IDC_SEARCH_KEYFRAME
, BM_SETCHECK
, CheckState
, 0);
267 if (strcmp(szName
, idAlwaysEnableAllStreams
) == 0)
271 VariantChangeType(pVar
, pVar
, 0, VT_BOOL
);
272 CheckState
= pVar
->boolVal
? BST_CHECKED
: BST_UNCHECKED
;
273 SendDlgItemMessage(m_Dlg
, IDC_ALWAYS_ENABLE_ALL
, BM_SETCHECK
, CheckState
, 0);
276 if (strcmp(szName
, idShowTrayIcon
) == 0)
280 VariantChangeType(pVar
, pVar
, 0, VT_BOOL
);
281 CheckState
= pVar
->boolVal
? BST_CHECKED
: BST_UNCHECKED
;
282 SendDlgItemMessage(m_Dlg
, IDC_SHOWTRAYICON
, BM_SETCHECK
, CheckState
, 0);
286 if (wcslen(pszPropName
) == 4)
290 VariantChangeType(pVar
, pVar
, 0, VT_BSTR
);
291 wsprintf(szCaption
, "%S -> %S", pszPropName
, pVar
->bstrVal
);
292 SendDlgItemMessage(m_Dlg
, IDC_FOURCC_MAPPINGS
, LB_ADDSTRING
, 0, (LPARAM
)szCaption
);
299 STDMETHODIMP
COggSplitPropPage::NonDelegatingQueryInterface(REFIID riid
, void **ppv
)
301 if (riid
== IID_IPropertyBag
)
303 CheckPointer(ppv
, E_POINTER
);
304 return GetInterface((IPropertyBag
*)(this), ppv
);
306 else return CBasePropertyPage::NonDelegatingQueryInterface(riid
, ppv
);
309 CUnknown
*COggSplitPropPage::CreateInstance(LPUNKNOWN pUnk
, HRESULT
* phr
)
311 return new COggSplitPropPage(pUnk
, phr
);