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"
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
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
|
|
|
|
2017-05-26 15:26:46 +00:00
|
|
|
std::string s{c.FriendlyName.begin(), c.FriendlyName.end()};
|
2009-05-11 08:18:00 +00:00
|
|
|
|
2015-09-20 16:20:56 +00:00
|
|
|
ComboBoxAppend(IDC_CODECS, s.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
|
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
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
if(id == IDC_BROWSE && code == BN_CLICKED)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
char buff[MAX_PATH] = {0};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
OPENFILENAME ofn;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
memset(&ofn, 0, sizeof(ofn));
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +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
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
strcpy(ofn.lpstrFile, m_filename.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
if(GetSaveFileName(&ofn))
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
m_filename = ofn.lpstrFile;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
SetText(IDC_FILENAME, m_filename.c_str());
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-06-03 12:09:04 +00:00
|
|
|
|
|
|
|
return true;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
2009-06-03 12:09:04 +00:00
|
|
|
else if(id == IDC_CONFIGURE && code == BN_CLICKED)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
Codec c;
|
|
|
|
|
|
|
|
if(GetSelCodec(c) == 1)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-06-03 12:09:04 +00:00
|
|
|
if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.filter)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.filter)
|
|
|
|
{
|
|
|
|
if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
|
|
|
|
{
|
|
|
|
pAMVfWCD->ShowDialog(VfwCompressDialog_Config, m_hWnd);
|
|
|
|
}
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if(id == IDOK)
|
|
|
|
{
|
|
|
|
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;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2010-03-02 12:55:26 +00:00
|
|
|
int ris = GetSelCodec(c);
|
|
|
|
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", "");
|
|
|
|
}
|
2009-06-03 12:09:04 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-06-03 12:09:04 +00:00
|
|
|
return __super::OnCommand(hWnd, id, code);
|
2010-04-25 00:31:27 +00:00
|
|
|
}
|