Skip to content

Commit

Permalink
fixes #284; implements loading from ipersistpropertybag option with l…
Browse files Browse the repository at this point in the history
…oading GRFX files
  • Loading branch information
roman380 committed Dec 9, 2015
1 parent fa01b47 commit 0459f7b
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions src/graph_config_xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,79 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
return TRUE;
}

////////////////////////////////////////////////////////
// CPropertyBag

// TODO: Possibly make it a normal COM class instead of quick patch

class CPropertyBag :
public IPropertyBag
{
private:
XML::XMLList& m_List;

public:
// CPropertyBag
CPropertyBag(XML::XMLList& List) :
m_List(List)
{
}

// IUnknown
STDMETHOD(QueryInterface)(REFIID, VOID**) override
{
return E_NOINTERFACE;
}
STDMETHOD_(ULONG, AddRef)() override
{
return 2;
}
STDMETHOD_(ULONG, Release)() override
{
return 1;
}

// IPropertyBag
STDMETHOD(Read)(LPCOLESTR pszPropertyName, VARIANT* pvValue, IErrorLog* pErrorLog) override
{
ATLTRACE(atlTraceCOM, 4, _T("pszPropertyName \"%s\"\n"), CString(pszPropertyName));
_ATLTRY
{
ATLENSURE_THROW(pszPropertyName, E_INVALIDARG);
ATLENSURE_THROW(pvValue, E_POINTER);
pErrorLog;
const CString sPropertyNameT(pszPropertyName);
BOOL bFound = FALSE;
for(auto&& pNode: m_List)
{
const CString sName = pNode->GetValue(_T("name"));
if(sName.CompareNoCase(sPropertyNameT) == 0)
{
const CString sValue = pNode->GetValue(_T("value"));
CComVariant vValue(sValue);
if(pvValue->vt > VT_NULL)
ATLENSURE_SUCCEEDED(vValue.ChangeType(pvValue->vt));
reinterpret_cast<CComVariant&>(*pvValue) = vValue;
bFound = TRUE;
break;
}
}
//if(!bFound)
// return E_INVALIDARG;
}
_ATLCATCH(Exception)
{
//return Exception;
return COleException::Process(Exception);
}
return S_OK;
}
STDMETHOD(Write)(LPCOLESTR pszPropertyName, VARIANT* pvValue) override
{
pszPropertyName; pvValue;
return E_NOTIMPL;
}
};

//-------------------------------------------------------------------------
//
Expand Down Expand Up @@ -80,6 +153,7 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
}
}

#pragma region ifilesinkfilter
PRESET("ifilesinkfilter")
// <ifilesinkfilter dest="d:\sga.avi"/>

Expand All @@ -100,7 +174,9 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
hr = fsink->SetFileName(filename, NULL);
}
}
#pragma endregion

#pragma region ipersiststream
PRESET("ipersiststream")
// <ipersiststream encoding="base64" data="MAAwADAAMAAwADAAMAAwADAAMAAwACAA="/>

Expand Down Expand Up @@ -149,7 +225,28 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
if (stream_hglobal)
GlobalFree(stream_hglobal);
}
#pragma endregion

#pragma region ipersistpropertybag
PRESET("ipersistpropertybag")
// <ipersistpropertybag><property name="Name" value="Value" />...</ipersistpropertybag>

_ATLTRY
{
const CComQIPtr<IPersistPropertyBag> pPersistPropertyBag(filter);
ATLENSURE_THROW(pPersistPropertyBag, E_NOINTERFACE);
CPropertyBag PropertyBag(conf->nodes);
ATLENSURE_SUCCEEDED(pPersistPropertyBag->Load(&PropertyBag, NULL));
}
_ATLCATCH(Exception)
{
//return Exception;
return COleException::Process(Exception);
}

#pragma endregion

#pragma region imonogram*
PRESET("imonogramgraphsink")
// <imonogramgraphsink name="video" blocking="1"/>

Expand Down Expand Up @@ -476,6 +573,7 @@ GRAPHSTUDIO_NAMESPACE_START // cf stdafx.h for explanation
CString url = conf->GetValue(_T("url"));
hr = httpsrc->SetURL(url.GetBuffer());
}
#pragma endregion

PRESET("iambuffernegotiation")
// <iambuffernegotiation pin="Capture" latency="40"/>
Expand Down

0 comments on commit 0459f7b

Please sign in to comment.