2010-04-25 00:31:27 +00:00
|
|
|
/*
|
2009-02-09 21:15:56 +00:00
|
|
|
* Copyright (C) 2007-2009 Gabest
|
|
|
|
* http://www.gabest.org
|
|
|
|
*
|
|
|
|
* This Program 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 2, or (at your option)
|
|
|
|
* any later version.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* This Program 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.
|
2010-04-25 00:31:27 +00:00
|
|
|
*
|
2009-02-09 21:15:56 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with GNU Make; see the file COPYING. If not, write to
|
2012-09-09 18:16:11 +00:00
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
|
2009-02-09 21:15:56 +00:00
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
2009-05-18 11:08:04 +00:00
|
|
|
#include "GSdx.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
#include "GSCaptureDlg.h"
|
|
|
|
|
2018-03-20 13:39:30 +00:00
|
|
|
#define BeginEnumSysDev(clsid, pMoniker) \
|
|
|
|
{CComPtr<ICreateDevEnum> pDevEnum4$##clsid; \
|
|
|
|
pDevEnum4$##clsid.CoCreateInstance(CLSID_SystemDeviceEnum); \
|
|
|
|
CComPtr<IEnumMoniker> pClassEnum4$##clsid; \
|
|
|
|
if(SUCCEEDED(pDevEnum4$##clsid->CreateClassEnumerator(clsid, &pClassEnum4$##clsid, 0)) \
|
|
|
|
&& pClassEnum4$##clsid) \
|
|
|
|
{ \
|
|
|
|
for(CComPtr<IMoniker> pMoniker; pClassEnum4$##clsid->Next(1, &pMoniker, 0) == S_OK; pMoniker = NULL) \
|
|
|
|
{ \
|
|
|
|
|
|
|
|
#define EndEnumSysDev }}}
|
|
|
|
|
2020-09-20 05:13:09 +00:00
|
|
|
void GSCaptureDlg::InvalidFile()
|
|
|
|
{
|
|
|
|
char tmp[512];
|
|
|
|
sprintf_s(tmp, "GSdx couldn't open file for capturing: %s.\nCapture aborted.", m_filename.c_str());
|
|
|
|
MessageBox(GetActiveWindow(), tmp, "GSdx System Message", MB_OK | MB_SETFOREGROUND);
|
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
GSCaptureDlg::GSCaptureDlg()
|
|
|
|
: GSDialog(IDD_CAPTURE)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2016-05-24 19:52:06 +00:00
|
|
|
m_width = theApp.GetConfigI("CaptureWidth");
|
|
|
|
m_height = theApp.GetConfigI("CaptureHeight");
|
|
|
|
m_filename = theApp.GetConfigS("CaptureFileName");
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int GSCaptureDlg::GetSelCodec(Codec& c)
|
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
INT_PTR data = 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-19 00:11:56 +00:00
|
|
|
if(ComboBoxGetSelData(IDC_CODECS, data))
|
2009-06-03 12:09:04 +00:00
|
|
|
{
|
|
|
|
if(data == 0) return 2;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
c = *(Codec*)data;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
if(!c.filter)
|
|
|
|
{
|
|
|
|
c.moniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.filter);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
if(!c.filter) return 0;
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
return 1;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
return 0;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2017-11-08 09:00:46 +00:00
|
|
|
void GSCaptureDlg::UpdateConfigureButton()
|
|
|
|
{
|
|
|
|
Codec c;
|
|
|
|
bool enable = false;
|
|
|
|
|
|
|
|
if (GetSelCodec(c) != 1)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(m_hWnd, IDC_CONFIGURE), false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CComQIPtr<ISpecifyPropertyPages> pSPP = c.filter)
|
|
|
|
{
|
|
|
|
CAUUID caGUID;
|
|
|
|
memset(&caGUID, 0, sizeof(caGUID));
|
|
|
|
enable = SUCCEEDED(pSPP->GetPages(&caGUID));
|
|
|
|
}
|
|
|
|
else if (CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.filter)
|
|
|
|
{
|
|
|
|
enable = pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, nullptr) == S_OK;
|
|
|
|
}
|
|
|
|
EnableWindow(GetDlgItem(m_hWnd, IDC_CONFIGURE), enable);
|
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
void GSCaptureDlg::OnInit()
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
__super::OnInit();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
SetTextAsInt(IDC_WIDTH, m_width);
|
|
|
|
SetTextAsInt(IDC_HEIGHT, m_height);
|
|
|
|
SetText(IDC_FILENAME, m_filename.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
m_codecs.clear();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2016-05-24 19:52:06 +00:00
|
|
|
_bstr_t selected = theApp.GetConfigS("CaptureVideoCodecDisplayName").c_str();
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-19 00:11:56 +00:00
|
|
|
ComboBoxAppend(IDC_CODECS, "Uncompressed", 0, true);
|
2011-05-02 21:04:33 +00:00
|
|
|
ComboBoxAppend(IDC_COLORSPACE, "YUY2", 0, true);
|
|
|
|
ComboBoxAppend(IDC_COLORSPACE, "RGB32", 1, false);
|
|
|
|
|
2011-02-07 01:59:05 +00:00
|
|
|
CoInitialize(0); // this is obviously wrong here, each thread should call this on start, and where is CoUninitalize?
|
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
BeginEnumSysDev(CLSID_VideoCompressorCategory, moniker)
|
|
|
|
{
|
|
|
|
Codec c;
|
2009-06-03 12:09:04 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
c.moniker = moniker;
|
|
|
|
|
2017-05-26 15:26:46 +00:00
|
|
|
std::wstring prefix;
|
2009-06-03 12:09:04 +00:00
|
|
|
|
|
|
|
LPOLESTR str = NULL;
|
|
|
|
|
|
|
|
if(FAILED(moniker->GetDisplayName(NULL, NULL, &str)))
|
2009-02-09 21:15:56 +00:00
|
|
|
continue;
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
if(wcsstr(str, L"@device:dmo:")) prefix = L"(DMO) ";
|
|
|
|
else if(wcsstr(str, L"@device:sw:")) prefix = L"(DS) ";
|
|
|
|
else if(wcsstr(str, L"@device:cm:")) prefix = L"(VfW) ";
|
|
|
|
|
|
|
|
c.DisplayName = str;
|
|
|
|
|
|
|
|
CoTaskMemFree(str);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
CComPtr<IPropertyBag> pPB;
|
2009-06-03 12:09:04 +00:00
|
|
|
|
|
|
|
if(FAILED(moniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
|
|
|
|
continue;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2013-07-01 21:28:58 +00:00
|
|
|
_variant_t var;
|
2009-06-03 12:09:04 +00:00
|
|
|
|
2013-07-01 21:28:58 +00:00
|
|
|
if(FAILED(pPB->Read(_bstr_t(_T("FriendlyName")), &var, NULL)))
|
2009-02-09 21:15:56 +00:00
|
|
|
continue;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
c.FriendlyName = prefix + var.bstrVal;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-11 08:18:00 +00:00
|
|
|
m_codecs.push_back(c);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2020-09-19 00:56:27 +00:00
|
|
|
ComboBoxAppend(IDC_CODECS, c.FriendlyName.c_str(), (LPARAM)&m_codecs.back(), c.DisplayName == selected);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-06-03 12:09:04 +00:00
|
|
|
EndEnumSysDev
|
2017-11-08 09:00:46 +00:00
|
|
|
UpdateConfigureButton();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
switch (id)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2020-08-31 21:26:20 +00:00
|
|
|
case IDC_FILENAME:
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(m_hWnd, IDOK), GetText(IDC_FILENAME).length() != 0);
|
|
|
|
return false;
|
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
case IDC_BROWSE:
|
|
|
|
{
|
|
|
|
if (code == BN_CLICKED)
|
|
|
|
{
|
|
|
|
char buff[MAX_PATH] = { 0 };
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2017-11-08 08:31:46 +00:00
|
|
|
OPENFILENAME ofn;
|
|
|
|
memset(&ofn, 0, sizeof(ofn));
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2017-11-08 08:31:46 +00:00
|
|
|
ofn.lStructSize = sizeof(ofn);
|
|
|
|
ofn.hwndOwner = m_hWnd;
|
|
|
|
ofn.lpstrFile = buff;
|
|
|
|
ofn.nMaxFile = countof(buff);
|
|
|
|
ofn.lpstrFilter = "Avi files (*.avi)\0*.avi\0";
|
|
|
|
ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2017-11-08 08:31:46 +00:00
|
|
|
strcpy(ofn.lpstrFile, m_filename.c_str());
|
|
|
|
if (GetSaveFileName(&ofn))
|
|
|
|
{
|
|
|
|
m_filename = ofn.lpstrFile;
|
|
|
|
SetText(IDC_FILENAME, m_filename.c_str());
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2017-11-08 08:31:46 +00:00
|
|
|
return true;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
break;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
case IDC_CONFIGURE:
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
if (code == BN_CLICKED)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
Codec c;
|
|
|
|
if (GetSelCodec(c) == 1)
|
2009-06-03 12:09:04 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
if (CComQIPtr<ISpecifyPropertyPages> pSPP = c.filter)
|
2009-06-03 12:09:04 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
CAUUID caGUID;
|
|
|
|
memset(&caGUID, 0, sizeof(caGUID));
|
|
|
|
|
|
|
|
if (SUCCEEDED(pSPP->GetPages(&caGUID)))
|
|
|
|
{
|
|
|
|
IUnknown* lpUnk = NULL;
|
|
|
|
pSPP.QueryInterface(&lpUnk);
|
|
|
|
OleCreatePropertyFrame(m_hWnd, 0, 0, c.FriendlyName.c_str(), 1, (IUnknown**)&lpUnk, caGUID.cElems, caGUID.pElems, 0, 0, NULL);
|
|
|
|
lpUnk->Release();
|
|
|
|
|
|
|
|
if (caGUID.pElems)
|
|
|
|
CoTaskMemFree(caGUID.pElems);
|
|
|
|
}
|
2009-06-03 12:09:04 +00:00
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
else if (CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.filter)
|
2009-06-03 12:09:04 +00:00
|
|
|
{
|
2017-11-08 08:31:46 +00:00
|
|
|
if (pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
|
|
|
|
pAMVfWCD->ShowDialog(VfwCompressDialog_Config, m_hWnd);
|
2009-06-03 12:09:04 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
return true;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
break;
|
2009-06-03 12:09:04 +00:00
|
|
|
}
|
2017-11-08 08:31:46 +00:00
|
|
|
case IDC_CODECS:
|
|
|
|
{
|
2017-11-08 09:00:46 +00:00
|
|
|
UpdateConfigureButton();
|
2017-11-08 08:31:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case IDOK:
|
2009-06-03 12:09:04 +00:00
|
|
|
{
|
|
|
|
m_width = GetTextAsInt(IDC_WIDTH);
|
|
|
|
m_height = GetTextAsInt(IDC_HEIGHT);
|
|
|
|
m_filename = GetText(IDC_FILENAME);
|
2016-07-13 18:35:43 +00:00
|
|
|
ComboBoxGetSelData(IDC_COLORSPACE, m_colorspace);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
Codec c;
|
2010-03-02 12:55:26 +00:00
|
|
|
int ris = GetSelCodec(c);
|
2017-11-08 08:31:46 +00:00
|
|
|
if (ris == 0)
|
2009-06-03 12:09:04 +00:00
|
|
|
return false;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
m_enc = c.filter;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
theApp.SetConfig("CaptureWidth", m_width);
|
|
|
|
theApp.SetConfig("CaptureHeight", m_height);
|
|
|
|
theApp.SetConfig("CaptureFileName", m_filename.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-03-02 12:55:26 +00:00
|
|
|
if (ris != 2)
|
2015-09-20 16:20:56 +00:00
|
|
|
theApp.SetConfig("CaptureVideoCodecDisplayName", c.DisplayName);
|
2010-03-02 12:55:26 +00:00
|
|
|
else
|
|
|
|
theApp.SetConfig("CaptureVideoCodecDisplayName", "");
|
2017-11-08 08:31:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2009-06-03 12:09:04 +00:00
|
|
|
}
|
|
|
|
return __super::OnCommand(hWnd, id, code);
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|