Merge pull request #3293 from a-wi:MSMF_remove_ATL_dependency_v3
This commit is contained in:
commit
478dd01c91
@ -72,6 +72,7 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
#pragma warning(disable:4503)
|
#pragma warning(disable:4503)
|
||||||
#pragma comment(lib, "mfplat")
|
#pragma comment(lib, "mfplat")
|
||||||
#pragma comment(lib, "mf")
|
#pragma comment(lib, "mf")
|
||||||
@ -81,6 +82,7 @@
|
|||||||
#if (WINVER >= 0x0602) // Available since Win 8
|
#if (WINVER >= 0x0602) // Available since Win 8
|
||||||
#pragma comment(lib, "MinCore_Downlevel")
|
#pragma comment(lib, "MinCore_Downlevel")
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <mferror.h>
|
#include <mferror.h>
|
||||||
|
|
||||||
@ -260,7 +262,7 @@ public:
|
|||||||
#include "ppltasks_winrt.h"
|
#include "ppltasks_winrt.h"
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <atlbase.h>
|
#include <comdef.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct IMFMediaType;
|
struct IMFMediaType;
|
||||||
|
@ -594,27 +594,65 @@ hr = orig.As(&obj);
|
|||||||
#define _ComPtr Microsoft::WRL::ComPtr
|
#define _ComPtr Microsoft::WRL::ComPtr
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#define _COM_SMARTPTR_DECLARE(T,var) T ## Ptr var
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class ComPtr : public ATL::CComPtr<T>
|
class ComPtr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ComPtr() throw()
|
ComPtr() throw()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ComPtr(int nNull) throw() :
|
ComPtr(int nNull) throw()
|
||||||
CComPtr<T>((T*)nNull)
|
{
|
||||||
|
assert(nNull == 0);
|
||||||
|
p = NULL;
|
||||||
|
}
|
||||||
|
ComPtr(T* lp) throw()
|
||||||
|
{
|
||||||
|
p = lp;
|
||||||
|
}
|
||||||
|
ComPtr(_In_ const ComPtr<T>& lp) throw()
|
||||||
|
{
|
||||||
|
p = lp.p;
|
||||||
|
}
|
||||||
|
virtual ~ComPtr()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ComPtr(T* lp) throw() :
|
|
||||||
CComPtr<T>(lp)
|
|
||||||
|
|
||||||
|
T** operator&() throw()
|
||||||
{
|
{
|
||||||
|
assert(p == NULL);
|
||||||
|
return p.operator&();
|
||||||
}
|
}
|
||||||
ComPtr(_In_ const CComPtr<T>& lp) throw() :
|
T* operator->() const throw()
|
||||||
CComPtr<T>(lp.p)
|
|
||||||
{
|
{
|
||||||
|
assert(p != NULL);
|
||||||
|
return p.operator->();
|
||||||
|
}
|
||||||
|
bool operator!() const throw()
|
||||||
|
{
|
||||||
|
return p.operator==(NULL);
|
||||||
|
}
|
||||||
|
bool operator==(_In_opt_ T* pT) const throw()
|
||||||
|
{
|
||||||
|
return p.operator==(pT);
|
||||||
|
}
|
||||||
|
// For comparison to NULL
|
||||||
|
bool operator==(int nNull) const
|
||||||
|
{
|
||||||
|
assert(nNull == 0);
|
||||||
|
return p.operator==(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(_In_opt_ T* pT) const throw()
|
||||||
|
{
|
||||||
|
return p.operator!=(pT);
|
||||||
|
}
|
||||||
|
operator bool()
|
||||||
|
{
|
||||||
|
return p.operator!=(NULL);
|
||||||
}
|
}
|
||||||
virtual ~ComPtr() {}
|
|
||||||
|
|
||||||
T* const* GetAddressOf() const throw()
|
T* const* GetAddressOf() const throw()
|
||||||
{
|
{
|
||||||
@ -628,7 +666,7 @@ public:
|
|||||||
|
|
||||||
T** ReleaseAndGetAddressOf() throw()
|
T** ReleaseAndGetAddressOf() throw()
|
||||||
{
|
{
|
||||||
InternalRelease();
|
p.Release();
|
||||||
return &p;
|
return &p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,27 +674,38 @@ public:
|
|||||||
{
|
{
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
ComPtr& operator=(decltype(__nullptr)) throw()
|
|
||||||
|
// Attach to an existing interface (does not AddRef)
|
||||||
|
void Attach(_In_opt_ T* p2) throw()
|
||||||
{
|
{
|
||||||
InternalRelease();
|
p.Attach(p2);
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
ComPtr& operator=(_In_ const int nNull) throw()
|
// Detach the interface (does not Release)
|
||||||
|
T* Detach() throw()
|
||||||
{
|
{
|
||||||
ASSERT(nNull == 0);
|
return p.Detach();
|
||||||
(void)nNull;
|
|
||||||
InternalRelease();
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
unsigned long Reset()
|
_Check_return_ HRESULT CopyTo(_Deref_out_opt_ T** ppT) throw()
|
||||||
{
|
{
|
||||||
return InternalRelease();
|
assert(ppT != NULL);
|
||||||
|
if (ppT == NULL)
|
||||||
|
return E_POINTER;
|
||||||
|
*ppT = p;
|
||||||
|
if (p != NULL)
|
||||||
|
p->AddRef();
|
||||||
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reset()
|
||||||
|
{
|
||||||
|
p.Release();
|
||||||
|
}
|
||||||
|
|
||||||
// query for U interface
|
// query for U interface
|
||||||
template<typename U>
|
template<typename U>
|
||||||
HRESULT As(_Inout_ U** lp) const throw()
|
HRESULT As(_Inout_ U** lp) const throw()
|
||||||
{
|
{
|
||||||
return p->QueryInterface(__uuidof(U), (void**)lp);
|
return p->QueryInterface(__uuidof(U), reinterpret_cast<void**>(lp));
|
||||||
}
|
}
|
||||||
// query for U interface
|
// query for U interface
|
||||||
template<typename U>
|
template<typename U>
|
||||||
@ -665,19 +714,8 @@ public:
|
|||||||
return p->QueryInterface(__uuidof(U), reinterpret_cast<void**>(lp->ReleaseAndGetAddressOf()));
|
return p->QueryInterface(__uuidof(U), reinterpret_cast<void**>(lp->ReleaseAndGetAddressOf()));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
unsigned long InternalRelease() throw()
|
_COM_SMARTPTR_TYPEDEF(T, __uuidof(T));
|
||||||
{
|
_COM_SMARTPTR_DECLARE(T, p);
|
||||||
unsigned long ref = 0;
|
|
||||||
T* temp = p;
|
|
||||||
|
|
||||||
if (temp != nullptr)
|
|
||||||
{
|
|
||||||
p = nullptr;
|
|
||||||
ref = temp->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _ComPtr ComPtr
|
#define _ComPtr ComPtr
|
||||||
@ -2256,6 +2294,11 @@ public:
|
|||||||
// succeed but return a nullptr pointer. By default, the list does not allow nullptr
|
// succeed but return a nullptr pointer. By default, the list does not allow nullptr
|
||||||
// pointers.
|
// pointers.
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable: 4127) // constant expression
|
||||||
|
#endif
|
||||||
|
|
||||||
template <class T, bool NULLABLE = FALSE>
|
template <class T, bool NULLABLE = FALSE>
|
||||||
class ComPtrList : public List<T*>
|
class ComPtrList : public List<T*>
|
||||||
{
|
{
|
||||||
@ -2346,6 +2389,10 @@ protected:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Be sure to declare webcam device capability in manifest
|
/* Be sure to declare webcam device capability in manifest
|
||||||
For better media capture support, add the following snippet with correct module name to the project manifest
|
For better media capture support, add the following snippet with correct module name to the project manifest
|
||||||
(videoio needs DLL activation class factoryentry points):
|
(videoio needs DLL activation class factoryentry points):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user